KOffice – TDE office suite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

212 lines
5.5KB

  1. /* This file is part of the KDE project
  2. Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
  3. This library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Library General Public
  5. License as published by the Free Software Foundation; either
  6. version 2 of the License, or (at your option) any later version.
  7. This library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public License
  12. along with this library; see the file COPYING.LIB. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  14. * Boston, MA 02110-1301, USA.
  15. */
  16. #ifndef __kspread_map_h__
  17. #define __kspread_map_h__
  18. #include <tqcstring.h>
  19. #include <tqptrlist.h>
  20. #include <tqstring.h>
  21. #include <tqstringlist.h>
  22. #include <tqintdict.h>
  23. #include <tqobject.h>
  24. #include <tqdict.h>
  25. #include <koffice_export.h>
  26. class KoStore;
  27. class KoOasisLoadingContext;
  28. class KoOasisStyles;
  29. class DCOPObject;
  30. class TQDomElement;
  31. class TQDomDocument;
  32. class KoXmlWriter;
  33. class KoGenStyles;
  34. class KoOasisSettings;
  35. namespace KSpread
  36. {
  37. class Changes;
  38. class Map;
  39. class Doc;
  40. class Sheet;
  41. class GenValidationStyles;
  42. class Style;
  43. /**
  44. A map is a simple container for all sheets. Usually a complete map
  45. is saved in one file.
  46. */
  47. class KSPREAD_EXPORT Map : public TQObject
  48. {
  49. Q_OBJECT
  50. public:
  51. /**
  52. * Created an empty map.
  53. */
  54. Map(Doc* doc, const char* name = 0);
  55. /**
  56. * This deletes all sheets contained in this map.
  57. */
  58. virtual ~Map();
  59. Doc* doc() const;
  60. TQDomElement save( TQDomDocument& doc );
  61. void saveOasisSettings( KoXmlWriter &settingsWriter );
  62. void loadOasisSettings( KoOasisSettings &settings );
  63. bool saveOasis( KoXmlWriter & xmlWriter, KoGenStyles & mainStyles, KoStore *store, KoXmlWriter* manifestWriter, int &_indexObj, int &_partIndexObj );
  64. bool loadOasis( const TQDomElement& mymap, KoOasisLoadingContext& oasisContext );
  65. bool loadXML( const TQDomElement& mymap );
  66. bool loadChildren( KoStore* _store );
  67. bool saveChildren( KoStore* _store );
  68. void password( TQCString & passwd ) const { passwd = m_strPassword; }
  69. bool isProtected() const { return !m_strPassword.isNull(); }
  70. void setProtected( TQCString const & passwd );
  71. bool checkPassword( TQCString const & passwd ) const { return ( passwd == m_strPassword ); }
  72. /**
  73. * The sheet named @p _from is being moved to the sheet @p _to.
  74. * If @p _before is true @p _from is inserted before (after otherwise)
  75. * @p _to.
  76. */
  77. void moveSheet( const TQString & _from, const TQString & _to, bool _before = true );
  78. /**
  79. * searches for a sheet named @p _name
  80. * @return a pointer to the searched sheet, @c 0 if nothing was found
  81. */
  82. Sheet* findSheet( const TQString & _name );
  83. Sheet* nextSheet( Sheet* );
  84. Sheet* previousSheet( Sheet* );
  85. Sheet* initialActiveSheet()const { return m_initialActiveSheet; }
  86. int initialMarkerColumn() const { return m_initialMarkerColumn; }
  87. int initialMarkerRow() const { return m_initialMarkerRow; }
  88. double initialXOffset() const { return m_initialXOffset; }
  89. double initialYOffset() const { return m_initialYOffset; }
  90. /**
  91. * @return a pointer to a new Sheet. The Sheet is not added
  92. * to the map nor added to the GUI.
  93. */
  94. Sheet * createSheet();
  95. /** add sheet to the map, making it active */
  96. void addSheet( Sheet *_sheet );
  97. /** add a new sheet to the map, returning a pointer to it */
  98. Sheet *addNewSheet ();
  99. /**
  100. * Use the @ref #nextSheet function to get all the other sheets.
  101. * Attention: Function is not reentrant.
  102. *
  103. * @return a pointer to the first sheet in this map.
  104. */
  105. Sheet* firstSheet() { return m_lstSheets.first(); }
  106. /**
  107. * Use the previousSheet() function to get all the other sheets.
  108. * Attention: Function is not reentrant.
  109. *
  110. * @return a pointer to the last sheet in this map.
  111. */
  112. Sheet* lastSheet() { return m_lstSheets.last(); }
  113. /**
  114. * Call @ref #firstSheet first. This will set the list pointer to
  115. * the first sheet. Attention: Function is not reentrant.
  116. *
  117. * @return a pointer to the next sheet in this map.
  118. */
  119. Sheet* nextSheet() { return m_lstSheets.next(); }
  120. TQPtrList<Sheet>& sheetList() { return m_lstSheets; }
  121. /**
  122. * @return amount of sheets in this map.
  123. */
  124. int count()const { return m_lstSheets.count(); }
  125. void update();
  126. /**
  127. * Needed for the printing Extension KOffice::Print
  128. */
  129. // void draw( TQPaintDevice* _dev, long int _width, long int _height,
  130. // float _scale );
  131. virtual DCOPObject* dcopObject();
  132. void takeSheet( Sheet * sheet );
  133. void insertSheet( Sheet * sheet );
  134. TQStringList visibleSheets() const;
  135. TQStringList hiddenSheets() const;
  136. static bool respectCase;
  137. signals:
  138. /**
  139. * Emitted if a new table is added to the document.
  140. */
  141. void sig_addSheet( Sheet *_table );
  142. private:
  143. Doc* m_doc;
  144. /**
  145. * List of all sheets in this map. The list has autodelete turned on.
  146. */
  147. TQPtrList<Sheet> m_lstSheets;
  148. TQPtrList<Sheet> m_lstDeletedSheets;
  149. /**
  150. * Password to protect the map from being changed.
  151. */
  152. TQCString m_strPassword;
  153. /**
  154. * Set from the XML
  155. */
  156. Sheet * m_initialActiveSheet;
  157. int m_initialMarkerColumn;
  158. int m_initialMarkerRow;
  159. double m_initialXOffset;
  160. double m_initialYOffset;
  161. // used to give every Sheet a unique default name.
  162. int tableId;
  163. DCOPObject* m_dcop;
  164. };
  165. } // namespace KSpread
  166. #endif