30#include "kspread_sheet.h"
31#include "kspread_sheetprint.h"
32#include "kspread_util.h"
33#include "kspread_doc.h"
35#include <dcopclient.h>
36#include <tdeapplication.h>
39#include "KSpreadCellIface.h"
42#include "KSpreadTableIface.h"
52class KSpread::CellProxy :
public DCOPObjectProxy
55 CellProxy( Sheet* sheet,
const TQCString& prefix );
58 virtual bool process(
const TQCString& obj,
const TQCString& fun,
const TQByteArray& data,
59 TQCString& replyType, TQByteArray &replyData );
67KSpread::CellProxy::CellProxy( Sheet* sheet,
const TQCString& prefix )
68 : DCOPObjectProxy( kapp->dcopClient() ), m_prefix( prefix )
70 m_cell =
new CellIface;
74KSpread::CellProxy::~CellProxy()
79bool KSpread::CellProxy::process(
const TQCString& obj,
const TQCString& fun,
const TQByteArray& data,
80 TQCString& replyType, TQByteArray &replyData )
83 kdDebug()<<
"CellProxy::process: requested object:"<<obj<<endl;
84 kdDebug()<<
"CellProxy::process: prefix:"<<m_prefix<<endl;
85 if ( strncmp( m_prefix.data(), obj.data(), m_prefix.length() ) != 0 )
88 if ( fun ==
"functions()" ) {
89 replyType =
"QCStringList";
90 TQDataStream reply( replyData, IO_WriteOnly );
91 QCStringList repList=m_cell->functions();
96 TQString cellID=TQString::fromUtf8(obj.data() + m_prefix.length());
97 cellID=m_sheet->sheetName()+
"!"+cellID;
99 kdDebug()<<
"CellProxy::process: cellID="<<cellID<<endl;
102 if ( p.pos().x()<0 ) {
103 kdDebug(36001)<<
"CellProyxy::process: resulting Point is not valid"<<endl;
107 kdDebug(36001)<<
"all checks finsihed, trying to access cell (x):"<<p.pos().x()<<endl;
109 m_cell->setCell( m_sheet, p.pos() );
110 return m_cell->process( fun, data, replyType, replyData );
119SheetIface::SheetIface( Sheet* t )
125 sheetNameHasChanged();
129void SheetIface::sheetNameHasChanged() {
131 TQObject *currentObj = m_sheet;
132 while (currentObj != 0L) {
133 ident.prepend( currentObj->name() );
135 currentObj = currentObj->parent();
137 if ( ident[0] ==
'/' )
138 ident = ident.mid(1);
140 if (qstrcmp(ident,objId())!=0) {
144 TQCString str = objId();
146 kdDebug(36001)<<
"SheetIface::tableNameHasChanged(): new DCOP-ID:"<<objId()<<endl;
147 m_proxy =
new CellProxy( m_sheet, str );
153SheetIface::~SheetIface()
158DCOPRef SheetIface::cell(
int x,
int y )
169 TQCString str = objId() +
'/' +
Cell::name( x, y ).latin1();
171 return DCOPRef( kapp->dcopClient()->appId(), str );
174DCOPRef SheetIface::cell(
const TQString& name )
176 TQCString str = objId();
178 str += name.latin1();
180 return DCOPRef( kapp->dcopClient()->appId(), str );
183DCOPRef SheetIface::column(
int _col )
188 return DCOPRef( kapp->dcopClient()->appId(),
189 m_sheet->nonDefaultColumnFormat( _col )->dcopObject()->objId() );
193DCOPRef SheetIface::row(
int _row )
198 return DCOPRef( kapp->dcopClient()->appId(),
199 m_sheet->nonDefaultRowFormat( _row )->dcopObject()->objId() );
203TQString SheetIface::name()
const
205 return m_sheet->sheetName();
209int SheetIface::maxColumn()
const
211 return m_sheet->maxColumn();
215bool SheetIface::areaHasNoContent(TQRect area)
const
217 kdDebug(36001) <<
"SheetIface::areaHasNoContent("<<area<<
");"<<endl;
218 return m_sheet->areaIsEmpty(area);
221bool SheetIface::areaHasNoComments(TQRect area)
const
223 return m_sheet->areaIsEmpty(area, Sheet::Comment);
226int SheetIface::maxRow()
const
228 return m_sheet->maxRow();
231bool SheetIface::processDynamic(
const TQCString& fun,
const TQByteArray&,
232 TQCString& replyType, TQByteArray &replyData )
234 kdDebug(36001) <<
"Calling '" << fun.data() <<
"'" << endl;
236 uint len = fun.length();
240 if ( fun[ len - 1 ] !=
')' || fun[ len - 2 ] !=
'(' )
244 Point p( fun.left( len - 2 ).data() );
248 TQCString str = objId() +
"/" + fun.left( len - 2 );
250 replyType =
"DCOPRef";
251 TQDataStream out( replyData, IO_WriteOnly );
252 out << DCOPRef( kapp->dcopClient()->appId(), str );
256bool SheetIface::setSheetName(
const TQString & name)
258 return m_sheet->setSheetName( name);
261bool SheetIface::insertColumn(
int col,
int nbCol )
263 return m_sheet->insertColumn(col,nbCol);
266bool SheetIface::insertRow(
int row,
int nbRow)
268 return m_sheet->insertRow(row,nbRow);
271void SheetIface::removeColumn(
int col,
int nbCol )
273 m_sheet->removeColumn( col,nbCol );
276void SheetIface::removeRow(
int row,
int nbRow )
278 m_sheet->removeRow( row,nbRow );
282bool SheetIface::isHidden()
const
284 return m_sheet->isHidden();
288bool SheetIface::showGrid()
const
290 return m_sheet->getShowGrid();
293bool SheetIface::showFormula()
const
295 return m_sheet->getShowFormula();
298bool SheetIface::lcMode()
const
300 return m_sheet->getLcMode();
303bool SheetIface::autoCalc()
const
305 return m_sheet->getAutoCalc();
308bool SheetIface::showColumnNumber()
const
310 return m_sheet->getShowColumnNumber();
313bool SheetIface::hideZero()
const
315 return m_sheet->getHideZero();
318bool SheetIface::firstLetterUpper()
const
320 return m_sheet->getFirstLetterUpper();
323void SheetIface::setShowPageBorders(
bool b )
325 m_sheet->setShowPageBorders( b );
326 m_sheet->doc()->updateBorderButton();
329float SheetIface::paperHeight()
const
331 return m_sheet->print()->paperHeight();
334float SheetIface::paperWidth()
const
336 return m_sheet->print()->paperWidth();
339float SheetIface::leftBorder()
const
341 return m_sheet->print()->leftBorder();
344float SheetIface::rightBorder()
const
346 return m_sheet->print()->rightBorder();
349float SheetIface::topBorder()
const
351 return m_sheet->print()->topBorder();
354float SheetIface::bottomBorder()
const
356 return m_sheet->print()->bottomBorder();
359TQString SheetIface::paperFormatString()
const
361 return m_sheet->print()->paperFormatString();
364TQString SheetIface::headLeft()
const
366 return m_sheet->print()->headLeft();
369TQString SheetIface::headMid()
const
371 return m_sheet->print()->headMid();
374TQString SheetIface::headRight()
const
376 return m_sheet->print()->headRight();
379TQString SheetIface::footLeft()
const
381 return m_sheet->print()->footLeft();
384TQString SheetIface::footMid()
const
386 return m_sheet->print()->footMid();
389TQString SheetIface::footRight()
const
391 return m_sheet->print()->footRight();
394void SheetIface::setHeaderLeft(
const TQString & text)
396 m_sheet->print()->setHeadFootLine( text, headMid(), headRight(),
397 footLeft(), footMid(), footRight() );
400void SheetIface::setHeaderMiddle(
const TQString & text)
402 m_sheet->print()->setHeadFootLine( headLeft(), text, headRight(),
403 footLeft(), footMid(), footRight() );
407void SheetIface::setHeaderRight(
const TQString & text)
409 m_sheet->print()->setHeadFootLine( headLeft(), headMid(), text,
410 footLeft(), footMid(), footRight() );
413void SheetIface::setFooterLeft(
const TQString & text)
415 m_sheet->print()->setHeadFootLine( headLeft(), headMid(), headRight(),
416 text, footMid(), footRight() );
419void SheetIface::setFooterMiddle(
const TQString & text)
421 m_sheet->print()->setHeadFootLine( headLeft(), headMid(), headRight(),
422 footLeft(), text, footRight() );
425void SheetIface::setFooterRight(
const TQString & text)
427 m_sheet->print()->setHeadFootLine( headLeft(), headMid(), headRight(),
428 footLeft(), footMid(), text );
431bool SheetIface::isProtected()
const
433 return m_sheet->isProtected();
TQString name() const
Returns the name of the cell.
Represents the position of a single cell in a workbook.