1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_XMLOFF_SOURCE_FORMS_LAYERIMPORT_HXX
21 #define INCLUDED_XMLOFF_SOURCE_FORMS_LAYERIMPORT_HXX
23 #include <sal/config.h>
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>
36 class SvXMLImportContext
;
37 class SvXMLStyleContext
;
38 class SvXMLStylesContext
;
40 // unfortunately, we can't put this into our namespace, as the macro expands to (amongst others) a forward
41 // declaration of the class name, which then would be in the namespace, too
46 class OAttribute2Property
;
48 //= OFormLayerXMLImport_Impl
49 class OFormLayerXMLImport_Impl
50 : public ODefaultEventAttacherManager
52 friend class OFormLayerXMLImport
;
55 SvXMLImport
& m_rImporter
;
56 OAttribute2Property m_aAttributeMetaData
;
58 /// the supplier for the forms of the currently imported page
59 css::uno::Reference
< css::form::XFormsSupplier2
>
60 m_xCurrentPageFormsSupp
;
61 SvXMLStylesContext
* m_pAutoStyles
;
64 typedef std::map
< OUString
, css::uno::Reference
< css::beans::XPropertySet
> > MapString2PropertySet
;
65 typedef std::map
<css::uno::Reference
<css::drawing::XDrawPage
>, MapString2PropertySet
, ODrawPageCompare
> MapDrawPage2Map
;
67 MapDrawPage2Map m_aControlIds
; // ids of the controls on all known page
68 MapDrawPage2Map::iterator m_aCurrentPageIds
; // ifs of the controls on the current page
70 typedef ::std::pair
< css::uno::Reference
< css::beans::XPropertySet
>, OUString
>
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
79 ::std::vector
< ModelStringPair
>
80 m_aXFormsValueBindings
; // collect xforms:bind attributes to be resolved
82 ::std::vector
< ModelStringPair
>
83 m_aXFormsListBindings
; // collect forms:xforms-list-source attributes to be resolved
85 ::std::vector
< ModelStringPair
>
86 m_aXFormsSubmissions
; // collect xforms:submission attributes to be resolved
90 void registerControlId(
91 const css::uno::Reference
< css::beans::XPropertySet
>& _rxControl
,
92 const OUString
& _rId
);
93 void registerControlReferences(
94 const css::uno::Reference
< css::beans::XPropertySet
>& _rxControl
,
95 const OUString
& _rReferringControls
);
97 // OFormLayerXMLImport_Impl
98 inline OAttribute2Property
& getAttributeMap() { return m_aAttributeMetaData
; }
99 inline SvXMLImport
& getGlobalContext() { return m_rImporter
; }
100 const SvXMLStyleContext
* getStyleElement(const OUString
& _rStyleName
) const;
101 void enterEventContext();
102 void leaveEventContext();
103 void applyControlNumberStyle(
104 const css::uno::Reference
< css::beans::XPropertySet
>& _rxControlModel
,
105 const OUString
& _rControlNumerStyleName
107 void registerCellValueBinding(
108 const css::uno::Reference
< css::beans::XPropertySet
>& _rxControlModel
,
109 const OUString
& _rCellAddress
112 void registerCellRangeListSource(
113 const css::uno::Reference
< css::beans::XPropertySet
>& _rxControlModel
,
114 const OUString
& _rCellRangeAddress
117 void registerXFormsValueBinding(
118 const css::uno::Reference
< css::beans::XPropertySet
>& _rxControlModel
,
119 const OUString
& _rBindingID
122 void registerXFormsListBinding(
123 const css::uno::Reference
< css::beans::XPropertySet
>& _rxControlModel
,
124 const OUString
& _rBindingID
127 void registerXFormsSubmission(
128 const css::uno::Reference
< css::beans::XPropertySet
>& _rxControlModel
,
129 const OUString
& _rSubmissionID
132 virtual ~OFormLayerXMLImport_Impl();
134 explicit OFormLayerXMLImport_Impl(SvXMLImport
& _rImporter
);
136 /** start importing the forms of the given page
139 const css::uno::Reference
< css::drawing::XDrawPage
>& _rxDrawPage
);
141 /** end importing the forms of the current page
145 /** creates an import context for the office:forms element
147 static SvXMLImportContext
* createOfficeFormsContext(
148 SvXMLImport
& _rImport
,
150 const OUString
& _rLocalName
);
152 /** create an <type>SvXMLImportContext</type> instance which is able to import the <form:form>
155 SvXMLImportContext
* createContext(
156 const sal_uInt16 _nPrefix
,
157 const OUString
& _rLocalName
,
158 const css::uno::Reference
< css::xml::sax::XAttributeList
>& _rxAttribs
);
160 /** get the control with the given id
162 css::uno::Reference
< css::beans::XPropertySet
>
163 lookupControlId(const OUString
& _rControlId
);
165 /** announces the auto-style context to the form importer
167 void setAutoStyleContext(SvXMLStylesContext
* _pNewContext
);
169 /** to be called when the document has been completely imported
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>
175 void documentDone( );
178 } // namespace xmloff
180 #endif // INCLUDED_XMLOFF_SOURCE_FORMS_LAYERIMPORT_HXX
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */