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