1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlstyle.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _XMLOFF_XMLSTYLE_HXX
32 #define _XMLOFF_XMLSTYLE_HXX
34 #ifndef _RSCSFX_HXX //autogen wg. SfxStyleFamily
35 #include <rsc/rscsfx.hxx>
39 #include <tools/rtti.hxx>
41 #ifndef _UNIVERSALL_REFERENCE_HXX
42 #include <bf_xmloff/uniref.hxx>
45 #ifndef _XMLOFF_XMLTKMAP_HXX
46 #include <bf_xmloff/xmltkmap.hxx>
48 #ifndef _XMLOFF_XMLICTXT_HXX
49 #include <bf_xmloff/xmlictxt.hxx>
51 namespace com
{ namespace sun
{ namespace star
{ namespace container
57 class SvXMLStylesContext_Impl
;
58 class SvXMLUnitConverter
;
59 class SvXMLImportPropertyMapper
;
63 enum XMLStyleStylesElemTokens
66 XML_TOK_STYLE_PAGE_MASTER
,
67 XML_TOK_TEXT_LIST_STYLE
,
69 XML_TOK_STYLES_GRADIENTSTYLES
,
70 XML_TOK_STYLES_HATCHSTYLES
,
71 XML_TOK_STYLES_BITMAPSTYLES
,
72 XML_TOK_STYLES_TRANSGRADIENTSTYLES
,
73 XML_TOK_STYLES_MARKERSTYLES
,
74 XML_TOK_STYLES_DASHSTYLES
,
75 XML_TOK_TEXT_FOOTNOTE_CONFIG
,
76 XML_TOK_TEXT_ENDNOTE_CONFIG
,
77 XML_TOK_TEXT_BIBLIOGRAPHY_CONFIG
,
78 XML_TOK_TEXT_LINENUMBERING_CONFIG
,
79 XML_TOK_STYLE_DEFAULT_STYLE
,
80 XML_TOK_STYLE_STYLES_ELEM_END
=XML_TOK_UNKNOWN
83 class SvXMLStyleContext
: public SvXMLImportContext
85 ::rtl::OUString aName
;
86 ::rtl::OUString aParent
; // Will be moved to XMLPropStyle soon!!!!
87 ::rtl::OUString aFollow
; // Will be moved to XMLPropStyle soon!!!!
89 ::rtl::OUString aHelpFile
; // Will be removed very soon!!!!
91 sal_uInt32 nHelpId
; // Will be removed very soon!!!!
94 sal_Bool bValid
: 1; // Set this to false in CreateAndInsert
95 // if the style shouldn't be processed
96 // by Finish() or si somehow invalid.
97 sal_Bool bNew
: 1; // Set this to false in CreateAnsInsert
98 // if the style is already existing.
99 sal_Bool bDefaultStyle
: 1;
103 virtual void SetAttribute( sal_uInt16 nPrefixKey
,
104 const ::rtl::OUString
& rLocalName
,
105 const ::rtl::OUString
& rValue
);
111 SvXMLStyleContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
112 const ::rtl::OUString
& rLName
,
113 const ::com::sun::star::uno::Reference
<
114 ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
115 sal_uInt16 nFamily
=0, sal_Bool bDefaultStyle
= sal_False
);
117 virtual ~SvXMLStyleContext();
119 virtual SvXMLImportContext
*CreateChildContext( sal_uInt16 nPrefix
,
120 const ::rtl::OUString
& rLocalName
,
121 const ::com::sun::star::uno::Reference
<
122 ::com::sun::star::xml::sax::XAttributeList
> & xAttrList
);
124 virtual void StartElement(
125 const ::com::sun::star::uno::Reference
<
126 ::com::sun::star::xml::sax::XAttributeList
> & xAttrList
);
128 const ::rtl::OUString
& GetName() const { return aName
; }
129 const ::rtl::OUString
& GetParent() const { return aParent
; }
130 const ::rtl::OUString
& GetFollow() const { return aFollow
; }
132 const ::rtl::OUString
& GetHelpFile() const { return aHelpFile
; }
133 sal_uInt32
GetHelpId() const { return nHelpId
; }
135 sal_uInt16
GetFamily() const { return nFamily
; }
137 BOOL
IsValid() const { return bValid
; }
138 void SetValid( sal_Bool b
) { bValid
= b
; }
140 BOOL
IsNew() const { return bNew
; }
141 void SetNew( sal_Bool b
) { bNew
= b
; }
143 // This method is called for every default style
144 virtual void SetDefaults();
146 // This method is called for every style. It must create it and insert
147 // it into the document.
148 virtual void CreateAndInsert( sal_Bool bOverwrite
);
150 // This method is called for every style. It must create it and insert
151 // it into the document if this hasn't happened already in CreateAndInsert().
152 virtual void CreateAndInsertLate( sal_Bool bOverwrite
);
154 // This method is called fpr every style after all styles have been
155 // inserted into the document.
156 virtual void Finish( sal_Bool bOverwrite
);
158 sal_Bool
IsDefaultStyle() const { return bDefaultStyle
; }
160 /** if this method returns true, its parent styles context
161 should not add it to its container.<br>
162 Transient styles can't be accessed from its
163 parent SvXMLStylesContext after theyre imported and
164 the methods CreateAndInsert(), CreateAndInsertLate()
165 and Finish() will not be called.
166 The default return value is false
168 virtual BOOL
IsTransient() const;
171 class SvXMLStylesContext
: public SvXMLImportContext
173 const ::rtl::OUString sParaStyleServiceName
;
174 const ::rtl::OUString sTextStyleServiceName
;
176 SvXMLStylesContext_Impl
*pImpl
;
177 SvXMLTokenMap
*pStyleStylesElemTokenMap
;
179 ::com::sun::star::uno::Reference
<
180 ::com::sun::star::container::XNameContainer
> xParaStyles
;
181 ::com::sun::star::uno::Reference
<
182 ::com::sun::star::container::XNameContainer
> xTextStyles
;
184 UniReference
< SvXMLImportPropertyMapper
> xParaImpPropMapper
;
185 UniReference
< SvXMLImportPropertyMapper
> xTextImpPropMapper
;
186 UniReference
< SvXMLImportPropertyMapper
> xShapeImpPropMapper
;
187 mutable UniReference
< SvXMLImportPropertyMapper
> xChartImpPropMapper
;
188 mutable UniReference
< SvXMLImportPropertyMapper
> xPageImpPropMapper
;
190 const SvXMLTokenMap
& GetStyleStylesElemTokenMap();
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 ::rtl::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 ::rtl::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 ::rtl::OUString
& rLocalName
,
211 const ::com::sun::star::uno::Reference
<
212 ::com::sun::star::xml::sax::XAttributeList
> & xAttrList
);
214 virtual sal_Bool
InsertStyleFamily( sal_uInt16 nFamily
) const;
219 SvXMLStylesContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
220 const ::rtl::OUString
& rLName
,
221 const ::com::sun::star::uno::Reference
<
222 ::com::sun::star::xml::sax::XAttributeList
> & xAttrList
);
224 virtual ~SvXMLStylesContext();
226 // Create child element.
227 virtual SvXMLImportContext
*CreateChildContext( sal_uInt16 nPrefix
,
228 const ::rtl::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(
240 const ::rtl::OUString
& rName
,
241 BOOL bCreateIndex
=sal_False
) const;
242 virtual sal_uInt16
GetFamily( const ::rtl::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 ::rtl::OUString
GetServiceName( sal_uInt16 nFamily
) const;
251 void CopyStylesToDoc( sal_Bool bOverwrite
, sal_Bool bFinish
=sal_True
);
252 void FinishStyles( sal_Bool bOverwrite
);
254 // This method must be called to release the references to all styles
255 // that are stored in the context.
259 class SvXMLUseStylesContext
: public SvXMLImportContext
263 SvXMLUseStylesContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
264 const ::rtl::OUString
& rLName
,
265 const ::com::sun::star::uno::Reference
<
266 ::com::sun::star::xml::sax::XAttributeList
> & xAttrList
,
267 ::rtl::OUString
& rHRef
);
269 virtual ~SvXMLUseStylesContext();
272 }//end of namespace binfilter
273 #endif // _XMLOFF_XMLSTYLE_HXX