xref: /AOO41X/main/xmloff/source/forms/layerimport.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _XMLOFF_FORMS_LAYERIMPORT_HXX_
29*cdf0e10cSrcweir #define _XMLOFF_FORMS_LAYERIMPORT_HXX_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <com/sun/star/xml/sax/XAttributeList.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/form/XFormsSupplier2.hpp>
33*cdf0e10cSrcweir #include <vos/ref.hxx>
34*cdf0e10cSrcweir #include "formattributes.hxx"
35*cdf0e10cSrcweir #include "callbacks.hxx"
36*cdf0e10cSrcweir #include "eventimport.hxx"
37*cdf0e10cSrcweir #include <tools/ref.hxx>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir class SvXMLImport;
40*cdf0e10cSrcweir class SvXMLImportContext;
41*cdf0e10cSrcweir class XMLPropertyHandlerFactory;
42*cdf0e10cSrcweir class SvXMLImportPropertyMapper;
43*cdf0e10cSrcweir class XMLPropStyleContext;
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir SV_DECL_REF( SvXMLStylesContext )
46*cdf0e10cSrcweir 	// unfortunately, we can't put this into our namespace, as the macro expands to (amongst others) a forward
47*cdf0e10cSrcweir 	// declaration of the class name, which then would be in the namespace, too
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir //.........................................................................
50*cdf0e10cSrcweir namespace xmloff
51*cdf0e10cSrcweir {
52*cdf0e10cSrcweir //.........................................................................
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir 	class OAttribute2Property;
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir 	//=====================================================================
57*cdf0e10cSrcweir 	//= ControlReference
58*cdf0e10cSrcweir 	//=====================================================================
59*cdf0e10cSrcweir 	/// a structure containing a property set (the referred control) and a string (the list of referring controls)
60*cdf0e10cSrcweir /*	struct ControlReference
61*cdf0e10cSrcweir 	{
62*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
63*cdf0e10cSrcweir 					xReferredControl;
64*cdf0e10cSrcweir 		::rtl::OUString
65*cdf0e10cSrcweir 					sReferringControls;
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir 		ControlReference(
68*cdf0e10cSrcweir 				const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxReferredControl,
69*cdf0e10cSrcweir 				const ::rtl::OUString& _rReferringControls)
70*cdf0e10cSrcweir 			:xReferredControl(_rxReferredControl)
71*cdf0e10cSrcweir 			,sReferringControls(_rReferringControls)
72*cdf0e10cSrcweir 		{
73*cdf0e10cSrcweir 		}
74*cdf0e10cSrcweir 	};
75*cdf0e10cSrcweir */
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir 	//=====================================================================
78*cdf0e10cSrcweir 	//= OFormLayerXMLImport_Impl
79*cdf0e10cSrcweir 	//=====================================================================
80*cdf0e10cSrcweir 	class OFormLayerXMLImport_Impl
81*cdf0e10cSrcweir 				: public ODefaultEventAttacherManager
82*cdf0e10cSrcweir 	{
83*cdf0e10cSrcweir 		friend class OFormLayerXMLImport;
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir 	protected:
86*cdf0e10cSrcweir 		SvXMLImport&						m_rImporter;
87*cdf0e10cSrcweir 		OAttribute2Property					m_aAttributeMetaData;
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir         /// the supplier for the forms of the currently imported page
90*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormsSupplier2 >
91*cdf0e10cSrcweir                                             m_xCurrentPageFormsSupp;
92*cdf0e10cSrcweir 		SvXMLStylesContext*					m_pAutoStyles;
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir 	protected:
95*cdf0e10cSrcweir 		DECLARE_STL_USTRINGACCESS_MAP( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >, MapString2PropertySet );
96*cdf0e10cSrcweir 		DECLARE_STL_MAP( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >, MapString2PropertySet, ODrawPageCompare, MapDrawPage2Map);
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 		MapDrawPage2Map			m_aControlIds;			// ids of the controls on all known page
99*cdf0e10cSrcweir 		MapDrawPage2MapIterator	m_aCurrentPageIds;		// ifs of the controls on the current page
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir         typedef ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >, ::rtl::OUString >
102*cdf0e10cSrcweir                                 ModelStringPair;
103*cdf0e10cSrcweir         ::std::vector< ModelStringPair >
104*cdf0e10cSrcweir                                 m_aControlReferences;	// control reference descriptions for current page
105*cdf0e10cSrcweir         ::std::vector< ModelStringPair >
106*cdf0e10cSrcweir                                 m_aCellValueBindings;   // information about controls bound to spreadsheet cells
107*cdf0e10cSrcweir         ::std::vector< ModelStringPair >
108*cdf0e10cSrcweir                                 m_aCellRangeListSources;// information about controls bound to spreadsheet cell range list sources
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir         ::std::vector< ModelStringPair >
111*cdf0e10cSrcweir                                 m_aXFormsValueBindings; // collect xforms:bind attributes to be resolved
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir         ::std::vector< ModelStringPair >
114*cdf0e10cSrcweir                                 m_aXFormsListBindings; // collect forms:xforms-list-source attributes to be resolved
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir         ::std::vector< ModelStringPair >
117*cdf0e10cSrcweir                                 m_aXFormsSubmissions;   // collect xforms:submission attributes to be resolved
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir 	public:
120*cdf0e10cSrcweir 		// IControlIdMap
121*cdf0e10cSrcweir 		void	registerControlId(
122*cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControl,
123*cdf0e10cSrcweir 			const ::rtl::OUString& _rId);
124*cdf0e10cSrcweir 		void	registerControlReferences(
125*cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControl,
126*cdf0e10cSrcweir 			const ::rtl::OUString& _rReferringControls);
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 		// OFormLayerXMLImport_Impl
129*cdf0e10cSrcweir         inline OAttribute2Property&		    getAttributeMap()   { return m_aAttributeMetaData; }
130*cdf0e10cSrcweir         inline SvXMLImport&				    getGlobalContext()  { return m_rImporter; }
131*cdf0e10cSrcweir 		const SvXMLStyleContext*			getStyleElement(const ::rtl::OUString& _rStyleName) const;
132*cdf0e10cSrcweir 		void						        enterEventContext();
133*cdf0e10cSrcweir 		void						        leaveEventContext();
134*cdf0e10cSrcweir 		void                                applyControlNumberStyle(
135*cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
136*cdf0e10cSrcweir 			const ::rtl::OUString& _rControlNumerStyleName
137*cdf0e10cSrcweir 		);
138*cdf0e10cSrcweir         void                        registerCellValueBinding(
139*cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
140*cdf0e10cSrcweir             const ::rtl::OUString& _rCellAddress
141*cdf0e10cSrcweir         );
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir         void                        registerCellRangeListSource(
144*cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
145*cdf0e10cSrcweir             const ::rtl::OUString& _rCellRangeAddress
146*cdf0e10cSrcweir         );
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir         void                        registerXFormsValueBinding(
149*cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
150*cdf0e10cSrcweir             const ::rtl::OUString& _rBindingID
151*cdf0e10cSrcweir         );
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir         void                        registerXFormsListBinding(
154*cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
155*cdf0e10cSrcweir             const ::rtl::OUString& _rBindingID
156*cdf0e10cSrcweir         );
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir         void                        registerXFormsSubmission(
159*cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
160*cdf0e10cSrcweir             const ::rtl::OUString& _rSubmissionID
161*cdf0e10cSrcweir         );
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir 	protected:
164*cdf0e10cSrcweir 		OFormLayerXMLImport_Impl(SvXMLImport& _rImporter);
165*cdf0e10cSrcweir 		virtual ~OFormLayerXMLImport_Impl();
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir 		/** start importing the forms of the given page
168*cdf0e10cSrcweir 		*/
169*cdf0e10cSrcweir 		void startPage(
170*cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& _rxDrawPage);
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir 		/** end importing the forms of the current page
173*cdf0e10cSrcweir 		*/
174*cdf0e10cSrcweir 		void endPage();
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 		/** creates an import context for the office:forms element
177*cdf0e10cSrcweir 		*/
178*cdf0e10cSrcweir 		SvXMLImportContext* createOfficeFormsContext(
179*cdf0e10cSrcweir 			SvXMLImport& _rImport,
180*cdf0e10cSrcweir 			sal_uInt16 _nPrefix,
181*cdf0e10cSrcweir 			const rtl::OUString& _rLocalName);
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir 		/** create an <type>SvXMLImportContext</type> instance which is able to import the &lt;form:form&gt;
184*cdf0e10cSrcweir 			element.
185*cdf0e10cSrcweir 		*/
186*cdf0e10cSrcweir 		SvXMLImportContext* createContext(
187*cdf0e10cSrcweir 			const sal_uInt16 _nPrefix,
188*cdf0e10cSrcweir 			const rtl::OUString& _rLocalName,
189*cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttribs);
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir 		/** get the control with the given id
192*cdf0e10cSrcweir 		*/
193*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
194*cdf0e10cSrcweir 				lookupControlId(const ::rtl::OUString& _rControlId);
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir 		/** seek to the given page
197*cdf0e10cSrcweir 		*/
198*cdf0e10cSrcweir 		void seekPage(
199*cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& _rxDrawPage);
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 		/** announces the auto-style context to the form importer
202*cdf0e10cSrcweir 		*/
203*cdf0e10cSrcweir 		void setAutoStyleContext(SvXMLStylesContext* _pNewContext);
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir         /** to be called when the document has been completely imported
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir             <p>For some documents (currently: only some spreadsheet documents) it's necessary
208*cdf0e10cSrcweir             do to a post processing, since not all information from the file can be processed
209*cdf0e10cSrcweir             if the document is not completed, yet.</p>
210*cdf0e10cSrcweir         */
211*cdf0e10cSrcweir         void documentDone( );
212*cdf0e10cSrcweir 	};
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir //.........................................................................
215*cdf0e10cSrcweir }	// namespace xmloff
216*cdf0e10cSrcweir //.........................................................................
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir #endif // _XMLOFF_FORMS_LAYERIMPORT_HXX_
219*cdf0e10cSrcweir 
220