LibreOffice Module reportdesign (master)  1
xmlfilter.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 #ifndef INCLUDED_REPORTDESIGN_SOURCE_FILTER_XML_XMLFILTER_HXX
20 #define INCLUDED_REPORTDESIGN_SOURCE_FILTER_XML_XMLFILTER_HXX
21 
22 #include <com/sun/star/container/XNamed.hpp>
23 #include <com/sun/star/document/XFilter.hpp>
24 #include <com/sun/star/document/XImporter.hpp>
25 #include <com/sun/star/io/XActiveDataSource.hpp>
26 #include <com/sun/star/report/XReportDefinition.hpp>
27 #include <xmloff/xmlimp.hxx>
28 #include <com/sun/star/uno/XComponentContext.hpp>
29 #include <map>
30 #include <memory>
31 #include <xmloff/prhdlfac.hxx>
32 #include <xmloff/xmlprmap.hxx>
33 
34 namespace rptui
35 {
36 class OReportModel;
37 }
38 namespace rptxml
39 {
40 using namespace ::xmloff::token;
41 using namespace ::com::sun::star::uno;
42 using namespace ::com::sun::star::container;
43 using namespace ::com::sun::star::lang;
44 using namespace ::com::sun::star::beans;
45 using namespace ::com::sun::star::document;
46 using namespace ::com::sun::star::text;
47 using namespace ::com::sun::star::io;
48 using namespace ::com::sun::star::report;
49 using namespace ::com::sun::star::xml::sax;
50 
51 
52 class ORptFilter : public SvXMLImport
53 {
54 public:
55  typedef std::map< OUString, Sequence<PropertyValue> > TPropertyNameMap;
56  typedef std::map< OUString, Reference<XFunction> > TGroupFunctionMap;
57 private:
58 
59  TGroupFunctionMap m_aFunctions;
60 
65 
66  Reference<XReportDefinition> m_xReportDefinition;
67  std::shared_ptr<rptui::OReportModel> m_pReportModel;
68 
70  bool implImport( const Sequence< PropertyValue >& rDescriptor );
71 
72 public:
74  SvXMLImportContext* CreateStylesContext( bool bIsAutoStyle );
75  SvXMLImportContext* CreateMetaContext(const sal_Int32 nElement);
77 protected:
78  // SvXMLImport
79  virtual SvXMLImportContext *CreateFastContext( sal_Int32 nElement,
80  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
81 
82  virtual XMLShapeImportHelper* CreateShapeImport() override;
83 
84  virtual ~ORptFilter() noexcept override;
85 public:
86 
87  ORptFilter( const Reference< XComponentContext >& _rxContext, OUString const & rImplementationName, SvXMLImportFlags nImportFlags );
88 
89  // XFilter
90  virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& rDescriptor ) override;
91 
92  const Reference<XReportDefinition>& getReportDefinition() const {
93  return m_xReportDefinition;
94  }
95  void FinishStyles();
96 
97  virtual void SAL_CALL startDocument() override;
98  virtual void SAL_CALL endDocument() override;
99 
102  }
105  }
108  }
109  static const OUString& convertFormula(const OUString& _sFormula);
114  void insertFunction(const css::uno::Reference< css::report::XFunction > & _xFunction);
115  void removeFunction(const OUString& _sFunctionName);
116  const TGroupFunctionMap& getFunctions() const {
117  return m_aFunctions;
118  }
119 
120  bool isOldFormat() const;
121 };
122 
123 
125 {
126 public:
128  : SvXMLImportContext(rImport)
129  {
130  }
131 
132  virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
133  sal_Int32 /*nElement*/, const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ ) override;
134 };
135 
136 } // rptxml
137 
138 #endif // INCLUDED_REPORTDESIGN_SOURCE_FILTER_XML_XMLFILTER_HXX
139 
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const Reference< XReportDefinition > & getReportDefinition() const
Definition: xmlfilter.hxx:92
const rtl::Reference< XMLPropertySetMapper > & GetRowStylesPropertySetMapper() const
Definition: xmlfilter.hxx:106
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32, const css::uno::Reference< css::xml::sax::XFastAttributeList > &) override
Definition: xmlfilter.cxx:583
const rtl::Reference< XMLPropertySetMapper > & GetColumnStylesPropertySetMapper() const
Definition: xmlfilter.hxx:103
Reference< XReportDefinition > m_xReportDefinition
Definition: xmlfilter.hxx:66
virtual void SAL_CALL startDocument() override
Definition: xmlfilter.cxx:699
std::shared_ptr< rptui::OReportModel > m_pReportModel
Definition: xmlfilter.hxx:67
SvXMLImportFlags
virtual ~ORptFilter() noexcept override
Definition: xmlfilter.cxx:316
rtl::Reference< XMLPropertyHandlerFactory > m_xPropHdlFactory
Definition: xmlfilter.hxx:61
static const OUString & convertFormula(const OUString &_sFormula)
Definition: xmlfilter.cxx:694
SvXMLImportContext * CreateFontDeclsContext()
Definition: xmlfilter.cxx:675
SvXMLImportContext * CreateStylesContext(bool bIsAutoStyle)
Definition: xmlfilter.cxx:661
std::map< OUString, Sequence< PropertyValue > > TPropertyNameMap
Definition: xmlfilter.hxx:55
virtual void SAL_CALL endDocument() override
Definition: xmlfilter.cxx:708
void insertFunction(const css::uno::Reference< css::report::XFunction > &_xFunction)
inserts a new function
Definition: xmlfilter.cxx:731
void SetMasterStyles(SvXMLStylesContext *pMasterStyles)
bool isOldFormat() const
Definition: xmlfilter.cxx:748
RptXMLDocumentBodyContext(SvXMLImport &rImport)
Definition: xmlfilter.hxx:127
unsigned char sal_Bool
rtl::Reference< XMLPropertySetMapper > m_xRowStylesPropertySetMapper
Definition: xmlfilter.hxx:64
virtual SvXMLImportContext * CreateFastContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: xmlfilter.cxx:636
const TGroupFunctionMap & getFunctions() const
Definition: xmlfilter.hxx:116
rtl::Reference< XMLPropertySetMapper > m_xColumnStylesPropertySetMapper
Definition: xmlfilter.hxx:63
const rtl::Reference< XMLPropertySetMapper > & GetCellStylesPropertySetMapper() const
Definition: xmlfilter.hxx:100
TGroupFunctionMap m_aFunctions
Definition: xmlfilter.hxx:59
bool implImport(const Sequence< PropertyValue > &rDescriptor)
Definition: xmlfilter.cxx:346
void removeFunction(const OUString &_sFunctionName)
Definition: xmlfilter.cxx:726
std::map< OUString, Reference< XFunction > > TGroupFunctionMap
Definition: xmlfilter.hxx:56
virtual XMLShapeImportHelper * CreateShapeImport() override
Definition: xmlfilter.cxx:683
SvXMLImportContext * CreateMetaContext(const sal_Int32 nElement)
Definition: xmlfilter.cxx:736
rtl::Reference< XMLPropertySetMapper > m_xCellStylesPropertySetMapper
Definition: xmlfilter.hxx:62