Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _XMLOFF_FORMS_LAYERIMPORT_HXX_
21 : #define _XMLOFF_FORMS_LAYERIMPORT_HXX_
22 :
23 : #include <com/sun/star/xml/sax/XAttributeList.hpp>
24 : #include <com/sun/star/form/XFormsSupplier2.hpp>
25 : #include <rtl/ref.hxx>
26 : #include "formattributes.hxx"
27 : #include "callbacks.hxx"
28 : #include "eventimport.hxx"
29 : #include <tools/ref.hxx>
30 :
31 : class SvXMLImport;
32 : class SvXMLImportContext;
33 : class SvXMLStyleContext;
34 :
35 : SV_DECL_REF( SvXMLStylesContext )
36 : // unfortunately, we can't put this into our namespace, as the macro expands to (amongst others) a forward
37 : // declaration of the class name, which then would be in the namespace, too
38 :
39 : //.........................................................................
40 : namespace xmloff
41 : {
42 : //.........................................................................
43 :
44 : class OAttribute2Property;
45 :
46 : //=====================================================================
47 : //= OFormLayerXMLImport_Impl
48 : //=====================================================================
49 : class OFormLayerXMLImport_Impl
50 : : public ODefaultEventAttacherManager
51 : {
52 : friend class OFormLayerXMLImport;
53 :
54 : protected:
55 : SvXMLImport& m_rImporter;
56 : OAttribute2Property m_aAttributeMetaData;
57 :
58 : /// the supplier for the forms of the currently imported page
59 : ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormsSupplier2 >
60 : m_xCurrentPageFormsSupp;
61 : SvXMLStylesContext* m_pAutoStyles;
62 :
63 : protected:
64 : DECLARE_STL_USTRINGACCESS_MAP( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >, MapString2PropertySet );
65 : DECLARE_STL_MAP( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >, MapString2PropertySet, ODrawPageCompare, MapDrawPage2Map);
66 :
67 : MapDrawPage2Map m_aControlIds; // ids of the controls on all known page
68 : MapDrawPage2MapIterator m_aCurrentPageIds; // ifs of the controls on the current page
69 :
70 : typedef ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >, ::rtl::OUString >
71 : ModelStringPair;
72 : ::std::vector< ModelStringPair >
73 : m_aControlReferences; // control reference descriptions for current page
74 : ::std::vector< ModelStringPair >
75 : m_aCellValueBindings; // information about controls bound to spreadsheet cells
76 : ::std::vector< ModelStringPair >
77 : m_aCellRangeListSources;// information about controls bound to spreadsheet cell range list sources
78 :
79 : ::std::vector< ModelStringPair >
80 : m_aXFormsValueBindings; // collect xforms:bind attributes to be resolved
81 :
82 : ::std::vector< ModelStringPair >
83 : m_aXFormsListBindings; // collect forms:xforms-list-source attributes to be resolved
84 :
85 : ::std::vector< ModelStringPair >
86 : m_aXFormsSubmissions; // collect xforms:submission attributes to be resolved
87 :
88 : public:
89 : // IControlIdMap
90 : void registerControlId(
91 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControl,
92 : const ::rtl::OUString& _rId);
93 : void registerControlReferences(
94 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControl,
95 : const ::rtl::OUString& _rReferringControls);
96 :
97 : // OFormLayerXMLImport_Impl
98 0 : inline OAttribute2Property& getAttributeMap() { return m_aAttributeMetaData; }
99 82 : inline SvXMLImport& getGlobalContext() { return m_rImporter; }
100 : const SvXMLStyleContext* getStyleElement(const ::rtl::OUString& _rStyleName) const;
101 : void enterEventContext();
102 : void leaveEventContext();
103 : void applyControlNumberStyle(
104 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
105 : const ::rtl::OUString& _rControlNumerStyleName
106 : );
107 : void registerCellValueBinding(
108 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
109 : const ::rtl::OUString& _rCellAddress
110 : );
111 :
112 : void registerCellRangeListSource(
113 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
114 : const ::rtl::OUString& _rCellRangeAddress
115 : );
116 :
117 : void registerXFormsValueBinding(
118 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
119 : const ::rtl::OUString& _rBindingID
120 : );
121 :
122 : void registerXFormsListBinding(
123 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
124 : const ::rtl::OUString& _rBindingID
125 : );
126 :
127 : void registerXFormsSubmission(
128 : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
129 : const ::rtl::OUString& _rSubmissionID
130 : );
131 :
132 : protected:
133 : OFormLayerXMLImport_Impl(SvXMLImport& _rImporter);
134 : virtual ~OFormLayerXMLImport_Impl();
135 :
136 : /** start importing the forms of the given page
137 : */
138 : void startPage(
139 : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& _rxDrawPage);
140 :
141 : /** end importing the forms of the current page
142 : */
143 : void endPage();
144 :
145 : /** creates an import context for the office:forms element
146 : */
147 : SvXMLImportContext* createOfficeFormsContext(
148 : SvXMLImport& _rImport,
149 : sal_uInt16 _nPrefix,
150 : const rtl::OUString& _rLocalName);
151 :
152 : /** create an <type>SvXMLImportContext</type> instance which is able to import the <form:form>
153 : element.
154 : */
155 : SvXMLImportContext* createContext(
156 : const sal_uInt16 _nPrefix,
157 : const rtl::OUString& _rLocalName,
158 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& _rxAttribs);
159 :
160 : /** get the control with the given id
161 : */
162 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
163 : lookupControlId(const ::rtl::OUString& _rControlId);
164 :
165 : /** announces the auto-style context to the form importer
166 : */
167 : void setAutoStyleContext(SvXMLStylesContext* _pNewContext);
168 :
169 : /** to be called when the document has been completely imported
170 :
171 : <p>For some documents (currently: only some spreadsheet documents) it's necessary
172 : do to a post processing, since not all information from the file can be processed
173 : if the document is not completed, yet.</p>
174 : */
175 : void documentDone( );
176 : };
177 :
178 : //.........................................................................
179 : } // namespace xmloff
180 : //.........................................................................
181 :
182 : #endif // _XMLOFF_FORMS_LAYERIMPORT_HXX_
183 :
184 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|