LibreOffice Module reportdesign (master)  1
xmlExport.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_REPORTDESIGN_SOURCE_FILTER_XML_XMLEXPORT_HXX
21 #define INCLUDED_REPORTDESIGN_SOURCE_FILTER_XML_XMLEXPORT_HXX
22 
23 #include <com/sun/star/container/XNamed.hpp>
24 #include <com/sun/star/document/XFilter.hpp>
25 #include <com/sun/star/document/XImporter.hpp>
26 #include <com/sun/star/beans/XPropertySet.hpp>
27 #include <com/sun/star/report/XReportDefinition.hpp>
28 #include <com/sun/star/report/XSection.hpp>
29 #include <com/sun/star/report/XReportControlModel.hpp>
30 #include <com/sun/star/report/XFormattedField.hpp>
31 #include <com/sun/star/lang/XComponent.hpp>
32 #include <xmloff/xmlexp.hxx>
33 #include <xmloff/xmlexppr.hxx>
34 #include <xmloff/prhdlfac.hxx>
35 #include <xmloff/xmlprmap.hxx>
36 #include <com/sun/star/uno/XComponentContext.hpp>
37 #include <memory>
38 
39 namespace rptxml
40 {
41 using namespace ::xmloff::token;
42 using namespace css::uno;
43 using namespace css::container;
44 using namespace css::lang;
45 using namespace css::beans;
46 using namespace css::document;
47 using namespace css::text;
48 using namespace css::report;
49 using namespace css::io;
50 using namespace css::xml::sax;
51 
52 
53 class ORptExport : public SvXMLExport
54 {
55 public:
56  struct TCell
57  {
58  sal_Int32 nColSpan;
59  sal_Int32 nRowSpan;
60  Reference<XReportComponent> xElement;
61  bool bSet;
62  TCell( sal_Int32 _nColSpan,
63  sal_Int32 _nRowSpan,
64  Reference<XReportComponent> const & _xElement = Reference<XReportComponent>()) :
65  nColSpan(_nColSpan)
66  ,nRowSpan(_nRowSpan)
67  ,xElement(_xElement)
68  ,bSet(xElement.is())
69  {}
70 
71  TCell( ) :
72  nColSpan(1)
73  ,nRowSpan(1)
74  ,bSet(true)
75  {}
76  };
77  typedef ::std::pair< OUString ,OUString> TStringPair;
78  typedef ::std::map< Reference<XPropertySet> ,OUString > TPropertyStyleMap;
79  typedef ::std::map< Reference<XPropertySet> , std::vector<OUString>> TGridStyleMap;
80  typedef ::std::vector< TCell > TRow;
81  typedef ::std::vector< ::std::pair< bool, TRow > > TGrid;
82  typedef ::std::map< Reference<XPropertySet> ,TGrid > TSectionsGrid;
83  typedef ::std::map< Reference<XGroup> ,Reference<XFunction> > TGroupFunctionMap;
84 private:
85  TSectionsGrid m_aSectionsGrid;
86 
87  TPropertyStyleMap m_aAutoStyleNames;
88  TGridStyleMap m_aColumnStyleNames;
89  TGridStyleMap m_aRowStyleNames;
90  TGroupFunctionMap m_aGroupFunctionMap;
91 
92  OUString m_sTableStyle;
93  OUString m_sCellStyle;
100 
102  Reference<XReportDefinition> m_xReportDefinition;
104 
105  void exportReport(const Reference<XReportDefinition>& _xReportDefinition);
106  void exportReportAttributes(const Reference<XReportDefinition>& _xReport);
107  void exportFunctions(const Reference<XIndexAccess>& _xFunctions);
108  void exportFunction(const Reference< XFunction>& _xFunction);
109  void exportMasterDetailFields(const Reference<XReportComponent>& _xReportComponent);
110  void exportComponent(const Reference<XReportComponent>& _xReportComponent);
111  void exportGroup(const Reference<XReportDefinition>& _xReportDefinition,sal_Int32 _nPos,bool _bExportAutoStyle = false);
112  void exportStyleName(XPropertySet* _xProp,SvXMLAttributeList& _rAtt,const OUString& _sName);
113  void exportSection(const Reference<XSection>& _xProp,bool bHeader = false);
114  void exportContainer(const Reference< XSection>& _xSection);
115  void exportShapes(const Reference< XSection>& _xSection,bool _bAddParagraph = true);
116  void exportTableColumns(const Reference< XSection>& _xSection);
117  void exportSectionAutoStyle(const Reference<XSection>& _xProp);
118  void exportReportElement(const Reference<XReportControlModel>& _xReportElement);
119  void exportFormatConditions(const Reference<XReportControlModel>& _xReportElement);
120  void exportAutoStyle(XPropertySet* _xProp,const Reference<XFormattedField>& _xParentFormattedField = Reference<XFormattedField>());
121  void exportAutoStyle(const Reference<XSection>& _xProp);
122  void exportReportComponentAutoStyles(const Reference<XSection>& _xProp);
123  void collectComponentStyles();
124  void collectStyleNames(XmlStyleFamily _nFamily,const ::std::vector< sal_Int32>& _aSize, std::vector<OUString>& _rStyleNames);
125  void collectStyleNames(XmlStyleFamily _nFamily,const ::std::vector< sal_Int32>& _aSize, const ::std::vector< sal_Int32>& _aSizeAutoGrow, std::vector<OUString>& _rStyleNames);
126  void exportParagraph(const Reference< XReportControlModel >& _xReportElement);
127  bool exportFormula(enum ::xmloff::token::XMLTokenEnum eName,const OUString& _sFormula);
128  void exportGroupsExpressionAsFunction(const Reference< XGroups>& _xGroups);
129  static OUString convertFormula(const OUString& _sFormula);
130 
131  virtual void SetBodyAttributes() override;
132 
133 protected:
134 
135  virtual void ExportStyles_( bool bUsed ) override;
136  virtual void ExportAutoStyles_() override;
137  virtual void ExportContent_() override;
138  virtual void ExportMasterStyles_() override;
139  virtual void ExportFontDecls_() override;
140  virtual SvXMLAutoStylePoolP* CreateAutoStylePool() override;
141  virtual XMLShapeExport* CreateShapeExport() override;
142 
143  virtual ~ORptExport() override {};
144 public:
145 
146  ORptExport(const Reference< XComponentContext >& _rxContext, OUString const & implementationName, SvXMLExportFlags nExportFlag);
147 
148  // XExporter
149  virtual void SAL_CALL setSourceDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
150 
151  const Reference<XReportDefinition>& getReportDefinition() const { return m_xReportDefinition; }
152 
153  const rtl::Reference < XMLPropertySetMapper >& GetCellStylePropertyMapper() const { return m_xCellStylesPropertySetMapper;}
154 };
155 
156 
157 } // rptxml
158 
159 #endif // INCLUDED_REPORTDESIGN_SOURCE_FILTER_XML_XMLEXPORT_HXX
160 
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::Reference< XMLPropertyHandlerFactory > m_xPropHdlFactory
Definition: xmlExport.hxx:99
::std::map< Reference< XPropertySet >,TGrid > TSectionsGrid
Definition: xmlExport.hxx:82
TPropertyStyleMap m_aAutoStyleNames
Definition: xmlExport.hxx:87
rtl::Reference< SvXMLExportPropertyMapper > m_xRowStylesExportPropertySetMapper
Definition: xmlExport.hxx:97
SvXMLExportFlags
TSectionsGrid m_aSectionsGrid
Definition: xmlExport.hxx:85
::std::pair< OUString,OUString > TStringPair
Definition: xmlExport.hxx:77
TGroupFunctionMap m_aGroupFunctionMap
Definition: xmlExport.hxx:90
::std::map< Reference< XPropertySet >,OUString > TPropertyStyleMap
Definition: xmlExport.hxx:78
XmlStyleFamily
OUString m_sCellStyle
Definition: xmlExport.hxx:93
TGridStyleMap m_aRowStyleNames
Definition: xmlExport.hxx:89
OUString m_sTableStyle
Definition: xmlExport.hxx:92
TGridStyleMap m_aColumnStyleNames
Definition: xmlExport.hxx:88
::std::vector< TCell > TRow
Definition: xmlExport.hxx:80
rtl::Reference< SvXMLExportPropertyMapper > m_xTableStylesExportPropertySetMapper
Definition: xmlExport.hxx:94
rtl::Reference< SvXMLExportPropertyMapper > m_xColumnStylesExportPropertySetMapper
Definition: xmlExport.hxx:96
TCell(sal_Int32 _nColSpan, sal_Int32 _nRowSpan, Reference< XReportComponent > const &_xElement=Reference< XReportComponent >())
Definition: xmlExport.hxx:62
Reference< XReportDefinition > m_xReportDefinition
Definition: xmlExport.hxx:102
::std::map< Reference< XGroup >,Reference< XFunction > > TGroupFunctionMap
Definition: xmlExport.hxx:83
rtl::Reference< XMLPropertySetMapper > m_xCellStylesPropertySetMapper
Definition: xmlExport.hxx:101
::std::map< Reference< XPropertySet >, std::vector< OUString > > TGridStyleMap
Definition: xmlExport.hxx:79
::std::vector< ::std::pair< bool, TRow > > TGrid
Definition: xmlExport.hxx:81
const rtl::Reference< XMLPropertySetMapper > & GetCellStylePropertyMapper() const
Definition: xmlExport.hxx:153
const Reference< XReportDefinition > & getReportDefinition() const
Definition: xmlExport.hxx:151
rtl::Reference< SvXMLExportPropertyMapper > m_xCellStylesExportPropertySetMapper
Definition: xmlExport.hxx:95
Reference< XReportComponent > xElement
Definition: xmlExport.hxx:60
rtl::Reference< SvXMLExportPropertyMapper > m_xParaPropMapper
Definition: xmlExport.hxx:98
virtual ~ORptExport() override
Definition: xmlExport.hxx:143