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 #ifndef INCLUDED_XMLOFF_SOURCE_FORMS_LAYEREXPORT_HXX
21 #define INCLUDED_XMLOFF_SOURCE_FORMS_LAYEREXPORT_HXX
22 
23 #include <sal/config.h>
24 
25 #include <map>
26 #include <set>
27 
28 #include <com/sun/star/container/XIndexAccess.hpp>
29 #include <com/sun/star/drawing/XDrawPage.hpp>
30 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
31 #include <com/sun/star/util/XNumberFormats.hpp>
32 #include <com/sun/star/awt/XControlModel.hpp>
33 #include "callbacks.hxx"
34 #include <rtl/ref.hxx>
35 
36 class SvXMLExport;
37 class SvXMLNumFmtExport;
40 
41 namespace xmloff
42 {
43 
44  typedef ::std::set < css::uno::Reference< css::beans::XPropertySet >
46 
47  // maps objects (property sets) to strings, e.g. control ids.
48  typedef ::std::map < css::uno::Reference< css::beans::XPropertySet >
49  , OUString
51 
52  // map pages to maps (of property sets to strings)
53  typedef ::std::map < css::uno::Reference< css::drawing::XDrawPage >
56 
57  //= OFormLayerXMLExport_Impl
61  :public IFormsExportContext
62  {
63  friend class OFormLayerXMLExport;
64 
67 
68  // ignore list for control models
70 
71  // style handling
74 
75  // we need our own number formats supplier:
76  // Controls which have a number formats do not work with the formats supplier of the document they reside
77  // in, instead they use the formats of the data source their form is associated with. If there is no
78  // such form or no such data source, they work with an own formatter.
79  // Even more, time and date fields do not work with a central formatter at all, they have their own one
80  // (which is shared internally, but this is a (hidden) implementation detail.)
81 
82  // To not contaminate the global (document) number formats supplier (which could be obtained from the context),
83  // we have an own one.
84  // (Contaminate means: If a user adds a user-defined format to a formatted field, this format is stored in
85  // in the data source's formats supplier. To export this _and_ reuse existing structures, we would need to
86  // add this format to the global (document) formats supplier.
87  // In case of an export we could do some cleanup afterwards, but in case of an import, there is no such
88  // chance, as (if other user-defined formats exist in the document as well) we can't distinguish
89  // between user-defined formats really needed for the doc (i.e. in a calc cell) and formats only added
90  // to the supplier because the controls needed it.
91  css::uno::Reference< css::util::XNumberFormats >
93 
95  // the control ids of all controls on all pages we ever examined
96 
98  // for a given page (iter->first), and a given control (iter->second->first), this is the comma-separated
99  // lists of ids of the controls referring to the control given.
100 
101  MapPropertySet2Map::iterator
103  // the iterator for the control id map for the page being handled
104  MapPropertySet2Map::iterator
106  // the same for the map of referring controls
107 
108  // TODO: To avoid this construct above, and to have a cleaner implementation, a class encapsulating the
109  // export of a single page should be introduced.
110 
111  typedef std::map<css::uno::Reference<css::beans::XPropertySet>, sal_Int32> MapPropertySet2Int;
112  MapPropertySet2Int m_aControlNumberFormats;
113  // maps controls to format keys, which are relative to our own formats supplier
114 
116  // style names of grid columns
117 
118  public:
119  explicit OFormLayerXMLExport_Impl(SvXMLExport& _rContext);
120  virtual ~OFormLayerXMLExport_Impl();
121 
122  private:
125  void exportGridColumn(
126  const css::uno::Reference< css::beans::XPropertySet >& _rxColumn,
127  const css::uno::Sequence< css::script::ScriptEventDescriptor >& _rEvents
128  );
129 
132  void exportControl(
133  const css::uno::Reference< css::beans::XPropertySet >& _rxControl,
134  const css::uno::Sequence< css::script::ScriptEventDescriptor >& _rEvents
135  );
136 
139  void exportForm(const css::uno::Reference< css::beans::XPropertySet >& _rxProps,
140  const css::uno::Sequence< css::script::ScriptEventDescriptor >& _rEvents
141  );
142 
150  bool seekPage(
151  const css::uno::Reference< css::drawing::XDrawPage >& _rxDrawPage);
152 
157  OUString
158  getControlId(const css::uno::Reference< css::beans::XPropertySet >& _rxControl);
159 
165  OUString
166  getControlNumberStyle( const css::uno::Reference< css::beans::XPropertySet >& _rxControl );
167 
168  // IFormsExportContext
169  virtual void exportCollectionElements(const css::uno::Reference< css::container::XIndexAccess >& _rxCollection) override;
170  virtual SvXMLExport& getGlobalContext() override;
171  virtual OUString getObjectStyleName(
172  const css::uno::Reference< css::beans::XPropertySet >& _rxObject ) override;
173  virtual ::rtl::Reference< SvXMLExportPropertyMapper > getStylePropertyMapper() override;
174 
177  void clear();
178 
199  void examineForms(
200  const css::uno::Reference< css::drawing::XDrawPage >& _rxDrawPage);
201 
207  void exportForms(
208  const css::uno::Reference< css::drawing::XDrawPage >& _rxDrawPage);
209 
212  void exportXForms() const;
213 
216  static bool pageContainsForms( const css::uno::Reference< css::drawing::XDrawPage >& _rxDrawPage );
217 
220  bool documentContainsXForms() const;
221 
225 
228  void exportAutoStyles();
229 
230  static bool impl_isFormPageContainingForms(
231  const css::uno::Reference< css::drawing::XDrawPage >& _rxDrawPage,
232  css::uno::Reference< css::container::XIndexAccess >& _rxForms);
233 
238  bool implMoveIterators(
239  const css::uno::Reference< css::drawing::XDrawPage >& _rxDrawPage,
240  bool _bClear);
241 
245  bool checkExamineControl(const css::uno::Reference< css::beans::XPropertySet >& _rxObject);
246 
251  void examineControlNumberFormat(const css::uno::Reference< css::beans::XPropertySet >& _rxControl);
252 
257  sal_Int32 implExamineControlNumberFormat( const css::uno::Reference< css::beans::XPropertySet >& _rxObject );
258 
261  void collectGridColumnStylesAndIds( const css::uno::Reference< css::beans::XPropertySet >& _rxControl );
262 
272  sal_Int32 ensureTranslateFormat(const css::uno::Reference< css::beans::XPropertySet >& _rxFormattedControl);
273 
276 
279 
282  OUString
283  getImmediateNumberStyle( const css::uno::Reference< css::beans::XPropertySet >& _rxObject );
284 
287  static const OUString& getControlNumberStyleNamePrefix();
288 
296  void excludeFromExport( const css::uno::Reference< css::awt::XControlModel >& _rxControl );
297  };
298 
299 } // namespace xmloff
300 
301 #endif // INCLUDED_XMLOFF_SOURCE_FORMS_LAYEREXPORT_HXX
302 
303 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::util::XNumberFormats > m_xControlNumberFormats
Definition: layerexport.hxx:92
bool documentContainsXForms() const
determines whether the given page contains XForm instances
void exportXForms() const
exports the XForms model data
void excludeFromExport(const css::uno::Reference< css::awt::XControlModel > &_rxControl)
exclude the given control (model) from export.
static bool impl_isFormPageContainingForms(const css::uno::Reference< css::drawing::XDrawPage > &_rxDrawPage, css::uno::Reference< css::container::XIndexAccess > &_rxForms)
bool seekPage(const css::uno::Reference< css::drawing::XDrawPage > &_rxDrawPage)
seek to the page given.
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.
void examineControlNumberFormat(const css::uno::Reference< css::beans::XPropertySet > &_rxControl)
examines the control's number format, so later the format style can be referred
the implementation class for OFormLayerXMLExport
Definition: layerexport.hxx:60
MapPropertySet2Map::iterator m_aCurrentPageIds
bool checkExamineControl(const css::uno::Reference< css::beans::XPropertySet > &_rxObject)
check the object given if it's a control, if so, examine it.
This class is a base-class to create XMLPropertyHandler.
Definition: prhdlfac.hxx:40
SvXMLNumFmtExport * m_pControlNumberStyles
Definition: layerexport.hxx:66
OUString getControlId(const css::uno::Reference< css::beans::XPropertySet > &_rxControl)
get the id of the given control.
::rtl::Reference< XMLPropertyHandlerFactory > m_xPropertyHandlerFactory
Definition: layerexport.hxx:72
void examineForms(const css::uno::Reference< css::drawing::XDrawPage > &_rxDrawPage)
examine a forms collection.
SvXMLNumFmtExport * getControlNumberStyleExport()
returns the instance exporting our control's number styles
static const OUString & getControlNumberStyleNamePrefix()
returns the prefix to be used for control number styles
Definition: layerexport.cxx:66
void exportControl(const css::uno::Reference< css::beans::XPropertySet > &_rxControl, const css::uno::Sequence< css::script::ScriptEventDescriptor > &_rEvents)
exports one single control
::std::map< css::uno::Reference< css::drawing::XDrawPage >, MapPropertySet2String > MapPropertySet2Map
Definition: layerexport.hxx:55
void exportAutoStyles()
exports the auto-styles collected during the examineForms calls
void exportAutoControlNumberStyles()
exports the automatic control number styles
MapPropertySet2Map::iterator m_aCurrentPageReferring
MapPropertySet2Map m_aControlIds
Definition: layerexport.hxx:94
::std::map< css::uno::Reference< css::beans::XPropertySet >, OUString > MapPropertySet2String
Definition: layerexport.hxx:50
bool implMoveIterators(const css::uno::Reference< css::drawing::XDrawPage > &_rxDrawPage, bool _bClear)
moves the m_aCurrentPage* members to the positions specifying the given page.
::std::set< css::uno::Reference< css::beans::XPropertySet > > PropertySetBag
Definition: layerexport.hxx:45
virtual void exportCollectionElements(const css::uno::Reference< css::container::XIndexAccess > &_rxCollection) override
steps through a collection and exports all children of this collection
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
virtual ::rtl::Reference< SvXMLExportPropertyMapper > getStylePropertyMapper() override
std::map< css::uno::Reference< css::beans::XPropertySet >, sal_Int32 > MapPropertySet2Int
virtual SvXMLExport & getGlobalContext() override
void exportGridColumn(const css::uno::Reference< css::beans::XPropertySet > &_rxColumn, const css::uno::Sequence< css::script::ScriptEventDescriptor > &_rEvents)
exports one single grid column
void clear()
clear any structures which have been build in the recent examine calls...
void collectGridColumnStylesAndIds(const css::uno::Reference< css::beans::XPropertySet > &_rxControl)
collects AutoStyles for grid columns
void exportForm(const css::uno::Reference< css::beans::XPropertySet > &_rxProps, const css::uno::Sequence< css::script::ScriptEventDescriptor > &_rEvents)
exports one single form
OUString getImmediateNumberStyle(const css::uno::Reference< css::beans::XPropertySet > &_rxObject)
determines the number format style for the given object without remembering it
void exportForms(const css::uno::Reference< css::drawing::XDrawPage > &_rxDrawPage)
export a forms collection of a draw page
OFormLayerXMLExport_Impl(SvXMLExport &_rContext)
Definition: layerexport.cxx:72
OUString getControlNumberStyle(const css::uno::Reference< css::beans::XPropertySet > &_rxControl)
retrieves the style name for the control's number style.
void ensureControlNumberStyleExport()
ensures that the instance exporting our control's number styles exists
MapPropertySet2Int m_aControlNumberFormats
provides functionality for exporting a complete form layer.
virtual OUString getObjectStyleName(const css::uno::Reference< css::beans::XPropertySet > &_rxObject) override
MapPropertySet2String m_aGridColumnStyles
static bool pageContainsForms(const css::uno::Reference< css::drawing::XDrawPage > &_rxDrawPage)
determines whether the given page contains logical forms
::rtl::Reference< SvXMLExportPropertyMapper > m_xStyleExportMapper
Definition: layerexport.hxx:73
MapPropertySet2Map m_aReferringControls
Definition: layerexport.hxx:97