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