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