Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_XMLOFF_PRSTYLEI_HXX
20 : #define INCLUDED_XMLOFF_PRSTYLEI_HXX
21 :
22 : #include <sal/config.h>
23 : #include <xmloff/dllapi.h>
24 : #include <sal/types.h>
25 : #include <com/sun/star/style/XStyle.hpp>
26 : #include <vector>
27 : #include <xmloff/xmlstyle.hxx>
28 :
29 : //UUUU
30 : #include <unordered_set>
31 :
32 : struct XMLPropertyState;
33 : class SvXMLStylesContext;
34 :
35 : namespace com { namespace sun { namespace star {
36 : namespace beans { class XPropertySet; }
37 : } } }
38 :
39 : //UUUU
40 : typedef std::unordered_set<OUString, OUStringHash> OldFillStyleDefinitionSet;
41 :
42 : class XMLOFF_DLLPUBLIC XMLPropStyleContext : public SvXMLStyleContext
43 : {
44 : private:
45 : const OUString msIsPhysical;
46 : const OUString msFollowStyle;
47 : ::std::vector< XMLPropertyState > maProperties;
48 : ::com::sun::star::uno::Reference < ::com::sun::star::style::XStyle > mxStyle;
49 : SvXMLImportContextRef mxStyles;
50 :
51 : //UUUU
52 : static OldFillStyleDefinitionSet maStandardSet;
53 : static OldFillStyleDefinitionSet maHeaderSet;
54 : static OldFillStyleDefinitionSet maFooterSet;
55 : static OldFillStyleDefinitionSet maParaSet;
56 :
57 : XMLPropStyleContext(XMLPropStyleContext &) SAL_DELETED_FUNCTION;
58 : void operator =(XMLPropStyleContext &) SAL_DELETED_FUNCTION;
59 :
60 : protected:
61 :
62 : //UUUU Helper to check if the local maProperties contzains the given
63 : // FillStyle tag and if the FillStyle there is different from FillStyle_NONE
64 : bool doNewDrawingLayerFillStyleDefinitionsExist(
65 : const ::rtl::OUString& rFillStyleTag) const;
66 :
67 : //UUUU Helper which will deactivate all old fill definitions (identified by
68 : // the given OldFillStyleDefinitionSet) in the local maProperties. Deactivation
69 : // is done setting theindex to -1. It returns true when actually old fill
70 : // definitions existed and were deactivated
71 : bool deactivateOldFillStyleDefinitions(
72 : const OldFillStyleDefinitionSet& rHashSetOfTags);
73 :
74 : //UUUU Helper to translate new DrawingLayer FillStyle values which are name-based
75 : // from ODF internal name to style display names which can be found in the current
76 : // document model (using NameOrIndex Items). The change is executed on the internal
77 : // maProperties. The return value is true when actually names were changed
78 : bool translateNameBasedDrawingLayerFillStyleDefinitionsToStyleDisplayNames();
79 :
80 : //UUUU provider for often used sets
81 : static const OldFillStyleDefinitionSet& getStandardSet();
82 : static const OldFillStyleDefinitionSet& getHeaderSet();
83 : static const OldFillStyleDefinitionSet& getFooterSet();
84 : static const OldFillStyleDefinitionSet& getParaSet();
85 :
86 : virtual void SetAttribute( sal_uInt16 nPrefixKey,
87 : const OUString& rLocalName,
88 : const OUString& rValue ) SAL_OVERRIDE;
89 50259 : SvXMLStylesContext *GetStyles() { return static_cast<SvXMLStylesContext *>(&mxStyles); }
90 80741 : ::std::vector< XMLPropertyState > & GetProperties() { return maProperties; }
91 :
92 : // Override this method to create a new style. It's called by
93 : // CreateInsert to create a style if a style with the requested family and
94 : // name couldn't be found.
95 : virtual ::com::sun::star::uno::Reference <
96 : ::com::sun::star::style::XStyle > Create();
97 :
98 : public:
99 :
100 : TYPEINFO_OVERRIDE();
101 :
102 : XMLPropStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
103 : const OUString& rLName,
104 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
105 : SvXMLStylesContext& rStyles, sal_uInt16 nFamily = 0,
106 : bool bDefaultStyle=false );
107 : virtual ~XMLPropStyleContext();
108 :
109 : virtual SvXMLImportContext *CreateChildContext(
110 : sal_uInt16 nPrefix,
111 : const OUString& rLocalName,
112 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE;
113 :
114 : virtual void FillPropertySet(
115 : const ::com::sun::star::uno::Reference<
116 : ::com::sun::star::beans::XPropertySet > & rPropSet );
117 :
118 7748 : const SvXMLStylesContext *GetStyles() const { return static_cast<const SvXMLStylesContext *>(&mxStyles); }
119 1472 : const ::std::vector< XMLPropertyState > & GetProperties() const { return maProperties; }
120 :
121 : const ::com::sun::star::uno::Reference <
122 : ::com::sun::star::style::XStyle >&
123 17301 : GetStyle() const { return mxStyle; }
124 1392 : void SetStyle(
125 : const ::com::sun::star::uno::Reference<
126 1392 : ::com::sun::star::style::XStyle >& xStl) { mxStyle = xStl; }
127 :
128 : virtual void SetDefaults() SAL_OVERRIDE;
129 :
130 : virtual void CreateAndInsert( bool bOverwrite ) SAL_OVERRIDE;
131 : virtual void Finish( bool bOverwrite ) SAL_OVERRIDE;
132 : };
133 :
134 : #endif
135 :
136 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|