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