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.

104 lines
3.2KB

  1. /* This file is part of the KDE project
  2. Copyright (C) 2003 Norbert Andres, nandres@web.de
  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_style_manager__
  17. #define __kspread_style_manager__
  18. #include <tqmap.h>
  19. #include <koffice_export.h>
  20. class TQDomElement;
  21. class TQDomDocument;
  22. class TQStringList;
  23. class KoGenStyles;
  24. class KoOasisStyles;
  25. namespace KSpread
  26. {
  27. class CustomStyle;
  28. class Sheet;
  29. class StyleDlg;
  30. class View;
  31. class KSPREAD_EXPORT StyleManager
  32. {
  33. public:
  34. StyleManager();
  35. ~StyleManager();
  36. TQDomElement save( TQDomDocument & doc );
  37. bool loadXML( TQDomElement const & styles );
  38. void saveOasis( KoGenStyles &mainStyles );
  39. void loadOasisStyleTemplate( KoOasisStyles& oasisStyles );
  40. CustomStyle * defaultStyle() const { return m_defaultStyle; }
  41. CustomStyle * style( TQString const & name ) const;
  42. bool checkCircle( TQString const & name, TQString const & parent );
  43. bool validateStyleName( TQString const & name, CustomStyle * style );
  44. void changeName( TQString const & oldName, TQString const & newName );
  45. void takeStyle( CustomStyle * style );
  46. void createBuiltinStyles();
  47. TQStringList styleNames() const;
  48. int count() const { return m_styles.count(); }
  49. /**
  50. * Loads OpenDocument auto styles.
  51. * The auto styles are preloaded, because an auto style could be shared
  52. * among cells. So, preloading prevents a multiple loading of the same
  53. * auto style.
  54. * This method is called before the cell loading process.
  55. * @param oasisStyles repository of styles
  56. * @return a hash of styles with the OpenDocument internal name as key
  57. */
  58. TQDict<Style> loadOasisAutoStyles( KoOasisStyles& oasisStyles );
  59. /**
  60. * Releases unused auto styles.
  61. * If there are auto styles, which are not used by any cell (uncommon case)
  62. * this method makes sure, that these get deleted.
  63. * This method is called after the cell loading porcess.
  64. * @param autoStyles a hash of styles with the OpenDocument internal name as
  65. * key
  66. * @see loadOasisAutoStyles
  67. */
  68. void releaseUnusedAutoStyles( TQDict<Style> autoStyles );
  69. private:
  70. friend class StyleDlg;
  71. friend class View;
  72. class Styles : public TQMap<TQString, CustomStyle *> {};
  73. CustomStyle * m_defaultStyle;
  74. Styles m_styles; // builtin and custom made styles
  75. // Same styles as above, but with the internal OpenDocument name as key.
  76. // NOTE: Temporary! Only valid while loading OpenDocument files.
  77. Styles m_oasisStyles;
  78. };
  79. } // namespace KSpread
  80. #endif