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 SC_XMLSTYLI_HXX
21 : #define SC_XMLSTYLI_HXX
22 :
23 : #include <rtl/ustring.hxx>
24 : #include <vector>
25 : #include <xmloff/xmlimp.hxx>
26 : #include <xmloff/xmlictxt.hxx>
27 : #include <xmloff/maptype.hxx>
28 : #include <xmloff/prstylei.hxx>
29 : #include <xmloff/xmlimppr.hxx>
30 : #include <xmloff/XMLTextMasterPageContext.hxx>
31 : #include <xmloff/XMLTextMasterStylesContext.hxx>
32 : #include <xmloff/txtstyli.hxx>
33 : #include <com/sun/star/sheet/ConditionOperator.hpp>
34 : #include "xmlimprt.hxx"
35 :
36 : class ScConditionalFormat;
37 :
38 : class ScXMLCellImportPropertyMapper : public SvXMLImportPropertyMapper
39 : {
40 : protected:
41 :
42 : public:
43 :
44 : ScXMLCellImportPropertyMapper(
45 : const UniReference< XMLPropertySetMapper >& rMapper,
46 : SvXMLImport& rImport);
47 : virtual ~ScXMLCellImportPropertyMapper();
48 :
49 : /** This method is called when all attributes have been processed. It may be used to remove items that are incomplete */
50 : virtual void finished(
51 : ::std::vector< XMLPropertyState >& rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const SAL_OVERRIDE;
52 : };
53 :
54 : class ScXMLRowImportPropertyMapper : public SvXMLImportPropertyMapper
55 : {
56 : protected:
57 :
58 : public:
59 :
60 : ScXMLRowImportPropertyMapper(
61 : const UniReference< XMLPropertySetMapper >& rMapper,
62 : SvXMLImport& rImport);
63 : virtual ~ScXMLRowImportPropertyMapper();
64 :
65 : /** This method is called when all attributes have been processed. It may be used to remove items that are incomplete */
66 : virtual void finished(
67 : ::std::vector< XMLPropertyState >& rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const SAL_OVERRIDE;
68 : };
69 :
70 : class XMLTableStyleContext : public XMLPropStyleContext
71 : {
72 : OUString sDataStyleName;
73 : OUString sPageStyle;
74 : SvXMLStylesContext* pStyles;
75 : sal_Int32 nNumberFormat;
76 : SCTAB nLastSheet;
77 : bool bParentSet;
78 : ScConditionalFormat* mpCondFormat;
79 : bool mbDeleteCondFormat;
80 :
81 : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
82 18 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
83 :
84 : protected:
85 :
86 : virtual void SetAttribute( sal_uInt16 nPrefixKey,
87 : const OUString& rLocalName,
88 : const OUString& rValue ) SAL_OVERRIDE;
89 :
90 : public:
91 :
92 : TYPEINFO_OVERRIDE();
93 :
94 : XMLTableStyleContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
95 : const OUString& rLName,
96 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
97 : SvXMLStylesContext& rStyles, sal_uInt16 nFamily, bool bDefaultStyle = false );
98 : virtual ~XMLTableStyleContext();
99 :
100 : virtual SvXMLImportContext *CreateChildContext(
101 : sal_uInt16 nPrefix,
102 : const OUString& rLocalName,
103 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE;
104 :
105 : virtual void FillPropertySet(const ::com::sun::star::uno::Reference<
106 : ::com::sun::star::beans::XPropertySet > & rPropSet ) SAL_OVERRIDE;
107 :
108 : virtual void SetDefaults() SAL_OVERRIDE;
109 :
110 : void AddProperty(sal_Int16 nContextID, const com::sun::star::uno::Any& aValue);
111 : XMLPropertyState* FindProperty(const sal_Int16 nContextID);
112 :
113 : sal_Int32 GetNumberFormat();// { return nNumberFormat; }
114 :
115 3558 : SCTAB GetLastSheet() const { return nLastSheet; }
116 1045 : void SetLastSheet(SCTAB nNew) { nLastSheet = nNew; }
117 :
118 : void ApplyCondFormat( com::sun::star::uno::Sequence<com::sun::star::table::CellRangeAddress> xCellRanges );
119 :
120 : private:
121 : using XMLPropStyleContext::SetStyle;
122 : };
123 :
124 : class XMLTableStylesContext : public SvXMLStylesContext
125 : {
126 : ::com::sun::star::uno::Reference <
127 : ::com::sun::star::container::XNameContainer > xCellStyles;
128 : ::com::sun::star::uno::Reference <
129 : ::com::sun::star::container::XNameContainer > xColumnStyles;
130 : ::com::sun::star::uno::Reference <
131 : ::com::sun::star::container::XNameContainer > xRowStyles;
132 : ::com::sun::star::uno::Reference <
133 : ::com::sun::star::container::XNameContainer > xTableStyles;
134 : const OUString sCellStyleServiceName;
135 : const OUString sColumnStyleServiceName;
136 : const OUString sRowStyleServiceName;
137 : const OUString sTableStyleServiceName;
138 : sal_Int32 nNumberFormatIndex;
139 : sal_Int32 nConditionalFormatIndex;
140 : sal_Int32 nCellStyleIndex;
141 : sal_Int32 nMasterPageNameIndex;
142 : bool bAutoStyles;
143 :
144 : UniReference < SvXMLImportPropertyMapper > xCellImpPropMapper;
145 : UniReference < SvXMLImportPropertyMapper > xColumnImpPropMapper;
146 : UniReference < SvXMLImportPropertyMapper > xRowImpPropMapper;
147 : UniReference < SvXMLImportPropertyMapper > xTableImpPropMapper;
148 :
149 679 : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
150 1654 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
151 :
152 : protected:
153 :
154 : // Create a style context.
155 : virtual SvXMLStyleContext *CreateStyleStyleChildContext(
156 : sal_uInt16 nFamily,
157 : sal_uInt16 nPrefix,
158 : const OUString& rLocalName,
159 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE;
160 :
161 : virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext(
162 : sal_uInt16 nFamily, sal_uInt16 nPrefix,
163 : const OUString& rLocalName,
164 : const ::com::sun::star::uno::Reference<
165 : ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE;
166 :
167 : public:
168 :
169 : XMLTableStylesContext( SvXMLImport& rImport, sal_uInt16 nPrfx ,
170 : const OUString& rLName ,
171 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
172 : const bool bAutoStyles );
173 : virtual ~XMLTableStylesContext();
174 :
175 : virtual void EndElement() SAL_OVERRIDE;
176 :
177 : virtual UniReference < SvXMLImportPropertyMapper > GetImportPropertyMapper(
178 : sal_uInt16 nFamily ) const SAL_OVERRIDE;
179 : virtual ::com::sun::star::uno::Reference <
180 : ::com::sun::star::container::XNameContainer >
181 : GetStylesContainer( sal_uInt16 nFamily ) const SAL_OVERRIDE;
182 : virtual OUString GetServiceName( sal_uInt16 nFamily ) const SAL_OVERRIDE;
183 :
184 : sal_Int32 GetIndex(const sal_Int16 nContextID);
185 : };
186 :
187 : class ScXMLMasterStylesContext : public SvXMLStylesContext
188 : {
189 : protected:
190 : virtual SvXMLStyleContext *CreateStyleChildContext( sal_uInt16 nPrefix,
191 : const OUString& rLocalName,
192 : const ::com::sun::star::uno::Reference<
193 : ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE;
194 :
195 : virtual SvXMLStyleContext *CreateStyleStyleChildContext( sal_uInt16 nFamily,
196 : sal_uInt16 nPrefix, const OUString& rLocalName,
197 : const ::com::sun::star::uno::Reference<
198 : ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE;
199 :
200 : virtual bool InsertStyleFamily( sal_uInt16 nFamily ) const SAL_OVERRIDE;
201 :
202 : public:
203 : TYPEINFO_OVERRIDE();
204 :
205 : ScXMLMasterStylesContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
206 : const OUString& rLName,
207 : const ::com::sun::star::uno::Reference<
208 : ::com::sun::star::xml::sax::XAttributeList > & xAttrList);
209 :
210 : virtual ~ScXMLMasterStylesContext();
211 : virtual void EndElement() SAL_OVERRIDE;
212 : };
213 :
214 : namespace com { namespace sun { namespace star {
215 : namespace style { class XStyle; }
216 : } } }
217 :
218 : class ScMasterPageContext : public XMLTextMasterPageContext
219 : {
220 : com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> xPropSet;
221 : const OUString sEmpty;
222 : bool bContainsRightHeader;
223 : bool bContainsRightFooter;
224 :
225 : void ClearContent(const OUString& rContent);
226 : public:
227 :
228 : TYPEINFO_OVERRIDE();
229 :
230 : ScMasterPageContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
231 : const OUString& rLName,
232 : const ::com::sun::star::uno::Reference<
233 : ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
234 : bool bOverwrite );
235 : virtual ~ScMasterPageContext();
236 :
237 : virtual SvXMLImportContext *CreateChildContext(
238 : sal_uInt16 nPrefix,
239 : const OUString& rLocalName,
240 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE;
241 :
242 : virtual SvXMLImportContext *CreateHeaderFooterContext(
243 : sal_uInt16 nPrefix,
244 : const OUString& rLocalName,
245 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
246 : const bool bFooter,
247 : const bool bLeft,
248 : const bool bFirst ) SAL_OVERRIDE;
249 :
250 : virtual void Finish( bool bOverwrite ) SAL_OVERRIDE;
251 : };
252 :
253 : class ScCellTextStyleContext : public XMLTextStyleContext
254 : {
255 : sal_Int32 nLastSheet;
256 :
257 : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
258 234 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
259 :
260 : public:
261 : ScCellTextStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
262 : const OUString& rLName,
263 : const ::com::sun::star::uno::Reference<
264 : ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
265 : SvXMLStylesContext& rStyles, sal_uInt16 nFamily,
266 : bool bDefaultStyle = false );
267 : virtual ~ScCellTextStyleContext();
268 :
269 : // overload FillPropertySet to store style information
270 : virtual void FillPropertySet(
271 : const ::com::sun::star::uno::Reference<
272 : ::com::sun::star::beans::XPropertySet > & rPropSet ) SAL_OVERRIDE;
273 : };
274 :
275 :
276 : #endif
277 :
278 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|