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 .
22 #include <rtl/ustring.hxx>
24 #include <xmloff/xmlictxt.hxx>
25 #include <xmloff/prstylei.hxx>
26 #include <xmloff/xmlimppr.hxx>
27 #include <xmloff/XMLShapeStyleContext.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 XMLTableStylesContext
;
68 class XMLTableStyleContext
: public XMLPropStyleContext
70 OUString sDataStyleName
;
72 XMLTableStylesContext
* pStyles
;
73 sal_Int32 nNumberFormat
;
76 ScConditionalFormat
* mpCondFormat
;
77 bool mbDeleteCondFormat
;
79 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
80 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
84 virtual void SetAttribute( sal_Int32 nElement
,
85 const OUString
& rValue
) override
;
89 XMLTableStyleContext( ScXMLImport
& rImport
,
90 XMLTableStylesContext
& rStyles
, XmlStyleFamily nFamily
, bool bDefaultStyle
= false );
91 virtual ~XMLTableStyleContext() override
;
93 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext(
94 sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& AttrList
) override
;
96 virtual void FillPropertySet(const css::uno::Reference
<
97 css::beans::XPropertySet
> & rPropSet
) override
;
99 virtual void SetDefaults() override
;
101 void AddProperty(sal_Int16 nContextID
, const css::uno::Any
& aValue
);
102 XMLPropertyState
* FindProperty(const sal_Int16 nContextID
);
104 sal_Int32
GetNumberFormat();// { return nNumberFormat; }
106 SCTAB
GetLastSheet() const { return nLastSheet
; }
107 void SetLastSheet(SCTAB nNew
) { nLastSheet
= nNew
; }
109 void ApplyCondFormat( const css::uno::Sequence
<css::table::CellRangeAddress
>& xCellRanges
);
112 using XMLPropStyleContext::SetStyle
;
115 class XMLTableStylesContext
: public SvXMLStylesContext
117 css::uno::Reference
< css::container::XNameContainer
> xCellStyles
;
118 css::uno::Reference
< css::container::XNameContainer
> xColumnStyles
;
119 css::uno::Reference
< css::container::XNameContainer
> xRowStyles
;
120 css::uno::Reference
< css::container::XNameContainer
> xTableStyles
;
121 css::uno::Reference
< css::container::XNameContainer
> xGraphicStyles
;
122 sal_Int32 nNumberFormatIndex
;
123 sal_Int32 nConditionalFormatIndex
;
124 sal_Int32 nCellStyleIndex
;
125 sal_Int32 nMasterPageNameIndex
;
128 rtl::Reference
< SvXMLImportPropertyMapper
> xCellImpPropMapper
;
129 rtl::Reference
< SvXMLImportPropertyMapper
> xColumnImpPropMapper
;
130 rtl::Reference
< SvXMLImportPropertyMapper
> xRowImpPropMapper
;
131 rtl::Reference
< SvXMLImportPropertyMapper
> xTableImpPropMapper
;
133 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
134 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
138 // Create a style context.
139 using SvXMLStylesContext::CreateStyleStyleChildContext
;
140 virtual SvXMLStyleContext
*CreateStyleStyleChildContext(
141 XmlStyleFamily nFamily
,
143 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & xAttrList
) override
;
145 using SvXMLStylesContext::CreateDefaultStyleStyleChildContext
;
146 virtual SvXMLStyleContext
*CreateDefaultStyleStyleChildContext(
147 XmlStyleFamily nFamily
, sal_Int32 nElement
,
148 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & xAttrList
) override
;
152 XMLTableStylesContext( SvXMLImport
& rImport
, bool bAutoStyles
);
153 virtual ~XMLTableStylesContext() override
;
155 virtual void SAL_CALL
endFastElement(sal_Int32 nElement
) override
;
157 virtual rtl::Reference
< SvXMLImportPropertyMapper
> GetImportPropertyMapper(
158 XmlStyleFamily nFamily
) const override
;
159 virtual css::uno::Reference
< css::container::XNameContainer
>
160 GetStylesContainer( XmlStyleFamily nFamily
) const override
;
161 virtual OUString
GetServiceName( XmlStyleFamily nFamily
) const override
;
163 sal_Int32
GetIndex(const sal_Int16 nContextID
);
166 class ScXMLMasterStylesContext
: public SvXMLStylesContext
169 virtual SvXMLStyleContext
*CreateStyleChildContext( sal_Int32 nElement
,
170 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & xAttrList
) override
;
172 using SvXMLStylesContext::CreateStyleStyleChildContext
;
173 virtual SvXMLStyleContext
*CreateStyleStyleChildContext( XmlStyleFamily nFamily
,
175 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & xAttrList
) override
;
177 virtual bool InsertStyleFamily( XmlStyleFamily nFamily
) const override
;
181 ScXMLMasterStylesContext( SvXMLImport
& rImport
);
183 virtual ~ScXMLMasterStylesContext() override
;
184 virtual void SAL_CALL
endFastElement(sal_Int32 nElement
) override
;
187 class ScMasterPageContext
: public XMLTextMasterPageContext
189 css::uno::Reference
<css::beans::XPropertySet
> xPropSet
;
190 bool bContainsRightHeader
;
191 bool bContainsRightFooter
;
193 void ClearContent(const OUString
& rContent
);
197 ScMasterPageContext( SvXMLImport
& rImport
, sal_Int32 nElement
,
198 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & xAttrList
,
200 virtual ~ScMasterPageContext() override
;
202 virtual SvXMLImportContext
*CreateHeaderFooterContext(
204 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & xAttrList
,
207 const bool bFirst
) override
;
209 virtual void Finish( bool bOverwrite
) override
;
212 class ScCellTextStyleContext
: public XMLTextStyleContext
214 sal_Int32 nLastSheet
;
216 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
217 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
220 ScCellTextStyleContext( SvXMLImport
& rImport
,
221 SvXMLStylesContext
& rStyles
, XmlStyleFamily nFamily
);
222 virtual ~ScCellTextStyleContext() override
;
224 // override FillPropertySet to store style information
225 virtual void FillPropertySet(
226 const css::uno::Reference
< css::beans::XPropertySet
> & rPropSet
) override
;
229 class ScShapeStyleContext
: public XMLShapeStyleContext
231 using XMLShapeStyleContext::XMLShapeStyleContext
;
232 void Finish(bool bOverwrite
) override
;
235 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */