LibreOffice Module dbaccess (master) 1
xmlExport.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
20#pragma once
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/beans/XPropertySet.hpp>
26#include <com/sun/star/lang/XComponent.hpp>
27#include <com/sun/star/io/XActiveDataSource.hpp>
28
29#include <optional>
30#include <utility>
31#include <xmloff/maptype.hxx>
32#include <xmloff/txtprmap.hxx>
33#include <xmloff/xmlexp.hxx>
34#include <xmloff/xmlexppr.hxx>
35#include <dsntypes.hxx>
37#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
38
39#include <memory>
40
41
42namespace dbaxml {
43
44using namespace ::xmloff::token;
45using namespace ::com::sun::star::uno;
46using namespace ::com::sun::star::container;
47using namespace ::com::sun::star::lang;
48using namespace ::com::sun::star::beans;
49using namespace ::com::sun::star::document;
50using namespace ::com::sun::star::sdbcx;
51using namespace ::com::sun::star::text;
52using namespace ::com::sun::star::io;
53using namespace ::com::sun::star::xml::sax;
54
55
56class ODBExport : public SvXMLExport
57{
58 typedef std::map< ::xmloff::token::XMLTokenEnum, OUString> TSettingsMap;
59
60 typedef std::pair< OUString ,OUString> TStringPair;
62 {
63 OUString sText;
64 OUString sField;
65 OUString sDecimal;
66 OUString sThousand;
67 bool bUsed;
68
69 TDelimiter() : bUsed( false ) { }
70 };
71 typedef std::map< Reference<XPropertySet> ,OUString > TPropertyStyleMap;
72 typedef std::map< Reference<XPropertySet> ,Reference<XPropertySet> > TTableColumnMap;
73
75 {
76 OUString Name;
77 css::uno::Type Type;
78 css::uno::Any Value;
79
80 TypedPropertyValue( OUString _name, const css::uno::Type& _type, css::uno::Any _value )
81 :Name(std::move( _name ))
82 ,Type( _type )
83 ,Value(std::move( _value ))
84 {
85 }
86 };
87
88 std::optional< TStringPair > m_oAutoIncrement;
89 std::unique_ptr< TDelimiter > m_aDelimiter;
90 std::vector< TypedPropertyValue > m_aDataSourceSettings;
91 std::vector< XMLPropertyState > m_aCurrentPropertyStates;
96 OUString m_sCharSet;
101
105
106 Reference<XPropertySet> m_xDataSource;
109
110 void exportDataSource();
112 void exportDriverSettings(const TSettingsMap& _aSettings);
114 void exportLogin();
115 void exportSequence(const Sequence< OUString>& _aValue
116 ,::xmloff::token::XMLTokenEnum _eTokenFilter
117 ,::xmloff::token::XMLTokenEnum _eTokenType);
118 void exportDelimiter();
119 void exportAutoIncrement();
120 void exportCharSet();
121 template< typename T > void exportDataSourceSettingsSequence(
122 std::vector< TypedPropertyValue >::iterator const & in);
124 void exportForms();
125 void exportReports();
126 void exportQueries(bool _bExportContext);
127 void exportTables(bool _bExportContext);
128 void exportStyleName(XPropertySet* _xProp,comphelper::AttributeList& _rAtt);
129 void exportStyleName(const ::xmloff::token::XMLTokenEnum _eToken,const Reference<XPropertySet>& _xProp,comphelper::AttributeList& _rAtt,TPropertyStyleMap& _rMap);
130 void exportCollection(const Reference< XNameAccess >& _xCollection
131 ,enum ::xmloff::token::XMLTokenEnum _eComponents
132 ,enum ::xmloff::token::XMLTokenEnum _eSubComponents
133 ,bool _bExportContext
134 ,const ::comphelper::mem_fun1_t<ODBExport,XPropertySet* >& _aMemFunc
135 );
136 void exportComponent(XPropertySet* _xProp);
137 void exportQuery(XPropertySet* _xProp);
138 void exportTable(XPropertySet* _xProp);
139 void exportFilter(XPropertySet* _xProp
140 ,const OUString& _sProp
141 ,enum ::xmloff::token::XMLTokenEnum _eStatementType);
142 void exportTableName(XPropertySet* _xProp,bool _bUpdate);
143 void exportAutoStyle(XPropertySet* _xProp);
144 void exportColumns(const Reference<XColumnsSupplier>& _xColSup);
146
147 static OUString implConvertAny(const Any& _rValue);
148
150
151 ODBExport() = delete;
152protected:
153
154 virtual void ExportAutoStyles_() override;
155 virtual void ExportContent_() override;
156 virtual void ExportMasterStyles_() override;
157 virtual void ExportFontDecls_() override;
158 virtual SvXMLAutoStylePoolP* CreateAutoStylePool() override;
159
160 virtual void GetViewSettings(css::uno::Sequence<css::beans::PropertyValue>& aProps) override;
161 virtual void GetConfigurationSettings(css::uno::Sequence<css::beans::PropertyValue>& aProps) override;
162
163 virtual ~ODBExport() override {};
164public:
165
166 ODBExport(const Reference< XComponentContext >& _rxContext, OUString const & implementationName, SvXMLExportFlags nExportFlag = SvXMLExportFlags::CONTENT | SvXMLExportFlags::AUTOSTYLES | SvXMLExportFlags::PRETTY | SvXMLExportFlags::FONTDECLS | SvXMLExportFlags::SCRIPTS );
167
170
171 // XExporter
172 virtual void SAL_CALL setSourceDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
173
174 const Reference<XPropertySet>& getDataSource() const { return m_xDataSource; }
175};
176
177} // dbaxml
178
179/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::map< Reference< XPropertySet >,Reference< XPropertySet > > TTableColumnMap
Definition: xmlExport.hxx:72
virtual void GetViewSettings(css::uno::Sequence< css::beans::PropertyValue > &aProps) override
Definition: xmlExport.cxx:1184
void exportDataSource()
Definition: xmlExport.cxx:209
std::map< ::xmloff::token::XMLTokenEnum, OUString > TSettingsMap
Definition: xmlExport.hxx:58
Reference< XPropertySet > m_xDataSource
Definition: xmlExport.hxx:106
void exportDriverSettings(const TSettingsMap &_aSettings)
Definition: xmlExport.cxx:472
rtl::Reference< SvXMLExportPropertyMapper > m_xCellExportHelper
Definition: xmlExport.hxx:99
void exportTable(XPropertySet *_xProp)
Definition: xmlExport.cxx:820
std::map< Reference< XPropertySet >,OUString > TPropertyStyleMap
Definition: xmlExport.hxx:71
rtl::Reference< XMLPropertySetMapper > const & GetTableStylesPropertySetMapper() const
Definition: xmlExport.cxx:1282
rtl::Reference< SvXMLExportPropertyMapper > m_xRowExportHelper
Definition: xmlExport.hxx:100
rtl::Reference< XMLPropertySetMapper > m_xTableStylesPropertySetMapper
Definition: xmlExport.hxx:102
void exportQuery(XPropertySet *_xProp)
Definition: xmlExport.cxx:796
rtl::Reference< SvXMLExportPropertyMapper > m_xColumnExportHelper
Definition: xmlExport.hxx:98
OUString m_sCharSet
Definition: xmlExport.hxx:96
virtual void ExportContent_() override
Definition: xmlExport.cxx:1156
virtual void SAL_CALL setSourceDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
Definition: xmlExport.cxx:1314
void exportDataSourceSettingsSequence(std::vector< TypedPropertyValue >::iterator const &in)
Definition: xmlExport.cxx:593
std::pair< OUString,OUString > TStringPair
Definition: xmlExport.hxx:60
void exportCollection(const Reference< XNameAccess > &_xCollection, enum ::xmloff::token::XMLTokenEnum _eComponents, enum ::xmloff::token::XMLTokenEnum _eSubComponents, bool _bExportContext, const ::comphelper::mem_fun1_t< ODBExport, XPropertySet * > &_aMemFunc)
Definition: xmlExport.cxx:746
virtual void ExportFontDecls_() override
Definition: xmlExport.cxx:1324
std::vector< TypedPropertyValue > m_aDataSourceSettings
Definition: xmlExport.hxx:90
::dbaccess::ODsnTypeCollection m_aTypeCollection
Definition: xmlExport.hxx:107
void exportTables(bool _bExportContext)
Definition: xmlExport.cxx:1044
void exportColumns(const Reference< XColumnsSupplier > &_xColSup)
Definition: xmlExport.cxx:898
void exportTableName(XPropertySet *_xProp, bool _bUpdate)
Definition: xmlExport.cxx:862
void exportComponent(XPropertySet *_xProp)
Definition: xmlExport.cxx:777
void exportFilter(XPropertySet *_xProp, const OUString &_sProp, enum ::xmloff::token::XMLTokenEnum _eStatementType)
Definition: xmlExport.cxx:883
void exportStyleName(XPropertySet *_xProp, comphelper::AttributeList &_rAtt)
Definition: xmlExport.cxx:843
rtl::Reference< SvXMLExportPropertyMapper > m_xExportHelper
Definition: xmlExport.hxx:97
void exportAutoIncrement()
Definition: xmlExport.cxx:700
std::unique_ptr< TDelimiter > m_aDelimiter
Definition: xmlExport.hxx:89
virtual SvXMLAutoStylePoolP * CreateAutoStylePool() override
Definition: xmlExport.cxx:1309
TPropertyStyleMap m_aCellAutoStyleNames
Definition: xmlExport.hxx:93
rtl::Reference< XMLPropertySetMapper > m_xCellStylesPropertySetMapper
Definition: xmlExport.hxx:104
void exportSequence(const Sequence< OUString > &_aValue,::xmloff::token::XMLTokenEnum _eTokenFilter,::xmloff::token::XMLTokenEnum _eTokenType)
Definition: xmlExport.cxx:710
void exportDataSourceSettings()
Definition: xmlExport.cxx:607
void exportStyleName(const ::xmloff::token::XMLTokenEnum _eToken, const Reference< XPropertySet > &_xProp, comphelper::AttributeList &_rAtt, TPropertyStyleMap &_rMap)
TPropertyStyleMap m_aAutoStyleNames
Definition: xmlExport.hxx:92
void exportQueries(bool _bExportContext)
Definition: xmlExport.cxx:1018
rtl::Reference< XMLPropertySetMapper > m_xColumnStylesPropertySetMapper
Definition: xmlExport.hxx:103
rtl::Reference< XMLPropertySetMapper > const & GetColumnStylesPropertySetMapper() const
Definition: xmlExport.cxx:1300
const Reference< XPropertySet > & getDataSource() const
Definition: xmlExport.hxx:174
void collectComponentStyles()
Definition: xmlExport.cxx:1331
void exportConnectionData()
Definition: xmlExport.cxx:493
virtual void ExportAutoStyles_() override
Definition: xmlExport.cxx:1170
std::optional< TStringPair > m_oAutoIncrement
Definition: xmlExport.hxx:88
virtual void ExportMasterStyles_() override
Definition: xmlExport.cxx:1165
TTableColumnMap m_aTableDummyColumns
Definition: xmlExport.hxx:95
std::vector< XMLPropertyState > m_aCurrentPropertyStates
Definition: xmlExport.hxx:91
void exportAutoStyle(XPropertySet *_xProp)
Definition: xmlExport.cxx:1062
static OUString implConvertAny(const Any &_rValue)
Definition: xmlExport.cxx:1250
void exportApplicationConnectionSettings(const TSettingsMap &_aSettings)
Definition: xmlExport.cxx:436
void exportDelimiter()
Definition: xmlExport.cxx:688
virtual ~ODBExport() override
Definition: xmlExport.hxx:163
TPropertyStyleMap m_aRowAutoStyleNames
Definition: xmlExport.hxx:94
virtual void GetConfigurationSettings(css::uno::Sequence< css::beans::PropertyValue > &aProps) override
Definition: xmlExport.cxx:1224
rtl::Reference< XMLPropertySetMapper > const & GetCellStylesPropertySetMapper() const
Definition: xmlExport.cxx:1291
Type
TypedPropertyValue(OUString _name, const css::uno::Type &_type, css::uno::Any _value)
Definition: xmlExport.hxx:80
SvXMLExportFlags