Branch data 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 : :
20 : : #ifndef DBA_XMLFILTER_HXX
21 : : #define DBA_XMLFILTER_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/document/XExporter.hpp>
27 : : #include <com/sun/star/lang/XInitialization.hpp>
28 : : #include <com/sun/star/lang/XServiceInfo.hpp>
29 : : #include <com/sun/star/beans/XPropertySet.hpp>
30 : : #include <com/sun/star/lang/XComponent.hpp>
31 : : #include <cppuhelper/implbase1.hxx>
32 : : #include <cppuhelper/implbase5.hxx>
33 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34 : : #include <com/sun/star/io/XActiveDataSource.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 "apitools.hxx"
41 : : #include <comphelper/stl_types.hxx>
42 : :
43 : : #include <memory>
44 : :
45 : : namespace dbaxml
46 : : {
47 : : using namespace ::xmloff::token;
48 : : using namespace ::com::sun::star::uno;
49 : : using namespace ::com::sun::star::container;
50 : : using namespace ::com::sun::star::lang;
51 : : using namespace ::com::sun::star::beans;
52 : : using namespace ::com::sun::star::document;
53 : : using namespace ::com::sun::star::text;
54 : : using namespace ::com::sun::star::io;
55 : : using namespace ::com::sun::star::xml::sax;
56 : :
57 : : // -------------
58 : : // - ODBFilter -
59 : : // -------------
60 : : class ODBFilter : public SvXMLImport
61 : : {
62 : : public:
63 : : DECLARE_STL_USTRINGACCESS_MAP(Sequence<PropertyValue>,TPropertyNameMap);
64 : : typedef ::std::vector< ::com::sun::star::beans::PropertyValue> TInfoSequence;
65 : : private:
66 : : TPropertyNameMap m_aQuerySettings;
67 : : TPropertyNameMap m_aTablesSettings;
68 : : TInfoSequence m_aInfoSequence;
69 : : Reference< XComponent > m_xSrcDoc;
70 : :
71 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
72 : : mutable ::std::auto_ptr<SvXMLTokenMap> m_pDocElemTokenMap;
73 : : mutable ::std::auto_ptr<SvXMLTokenMap> m_pDatabaseElemTokenMap;
74 : : mutable ::std::auto_ptr<SvXMLTokenMap> m_pDataSourceElemTokenMap;
75 : : mutable ::std::auto_ptr<SvXMLTokenMap> m_pLoginElemTokenMap;
76 : : mutable ::std::auto_ptr<SvXMLTokenMap> m_pDatabaseDescriptionElemTokenMap;
77 : : mutable ::std::auto_ptr<SvXMLTokenMap> m_pDataSourceInfoElemTokenMap;
78 : : mutable ::std::auto_ptr<SvXMLTokenMap> m_pDocumentsElemTokenMap;
79 : : mutable ::std::auto_ptr<SvXMLTokenMap> m_pComponentElemTokenMap;
80 : : mutable ::std::auto_ptr<SvXMLTokenMap> m_pQueryElemTokenMap;
81 : : mutable ::std::auto_ptr<SvXMLTokenMap> m_pColumnElemTokenMap;
82 : : SAL_WNODEPRECATED_DECLARATIONS_POP
83 : :
84 : : mutable UniReference < XMLPropertySetMapper > m_xTableStylesPropertySetMapper;
85 : : mutable UniReference < XMLPropertySetMapper > m_xColumnStylesPropertySetMapper;
86 : : mutable UniReference < XMLPropertySetMapper > m_xCellStylesPropertySetMapper;
87 : : Reference<XPropertySet> m_xDataSource;
88 : : sal_Int32 m_nPreviewMode;
89 : : bool m_bNewFormat;
90 : :
91 : : sal_Bool implImport( const Sequence< PropertyValue >& rDescriptor ) throw (RuntimeException);
92 : :
93 : :
94 : : /** fills the map with the Properties
95 : : @param _rValue
96 : : The Any where the sequence resists in.
97 : : @param _rMap
98 : : The map to fill.
99 : : */
100 : : void fillPropertyMap(const Any& _rValue,TPropertyNameMap& _rMap);
101 : :
102 : : SvXMLImportContext* CreateStylesContext(sal_uInt16 nPrefix,const ::rtl::OUString& rLocalName,
103 : : const Reference< XAttributeList>& xAttrList, sal_Bool bIsAutoStyle );
104 : : SvXMLImportContext* CreateScriptContext( const ::rtl::OUString& rLocalName );
105 : :
106 : : protected:
107 : : // SvXMLImport
108 : : virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
109 : : const ::rtl::OUString& rLocalName,
110 : : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
111 : :
112 : : virtual ~ODBFilter() throw();
113 : : public:
114 : :
115 : : ODBFilter( const Reference< XMultiServiceFactory >& _rxMSF );
116 : :
117 : : // XFilter
118 : : virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& rDescriptor ) throw(RuntimeException);
119 : :
120 : : // XServiceInfo
121 : : DECLARE_SERVICE_INFO_STATIC( );
122 : :
123 : : // helper class
124 : : virtual void SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps);
125 : : virtual void SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aConfigProps);
126 : :
127 : 38 : inline Reference< XMultiServiceFactory > getORB() { return getServiceFactory(); }
128 : 124 : inline Reference<XPropertySet> getDataSource() const { return m_xDataSource; }
129 : :
130 : 0 : inline const TPropertyNameMap& getQuerySettings() const { return m_aQuerySettings;}
131 : : inline const TPropertyNameMap& getTableSettings() const { return m_aTablesSettings;}
132 : :
133 : : const SvXMLTokenMap& GetDocElemTokenMap() const;
134 : : const SvXMLTokenMap& GetDatabaseElemTokenMap() const;
135 : : const SvXMLTokenMap& GetDataSourceElemTokenMap() const;
136 : : const SvXMLTokenMap& GetLoginElemTokenMap() const;
137 : : const SvXMLTokenMap& GetDatabaseDescriptionElemTokenMap() const;
138 : : const SvXMLTokenMap& GetDataSourceInfoElemTokenMap() const;
139 : : const SvXMLTokenMap& GetDocumentsElemTokenMap() const;
140 : : const SvXMLTokenMap& GetComponentElemTokenMap() const;
141 : : const SvXMLTokenMap& GetQueryElemTokenMap() const;
142 : : const SvXMLTokenMap& GetColumnElemTokenMap() const;
143 : :
144 : : UniReference < XMLPropertySetMapper > GetTableStylesPropertySetMapper() const;
145 : : UniReference < XMLPropertySetMapper > GetColumnStylesPropertySetMapper() const;
146 : : UniReference < XMLPropertySetMapper > GetCellStylesPropertySetMapper() const;
147 : :
148 : : /** add a Info to the sequence which will be appened to the data source
149 : : @param _rInfo The property to append.
150 : : */
151 : 96 : inline void addInfo(const ::com::sun::star::beans::PropertyValue& _rInfo)
152 : : {
153 : 96 : m_aInfoSequence.push_back(_rInfo);
154 : 96 : }
155 : :
156 : : void setPropertyInfo();
157 : :
158 : : const ::std::map< sal_uInt16,com::sun::star::beans::Property>& GetDataSourceInfoDefaulValueMap() const;
159 : :
160 : 54 : inline bool isNewFormat() const { return m_bNewFormat; }
161 : 14 : inline void setNewFormat(bool _bNewFormat) { m_bNewFormat = _bNewFormat; }
162 : : };
163 : :
164 : : // -----------------------------------------------------------------------------
165 : : } // dbaxml
166 : : // -----------------------------------------------------------------------------
167 : : #endif // DBA_XMLFILTER_HXX
168 : :
169 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|