Line data Source code
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 RPT_XMLFILTER_HXX
20 : #define RPT_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/document/XExporter.hpp>
26 : #include <com/sun/star/lang/XInitialization.hpp>
27 : #include <com/sun/star/lang/XServiceInfo.hpp>
28 : #include <com/sun/star/beans/XPropertySet.hpp>
29 : #include <com/sun/star/lang/XComponent.hpp>
30 : #include <cppuhelper/implbase1.hxx>
31 : #include <cppuhelper/implbase5.hxx>
32 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
33 : #include <com/sun/star/io/XActiveDataSource.hpp>
34 : #include <com/sun/star/report/XReportDefinition.hpp>
35 : #include <osl/diagnose.h>
36 : #include <unotools/tempfile.hxx>
37 : #include <unotools/localfilehelper.hxx>
38 : #include <unotools/ucbstreamhelper.hxx>
39 : #include <xmloff/xmlimp.hxx>
40 : #include <comphelper/sequence.hxx>
41 : #include <com/sun/star/uno/XComponentContext.hpp>
42 : #include <map>
43 : #include <memory>
44 : #include <boost/shared_ptr.hpp>
45 : #include <xmloff/prhdlfac.hxx>
46 : #include <xmloff/xmlprmap.hxx>
47 :
48 : namespace rptui
49 : {
50 : class OReportModel;
51 : }
52 : namespace rptxml
53 : {
54 : using namespace ::xmloff::token;
55 : using namespace ::com::sun::star::uno;
56 : using namespace ::com::sun::star::container;
57 : using namespace ::com::sun::star::lang;
58 : using namespace ::com::sun::star::beans;
59 : using namespace ::com::sun::star::document;
60 : using namespace ::com::sun::star::text;
61 : using namespace ::com::sun::star::io;
62 : using namespace ::com::sun::star::report;
63 : using namespace ::com::sun::star::xml::sax;
64 :
65 :
66 : // - ORptFilter -
67 :
68 : class ORptFilter : public SvXMLImport
69 : {
70 : public:
71 : typedef std::map< OUString, Sequence<PropertyValue> > TPropertyNameMap;
72 : typedef std::map< OUString, Reference<XFunction> > TGroupFunctionMap;
73 : private:
74 :
75 : TGroupFunctionMap m_aFunctions;
76 : com::sun::star::uno::Any m_aViewSettings;
77 : Reference< XComponent > m_xSrcDoc;
78 :
79 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
80 : mutable ::std::auto_ptr<SvXMLTokenMap> m_pDocElemTokenMap;
81 : mutable ::std::auto_ptr<SvXMLTokenMap> m_pReportElemTokenMap;
82 : mutable ::std::auto_ptr<SvXMLTokenMap> m_pGroupsElemTokenMap;
83 : mutable ::std::auto_ptr<SvXMLTokenMap> m_pGroupElemTokenMap;
84 : mutable ::std::auto_ptr<SvXMLTokenMap> m_pSectionElemTokenMap;
85 : mutable ::std::auto_ptr<SvXMLTokenMap> m_pComponentElemTokenMap;
86 : mutable ::std::auto_ptr<SvXMLTokenMap> m_pElemTokenMap;
87 : mutable ::std::auto_ptr<SvXMLTokenMap> m_pControlElemTokenMap;
88 : mutable ::std::auto_ptr<SvXMLTokenMap> m_pFunctionElemTokenMap;
89 : mutable ::std::auto_ptr<SvXMLTokenMap> m_pSubDocumentElemTokenMap;
90 : mutable ::std::auto_ptr<SvXMLTokenMap> m_pFormatElemTokenMap;
91 : mutable ::std::auto_ptr<SvXMLTokenMap> m_pColumnTokenMap;
92 : mutable ::std::auto_ptr<SvXMLTokenMap> m_pCellElemTokenMap;
93 : SAL_WNODEPRECATED_DECLARATIONS_POP
94 :
95 : UniReference < XMLPropertyHandlerFactory > m_xPropHdlFactory;
96 : UniReference < XMLPropertySetMapper > m_xCellStylesPropertySetMapper;
97 : UniReference < XMLPropertySetMapper > m_xColumnStylesPropertySetMapper;
98 : UniReference < XMLPropertySetMapper > m_xRowStylesPropertySetMapper;
99 : UniReference < XMLPropertySetMapper > m_xTableStylesPropertySetMapper;
100 :
101 : Reference<XReportDefinition> m_xReportDefinition;
102 : ::boost::shared_ptr<rptui::OReportModel> m_pReportModel;
103 :
104 : sal_Bool implImport( const Sequence< PropertyValue >& rDescriptor ) throw (RuntimeException);
105 :
106 : SvXMLImportContext* CreateStylesContext(const OUString& rLocalName,
107 : const Reference< XAttributeList>& xAttrList, sal_Bool bIsAutoStyle );
108 : SvXMLImportContext* CreateMetaContext(const OUString& rLocalName,
109 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
110 : SvXMLImportContext* CreateFontDeclsContext(const OUString& rLocalName,
111 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
112 : protected:
113 : // SvXMLImport
114 : virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
115 : const OUString& rLocalName,
116 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ) SAL_OVERRIDE;
117 :
118 : virtual XMLShapeImportHelper* CreateShapeImport() SAL_OVERRIDE;
119 :
120 : virtual ~ORptFilter() throw();
121 : public:
122 :
123 : ORptFilter( const Reference< XComponentContext >& _rxContext, sal_uInt16 nImportFlags = IMPORT_ALL );
124 :
125 : // XFilter
126 : virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& rDescriptor ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
127 :
128 : static ::com::sun::star::uno::Sequence< OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
129 : static OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException );
130 : static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
131 : create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext);
132 :
133 : inline Reference< XComponentContext > getORB() { return SvXMLImport::GetComponentContext(); }
134 0 : inline Reference<XReportDefinition> getReportDefinition() const { return m_xReportDefinition; }
135 : /** return the SdrModel of the real model
136 : *
137 : * \return
138 : */
139 : ::boost::shared_ptr<rptui::OReportModel> getSdrModel() const { return m_pReportModel; }
140 : void FinishStyles();
141 :
142 : virtual void SAL_CALL startDocument(void)
143 : throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
144 : virtual void SAL_CALL endDocument(void)
145 : throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
146 :
147 : const SvXMLTokenMap& GetDocElemTokenMap() const;
148 : const SvXMLTokenMap& GetReportElemTokenMap() const;
149 : const SvXMLTokenMap& GetGroupElemTokenMap() const;
150 : const SvXMLTokenMap& GetSectionElemTokenMap() const;
151 : const SvXMLTokenMap& GetComponentElemTokenMap() const;
152 : const SvXMLTokenMap& GetReportElementElemTokenMap() const;
153 : const SvXMLTokenMap& GetControlElemTokenMap() const;
154 : const SvXMLTokenMap& GetControlPropertyElemTokenMap() const;
155 : const SvXMLTokenMap& GetFunctionElemTokenMap() const;
156 : const SvXMLTokenMap& GetFormatElemTokenMap() const;
157 : const SvXMLTokenMap& GetSubDocumentElemTokenMap() const;
158 : const SvXMLTokenMap& GetColumnTokenMap() const;
159 : const SvXMLTokenMap& GetCellElemTokenMap() const;
160 :
161 0 : inline UniReference < XMLPropertySetMapper > GetCellStylesPropertySetMapper() const { return m_xCellStylesPropertySetMapper; }
162 0 : inline UniReference < XMLPropertySetMapper > GetColumnStylesPropertySetMapper() const { return m_xColumnStylesPropertySetMapper; }
163 0 : inline UniReference < XMLPropertySetMapper > GetRowStylesPropertySetMapper() const { return m_xRowStylesPropertySetMapper; }
164 : inline UniReference < XMLPropertySetMapper > GetTableStylesPropertySetMapper() const { return m_xTableStylesPropertySetMapper; }
165 : static OUString convertFormula(const OUString& _sFormula);
166 : /** inserts a new function
167 : *
168 : * \param _xFunction
169 : */
170 : void insertFunction(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunction > & _xFunction);
171 : void removeFunction(const OUString& _sFunctionName);
172 0 : inline const TGroupFunctionMap& getFunctions() const { return m_aFunctions; }
173 :
174 : virtual SvXMLImport& getGlobalContext();
175 :
176 : virtual void enterEventContext();
177 : virtual void leaveEventContext();
178 :
179 : sal_Bool isOldFormat() const;
180 : };
181 :
182 : /** Imports only settings
183 : * \ingroup reportdesign_source_filter_xml
184 : *
185 : */
186 : class ORptImportHelper
187 : {
188 : public:
189 : static OUString getImplementationName_Static( ) throw (::com::sun::star::uno::RuntimeException);
190 : static Sequence< OUString > getSupportedServiceNames_Static( ) throw(::com::sun::star::uno::RuntimeException);
191 : static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
192 : create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext);
193 : };
194 :
195 : /** Imports only content
196 : * \ingroup reportdesign_source_filter_xml
197 : *
198 : */
199 : class ORptContentImportHelper
200 : {
201 : public:
202 : static OUString getImplementationName_Static( ) throw (::com::sun::star::uno::RuntimeException);
203 : static Sequence< OUString > getSupportedServiceNames_Static( ) throw(::com::sun::star::uno::RuntimeException);
204 : static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
205 : create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext);
206 : };
207 :
208 : /** Imports only styles
209 : * \ingroup reportdesign_source_filter_xml
210 : *
211 : */
212 : class ORptStylesImportHelper
213 : {
214 : public:
215 : static OUString getImplementationName_Static( ) throw (::com::sun::star::uno::RuntimeException);
216 : static Sequence< OUString > getSupportedServiceNames_Static( ) throw(::com::sun::star::uno::RuntimeException);
217 : static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
218 : create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext);
219 : };
220 :
221 : /** Imports only meta data
222 : * \ingroup reportdesign_source_filter_xml
223 : *
224 : */
225 : class ORptMetaImportHelper
226 : {
227 : public:
228 : static OUString getImplementationName_Static( ) throw (::com::sun::star::uno::RuntimeException);
229 : static Sequence< OUString > getSupportedServiceNames_Static( ) throw(::com::sun::star::uno::RuntimeException);
230 : static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
231 : create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext);
232 : };
233 :
234 :
235 : } // rptxml
236 :
237 : #endif // RPT_XMLFILTER_HXX
238 :
239 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|