1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: layerimport.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _XMLOFF_FORMS_LAYERIMPORT_HXX_
32 #define _XMLOFF_FORMS_LAYERIMPORT_HXX_
34 #include <com/sun/star/xml/sax/XAttributeList.hpp>
35 #include <com/sun/star/form/XFormsSupplier2.hpp>
36 #include <vos/ref.hxx>
37 #include "formattributes.hxx"
38 #include "callbacks.hxx"
39 #include "eventimport.hxx"
40 #include <tools/ref.hxx>
43 class SvXMLImportContext
;
44 class XMLPropertyHandlerFactory
;
45 class SvXMLImportPropertyMapper
;
46 class XMLPropStyleContext
;
48 SV_DECL_REF( SvXMLStylesContext
)
49 // unfortunately, we can't put this into our namespace, as the macro expands to (amongst others) a forward
50 // declaration of the class name, which then would be in the namespace, too
52 //.........................................................................
55 //.........................................................................
57 class OAttribute2Property
;
59 //=====================================================================
61 //=====================================================================
62 /// a structure containing a property set (the referred control) and a string (the list of referring controls)
63 /* struct ControlReference
65 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
71 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxReferredControl,
72 const ::rtl::OUString& _rReferringControls)
73 :xReferredControl(_rxReferredControl)
74 ,sReferringControls(_rReferringControls)
80 //=====================================================================
81 //= OFormLayerXMLImport_Impl
82 //=====================================================================
83 class OFormLayerXMLImport_Impl
84 : public ODefaultEventAttacherManager
86 friend class OFormLayerXMLImport
;
89 SvXMLImport
& m_rImporter
;
90 OAttribute2Property m_aAttributeMetaData
;
92 /// the supplier for the forms of the currently imported page
93 ::com::sun::star::uno::Reference
< ::com::sun::star::form::XFormsSupplier2
>
94 m_xCurrentPageFormsSupp
;
95 SvXMLStylesContext
* m_pAutoStyles
;
99 ::vos::ORef
< XMLPropertyHandlerFactory
> m_xPropertyHandlerFactory
;
100 ::vos::ORef
< SvXMLImportPropertyMapper
> m_xImportMapper
;
102 DECLARE_STL_USTRINGACCESS_MAP( ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>, MapString2PropertySet
);
103 DECLARE_STL_MAP( ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XDrawPage
>, MapString2PropertySet
, ODrawPageCompare
, MapDrawPage2Map
);
105 MapDrawPage2Map m_aControlIds
; // ids of the controls on all known page
106 MapDrawPage2MapIterator m_aCurrentPageIds
; // ifs of the controls on the current page
108 typedef ::std::pair
< ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>, ::rtl::OUString
>
110 ::std::vector
< ModelStringPair
>
111 m_aControlReferences
; // control reference descriptions for current page
112 ::std::vector
< ModelStringPair
>
113 m_aCellValueBindings
; // information about controls bound to spreadsheet cells
114 ::std::vector
< ModelStringPair
>
115 m_aCellRangeListSources
;// information about controls bound to spreadsheet cell range list sources
117 ::std::vector
< ModelStringPair
>
118 m_aXFormsValueBindings
; // collect xforms:bind attributes to be resolved
120 ::std::vector
< ModelStringPair
>
121 m_aXFormsListBindings
; // collect forms:xforms-list-source attributes to be resolved
123 ::std::vector
< ModelStringPair
>
124 m_aXFormsSubmissions
; // collect xforms:submission attributes to be resolved
128 void registerControlId(
129 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxControl
,
130 const ::rtl::OUString
& _rId
);
131 void registerControlReferences(
132 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxControl
,
133 const ::rtl::OUString
& _rReferringControls
);
135 // OFormLayerXMLImport_Impl
136 inline OAttribute2Property
& getAttributeMap() { return m_aAttributeMetaData
; }
137 inline SvXMLImport
& getGlobalContext() { return m_rImporter
; }
138 const SvXMLStyleContext
* getStyleElement(const ::rtl::OUString
& _rStyleName
) const;
139 void enterEventContext();
140 void leaveEventContext();
141 void applyControlNumberStyle(
142 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxControlModel
,
143 const ::rtl::OUString
& _rControlNumerStyleName
145 void registerCellValueBinding(
146 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxControlModel
,
147 const ::rtl::OUString
& _rCellAddress
150 void registerCellRangeListSource(
151 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxControlModel
,
152 const ::rtl::OUString
& _rCellRangeAddress
155 void registerXFormsValueBinding(
156 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxControlModel
,
157 const ::rtl::OUString
& _rBindingID
160 void registerXFormsListBinding(
161 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxControlModel
,
162 const ::rtl::OUString
& _rBindingID
165 void registerXFormsSubmission(
166 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxControlModel
,
167 const ::rtl::OUString
& _rSubmissionID
171 OFormLayerXMLImport_Impl(SvXMLImport
& _rImporter
);
172 virtual ~OFormLayerXMLImport_Impl();
174 /** retrieves the property mapper form form related auto styles.
176 ::vos::ORef
< SvXMLImportPropertyMapper
> getStylePropertyMapper() const;
178 /** start importing the forms of the given page
181 const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XDrawPage
>& _rxDrawPage
);
183 /** end importing the forms of the current page
187 /** creates an import context for the office:forms element
189 SvXMLImportContext
* createOfficeFormsContext(
190 SvXMLImport
& _rImport
,
192 const rtl::OUString
& _rLocalName
);
194 /** create an <type>SvXMLImportContext</type> instance which is able to import the <form:form>
197 SvXMLImportContext
* createContext(
198 const sal_uInt16 _nPrefix
,
199 const rtl::OUString
& _rLocalName
,
200 const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& _rxAttribs
);
202 /** get the control with the given id
204 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>
205 lookupControlId(const ::rtl::OUString
& _rControlId
);
207 /** seek to the given page
210 const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XDrawPage
>& _rxDrawPage
);
212 /** announces the auto-style context to the form importer
214 void setAutoStyleContext(SvXMLStylesContext
* _pNewContext
);
216 /** to be called when the document has been completely imported
218 <p>For some documents (currently: only some spreadsheet documents) it's necessary
219 do to a post processing, since not all information from the file can be processed
220 if the document is not completed, yet.</p>
222 void documentDone( );
225 //.........................................................................
226 } // namespace xmloff
227 //.........................................................................
229 #endif // _XMLOFF_FORMS_LAYERIMPORT_HXX_