Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #ifndef _XMLOFF_XMLSTYLE_HXX
21 : : #define _XMLOFF_XMLSTYLE_HXX
22 : :
23 : : #include "sal/config.h"
24 : : #include "xmloff/dllapi.h"
25 : : #include "sal/types.h"
26 : : #include <rsc/rscsfx.hxx>
27 : : #include <tools/rtti.hxx>
28 : : #include <xmloff/uniref.hxx>
29 : : #include <xmloff/xmltkmap.hxx>
30 : : #include <xmloff/xmlictxt.hxx>
31 : :
32 : : class SvXMLStylesContext_Impl;
33 : : class SvXMLUnitConverter;
34 : : class SvXMLImportPropertyMapper;
35 : :
36 : : namespace com { namespace sun { namespace star {
37 : : namespace container { class XNameContainer; }
38 : : namespace style { class XAutoStyleFamily; }
39 : : } } }
40 : :
41 : : enum XMLStyleStylesElemTokens
42 : : {
43 : : XML_TOK_STYLE_STYLE,
44 : : XML_TOK_STYLE_PAGE_MASTER,
45 : : XML_TOK_TEXT_LIST_STYLE,
46 : : XML_TOK_TEXT_OUTLINE,
47 : : XML_TOK_STYLES_GRADIENTSTYLES,
48 : : XML_TOK_STYLES_HATCHSTYLES,
49 : : XML_TOK_STYLES_BITMAPSTYLES,
50 : : XML_TOK_STYLES_TRANSGRADIENTSTYLES,
51 : : XML_TOK_STYLES_MARKERSTYLES,
52 : : XML_TOK_STYLES_DASHSTYLES,
53 : : XML_TOK_TEXT_NOTE_CONFIG,
54 : : XML_TOK_TEXT_BIBLIOGRAPHY_CONFIG,
55 : : XML_TOK_TEXT_LINENUMBERING_CONFIG,
56 : : XML_TOK_STYLE_DEFAULT_STYLE,
57 : : XML_TOK_STYLE_DEFAULT_PAGE_LAYOUT, //text grid enhancement
58 : : XML_TOK_STYLE_STYLES_ELEM_END=XML_TOK_UNKNOWN
59 : : };
60 : :
61 : : class XMLOFF_DLLPUBLIC SvXMLStyleContext : public SvXMLImportContext
62 : : {
63 : : ::rtl::OUString maName;
64 : : ::rtl::OUString maDisplayName;
65 : : ::rtl::OUString maAutoName;
66 : : ::rtl::OUString maParentName;// Will be moved to XMLPropStyle soon!!!!
67 : : ::rtl::OUString maFollow; // Will be moved to XMLPropStyle soon!!!!
68 : :
69 : : ::rtl::OUString maHelpFile; // Will be removed very soon!!!!
70 : :
71 : : sal_uInt32 mnHelpId; // Will be removed very soon!!!!
72 : : sal_uInt16 mnFamily;
73 : :
74 : : sal_Bool mbValid : 1; // Set this to false in CreateAndInsert
75 : : // if the style shouldn't be processed
76 : : // by Finish() or si somehow invalid.
77 : : sal_Bool mbNew : 1; // Set this to false in CreateAnsInsert
78 : : // if the style is already existing.
79 : : sal_Bool mbDefaultStyle : 1;
80 : :
81 : : protected:
82 : :
83 : : virtual void SetAttribute( sal_uInt16 nPrefixKey,
84 : : const ::rtl::OUString& rLocalName,
85 : : const ::rtl::OUString& rValue );
86 : :
87 : : void SetFamily( sal_uInt16 nSet ) { mnFamily = nSet; }
88 : : void SetAutoName( const ::rtl::OUString& rName ) { maAutoName = rName; }
89 : :
90 : : public:
91 : :
92 : : TYPEINFO();
93 : :
94 : : SvXMLStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
95 : : const ::rtl::OUString& rLName,
96 : : const ::com::sun::star::uno::Reference<
97 : : ::com::sun::star::xml::sax::XAttributeList >& xAttrList,
98 : : sal_uInt16 nFamily=0, sal_Bool bDefaultStyle = sal_False );
99 : :
100 : : virtual ~SvXMLStyleContext();
101 : :
102 : : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
103 : : const ::rtl::OUString& rLocalName,
104 : : const ::com::sun::star::uno::Reference<
105 : : ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
106 : :
107 : : virtual void StartElement(
108 : : const ::com::sun::star::uno::Reference<
109 : : ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
110 : :
111 : 6 : const ::rtl::OUString& GetName() const { return maName; }
112 : : const ::rtl::OUString& GetDisplayName() const { return maDisplayName.getLength() ? maDisplayName : maName; }
113 : : const ::rtl::OUString& GetAutoName() const { return maAutoName; }
114 : 845 : const ::rtl::OUString& GetParentName() const { return maParentName; }
115 : : const ::rtl::OUString& GetFollow() const { return maFollow; }
116 : :
117 : : const ::rtl::OUString& GetHelpFile() const { return maHelpFile; }
118 : : sal_uInt32 GetHelpId() const { return mnHelpId; }
119 : :
120 : 14500 : sal_uInt16 GetFamily() const { return mnFamily; }
121 : :
122 : : sal_Bool IsValid() const { return mbValid; }
123 : : void SetValid( sal_Bool b ) { mbValid = b; }
124 : :
125 : : sal_Bool IsNew() const { return mbNew; }
126 : : void SetNew( sal_Bool b ) { mbNew = b; }
127 : :
128 : : // This method is called for every default style
129 : : virtual void SetDefaults();
130 : :
131 : : // This method is called for every style. It must create it and insert
132 : : // it into the document.
133 : : virtual void CreateAndInsert( sal_Bool bOverwrite );
134 : :
135 : : // This method is called for every style. It must create it and insert
136 : : // it into the document if this hasn't happened already in CreateAndInsert().
137 : : virtual void CreateAndInsertLate( sal_Bool bOverwrite );
138 : :
139 : : // This method is called fpr every style after all styles have been
140 : : // inserted into the document.
141 : : virtual void Finish( sal_Bool bOverwrite );
142 : :
143 : 6993 : sal_Bool IsDefaultStyle() const { return mbDefaultStyle; }
144 : :
145 : : /** if this method returns true, its parent styles context
146 : : should not add it to its container.<br>
147 : : Transient styles can't be accessed from its
148 : : parent SvXMLStylesContext after theyre imported and
149 : : the methods CreateAndInsert(), CreateAndInsertLate()
150 : : and Finish() will not be called.
151 : : The default return value is false
152 : : */
153 : : virtual sal_Bool IsTransient() const;
154 : : };
155 : :
156 : : class XMLOFF_DLLPUBLIC SvXMLStylesContext : public SvXMLImportContext
157 : : {
158 : : const ::rtl::OUString msParaStyleServiceName;
159 : : const ::rtl::OUString msTextStyleServiceName;
160 : :
161 : : SvXMLStylesContext_Impl *mpImpl;
162 : : SvXMLTokenMap *mpStyleStylesElemTokenMap;
163 : :
164 : :
165 : : ::com::sun::star::uno::Reference <
166 : : ::com::sun::star::container::XNameContainer > mxParaStyles;
167 : :
168 : : ::com::sun::star::uno::Reference <
169 : : ::com::sun::star::container::XNameContainer > mxTextStyles;
170 : :
171 : : ::com::sun::star::uno::Reference <
172 : : ::com::sun::star::style::XAutoStyleFamily > mxParaAutoStyles;
173 : :
174 : : ::com::sun::star::uno::Reference <
175 : : ::com::sun::star::style::XAutoStyleFamily > mxTextAutoStyles;
176 : :
177 : : UniReference < SvXMLImportPropertyMapper > mxParaImpPropMapper;
178 : : UniReference < SvXMLImportPropertyMapper > mxTextImpPropMapper;
179 : : UniReference < SvXMLImportPropertyMapper > mxShapeImpPropMapper;
180 : : mutable UniReference < SvXMLImportPropertyMapper > mxChartImpPropMapper;
181 : : mutable UniReference < SvXMLImportPropertyMapper > mxPageImpPropMapper;
182 : :
183 : : SAL_DLLPRIVATE const SvXMLTokenMap& GetStyleStylesElemTokenMap();
184 : :
185 : : SAL_DLLPRIVATE SvXMLStylesContext(SvXMLStylesContext &); // not defined
186 : : SAL_DLLPRIVATE void operator =(SvXMLStylesContext &); // not defined
187 : :
188 : : protected:
189 : :
190 : : sal_uInt32 GetStyleCount() const;
191 : : SvXMLStyleContext *GetStyle( sal_uInt32 i );
192 : : const SvXMLStyleContext *GetStyle( sal_uInt32 i ) const;
193 : :
194 : : virtual SvXMLStyleContext *CreateStyleChildContext( sal_uInt16 nPrefix,
195 : : const ::rtl::OUString& rLocalName,
196 : : const ::com::sun::star::uno::Reference<
197 : : ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
198 : :
199 : : virtual SvXMLStyleContext *CreateStyleStyleChildContext( sal_uInt16 nFamily,
200 : : sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName,
201 : : const ::com::sun::star::uno::Reference<
202 : : ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
203 : :
204 : : virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext(
205 : : sal_uInt16 nFamily, sal_uInt16 nPrefix,
206 : : const ::rtl::OUString& rLocalName,
207 : : const ::com::sun::star::uno::Reference<
208 : : ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
209 : :
210 : : virtual sal_Bool InsertStyleFamily( sal_uInt16 nFamily ) const;
211 : :
212 : : public:
213 : : TYPEINFO();
214 : :
215 : : SvXMLStylesContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
216 : : const ::rtl::OUString& rLName,
217 : : const ::com::sun::star::uno::Reference<
218 : : ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
219 : : sal_Bool bAutomatic = sal_False );
220 : :
221 : : virtual ~SvXMLStylesContext();
222 : :
223 : : // Create child element.
224 : : virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
225 : : const ::rtl::OUString& rLocalName,
226 : : const ::com::sun::star::uno::Reference<
227 : : ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
228 : :
229 : : // This method must be overloaded to insert styles into the document.
230 : : virtual void EndElement();
231 : :
232 : : // This allows to add an SvXMLStyleContext to this context from extern
233 : : void AddStyle(SvXMLStyleContext& rNew);
234 : :
235 : : const SvXMLStyleContext *FindStyleChildContext(
236 : : sal_uInt16 nFamily,
237 : : const ::rtl::OUString& rName,
238 : : sal_Bool bCreateIndex=sal_False ) const;
239 : : virtual sal_uInt16 GetFamily( const ::rtl::OUString& rFamily ) const;
240 : : virtual UniReference < SvXMLImportPropertyMapper > GetImportPropertyMapper(
241 : : sal_uInt16 nFamily ) const;
242 : :
243 : : virtual ::com::sun::star::uno::Reference <
244 : : ::com::sun::star::container::XNameContainer >
245 : : GetStylesContainer( sal_uInt16 nFamily ) const;
246 : : virtual ::rtl::OUString GetServiceName( sal_uInt16 nFamily ) const;
247 : :
248 : : virtual ::com::sun::star::uno::Reference < ::com::sun::star::style::XAutoStyleFamily >
249 : : GetAutoStyles( sal_uInt16 nFamily ) const;
250 : : void CopyAutoStylesToDoc();
251 : : void CopyStylesToDoc( sal_Bool bOverwrite, sal_Bool bFinish=sal_True );
252 : : void FinishStyles( sal_Bool bOverwrite );
253 : :
254 : : // This method must be called to release the references to all styles
255 : : // that are stored in the context.
256 : : void Clear();
257 : : sal_Bool IsAutomaticStyle() const;
258 : : };
259 : :
260 : : #endif // _XMLOFF_XMLSTYLE_HXX
261 : :
262 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|