bump product version to 4.2.0.1
[LibreOffice.git] / include / xmloff / xmlstyle.hxx
blob1b325bdab9d949db2092f56b1fddf9853e30e5cc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_XMLOFF_XMLSTYLE_HXX
21 #define INCLUDED_XMLOFF_XMLSTYLE_HXX
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>
32 class SvXMLStylesContext_Impl;
33 class SvXMLUnitConverter;
34 class SvXMLImportPropertyMapper;
36 namespace com { namespace sun { namespace star {
37 namespace container { class XNameContainer; }
38 namespace style { class XAutoStyleFamily; }
39 } } }
41 enum XMLStyleStylesElemTokens
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
61 class XMLOFF_DLLPUBLIC SvXMLStyleContext : public SvXMLImportContext
63 OUString maName;
64 OUString maDisplayName;
65 OUString maAutoName;
66 OUString maParentName;// Will be moved to XMLPropStyle soon!!!!
67 OUString maFollow; // Will be moved to XMLPropStyle soon!!!!
68 sal_Bool mbHidden;
70 OUString maHelpFile; // Will be removed very soon!!!!
72 sal_uInt32 mnHelpId; // Will be removed very soon!!!!
73 sal_uInt16 mnFamily;
75 sal_Bool mbValid : 1; // Set this to false in CreateAndInsert
76 // if the style shouldn't be processed
77 // by Finish() or si somehow invalid.
78 sal_Bool mbNew : 1; // Set this to false in CreateAnsInsert
79 // if the style is already existing.
80 sal_Bool mbDefaultStyle : 1;
82 protected:
84 virtual void SetAttribute( sal_uInt16 nPrefixKey,
85 const OUString& rLocalName,
86 const OUString& rValue );
88 void SetFamily( sal_uInt16 nSet ) { mnFamily = nSet; }
89 void SetAutoName( const OUString& rName ) { maAutoName = rName; }
91 public:
93 TYPEINFO();
95 SvXMLStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
96 const OUString& rLName,
97 const ::com::sun::star::uno::Reference<
98 ::com::sun::star::xml::sax::XAttributeList >& xAttrList,
99 sal_uInt16 nFamily=0, sal_Bool bDefaultStyle = sal_False );
101 virtual ~SvXMLStyleContext();
103 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
104 const OUString& rLocalName,
105 const ::com::sun::star::uno::Reference<
106 ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
108 virtual void StartElement(
109 const ::com::sun::star::uno::Reference<
110 ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
112 const OUString& GetName() const { return maName; }
113 const OUString& GetDisplayName() const { return maDisplayName.getLength() ? maDisplayName : maName; }
114 const OUString& GetAutoName() const { return maAutoName; }
115 const OUString& GetParentName() const { return maParentName; }
116 const OUString& GetFollow() const { return maFollow; }
118 const OUString& GetHelpFile() const { return maHelpFile; }
119 sal_uInt32 GetHelpId() const { return mnHelpId; }
121 sal_uInt16 GetFamily() const { return mnFamily; }
123 sal_Bool IsValid() const { return mbValid; }
124 void SetValid( sal_Bool b ) { mbValid = b; }
126 sal_Bool IsNew() const { return mbNew; }
127 void SetNew( sal_Bool b ) { mbNew = b; }
129 sal_Bool IsHidden() const { return mbHidden; }
131 // This method is called for every default style
132 virtual void SetDefaults();
134 // This method is called for every style. It must create it and insert
135 // it into the document.
136 virtual void CreateAndInsert( sal_Bool bOverwrite );
138 // This method is called for every style. It must create it and insert
139 // it into the document if this hasn't happened already in CreateAndInsert().
140 virtual void CreateAndInsertLate( sal_Bool bOverwrite );
142 // This method is called fpr every style after all styles have been
143 // inserted into the document.
144 virtual void Finish( sal_Bool bOverwrite );
146 sal_Bool IsDefaultStyle() const { return mbDefaultStyle; }
148 /** if this method returns true, its parent styles context
149 should not add it to its container.<br>
150 Transient styles can't be accessed from its
151 parent SvXMLStylesContext after theyre imported and
152 the methods CreateAndInsert(), CreateAndInsertLate()
153 and Finish() will not be called.
154 The default return value is false
156 virtual sal_Bool IsTransient() const;
159 class XMLOFF_DLLPUBLIC SvXMLStylesContext : public SvXMLImportContext
161 const OUString msParaStyleServiceName;
162 const OUString msTextStyleServiceName;
164 SvXMLStylesContext_Impl *mpImpl;
165 SvXMLTokenMap *mpStyleStylesElemTokenMap;
168 ::com::sun::star::uno::Reference <
169 ::com::sun::star::container::XNameContainer > mxParaStyles;
171 ::com::sun::star::uno::Reference <
172 ::com::sun::star::container::XNameContainer > mxTextStyles;
174 ::com::sun::star::uno::Reference <
175 ::com::sun::star::style::XAutoStyleFamily > mxParaAutoStyles;
177 ::com::sun::star::uno::Reference <
178 ::com::sun::star::style::XAutoStyleFamily > mxTextAutoStyles;
180 UniReference < SvXMLImportPropertyMapper > mxParaImpPropMapper;
181 UniReference < SvXMLImportPropertyMapper > mxTextImpPropMapper;
182 UniReference < SvXMLImportPropertyMapper > mxShapeImpPropMapper;
183 mutable UniReference < SvXMLImportPropertyMapper > mxChartImpPropMapper;
184 mutable UniReference < SvXMLImportPropertyMapper > mxPageImpPropMapper;
186 SAL_DLLPRIVATE const SvXMLTokenMap& GetStyleStylesElemTokenMap();
188 SAL_DLLPRIVATE SvXMLStylesContext(SvXMLStylesContext &); // not defined
189 SAL_DLLPRIVATE void operator =(SvXMLStylesContext &); // not defined
191 protected:
193 sal_uInt32 GetStyleCount() const;
194 SvXMLStyleContext *GetStyle( sal_uInt32 i );
195 const SvXMLStyleContext *GetStyle( sal_uInt32 i ) const;
197 virtual SvXMLStyleContext *CreateStyleChildContext( sal_uInt16 nPrefix,
198 const OUString& rLocalName,
199 const ::com::sun::star::uno::Reference<
200 ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
202 virtual SvXMLStyleContext *CreateStyleStyleChildContext( sal_uInt16 nFamily,
203 sal_uInt16 nPrefix, const OUString& rLocalName,
204 const ::com::sun::star::uno::Reference<
205 ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
207 virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext(
208 sal_uInt16 nFamily, sal_uInt16 nPrefix,
209 const OUString& rLocalName,
210 const ::com::sun::star::uno::Reference<
211 ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
213 virtual sal_Bool InsertStyleFamily( sal_uInt16 nFamily ) const;
215 public:
216 TYPEINFO();
218 SvXMLStylesContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
219 const OUString& rLName,
220 const ::com::sun::star::uno::Reference<
221 ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
222 sal_Bool bAutomatic = sal_False );
224 virtual ~SvXMLStylesContext();
226 // Create child element.
227 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
228 const OUString& rLocalName,
229 const ::com::sun::star::uno::Reference<
230 ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
232 // This method must be overloaded to insert styles into the document.
233 virtual void EndElement();
235 // This allows to add an SvXMLStyleContext to this context from extern
236 void AddStyle(SvXMLStyleContext& rNew);
238 const SvXMLStyleContext *FindStyleChildContext(
239 sal_uInt16 nFamily,
240 const OUString& rName,
241 sal_Bool bCreateIndex=sal_False ) const;
242 virtual sal_uInt16 GetFamily( const OUString& rFamily ) const;
243 virtual UniReference < SvXMLImportPropertyMapper > GetImportPropertyMapper(
244 sal_uInt16 nFamily ) const;
246 virtual ::com::sun::star::uno::Reference <
247 ::com::sun::star::container::XNameContainer >
248 GetStylesContainer( sal_uInt16 nFamily ) const;
249 virtual OUString GetServiceName( sal_uInt16 nFamily ) const;
251 virtual ::com::sun::star::uno::Reference < ::com::sun::star::style::XAutoStyleFamily >
252 GetAutoStyles( sal_uInt16 nFamily ) const;
253 void CopyAutoStylesToDoc();
254 void CopyStylesToDoc( sal_Bool bOverwrite, sal_Bool bFinish=sal_True );
255 void FinishStyles( sal_Bool bOverwrite );
257 // This method must be called to release the references to all styles
258 // that are stored in the context.
259 void Clear();
260 sal_Bool IsAutomaticStyle() const;
263 #endif // INCLUDED_XMLOFF_XMLSTYLE_HXX
265 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */