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 : #include "xmlExport.hxx"
21 : #include "xmlAutoStyle.hxx"
22 : #include "xmlservices.hxx"
23 : #include "flt_reghelper.hxx"
24 : #include <sax/tools/converter.hxx>
25 : #include <xmloff/ProgressBarHelper.hxx>
26 : #include <xmloff/xmltoken.hxx>
27 : #include <xmloff/txtimp.hxx>
28 : #include <xmloff/xmlnmspe.hxx>
29 : #include <xmloff/nmspmap.hxx>
30 : #include <comphelper/processfactory.hxx>
31 : #include <comphelper/sequence.hxx>
32 : #include <comphelper/string.hxx>
33 : #include <comphelper/types.hxx>
34 : #include "xmlstrings.hrc"
35 : #include "xmlEnums.hxx"
36 : #include <com/sun/star/beans/XPropertyState.hpp>
37 : #include <com/sun/star/beans/PropertyAttribute.hpp>
38 : #include <com/sun/star/sdb/XFormDocumentsSupplier.hpp>
39 : #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
40 : #include <com/sun/star/sdb/XReportDocumentsSupplier.hpp>
41 : #include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp>
42 : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
43 : #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
44 :
45 : #include <com/sun/star/awt/TextAlign.hpp>
46 : #include <xmloff/xmluconv.hxx>
47 : #include "xmlHelper.hxx"
48 : #include <com/sun/star/awt/FontDescriptor.hpp>
49 : #include <svl/filenotation.hxx>
50 : #include <unotools/pathoptions.hxx>
51 : #include <tools/diagnose_ex.h>
52 : #include <connectivity/DriversConfig.hxx>
53 : #include <connectivity/dbtools.hxx>
54 :
55 : #include <boost/optional.hpp>
56 : #include <boost/scoped_ptr.hpp>
57 :
58 : namespace dbaxml
59 : {
60 : using namespace comphelper;
61 : using namespace ::com::sun::star::sdb;
62 : using namespace ::com::sun::star::sdbcx;
63 : using namespace ::com::sun::star::util;
64 : using namespace ::com::sun::star;
65 :
66 : class ODBExportHelper
67 : {
68 : public:
69 : static OUString SAL_CALL getImplementationName_Static( ) throw (RuntimeException);
70 : static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static( ) throw(RuntimeException);
71 : static Reference< XInterface > SAL_CALL Create(const Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
72 : };
73 : class ODBFullExportHelper
74 : {
75 : public:
76 : static OUString SAL_CALL getImplementationName_Static( ) throw (RuntimeException);
77 : static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static( ) throw(RuntimeException);
78 : static Reference< XInterface > SAL_CALL Create(const Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
79 : };
80 : }
81 :
82 23 : extern "C" void SAL_CALL createRegistryInfo_ODBFilterExport( )
83 : {
84 23 : static ::dbaxml::OMultiInstanceAutoRegistration< ::dbaxml::ODBExport > aAutoRegistration;
85 23 : }
86 :
87 23 : extern "C" void SAL_CALL createRegistryInfo_OSettingsExport( )
88 :
89 : {
90 23 : static ::dbaxml::OMultiInstanceAutoRegistration< ::dbaxml::ODBExportHelper > aAutoRegistration;
91 23 : }
92 :
93 23 : extern "C" void SAL_CALL createRegistryInfo_OFullExport( )
94 : {
95 23 : static ::dbaxml::OMultiInstanceAutoRegistration< ::dbaxml::ODBFullExportHelper > aAutoRegistration;
96 23 : }
97 :
98 : namespace dbaxml
99 : {
100 : using namespace comphelper;
101 : using namespace ::com::sun::star::sdb;
102 : using namespace ::com::sun::star::sdbcx;
103 : using namespace ::com::sun::star::util;
104 :
105 97 : Reference< XInterface > SAL_CALL ODBExportHelper::Create(const Reference< XMultiServiceFactory >& _rxORB)
106 : {
107 97 : return static_cast< XServiceInfo* >(new ODBExport(comphelper::getComponentContext(_rxORB), getImplementationName_Static(), SvXMLExportFlags::SETTINGS | SvXMLExportFlags::PRETTY ));
108 : }
109 :
110 143 : OUString SAL_CALL ODBExportHelper::getImplementationName_Static( ) throw (RuntimeException)
111 : {
112 143 : return OUString("com.sun.star.comp.sdb.XMLSettingsExporter");
113 : }
114 :
115 23 : Sequence< OUString > SAL_CALL ODBExportHelper::getSupportedServiceNames_Static( ) throw(RuntimeException)
116 : {
117 23 : Sequence< OUString > aSupported(1);
118 23 : aSupported[0] = "com.sun.star.document.ExportFilter";
119 23 : return aSupported;
120 : }
121 :
122 1 : Reference< XInterface > SAL_CALL ODBFullExportHelper::Create(const Reference< XMultiServiceFactory >& _rxORB)
123 : {
124 1 : return static_cast< XServiceInfo* >(new ODBExport(comphelper::getComponentContext(_rxORB), getImplementationName_Static(), SvXMLExportFlags::ALL));
125 : }
126 47 : OUString SAL_CALL ODBFullExportHelper::getImplementationName_Static( ) throw (RuntimeException)
127 : {
128 47 : return OUString("com.sun.star.comp.sdb.XMLFullExporter");
129 : }
130 23 : Sequence< OUString > SAL_CALL ODBFullExportHelper::getSupportedServiceNames_Static( ) throw(RuntimeException)
131 : {
132 23 : Sequence< OUString > aSupported(1);
133 23 : aSupported[0] = "com.sun.star.document.ExportFilter";
134 23 : return aSupported;
135 : }
136 :
137 0 : OUString lcl_implGetPropertyXMLType(const Type& _rType)
138 : {
139 : // possible types we can write (either because we recognize them directly or because we convert _rValue
140 : // into one of these types)
141 :
142 : // handle the type description
143 0 : switch (_rType.getTypeClass())
144 : {
145 : case TypeClass_STRING:
146 0 : return OUString("string");
147 : case TypeClass_DOUBLE:
148 0 : return OUString("double");
149 : case TypeClass_BOOLEAN:
150 0 : return OUString("boolean");
151 : case TypeClass_BYTE:
152 : case TypeClass_SHORT:
153 0 : return OUString("short");
154 : case TypeClass_LONG:
155 0 : return OUString("int");
156 : case TypeClass_HYPER:
157 0 : return OUString("long");
158 : case TypeClass_ENUM:
159 0 : return OUString("int");
160 :
161 : default:
162 : OSL_FAIL( "lcl_implGetPropertyXMLType: unsupported value type!" );
163 0 : return OUString("double");
164 : }
165 : }
166 :
167 1170 : class OSpecialHandleXMLExportPropertyMapper : public SvXMLExportPropertyMapper
168 : {
169 : public:
170 585 : OSpecialHandleXMLExportPropertyMapper(const rtl::Reference< XMLPropertySetMapper >& rMapper) : SvXMLExportPropertyMapper(rMapper )
171 : {
172 585 : }
173 : /** this method is called for every item that has the
174 : MID_FLAG_SPECIAL_ITEM_EXPORT flag set */
175 0 : virtual void handleSpecialItem(
176 : SvXMLAttributeList& /*rAttrList*/,
177 : const XMLPropertyState& /*rProperty*/,
178 : const SvXMLUnitConverter& /*rUnitConverter*/,
179 : const SvXMLNamespaceMap& /*rNamespaceMap*/,
180 : const ::std::vector< XMLPropertyState > * /*pProperties*/ ,
181 : sal_uInt32 /*nIdx*/ ) const SAL_OVERRIDE
182 : {
183 : // nothing to do here
184 0 : }
185 : };
186 195 : ODBExport::ODBExport(const Reference< XComponentContext >& _rxContext, OUString const & implementationName, SvXMLExportFlags nExportFlag)
187 : : SvXMLExport( util::MeasureUnit::MM_10TH, _rxContext, implementationName, XML_DATABASE,
188 390 : SvXMLExportFlags::OASIS | nExportFlag)
189 : ,m_aTypeCollection(_rxContext)
190 390 : ,m_bAllreadyFilled(false)
191 : {
192 195 : GetMM100UnitConverter().SetCoreMeasureUnit(util::MeasureUnit::MM_10TH);
193 195 : GetMM100UnitConverter().SetXMLMeasureUnit(util::MeasureUnit::CM);
194 :
195 195 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_OFFICE), GetXMLToken(XML_N_OFFICE), XML_NAMESPACE_OFFICE );
196 195 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_OOO), GetXMLToken(XML_N_OOO), XML_NAMESPACE_OOO );
197 195 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_SVG), GetXMLToken(XML_N_SVG), XML_NAMESPACE_SVG );
198 :
199 195 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_DB), GetXMLToken(XML_N_DB_OASIS), XML_NAMESPACE_DB );
200 :
201 195 : if( nExportFlag & (SvXMLExportFlags::STYLES|SvXMLExportFlags::MASTERSTYLES|SvXMLExportFlags::AUTOSTYLES|SvXMLExportFlags::FONTDECLS) )
202 98 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_FO), GetXMLToken(XML_N_FO_COMPAT), XML_NAMESPACE_FO );
203 :
204 195 : if( nExportFlag & (SvXMLExportFlags::META|SvXMLExportFlags::STYLES|SvXMLExportFlags::MASTERSTYLES|SvXMLExportFlags::AUTOSTYLES|SvXMLExportFlags::CONTENT|SvXMLExportFlags::SCRIPTS|SvXMLExportFlags::SETTINGS) )
205 : {
206 195 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_XLINK), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK );
207 : }
208 195 : if( nExportFlag & SvXMLExportFlags::SETTINGS )
209 : {
210 98 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_CONFIG), GetXMLToken(XML_N_CONFIG), XML_NAMESPACE_CONFIG );
211 : }
212 :
213 195 : if( nExportFlag & (SvXMLExportFlags::STYLES|SvXMLExportFlags::MASTERSTYLES|SvXMLExportFlags::AUTOSTYLES|SvXMLExportFlags::CONTENT|SvXMLExportFlags::FONTDECLS) )
214 : {
215 98 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_STYLE), GetXMLToken(XML_N_STYLE), XML_NAMESPACE_STYLE );
216 : }
217 :
218 195 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_TABLE), GetXMLToken(XML_N_TABLE), XML_NAMESPACE_TABLE );
219 195 : _GetNamespaceMap().Add( GetXMLToken(XML_NP_NUMBER), GetXMLToken(XML_N_NUMBER), XML_NAMESPACE_NUMBER );
220 :
221 195 : m_xExportHelper = new SvXMLExportPropertyMapper(GetTableStylesPropertySetMapper());
222 195 : m_xColumnExportHelper = new OSpecialHandleXMLExportPropertyMapper(GetColumnStylesPropertySetMapper());
223 :
224 195 : m_xCellExportHelper = new OSpecialHandleXMLExportPropertyMapper(GetCellStylesPropertySetMapper());
225 195 : m_xRowExportHelper = new OSpecialHandleXMLExportPropertyMapper(OXMLHelper::GetRowStylesPropertySetMapper( true));
226 :
227 : GetAutoStylePool()->AddFamily(
228 : XML_STYLE_FAMILY_TABLE_TABLE,
229 : OUString(XML_STYLE_FAMILY_TABLE_TABLE_STYLES_NAME ),
230 : m_xExportHelper.get(),
231 195 : OUString(XML_STYLE_FAMILY_TABLE_TABLE_STYLES_PREFIX ));
232 :
233 : GetAutoStylePool()->AddFamily(
234 : XML_STYLE_FAMILY_TABLE_COLUMN,
235 : OUString(XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_NAME ),
236 : m_xColumnExportHelper.get(),
237 195 : OUString(XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_PREFIX ));
238 :
239 : GetAutoStylePool()->AddFamily(
240 : XML_STYLE_FAMILY_TABLE_CELL,
241 : OUString(XML_STYLE_FAMILY_TABLE_CELL_STYLES_NAME ),
242 : m_xCellExportHelper.get(),
243 195 : OUString(XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX ));
244 :
245 : GetAutoStylePool()->AddFamily(
246 : XML_STYLE_FAMILY_TABLE_ROW,
247 : OUString(XML_STYLE_FAMILY_TABLE_ROW_STYLES_NAME ),
248 : m_xRowExportHelper.get(),
249 195 : OUString(XML_STYLE_FAMILY_TABLE_ROW_STYLES_PREFIX ));
250 195 : }
251 :
252 143 : OUString ODBExport::getImplementationName_Static()
253 : throw (css::uno::RuntimeException)
254 : {
255 143 : return OUString("com.sun.star.comp.sdb.DBExportFilter");
256 : }
257 :
258 23 : css::uno::Sequence<OUString> ODBExport::getSupportedServiceNames_Static()
259 : throw (css::uno::RuntimeException)
260 : {
261 23 : css::uno::Sequence<OUString> s(1);
262 23 : s[0] = "com.sun.star.document.ExportFilter";
263 23 : return s;
264 : }
265 :
266 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
267 97 : SAL_CALL ODBExport::Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB)
268 : {
269 194 : return static_cast< XServiceInfo* >(new ODBExport( comphelper::getComponentContext(_rxORB), getImplementationName_Static()));
270 : }
271 :
272 96 : void ODBExport::exportDataSource()
273 : {
274 : try
275 : {
276 96 : Reference<XPropertySet> xProp( getDataSource(), UNO_SET_THROW );
277 :
278 96 : bool bAutoIncrementEnabled = true;
279 192 : TStringPair aAutoIncrement;
280 :
281 192 : Reference< XPropertySet > xDataSourceSettings;
282 96 : OSL_VERIFY( xProp->getPropertyValue( PROPERTY_SETTINGS ) >>= xDataSourceSettings );
283 192 : Reference< XPropertyState > xSettingsState( xDataSourceSettings, UNO_QUERY_THROW );
284 192 : Reference< XPropertySetInfo > xSettingsInfo( xDataSourceSettings->getPropertySetInfo(), UNO_SET_THROW );
285 :
286 192 : TDelimiter aDelimiter;
287 96 : xSettingsState->getPropertyDefault( INFO_TEXTDELIMITER ) >>= aDelimiter.sText;
288 96 : xSettingsState->getPropertyDefault( INFO_FIELDDELIMITER ) >>= aDelimiter.sField;
289 96 : xSettingsState->getPropertyDefault( INFO_DECIMALDELIMITER ) >>= aDelimiter.sDecimal;
290 96 : xSettingsState->getPropertyDefault( INFO_THOUSANDSDELIMITER ) >>= aDelimiter.sThousand;
291 :
292 192 : ::connectivity::DriversConfig aDriverConfig(getComponentContext());
293 192 : const OUString sURL = ::comphelper::getString(xProp->getPropertyValue(PROPERTY_URL));
294 192 : ::comphelper::NamedValueCollection aDriverSupportedProperties( aDriverConfig.getProperties( sURL ) );
295 :
296 96 : static OUString s_sTrue(::xmloff::token::GetXMLToken( XML_TRUE ));
297 96 : static OUString s_sFalse(::xmloff::token::GetXMLToken( XML_FALSE ));
298 : // loop through the properties, and export only those which are not defaulted
299 192 : TSettingsMap aSettingsMap;
300 192 : Sequence< Property > aProperties = xSettingsInfo->getProperties();
301 96 : const Property* pProperties = aProperties.getConstArray();
302 96 : const Property* pPropertiesEnd = pProperties + aProperties.getLength();
303 5184 : for ( ; pProperties != pPropertiesEnd; ++pProperties )
304 : {
305 5088 : OUString sValue;
306 5664 : Any aValue = xDataSourceSettings->getPropertyValue( pProperties->Name );
307 5088 : switch ( aValue.getValueTypeClass() )
308 : {
309 : case TypeClass_STRING:
310 2304 : aValue >>= sValue;
311 2304 : break;
312 : case TypeClass_DOUBLE:
313 : // let the unit converter format is as string
314 0 : sValue = OUString::number( getDouble( aValue ) );
315 0 : break;
316 : case TypeClass_BOOLEAN:
317 2016 : sValue = ::xmloff::token::GetXMLToken( getBOOL( aValue ) ? XML_TRUE : XML_FALSE );
318 2016 : break;
319 : case TypeClass_BYTE:
320 : case TypeClass_SHORT:
321 : case TypeClass_LONG:
322 : // let the unit converter format is as string
323 384 : sValue = OUString::number( getINT32( aValue ) );
324 384 : break;
325 : default:
326 384 : break;
327 : }
328 :
329 5088 : ::xmloff::token::XMLTokenEnum eToken = XML_TOKEN_INVALID;
330 :
331 61056 : struct PropertyMap
332 : {
333 : const OUString sPropertyName;
334 : const XMLTokenEnum eAttributeToken;
335 : const ::boost::optional< OUString > aXMLDefault;
336 :
337 15264 : PropertyMap( const OUString& _rPropertyName, const XMLTokenEnum _eToken )
338 : :sPropertyName( _rPropertyName )
339 : ,eAttributeToken( _eToken )
340 15264 : ,aXMLDefault()
341 : {
342 15264 : }
343 :
344 45792 : PropertyMap( const OUString& _rPropertyName, const XMLTokenEnum _eToken, const OUString& _rDefault )
345 : :sPropertyName( _rPropertyName )
346 : ,eAttributeToken( _eToken )
347 45792 : ,aXMLDefault( _rDefault )
348 : {
349 45792 : }
350 : };
351 :
352 : PropertyMap aTokens[] =
353 : {
354 : PropertyMap( INFO_TEXTFILEHEADER, XML_IS_FIRST_ROW_HEADER_LINE, s_sTrue ),
355 : PropertyMap( INFO_SHOWDELETEDROWS, XML_SHOW_DELETED, s_sFalse ),
356 : PropertyMap( INFO_ALLOWLONGTABLENAMES, XML_IS_TABLE_NAME_LENGTH_LIMITED, s_sTrue ),
357 : PropertyMap( INFO_ADDITIONALOPTIONS, XML_SYSTEM_DRIVER_SETTINGS ),
358 : PropertyMap( PROPERTY_ENABLESQL92CHECK, XML_ENABLE_SQL92_CHECK, s_sFalse ),
359 : PropertyMap( INFO_APPEND_TABLE_ALIAS, XML_APPEND_TABLE_ALIAS_NAME, s_sTrue ),
360 : PropertyMap( INFO_PARAMETERNAMESUBST, XML_PARAMETER_NAME_SUBSTITUTION, s_sTrue ),
361 : PropertyMap( INFO_IGNOREDRIVER_PRIV, XML_IGNORE_DRIVER_PRIVILEGES, s_sTrue ),
362 : PropertyMap( INFO_USECATALOG, XML_USE_CATALOG, s_sFalse ),
363 : PropertyMap( PROPERTY_SUPPRESSVERSIONCL,XML_SUPPRESS_VERSION_COLUMNS, s_sTrue ),
364 : PropertyMap( INFO_CONN_LDAP_BASEDN, XML_BASE_DN ),
365 : PropertyMap( INFO_CONN_LDAP_ROWCOUNT, XML_MAX_ROW_COUNT )
366 66144 : };
367 :
368 5088 : bool bIsXMLDefault = false;
369 58944 : for ( size_t i=0; i < sizeof( aTokens ) / sizeof( aTokens[0] ); ++i )
370 : {
371 54912 : if ( pProperties->Name == aTokens[i].sPropertyName )
372 : {
373 1056 : eToken = aTokens[i].eAttributeToken;
374 :
375 2112 : if ( !!aTokens[i].aXMLDefault
376 1056 : && ( sValue == *aTokens[i].aXMLDefault )
377 : )
378 : {
379 480 : bIsXMLDefault = true;
380 : }
381 1056 : break;
382 : }
383 : }
384 :
385 5088 : if ( bIsXMLDefault )
386 : // the property has the value which is specified as default in the XML schema -> no need to write it
387 480 : continue;
388 :
389 4608 : if ( eToken == XML_TOKEN_INVALID )
390 : {
391 : // for properties which are not REMOVABLE, we care for their state, and
392 : // only export them if they're not DEFAULTed
393 4032 : if ( ( pProperties->Attributes & PropertyAttribute::REMOVABLE ) == 0 )
394 : {
395 4032 : PropertyState ePropertyState = xSettingsState->getPropertyState( pProperties->Name );
396 4032 : if ( PropertyState_DEFAULT_VALUE == ePropertyState )
397 4032 : continue;
398 : }
399 :
400 : // special handlings
401 0 : if ( pProperties->Name == PROPERTY_BOOLEANCOMPARISONMODE )
402 : {
403 0 : sal_Int32 nValue = 0;
404 0 : aValue >>= nValue;
405 0 : if ( sValue == "0" )
406 0 : sValue = "equal-integer";
407 0 : else if ( sValue == "1" )
408 0 : sValue = "is-boolean";
409 0 : else if ( sValue == "2" )
410 0 : sValue = "equal-boolean";
411 0 : else if ( sValue == "3" )
412 0 : sValue = "equal-use-only-zero";
413 0 : if ( sValue == "equal-integer" )
414 0 : continue;
415 0 : eToken = XML_BOOLEAN_COMPARISON_MODE;
416 : }
417 0 : else if ( pProperties->Name == INFO_AUTORETRIEVEENABLED )
418 : {
419 0 : aValue >>= bAutoIncrementEnabled;
420 0 : continue;
421 : }
422 0 : else if ( pProperties->Name == INFO_AUTORETRIEVEVALUE )
423 : {
424 0 : aAutoIncrement.first = sValue;
425 0 : continue;
426 : }
427 0 : else if ( pProperties->Name == PROPERTY_AUTOINCREMENTCREATION )
428 : {
429 0 : aAutoIncrement.second = sValue;
430 0 : continue;
431 : }
432 0 : else if ( pProperties->Name == INFO_TEXTDELIMITER )
433 : {
434 0 : aDelimiter.sText = sValue;
435 0 : aDelimiter.bUsed = true;
436 0 : continue;
437 : }
438 0 : else if ( pProperties->Name == INFO_FIELDDELIMITER )
439 : {
440 0 : aDelimiter.sField = sValue;
441 0 : aDelimiter.bUsed = true;
442 0 : continue;
443 : }
444 0 : else if ( pProperties->Name == INFO_DECIMALDELIMITER )
445 : {
446 0 : aDelimiter.sDecimal = sValue;
447 0 : aDelimiter.bUsed = true;
448 0 : continue;
449 : }
450 0 : else if ( pProperties->Name == INFO_THOUSANDSDELIMITER )
451 : {
452 0 : aDelimiter.sThousand = sValue;
453 0 : aDelimiter.bUsed = true;
454 0 : continue;
455 : }
456 0 : else if ( pProperties->Name == INFO_CHARSET )
457 : {
458 0 : m_sCharSet = sValue;
459 0 : continue;
460 : }
461 : else
462 : {
463 0 : if ( !aDriverSupportedProperties.has(pProperties->Name) || aDriverSupportedProperties.get(pProperties->Name) != aValue )
464 : {
465 : m_aDataSourceSettings.push_back( TypedPropertyValue(
466 0 : pProperties->Name, pProperties->Type, aValue ) );
467 : }
468 0 : continue;
469 : }
470 : }
471 :
472 576 : aSettingsMap.insert(TSettingsMap::value_type(eToken,sValue));
473 1152 : }
474 96 : if ( bAutoIncrementEnabled && !(aAutoIncrement.first.isEmpty() && aAutoIncrement.second.isEmpty()) )
475 0 : m_aAutoIncrement.reset( new TStringPair(aAutoIncrement));
476 96 : if ( aDelimiter.bUsed )
477 0 : m_aDelimiter.reset( new TDelimiter( aDelimiter ) );
478 :
479 96 : SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_DATASOURCE, true, true);
480 :
481 96 : exportConnectionData();
482 96 : exportDriverSettings(aSettingsMap);
483 192 : exportApplicationConnectionSettings(aSettingsMap);
484 : }
485 0 : catch( const Exception& )
486 : {
487 : DBG_UNHANDLED_EXCEPTION();
488 : }
489 96 : }
490 :
491 96 : void ODBExport::exportApplicationConnectionSettings(const TSettingsMap& _aSettings)
492 : {
493 : const ::xmloff::token::XMLTokenEnum pSettings[] = {
494 : XML_IS_TABLE_NAME_LENGTH_LIMITED
495 : ,XML_ENABLE_SQL92_CHECK
496 : ,XML_APPEND_TABLE_ALIAS_NAME
497 : ,XML_IGNORE_DRIVER_PRIVILEGES
498 : ,XML_BOOLEAN_COMPARISON_MODE
499 : ,XML_USE_CATALOG
500 : ,XML_MAX_ROW_COUNT
501 : ,XML_SUPPRESS_VERSION_COLUMNS
502 96 : };
503 864 : for (size_t i = 0; i< sizeof(pSettings)/sizeof(pSettings[0]); ++i)
504 : {
505 768 : TSettingsMap::const_iterator aFind = _aSettings.find(pSettings[i]);
506 768 : if ( aFind != _aSettings.end() )
507 288 : AddAttribute(XML_NAMESPACE_DB, aFind->first,aFind->second);
508 : }
509 96 : SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_APPLICATION_CONNECTION_SETTINGS, true, true);
510 :
511 192 : Reference<XPropertySet> xProp(getDataSource());
512 192 : Sequence< OUString> aValue;
513 96 : xProp->getPropertyValue(PROPERTY_TABLEFILTER) >>= aValue;
514 96 : if ( aValue.getLength() )
515 : {
516 96 : SvXMLElementExport aElem2(*this,XML_NAMESPACE_DB, XML_TABLE_FILTER, true, true);
517 96 : exportSequence(aValue,XML_TABLE_INCLUDE_FILTER,XML_TABLE_FILTER_PATTERN);
518 : }
519 :
520 96 : xProp->getPropertyValue(PROPERTY_TABLETYPEFILTER) >>= aValue;
521 96 : if ( aValue.getLength() )
522 0 : exportSequence(aValue,XML_TABLE_TYPE_FILTER,XML_TABLE_TYPE);
523 :
524 192 : exportDataSourceSettings();
525 96 : }
526 :
527 96 : void ODBExport::exportDriverSettings(const TSettingsMap& _aSettings)
528 : {
529 : const ::xmloff::token::XMLTokenEnum pSettings[] = {
530 : XML_SHOW_DELETED
531 : ,XML_SYSTEM_DRIVER_SETTINGS
532 : ,XML_BASE_DN
533 : ,XML_IS_FIRST_ROW_HEADER_LINE
534 : ,XML_PARAMETER_NAME_SUBSTITUTION
535 96 : };
536 576 : for (size_t i = 0; i< sizeof(pSettings)/sizeof(pSettings[0]); ++i)
537 : {
538 480 : TSettingsMap::const_iterator aFind = _aSettings.find(pSettings[i]);
539 480 : if ( aFind != _aSettings.end() )
540 288 : AddAttribute(XML_NAMESPACE_DB, aFind->first,aFind->second);
541 : }
542 96 : SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_DRIVER_SETTINGS, true, true);
543 96 : exportAutoIncrement();
544 96 : exportDelimiter();
545 96 : exportCharSet();
546 96 : }
547 :
548 96 : void ODBExport::exportConnectionData()
549 : {
550 96 : SvXMLElementExport aConnData(*this,XML_NAMESPACE_DB, XML_CONNECTION_DATA, true, true);
551 :
552 : {
553 96 : OUString sValue;
554 192 : Reference<XPropertySet> xProp(getDataSource());
555 96 : xProp->getPropertyValue(PROPERTY_URL) >>= sValue;
556 96 : if ( m_aTypeCollection.isFileSystemBased(sValue) )
557 : {
558 87 : SvXMLElementExport aDatabaseDescription(*this,XML_NAMESPACE_DB, XML_DATABASE_DESCRIPTION, true, true);
559 : {
560 87 : SvtPathOptions aPathOptions;
561 174 : const OUString sOrigUrl = m_aTypeCollection.cutPrefix(sValue);
562 174 : OUString sFileName = aPathOptions.SubstituteVariable(sOrigUrl);
563 87 : if ( sOrigUrl == sFileName )
564 : {
565 87 : ::svt::OFileNotation aTransformer( sFileName );
566 174 : OUStringBuffer sURL( aTransformer.get( ::svt::OFileNotation::N_URL ) );
567 87 : if (sURL.isEmpty() || sURL[sURL.getLength() - 1] != '/')
568 5 : sURL.append('/');
569 :
570 174 : AddAttribute(XML_NAMESPACE_XLINK,XML_HREF,GetRelativeReference(sURL.makeStringAndClear()));
571 : }
572 : else
573 0 : AddAttribute(XML_NAMESPACE_XLINK,XML_HREF,sOrigUrl);
574 87 : AddAttribute(XML_NAMESPACE_DB,XML_MEDIA_TYPE,m_aTypeCollection.getMediaType(sValue));
575 87 : const ::dbaccess::DATASOURCE_TYPE eType = m_aTypeCollection.determineType(sValue);
576 : try
577 : {
578 87 : OUString sExtension;
579 87 : if ( eType == dbaccess::DST_MSACCESS )
580 0 : sExtension = "mdb";
581 : else
582 : {
583 87 : Reference< XPropertySet > xDataSourceSettings;
584 87 : OSL_VERIFY( xProp->getPropertyValue( PROPERTY_SETTINGS ) >>= xDataSourceSettings );
585 87 : xDataSourceSettings->getPropertyValue( INFO_TEXTFILEEXTENSION ) >>= sExtension;
586 : }
587 87 : if ( !sExtension.isEmpty() )
588 0 : AddAttribute(XML_NAMESPACE_DB,XML_EXTENSION,sExtension);
589 : }
590 0 : catch(const Exception&)
591 : {
592 : }
593 174 : SvXMLElementExport aFileBasedDB(*this,XML_NAMESPACE_DB, XML_FILE_BASED_DATABASE, true, true);
594 87 : }
595 : }
596 : else
597 : {
598 18 : OUString sDatabaseName,sHostName;
599 9 : sal_Int32 nPort = -1;
600 9 : m_aTypeCollection.extractHostNamePort(sValue,sDatabaseName,sHostName,nPort);
601 9 : if ( sHostName.getLength() )
602 : {
603 0 : SvXMLElementExport aDatabaseDescription(*this,XML_NAMESPACE_DB, XML_DATABASE_DESCRIPTION, true, true);
604 : {
605 0 : OUString sType = comphelper::string::stripEnd(m_aTypeCollection.getPrefix(sValue), ':');
606 0 : AddAttribute(XML_NAMESPACE_DB,XML_TYPE,sType);
607 0 : AddAttribute(XML_NAMESPACE_DB,XML_HOSTNAME,sHostName);
608 0 : if ( nPort != -1 )
609 0 : AddAttribute(XML_NAMESPACE_DB,XML_PORT,OUString::number(nPort));
610 0 : if ( sDatabaseName.getLength() )
611 0 : AddAttribute(XML_NAMESPACE_DB,XML_DATABASE_NAME,sDatabaseName);
612 :
613 : try
614 : {
615 0 : Reference< XPropertySet > xDataSourceSettings( xProp->getPropertyValue( PROPERTY_SETTINGS ), UNO_QUERY_THROW );
616 0 : Reference< XPropertySetInfo > xSettingsInfo( xDataSourceSettings->getPropertySetInfo(), UNO_SET_THROW );
617 :
618 : struct PropertyMap
619 : {
620 : const sal_Char* pAsciiPropertyName;
621 : sal_uInt16 nAttributeId;
622 :
623 0 : PropertyMap( const sal_Char* _pAsciiPropertyName, const sal_uInt16 _nAttributeId )
624 : :pAsciiPropertyName( _pAsciiPropertyName )
625 0 : ,nAttributeId( _nAttributeId )
626 : {
627 0 : }
628 : };
629 : PropertyMap aProperties[] =
630 : {
631 : PropertyMap( "LocalSocket", XML_LOCAL_SOCKET )
632 : //PropertyMap( "NamedPipe", 0 /* TODO */ )
633 0 : };
634 :
635 0 : for ( size_t i=0;
636 0 : i < sizeof( aProperties ) / sizeof( aProperties[0] );
637 : ++i
638 : )
639 : {
640 0 : const OUString sPropertyName = OUString::createFromAscii( aProperties[i].pAsciiPropertyName );
641 0 : if ( xSettingsInfo->hasPropertyByName( sPropertyName ) )
642 : {
643 0 : OUString sPropertyValue;
644 0 : if ( ( xDataSourceSettings->getPropertyValue( sPropertyName ) >>= sPropertyValue ) && !sPropertyValue.isEmpty() )
645 0 : AddAttribute( XML_NAMESPACE_DB, XML_LOCAL_SOCKET, sPropertyValue );
646 :
647 : }
648 0 : }
649 : }
650 0 : catch( const Exception& )
651 : {
652 : DBG_UNHANDLED_EXCEPTION();
653 : }
654 :
655 0 : SvXMLElementExport aServerDB(*this,XML_NAMESPACE_DB, XML_SERVER_DATABASE, true, true);
656 0 : }
657 : }
658 : else
659 : {
660 9 : AddAttribute(XML_NAMESPACE_XLINK, XML_HREF,sValue);
661 9 : AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE);
662 9 : SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_CONNECTION_RESOURCE, true, true);
663 9 : }
664 96 : }
665 :
666 : }
667 :
668 96 : exportLogin();
669 96 : }
670 :
671 0 : template< typename T > void ODBExport::exportDataSourceSettingsSequence(
672 : ::std::vector< TypedPropertyValue >::iterator const & in)
673 : {
674 0 : OSequenceIterator< T > i( in->Value );
675 0 : while (i.hasMoreElements())
676 : {
677 0 : SvXMLElementExport aDataValue(*this,XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_VALUE, true, false);
678 : // (no whitespace inside the tag)
679 0 : Characters(implConvertAny(i.nextElement()));
680 : }
681 0 : }
682 :
683 96 : void ODBExport::exportDataSourceSettings()
684 : {
685 96 : if ( m_aDataSourceSettings.empty() )
686 192 : return;
687 :
688 0 : SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTINGS, true, true);
689 0 : ::std::vector< TypedPropertyValue >::iterator aIter = m_aDataSourceSettings.begin();
690 0 : ::std::vector< TypedPropertyValue >::iterator aEnd = m_aDataSourceSettings.end();
691 0 : for ( ; aIter != aEnd; ++aIter )
692 : {
693 0 : bool bIsSequence = TypeClass_SEQUENCE == aIter->Type.getTypeClass();
694 :
695 0 : Type aSimpleType;
696 0 : if ( bIsSequence )
697 0 : aSimpleType = ::comphelper::getSequenceElementType( aIter->Value.getValueType() );
698 : else
699 0 : aSimpleType = aIter->Type;
700 :
701 0 : AddAttribute( XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_IS_LIST,bIsSequence ? XML_TRUE : XML_FALSE );
702 0 : AddAttribute( XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_NAME, aIter->Name );
703 :
704 0 : OUString sTypeName = lcl_implGetPropertyXMLType( aSimpleType );
705 0 : if ( bIsSequence && aSimpleType.getTypeClass() == TypeClass_ANY )
706 : {
707 0 : Sequence<Any> aSeq;
708 0 : aIter->Value >>= aSeq;
709 0 : if ( aSeq.getLength() )
710 0 : sTypeName = lcl_implGetPropertyXMLType(aSeq[0].getValueType());
711 : }
712 :
713 0 : AddAttribute( XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_TYPE, sTypeName );
714 :
715 0 : SvXMLElementExport aDataSourceSetting( *this, XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING, true, true );
716 :
717 0 : if ( !bIsSequence )
718 : {
719 0 : SvXMLElementExport aDataValue( *this, XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_VALUE, true, false );
720 : // (no whitespace inside the tag)
721 0 : Characters( implConvertAny( aIter->Value ) );
722 : }
723 : else
724 : {
725 : // the not-that-simple case, we need to iterate through the sequence elements
726 0 : switch (aSimpleType.getTypeClass())
727 : {
728 : case TypeClass_STRING:
729 : exportDataSourceSettingsSequence< OUString >(
730 0 : aIter );
731 0 : break;
732 : case TypeClass_DOUBLE:
733 0 : exportDataSourceSettingsSequence< double >( aIter );
734 0 : break;
735 : case TypeClass_BOOLEAN:
736 0 : exportDataSourceSettingsSequence< sal_Bool >( aIter );
737 0 : break;
738 : case TypeClass_BYTE:
739 0 : exportDataSourceSettingsSequence< sal_Int8 >( aIter );
740 0 : break;
741 : case TypeClass_SHORT:
742 0 : exportDataSourceSettingsSequence< sal_Int16 >( aIter );
743 0 : break;
744 : case TypeClass_LONG:
745 0 : exportDataSourceSettingsSequence< sal_Int32 >( aIter );
746 0 : break;
747 : case TypeClass_ANY:
748 0 : exportDataSourceSettingsSequence< Any >( aIter );
749 0 : break;
750 : default:
751 : OSL_FAIL("unsupported sequence type !");
752 0 : break;
753 : }
754 : }
755 0 : }
756 : }
757 :
758 96 : void ODBExport::exportCharSet()
759 : {
760 96 : if ( !m_sCharSet.isEmpty() )
761 : {
762 0 : AddAttribute(XML_NAMESPACE_DB, XML_ENCODING,m_sCharSet);
763 :
764 0 : SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_FONT_CHARSET, true, true);
765 : }
766 96 : }
767 :
768 96 : void ODBExport::exportDelimiter()
769 : {
770 96 : if ( m_aDelimiter.get() && m_aDelimiter->bUsed )
771 : {
772 0 : AddAttribute(XML_NAMESPACE_DB, XML_FIELD,m_aDelimiter->sField);
773 0 : AddAttribute(XML_NAMESPACE_DB, XML_STRING,m_aDelimiter->sText);
774 0 : AddAttribute(XML_NAMESPACE_DB, XML_DECIMAL,m_aDelimiter->sDecimal);
775 0 : AddAttribute(XML_NAMESPACE_DB, XML_THOUSAND,m_aDelimiter->sThousand);
776 0 : SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_DELIMITER, true, true);
777 : }
778 96 : }
779 :
780 96 : void ODBExport::exportAutoIncrement()
781 : {
782 96 : if ( m_aAutoIncrement.get() )
783 : {
784 0 : AddAttribute(XML_NAMESPACE_DB, XML_ADDITIONAL_COLUMN_STATEMENT,m_aAutoIncrement->second);
785 0 : AddAttribute(XML_NAMESPACE_DB, XML_ROW_RETRIEVING_STATEMENT,m_aAutoIncrement->first);
786 0 : SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_AUTO_INCREMENT, true, true);
787 : }
788 96 : }
789 :
790 96 : void ODBExport::exportSequence(const Sequence< OUString>& _aValue
791 : ,::xmloff::token::XMLTokenEnum _eTokenFilter
792 : ,::xmloff::token::XMLTokenEnum _eTokenType)
793 : {
794 96 : Reference<XPropertySet> xProp(getDataSource());
795 96 : if ( _aValue.getLength() )
796 : {
797 96 : SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, _eTokenFilter, true, true);
798 :
799 96 : const OUString* pIter = _aValue.getConstArray();
800 96 : const OUString* pEnd = pIter + _aValue.getLength();
801 192 : for(;pIter != pEnd;++pIter)
802 : {
803 96 : SvXMLElementExport aDataSource(*this,XML_NAMESPACE_DB, _eTokenType, true, false);
804 96 : Characters(*pIter);
805 192 : }
806 96 : }
807 96 : }
808 :
809 96 : void ODBExport::exportLogin()
810 : {
811 96 : Reference<XPropertySet> xProp(getDataSource());
812 192 : OUString sValue;
813 96 : xProp->getPropertyValue(PROPERTY_USER) >>= sValue;
814 96 : bool bAddLogin = !sValue.isEmpty();
815 96 : if ( bAddLogin )
816 0 : AddAttribute(XML_NAMESPACE_DB, XML_USER_NAME,sValue);
817 96 : bool bValue = false;
818 96 : if ( xProp->getPropertyValue(PROPERTY_ISPASSWORDREQUIRED) >>= bValue )
819 : {
820 96 : bAddLogin = true;
821 96 : AddAttribute(XML_NAMESPACE_DB, XML_IS_PASSWORD_REQUIRED,bValue ? XML_TRUE : XML_FALSE);
822 : }
823 96 : if ( bAddLogin )
824 192 : SvXMLElementExport aElem(*this,XML_NAMESPACE_DB, XML_LOGIN, true, true);
825 96 : }
826 :
827 21 : void ODBExport::exportCollection(const Reference< XNameAccess >& _xCollection
828 : ,enum ::xmloff::token::XMLTokenEnum _eComponents
829 : ,enum ::xmloff::token::XMLTokenEnum _eSubComponents
830 : ,bool _bExportContext
831 : ,const ::comphelper::mem_fun1_t<ODBExport,XPropertySet* >& _aMemFunc
832 : )
833 : {
834 21 : if ( _xCollection.is() )
835 : {
836 21 : boost::scoped_ptr<SvXMLElementExport> pComponents;
837 21 : if ( _bExportContext )
838 9 : pComponents.reset( new SvXMLElementExport(*this,XML_NAMESPACE_DB, _eComponents, true, true));
839 42 : Sequence< OUString> aSeq = _xCollection->getElementNames();
840 21 : const OUString* pIter = aSeq.getConstArray();
841 21 : const OUString* pEnd = pIter + aSeq.getLength();
842 39 : for(;pIter != pEnd;++pIter)
843 : {
844 18 : Reference<XPropertySet> xProp(_xCollection->getByName(*pIter),UNO_QUERY);
845 18 : if ( _bExportContext && XML_TABLE_REPRESENTATIONS != _eComponents )
846 9 : AddAttribute(XML_NAMESPACE_DB, XML_NAME,*pIter);
847 36 : Reference< XNameAccess > xSub(xProp,UNO_QUERY);
848 18 : if ( xSub.is() )
849 : {
850 0 : exportCollection(xSub,_eSubComponents,_eSubComponents,_bExportContext,_aMemFunc);
851 : }
852 18 : else if ( xProp.is() )
853 18 : _aMemFunc(this,xProp.get());
854 39 : }
855 : }
856 21 : }
857 :
858 6 : void ODBExport::exportComponent(XPropertySet* _xProp)
859 : {
860 6 : OUString sValue;
861 6 : _xProp->getPropertyValue(PROPERTY_PERSISTENT_NAME) >>= sValue;
862 6 : bool bIsForm = true;
863 6 : _xProp->getPropertyValue("IsForm") >>= bIsForm;
864 6 : if ( bIsForm )
865 0 : sValue = "forms/" + sValue;
866 : else
867 6 : sValue = "reports/" + sValue;
868 :
869 6 : AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sValue);
870 6 : AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE);
871 6 : bool bAsTemplate = false;
872 6 : _xProp->getPropertyValue(PROPERTY_AS_TEMPLATE) >>= bAsTemplate;
873 6 : AddAttribute(XML_NAMESPACE_DB, XML_AS_TEMPLATE,bAsTemplate ? XML_TRUE : XML_FALSE);
874 6 : SvXMLElementExport aComponents(*this,XML_NAMESPACE_DB, XML_COMPONENT, true, true);
875 6 : }
876 :
877 3 : void ODBExport::exportQuery(XPropertySet* _xProp)
878 : {
879 3 : AddAttribute(XML_NAMESPACE_DB, XML_COMMAND,getString(_xProp->getPropertyValue(PROPERTY_COMMAND)));
880 :
881 3 : if ( getBOOL(_xProp->getPropertyValue(PROPERTY_APPLYFILTER)) )
882 0 : AddAttribute(XML_NAMESPACE_DB, XML_APPLY_FILTER,XML_TRUE);
883 :
884 15 : if ( _xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_APPLYORDER)
885 15 : && getBOOL(_xProp->getPropertyValue(PROPERTY_APPLYORDER)) )
886 0 : AddAttribute(XML_NAMESPACE_DB, XML_APPLY_ORDER,XML_TRUE);
887 :
888 3 : if ( ! getBOOL(_xProp->getPropertyValue(PROPERTY_ESCAPE_PROCESSING)) )
889 0 : AddAttribute(XML_NAMESPACE_DB, XML_ESCAPE_PROCESSING,XML_FALSE);
890 :
891 3 : exportStyleName(_xProp,GetAttrList());
892 :
893 3 : SvXMLElementExport aComponents(*this,XML_NAMESPACE_DB, XML_QUERY, true, true);
894 6 : Reference<XColumnsSupplier> xCol(_xProp,UNO_QUERY);
895 3 : exportColumns(xCol);
896 3 : exportFilter(_xProp,PROPERTY_FILTER,XML_FILTER_STATEMENT);
897 3 : exportFilter(_xProp,PROPERTY_ORDER,XML_ORDER_STATEMENT);
898 6 : exportTableName(_xProp,true);
899 3 : }
900 :
901 3 : void ODBExport::exportTable(XPropertySet* _xProp)
902 : {
903 3 : exportTableName(_xProp,false);
904 :
905 3 : if ( _xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_DESCRIPTION) )
906 0 : AddAttribute(XML_NAMESPACE_DB, XML_DESCRIPTION,getString(_xProp->getPropertyValue(PROPERTY_DESCRIPTION)));
907 :
908 3 : if ( getBOOL(_xProp->getPropertyValue(PROPERTY_APPLYFILTER)) )
909 0 : AddAttribute(XML_NAMESPACE_DB, XML_APPLY_FILTER,XML_TRUE);
910 :
911 15 : if ( _xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_APPLYORDER)
912 15 : && getBOOL(_xProp->getPropertyValue(PROPERTY_APPLYORDER)) )
913 0 : AddAttribute(XML_NAMESPACE_DB, XML_APPLY_ORDER,XML_TRUE);
914 :
915 3 : exportStyleName(_xProp,GetAttrList());
916 :
917 3 : SvXMLElementExport aComponents(*this,XML_NAMESPACE_DB, XML_TABLE_REPRESENTATION, true, true);
918 6 : Reference<XColumnsSupplier> xCol(_xProp,UNO_QUERY);
919 3 : exportColumns(xCol);
920 3 : exportFilter(_xProp,PROPERTY_FILTER,XML_FILTER_STATEMENT);
921 6 : exportFilter(_xProp,PROPERTY_ORDER,XML_ORDER_STATEMENT);
922 3 : }
923 :
924 6 : void ODBExport::exportStyleName(XPropertySet* _xProp,SvXMLAttributeList& _rAtt)
925 : {
926 6 : Reference<XPropertySet> xFind(_xProp);
927 6 : exportStyleName(XML_STYLE_NAME,xFind,_rAtt,m_aAutoStyleNames);
928 6 : exportStyleName(XML_DEFAULT_CELL_STYLE_NAME,xFind,_rAtt,m_aCellAutoStyleNames);
929 6 : exportStyleName(XML_DEFAULT_ROW_STYLE_NAME,xFind,_rAtt,m_aRowAutoStyleNames);
930 6 : }
931 :
932 18 : void ODBExport::exportStyleName(const ::xmloff::token::XMLTokenEnum _eToken,const uno::Reference<beans::XPropertySet>& _xProp,SvXMLAttributeList& _rAtt,TPropertyStyleMap& _rMap)
933 : {
934 18 : TPropertyStyleMap::iterator aFind = _rMap.find(_xProp);
935 18 : if ( aFind != _rMap.end() )
936 : {
937 0 : _rAtt.AddAttribute( GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_DB, GetXMLToken(_eToken) ),
938 0 : aFind->second );
939 0 : _rMap.erase(aFind);
940 : }
941 18 : }
942 :
943 6 : void ODBExport::exportTableName(XPropertySet* _xProp,bool _bUpdate)
944 : {
945 6 : OUString sValue;
946 6 : _xProp->getPropertyValue(_bUpdate ? OUString(PROPERTY_UPDATE_TABLENAME) : OUString(PROPERTY_NAME)) >>= sValue;
947 6 : if ( !sValue.isEmpty() )
948 : {
949 3 : AddAttribute(XML_NAMESPACE_DB, XML_NAME,sValue);
950 3 : _xProp->getPropertyValue(_bUpdate ? OUString(PROPERTY_UPDATE_SCHEMANAME) : OUString(PROPERTY_SCHEMANAME)) >>= sValue;
951 3 : if ( !sValue.isEmpty() )
952 0 : AddAttribute(XML_NAMESPACE_DB, XML_SCHEMA_NAME,sValue);
953 3 : _xProp->getPropertyValue(_bUpdate ? OUString(PROPERTY_UPDATE_CATALOGNAME) : OUString(PROPERTY_CATALOGNAME)) >>= sValue;
954 3 : if ( !sValue.isEmpty() )
955 0 : AddAttribute(XML_NAMESPACE_DB, XML_CATALOG_NAME,sValue);
956 :
957 3 : if ( _bUpdate )
958 : {
959 0 : SvXMLElementExport aComponents(*this,XML_NAMESPACE_DB, XML_UPDATE_TABLE, true, true);
960 : }
961 6 : }
962 6 : }
963 :
964 12 : void ODBExport::exportFilter(XPropertySet* _xProp
965 : ,const OUString& _sProp
966 : ,enum ::xmloff::token::XMLTokenEnum _eStatementType)
967 : {
968 : OSL_PRECOND(!GetAttrList().getLength(),"Invalid attribute length!");
969 12 : OUString sCommand;
970 12 : _xProp->getPropertyValue(_sProp) >>= sCommand;
971 12 : if ( !sCommand.isEmpty() )
972 : {
973 0 : AddAttribute(XML_NAMESPACE_DB, XML_COMMAND,sCommand);
974 0 : SvXMLElementExport aComponents(*this,XML_NAMESPACE_DB, _eStatementType, true, true);
975 : }
976 12 : SAL_WARN_IF(GetAttrList().getLength(), "dbaccess", "Invalid attribute length!");
977 12 : }
978 :
979 6 : void ODBExport::exportColumns(const Reference<XColumnsSupplier>& _xColSup)
980 : {
981 : OSL_PRECOND( _xColSup.is(), "ODBExport::exportColumns: invalid columns supplier!" );
982 6 : if ( !_xColSup.is() )
983 0 : return;
984 :
985 : try
986 : {
987 6 : Reference<XNameAccess> xNameAccess( _xColSup->getColumns(), UNO_SET_THROW );
988 6 : if ( !xNameAccess->hasElements() )
989 : {
990 6 : Reference< XPropertySet > xComponent(_xColSup,UNO_QUERY);
991 6 : TTableColumnMap::iterator aFind = m_aTableDummyColumns.find(xComponent);
992 6 : if ( aFind != m_aTableDummyColumns.end() )
993 : {
994 0 : SvXMLElementExport aColumns(*this,XML_NAMESPACE_DB, XML_COLUMNS, true, true);
995 0 : SvXMLAttributeList* pAtt = new SvXMLAttributeList;
996 0 : Reference<XAttributeList> xAtt = pAtt;
997 0 : exportStyleName(aFind->second.get(),*pAtt);
998 0 : AddAttributeList(xAtt);
999 0 : SvXMLElementExport aColumn(*this,XML_NAMESPACE_DB, XML_COLUMN, true, true);
1000 :
1001 : }
1002 6 : return;
1003 : }
1004 :
1005 0 : SvXMLElementExport aColumns(*this,XML_NAMESPACE_DB, XML_COLUMNS, true, true);
1006 0 : Sequence< OUString> aSeq = xNameAccess->getElementNames();
1007 0 : const OUString* pIter = aSeq.getConstArray();
1008 0 : const OUString* pEnd = pIter + aSeq.getLength();
1009 0 : for( ; pIter != pEnd ; ++pIter)
1010 : {
1011 0 : Reference<XPropertySet> xProp(xNameAccess->getByName(*pIter),UNO_QUERY);
1012 0 : if ( xProp.is() )
1013 : {
1014 0 : SvXMLAttributeList* pAtt = new SvXMLAttributeList;
1015 0 : Reference<XAttributeList> xAtt = pAtt;
1016 0 : exportStyleName(xProp.get(),*pAtt);
1017 :
1018 0 : bool bHidden = getBOOL(xProp->getPropertyValue(PROPERTY_HIDDEN));
1019 :
1020 0 : OUString sValue;
1021 0 : xProp->getPropertyValue(PROPERTY_HELPTEXT) >>= sValue;
1022 0 : Any aColumnDefault;
1023 0 : aColumnDefault = xProp->getPropertyValue(PROPERTY_CONTROLDEFAULT);
1024 :
1025 0 : if ( bHidden || !sValue.isEmpty() || aColumnDefault.hasValue() || pAtt->getLength() )
1026 : {
1027 0 : AddAttribute(XML_NAMESPACE_DB, XML_NAME,*pIter);
1028 0 : if ( bHidden )
1029 0 : AddAttribute(XML_NAMESPACE_DB, XML_VISIBLE,XML_FALSE);
1030 :
1031 0 : if ( !sValue.isEmpty() )
1032 0 : AddAttribute(XML_NAMESPACE_DB, XML_HELP_MESSAGE,sValue);
1033 :
1034 0 : if ( aColumnDefault.hasValue() )
1035 : {
1036 0 : OUStringBuffer sColumnDefaultString,sType;
1037 : ::sax::Converter::convertAny(
1038 0 : sColumnDefaultString, sType, aColumnDefault );
1039 0 : AddAttribute(XML_NAMESPACE_DB, XML_TYPE_NAME,sType.makeStringAndClear());
1040 0 : AddAttribute(XML_NAMESPACE_DB, XML_DEFAULT_VALUE,sColumnDefaultString.makeStringAndClear());
1041 : }
1042 :
1043 0 : if ( pAtt->getLength() )
1044 0 : AddAttributeList(xAtt);
1045 : }
1046 :
1047 0 : if ( GetAttrList().getLength() )
1048 : {
1049 0 : SvXMLElementExport aComponents(*this,XML_NAMESPACE_DB, XML_COLUMN, true, true);
1050 0 : }
1051 : }
1052 0 : }
1053 : }
1054 0 : catch( const Exception& )
1055 : {
1056 : DBG_UNHANDLED_EXCEPTION();
1057 : }
1058 : }
1059 :
1060 96 : void ODBExport::exportForms()
1061 : {
1062 96 : Any aValue;
1063 192 : OUString sService;
1064 96 : dbtools::getDataSourceSetting(getDataSource(),"Forms",aValue);
1065 96 : aValue >>= sService;
1066 96 : if ( sService.isEmpty() )
1067 : {
1068 96 : Reference<XFormDocumentsSupplier> xSup(GetModel(),UNO_QUERY);
1069 96 : if ( xSup.is() )
1070 : {
1071 96 : Reference< XNameAccess > xCollection = xSup->getFormDocuments();
1072 96 : if ( xCollection.is() && xCollection->hasElements() )
1073 : {
1074 0 : ::comphelper::mem_fun1_t<ODBExport,XPropertySet* > aMemFunc(&ODBExport::exportComponent);
1075 0 : exportCollection(xCollection,XML_FORMS,XML_COMPONENT_COLLECTION,true,aMemFunc);
1076 96 : }
1077 96 : }
1078 96 : }
1079 96 : }
1080 :
1081 96 : void ODBExport::exportReports()
1082 : {
1083 96 : Any aValue;
1084 192 : OUString sService;
1085 96 : dbtools::getDataSourceSetting(getDataSource(),"Reports",aValue);
1086 96 : aValue >>= sService;
1087 96 : if ( sService.isEmpty() )
1088 : {
1089 96 : Reference<XReportDocumentsSupplier> xSup(GetModel(),UNO_QUERY);
1090 96 : if ( xSup.is() )
1091 : {
1092 96 : Reference< XNameAccess > xCollection = xSup->getReportDocuments();
1093 96 : if ( xCollection.is() && xCollection->hasElements() )
1094 : {
1095 3 : ::comphelper::mem_fun1_t<ODBExport,XPropertySet* > aMemFunc(&ODBExport::exportComponent);
1096 3 : exportCollection(xCollection,XML_REPORTS,XML_COMPONENT_COLLECTION,true,aMemFunc);
1097 96 : }
1098 96 : }
1099 96 : }
1100 96 : }
1101 :
1102 192 : void ODBExport::exportQueries(bool _bExportContext)
1103 : {
1104 192 : Any aValue;
1105 384 : OUString sService;
1106 192 : dbtools::getDataSourceSetting(getDataSource(),"CommandDefinitions",aValue);
1107 192 : aValue >>= sService;
1108 192 : if ( sService.isEmpty() )
1109 : {
1110 192 : Reference<XQueryDefinitionsSupplier> xSup(getDataSource(),UNO_QUERY);
1111 192 : if ( xSup.is() )
1112 : {
1113 192 : Reference< XNameAccess > xCollection = xSup->getQueryDefinitions();
1114 192 : if ( xCollection.is() && xCollection->hasElements() )
1115 : {
1116 6 : boost::scoped_ptr< ::comphelper::mem_fun1_t<ODBExport,XPropertySet* > > pMemFunc;
1117 6 : if ( _bExportContext )
1118 3 : pMemFunc.reset( new ::comphelper::mem_fun1_t<ODBExport,XPropertySet* >(&ODBExport::exportQuery) );
1119 : else
1120 3 : pMemFunc.reset( new ::comphelper::mem_fun1_t<ODBExport,XPropertySet* >(&ODBExport::exportAutoStyle) );
1121 :
1122 6 : exportCollection(xCollection,XML_QUERIES,XML_QUERY_COLLECTION,_bExportContext,*pMemFunc);
1123 192 : }
1124 192 : }
1125 192 : }
1126 192 : }
1127 :
1128 192 : void ODBExport::exportTables(bool _bExportContext)
1129 : {
1130 192 : Reference<XTablesSupplier> xSup(getDataSource(),UNO_QUERY);
1131 192 : if ( xSup.is() )
1132 : {
1133 192 : Reference< XNameAccess > xCollection = xSup->getTables();
1134 192 : if ( xCollection.is() && xCollection->hasElements() )
1135 : {
1136 6 : boost::scoped_ptr< ::comphelper::mem_fun1_t<ODBExport,XPropertySet* > > pMemFunc;
1137 6 : if ( _bExportContext )
1138 3 : pMemFunc.reset( new ::comphelper::mem_fun1_t<ODBExport,XPropertySet* >(&ODBExport::exportTable) );
1139 : else
1140 3 : pMemFunc.reset( new ::comphelper::mem_fun1_t<ODBExport,XPropertySet* >(&ODBExport::exportAutoStyle) );
1141 6 : exportCollection(xCollection,XML_TABLE_REPRESENTATIONS,XML_TOKEN_INVALID,_bExportContext,*pMemFunc);
1142 192 : }
1143 192 : }
1144 192 : }
1145 :
1146 6 : void ODBExport::exportAutoStyle(XPropertySet* _xProp)
1147 : {
1148 : typedef ::std::pair<TPropertyStyleMap*,sal_uInt16> TEnumMapperPair;
1149 : typedef ::std::pair< rtl::Reference < SvXMLExportPropertyMapper> , TEnumMapperPair> TExportPropMapperPair;
1150 6 : Reference<XColumnsSupplier> xSup(_xProp,UNO_QUERY);
1151 6 : if ( xSup.is() )
1152 : {
1153 : const TExportPropMapperPair pExportHelper[] = {
1154 : TExportPropMapperPair(m_xExportHelper,TEnumMapperPair(&m_aAutoStyleNames,XML_STYLE_FAMILY_TABLE_TABLE ))
1155 : // ,TExportPropMapperPair(m_xCellExportHelper,TEnumMapperPair(&m_aCellAutoStyleNames,XML_STYLE_FAMILY_TABLE_CELL))
1156 : ,TExportPropMapperPair(m_xRowExportHelper,TEnumMapperPair(&m_aRowAutoStyleNames,XML_STYLE_FAMILY_TABLE_ROW))
1157 18 : };
1158 :
1159 12 : ::std::vector< XMLPropertyState > aPropertyStates;
1160 18 : for (size_t i = 0 ; i < sizeof(pExportHelper)/sizeof(pExportHelper[0]); ++i)
1161 : {
1162 12 : aPropertyStates = pExportHelper[i].first->Filter(_xProp);
1163 12 : if ( !aPropertyStates.empty() )
1164 0 : pExportHelper[i].second.first->insert( TPropertyStyleMap::value_type(_xProp,GetAutoStylePool()->Add( pExportHelper[i].second.second, aPropertyStates )));
1165 : }
1166 :
1167 12 : Reference< XNameAccess > xCollection;
1168 : try
1169 : {
1170 6 : xCollection.set( xSup->getColumns(), UNO_SET_THROW );
1171 6 : awt::FontDescriptor aFont;
1172 6 : _xProp->getPropertyValue(PROPERTY_FONT) >>= aFont;
1173 : GetFontAutoStylePool()->Add(aFont.Name,aFont.StyleName,static_cast<FontFamily>(aFont.Family),
1174 6 : static_cast<FontPitch>(aFont.Pitch),aFont.CharSet );
1175 :
1176 6 : m_aCurrentPropertyStates = m_xCellExportHelper->Filter(_xProp);
1177 6 : if ( !m_aCurrentPropertyStates.empty() && !xCollection->hasElements() )
1178 : {
1179 0 : Reference< XDataDescriptorFactory> xFac(xCollection,UNO_QUERY);
1180 0 : if ( xFac.is() )
1181 : {
1182 0 : Reference< XPropertySet> xColumn = xFac->createDataDescriptor();
1183 0 : m_aTableDummyColumns.insert(TTableColumnMap::value_type(Reference< XPropertySet>(_xProp),xColumn));
1184 0 : exportAutoStyle(xColumn.get());
1185 0 : }
1186 : }
1187 : else
1188 : {
1189 6 : ::comphelper::mem_fun1_t<ODBExport,XPropertySet* > aMemFunc(&ODBExport::exportAutoStyle);
1190 6 : exportCollection(xCollection,XML_TOKEN_INVALID,XML_TOKEN_INVALID,false,aMemFunc);
1191 6 : }
1192 : }
1193 0 : catch(const Exception&)
1194 : {
1195 : DBG_UNHANDLED_EXCEPTION();
1196 : }
1197 24 : m_aCurrentPropertyStates.clear();
1198 : }
1199 : else
1200 : { // here I know I have a column
1201 : TExportPropMapperPair pExportHelper[] = {
1202 : TExportPropMapperPair(m_xColumnExportHelper,TEnumMapperPair(&m_aAutoStyleNames,XML_STYLE_FAMILY_TABLE_COLUMN ))
1203 : ,TExportPropMapperPair(m_xCellExportHelper,TEnumMapperPair(&m_aCellAutoStyleNames,XML_STYLE_FAMILY_TABLE_CELL))
1204 0 : };
1205 0 : for (size_t i = 0 ; i < sizeof(pExportHelper)/sizeof(pExportHelper[0]); ++i)
1206 : {
1207 0 : ::std::vector< XMLPropertyState > aPropStates = pExportHelper[i].first->Filter( _xProp );
1208 0 : if ( !aPropStates.empty() )
1209 : {
1210 0 : ::std::vector< XMLPropertyState >::iterator aItr = aPropStates.begin();
1211 0 : ::std::vector< XMLPropertyState >::iterator aEnd = aPropStates.end();
1212 0 : const rtl::Reference < XMLPropertySetMapper >& pStyle = pExportHelper[i].first->getPropertySetMapper();
1213 0 : while ( aItr != aEnd )
1214 : {
1215 0 : if ( aItr->mnIndex != -1 )
1216 : {
1217 0 : switch ( pStyle->GetEntryContextId(aItr->mnIndex) )
1218 : {
1219 : case CTF_DB_NUMBERFORMAT:
1220 : {
1221 0 : sal_Int32 nNumberFormat = -1;
1222 0 : if ( aItr->maValue >>= nNumberFormat )
1223 0 : addDataStyle(nNumberFormat);
1224 : }
1225 0 : break;
1226 : case CTF_DB_COLUMN_TEXT_ALIGN:
1227 0 : if ( !aItr->maValue.hasValue() )
1228 0 : aItr->maValue <<= ::com::sun::star::awt::TextAlign::LEFT;
1229 0 : break;
1230 : }
1231 : }
1232 0 : ++aItr;
1233 : }
1234 :
1235 : }
1236 0 : if ( XML_STYLE_FAMILY_TABLE_CELL == pExportHelper[i].second.second )
1237 0 : ::std::copy( m_aCurrentPropertyStates.begin(), m_aCurrentPropertyStates.end(), ::std::back_inserter( aPropStates ));
1238 0 : if ( !aPropStates.empty() )
1239 0 : pExportHelper[i].second.first->insert( TPropertyStyleMap::value_type(_xProp,GetAutoStylePool()->Add( pExportHelper[i].second.second, aPropStates )));
1240 0 : }
1241 6 : }
1242 6 : }
1243 :
1244 96 : void ODBExport::_ExportContent()
1245 : {
1246 96 : exportDataSource();
1247 96 : exportForms();
1248 96 : exportReports();
1249 96 : exportQueries(true);
1250 96 : exportTables(true);
1251 96 : }
1252 :
1253 0 : void ODBExport::_ExportMasterStyles()
1254 : {
1255 0 : GetPageExport()->exportMasterStyles( true );
1256 0 : }
1257 :
1258 96 : void ODBExport::_ExportAutoStyles()
1259 : {
1260 : // there are no styles that require their own autostyles
1261 96 : if ( getExportFlags() & SvXMLExportFlags::CONTENT )
1262 : {
1263 96 : collectComponentStyles();
1264 : GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_TABLE
1265 96 : ,GetDocHandler()
1266 96 : ,GetMM100UnitConverter()
1267 96 : ,GetNamespaceMap()
1268 96 : );
1269 : GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_COLUMN
1270 96 : ,GetDocHandler()
1271 96 : ,GetMM100UnitConverter()
1272 96 : ,GetNamespaceMap()
1273 96 : );
1274 : GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_CELL
1275 96 : ,GetDocHandler()
1276 96 : ,GetMM100UnitConverter()
1277 96 : ,GetNamespaceMap()
1278 96 : );
1279 : GetAutoStylePool()->exportXML(XML_STYLE_FAMILY_TABLE_ROW
1280 96 : ,GetDocHandler()
1281 96 : ,GetMM100UnitConverter()
1282 96 : ,GetNamespaceMap()
1283 96 : );
1284 96 : exportDataStyles();
1285 : }
1286 96 : }
1287 :
1288 0 : void ODBExport::_ExportStyles(bool bUsed)
1289 : {
1290 0 : SvXMLExport::_ExportStyles(bUsed);
1291 0 : }
1292 :
1293 192 : sal_uInt32 ODBExport::exportDoc(enum ::xmloff::token::XMLTokenEnum eClass)
1294 : {
1295 192 : return SvXMLExport::exportDoc( eClass );
1296 : }
1297 :
1298 96 : void ODBExport::GetViewSettings(Sequence<PropertyValue>& aProps)
1299 : {
1300 96 : Reference<XQueryDefinitionsSupplier> xSup(getDataSource(),UNO_QUERY);
1301 96 : if ( xSup.is() )
1302 : {
1303 96 : Reference< XNameAccess > xCollection = xSup->getQueryDefinitions();
1304 96 : if ( xCollection.is() && xCollection->hasElements() )
1305 : {
1306 : try
1307 : {
1308 3 : sal_Int32 nLength = aProps.getLength();
1309 3 : aProps.realloc(nLength + 1);
1310 3 : aProps[nLength].Name = "Queries";
1311 3 : Sequence< OUString> aSeq = xCollection->getElementNames();
1312 3 : const OUString* pIter = aSeq.getConstArray();
1313 3 : const OUString* pEnd = pIter + aSeq.getLength();
1314 :
1315 6 : Sequence<PropertyValue> aQueries(aSeq.getLength());
1316 6 : for(sal_Int32 i = 0;pIter != pEnd;++pIter,++i)
1317 : {
1318 3 : Reference<XPropertySet> xProp(xCollection->getByName(*pIter),UNO_QUERY);
1319 3 : if ( xProp.is() )
1320 : {
1321 3 : aQueries[i].Name = *pIter;
1322 3 : aQueries[i].Value = xProp->getPropertyValue(PROPERTY_LAYOUTINFORMATION);
1323 : }
1324 3 : }
1325 6 : aProps[nLength].Value <<= aQueries;
1326 : }
1327 0 : catch(const Exception&)
1328 : {
1329 : OSL_FAIL("ODBExport::GetViewSettings: Exception caught!");
1330 : }
1331 96 : }
1332 96 : }
1333 :
1334 96 : }
1335 :
1336 96 : void ODBExport::GetConfigurationSettings(Sequence<PropertyValue>& aProps)
1337 : {
1338 96 : Reference<XPropertySet> xProp(getDataSource());
1339 96 : if ( xProp.is() )
1340 : {
1341 96 : sal_Int32 nLength = aProps.getLength();
1342 : try
1343 : {
1344 96 : Any aValue = xProp->getPropertyValue(PROPERTY_LAYOUTINFORMATION);
1345 192 : Sequence< PropertyValue > aPropValues;
1346 96 : aValue >>= aPropValues;
1347 96 : if ( aPropValues.getLength() )
1348 : {
1349 0 : aProps.realloc(nLength + 1);
1350 0 : aProps[nLength].Name = "layout-settings";
1351 0 : aProps[nLength].Value = aValue;
1352 96 : }
1353 : }
1354 0 : catch(const Exception&)
1355 : {
1356 : OSL_FAIL("Could not access layout information from the data source!");
1357 : }
1358 96 : }
1359 96 : }
1360 :
1361 0 : OUString ODBExport::implConvertAny(const Any& _rValue)
1362 : {
1363 0 : OUStringBuffer aBuffer;
1364 0 : switch (_rValue.getValueTypeClass())
1365 : {
1366 : case TypeClass_STRING:
1367 : { // extract the string
1368 0 : OUString sCurrentValue;
1369 0 : _rValue >>= sCurrentValue;
1370 0 : aBuffer.append(sCurrentValue);
1371 : }
1372 0 : break;
1373 : case TypeClass_DOUBLE:
1374 : // let the unit converter format is as string
1375 0 : ::sax::Converter::convertDouble(aBuffer, getDouble(_rValue));
1376 0 : break;
1377 : case TypeClass_BOOLEAN:
1378 0 : aBuffer = getBOOL(_rValue) ? ::xmloff::token::GetXMLToken(XML_TRUE) : ::xmloff::token::GetXMLToken(XML_FALSE);
1379 0 : break;
1380 : case TypeClass_BYTE:
1381 : case TypeClass_SHORT:
1382 : case TypeClass_LONG:
1383 : // let the unit converter format is as string
1384 0 : ::sax::Converter::convertNumber(aBuffer, getINT32(_rValue));
1385 0 : break;
1386 : default:
1387 : OSL_FAIL("ODBExport::implConvertAny: Invalid type");
1388 : }
1389 :
1390 0 : return aBuffer.makeStringAndClear();
1391 : }
1392 :
1393 195 : rtl::Reference < XMLPropertySetMapper > ODBExport::GetTableStylesPropertySetMapper() const
1394 : {
1395 195 : if ( !m_xTableStylesPropertySetMapper.is() )
1396 : {
1397 195 : m_xTableStylesPropertySetMapper = OXMLHelper::GetTableStylesPropertySetMapper( true);
1398 : }
1399 195 : return m_xTableStylesPropertySetMapper;
1400 : }
1401 :
1402 195 : rtl::Reference < XMLPropertySetMapper > ODBExport::GetCellStylesPropertySetMapper() const
1403 : {
1404 195 : if ( !m_xCellStylesPropertySetMapper.is() )
1405 : {
1406 195 : m_xCellStylesPropertySetMapper = OXMLHelper::GetCellStylesPropertySetMapper( true);
1407 : }
1408 195 : return m_xCellStylesPropertySetMapper;
1409 : }
1410 :
1411 195 : rtl::Reference < XMLPropertySetMapper > ODBExport::GetColumnStylesPropertySetMapper() const
1412 : {
1413 195 : if ( !m_xColumnStylesPropertySetMapper.is() )
1414 : {
1415 195 : m_xColumnStylesPropertySetMapper = OXMLHelper::GetColumnStylesPropertySetMapper( true);
1416 : }
1417 195 : return m_xColumnStylesPropertySetMapper;
1418 : }
1419 :
1420 195 : SvXMLAutoStylePoolP* ODBExport::CreateAutoStylePool()
1421 : {
1422 195 : return new OXMLAutoStylePoolP(*this);
1423 : }
1424 :
1425 192 : void SAL_CALL ODBExport::setSourceDocument( const Reference< XComponent >& xDoc ) throw(IllegalArgumentException, RuntimeException, std::exception)
1426 : {
1427 192 : Reference<XOfficeDatabaseDocument> xOfficeDoc(xDoc,UNO_QUERY_THROW);
1428 192 : m_xDataSource.set(xOfficeDoc->getDataSource(),UNO_QUERY_THROW);
1429 : OSL_ENSURE(m_xDataSource.is(),"DataSource is NULL!");
1430 384 : Reference< XNumberFormatsSupplier > xNum(m_xDataSource->getPropertyValue(PROPERTY_NUMBERFORMATSSUPPLIER),UNO_QUERY);
1431 192 : SetNumberFormatsSupplier(xNum);
1432 384 : SvXMLExport::setSourceDocument(xDoc);
1433 192 : }
1434 :
1435 96 : void ODBExport::_ExportFontDecls()
1436 : {
1437 96 : GetFontAutoStylePool(); // make sure the pool is created
1438 96 : collectComponentStyles();
1439 96 : SvXMLExport::_ExportFontDecls();
1440 96 : }
1441 :
1442 192 : void ODBExport::collectComponentStyles()
1443 : {
1444 192 : if ( m_bAllreadyFilled )
1445 288 : return;
1446 :
1447 96 : m_bAllreadyFilled = true;
1448 96 : exportQueries(false);
1449 96 : exportTables(false);
1450 : }
1451 :
1452 : }// dbaxml
1453 :
1454 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|