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/xmlictxt.hxx>
26 #include <xmloff/prstylei.hxx>
27 #include <xmloff/xmlimppr.hxx>
28 #include <xmloff/XMLTextMasterPageContext.hxx>
29 #include <xmloff/txtstyli.hxx>
30 #include "xmlimprt.hxx"
32 class ScConditionalFormat
;
34 class ScXMLCellImportPropertyMapper
: public SvXMLImportPropertyMapper
40 ScXMLCellImportPropertyMapper(
41 const rtl::Reference
< XMLPropertySetMapper
>& rMapper
,
42 SvXMLImport
& rImport
);
43 virtual ~ScXMLCellImportPropertyMapper() override
;
45 /** This method is called when all attributes have been processed. It may be used to remove items that are incomplete */
46 virtual void finished(
47 ::std::vector
< XMLPropertyState
>& rProperties
, sal_Int32 nStartIndex
, sal_Int32 nEndIndex
) const override
;
50 class ScXMLRowImportPropertyMapper
: public SvXMLImportPropertyMapper
56 ScXMLRowImportPropertyMapper(
57 const rtl::Reference
< XMLPropertySetMapper
>& rMapper
,
58 SvXMLImport
& rImport
);
59 virtual ~ScXMLRowImportPropertyMapper() override
;
61 /** This method is called when all attributes have been processed. It may be used to remove items that are incomplete */
62 virtual void finished(
63 ::std::vector
< XMLPropertyState
>& rProperties
, sal_Int32 nStartIndex
, sal_Int32 nEndIndex
) const override
;
66 class XMLTableStyleContext
: public XMLPropStyleContext
68 OUString sDataStyleName
;
70 SvXMLStylesContext
* pStyles
;
71 sal_Int32 nNumberFormat
;
74 ScConditionalFormat
* mpCondFormat
;
75 bool mbDeleteCondFormat
;
77 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
78 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
82 virtual void SetAttribute( sal_uInt16 nPrefixKey
,
83 const OUString
& rLocalName
,
84 const OUString
& rValue
) override
;
89 XMLTableStyleContext( ScXMLImport
& rImport
, sal_uInt16 nPrfx
,
90 const OUString
& rLName
,
91 const css::uno::Reference
< css::xml::sax::XAttributeList
> & xAttrList
,
92 SvXMLStylesContext
& rStyles
, sal_uInt16 nFamily
, bool bDefaultStyle
= false );
93 virtual ~XMLTableStyleContext() override
;
95 virtual SvXMLImportContextRef
CreateChildContext(
97 const OUString
& rLocalName
,
98 const css::uno::Reference
< css::xml::sax::XAttributeList
> & xAttrList
) override
;
100 virtual void FillPropertySet(const css::uno::Reference
<
101 css::beans::XPropertySet
> & rPropSet
) override
;
103 virtual void SetDefaults() override
;
105 void AddProperty(sal_Int16 nContextID
, const css::uno::Any
& aValue
);
106 XMLPropertyState
* FindProperty(const sal_Int16 nContextID
);
108 sal_Int32
GetNumberFormat();// { return nNumberFormat; }
110 SCTAB
GetLastSheet() const { return nLastSheet
; }
111 void SetLastSheet(SCTAB nNew
) { nLastSheet
= nNew
; }
113 void ApplyCondFormat( const css::uno::Sequence
<css::table::CellRangeAddress
>& xCellRanges
);
116 using XMLPropStyleContext::SetStyle
;
119 class XMLTableStylesContext
: public SvXMLStylesContext
121 css::uno::Reference
< css::container::XNameContainer
> xCellStyles
;
122 css::uno::Reference
< css::container::XNameContainer
> xColumnStyles
;
123 css::uno::Reference
< css::container::XNameContainer
> xRowStyles
;
124 css::uno::Reference
< css::container::XNameContainer
> xTableStyles
;
125 sal_Int32 nNumberFormatIndex
;
126 sal_Int32 nConditionalFormatIndex
;
127 sal_Int32 nCellStyleIndex
;
128 sal_Int32 nMasterPageNameIndex
;
129 bool const bAutoStyles
;
131 rtl::Reference
< SvXMLImportPropertyMapper
> xCellImpPropMapper
;
132 rtl::Reference
< SvXMLImportPropertyMapper
> xColumnImpPropMapper
;
133 rtl::Reference
< SvXMLImportPropertyMapper
> xRowImpPropMapper
;
134 rtl::Reference
< SvXMLImportPropertyMapper
> xTableImpPropMapper
;
136 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
137 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
141 // Create a style context.
142 virtual SvXMLStyleContext
*CreateStyleStyleChildContext(
145 const OUString
& rLocalName
,
146 const css::uno::Reference
< css::xml::sax::XAttributeList
> & xAttrList
) override
;
148 virtual SvXMLStyleContext
*CreateDefaultStyleStyleChildContext(
149 sal_uInt16 nFamily
, sal_uInt16 nPrefix
,
150 const OUString
& rLocalName
,
151 const css::uno::Reference
< css::xml::sax::XAttributeList
> & xAttrList
) override
;
155 XMLTableStylesContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
156 const OUString
& rLName
,
157 const css::uno::Reference
< css::xml::sax::XAttributeList
> & xAttrList
,
158 const bool bAutoStyles
);
159 virtual ~XMLTableStylesContext() override
;
161 virtual void EndElement() override
;
163 virtual rtl::Reference
< SvXMLImportPropertyMapper
> GetImportPropertyMapper(
164 sal_uInt16 nFamily
) const override
;
165 virtual css::uno::Reference
< css::container::XNameContainer
>
166 GetStylesContainer( sal_uInt16 nFamily
) const override
;
167 virtual OUString
GetServiceName( sal_uInt16 nFamily
) const override
;
169 sal_Int32
GetIndex(const sal_Int16 nContextID
);
172 class ScXMLMasterStylesContext
: public SvXMLStylesContext
175 virtual SvXMLStyleContext
*CreateStyleChildContext( sal_uInt16 nPrefix
,
176 const OUString
& rLocalName
,
177 const css::uno::Reference
< css::xml::sax::XAttributeList
> & xAttrList
) override
;
179 virtual SvXMLStyleContext
*CreateStyleStyleChildContext( sal_uInt16 nFamily
,
180 sal_uInt16 nPrefix
, const OUString
& rLocalName
,
181 const css::uno::Reference
< css::xml::sax::XAttributeList
> & xAttrList
) override
;
183 virtual bool InsertStyleFamily( sal_uInt16 nFamily
) const override
;
187 ScXMLMasterStylesContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
188 const OUString
& rLName
,
189 const css::uno::Reference
< css::xml::sax::XAttributeList
> & xAttrList
);
191 virtual ~ScXMLMasterStylesContext() override
;
192 virtual void EndElement() override
;
195 class ScMasterPageContext
: public XMLTextMasterPageContext
197 css::uno::Reference
<css::beans::XPropertySet
> xPropSet
;
198 bool bContainsRightHeader
;
199 bool bContainsRightFooter
;
201 void ClearContent(const OUString
& rContent
);
205 ScMasterPageContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
206 const OUString
& rLName
,
207 const css::uno::Reference
< css::xml::sax::XAttributeList
> & xAttrList
,
209 virtual ~ScMasterPageContext() override
;
211 virtual SvXMLImportContext
*CreateHeaderFooterContext(
213 const OUString
& rLocalName
,
214 const css::uno::Reference
< css::xml::sax::XAttributeList
> & xAttrList
,
217 const bool bFirst
) override
;
219 virtual void Finish( bool bOverwrite
) override
;
222 class ScCellTextStyleContext
: public XMLTextStyleContext
224 sal_Int32 nLastSheet
;
226 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
227 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
230 ScCellTextStyleContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
231 const OUString
& rLName
,
232 const css::uno::Reference
< css::xml::sax::XAttributeList
> & xAttrList
,
233 SvXMLStylesContext
& rStyles
, sal_uInt16 nFamily
);
234 virtual ~ScCellTextStyleContext() override
;
236 // override FillPropertySet to store style information
237 virtual void FillPropertySet(
238 const css::uno::Reference
< css::beans::XPropertySet
> & rPropSet
) override
;
243 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */