Branch libreoffice-5-0-4
[LibreOffice.git] / include / xmloff / xmlstyle.hxx
blobbc8d4b692baf224c6909804b34399f0d786b5e6a
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 <rtl/ref.hxx>
24 #include <sal/config.h>
25 #include <xmloff/dllapi.h>
26 #include <sal/types.h>
27 #include <rsc/rscsfx.hxx>
28 #include <tools/rtti.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 bool mbHidden;
70 OUString maHelpFile; // Will be removed very soon!!!!
72 sal_uInt32 mnHelpId; // Will be removed very soon!!!!
73 sal_uInt16 mnFamily;
75 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 bool mbNew : 1; // Set this to false in CreateAnsInsert
79 // if the style is already existing.
80 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_OVERRIDE();
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,
100 bool bDefaultStyle = false );
102 virtual ~SvXMLStyleContext();
104 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
105 const OUString& rLocalName,
106 const ::com::sun::star::uno::Reference<
107 ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE;
109 virtual void StartElement(
110 const ::com::sun::star::uno::Reference<
111 ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE;
113 const OUString& GetName() const { return maName; }
114 const OUString& GetDisplayName() const { return maDisplayName.getLength() ? maDisplayName : maName; }
115 const OUString& GetAutoName() const { return maAutoName; }
116 const OUString& GetParentName() const { return maParentName; }
117 const OUString& GetFollow() const { return maFollow; }
119 const OUString& GetHelpFile() const { return maHelpFile; }
120 sal_uInt32 GetHelpId() const { return mnHelpId; }
122 sal_uInt16 GetFamily() const { return mnFamily; }
124 bool IsValid() const { return mbValid; }
125 void SetValid( bool b ) { mbValid = b; }
127 bool IsNew() const { return mbNew; }
128 void SetNew( bool b ) { mbNew = b; }
130 bool IsHidden() const { return mbHidden; }
132 // This method is called for every default style
133 virtual void SetDefaults();
135 // This method is called for every style. It must create it and insert
136 // it into the document.
137 virtual void CreateAndInsert( bool bOverwrite );
139 // This method is called for every style. It must create it and insert
140 // it into the document if this hasn't happened already in CreateAndInsert().
141 virtual void CreateAndInsertLate( bool bOverwrite );
143 // This method is called fpr every style after all styles have been
144 // inserted into the document.
145 virtual void Finish( bool bOverwrite );
147 bool IsDefaultStyle() const { return mbDefaultStyle; }
149 /** if this method returns true, its parent styles context
150 should not add it to its container.<br>
151 Transient styles can't be accessed from its
152 parent SvXMLStylesContext after they are imported and
153 the methods CreateAndInsert(), CreateAndInsertLate()
154 and Finish() will not be called.
155 The default return value is false
157 virtual bool IsTransient() const;
160 class XMLOFF_DLLPUBLIC SvXMLStylesContext : public SvXMLImportContext
162 const OUString msParaStyleServiceName;
163 const OUString msTextStyleServiceName;
165 SvXMLStylesContext_Impl *mpImpl;
166 SvXMLTokenMap *mpStyleStylesElemTokenMap;
169 ::com::sun::star::uno::Reference <
170 ::com::sun::star::container::XNameContainer > mxParaStyles;
172 ::com::sun::star::uno::Reference <
173 ::com::sun::star::container::XNameContainer > mxTextStyles;
175 ::com::sun::star::uno::Reference <
176 ::com::sun::star::style::XAutoStyleFamily > mxParaAutoStyles;
178 ::com::sun::star::uno::Reference <
179 ::com::sun::star::style::XAutoStyleFamily > mxTextAutoStyles;
181 rtl::Reference < SvXMLImportPropertyMapper > mxParaImpPropMapper;
182 rtl::Reference < SvXMLImportPropertyMapper > mxTextImpPropMapper;
183 rtl::Reference < SvXMLImportPropertyMapper > mxShapeImpPropMapper;
184 mutable rtl::Reference < SvXMLImportPropertyMapper > mxChartImpPropMapper;
185 mutable rtl::Reference < SvXMLImportPropertyMapper > mxPageImpPropMapper;
187 SAL_DLLPRIVATE const SvXMLTokenMap& GetStyleStylesElemTokenMap();
189 SvXMLStylesContext(SvXMLStylesContext &) SAL_DELETED_FUNCTION;
190 void operator =(SvXMLStylesContext &) SAL_DELETED_FUNCTION;
192 protected:
194 sal_uInt32 GetStyleCount() const;
195 SvXMLStyleContext *GetStyle( sal_uInt32 i );
196 const SvXMLStyleContext *GetStyle( sal_uInt32 i ) const;
198 virtual SvXMLStyleContext *CreateStyleChildContext( sal_uInt16 nPrefix,
199 const OUString& rLocalName,
200 const ::com::sun::star::uno::Reference<
201 ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
203 virtual SvXMLStyleContext *CreateStyleStyleChildContext( sal_uInt16 nFamily,
204 sal_uInt16 nPrefix, const OUString& rLocalName,
205 const ::com::sun::star::uno::Reference<
206 ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
208 virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext(
209 sal_uInt16 nFamily, sal_uInt16 nPrefix,
210 const OUString& rLocalName,
211 const ::com::sun::star::uno::Reference<
212 ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
214 virtual bool InsertStyleFamily( sal_uInt16 nFamily ) const;
216 public:
217 TYPEINFO_OVERRIDE();
219 SvXMLStylesContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
220 const OUString& rLName,
221 const ::com::sun::star::uno::Reference<
222 ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
223 bool bAutomatic = false );
225 virtual ~SvXMLStylesContext();
227 // Create child element.
228 virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
229 const OUString& rLocalName,
230 const ::com::sun::star::uno::Reference<
231 ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE;
233 // Override this method to insert styles into the document.
234 virtual void EndElement() SAL_OVERRIDE;
236 // This allows to add an SvXMLStyleContext to this context from extern
237 void AddStyle(SvXMLStyleContext& rNew);
239 const SvXMLStyleContext *FindStyleChildContext(
240 sal_uInt16 nFamily,
241 const OUString& rName,
242 bool bCreateIndex = false ) const;
243 virtual sal_uInt16 GetFamily( const OUString& rFamily ) const;
244 virtual rtl::Reference < SvXMLImportPropertyMapper > GetImportPropertyMapper(
245 sal_uInt16 nFamily ) const;
247 virtual ::com::sun::star::uno::Reference <
248 ::com::sun::star::container::XNameContainer >
249 GetStylesContainer( sal_uInt16 nFamily ) const;
250 virtual OUString GetServiceName( sal_uInt16 nFamily ) const;
252 ::com::sun::star::uno::Reference < ::com::sun::star::style::XAutoStyleFamily >
253 GetAutoStyles( sal_uInt16 nFamily ) const;
254 void CopyAutoStylesToDoc();
255 void CopyStylesToDoc( bool bOverwrite, bool bFinish = true );
256 void FinishStyles( bool bOverwrite );
258 // This method must be called to release the references to all styles
259 // that are stored in the context.
260 void Clear();
261 bool IsAutomaticStyle() const;
264 #endif // INCLUDED_XMLOFF_XMLSTYLE_HXX
266 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */