File indexing completed on 2024-05-12 16:35:36
0001 /* This file is part of the KDE project 0002 0003 Copyright 2006 Fredrik Edemar <f_edemar@linux.se> 0004 Copyright 2000, 2003 Laurent Montel <montel@kde.org> 0005 Copyright 2002-2003 Joseph Wenninger <jowenn@kde.org> 0006 Copyright 2002 Philipp Mueller <philipp.mueller@gmx.de> 0007 Copyright 2002 Ariya Hidayat <ariya@kde.org> 0008 Copyright 2002 John Dailey <dailey@vt.edu> 0009 Copyright 1999 Torben Weis <weis@kde.org> 0010 0011 This library is free software; you can redistribute it and/or 0012 modify it under the terms of the GNU Library General Public 0013 License as published by the Free Software Foundation; either 0014 version 2 of the License, or (at your option) any later version. 0015 0016 This library is distributed in the hope that it will be useful, 0017 but WITHOUT ANY WARRANTY; without even the implied warranty of 0018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0019 Library General Public License for more details. 0020 0021 You should have received a copy of the GNU Library General Public License 0022 along with this library; see the file COPYING.LIB. If not, write to 0023 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0024 Boston, MA 02110-1301, USA. 0025 */ 0026 0027 #ifndef CALLIGRA_SHEETS_SHEET_ADAPTOR 0028 #define CALLIGRA_SHEETS_SHEET_ADAPTOR 0029 0030 #ifndef QT_NO_DBUS 0031 #include <QDBusAbstractAdaptor> 0032 #include <QString> 0033 0034 #include "sheets_common_export.h" 0035 0036 namespace Calligra 0037 { 0038 namespace Sheets 0039 { 0040 class Damage; 0041 class Sheet; 0042 0043 class CALLIGRA_SHEETS_COMMON_EXPORT SheetAdaptor : public QDBusAbstractAdaptor 0044 { 0045 Q_OBJECT 0046 Q_CLASSINFO("D-Bus Interface", "org.kde.calligra.spreadsheet.sheet") 0047 public: 0048 explicit SheetAdaptor(Sheet*); 0049 ~SheetAdaptor() override; 0050 0051 public Q_SLOTS: // METHODS 0052 0053 /** Return the cellname for x,y (where x is the row and y is the column). For 0054 example for x=5 and y=2 the string "B5" got returned. */ 0055 virtual QString cellName(int x, int y); 0056 /** Return the x,y-point for the cellname. */ 0057 virtual QPoint cellLocation(const QString& cellname); 0058 /** Return the row-number for the cellname. For example for the cellname "B5" 0059 the integer 5 got returned. */ 0060 virtual int cellRow(const QString& cellname); 0061 /** Return the column-number for the cellname. For example for the cellname "B5" 0062 the integer 2 got returned. */ 0063 virtual int cellColumn(const QString& cellname); 0064 0065 /** Return the text for the row x and for the column y. */ 0066 virtual QString text(int x, int y); 0067 /** Return the text for a cellname. */ 0068 virtual QString text(const QString& cellname); 0069 /** Set the text of the cell with row x and column y. If the parse argument is 0070 true, the passed text got parsed (e.g. a text like "123" will be recognised 0071 as numeric value. */ 0072 virtual bool setText(int x, int y, const QString& text, bool parse = true); 0073 /** Set the text of the cell defined with cellname. */ 0074 virtual bool setText(const QString& cellname, const QString& text, bool parse = true); 0075 0076 /** Return the value the cell at row x and column y has. The returned value is 0077 a variant and could be e.g. a number, a bool or a text depending on the format 0078 and the content the cell has. */ 0079 virtual QVariant value(int x, int y); 0080 /** Return the value for the cell defined with cellname. */ 0081 virtual QVariant value(const QString& cellname); 0082 /** Set the value in the cell at row x and column y. */ 0083 virtual bool setValue(int x, int y, const QVariant& value); 0084 /** Set the value in the cell defined with cellname. */ 0085 virtual bool setValue(const QString& cellname, const QVariant& value); 0086 0087 /** Return the name of the sheet. */ 0088 virtual QString sheetName() const; 0089 /** Set the name of the sheet. */ 0090 virtual bool setSheetName(const QString & name); 0091 0092 //virtual QString column( int _col ); 0093 //virtual QString row( int _row ); 0094 0095 /** Return the position the last column on this sheet has. */ 0096 virtual int lastColumn() const; 0097 /** Return the position the last row on this sheet has. */ 0098 virtual int lastRow() const; 0099 0100 /** Inserts nbCol number of new columns at the position col. All columns which 0101 are >= col are moved to the right. */ 0102 virtual void insertColumn(int col, int nbCol = 1); 0103 /** Inserts nbRow number of new rows at the position row. All rows which 0104 are >= row are moved down. */ 0105 virtual void insertRow(int row, int nbRow = 1); 0106 /** Remove nbCol number of columns from the position col. */ 0107 virtual void removeColumn(int col, int nbCol = 1); 0108 /** Remove nbRow number of columns from the position row. */ 0109 virtual void removeRow(int row, int nbRow = 1); 0110 0111 /** Returns true if the sheet is hidden else false is returned. */ 0112 virtual bool isHidden() const; 0113 /** Hide the sheet if the argument hidden is true or show it if hidden is false. */ 0114 virtual void setHidden(bool hidden); 0115 0116 //virtual bool showGrid() const; 0117 //virtual bool showFormula() const; 0118 //virtual bool lcMode() const; 0119 //virtual bool autoCalc() const; 0120 //virtual bool showColumnNumber() const; 0121 //virtual bool hideZero() const; 0122 //virtual bool firstLetterUpper() const; 0123 //virtual void setShowPageOutline( bool b ); 0124 0125 /** Return the height the paper of the printer has. */ 0126 virtual float paperHeight() const; 0127 /** Set the height the paper of the printer has. */ 0128 virtual void setPrinterHeight(float height); 0129 /** Return the width the paper of the printer has. */ 0130 virtual float paperWidth() const; 0131 /** Set the width the paper of the printer has. */ 0132 virtual void setPaperWidth(float width); 0133 /** Return the left border the paper of the printer has. */ 0134 virtual float paperLeftBorder() const; 0135 /** Return the right border the paper of the printer has. */ 0136 virtual float paperRightBorder() const; 0137 /** Return the top border the paper of the printer has. */ 0138 virtual float paperTopBorder() const; 0139 /** Return the bottom border the paper of the printer has. */ 0140 virtual float paperBottomBorder() const; 0141 /** Return the name of the paper format (like "A4" or "Letter"). */ 0142 virtual QString paperFormat() const; 0143 /** Return the name of the paper orientation (like "Portrait" or "Landscape"). */ 0144 virtual QString paperOrientation() const; 0145 /** Set the left, top, right and bottom border as well as the page format and 0146 orientation the paper of the printer has. */ 0147 virtual void setPaperLayout(float leftBorder, float topBorder, float rightBorder, float bottomBoder, const QString& format, const QString& orientation); 0148 0149 //QString printHeadLeft() const; 0150 //QString printHeadMid() const; 0151 //QString printHeadRight() const; 0152 //QString printFootLeft() const; 0153 //QString printFootMid() const; 0154 //QString printFootRight() const; 0155 //void setPrintHeaderLeft(const QString & text); 0156 //void setPrintHeaderMiddle(const QString & text); 0157 //void setPrintHeaderRight(const QString & text); 0158 //void setPrintFooterLeft(const QString & text); 0159 //void setPrintFooterMiddle(const QString & text); 0160 //void setPrintFooterRight(const QString & text); 0161 0162 //NOTE: don't publish "QByteArray password()" cause that may introduce insecure situations... 0163 /** Return true if passwd is the correct password. */ 0164 virtual bool checkPassword(const QByteArray& passwd) const; 0165 /** Return true if the sheet/document is protected. */ 0166 virtual bool isProtected() const; 0167 /** Protect the document with the password passwd. */ 0168 virtual void setProtected(const QByteArray& passwd); 0169 0170 Q_SIGNALS: 0171 0172 /** This signal got emitted if the name of the sheet changed. */ 0173 void nameChanged(); 0174 /** This signal got emitted if the sheet got shown. */ 0175 void showChanged(); 0176 /** This signal got emitted if the sheet got hidden. */ 0177 void hideChanged(); 0178 0179 private Q_SLOTS: 0180 /** 0181 * \ingroup Damages 0182 * Handles changes of the sheet name and visibility. 0183 */ 0184 void handleDamages(const QList<Damage*>& damages); 0185 0186 private: 0187 Sheet* m_sheet; 0188 QByteArray ident; 0189 }; 0190 0191 } // namespace Sheets 0192 } // namespace Calligra 0193 #endif 0194 0195 #endif // CALLIGRA_SHEETS_SHEET_ADAPTOR