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