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 .
22 #include <sal/config.h>
25 #include <unordered_map>
27 #include <com/sun/star/xml/sax/XFastAttributeList.hpp>
28 #include <com/sun/star/drawing/XDrawPage.hpp>
29 #include <com/sun/star/form/XFormsSupplier2.hpp>
30 #include <rtl/ref.hxx>
31 #include "formattributes.hxx"
32 #include "eventimport.hxx"
35 class SvXMLImportContext
;
36 class SvXMLStyleContext
;
37 class SvXMLStylesContext
;
39 // unfortunately, we can't put this into our namespace, as the macro expands to (amongst others) a forward
40 // declaration of the class name, which then would be in the namespace, too
45 class OAttribute2Property
;
47 //= OFormLayerXMLImport_Impl
48 class OFormLayerXMLImport_Impl
49 : public ODefaultEventAttacherManager
51 friend class OFormLayerXMLImport
;
53 SvXMLImport
& m_rImporter
;
54 OAttribute2Property m_aAttributeMetaData
;
56 /// the supplier for the forms of the currently imported page
57 css::uno::Reference
< css::form::XFormsSupplier2
>
58 m_xCurrentPageFormsSupp
;
59 rtl::Reference
<SvXMLStylesContext
> m_xAutoStyles
;
61 typedef std::map
< OUString
, css::uno::Reference
< css::beans::XPropertySet
> > MapString2PropertySet
;
62 typedef std::unordered_map
<css::uno::Reference
<css::drawing::XDrawPage
>, MapString2PropertySet
> MapDrawPage2Map
;
64 MapDrawPage2Map m_aControlIds
; // ids of the controls on all known page
65 MapDrawPage2Map::iterator m_aCurrentPageIds
; // ifs of the controls on the current page
67 typedef ::std::pair
< css::uno::Reference
< css::beans::XPropertySet
>, OUString
>
69 ::std::vector
< ModelStringPair
>
70 m_aControlReferences
; // control reference descriptions for current page
71 ::std::vector
< ModelStringPair
>
72 m_aCellValueBindings
; // information about controls bound to spreadsheet cells
73 ::std::vector
< ModelStringPair
>
74 m_aCellRangeListSources
;// information about controls bound to spreadsheet cell range list sources
76 ::std::vector
< ModelStringPair
>
77 m_aXFormsValueBindings
; // collect xforms:bind attributes to be resolved
79 ::std::vector
< ModelStringPair
>
80 m_aXFormsListBindings
; // collect forms:xforms-list-source attributes to be resolved
82 ::std::vector
< ModelStringPair
>
83 m_aXFormsSubmissions
; // collect xforms:submission attributes to be resolved
87 void registerControlId(
88 const css::uno::Reference
< css::beans::XPropertySet
>& _rxControl
,
89 const OUString
& _rId
);
90 void registerControlReferences(
91 const css::uno::Reference
< css::beans::XPropertySet
>& _rxControl
,
92 const OUString
& _rReferringControls
);
94 // OFormLayerXMLImport_Impl
95 OAttribute2Property
& getAttributeMap() { return m_aAttributeMetaData
; }
96 SvXMLImport
& getGlobalContext() { return m_rImporter
; }
97 const SvXMLStyleContext
* getStyleElement(const OUString
& _rStyleName
) const;
98 void enterEventContext();
99 void leaveEventContext();
100 void applyControlNumberStyle(
101 const css::uno::Reference
< css::beans::XPropertySet
>& _rxControlModel
,
102 const OUString
& _rControlNumberStyleName
104 void registerCellValueBinding(
105 const css::uno::Reference
< css::beans::XPropertySet
>& _rxControlModel
,
106 const OUString
& _rCellAddress
109 void registerCellRangeListSource(
110 const css::uno::Reference
< css::beans::XPropertySet
>& _rxControlModel
,
111 const OUString
& _rCellRangeAddress
114 void registerXFormsValueBinding(
115 const css::uno::Reference
< css::beans::XPropertySet
>& _rxControlModel
,
116 const OUString
& _rBindingID
119 void registerXFormsListBinding(
120 const css::uno::Reference
< css::beans::XPropertySet
>& _rxControlModel
,
121 const OUString
& _rBindingID
124 void registerXFormsSubmission(
125 const css::uno::Reference
< css::beans::XPropertySet
>& _rxControlModel
,
126 const OUString
& _rSubmissionID
129 ~OFormLayerXMLImport_Impl() override
;
132 explicit OFormLayerXMLImport_Impl(SvXMLImport
& _rImporter
);
134 /** start importing the forms of the given page
137 const css::uno::Reference
< css::drawing::XDrawPage
>& _rxDrawPage
);
139 /** end importing the forms of the current page
143 /** creates an import context for the office:forms element
145 static SvXMLImportContext
* createOfficeFormsContext(
146 SvXMLImport
& _rImport
);
148 /** create an <type>SvXMLImportContext</type> instance which is able to import the <form:form>
151 SvXMLImportContext
* createContext(
153 const css::uno::Reference
< css::xml::sax::XFastAttributeList
>& _rxAttribs
);
155 /** get the control with the given id
157 css::uno::Reference
< css::beans::XPropertySet
>
158 lookupControlId(const OUString
& _rControlId
);
160 /** announces the auto-style context to the form importer
162 void setAutoStyleContext(SvXMLStylesContext
* _pNewContext
);
164 /** to be called when the document has been completely imported
166 <p>For some documents (currently: only some spreadsheet documents) it's necessary
167 do to a post processing, since not all information from the file can be processed
168 if the document is not completed, yet.</p>
170 void documentDone( );
173 } // namespace xmloff
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */