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/XMLTextMasterPageContext.hxx>
28 #include <xmloff/txtstyli.hxx>
29 #include "xmlimprt.hxx"
31 class ScConditionalFormat
;
33 class ScXMLCellImportPropertyMapper
: public SvXMLImportPropertyMapper
39 ScXMLCellImportPropertyMapper(
40 const rtl::Reference
< XMLPropertySetMapper
>& rMapper
,
41 SvXMLImport
& rImport
);
42 virtual ~ScXMLCellImportPropertyMapper() override
;
44 /** This method is called when all attributes have been processed. It may be used to remove items that are incomplete */
45 virtual void finished(
46 ::std::vector
< XMLPropertyState
>& rProperties
, sal_Int32 nStartIndex
, sal_Int32 nEndIndex
) const override
;
49 class ScXMLRowImportPropertyMapper
: public SvXMLImportPropertyMapper
55 ScXMLRowImportPropertyMapper(
56 const rtl::Reference
< XMLPropertySetMapper
>& rMapper
,
57 SvXMLImport
& rImport
);
58 virtual ~ScXMLRowImportPropertyMapper() override
;
60 /** This method is called when all attributes have been processed. It may be used to remove items that are incomplete */
61 virtual void finished(
62 ::std::vector
< XMLPropertyState
>& rProperties
, sal_Int32 nStartIndex
, sal_Int32 nEndIndex
) const override
;
65 class XMLTableStyleContext
: public XMLPropStyleContext
67 OUString sDataStyleName
;
69 SvXMLStylesContext
* pStyles
;
70 sal_Int32 nNumberFormat
;
73 ScConditionalFormat
* mpCondFormat
;
74 bool mbDeleteCondFormat
;
76 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
77 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
81 virtual void SetAttribute( sal_Int32 nElement
,
82 const OUString
& rValue
) override
;
86 XMLTableStyleContext( ScXMLImport
& rImport
,
87 SvXMLStylesContext
& rStyles
, XmlStyleFamily nFamily
, bool bDefaultStyle
= false );
88 virtual ~XMLTableStyleContext() override
;
90 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
createFastChildContext(
91 sal_Int32 nElement
, const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& AttrList
) override
;
93 virtual void FillPropertySet(const css::uno::Reference
<
94 css::beans::XPropertySet
> & rPropSet
) override
;
96 virtual void SetDefaults() override
;
98 void AddProperty(sal_Int16 nContextID
, const css::uno::Any
& aValue
);
99 XMLPropertyState
* FindProperty(const sal_Int16 nContextID
);
101 sal_Int32
GetNumberFormat();// { return nNumberFormat; }
103 SCTAB
GetLastSheet() const { return nLastSheet
; }
104 void SetLastSheet(SCTAB nNew
) { nLastSheet
= nNew
; }
106 void ApplyCondFormat( const css::uno::Sequence
<css::table::CellRangeAddress
>& xCellRanges
);
109 using XMLPropStyleContext::SetStyle
;
112 class XMLTableStylesContext
: public SvXMLStylesContext
114 css::uno::Reference
< css::container::XNameContainer
> xCellStyles
;
115 css::uno::Reference
< css::container::XNameContainer
> xColumnStyles
;
116 css::uno::Reference
< css::container::XNameContainer
> xRowStyles
;
117 css::uno::Reference
< css::container::XNameContainer
> xTableStyles
;
118 sal_Int32 nNumberFormatIndex
;
119 sal_Int32 nConditionalFormatIndex
;
120 sal_Int32 nCellStyleIndex
;
121 sal_Int32 nMasterPageNameIndex
;
124 rtl::Reference
< SvXMLImportPropertyMapper
> xCellImpPropMapper
;
125 rtl::Reference
< SvXMLImportPropertyMapper
> xColumnImpPropMapper
;
126 rtl::Reference
< SvXMLImportPropertyMapper
> xRowImpPropMapper
;
127 rtl::Reference
< SvXMLImportPropertyMapper
> xTableImpPropMapper
;
129 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
130 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
134 // Create a style context.
135 using SvXMLStylesContext::CreateStyleStyleChildContext
;
136 virtual SvXMLStyleContext
*CreateStyleStyleChildContext(
137 XmlStyleFamily nFamily
,
139 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & xAttrList
) override
;
141 using SvXMLStylesContext::CreateDefaultStyleStyleChildContext
;
142 virtual SvXMLStyleContext
*CreateDefaultStyleStyleChildContext(
143 XmlStyleFamily nFamily
, sal_Int32 nElement
,
144 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & xAttrList
) override
;
148 XMLTableStylesContext( SvXMLImport
& rImport
, bool bAutoStyles
);
149 virtual ~XMLTableStylesContext() override
;
151 virtual void SAL_CALL
endFastElement(sal_Int32 nElement
) override
;
153 virtual rtl::Reference
< SvXMLImportPropertyMapper
> GetImportPropertyMapper(
154 XmlStyleFamily nFamily
) const override
;
155 virtual css::uno::Reference
< css::container::XNameContainer
>
156 GetStylesContainer( XmlStyleFamily nFamily
) const override
;
157 virtual OUString
GetServiceName( XmlStyleFamily nFamily
) const override
;
159 sal_Int32
GetIndex(const sal_Int16 nContextID
);
162 class ScXMLMasterStylesContext
: public SvXMLStylesContext
165 virtual SvXMLStyleContext
*CreateStyleChildContext( sal_Int32 nElement
,
166 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & xAttrList
) override
;
168 using SvXMLStylesContext::CreateStyleStyleChildContext
;
169 virtual SvXMLStyleContext
*CreateStyleStyleChildContext( XmlStyleFamily nFamily
,
171 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & xAttrList
) override
;
173 virtual bool InsertStyleFamily( XmlStyleFamily nFamily
) const override
;
177 ScXMLMasterStylesContext( SvXMLImport
& rImport
);
179 virtual ~ScXMLMasterStylesContext() override
;
180 virtual void SAL_CALL
endFastElement(sal_Int32 nElement
) override
;
183 class ScMasterPageContext
: public XMLTextMasterPageContext
185 css::uno::Reference
<css::beans::XPropertySet
> xPropSet
;
186 bool bContainsRightHeader
;
187 bool bContainsRightFooter
;
189 void ClearContent(const OUString
& rContent
);
193 ScMasterPageContext( SvXMLImport
& rImport
, sal_Int32 nElement
,
194 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & xAttrList
,
196 virtual ~ScMasterPageContext() override
;
198 virtual SvXMLImportContext
*CreateHeaderFooterContext(
200 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & xAttrList
,
203 const bool bFirst
) override
;
205 virtual void Finish( bool bOverwrite
) override
;
208 class ScCellTextStyleContext
: public XMLTextStyleContext
210 sal_Int32 nLastSheet
;
212 const ScXMLImport
& GetScImport() const { return static_cast<const ScXMLImport
&>(GetImport()); }
213 ScXMLImport
& GetScImport() { return static_cast<ScXMLImport
&>(GetImport()); }
216 ScCellTextStyleContext( SvXMLImport
& rImport
,
217 SvXMLStylesContext
& rStyles
, XmlStyleFamily nFamily
);
218 virtual ~ScCellTextStyleContext() override
;
220 // override FillPropertySet to store style information
221 virtual void FillPropertySet(
222 const css::uno::Reference
< css::beans::XPropertySet
> & rPropSet
) override
;
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */