1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_SC_SOURCE_FILTER_XML_XMLSTYLI_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_XML_XMLSTYLI_HXX
23 #include <rtl/ustring.hxx>
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"
36 class ScConditionalFormat
;
38 class ScXMLCellImportPropertyMapper
: public SvXMLImportPropertyMapper
44 ScXMLCellImportPropertyMapper(
45 const rtl::Reference
< XMLPropertySetMapper
>& rMapper
,
46 SvXMLImport
& rImport
);
47 virtual ~ScXMLCellImportPropertyMapper();
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
;
54 class ScXMLRowImportPropertyMapper
: public SvXMLImportPropertyMapper
60 ScXMLRowImportPropertyMapper(
61 const rtl::Reference
< XMLPropertySetMapper
>& rMapper
,
62 SvXMLImport
& rImport
);
63 virtual ~ScXMLRowImportPropertyMapper();
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
;
70 class XMLTableStyleContext
: public XMLPropStyleContext
72 OUString sDataStyleName
;
74 SvXMLStylesContext
* pStyles
;
75 sal_Int32 nNumberFormat
;
78 ScConditionalFormat
* mpCondFormat
;
79 bool mbDeleteCondFormat
;
81 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
82 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
86 virtual void SetAttribute( sal_uInt16 nPrefixKey
,
87 const OUString
& rLocalName
,
88 const OUString
& rValue
) SAL_OVERRIDE
;
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();
100 virtual SvXMLImportContext
*CreateChildContext(
102 const OUString
& rLocalName
,
103 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
> & xAttrList
) SAL_OVERRIDE
;
105 virtual void FillPropertySet(const ::com::sun::star::uno::Reference
<
106 ::com::sun::star::beans::XPropertySet
> & rPropSet
) SAL_OVERRIDE
;
108 virtual void SetDefaults() SAL_OVERRIDE
;
110 void AddProperty(sal_Int16 nContextID
, const com::sun::star::uno::Any
& aValue
);
111 XMLPropertyState
* FindProperty(const sal_Int16 nContextID
);
113 sal_Int32
GetNumberFormat();// { return nNumberFormat; }
115 SCTAB
GetLastSheet() const { return nLastSheet
; }
116 void SetLastSheet(SCTAB nNew
) { nLastSheet
= nNew
; }
118 void ApplyCondFormat( const com::sun::star::uno::Sequence
<com::sun::star::table::CellRangeAddress
>& xCellRanges
);
121 using XMLPropStyleContext::SetStyle
;
124 class XMLTableStylesContext
: public SvXMLStylesContext
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
;
144 rtl::Reference
< SvXMLImportPropertyMapper
> xCellImpPropMapper
;
145 rtl::Reference
< SvXMLImportPropertyMapper
> xColumnImpPropMapper
;
146 rtl::Reference
< SvXMLImportPropertyMapper
> xRowImpPropMapper
;
147 rtl::Reference
< SvXMLImportPropertyMapper
> xTableImpPropMapper
;
149 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
150 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
154 // Create a style context.
155 virtual SvXMLStyleContext
*CreateStyleStyleChildContext(
158 const OUString
& rLocalName
,
159 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
> & xAttrList
) SAL_OVERRIDE
;
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
;
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();
175 virtual void EndElement() SAL_OVERRIDE
;
177 virtual rtl::Reference
< 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
;
184 sal_Int32
GetIndex(const sal_Int16 nContextID
);
187 class ScXMLMasterStylesContext
: public SvXMLStylesContext
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
;
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
;
200 virtual bool InsertStyleFamily( sal_uInt16 nFamily
) const SAL_OVERRIDE
;
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
);
210 virtual ~ScXMLMasterStylesContext();
211 virtual void EndElement() SAL_OVERRIDE
;
214 namespace com
{ namespace sun
{ namespace star
{
215 namespace style
{ class XStyle
; }
218 class ScMasterPageContext
: public XMLTextMasterPageContext
220 com::sun::star::uno::Reference
<com::sun::star::beans::XPropertySet
> xPropSet
;
221 const OUString sEmpty
;
222 bool bContainsRightHeader
;
223 bool bContainsRightFooter
;
225 void ClearContent(const OUString
& rContent
);
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
,
235 virtual ~ScMasterPageContext();
237 virtual SvXMLImportContext
*CreateChildContext(
239 const OUString
& rLocalName
,
240 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
> & xAttrList
) SAL_OVERRIDE
;
242 virtual SvXMLImportContext
*CreateHeaderFooterContext(
244 const OUString
& rLocalName
,
245 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
> & xAttrList
,
248 const bool bFirst
) SAL_OVERRIDE
;
250 virtual void Finish( bool bOverwrite
) SAL_OVERRIDE
;
253 class ScCellTextStyleContext
: public XMLTextStyleContext
255 sal_Int32 nLastSheet
;
257 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
258 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
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();
269 // override 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
;
277 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */