1 /* AbiSource
2  *
3  * Copyright (C) 2005 INdT
4  * Author: Daniel d'Andrada T. de Carvalho <daniel.carvalho@indt.org.br>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301 USA.
20  */
21 
22 
23 #ifndef _ODE_AUTOMATICSTYLES_H_
24 #define _ODE_AUTOMATICSTYLES_H_
25 
26 // AbiWord includes
27 #include <ut_hash.h>
28 
29 // External includes
30 #include <gsf/gsf-output.h>
31 
32 // Internal classes
33 class ODe_Style_Style;
34 class ODe_Style_PageLayout;
35 class ODe_Style_List;
36 
37 /**
38  * Represents a <office:automatic-styles> element.
39  */
40 class ODe_AutomaticStyles {
41 
42 public:
43 
44     ~ODe_AutomaticStyles();
45 
46     void storeTextStyle(ODe_Style_Style*& rpTextStyle);
47     void storeParagraphStyle(ODe_Style_Style*& rpParagraphStyle);
48     void storeSectionStyle(ODe_Style_Style*& rpSectionStyle);
49     void storeGraphicStyle(ODe_Style_Style*& rpGraphicStyle);
50 
51     ODe_Style_Style* addTableStyle(const UT_UTF8String& rStyleName);
52     ODe_Style_Style* addTableColumnStyle(const UT_UTF8String& rStyleName);
53     ODe_Style_Style* addTableRowStyle(const UT_UTF8String& rStyleName);
54     ODe_Style_Style* addTableCellStyle(const UT_UTF8String& rStyleName);
55 	ODe_Style_PageLayout* addPageLayout();
56     ODe_Style_List* addListStyle();
57 
58     void addPageLayout(ODe_Style_PageLayout*& pPageLayout);
59 
getPageLayout(const gchar * pName)60     ODe_Style_PageLayout* getPageLayout(const gchar* pName) {
61         return m_pageLayouts.pick(pName);
62     };
63 
getMasterPage(const gchar * pName)64     ODe_Style_PageLayout* getMasterPage(const gchar* pName) {
65         return m_pageLayouts.pick(pName);
66     };
67 
getSectionStylesCount()68 	UT_uint32 getSectionStylesCount() const {
69         return m_sectionStyles.size();
70     }
71 
getParagraphStyles()72     UT_GenericVector<ODe_Style_Style*>* getParagraphStyles() {
73         return m_paragraphStyles.enumerate();
74     }
75 
getTextStyles()76     UT_GenericVector<ODe_Style_Style*>* getTextStyles() {
77         return m_textStyles.enumerate();
78     }
79 
getListStyles()80     UT_GenericVector<ODe_Style_List*>* getListStyles() {
81         return m_listStyles.enumerate();
82     }
83 
84     // Writes <office:automatic-styles> element.
85     void write(GsfOutput* pContentStream) const;
86 
87 private:
88     void _storeStyle(ODe_Style_Style*& rpStyle,
89                      UT_GenericStringMap<ODe_Style_Style*>& rStyles,
90                      const char* pNamingPrefix);
91 
92     UT_GenericStringMap<ODe_Style_Style*> m_textStyles;
93     UT_GenericStringMap<ODe_Style_Style*> m_paragraphStyles;
94     UT_GenericStringMap<ODe_Style_Style*> m_sectionStyles;
95     UT_GenericStringMap<ODe_Style_Style*> m_tableStyles;
96     UT_GenericStringMap<ODe_Style_Style*> m_tableColumnStyles;
97     UT_GenericStringMap<ODe_Style_Style*> m_tableRowStyles;
98     UT_GenericStringMap<ODe_Style_Style*> m_tableCellStyles;
99     UT_GenericStringMap<ODe_Style_Style*> m_graphicStyles;
100     UT_GenericStringMap<ODe_Style_PageLayout*> m_pageLayouts;
101     UT_GenericStringMap<ODe_Style_List*> m_listStyles;
102 };
103 
104 #endif //_ODE_AUTOMATICSTYLES_H_
105