LibreOffice Module xmloff (master) 1
layerexport.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <sal/config.h>
23
24#include <unordered_map>
25
26#include <com/sun/star/container/XIndexAccess.hpp>
27#include <com/sun/star/drawing/XDrawPage.hpp>
28#include <com/sun/star/script/ScriptEventDescriptor.hpp>
29#include <com/sun/star/util/XNumberFormats.hpp>
30#include <com/sun/star/awt/XControlModel.hpp>
31#include "callbacks.hxx"
32#include <rtl/ref.hxx>
34
35class SvXMLExport;
39
40namespace xmloff
41{
42
44
45 // maps objects (property sets) to strings, e.g. control ids.
46 typedef ::std::unordered_map < css::uno::Reference< css::beans::XPropertySet >
47 , OUString
49
50 // map pages to maps (of property sets to strings)
51 typedef ::std::unordered_map < css::uno::Reference< css::drawing::XDrawPage >
54
55 //= OFormLayerXMLExport_Impl
60 {
61 friend class OFormLayerXMLExport;
62
65
66 // ignore list for control models
68
69 // style handling
72
73 // we need our own number formats supplier:
74 // Controls which have a number formats do not work with the formats supplier of the document they reside
75 // in, instead they use the formats of the data source their form is associated with. If there is no
76 // such form or no such data source, they work with an own formatter.
77 // Even more, time and date fields do not work with a central formatter at all, they have their own one
78 // (which is shared internally, but this is a (hidden) implementation detail.)
79
80 // To not contaminate the global (document) number formats supplier (which could be obtained from the context),
81 // we have an own one.
82 // (Contaminate means: If a user adds a user-defined format to a formatted field, this format is stored in
83 // in the data source's formats supplier. To export this _and_ reuse existing structures, we would need to
84 // add this format to the global (document) formats supplier.
85 // In case of an export we could do some cleanup afterwards, but in case of an import, there is no such
86 // chance, as (if other user-defined formats exist in the document as well) we can't distinguish
87 // between user-defined formats really needed for the doc (i.e. in a calc cell) and formats only added
88 // to the supplier because the controls needed it.
89 css::uno::Reference< css::util::XNumberFormats >
91
93 // the control ids of all controls on all pages we ever examined
94
96 // for a given page (iter->first), and a given control (iter->second->first), this is the comma-separated
97 // lists of ids of the controls referring to the control given.
98
99 MapPropertySet2Map::iterator
101 // the iterator for the control id map for the page being handled
102 MapPropertySet2Map::iterator
104 // the same for the map of referring controls
105
106 // TODO: To avoid this construct above, and to have a cleaner implementation, a class encapsulating the
107 // export of a single page should be introduced.
108
109 typedef std::unordered_map<css::uno::Reference<css::beans::XPropertySet>, sal_Int32> MapPropertySet2Int;
111 // maps controls to format keys, which are relative to our own formats supplier
112
114 // style names of grid columns
115
116 public:
117 explicit OFormLayerXMLExport_Impl(SvXMLExport& _rContext);
119
120 private:
123 void exportGridColumn(
124 const css::uno::Reference< css::beans::XPropertySet >& _rxColumn,
125 const css::uno::Sequence< css::script::ScriptEventDescriptor >& _rEvents
126 );
127
130 void exportControl(
131 const css::uno::Reference< css::beans::XPropertySet >& _rxControl,
132 const css::uno::Sequence< css::script::ScriptEventDescriptor >& _rEvents
133 );
134
137 void exportForm(const css::uno::Reference< css::beans::XPropertySet >& _rxProps,
138 const css::uno::Sequence< css::script::ScriptEventDescriptor >& _rEvents
139 );
140
148 bool seekPage(
149 const css::uno::Reference< css::drawing::XDrawPage >& _rxDrawPage);
150
155 OUString
156 getControlId(const css::uno::Reference< css::beans::XPropertySet >& _rxControl);
157
163 OUString
164 getControlNumberStyle( const css::uno::Reference< css::beans::XPropertySet >& _rxControl );
165
166 // IFormsExportContext
167 virtual void exportCollectionElements(const css::uno::Reference< css::container::XIndexAccess >& _rxCollection) override;
168 virtual SvXMLExport& getGlobalContext() override;
169 virtual OUString getObjectStyleName(
170 const css::uno::Reference< css::beans::XPropertySet >& _rxObject ) override;
171 virtual ::rtl::Reference< SvXMLExportPropertyMapper > getStylePropertyMapper() override;
172
175 void clear();
176
197 void examineForms(
198 const css::uno::Reference< css::drawing::XDrawPage >& _rxDrawPage);
199
205 void exportForms(
206 const css::uno::Reference< css::drawing::XDrawPage >& _rxDrawPage);
207
210 void exportXForms() const;
211
214 static bool pageContainsForms( const css::uno::Reference< css::drawing::XDrawPage >& _rxDrawPage );
215
218 bool documentContainsXForms() const;
219
223
226 void exportAutoStyles();
227
229 const css::uno::Reference< css::drawing::XDrawPage >& _rxDrawPage,
230 css::uno::Reference< css::container::XIndexAccess >& _rxForms);
231
237 const css::uno::Reference< css::drawing::XDrawPage >& _rxDrawPage,
238 bool _bClear);
239
243 bool checkExamineControl(const css::uno::Reference< css::beans::XPropertySet >& _rxObject);
244
249 void examineControlNumberFormat(const css::uno::Reference< css::beans::XPropertySet >& _rxControl);
250
255 sal_Int32 implExamineControlNumberFormat( const css::uno::Reference< css::beans::XPropertySet >& _rxObject );
256
259 void collectGridColumnStylesAndIds( const css::uno::Reference< css::beans::XPropertySet >& _rxControl );
260
270 sal_Int32 ensureTranslateFormat(const css::uno::Reference< css::beans::XPropertySet >& _rxFormattedControl);
271
274
277
280 OUString
281 getImmediateNumberStyle( const css::uno::Reference< css::beans::XPropertySet >& _rxObject );
282
285 static const OUString& getControlNumberStyleNamePrefix();
286
294 void excludeFromExport( const css::uno::Reference< css::awt::XControlModel >& _rxControl );
295 };
296
297} // namespace xmloff
298
299/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class is a base-class to create XMLPropertyHandler.
Definition: prhdlfac.hxx:41
the implementation class for OFormLayerXMLExport
Definition: layerexport.hxx:60
virtual SvXMLExport & getGlobalContext() override
bool documentContainsXForms() const
determines whether the given page contains XForm instances
OUString getControlId(const css::uno::Reference< css::beans::XPropertySet > &_rxControl)
get the id of the given control.
virtual OUString getObjectStyleName(const css::uno::Reference< css::beans::XPropertySet > &_rxObject) override
sal_Int32 implExamineControlNumberFormat(const css::uno::Reference< css::beans::XPropertySet > &_rxObject)
examines the control's number format, so later the format style can be referred
void exportControl(const css::uno::Reference< css::beans::XPropertySet > &_rxControl, const css::uno::Sequence< css::script::ScriptEventDescriptor > &_rEvents)
exports one single control
OUString getControlNumberStyle(const css::uno::Reference< css::beans::XPropertySet > &_rxControl)
retrieves the style name for the control's number style.
void examineControlNumberFormat(const css::uno::Reference< css::beans::XPropertySet > &_rxControl)
examines the control's number format, so later the format style can be referred
sal_Int32 ensureTranslateFormat(const css::uno::Reference< css::beans::XPropertySet > &_rxFormattedControl)
ensures that the number format of the given control exist in our own formats supplier.
MapPropertySet2Map::iterator m_aCurrentPageIds
void ensureControlNumberStyleExport()
ensures that the instance exporting our control's number styles exists
bool checkExamineControl(const css::uno::Reference< css::beans::XPropertySet > &_rxObject)
check the object given if it's a control, if so, examine it.
std::unordered_map< css::uno::Reference< css::beans::XPropertySet >, sal_Int32 > MapPropertySet2Int
void exportForm(const css::uno::Reference< css::beans::XPropertySet > &_rxProps, const css::uno::Sequence< css::script::ScriptEventDescriptor > &_rEvents)
exports one single form
static const OUString & getControlNumberStyleNamePrefix()
returns the prefix to be used for control number styles
Definition: layerexport.cxx:66
SvXMLNumFmtExport * getControlNumberStyleExport()
returns the instance exporting our control's number styles
void exportAutoStyles()
exports the auto-styles collected during the examineForms calls
MapPropertySet2String m_aGridColumnStyles
OFormLayerXMLExport_Impl(SvXMLExport &_rContext)
Definition: layerexport.cxx:72
::rtl::Reference< SvXMLExportPropertyMapper > m_xStyleExportMapper
Definition: layerexport.hxx:71
MapPropertySet2Int m_aControlNumberFormats
SvXMLNumFmtExport * m_pControlNumberStyles
Definition: layerexport.hxx:64
void exportGridColumn(const css::uno::Reference< css::beans::XPropertySet > &_rxColumn, const css::uno::Sequence< css::script::ScriptEventDescriptor > &_rEvents)
exports one single grid column
css::uno::Reference< css::util::XNumberFormats > m_xControlNumberFormats
Definition: layerexport.hxx:90
void exportAutoControlNumberStyles()
exports the automatic control number styles
virtual void exportCollectionElements(const css::uno::Reference< css::container::XIndexAccess > &_rxCollection) override
steps through a collection and exports all children of this collection
virtual ::rtl::Reference< SvXMLExportPropertyMapper > getStylePropertyMapper() override
MapPropertySet2Map m_aControlIds
Definition: layerexport.hxx:92
void clear()
clear any structures which have been build in the recent <method>examine</method> calls.
MapPropertySet2Map m_aReferringControls
Definition: layerexport.hxx:95
MapPropertySet2Map::iterator m_aCurrentPageReferring
::rtl::Reference< XMLPropertyHandlerFactory > m_xPropertyHandlerFactory
Definition: layerexport.hxx:70
void excludeFromExport(const css::uno::Reference< css::awt::XControlModel > &_rxControl)
exclude the given control (model) from export.
static bool pageContainsForms(const css::uno::Reference< css::drawing::XDrawPage > &_rxDrawPage)
determines whether the given page contains logical forms
OUString getImmediateNumberStyle(const css::uno::Reference< css::beans::XPropertySet > &_rxObject)
determines the number format style for the given object without remembering it
bool seekPage(const css::uno::Reference< css::drawing::XDrawPage > &_rxDrawPage)
seek to the page given.
void collectGridColumnStylesAndIds(const css::uno::Reference< css::beans::XPropertySet > &_rxControl)
collects AutoStyles for grid columns
bool implMoveIterators(const css::uno::Reference< css::drawing::XDrawPage > &_rxDrawPage, bool _bClear)
moves the m_aCurrentPage* members to the positions specifying the given page.
void examineForms(const css::uno::Reference< css::drawing::XDrawPage > &_rxDrawPage)
examine a forms collection.
static bool impl_isFormPageContainingForms(const css::uno::Reference< css::drawing::XDrawPage > &_rxDrawPage, css::uno::Reference< css::container::XIndexAccess > &_rxForms)
void exportForms(const css::uno::Reference< css::drawing::XDrawPage > &_rxDrawPage)
export a forms collection of a draw page
void exportXForms() const
exports the XForms model data
provides functionality for exporting a complete form layer.
::std::unordered_map< css::uno::Reference< css::drawing::XDrawPage >, MapPropertySet2String > MapPropertySet2Map
Definition: layerexport.hxx:53
::std::unordered_map< css::uno::Reference< css::beans::XPropertySet >, OUString > MapPropertySet2String
Definition: layerexport.hxx:48
o3tl::sorted_vector< css::uno::Reference< css::beans::XPropertySet > > PropertySetBag
Definition: layerexport.hxx:43