1*9ee13d13SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9ee13d13SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9ee13d13SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9ee13d13SAndrew Rist * distributed with this work for additional information 6*9ee13d13SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9ee13d13SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9ee13d13SAndrew Rist * "License"); you may not use this file except in compliance 9*9ee13d13SAndrew Rist * with the License. You may obtain a copy of the License at 10*9ee13d13SAndrew Rist * 11*9ee13d13SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*9ee13d13SAndrew Rist * 13*9ee13d13SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9ee13d13SAndrew Rist * software distributed under the License is distributed on an 15*9ee13d13SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9ee13d13SAndrew Rist * KIND, either express or implied. See the License for the 17*9ee13d13SAndrew Rist * specific language governing permissions and limitations 18*9ee13d13SAndrew Rist * under the License. 19*9ee13d13SAndrew Rist * 20*9ee13d13SAndrew Rist *************************************************************/ 21*9ee13d13SAndrew Rist 22*9ee13d13SAndrew Rist 23cdf0e10cSrcweir #ifndef RPT_XMLFILTER_HXX 24cdf0e10cSrcweir #define RPT_XMLFILTER_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <com/sun/star/container/XNamed.hpp> 27cdf0e10cSrcweir #include <com/sun/star/document/XFilter.hpp> 28cdf0e10cSrcweir #include <com/sun/star/document/XImporter.hpp> 29cdf0e10cSrcweir #include <com/sun/star/document/XExporter.hpp> 30cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 31cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 32cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 33cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp> 34cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 35cdf0e10cSrcweir #include <cppuhelper/implbase5.hxx> 36cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 37cdf0e10cSrcweir #include <com/sun/star/io/XActiveDataSource.hpp> 38cdf0e10cSrcweir #include <com/sun/star/report/XReportDefinition.hpp> 39cdf0e10cSrcweir #include <osl/diagnose.h> 40cdf0e10cSrcweir #include <unotools/tempfile.hxx> 41cdf0e10cSrcweir #include <unotools/localfilehelper.hxx> 42cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx> 43cdf0e10cSrcweir #include <xmloff/xmlimp.hxx> 44cdf0e10cSrcweir #include <comphelper/stl_types.hxx> 45cdf0e10cSrcweir #include <comphelper/sequence.hxx> 46cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 47cdf0e10cSrcweir #include <memory> 48cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 49cdf0e10cSrcweir #include <xmloff/prhdlfac.hxx> 50cdf0e10cSrcweir #include <xmloff/xmlprmap.hxx> 51cdf0e10cSrcweir 52cdf0e10cSrcweir namespace rptui 53cdf0e10cSrcweir { 54cdf0e10cSrcweir class OReportModel; 55cdf0e10cSrcweir } 56cdf0e10cSrcweir namespace rptxml 57cdf0e10cSrcweir { 58cdf0e10cSrcweir using namespace ::xmloff::token; 59cdf0e10cSrcweir using namespace ::com::sun::star::uno; 60cdf0e10cSrcweir using namespace ::com::sun::star::container; 61cdf0e10cSrcweir using namespace ::com::sun::star::lang; 62cdf0e10cSrcweir using namespace ::com::sun::star::beans; 63cdf0e10cSrcweir using namespace ::com::sun::star::document; 64cdf0e10cSrcweir using namespace ::com::sun::star::text; 65cdf0e10cSrcweir using namespace ::com::sun::star::io; 66cdf0e10cSrcweir using namespace ::com::sun::star::report; 67cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax; 68cdf0e10cSrcweir 69cdf0e10cSrcweir // ------------- 70cdf0e10cSrcweir // - ORptFilter - 71cdf0e10cSrcweir // ------------- 72cdf0e10cSrcweir class ORptFilter : public SvXMLImport 73cdf0e10cSrcweir { 74cdf0e10cSrcweir public: 75cdf0e10cSrcweir DECLARE_STL_USTRINGACCESS_MAP(Sequence<PropertyValue>,TPropertyNameMap); 76cdf0e10cSrcweir DECLARE_STL_USTRINGACCESS_MAP( Reference<XFunction> ,TGroupFunctionMap); 77cdf0e10cSrcweir private: 78cdf0e10cSrcweir 79cdf0e10cSrcweir TGroupFunctionMap m_aFunctions; 80cdf0e10cSrcweir com::sun::star::uno::Any m_aViewSettings; 81cdf0e10cSrcweir Reference< XComponent > m_xSrcDoc; 82cdf0e10cSrcweir mutable ::std::auto_ptr<SvXMLTokenMap> m_pDocElemTokenMap; 83cdf0e10cSrcweir mutable ::std::auto_ptr<SvXMLTokenMap> m_pReportElemTokenMap; 84cdf0e10cSrcweir mutable ::std::auto_ptr<SvXMLTokenMap> m_pGroupsElemTokenMap; 85cdf0e10cSrcweir mutable ::std::auto_ptr<SvXMLTokenMap> m_pGroupElemTokenMap; 86cdf0e10cSrcweir mutable ::std::auto_ptr<SvXMLTokenMap> m_pSectionElemTokenMap; 87cdf0e10cSrcweir mutable ::std::auto_ptr<SvXMLTokenMap> m_pComponentElemTokenMap; 88cdf0e10cSrcweir mutable ::std::auto_ptr<SvXMLTokenMap> m_pElemTokenMap; 89cdf0e10cSrcweir mutable ::std::auto_ptr<SvXMLTokenMap> m_pControlElemTokenMap; 90cdf0e10cSrcweir mutable ::std::auto_ptr<SvXMLTokenMap> m_pFunctionElemTokenMap; 91cdf0e10cSrcweir mutable ::std::auto_ptr<SvXMLTokenMap> m_pSubDocumentElemTokenMap; 92cdf0e10cSrcweir mutable ::std::auto_ptr<SvXMLTokenMap> m_pFormatElemTokenMap; 93cdf0e10cSrcweir mutable ::std::auto_ptr<SvXMLTokenMap> m_pColumnTokenMap; 94cdf0e10cSrcweir mutable ::std::auto_ptr<SvXMLTokenMap> m_pCellElemTokenMap; 95cdf0e10cSrcweir 96cdf0e10cSrcweir UniReference < XMLPropertyHandlerFactory > m_xPropHdlFactory; 97cdf0e10cSrcweir UniReference < XMLPropertySetMapper > m_xCellStylesPropertySetMapper; 98cdf0e10cSrcweir UniReference < XMLPropertySetMapper > m_xColumnStylesPropertySetMapper; 99cdf0e10cSrcweir UniReference < XMLPropertySetMapper > m_xRowStylesPropertySetMapper; 100cdf0e10cSrcweir UniReference < XMLPropertySetMapper > m_xTableStylesPropertySetMapper; 101cdf0e10cSrcweir 102cdf0e10cSrcweir Reference<XReportDefinition> m_xReportDefinition; 103cdf0e10cSrcweir ::boost::shared_ptr<rptui::OReportModel> m_pReportModel; 104cdf0e10cSrcweir 105cdf0e10cSrcweir sal_Bool implImport( const Sequence< PropertyValue >& rDescriptor ) throw (RuntimeException); 106cdf0e10cSrcweir 107cdf0e10cSrcweir SvXMLImportContext* CreateStylesContext(const ::rtl::OUString& rLocalName, 108cdf0e10cSrcweir const Reference< XAttributeList>& xAttrList, sal_Bool bIsAutoStyle ); 109cdf0e10cSrcweir SvXMLImportContext* CreateMetaContext(const ::rtl::OUString& rLocalName, 110cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); 111cdf0e10cSrcweir SvXMLImportContext* CreateFontDeclsContext(const ::rtl::OUString& rLocalName, 112cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); 113cdf0e10cSrcweir protected: 114cdf0e10cSrcweir // SvXMLImport 115cdf0e10cSrcweir virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix, 116cdf0e10cSrcweir const ::rtl::OUString& rLocalName, 117cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); 118cdf0e10cSrcweir 119cdf0e10cSrcweir virtual XMLShapeImportHelper* CreateShapeImport(); 120cdf0e10cSrcweir 121cdf0e10cSrcweir virtual ~ORptFilter() throw(); 122cdf0e10cSrcweir public: 123cdf0e10cSrcweir 124cdf0e10cSrcweir ORptFilter( const Reference< XMultiServiceFactory >& _rxMSF,sal_uInt16 nImportFlags = IMPORT_ALL ); 125cdf0e10cSrcweir 126cdf0e10cSrcweir // XFilter 127cdf0e10cSrcweir virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& rDescriptor ) throw(RuntimeException); 128cdf0e10cSrcweir 129cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo 130cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); 131cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); 132cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); 133cdf0e10cSrcweir 134cdf0e10cSrcweir static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); 135cdf0e10cSrcweir static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException ); 136cdf0e10cSrcweir static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL 137cdf0e10cSrcweir create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); 138cdf0e10cSrcweir getORB()139cdf0e10cSrcweir inline Reference< XMultiServiceFactory > getORB() { return SvXMLImport::getServiceFactory(); } getReportDefinition() const140cdf0e10cSrcweir inline Reference<XReportDefinition> getReportDefinition() const { return m_xReportDefinition; } 141cdf0e10cSrcweir /** return the SdrModel of the real model 142cdf0e10cSrcweir * 143cdf0e10cSrcweir * \return 144cdf0e10cSrcweir */ getSdrModel() const145cdf0e10cSrcweir ::boost::shared_ptr<rptui::OReportModel> getSdrModel() const { return m_pReportModel; } 146cdf0e10cSrcweir void FinishStyles(); 147cdf0e10cSrcweir 148cdf0e10cSrcweir virtual void SAL_CALL startDocument(void) 149cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); 150cdf0e10cSrcweir virtual void SAL_CALL endDocument(void) 151cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); 152cdf0e10cSrcweir 153cdf0e10cSrcweir const SvXMLTokenMap& GetDocElemTokenMap() const; 154cdf0e10cSrcweir const SvXMLTokenMap& GetReportElemTokenMap() const; 155cdf0e10cSrcweir const SvXMLTokenMap& GetGroupElemTokenMap() const; 156cdf0e10cSrcweir const SvXMLTokenMap& GetSectionElemTokenMap() const; 157cdf0e10cSrcweir const SvXMLTokenMap& GetComponentElemTokenMap() const; 158cdf0e10cSrcweir const SvXMLTokenMap& GetReportElementElemTokenMap() const; 159cdf0e10cSrcweir const SvXMLTokenMap& GetControlElemTokenMap() const; 160cdf0e10cSrcweir const SvXMLTokenMap& GetControlPropertyElemTokenMap() const; 161cdf0e10cSrcweir const SvXMLTokenMap& GetFunctionElemTokenMap() const; 162cdf0e10cSrcweir const SvXMLTokenMap& GetFormatElemTokenMap() const; 163cdf0e10cSrcweir const SvXMLTokenMap& GetSubDocumentElemTokenMap() const; 164cdf0e10cSrcweir const SvXMLTokenMap& GetColumnTokenMap() const; 165cdf0e10cSrcweir const SvXMLTokenMap& GetCellElemTokenMap() const; 166cdf0e10cSrcweir GetCellStylesPropertySetMapper() const167cdf0e10cSrcweir inline UniReference < XMLPropertySetMapper > GetCellStylesPropertySetMapper() const { return m_xCellStylesPropertySetMapper; } GetColumnStylesPropertySetMapper() const168cdf0e10cSrcweir inline UniReference < XMLPropertySetMapper > GetColumnStylesPropertySetMapper() const { return m_xColumnStylesPropertySetMapper; } GetRowStylesPropertySetMapper() const169cdf0e10cSrcweir inline UniReference < XMLPropertySetMapper > GetRowStylesPropertySetMapper() const { return m_xRowStylesPropertySetMapper; } GetTableStylesPropertySetMapper() const170cdf0e10cSrcweir inline UniReference < XMLPropertySetMapper > GetTableStylesPropertySetMapper() const { return m_xTableStylesPropertySetMapper; } 171cdf0e10cSrcweir static ::rtl::OUString convertFormula(const ::rtl::OUString& _sFormula); 172cdf0e10cSrcweir /** inserts a new function 173cdf0e10cSrcweir * 174cdf0e10cSrcweir * \param _xFunction 175cdf0e10cSrcweir */ 176cdf0e10cSrcweir void insertFunction(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunction > & _xFunction); 177cdf0e10cSrcweir void removeFunction(const ::rtl::OUString& _sFunctionName); getFunctions() const178cdf0e10cSrcweir inline const TGroupFunctionMap& getFunctions() const { return m_aFunctions; } 179cdf0e10cSrcweir 180cdf0e10cSrcweir virtual SvXMLImport& getGlobalContext(); 181cdf0e10cSrcweir 182cdf0e10cSrcweir virtual void enterEventContext(); 183cdf0e10cSrcweir virtual void leaveEventContext(); 184cdf0e10cSrcweir 185cdf0e10cSrcweir sal_Bool isOldFormat() const; 186cdf0e10cSrcweir }; 187cdf0e10cSrcweir 188cdf0e10cSrcweir /** Imports only settings 189cdf0e10cSrcweir * \ingroup reportdesign_source_filter_xml 190cdf0e10cSrcweir * 191cdf0e10cSrcweir */ 192cdf0e10cSrcweir class ORptImportHelper 193cdf0e10cSrcweir { 194cdf0e10cSrcweir public: 195cdf0e10cSrcweir static ::rtl::OUString getImplementationName_Static( ) throw (::com::sun::star::uno::RuntimeException); 196cdf0e10cSrcweir static Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw(::com::sun::star::uno::RuntimeException); 197cdf0e10cSrcweir static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL 198cdf0e10cSrcweir create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); 199cdf0e10cSrcweir }; 200cdf0e10cSrcweir 201cdf0e10cSrcweir /** Imports only content 202cdf0e10cSrcweir * \ingroup reportdesign_source_filter_xml 203cdf0e10cSrcweir * 204cdf0e10cSrcweir */ 205cdf0e10cSrcweir class ORptContentImportHelper 206cdf0e10cSrcweir { 207cdf0e10cSrcweir public: 208cdf0e10cSrcweir static ::rtl::OUString getImplementationName_Static( ) throw (::com::sun::star::uno::RuntimeException); 209cdf0e10cSrcweir static Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw(::com::sun::star::uno::RuntimeException); 210cdf0e10cSrcweir static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL 211cdf0e10cSrcweir create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); 212cdf0e10cSrcweir }; 213cdf0e10cSrcweir 214cdf0e10cSrcweir /** Imports only styles 215cdf0e10cSrcweir * \ingroup reportdesign_source_filter_xml 216cdf0e10cSrcweir * 217cdf0e10cSrcweir */ 218cdf0e10cSrcweir class ORptStylesImportHelper 219cdf0e10cSrcweir { 220cdf0e10cSrcweir public: 221cdf0e10cSrcweir static ::rtl::OUString getImplementationName_Static( ) throw (::com::sun::star::uno::RuntimeException); 222cdf0e10cSrcweir static Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw(::com::sun::star::uno::RuntimeException); 223cdf0e10cSrcweir static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL 224cdf0e10cSrcweir create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); 225cdf0e10cSrcweir }; 226cdf0e10cSrcweir 227cdf0e10cSrcweir /** Imports only meta data 228cdf0e10cSrcweir * \ingroup reportdesign_source_filter_xml 229cdf0e10cSrcweir * 230cdf0e10cSrcweir */ 231cdf0e10cSrcweir class ORptMetaImportHelper 232cdf0e10cSrcweir { 233cdf0e10cSrcweir public: 234cdf0e10cSrcweir static ::rtl::OUString getImplementationName_Static( ) throw (::com::sun::star::uno::RuntimeException); 235cdf0e10cSrcweir static Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw(::com::sun::star::uno::RuntimeException); 236cdf0e10cSrcweir static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL 237cdf0e10cSrcweir create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); 238cdf0e10cSrcweir }; 239cdf0e10cSrcweir 240cdf0e10cSrcweir // ----------------------------------------------------------------------------- 241cdf0e10cSrcweir } // rptxml 242cdf0e10cSrcweir // ----------------------------------------------------------------------------- 243cdf0e10cSrcweir #endif // RPT_XMLFILTER_HXX 244