xref: /trunk/main/xmloff/source/forms/layerimport.hxx (revision ecfe53c5)
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 _XMLOFF_FORMS_LAYERIMPORT_HXX_
25 #define _XMLOFF_FORMS_LAYERIMPORT_HXX_
26 
27 #include <com/sun/star/xml/sax/XAttributeList.hpp>
28 #include <com/sun/star/form/XFormsSupplier2.hpp>
29 #include <vos/ref.hxx>
30 #include "formattributes.hxx"
31 #include "callbacks.hxx"
32 #include "eventimport.hxx"
33 #include <tools/ref.hxx>
34 
35 class SvXMLImport;
36 class SvXMLImportContext;
37 class XMLPropertyHandlerFactory;
38 class SvXMLImportPropertyMapper;
39 class XMLPropStyleContext;
40 
41 SV_DECL_REF( SvXMLStylesContext )
42 	// unfortunately, we can't put this into our namespace, as the macro expands to (amongst others) a forward
43 	// declaration of the class name, which then would be in the namespace, too
44 
45 //.........................................................................
46 namespace xmloff
47 {
48 //.........................................................................
49 
50 	class OAttribute2Property;
51 
52 	//=====================================================================
53 	//= ControlReference
54 	//=====================================================================
55 	/// a structure containing a property set (the referred control) and a string (the list of referring controls)
56 /*	struct ControlReference
57 	{
58 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
59 					xReferredControl;
60 		::rtl::OUString
61 					sReferringControls;
62 
63 		ControlReference(
64 				const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxReferredControl,
65 				const ::rtl::OUString& _rReferringControls)
66 			:xReferredControl(_rxReferredControl)
67 			,sReferringControls(_rReferringControls)
68 		{
69 		}
70 	};
71 */
72 
73 	//=====================================================================
74 	//= OFormLayerXMLImport_Impl
75 	//=====================================================================
76 	class OFormLayerXMLImport_Impl
77 				: public ODefaultEventAttacherManager
78 	{
79 		friend class OFormLayerXMLImport;
80 
81 	protected:
82 		SvXMLImport&						m_rImporter;
83 		OAttribute2Property					m_aAttributeMetaData;
84 
85         /// the supplier for the forms of the currently imported page
86         ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormsSupplier2 >
87                                             m_xCurrentPageFormsSupp;
88 		SvXMLStylesContext*					m_pAutoStyles;
89 
90 	protected:
91 		DECLARE_STL_USTRINGACCESS_MAP( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >, MapString2PropertySet );
92 		DECLARE_STL_MAP( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >, MapString2PropertySet, ODrawPageCompare, MapDrawPage2Map);
93 
94 		MapDrawPage2Map			m_aControlIds;			// ids of the controls on all known page
95 		MapDrawPage2MapIterator	m_aCurrentPageIds;		// ifs of the controls on the current page
96 
97         typedef ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >, ::rtl::OUString >
98                                 ModelStringPair;
99         ::std::vector< ModelStringPair >
100                                 m_aControlReferences;	// control reference descriptions for current page
101         ::std::vector< ModelStringPair >
102                                 m_aCellValueBindings;   // information about controls bound to spreadsheet cells
103         ::std::vector< ModelStringPair >
104                                 m_aCellRangeListSources;// information about controls bound to spreadsheet cell range list sources
105 
106         ::std::vector< ModelStringPair >
107                                 m_aXFormsValueBindings; // collect xforms:bind attributes to be resolved
108 
109         ::std::vector< ModelStringPair >
110                                 m_aXFormsListBindings; // collect forms:xforms-list-source attributes to be resolved
111 
112         ::std::vector< ModelStringPair >
113                                 m_aXFormsSubmissions;   // collect xforms:submission attributes to be resolved
114 
115 	public:
116 		// IControlIdMap
117 		void	registerControlId(
118 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControl,
119 			const ::rtl::OUString& _rId);
120 		void	registerControlReferences(
121 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControl,
122 			const ::rtl::OUString& _rReferringControls);
123 
124 		// OFormLayerXMLImport_Impl
getAttributeMap()125         inline OAttribute2Property&		    getAttributeMap()   { return m_aAttributeMetaData; }
getGlobalContext()126         inline SvXMLImport&				    getGlobalContext()  { return m_rImporter; }
127 		const SvXMLStyleContext*			getStyleElement(const ::rtl::OUString& _rStyleName) const;
128 		void						        enterEventContext();
129 		void						        leaveEventContext();
130 		void                                applyControlNumberStyle(
131 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
132 			const ::rtl::OUString& _rControlNumerStyleName
133 		);
134         void                        registerCellValueBinding(
135             const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
136             const ::rtl::OUString& _rCellAddress
137         );
138 
139         void                        registerCellRangeListSource(
140             const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
141             const ::rtl::OUString& _rCellRangeAddress
142         );
143 
144         void                        registerXFormsValueBinding(
145             const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
146             const ::rtl::OUString& _rBindingID
147         );
148 
149         void                        registerXFormsListBinding(
150             const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
151             const ::rtl::OUString& _rBindingID
152         );
153 
154         void                        registerXFormsSubmission(
155             const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
156             const ::rtl::OUString& _rSubmissionID
157         );
158 
159 	protected:
160 		OFormLayerXMLImport_Impl(SvXMLImport& _rImporter);
161 		virtual ~OFormLayerXMLImport_Impl();
162 
163 		/** start importing the forms of the given page
164 		*/
165 		void startPage(
166 			const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& _rxDrawPage);
167 
168 		/** end importing the forms of the current page
169 		*/
170 		void endPage();
171 
172 		/** creates an import context for the office:forms element
173 		*/
174 		SvXMLImportContext* createOfficeFormsContext(
175 			SvXMLImport& _rImport,
176 			sal_uInt16 _nPrefix,
177 			const rtl::OUString& _rLocalName);
178 
179 		/** create an <type>SvXMLImportContext</type> instance which is able to import the &lt;form:form&gt;
180 			element.
181 		*/
182 		SvXMLImportContext* createContext(
183 			const sal_uInt16 _nPrefix,
184 			const rtl::OUString& _rLocalName,
185 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttribs);
186 
187 		/** get the control with the given id
188 		*/
189 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
190 				lookupControlId(const ::rtl::OUString& _rControlId);
191 
192 		/** seek to the given page
193 		*/
194 		void seekPage(
195 			const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& _rxDrawPage);
196 
197 		/** announces the auto-style context to the form importer
198 		*/
199 		void setAutoStyleContext(SvXMLStylesContext* _pNewContext);
200 
201         /** to be called when the document has been completely imported
202 
203             <p>For some documents (currently: only some spreadsheet documents) it's necessary
204             do to a post processing, since not all information from the file can be processed
205             if the document is not completed, yet.</p>
206         */
207         void documentDone( );
208 	};
209 
210 //.........................................................................
211 }	// namespace xmloff
212 //.........................................................................
213 
214 #endif // _XMLOFF_FORMS_LAYERIMPORT_HXX_
215 
216