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 .
19 #ifndef INCLUDED_XMLOFF_PRSTYLEI_HXX
20 #define INCLUDED_XMLOFF_PRSTYLEI_HXX
22 #include <sal/config.h>
23 #include <xmloff/dllapi.h>
24 #include <sal/types.h>
25 #include <com/sun/star/style/XStyle.hpp>
27 #include <xmloff/xmlstyle.hxx>
30 #include <unordered_set>
32 struct XMLPropertyState
;
33 class SvXMLStylesContext
;
35 namespace com
{ namespace sun
{ namespace star
{
36 namespace beans
{ class XPropertySet
; }
40 typedef std::unordered_set
<OUString
, OUStringHash
> OldFillStyleDefinitionSet
;
42 class XMLOFF_DLLPUBLIC XMLPropStyleContext
: public SvXMLStyleContext
45 const OUString msIsPhysical
;
46 const OUString msFollowStyle
;
47 ::std::vector
< XMLPropertyState
> maProperties
;
48 css::uno::Reference
< css::style::XStyle
> mxStyle
;
49 SvXMLImportContextRef mxStyles
;
51 XMLPropStyleContext(XMLPropStyleContext
&) = delete;
52 void operator =(XMLPropStyleContext
&) = delete;
56 //UUUU Helper to check if the local maProperties contains the given
57 // FillStyle tag and if the FillStyle there is different from FillStyle_NONE
58 bool doNewDrawingLayerFillStyleDefinitionsExist(
59 const ::rtl::OUString
& rFillStyleTag
) const;
61 //UUUU Helper which will deactivate all old fill definitions (identified by
62 // the given OldFillStyleDefinitionSet) in the local maProperties. Deactivation
63 // is done setting theindex to -1. It returns true when actually old fill
64 // definitions existed and were deactivated
65 void deactivateOldFillStyleDefinitions(
66 const OldFillStyleDefinitionSet
& rHashSetOfTags
);
68 //UUUU Helper to translate new DrawingLayer FillStyle values which are name-based
69 // from ODF internal name to style display names which can be found in the current
70 // document model (using NameOrIndex Items). The change is executed on the internal
71 // maProperties. The return value is true when actually names were changed
72 void translateNameBasedDrawingLayerFillStyleDefinitionsToStyleDisplayNames();
74 //UUUU provider for often used sets
75 static const OldFillStyleDefinitionSet
& getStandardSet();
76 static const OldFillStyleDefinitionSet
& getHeaderSet();
77 static const OldFillStyleDefinitionSet
& getFooterSet();
79 virtual void SetAttribute( sal_uInt16 nPrefixKey
,
80 const OUString
& rLocalName
,
81 const OUString
& rValue
) override
;
82 SvXMLStylesContext
*GetStyles() { return static_cast<SvXMLStylesContext
*>(mxStyles
.get()); }
83 ::std::vector
< XMLPropertyState
> & GetProperties() { return maProperties
; }
85 // Override this method to create a new style. It's called by
86 // CreateInsert to create a style if a style with the requested family and
87 // name couldn't be found.
88 virtual css::uno::Reference
< css::style::XStyle
> Create();
93 XMLPropStyleContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
94 const OUString
& rLName
,
95 const css::uno::Reference
< css::xml::sax::XAttributeList
> & xAttrList
,
96 SvXMLStylesContext
& rStyles
, sal_uInt16 nFamily
,
97 bool bDefaultStyle
=false );
98 virtual ~XMLPropStyleContext() override
;
100 virtual SvXMLImportContext
*CreateChildContext(
102 const OUString
& rLocalName
,
103 const css::uno::Reference
< css::xml::sax::XAttributeList
> & xAttrList
) override
;
105 virtual void FillPropertySet(
106 const css::uno::Reference
< css::beans::XPropertySet
> & rPropSet
);
108 const SvXMLStylesContext
*GetStyles() const { return static_cast<const SvXMLStylesContext
*>(mxStyles
.get()); }
109 const ::std::vector
< XMLPropertyState
> & GetProperties() const { return maProperties
; }
111 const css::uno::Reference
< css::style::XStyle
>&
112 GetStyle() const { return mxStyle
; }
114 const css::uno::Reference
< css::style::XStyle
>& xStl
) { mxStyle
= xStl
; }
116 virtual void SetDefaults() override
;
118 virtual void CreateAndInsert( bool bOverwrite
) override
;
119 virtual void Finish( bool bOverwrite
) override
;
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */