xref: /trunk/main/xmloff/inc/xmloff/prstylei.hxx (revision 56b35d86)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _XMLOFF_PRSTYLEI_HXX_
24 #define _XMLOFF_PRSTYLEI_HXX_
25 
26 #include "sal/config.h"
27 #include "xmloff/dllapi.h"
28 #include "sal/types.h"
29 #include <com/sun/star/style/XStyle.hpp>
30 #include <vector>
31 #include <xmloff/xmlstyle.hxx>
32 
33 //UUUU
34 #include <hash_set>
35 
36 struct XMLPropertyState;
37 class SvXMLStylesContext;
38 
39 namespace com { namespace sun { namespace star {
40 	namespace beans { class XPropertySet; }
41 } } }
42 
43 //UUUU
44 typedef std::hash_set< rtl::OUString, rtl::OUStringHash > OldFillStyleDefinitionSet;
45 
46 class XMLOFF_DLLPUBLIC XMLPropStyleContext : public SvXMLStyleContext
47 {
48 private:
49 	const ::rtl::OUString msIsPhysical;
50 	const ::rtl::OUString msFollowStyle;
51 	::std::vector< XMLPropertyState > maProperties;
52 	::com::sun::star::uno::Reference < ::com::sun::star::style::XStyle > mxStyle;
53 	SvXMLImportContextRef				mxStyles;
54 
55     //UUUU
56     static OldFillStyleDefinitionSet maStandardSet;
57     static OldFillStyleDefinitionSet maHeaderSet;
58     static OldFillStyleDefinitionSet maFooterSet;
59     static OldFillStyleDefinitionSet maParaSet;
60 
61     SAL_DLLPRIVATE XMLPropStyleContext(XMLPropStyleContext &); // not defined
62     SAL_DLLPRIVATE void operator =(XMLPropStyleContext &); // not defined
63 
64 protected:
65 
66     //UUUU Helper to check if the local maProperties contzains the given
67     // FillStyle tag and if the FillStyle there is different from FillStyle_NONE
68     bool doNewDrawingLayerFillStyleDefinitionsExist(
69         const ::rtl::OUString& rFillStyleTag) const;
70 
71     //UUUU Helper which will deactivate all old fill definitions (identified by
72     // the given OldFillStyleDefinitionSet) in the local maProperties. Deactivation
73     // is done setting theindex to -1. It returns true when actually old fill
74     // definitions existed and were deactivated
75     bool deactivateOldFillStyleDefinitions(
76         const OldFillStyleDefinitionSet& rHashSetOfTags);
77 
78     //UUUU Helper to translate new DrawingLayer FillStyle values which are name-based
79     // from ODF internal name to style display names which can be found in the current
80     // document model (using NameOrIndex Items). The change is executed on the internal
81     // maProperties. The return value is true when actually names were changed
82     bool translateNameBasedDrawingLayerFillStyleDefinitionsToStyleDisplayNames();
83 
84     //UUUU provider for often used sets
85     const OldFillStyleDefinitionSet& getStandardSet();
86     const OldFillStyleDefinitionSet& getHeaderSet();
87     const OldFillStyleDefinitionSet& getFooterSet();
88     const OldFillStyleDefinitionSet& getParaSet();
89 
90 	virtual void SetAttribute( sal_uInt16 nPrefixKey,
91 							   const ::rtl::OUString& rLocalName,
92 							   const ::rtl::OUString& rValue );
GetStyles()93 	SvXMLStylesContext *GetStyles() { return (SvXMLStylesContext *)&mxStyles; }
GetProperties()94 	::std::vector< XMLPropertyState > & GetProperties() { return maProperties; }
95 
96 	// This methos my be overloaded to create a new style. Its called by
97 	// CreateInsert to create a style if a style with the requested family and
98 	// name couldn't be found. The st
99 	virtual ::com::sun::star::uno::Reference <
100 		::com::sun::star::style::XStyle > Create();
101 
102 public:
103 
104 	TYPEINFO();
105 
106 	XMLPropStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
107 			const ::rtl::OUString& rLName,
108 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
109 			SvXMLStylesContext& rStyles, sal_uInt16 nFamily = 0,
110 		    sal_Bool bDefaultStyle=sal_False );
111 	virtual ~XMLPropStyleContext();
112 
113 	virtual SvXMLImportContext *CreateChildContext(
114 			sal_uInt16 nPrefix,
115 			const ::rtl::OUString& rLocalName,
116 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
117 
118 	virtual void FillPropertySet(
119 			const ::com::sun::star::uno::Reference<
120 				::com::sun::star::beans::XPropertySet > & rPropSet );
121 
GetStyles() const122 	const SvXMLStylesContext *GetStyles() const { return (const SvXMLStylesContext *)&mxStyles; }
GetProperties() const123 	const ::std::vector< XMLPropertyState > & GetProperties() const { return maProperties; }
124 
125 	const ::com::sun::star::uno::Reference <
126 				::com::sun::star::style::XStyle >&
GetStyle() const127 	   		GetStyle() const { return mxStyle; }
SetStyle(const::com::sun::star::uno::Reference<::com::sun::star::style::XStyle> & xStl)128 	void SetStyle(
129 			const ::com::sun::star::uno::Reference<
130 				::com::sun::star::style::XStyle >& xStl) { mxStyle = xStl; }
131 
132 	virtual void SetDefaults();
133 
134 	virtual void CreateAndInsert( sal_Bool bOverwrite );
135 	virtual void Finish( sal_Bool bOverwrite );
136 };
137 
138 #endif
139