1*ecfe53c5SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ecfe53c5SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ecfe53c5SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ecfe53c5SAndrew Rist  * distributed with this work for additional information
6*ecfe53c5SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ecfe53c5SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ecfe53c5SAndrew Rist  * "License"); you may not use this file except in compliance
9*ecfe53c5SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ecfe53c5SAndrew Rist  *
11*ecfe53c5SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ecfe53c5SAndrew Rist  *
13*ecfe53c5SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ecfe53c5SAndrew Rist  * software distributed under the License is distributed on an
15*ecfe53c5SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ecfe53c5SAndrew Rist  * KIND, either express or implied.  See the License for the
17*ecfe53c5SAndrew Rist  * specific language governing permissions and limitations
18*ecfe53c5SAndrew Rist  * under the License.
19*ecfe53c5SAndrew Rist  *
20*ecfe53c5SAndrew Rist  *************************************************************/
21*ecfe53c5SAndrew Rist 
22*ecfe53c5SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _XMLOFF_FORMLAYEREXPORT_HXX_
25cdf0e10cSrcweir #define _XMLOFF_FORMLAYEREXPORT_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "sal/config.h"
28cdf0e10cSrcweir #include "xmloff/dllapi.h"
29cdf0e10cSrcweir #include <vos/refernce.hxx>
30cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPage.hpp>
31cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp>
32cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
33cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp>
34cdf0e10cSrcweir #include <vos/ref.hxx>
35cdf0e10cSrcweir #include <xmloff/xmlexppr.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace awt {
38cdf0e10cSrcweir 	class XControlModel;
39cdf0e10cSrcweir } } } }
40cdf0e10cSrcweir 
41cdf0e10cSrcweir class SvXMLExport;
42cdf0e10cSrcweir //.........................................................................
43cdf0e10cSrcweir namespace xmloff
44cdf0e10cSrcweir {
45cdf0e10cSrcweir //.........................................................................
46cdf0e10cSrcweir 
47cdf0e10cSrcweir 	class OFormLayerXMLExport_Impl;
48cdf0e10cSrcweir 	class OFormsRootExport;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir 	//=====================================================================
51cdf0e10cSrcweir 	//= OFormLayerXMLExport
52cdf0e10cSrcweir 	//=====================================================================
53cdf0e10cSrcweir 	/** provides functionallity for exporting a complete form layer.
54cdf0e10cSrcweir 	*/
55cdf0e10cSrcweir 	class XMLOFF_DLLPUBLIC OFormLayerXMLExport
56cdf0e10cSrcweir 				:public ::vos::OReference
57cdf0e10cSrcweir 	{
58cdf0e10cSrcweir 	protected:
59cdf0e10cSrcweir 		/// our export context
60cdf0e10cSrcweir 		SvXMLExport&				m_rContext;
61cdf0e10cSrcweir 		// impl class
62cdf0e10cSrcweir 		OFormLayerXMLExport_Impl*	m_pImpl;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 	protected:
65cdf0e10cSrcweir 		~OFormLayerXMLExport();
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 	public:
68cdf0e10cSrcweir 		OFormLayerXMLExport(SvXMLExport& _rContext);
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 		/** initial the object
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 			<p>To be called if you want to reuse the same object for exportin different documents.</p>
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 			<p>You don't need to call this if you just constructed the object, in this case it is already
75cdf0e10cSrcweir 			initialized..</p>
76cdf0e10cSrcweir 		*/
77cdf0e10cSrcweir 		void initialize();
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 		/** initializes some internal structures for fast access to the given page
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 			<p>This method has to be called before you use getControlId for controls on the given page.
82cdf0e10cSrcweir 			This way a performance optimization can be done for faster access to the control ids</p>
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 			@return
85cdf0e10cSrcweir 				<TRUE/> if the page has been examined before. If <FALSE/> is returned, this is a serious error.
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 			@see getControlId
88cdf0e10cSrcweir 			@see examineForms
89cdf0e10cSrcweir 		*/
90cdf0e10cSrcweir 		sal_Bool seekPage(
91cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& _rxDrawPage);
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 		/** get the id for the given control
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 			<p>The page the control belongs to must have been examined and sought to.</p>
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 			@param _rxControl
98cdf0e10cSrcweir 				the control which's id should be retrieved. Must not be <NULL/>.
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 			@see examineForms
101cdf0e10cSrcweir 			@see seekPage
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 		*/
104cdf0e10cSrcweir 		::rtl::OUString getControlId(
105cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControl);
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 		/** retrieves the style name for the control's number style.
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 			<p>For performance reasons, this method is allowed to be called for any controls, even those which
110cdf0e10cSrcweir 			do not have a number style. In this case, an empty string is returned.</p>
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 			@param _rxControl
113cdf0e10cSrcweir 				the control which's id should be retrieved. Must not be <NULL/>.
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 			@see examineForms
116cdf0e10cSrcweir 			@see seekPage
117cdf0e10cSrcweir 		*/
118cdf0e10cSrcweir 		::rtl::OUString getControlNumberStyle(
119cdf0e10cSrcweir 			const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControl );
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 		/** examines the forms collection given.
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 			<p>This method will collect all form layer related data of the given draw page</p>
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 			@param _rxDrawPage
126cdf0e10cSrcweir 				the draw page to examine. The object will be queried for a <type scope="com.sun.star.form">XFormsSupplier</type>
127cdf0e10cSrcweir 				interface to obtain the forms container.
128cdf0e10cSrcweir 		*/
129cdf0e10cSrcweir 		void examineForms(const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& _rxDrawPage);
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 		/** exports the structure of a form layer
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 			<p>This method does not export styles (e.g. font properties of the controls), or any references
134cdf0e10cSrcweir 			external instances may have to the control models contained in the form layer (e.g. uno control
135cdf0e10cSrcweir 			shapes in the drawing layer may have such references)</p>
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 			<p>No top level element describing the whole collection is inserted. I.e. if within your document, you
138cdf0e10cSrcweir 			expect the the forms collection to be stored like
139cdf0e10cSrcweir 				<listing>
140cdf0e10cSrcweir 					&lt;Forms&gt;
141cdf0e10cSrcweir 						....	// all the forms stuff here
142cdf0e10cSrcweir 					&lt;/Forms&gt;
143cdf0e10cSrcweir 				</listing>
144cdf0e10cSrcweir 			you have to start the Forms element yourself.</p>
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 			@param	_rxDrawPage
147cdf0e10cSrcweir 				the draw page to examine. The object will be queried for a <type scope="com.sun.star.form">XFormsSupplier</type>
148cdf0e10cSrcweir 				interface to obtain the forms container.
149cdf0e10cSrcweir 		*/
150cdf0e10cSrcweir 		void exportForms(const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& _rxDrawPage);
151cdf0e10cSrcweir 
152cdf0e10cSrcweir         /** exports the XForms model data
153cdf0e10cSrcweir         */
154cdf0e10cSrcweir         void exportXForms() const;
155cdf0e10cSrcweir 
156cdf0e10cSrcweir         /** determines whether the given page contains logical forms
157cdf0e10cSrcweir         */
158cdf0e10cSrcweir 		bool pageContainsForms( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& _rxDrawPage ) const;
159cdf0e10cSrcweir 
160cdf0e10cSrcweir         /** determines whether the given page contains XForm instances
161cdf0e10cSrcweir         */
162cdf0e10cSrcweir 		bool documentContainsXForms() const;
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 		/** exports the controls number styles
165cdf0e10cSrcweir 		*/
166cdf0e10cSrcweir 		void exportControlNumberStyles();
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 		/** exports the automatic controls number styles
169cdf0e10cSrcweir 		*/
170cdf0e10cSrcweir 		void exportAutoControlNumberStyles();
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 		/** exports the auto-styles collected during the examineForms calls
173cdf0e10cSrcweir 		*/
174cdf0e10cSrcweir 		void exportAutoStyles();
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 		/** exclude the given control (model) from export.
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 			<p>If your document contains form controls which are not to be exported for whatever reason,
179cdf0e10cSrcweir 			you need to announce the models of these controls (can be retrieved from XControlShape::getControl)
180cdf0e10cSrcweir 			to the form layer exporter.<br/>
181cdf0e10cSrcweir 			Of course you have to do this before calling <member>exportForms</member></p>
182cdf0e10cSrcweir 		*/
183cdf0e10cSrcweir 		void excludeFromExport( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > _rxControl );
184cdf0e10cSrcweir 	};
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 	//=========================================================================
187cdf0e10cSrcweir 	//= OOfficeFormsExport
188cdf0e10cSrcweir 	//=========================================================================
189cdf0e10cSrcweir 	/// export helper for the office::forms element
190cdf0e10cSrcweir 	class XMLOFF_DLLPUBLIC OOfficeFormsExport
191cdf0e10cSrcweir 	{
192cdf0e10cSrcweir 	private:
193cdf0e10cSrcweir 		OFormsRootExport*	m_pImpl;
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 	public:
196cdf0e10cSrcweir 		OOfficeFormsExport( SvXMLExport& _rExp );
197cdf0e10cSrcweir 		~OOfficeFormsExport();
198cdf0e10cSrcweir 	};
199cdf0e10cSrcweir 
200cdf0e10cSrcweir //.........................................................................
201cdf0e10cSrcweir }	// namespace xmloff
202cdf0e10cSrcweir //.........................................................................
203cdf0e10cSrcweir 
204cdf0e10cSrcweir #endif // _XMLOFF_FORMLAYEREXPORT_HXX_
205cdf0e10cSrcweir 
206