merge the formfield patch from ooo-build
[ooovba.git] / sc / source / filter / xml / xmlstyli.hxx
blob8ae90b43d478967b5061cc6787304b1181b097a0
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: xmlstyli.hxx,v $
10 * $Revision: 1.29 $
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 SC_XMLSTYLI_HXX
32 #define SC_XMLSTYLI_HXX
34 #include <rtl/ustring.hxx>
35 #include <vector>
36 #include <xmloff/xmlimp.hxx>
37 #include <xmloff/xmlictxt.hxx>
38 #include <xmloff/maptype.hxx>
39 #include <xmloff/prstylei.hxx>
40 #include <xmloff/xmlimppr.hxx>
41 #include <xmloff/XMLTextMasterPageContext.hxx>
42 #include <xmloff/XMLTextMasterStylesContext.hxx>
43 #include <xmloff/txtstyli.hxx>
44 #include <com/sun/star/sheet/ConditionOperator.hpp>
45 #include "xmlimprt.hxx"
47 class ScSheetSaveData;
49 class ScXMLCellImportPropertyMapper : public SvXMLImportPropertyMapper
51 protected:
53 public:
55 ScXMLCellImportPropertyMapper(
56 const UniReference< XMLPropertySetMapper >& rMapper,
57 SvXMLImport& rImport);
58 virtual ~ScXMLCellImportPropertyMapper();
60 /** this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_IMPORT flag set */
61 /* virtual sal_Bool handleSpecialItem(
62 XMLPropertyState& rProperty,
63 ::std::vector< XMLPropertyState >& rProperties,
64 const ::rtl::OUString& rValue,
65 const SvXMLUnitConverter& rUnitConverter,
66 const SvXMLNamespaceMap& rNamespaceMap ) const;*/
68 /** this method is called for every item that has the MID_FLAG_NO_ITEM_IMPORT flag set */
69 /* virtual sal_Bool handleNoItem(
70 sal_Int32 nIndex,
71 ::std::vector< XMLPropertyState >& rProperties,
72 const ::rtl::OUString& rValue,
73 const SvXMLUnitConverter& rUnitConverter,
74 const SvXMLNamespaceMap& rNamespaceMap ) const;*/
76 /** This method is called when all attributes have been processed. It may be used to remove items that are incomplete */
77 virtual void finished(
78 ::std::vector< XMLPropertyState >& rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const;
81 class ScXMLRowImportPropertyMapper : public SvXMLImportPropertyMapper
83 protected:
85 public:
87 ScXMLRowImportPropertyMapper(
88 const UniReference< XMLPropertySetMapper >& rMapper,
89 SvXMLImport& rImport);
90 virtual ~ScXMLRowImportPropertyMapper();
92 /** This method is called when all attributes have been processed. It may be used to remove items that are incomplete */
93 virtual void finished(
94 ::std::vector< XMLPropertyState >& rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const;
96 struct ScXMLMapContent;
98 class XMLTableStyleContext : public XMLPropStyleContext
100 ::rtl::OUString sDataStyleName;
101 rtl::OUString sPageStyle;
102 const rtl::OUString sNumberFormat;
103 SvXMLStylesContext* pStyles;
104 std::vector<ScXMLMapContent> aMaps;
105 com::sun::star::uno::Any aConditionalFormat;
106 sal_Int32 nNumberFormat;
107 sal_Int32 nLastSheet;
108 sal_Bool bConditionalFormatCreated;
109 sal_Bool bParentSet;
111 const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
112 ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
114 void SetOperator(
115 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rProps,
116 ::com::sun::star::sheet::ConditionOperator eOp ) const;
118 void SetBaseCellAddress(
119 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rProps,
120 const ::rtl::OUString& rBaseCell ) const;
122 void SetStyle(
123 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rProps,
124 const ::rtl::OUString& rApplyStyle ) const;
126 void SetFormula(
127 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rProps,
128 sal_Int32 nFormulaIdx, const ::rtl::OUString& rFormula,
129 const ::rtl::OUString& rFormulaNmsp, ::formula::FormulaGrammar::Grammar eGrammar, bool bHasNmsp ) const;
131 void GetConditionalFormat(
132 ::com::sun::star::uno::Any& aAny, const rtl::OUString& sCondition,
133 const rtl::OUString& sApplyStyle, const rtl::OUString& sBaseCell) const;
134 protected:
136 virtual void SetAttribute( sal_uInt16 nPrefixKey,
137 const ::rtl::OUString& rLocalName,
138 const ::rtl::OUString& rValue );
140 public:
142 TYPEINFO();
144 XMLTableStyleContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
145 const ::rtl::OUString& rLName,
146 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
147 SvXMLStylesContext& rStyles, sal_uInt16 nFamily, sal_Bool bDefaultStyle = sal_False );
148 virtual ~XMLTableStyleContext();
150 virtual SvXMLImportContext *CreateChildContext(
151 sal_uInt16 nPrefix,
152 const ::rtl::OUString& rLocalName,
153 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
155 virtual void FillPropertySet(const ::com::sun::star::uno::Reference<
156 ::com::sun::star::beans::XPropertySet > & rPropSet );
158 virtual void SetDefaults();
160 void AddProperty(sal_Int16 nContextID, const com::sun::star::uno::Any& aValue);
161 XMLPropertyState* FindProperty(const sal_Int16 nContextID);
163 sal_Int32 GetNumberFormat();// { return nNumberFormat; }
165 sal_Int32 GetLastSheet() const { return nLastSheet; }
166 void SetLastSheet(sal_Int32 nNew) { nLastSheet = nNew; }
168 private:
169 using XMLPropStyleContext::SetStyle;
172 class XMLTableStylesContext : public SvXMLStylesContext
174 ::com::sun::star::uno::Reference <
175 ::com::sun::star::container::XNameContainer > xCellStyles;
176 ::com::sun::star::uno::Reference <
177 ::com::sun::star::container::XNameContainer > xColumnStyles;
178 ::com::sun::star::uno::Reference <
179 ::com::sun::star::container::XNameContainer > xRowStyles;
180 ::com::sun::star::uno::Reference <
181 ::com::sun::star::container::XNameContainer > xTableStyles;
182 const ::rtl::OUString sCellStyleServiceName;
183 const ::rtl::OUString sColumnStyleServiceName;
184 const ::rtl::OUString sRowStyleServiceName;
185 const ::rtl::OUString sTableStyleServiceName;
186 sal_Int32 nNumberFormatIndex;
187 sal_Int32 nConditionalFormatIndex;
188 sal_Int32 nCellStyleIndex;
189 sal_Int32 nMasterPageNameIndex;
190 sal_Bool bAutoStyles;
192 UniReference < SvXMLImportPropertyMapper > xCellImpPropMapper;
193 UniReference < SvXMLImportPropertyMapper > xColumnImpPropMapper;
194 UniReference < SvXMLImportPropertyMapper > xRowImpPropMapper;
195 UniReference < SvXMLImportPropertyMapper > xTableImpPropMapper;
197 const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
198 ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
200 protected:
202 // Create a style context.
203 virtual SvXMLStyleContext *CreateStyleStyleChildContext(
204 sal_uInt16 nFamily,
205 sal_uInt16 nPrefix,
206 const ::rtl::OUString& rLocalName,
207 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
209 virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext(
210 sal_uInt16 nFamily, sal_uInt16 nPrefix,
211 const ::rtl::OUString& rLocalName,
212 const ::com::sun::star::uno::Reference<
213 ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
215 // virtual SvXMLImportPropertyMapper *GetImpPropMapper();
217 public:
219 XMLTableStylesContext( SvXMLImport& rImport, sal_uInt16 nPrfx ,
220 const ::rtl::OUString& rLName ,
221 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
222 const sal_Bool bAutoStyles );
223 virtual ~XMLTableStylesContext();
225 // Create child element.
226 /* virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
227 const ::rtl::OUString& rLocalName,
228 const ::com::sun::star::uno::Reference<
229 ::com::sun::star::xml::sax::XAttributeList > & xAttrList );*/
231 virtual void EndElement();
233 virtual UniReference < SvXMLImportPropertyMapper > GetImportPropertyMapper(
234 sal_uInt16 nFamily ) const;
235 virtual ::com::sun::star::uno::Reference <
236 ::com::sun::star::container::XNameContainer >
237 GetStylesContainer( sal_uInt16 nFamily ) const;
238 virtual ::rtl::OUString GetServiceName( sal_uInt16 nFamily ) const;
240 sal_Int32 GetIndex(const sal_Int16 nContextID);
243 class ScXMLMasterStylesContext : public SvXMLStylesContext
245 protected:
246 virtual SvXMLStyleContext *CreateStyleChildContext( sal_uInt16 nPrefix,
247 const ::rtl::OUString& rLocalName,
248 const ::com::sun::star::uno::Reference<
249 ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
251 virtual SvXMLStyleContext *CreateStyleStyleChildContext( sal_uInt16 nFamily,
252 sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName,
253 const ::com::sun::star::uno::Reference<
254 ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
256 virtual sal_Bool InsertStyleFamily( sal_uInt16 nFamily ) const;
258 public:
259 TYPEINFO();
261 ScXMLMasterStylesContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
262 const ::rtl::OUString& rLName,
263 const ::com::sun::star::uno::Reference<
264 ::com::sun::star::xml::sax::XAttributeList > & xAttrList);
266 virtual ~ScXMLMasterStylesContext();
267 virtual void EndElement();
270 namespace com { namespace sun { namespace star {
271 namespace style { class XStyle; }
272 } } }
274 class ScMasterPageContext : public XMLTextMasterPageContext
276 com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> xPropSet;
277 const rtl::OUString sEmpty;
278 sal_Bool bContainsRightHeader;
279 sal_Bool bContainsRightFooter;
281 void ClearContent(const rtl::OUString& rContent);
282 public:
284 TYPEINFO();
286 ScMasterPageContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
287 const ::rtl::OUString& rLName,
288 const ::com::sun::star::uno::Reference<
289 ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
290 sal_Bool bOverwrite );
291 virtual ~ScMasterPageContext();
293 virtual SvXMLImportContext *CreateChildContext(
294 sal_uInt16 nPrefix,
295 const ::rtl::OUString& rLocalName,
296 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
298 virtual SvXMLImportContext *CreateHeaderFooterContext(
299 sal_uInt16 nPrefix,
300 const ::rtl::OUString& rLocalName,
301 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
302 const sal_Bool bFooter,
303 const sal_Bool bLeft );
305 virtual void Finish( sal_Bool bOverwrite );
308 class ScCellTextStyleContext : public XMLTextStyleContext
310 sal_Int32 nLastSheet;
312 const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
313 ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
315 public:
316 ScCellTextStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
317 const ::rtl::OUString& rLName,
318 const ::com::sun::star::uno::Reference<
319 ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
320 SvXMLStylesContext& rStyles, sal_uInt16 nFamily,
321 sal_Bool bDefaultStyle = sal_False );
322 virtual ~ScCellTextStyleContext();
324 // overload FillPropertySet to store style information
325 virtual void FillPropertySet(
326 const ::com::sun::star::uno::Reference<
327 ::com::sun::star::beans::XPropertySet > & rPropSet );
331 #endif