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 
24 #ifndef RPT_XMLSTYLEIMPORT_HXX
25 #define RPT_XMLSTYLEIMPORT_HXX
26 
27 #include <rtl/ustring.hxx>
28 #include <xmloff/xmlimp.hxx>
29 #include <xmloff/xmlictxt.hxx>
30 #include <xmloff/maptype.hxx>
31 #include <xmloff/prstylei.hxx>
32 #include <xmloff/xmlimppr.hxx>
33 #ifndef _XMLTEXTMASTERPAGECONTEXT_HXX
34 #include <xmloff/XMLTextMasterPageContext.hxx>
35 #endif
36 #ifndef _XMLTEXTMASTERSTYLESCONTEXT_HXX
37 #include <xmloff/XMLTextMasterStylesContext.hxx>
38 #endif
39 #include <xmloff/contextid.hxx>
40 #include <xmloff/controlpropertyhdl.hxx>
41 #include <vector>
42 
43 namespace rptxml
44 {
45 	class ORptFilter;
46 
47 	class OControlStyleContext : public XMLPropStyleContext
48 	{
49 		::rtl::OUString				m_sDataStyleName;
50 		::rtl::OUString				sPageStyle;
51 		const rtl::OUString			sNumberFormat;
52 		SvXMLStylesContext*			pStyles;
53 		//	std::vector<ScXMLMapContent>	aMaps;
54 		com::sun::star::uno::Any	aConditionalFormat;
55 		sal_Int32					m_nNumberFormat;
56         ORptFilter&                 m_rImport;
57 		sal_Bool					bConditionalFormatCreated : 1;
58 		sal_Bool					bParentSet : 1;
59 
60 		ORptFilter& GetOwnImport() const;
61 
62         OControlStyleContext(const OControlStyleContext&);
63         void operator =(const OControlStyleContext&);
64 	protected:
65 
66 		virtual void SetAttribute( sal_uInt16 nPrefixKey,
67 								const ::rtl::OUString& rLocalName,
68 								const ::rtl::OUString& rValue );
69 
70 	public:
71 
72 		TYPEINFO();
73 
74 		OControlStyleContext( ORptFilter& rImport, sal_uInt16 nPrfx,
75 				const ::rtl::OUString& rLName,
76 				const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
77 				SvXMLStylesContext& rStyles, sal_uInt16 nFamily, sal_Bool bDefaultStyle = sal_False );
78 
79 		virtual ~OControlStyleContext();
80 
81 
82 		virtual void FillPropertySet(const ::com::sun::star::uno::Reference<
83 					::com::sun::star::beans::XPropertySet > & rPropSet );
84 
85 		virtual void SetDefaults();
86 
87   		void AddProperty(sal_Int16 nContextID, const com::sun::star::uno::Any& aValue);
88 
GetNumberFormat()89 		sal_Int32 GetNumberFormat() { return m_nNumberFormat; }
90 	};
91 
92 	class OReportStylesContext : public SvXMLStylesContext
93 	{
94         const ::rtl::OUString m_sTableStyleFamilyName;
95         const ::rtl::OUString m_sColumnStyleFamilyName;
96         const ::rtl::OUString m_sRowStyleFamilyName;
97         const ::rtl::OUString m_sCellStyleFamilyName;
98         ORptFilter&           m_rImport;
99 		sal_Int32 m_nNumberFormatIndex;
100 		sal_Int32 nMasterPageNameIndex;
101 		sal_Bool bAutoStyles : 1;
102 
103 		//mutable UniReference < SvXMLImportPropertyMapper > m_xControlImpPropMapper;
104         mutable UniReference < SvXMLImportPropertyMapper > m_xCellImpPropMapper;
105 	    mutable UniReference < SvXMLImportPropertyMapper > m_xColumnImpPropMapper;
106 	    mutable UniReference < SvXMLImportPropertyMapper > m_xRowImpPropMapper;
107 	    mutable UniReference < SvXMLImportPropertyMapper > m_xTableImpPropMapper;
108 
109         mutable ::com::sun::star::uno::Reference <
110 					::com::sun::star::container::XNameContainer > m_xCellStyles;
111 	    mutable ::com::sun::star::uno::Reference <
112 					    ::com::sun::star::container::XNameContainer > m_xColumnStyles;
113 	    mutable ::com::sun::star::uno::Reference <
114 					    ::com::sun::star::container::XNameContainer > m_xRowStyles;
115 	    mutable ::com::sun::star::uno::Reference <
116 					    ::com::sun::star::container::XNameContainer > m_xTableStyles;
117 
118 		ORptFilter& GetOwnImport() const;
119 
120         OReportStylesContext(const OReportStylesContext&);
121         void operator =(const OReportStylesContext&);
122 	protected:
123 
124 		// Create a style context.
125 		virtual SvXMLStyleContext *CreateStyleStyleChildContext(
126 				sal_uInt16 nFamily,
127 				sal_uInt16 nPrefix,
128 				const ::rtl::OUString& rLocalName,
129 				const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
130 
131         virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext(
132 		        sal_uInt16 nFamily, sal_uInt16 nPrefix,
133 		        const ::rtl::OUString& rLocalName,
134 		        const ::com::sun::star::uno::Reference<
135 			        ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
136 
137 	public:
138 
139 		TYPEINFO();
140 
141 		OReportStylesContext( ORptFilter& rImport, sal_uInt16 nPrfx ,
142 				const ::rtl::OUString& rLName ,
143 				const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
144 				const sal_Bool bAutoStyles );
145 		virtual ~OReportStylesContext();
146 
147 		virtual void EndElement();
148 
149 		virtual UniReference < SvXMLImportPropertyMapper > GetImportPropertyMapper(
150 							sal_uInt16 nFamily ) const;
151 		virtual ::com::sun::star::uno::Reference <
152 						::com::sun::star::container::XNameContainer >
153 			GetStylesContainer( sal_uInt16 nFamily ) const;
154 		virtual ::rtl::OUString GetServiceName( sal_uInt16 nFamily ) const;
155         virtual sal_uInt16 GetFamily( const ::rtl::OUString& rFamily ) const;
156 
157 		sal_Int32 GetIndex(const sal_Int16 nContextID);
158 	};
159 // -----------------------------------------------------------------------------
160 } // rptxml
161 // -----------------------------------------------------------------------------
162 #endif // RPT_XMLSTYLEIMPORT_HXX
163