1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef RPT_EXPORTDOCUMENTHANDLER_HXX_INCLUDED
24 #define RPT_EXPORTDOCUMENTHANDLER_HXX_INCLUDED
25 
26 #include "sal/config.h"
27 #include "com/sun/star/uno/XComponentContext.hpp"
28 #include <cppuhelper/implbase3.hxx>
29 #include "com/sun/star/xml/sax/XDocumentHandler.hpp"
30 #include <com/sun/star/lang/XInitialization.hpp>
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <com/sun/star/lang/XTypeProvider.hpp>
33 #include <com/sun/star/chart2/XChartDocument.hpp>
34 #include "com/sun/star/chart2/data/XDatabaseDataProvider.hpp"
35 #include <comphelper/uno3.hxx>
36 
37 namespace rptxml
38 {
39 typedef ::cppu::WeakAggImplHelper3< ::com::sun::star::xml::sax::XDocumentHandler
40                                 ,   ::com::sun::star::lang::XInitialization
41                                 ,   ::com::sun::star::lang::XServiceInfo>   ExportDocumentHandler_BASE;
42 
43 class ExportDocumentHandler : public ExportDocumentHandler_BASE
44 {
45 public:
46     // XServiceInfo - static versions
47 	static ::rtl::OUString getImplementationName_Static(  ) throw(::com::sun::star::uno::RuntimeException);
48 	static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static(  ) throw(::com::sun::star::uno::RuntimeException);
49 	static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
50 					create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
51 public:
52     explicit ExportDocumentHandler(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & context);
53 
54 private:
55     // XServiceInfo
56 	virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException);
57 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
58 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException);
59 
60     DECLARE_XINTERFACE( )
61     DECLARE_XTYPEPROVIDER( )
62 
63     // ::com::sun::star::xml::sax::XDocumentHandler:
64     virtual void SAL_CALL startDocument() throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
65     virtual void SAL_CALL endDocument() throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
66     virtual void SAL_CALL startElement(const ::rtl::OUString & aName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttribs) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
67     virtual void SAL_CALL endElement(const ::rtl::OUString & aName) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
68     virtual void SAL_CALL characters(const ::rtl::OUString & aChars) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
69     virtual void SAL_CALL ignorableWhitespace(const ::rtl::OUString & aWhitespaces) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
70     virtual void SAL_CALL processingInstruction(const ::rtl::OUString & aTarget, const ::rtl::OUString & aData) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
71     virtual void SAL_CALL setDocumentLocator(const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > & xLocator) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::xml::sax::SAXException);
72 
73     virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
74 
75     void exportTableRows();
76 private:
77     ExportDocumentHandler(ExportDocumentHandler &); // not defined
78     void operator =(ExportDocumentHandler &); // not defined
79 
80     virtual ~ExportDocumentHandler();
81 
82     ::osl::Mutex                                                                        m_aMutex;
83     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >        m_xContext;
84     ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler >    m_xDelegatee;
85     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >             m_xProxy;
86     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XTypeProvider >           m_xTypeProvider;
87     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo >            m_xServiceInfo;
88     ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >        m_xModel;
89     ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDatabaseDataProvider >   m_xDatabaseDataProvider;
90     ::com::sun::star::uno::Sequence< ::rtl::OUString >                                  m_aColumns;
91     sal_Int32                                                                           m_nCurrentCellIndex;
92     sal_Int32                                                                           m_nColumnCount;
93     bool m_bTableRowsStarted;
94     bool m_bFirstRowExported;
95 	bool m_bExportChar;
96     bool m_bCountColumnHeader;
97 };
98 // -----------------------------------------------------------------------------
99 } // namespace rptxml
100 // -----------------------------------------------------------------------------
101 #endif // RPT_EXPORTDOCUMENTHANDLER_HXX_INCLUDED
102