1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_dbaxml.hxx"
26
27 #ifndef _COM_SUN_STAR_PACKAGES_ZIP_ZIPIOEXCEPTION_HPP_
28 #include <com/sun/star/packages/zip/ZipIOException.hpp>
29 #endif
30 #ifndef _COM_SUN_STAR_EMBED_ELEMENTMODES_HPP_
31 #include <com/sun/star/embed/ElementModes.hpp>
32 #endif
33 #ifndef _COM_SUN_STAR_SDB_XOFFICEDATABASEDOCUMENT_HPP_
34 #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
35 #endif
36 #ifndef DBA_XMLFILTER_HXX
37 #include "xmlfilter.hxx"
38 #endif
39 #ifndef _FLT_REGHELPER_HXX_
40 #include "flt_reghelper.hxx"
41 #endif
42 #ifndef _SV_SVAPP_HXX
43 #include <vcl/svapp.hxx>
44 #endif
45 #ifndef _SV_WINDOW_HXX
46 #include <vcl/window.hxx>
47 #endif
48 #ifndef _XMLOFF_XMLNMSPE_HXX
49 #include <xmloff/xmlnmspe.hxx>
50 #endif
51 #ifndef _XMLOFF_XMLSCRIPTI_HXX
52 #include <xmloff/xmlscripti.hxx>
53 #endif
54 #ifndef _XMLOFF_XMLTOKEN_HXX
55 #include <xmloff/xmltoken.hxx>
56 #endif
57 #ifndef _XMLOFF_TEXTIMP_HXX_
58 #include <xmloff/txtimp.hxx>
59 #endif
60 #ifndef _XMLOFF_NMSPMAP_HXX
61 #include <xmloff/nmspmap.hxx>
62 #endif
63 #ifndef _RTL_LOGFILE_HXX_
64 #include <rtl/logfile.hxx>
65 #endif
66 #ifndef _COM_SUN_STAR_XML_SAX_INPUTSOURCE_HPP_
67 #include <com/sun/star/xml/sax/InputSource.hpp>
68 #endif
69 #ifndef _COM_SUN_STAR_XML_SAX_XPARSER_HPP_
70 #include <com/sun/star/xml/sax/XParser.hpp>
71 #endif
72 #ifndef _XMLOFF_PROGRESSBARHELPER_HXX
73 #include <xmloff/ProgressBarHelper.hxx>
74 #endif
75 #ifndef _SFXDOCFILE_HXX //autogen wg. SfxMedium
76 #include <sfx2/docfile.hxx>
77 #endif
78 #ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
79 #include <com/sun/star/io/XInputStream.hpp>
80 #endif
81 #ifndef _COM_SUN_STAR_UNO_XNAMINGSERVICE_HPP_
82 #include <com/sun/star/uno/XNamingService.hpp>
83 #endif
84 #ifndef DBA_XMLDATABASE_HXX
85 #include "xmlDatabase.hxx"
86 #endif
87 #ifndef DBA_XMLENUMS_HXX
88 #include "xmlEnums.hxx"
89 #endif
90 #ifndef _URLOBJ_HXX //autogen wg. INetURLObject
91 #include <tools/urlobj.hxx>
92 #endif
93 #ifndef DBACCESS_SHARED_XMLSTRINGS_HRC
94 #include "xmlstrings.hrc"
95 #endif
96 #ifndef _XMLOFF_DOCUMENTSETTINGSCONTEXT_HXX
97 #include <xmloff/DocumentSettingsContext.hxx>
98 #endif
99 #ifndef DBA_XMLSTYLEIMPORT_HXX
100 #include "xmlStyleImport.hxx"
101 #endif
102 #ifndef _XMLOFF_XMLUCONV_HXX
103 #include <xmloff/xmluconv.hxx>
104 #endif
105 #ifndef DBA_XMLHELPER_HXX
106 #include "xmlHelper.hxx"
107 #endif
108 #ifndef _COM_SUN_STAR_UTIL_XMODIFIABLE_HPP_
109 #include <com/sun/star/util/XModifiable.hpp>
110 #endif
111 #include <com/sun/star/frame/XComponentLoader.hpp>
112 #include <com/sun/star/frame/FrameSearchFlag.hpp>
113 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
114 #ifndef _SV_SVAPP_HXX //autogen
115 #include <vcl/svapp.hxx>
116 #endif
117 #ifndef _VOS_MUTEX_HXX_
118 #include <vos/mutex.hxx>
119 #endif
120 #include <svtools/sfxecode.hxx>
121 #include <unotools/moduleoptions.hxx>
122 #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
123 #include <toolkit/helper/vclunohelper.hxx>
124 #endif
125 #include <tools/diagnose_ex.h>
126 #include <comphelper/namedvaluecollection.hxx>
127 #include <comphelper/mimeconfighelper.hxx>
128 #include <comphelper/documentconstants.hxx>
129 #include <comphelper/uno3.hxx>
130 #include <cppuhelper/exc_hlp.hxx>
131 #include <osl/thread.hxx>
132 #include <connectivity/CommonTools.hxx>
133 #include <connectivity/DriversConfig.hxx>
134 #include "dsntypes.hxx"
135
136 using namespace ::com::sun::star;
137
createRegistryInfo_ODBFilter()138 extern "C" void SAL_CALL createRegistryInfo_ODBFilter( )
139 {
140 static ::dbaxml::OMultiInstanceAutoRegistration< ::dbaxml::ODBFilter > aAutoRegistration;
141 }
142 //--------------------------------------------------------------------------
143 namespace dbaxml
144 {
145 namespace
146 {
147 class FastLoader : public ::osl::Thread
148 {
149 public:
150 typedef enum { E_JAVA, E_CALC } StartType;
FastLoader(uno::Reference<lang::XMultiServiceFactory> const & _xFactory,StartType _eType)151 FastLoader(uno::Reference< lang::XMultiServiceFactory > const & _xFactory,StartType _eType)
152 :m_xFactory(_xFactory)
153 ,m_eWhat(_eType)
154 {}
155
156 protected:
~FastLoader()157 virtual ~FastLoader(){}
158
159 /// Working method which should be overridden.
160 virtual void SAL_CALL run();
161 virtual void SAL_CALL onTerminated();
162 private:
163 uno::Reference< lang::XMultiServiceFactory > m_xFactory;
164 StartType m_eWhat;
165 };
166
run()167 void SAL_CALL FastLoader::run()
168 {
169 if ( m_eWhat == E_JAVA )
170 {
171 static bool s_bFirstTime = true;
172 if ( s_bFirstTime )
173 {
174 s_bFirstTime = false;
175 try
176 {
177 ::rtl::Reference< jvmaccess::VirtualMachine > xJVM = ::connectivity::getJavaVM(m_xFactory);
178 }
179 catch(uno::Exception& ex)
180 {
181 (void)ex;
182 OSL_ASSERT(0);
183 }
184 } // if ( s_bFirstTime )
185 } // if ( m_eWhat == E_JAVA )
186 else if ( m_eWhat == E_CALC )
187 {
188 static bool s_bFirstTime = true;
189 if ( s_bFirstTime )
190 {
191 s_bFirstTime = false;
192 try
193 {
194 uno::Reference<frame::XComponentLoader> xFrameLoad( m_xFactory->createInstance(
195 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")))
196 ,uno::UNO_QUERY);
197 const ::rtl::OUString sTarget(RTL_CONSTASCII_USTRINGPARAM("_blank"));
198 sal_Int32 nFrameSearchFlag = frame::FrameSearchFlag::TASKS | frame::FrameSearchFlag::CREATE;
199 uno::Reference< frame::XFrame> xFrame = uno::Reference< frame::XFrame>(xFrameLoad,uno::UNO_QUERY_THROW)->findFrame(sTarget,nFrameSearchFlag);
200 xFrameLoad.set( xFrame,uno::UNO_QUERY);
201
202 if ( xFrameLoad.is() )
203 {
204 uno::Sequence < beans::PropertyValue > aArgs( 3);
205 sal_Int32 nLen = 0;
206 aArgs[nLen].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AsTemplate"));
207 aArgs[nLen++].Value <<= sal_False;
208
209 aArgs[nLen].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ReadOnly"));
210 aArgs[nLen++].Value <<= sal_True;
211
212 aArgs[nLen].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Hidden"));
213 aArgs[nLen++].Value <<= sal_True;
214
215 ::comphelper::MimeConfigurationHelper aHelper(m_xFactory);
216 SvtModuleOptions aModuleOptions;
217 uno::Reference< frame::XModel > xModel(xFrameLoad->loadComponentFromURL(
218 aModuleOptions.GetFactoryEmptyDocumentURL( aModuleOptions.ClassifyFactoryByServiceName( aHelper.GetDocServiceNameFromMediaType(MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET) )),
219 ::rtl::OUString(), // empty frame name
220 0,
221 aArgs
222 ),uno::UNO_QUERY);
223 ::comphelper::disposeComponent(xModel);
224 }
225 }
226 catch(uno::Exception& ex)
227 {
228 (void)ex;
229 OSL_ASSERT(0);
230 }
231 }
232 }
233 }
onTerminated()234 void SAL_CALL FastLoader::onTerminated()
235 {
236 delete this;
237 }
238
239 class DatasourceURLListener : public ::cppu::WeakImplHelper1< beans::XPropertyChangeListener >
240 {
241 uno::Reference< lang::XMultiServiceFactory > m_xFactory;
242 ::dbaccess::ODsnTypeCollection m_aTypeCollection;
243 DatasourceURLListener(const DatasourceURLListener&);
244 void operator =(const DatasourceURLListener&);
245 protected:
~DatasourceURLListener()246 virtual ~DatasourceURLListener(){}
247 public:
DatasourceURLListener(uno::Reference<lang::XMultiServiceFactory> const & _xFactory)248 DatasourceURLListener(uno::Reference< lang::XMultiServiceFactory > const & _xFactory) : m_xFactory(_xFactory),m_aTypeCollection(_xFactory){}
249 // XPropertyChangeListener
propertyChange(const beans::PropertyChangeEvent & _rEvent)250 virtual void SAL_CALL propertyChange( const beans::PropertyChangeEvent& _rEvent ) throw (uno::RuntimeException)
251 {
252 ::rtl::OUString sURL;
253 _rEvent.NewValue >>= sURL;
254 FastLoader* pCreatorThread = NULL;
255
256 if ( m_aTypeCollection.needsJVM(sURL) )
257 {
258 pCreatorThread = new FastLoader(m_xFactory,FastLoader::E_JAVA);
259 } // if ( m_aTypeCollection.needsJVM(sURL) )
260 else if ( sURL.matchIgnoreAsciiCaseAsciiL("sdbc:calc:",10,0) )
261 {
262 pCreatorThread = new FastLoader(m_xFactory,FastLoader::E_CALC);
263 }
264 if ( pCreatorThread )
265 {
266 pCreatorThread->createSuspended();
267 pCreatorThread->setPriority(osl_Thread_PriorityBelowNormal);
268 pCreatorThread->resume();
269 }
270 }
271 // XEventListener
disposing(const lang::EventObject &)272 virtual void SAL_CALL disposing( const lang::EventObject& /*_rSource*/ ) throw (uno::RuntimeException)
273 {
274 }
275 };
276 }
277 sal_Char __READONLY_DATA sXML_np__db[] = "_db";
278 sal_Char __READONLY_DATA sXML_np___db[] = "__db";
279
280 using namespace ::com::sun::star::util;
281 /// read a component (file + filter version)
ReadThroughComponent(const uno::Reference<XInputStream> & xInputStream,const uno::Reference<XComponent> & xModelComponent,const uno::Reference<XMultiServiceFactory> & rFactory,const uno::Reference<XDocumentHandler> & _xFilter)282 sal_Int32 ReadThroughComponent(
283 const uno::Reference<XInputStream>& xInputStream,
284 const uno::Reference<XComponent>& xModelComponent,
285 const uno::Reference<XMultiServiceFactory> & rFactory,
286 const uno::Reference< XDocumentHandler >& _xFilter )
287 {
288 DBG_ASSERT(xInputStream.is(), "input stream missing");
289 DBG_ASSERT(xModelComponent.is(), "document missing");
290 DBG_ASSERT(rFactory.is(), "factory missing");
291
292 RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "dbaxml", "oj", "ReadThroughComponent" );
293
294 // prepare ParserInputSrouce
295 InputSource aParserInput;
296 aParserInput.aInputStream = xInputStream;
297
298 // get parser
299 uno::Reference< XParser > xParser(
300 rFactory->createInstance(
301 ::rtl::OUString::createFromAscii("com.sun.star.xml.sax.Parser") ),
302 UNO_QUERY );
303 DBG_ASSERT( xParser.is(), "Can't create parser" );
304 if( !xParser.is() )
305 return 1;
306 RTL_LOGFILE_CONTEXT_TRACE( aLog, "parser created" );
307
308 // get filter
309 DBG_ASSERT( _xFilter.is(), "Can't instantiate filter component." );
310 if( !_xFilter.is() )
311 return 1;
312
313 // connect parser and filter
314 xParser->setDocumentHandler( _xFilter );
315
316 // connect model and filter
317 uno::Reference < XImporter > xImporter( _xFilter, UNO_QUERY );
318 xImporter->setTargetDocument( xModelComponent );
319
320
321
322 // finally, parser the stream
323 try
324 {
325 xParser->parseStream( aParserInput );
326 }
327 #if OSL_DEBUG_LEVEL > 1
328 catch( SAXParseException& r )
329 {
330 ByteString aError( "SAX parse exception catched while importing:\n" );
331 aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US );
332 aError += ByteString::CreateFromInt32( r.LineNumber );
333 aError += ',';
334 aError += ByteString::CreateFromInt32( r.ColumnNumber );
335
336 DBG_ERROR( aError.GetBuffer() );
337 return 1;
338 }
339 #else
340 catch( SAXParseException& )
341 {
342 return 1;
343 }
344 #endif
345 catch( SAXException& )
346 {
347 return 1;
348 }
349 catch( packages::zip::ZipIOException& )
350 {
351 return ERRCODE_IO_BROKENPACKAGE;
352 }
353 catch( Exception& )
354 {
355 DBG_UNHANDLED_EXCEPTION();
356 }
357
358 // success!
359 return 0;
360 }
361
362 /// read a component (storage version)
ReadThroughComponent(uno::Reference<embed::XStorage> xStorage,const uno::Reference<XComponent> & xModelComponent,const sal_Char * pStreamName,const sal_Char * pCompatibilityStreamName,const uno::Reference<XMultiServiceFactory> & rFactory,const uno::Reference<XDocumentHandler> & _xFilter)363 sal_Int32 ReadThroughComponent(
364 uno::Reference< embed::XStorage > xStorage,
365 const uno::Reference<XComponent>& xModelComponent,
366 const sal_Char* pStreamName,
367 const sal_Char* pCompatibilityStreamName,
368 const uno::Reference<XMultiServiceFactory> & rFactory,
369 const uno::Reference< XDocumentHandler >& _xFilter)
370 {
371 DBG_ASSERT( xStorage.is(), "Need storage!");
372 DBG_ASSERT(NULL != pStreamName, "Please, please, give me a name!");
373
374 if ( xStorage.is() )
375 {
376 uno::Reference< io::XStream > xDocStream;
377 sal_Bool bEncrypted = sal_False;
378
379 try
380 {
381 // open stream (and set parser input)
382 ::rtl::OUString sStreamName = ::rtl::OUString::createFromAscii(pStreamName);
383 if ( !xStorage->hasByName( sStreamName ) || !xStorage->isStreamElement( sStreamName ) )
384 {
385 // stream name not found! Then try the compatibility name.
386 // if no stream can be opened, return immediately with OK signal
387
388 // do we even have an alternative name?
389 if ( NULL == pCompatibilityStreamName )
390 return 0;
391
392 // if so, does the stream exist?
393 sStreamName = ::rtl::OUString::createFromAscii(pCompatibilityStreamName);
394 if ( !xStorage->hasByName( sStreamName ) || !xStorage->isStreamElement( sStreamName ) )
395 return 0;
396 }
397
398 // get input stream
399 xDocStream = xStorage->openStreamElement( sStreamName, embed::ElementModes::READ );
400
401 uno::Reference< beans::XPropertySet > xProps( xDocStream, uno::UNO_QUERY_THROW );
402 uno::Any aAny = xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Encrypted") ) );
403 aAny >>= bEncrypted;
404 }
405 catch( packages::WrongPasswordException& )
406 {
407 return ERRCODE_SFX_WRONGPASSWORD;
408 }
409 catch ( uno::Exception& )
410 {
411 return 1; // TODO/LATER: error handling
412 }
413
414 #ifdef TIMELOG
415 // if we do profiling, we want to know the stream
416 RTL_LOGFILE_TRACE_AUTHOR1( "dbaxml", "oj",
417 "ReadThroughComponent : parsing \"%s\"", pStreamName );
418 #endif
419
420 uno::Reference< XInputStream > xInputStream = xDocStream->getInputStream();
421 // read from the stream
422 return ReadThroughComponent( xInputStream
423 ,xModelComponent
424 ,rFactory
425 ,_xFilter );
426 }
427
428 // TODO/LATER: better error handling
429 return 1;
430 }
431
432 // -------------
433 // - ODBFilter -
434 // -------------
DBG_NAME(ODBFilter)435 DBG_NAME(ODBFilter)
436
437 ODBFilter::ODBFilter( const uno::Reference< XMultiServiceFactory >& _rxMSF )
438 :SvXMLImport(_rxMSF)
439 ,m_bNewFormat(false)
440 {
441 DBG_CTOR(ODBFilter,NULL);
442
443 GetMM100UnitConverter().setCoreMeasureUnit(MAP_10TH_MM);
444 GetMM100UnitConverter().setXMLMeasureUnit(MAP_CM);
445 GetNamespaceMap().Add( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__db) ),
446 GetXMLToken(XML_N_DB),
447 XML_NAMESPACE_DB );
448
449 GetNamespaceMap().Add( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np___db) ),
450 GetXMLToken(XML_N_DB_OASIS),
451 XML_NAMESPACE_DB );
452 }
453
454 // -----------------------------------------------------------------------------
455
~ODBFilter()456 ODBFilter::~ODBFilter() throw()
457 {
458
459 DBG_DTOR(ODBFilter,NULL);
460 }
461 // -----------------------------------------------------------------------------
462 IMPLEMENT_SERVICE_INFO1_STATIC( ODBFilter, "com.sun.star.comp.sdb.DBFilter", "com.sun.star.document.ImportFilter")
463 // -----------------------------------------------------------------------------
filter(const Sequence<PropertyValue> & rDescriptor)464 sal_Bool SAL_CALL ODBFilter::filter( const Sequence< PropertyValue >& rDescriptor )
465 throw (RuntimeException)
466 {
467 uno::Reference< ::com::sun::star::awt::XWindow > xWindow;
468 {
469 ::vos::OGuard aGuard(Application::GetSolarMutex());
470 Window* pFocusWindow = Application::GetFocusWindow();
471 xWindow = VCLUnoHelper::GetInterface( pFocusWindow );
472 if( pFocusWindow )
473 pFocusWindow->EnterWait();
474 }
475 sal_Bool bRet = sal_False;
476
477 if ( GetModel().is() )
478 bRet = implImport( rDescriptor );
479
480 if ( xWindow.is() )
481 {
482 ::vos::OGuard aGuard(Application::GetSolarMutex());
483 Window* pFocusWindow = VCLUnoHelper::GetWindow( xWindow );
484 if ( pFocusWindow )
485 pFocusWindow->LeaveWait();
486 }
487
488
489 return bRet;
490 }
491 // -----------------------------------------------------------------------------
implImport(const Sequence<PropertyValue> & rDescriptor)492 sal_Bool ODBFilter::implImport( const Sequence< PropertyValue >& rDescriptor )
493 throw (RuntimeException)
494 {
495 ::rtl::OUString sFileName;
496 ::comphelper::NamedValueCollection aMediaDescriptor( rDescriptor );
497 if ( aMediaDescriptor.has( "URL" ) )
498 sFileName = aMediaDescriptor.getOrDefault( "URL", ::rtl::OUString() );
499 if ( !sFileName.getLength() && aMediaDescriptor.has( "FileName" ) )
500 sFileName = aMediaDescriptor.getOrDefault( "FileName", sFileName );
501
502 OSL_ENSURE( sFileName.getLength(), "ODBFilter::implImport: no URL given!" );
503 sal_Bool bRet = ( sFileName.getLength() != 0 );
504
505 if ( bRet )
506 {
507 uno::Reference<XComponent> xCom(GetModel(),UNO_QUERY);
508
509 SfxMediumRef pMedium = new SfxMedium(
510 sFileName, ( STREAM_READ | STREAM_NOCREATE ), sal_False, 0 );
511 uno::Reference< embed::XStorage > xStorage;
512 try
513 {
514 xStorage.set( pMedium->GetStorage( sal_False ), UNO_QUERY_THROW );
515 }
516 catch( const Exception& )
517 {
518 Any aError = ::cppu::getCaughtException();
519 if ( aError.isExtractableTo( ::cppu::UnoType< RuntimeException >::get() ) )
520 throw;
521 throw lang::WrappedTargetRuntimeException( ::rtl::OUString(), *this, aError );
522 }
523
524 uno::Reference<sdb::XOfficeDatabaseDocument> xOfficeDoc(GetModel(),UNO_QUERY_THROW);
525 m_xDataSource.set(xOfficeDoc->getDataSource(),UNO_QUERY_THROW);
526 uno::Reference<beans::XPropertyChangeListener> xListener = new DatasourceURLListener(getServiceFactory());
527 m_xDataSource->addPropertyChangeListener(PROPERTY_URL,xListener);
528 uno::Reference< XNumberFormatsSupplier > xNum(m_xDataSource->getPropertyValue(PROPERTY_NUMBERFORMATSSUPPLIER),UNO_QUERY);
529 SetNumberFormatsSupplier(xNum);
530
531 uno::Reference<XComponent> xModel(GetModel(),UNO_QUERY);
532 sal_Int32 nRet = ReadThroughComponent( xStorage
533 ,xModel
534 ,"settings.xml"
535 ,"Settings.xml"
536 ,getServiceFactory()
537 ,this
538 );
539
540 if ( nRet == 0 )
541 nRet = ReadThroughComponent( xStorage
542 ,xModel
543 ,"content.xml"
544 ,"Content.xml"
545 ,getServiceFactory()
546 ,this
547 );
548
549 bRet = nRet == 0;
550
551 if ( bRet )
552 {
553 uno::Reference< XModifiable > xModi(GetModel(),UNO_QUERY);
554 if ( xModi.is() )
555 xModi->setModified(sal_False);
556 }
557 else
558 {
559 switch( nRet )
560 {
561 case ERRCODE_IO_BROKENPACKAGE:
562 // TODO/LATER: no way to transport the error outside from the filter!
563 break;
564 default:
565 {
566 // TODO/LATER: this is completely wrong! Filter code should never call ErrorHandler directly! But for now this is the only way!
567 ErrorHandler::HandleError( nRet );
568 if( nRet & ERRCODE_WARNING_MASK )
569 bRet = sal_True;
570 }
571 }
572 }
573 }
574
575 return bRet;
576 }
577 // -----------------------------------------------------------------------------
CreateContext(sal_uInt16 nPrefix,const::rtl::OUString & rLocalName,const uno::Reference<::com::sun::star::xml::sax::XAttributeList> & xAttrList)578 SvXMLImportContext* ODBFilter::CreateContext( sal_uInt16 nPrefix,
579 const ::rtl::OUString& rLocalName,
580 const uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList )
581 {
582 SvXMLImportContext *pContext = 0;
583
584 const SvXMLTokenMap& rTokenMap = GetDocElemTokenMap();
585 switch( rTokenMap.Get( nPrefix, rLocalName ) )
586 {
587 case XML_TOK_DOC_SETTINGS:
588 GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
589 pContext = new XMLDocumentSettingsContext( *this, nPrefix, rLocalName,xAttrList );
590 break;
591 case XML_TOK_DOC_DATABASE:
592 GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
593 pContext = new OXMLDatabase( *this, nPrefix, rLocalName );
594 break;
595 case XML_TOK_DOC_STYLES:
596 GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
597 pContext = CreateStylesContext(nPrefix, rLocalName, xAttrList, sal_False);
598 break;
599 case XML_TOK_DOC_AUTOSTYLES:
600 GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
601 pContext = CreateStylesContext(nPrefix, rLocalName, xAttrList, sal_True);
602 break;
603 case XML_TOK_DOC_SCRIPT:
604 pContext = CreateScriptContext( rLocalName );
605 break;
606 }
607
608 if ( !pContext )
609 pContext = SvXMLImport::CreateContext( nPrefix, rLocalName, xAttrList );
610
611 return pContext;
612 }
613 // -----------------------------------------------------------------------------
SetViewSettings(const Sequence<PropertyValue> & aViewProps)614 void ODBFilter::SetViewSettings(const Sequence<PropertyValue>& aViewProps)
615 {
616 const PropertyValue *pIter = aViewProps.getConstArray();
617 const PropertyValue *pEnd = pIter + aViewProps.getLength();
618 for (; pIter != pEnd; ++pIter)
619 {
620 if ( pIter->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "Queries" ) ) )
621 {
622 fillPropertyMap(pIter->Value,m_aQuerySettings);
623 }
624 else if ( pIter->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "Tables" ) ) )
625 {
626 fillPropertyMap(pIter->Value,m_aTablesSettings);
627 }
628 }
629 }
630 // -----------------------------------------------------------------------------
SetConfigurationSettings(const Sequence<PropertyValue> & aConfigProps)631 void ODBFilter::SetConfigurationSettings(const Sequence<PropertyValue>& aConfigProps)
632 {
633 const PropertyValue *pIter = aConfigProps.getConstArray();
634 const PropertyValue *pEnd = pIter + aConfigProps.getLength();
635 for (; pIter != pEnd; ++pIter)
636 {
637 if ( pIter->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "layout-settings" ) ) )
638 {
639 Sequence<PropertyValue> aWindows;
640 pIter->Value >>= aWindows;
641 uno::Reference<XPropertySet> xProp(getDataSource());
642 if ( xProp.is() )
643 xProp->setPropertyValue(PROPERTY_LAYOUTINFORMATION,makeAny(aWindows));
644 }
645 }
646 }
647 // -----------------------------------------------------------------------------
fillPropertyMap(const Any & _rValue,TPropertyNameMap & _rMap)648 void ODBFilter::fillPropertyMap(const Any& _rValue,TPropertyNameMap& _rMap)
649 {
650 Sequence<PropertyValue> aWindows;
651 _rValue >>= aWindows;
652 const PropertyValue *pIter = aWindows.getConstArray();
653 const PropertyValue *pEnd = pIter + aWindows.getLength();
654 for (; pIter != pEnd; ++pIter)
655 {
656 Sequence<PropertyValue> aValue;
657 pIter->Value >>= aValue;
658 _rMap.insert(TPropertyNameMap::value_type(pIter->Name,aValue));
659 }
660
661 }
662 // -----------------------------------------------------------------------------
GetDocElemTokenMap() const663 const SvXMLTokenMap& ODBFilter::GetDocElemTokenMap() const
664 {
665 if ( !m_pDocElemTokenMap.get() )
666 {
667 static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]=
668 {
669 { XML_NAMESPACE_OFFICE, XML_SETTINGS, XML_TOK_DOC_SETTINGS },
670 { XML_NAMESPACE_OOO, XML_SETTINGS, XML_TOK_DOC_SETTINGS },
671 { XML_NAMESPACE_OFFICE, XML_STYLES, XML_TOK_DOC_STYLES },
672 { XML_NAMESPACE_OOO, XML_STYLES, XML_TOK_DOC_STYLES },
673 { XML_NAMESPACE_OFFICE, XML_AUTOMATIC_STYLES, XML_TOK_DOC_AUTOSTYLES },
674 { XML_NAMESPACE_OOO, XML_AUTOMATIC_STYLES, XML_TOK_DOC_AUTOSTYLES },
675 { XML_NAMESPACE_OFFICE, XML_DATABASE, XML_TOK_DOC_DATABASE },
676 { XML_NAMESPACE_OOO, XML_DATABASE, XML_TOK_DOC_DATABASE },
677 { XML_NAMESPACE_OFFICE, XML_SCRIPTS, XML_TOK_DOC_SCRIPT },
678 XML_TOKEN_MAP_END
679 };
680 m_pDocElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
681 }
682 return *m_pDocElemTokenMap;
683 }
684 // -----------------------------------------------------------------------------
GetDatabaseElemTokenMap() const685 const SvXMLTokenMap& ODBFilter::GetDatabaseElemTokenMap() const
686 {
687 if ( !m_pDatabaseElemTokenMap.get() )
688 {
689 static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]=
690 {
691 { XML_NAMESPACE_DB, XML_DATASOURCE, XML_TOK_DATASOURCE },
692 { XML_NAMESPACE_DB, XML_FORMS, XML_TOK_FORMS},
693 { XML_NAMESPACE_DB, XML_REPORTS, XML_TOK_REPORTS},
694 { XML_NAMESPACE_DB, XML_QUERIES, XML_TOK_QUERIES},
695 { XML_NAMESPACE_DB, XML_TABLES, XML_TOK_TABLES},
696 { XML_NAMESPACE_DB, XML_TABLE_REPRESENTATIONS, XML_TOK_TABLES},
697 { XML_NAMESPACE_DB, XML_SCHEMA_DEFINITION, XML_TOK_SCHEMA_DEFINITION},
698 XML_TOKEN_MAP_END
699 };
700 m_pDatabaseElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
701 }
702 return *m_pDatabaseElemTokenMap;
703 }
704 // -----------------------------------------------------------------------------
GetDataSourceElemTokenMap() const705 const SvXMLTokenMap& ODBFilter::GetDataSourceElemTokenMap() const
706 {
707 if ( !m_pDataSourceElemTokenMap.get() )
708 {
709 static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]=
710 {
711 { XML_NAMESPACE_DB, XML_CONNECTION_RESOURCE, XML_TOK_CONNECTION_RESOURCE},
712 { XML_NAMESPACE_DB, XML_SUPPRESS_VERSION_COLUMNS, XML_TOK_SUPPRESS_VERSION_COLUMNS},
713 { XML_NAMESPACE_DB, XML_JAVA_DRIVER_CLASS, XML_TOK_JAVA_DRIVER_CLASS},
714 { XML_NAMESPACE_DB, XML_EXTENSION, XML_TOK_EXTENSION},
715 { XML_NAMESPACE_DB, XML_IS_FIRST_ROW_HEADER_LINE, XML_TOK_IS_FIRST_ROW_HEADER_LINE},
716 { XML_NAMESPACE_DB, XML_SHOW_DELETED, XML_TOK_SHOW_DELETED},
717 { XML_NAMESPACE_DB, XML_IS_TABLE_NAME_LENGTH_LIMITED, XML_TOK_IS_TABLE_NAME_LENGTH_LIMITED},
718 { XML_NAMESPACE_DB, XML_SYSTEM_DRIVER_SETTINGS, XML_TOK_SYSTEM_DRIVER_SETTINGS},
719 { XML_NAMESPACE_DB, XML_ENABLE_SQL92_CHECK, XML_TOK_ENABLE_SQL92_CHECK},
720 { XML_NAMESPACE_DB, XML_APPEND_TABLE_ALIAS_NAME, XML_TOK_APPEND_TABLE_ALIAS_NAME},
721 { XML_NAMESPACE_DB, XML_PARAMETER_NAME_SUBSTITUTION, XML_TOK_PARAMETER_NAME_SUBSTITUTION},
722 { XML_NAMESPACE_DB, XML_IGNORE_DRIVER_PRIVILEGES, XML_TOK_IGNORE_DRIVER_PRIVILEGES},
723 { XML_NAMESPACE_DB, XML_BOOLEAN_COMPARISON_MODE, XML_TOK_BOOLEAN_COMPARISON_MODE},
724 { XML_NAMESPACE_DB, XML_USE_CATALOG, XML_TOK_USE_CATALOG},
725 { XML_NAMESPACE_DB, XML_BASE_DN, XML_TOK_BASE_DN},
726 { XML_NAMESPACE_DB, XML_MAX_ROW_COUNT, XML_TOK_MAX_ROW_COUNT},
727 { XML_NAMESPACE_DB, XML_LOGIN, XML_TOK_LOGIN},
728 { XML_NAMESPACE_DB, XML_TABLE_FILTER, XML_TOK_TABLE_FILTER},
729 { XML_NAMESPACE_DB, XML_TABLE_TYPE_FILTER, XML_TOK_TABLE_TYPE_FILTER},
730 { XML_NAMESPACE_DB, XML_AUTO_INCREMENT, XML_TOK_AUTO_INCREMENT},
731 { XML_NAMESPACE_DB, XML_DELIMITER, XML_TOK_DELIMITER},
732 { XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTINGS, XML_TOK_DATA_SOURCE_SETTINGS},
733 { XML_NAMESPACE_DB, XML_FONT_CHARSET, XML_TOK_FONT_CHARSET},
734 // db odf 12
735 { XML_NAMESPACE_DB, XML_CONNECTION_DATA, XML_TOK_CONNECTION_DATA},
736 { XML_NAMESPACE_DB, XML_DATABASE_DESCRIPTION, XML_TOK_DATABASE_DESCRIPTION},
737 { XML_NAMESPACE_DB, XML_COMPOUND_DATABASE, XML_TOK_COMPOUND_DATABASE},
738 { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_DB_HREF},
739 { XML_NAMESPACE_DB, XML_MEDIA_TYPE, XML_TOK_MEDIA_TYPE},
740 { XML_NAMESPACE_DB, XML_TYPE, XML_TOK_DB_TYPE},
741 { XML_NAMESPACE_DB, XML_HOSTNAME, XML_TOK_HOSTNAME},
742 { XML_NAMESPACE_DB, XML_PORT, XML_TOK_PORT},
743 { XML_NAMESPACE_DB, XML_LOCAL_SOCKET, XML_TOK_LOCAL_SOCKET},
744 { XML_NAMESPACE_DB, XML_DATABASE_NAME, XML_TOK_DATABASE_NAME},
745 { XML_NAMESPACE_DB, XML_DRIVER_SETTINGS, XML_TOK_DRIVER_SETTINGS},
746 { XML_NAMESPACE_DB, XML_JAVA_CLASSPATH, XML_TOK_JAVA_CLASSPATH},
747 { XML_NAMESPACE_DB, XML_CHARACTER_SET, XML_TOK_CHARACTER_SET},
748 { XML_NAMESPACE_DB, XML_APPLICATION_CONNECTION_SETTINGS,XML_TOK_APPLICATION_CONNECTION_SETTINGS},
749 XML_TOKEN_MAP_END
750 };
751 m_pDataSourceElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
752 }
753 return *m_pDataSourceElemTokenMap;
754 }
755 // -----------------------------------------------------------------------------
GetLoginElemTokenMap() const756 const SvXMLTokenMap& ODBFilter::GetLoginElemTokenMap() const
757 {
758 if ( !m_pLoginElemTokenMap.get() )
759 {
760 static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]=
761 {
762 { XML_NAMESPACE_DB, XML_USER_NAME, XML_TOK_USER_NAME},
763 { XML_NAMESPACE_DB, XML_IS_PASSWORD_REQUIRED, XML_TOK_IS_PASSWORD_REQUIRED},
764 { XML_NAMESPACE_DB, XML_USE_SYSTEM_USER, XML_TOK_USE_SYSTEM_USER},
765 { XML_NAMESPACE_DB, XML_LOGIN_TIMEOUT, XML_TOK_LOGIN_TIMEOUT},
766 XML_TOKEN_MAP_END
767 };
768 m_pLoginElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
769 }
770 return *m_pLoginElemTokenMap;
771 }
772 // -----------------------------------------------------------------------------
GetDatabaseDescriptionElemTokenMap() const773 const SvXMLTokenMap& ODBFilter::GetDatabaseDescriptionElemTokenMap() const
774 {
775 if ( !m_pDatabaseDescriptionElemTokenMap.get() )
776 {
777 static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]=
778 {
779 { XML_NAMESPACE_DB, XML_FILE_BASED_DATABASE, XML_TOK_FILE_BASED_DATABASE},
780 { XML_NAMESPACE_DB, XML_SERVER_DATABASE, XML_TOK_SERVER_DATABASE},
781 XML_TOKEN_MAP_END
782 };
783 m_pDatabaseDescriptionElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
784 }
785 return *m_pDatabaseDescriptionElemTokenMap;
786 }
787 // -----------------------------------------------------------------------------
GetDataSourceInfoElemTokenMap() const788 const SvXMLTokenMap& ODBFilter::GetDataSourceInfoElemTokenMap() const
789 {
790 if ( !m_pDataSourceInfoElemTokenMap.get() )
791 {
792 static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]=
793 {
794 { XML_NAMESPACE_DB, XML_ADDITIONAL_COLUMN_STATEMENT,XML_TOK_ADDITIONAL_COLUMN_STATEMENT},
795 { XML_NAMESPACE_DB, XML_ROW_RETRIEVING_STATEMENT, XML_TOK_ROW_RETRIEVING_STATEMENT},
796 { XML_NAMESPACE_DB, XML_STRING, XML_TOK_STRING},
797 { XML_NAMESPACE_DB, XML_FIELD, XML_TOK_FIELD},
798 { XML_NAMESPACE_DB, XML_DECIMAL, XML_TOK_DECIMAL},
799 { XML_NAMESPACE_DB, XML_THOUSAND, XML_TOK_THOUSAND},
800 { XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING, XML_TOK_DATA_SOURCE_SETTING},
801 { XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_VALUE, XML_TOK_DATA_SOURCE_SETTING_VALUE},
802 { XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_IS_LIST,XML_TOK_DATA_SOURCE_SETTING_IS_LIST},
803 { XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_TYPE, XML_TOK_DATA_SOURCE_SETTING_TYPE},
804 { XML_NAMESPACE_DB, XML_DATA_SOURCE_SETTING_NAME, XML_TOK_DATA_SOURCE_SETTING_NAME},
805 { XML_NAMESPACE_DB, XML_FONT_CHARSET, XML_TOK_FONT_CHARSET},
806 { XML_NAMESPACE_DB, XML_ENCODING, XML_TOK_ENCODING},
807 XML_TOKEN_MAP_END
808 };
809 m_pDataSourceInfoElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
810 }
811 return *m_pDataSourceInfoElemTokenMap;
812 }
813 // -----------------------------------------------------------------------------
GetDocumentsElemTokenMap() const814 const SvXMLTokenMap& ODBFilter::GetDocumentsElemTokenMap() const
815 {
816 if ( !m_pDocumentsElemTokenMap.get() )
817 {
818 static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]=
819 {
820 { XML_NAMESPACE_DB, XML_COMPONENT, XML_TOK_COMPONENT},
821 { XML_NAMESPACE_DB, XML_COMPONENT_COLLECTION, XML_TOK_COMPONENT_COLLECTION},
822 { XML_NAMESPACE_DB, XML_QUERY_COLLECTION, XML_TOK_QUERY_COLLECTION},
823 { XML_NAMESPACE_DB, XML_QUERY, XML_TOK_QUERY},
824 { XML_NAMESPACE_DB, XML_TABLE, XML_TOK_TABLE},
825 { XML_NAMESPACE_DB, XML_TABLE_REPRESENTATION, XML_TOK_TABLE},
826 { XML_NAMESPACE_DB, XML_COLUMN, XML_TOK_COLUMN},
827 XML_TOKEN_MAP_END
828 };
829 m_pDocumentsElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
830 }
831 return *m_pDocumentsElemTokenMap;
832 }
833 // -----------------------------------------------------------------------------
GetComponentElemTokenMap() const834 const SvXMLTokenMap& ODBFilter::GetComponentElemTokenMap() const
835 {
836 if ( !m_pComponentElemTokenMap.get() )
837 {
838 static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]=
839 {
840 { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_HREF },
841 { XML_NAMESPACE_XLINK, XML_TYPE, XML_TOK_TYPE },
842 { XML_NAMESPACE_XLINK, XML_SHOW, XML_TOK_SHOW },
843 { XML_NAMESPACE_XLINK, XML_ACTUATE, XML_TOK_ACTUATE},
844 { XML_NAMESPACE_DB, XML_AS_TEMPLATE, XML_TOK_AS_TEMPLATE },
845 { XML_NAMESPACE_DB, XML_NAME, XML_TOK_COMPONENT_NAME },
846 XML_TOKEN_MAP_END
847 };
848 m_pComponentElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
849 }
850 return *m_pComponentElemTokenMap;
851 }
852 // -----------------------------------------------------------------------------
GetQueryElemTokenMap() const853 const SvXMLTokenMap& ODBFilter::GetQueryElemTokenMap() const
854 {
855 if ( !m_pQueryElemTokenMap.get() )
856 {
857 static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]=
858 {
859 { XML_NAMESPACE_DB, XML_COMMAND, XML_TOK_COMMAND },
860 { XML_NAMESPACE_DB, XML_ESCAPE_PROCESSING, XML_TOK_ESCAPE_PROCESSING },
861 { XML_NAMESPACE_DB, XML_NAME, XML_TOK_QUERY_NAME },
862 { XML_NAMESPACE_DB, XML_FILTER_STATEMENT, XML_TOK_FILTER_STATEMENT },
863 { XML_NAMESPACE_DB, XML_ORDER_STATEMENT, XML_TOK_ORDER_STATEMENT },
864 { XML_NAMESPACE_DB, XML_CATALOG_NAME, XML_TOK_CATALOG_NAME },
865 { XML_NAMESPACE_DB, XML_SCHEMA_NAME, XML_TOK_SCHEMA_NAME },
866 { XML_NAMESPACE_DB, XML_STYLE_NAME, XML_TOK_STYLE_NAME},
867 { XML_NAMESPACE_DB, XML_APPLY_FILTER, XML_TOK_APPLY_FILTER},
868 { XML_NAMESPACE_DB, XML_APPLY_ORDER, XML_TOK_APPLY_ORDER},
869 { XML_NAMESPACE_DB, XML_COLUMNS, XML_TOK_COLUMNS},
870 XML_TOKEN_MAP_END
871 };
872 m_pQueryElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
873 }
874 return *m_pQueryElemTokenMap;
875 }
876 // -----------------------------------------------------------------------------
GetColumnElemTokenMap() const877 const SvXMLTokenMap& ODBFilter::GetColumnElemTokenMap() const
878 {
879 if ( !m_pColumnElemTokenMap.get() )
880 {
881 static __FAR_DATA SvXMLTokenMapEntry aElemTokenMap[]=
882 {
883 { XML_NAMESPACE_DB, XML_NAME, XML_TOK_COLUMN_NAME },
884 { XML_NAMESPACE_DB, XML_STYLE_NAME, XML_TOK_COLUMN_STYLE_NAME },
885 { XML_NAMESPACE_DB, XML_HELP_MESSAGE, XML_TOK_COLUMN_HELP_MESSAGE },
886 { XML_NAMESPACE_DB, XML_VISIBILITY, XML_TOK_COLUMN_VISIBILITY },
887 { XML_NAMESPACE_DB, XML_DEFAULT_VALUE, XML_TOK_COLUMN_DEFAULT_VALUE },
888 { XML_NAMESPACE_DB, XML_TYPE_NAME, XML_TOK_COLUMN_TYPE_NAME },
889 { XML_NAMESPACE_DB, XML_VISIBLE, XML_TOK_COLUMN_VISIBLE },
890 { XML_NAMESPACE_DB, XML_DEFAULT_CELL_STYLE_NAME, XML_TOK_DEFAULT_CELL_STYLE_NAME },
891 XML_TOKEN_MAP_END
892 };
893 m_pColumnElemTokenMap.reset(new SvXMLTokenMap( aElemTokenMap ));
894 }
895 return *m_pColumnElemTokenMap;
896 }
897 // -----------------------------------------------------------------------------
CreateStylesContext(sal_uInt16 _nPrefix,const::rtl::OUString & rLocalName,const uno::Reference<XAttributeList> & xAttrList,sal_Bool bIsAutoStyle)898 SvXMLImportContext* ODBFilter::CreateStylesContext(sal_uInt16 _nPrefix,const ::rtl::OUString& rLocalName,
899 const uno::Reference< XAttributeList>& xAttrList, sal_Bool bIsAutoStyle )
900 {
901 SvXMLImportContext *pContext = NULL;
902 if (!pContext)
903 {
904 pContext = new OTableStylesContext(*this, _nPrefix, rLocalName, xAttrList, bIsAutoStyle);
905 if (bIsAutoStyle)
906 //xAutoStyles = pContext;
907 SetAutoStyles((SvXMLStylesContext*)pContext);
908 else
909 //xStyles = pContext;
910 SetStyles((SvXMLStylesContext*)pContext);
911 }
912 return pContext;
913 }
914 // -----------------------------------------------------------------------------
CreateScriptContext(const::rtl::OUString & _rLocalName)915 SvXMLImportContext* ODBFilter::CreateScriptContext( const ::rtl::OUString& _rLocalName )
916 {
917 return new XMLScriptContext( *this, XML_NAMESPACE_OFFICE, _rLocalName, GetModel() );
918 }
919 // -----------------------------------------------------------------------------
GetTableStylesPropertySetMapper() const920 UniReference < XMLPropertySetMapper > ODBFilter::GetTableStylesPropertySetMapper() const
921 {
922 if ( !m_xTableStylesPropertySetMapper.is() )
923 {
924 m_xTableStylesPropertySetMapper = OXMLHelper::GetTableStylesPropertySetMapper();
925 }
926 return m_xTableStylesPropertySetMapper;
927 }
928 // -----------------------------------------------------------------------------
GetColumnStylesPropertySetMapper() const929 UniReference < XMLPropertySetMapper > ODBFilter::GetColumnStylesPropertySetMapper() const
930 {
931 if ( !m_xColumnStylesPropertySetMapper.is() )
932 {
933 m_xColumnStylesPropertySetMapper = OXMLHelper::GetColumnStylesPropertySetMapper();
934 }
935 return m_xColumnStylesPropertySetMapper;
936 }
937 // -----------------------------------------------------------------------------
GetCellStylesPropertySetMapper() const938 UniReference < XMLPropertySetMapper > ODBFilter::GetCellStylesPropertySetMapper() const
939 {
940 if ( !m_xCellStylesPropertySetMapper.is() )
941 {
942 m_xCellStylesPropertySetMapper = OXMLHelper::GetCellStylesPropertySetMapper();
943 }
944 return m_xCellStylesPropertySetMapper;
945 }
946 // -----------------------------------------------------------------------------
setPropertyInfo()947 void ODBFilter::setPropertyInfo()
948 {
949 Reference<XPropertySet> xDataSource(getDataSource());
950 if ( !xDataSource.is() )
951 return;
952
953 ::connectivity::DriversConfig aDriverConfig(getServiceFactory());
954 const ::rtl::OUString sURL = ::comphelper::getString(xDataSource->getPropertyValue(PROPERTY_URL));
955 ::comphelper::NamedValueCollection aDataSourceSettings = aDriverConfig.getProperties( sURL );
956
957 Sequence<PropertyValue> aInfo;
958 if ( !m_aInfoSequence.empty() )
959 aInfo = Sequence<PropertyValue>(&(*m_aInfoSequence.begin()),m_aInfoSequence.size());
960 aDataSourceSettings.merge( ::comphelper::NamedValueCollection( aInfo ), true );
961
962 aDataSourceSettings >>= aInfo;
963 if ( aInfo.getLength() )
964 {
965 try
966 {
967 xDataSource->setPropertyValue(PROPERTY_INFO,makeAny(aInfo));
968 }
969 catch(Exception)
970 {
971 DBG_UNHANDLED_EXCEPTION();
972 }
973 }
974 }
975 // -----------------------------------------------------------------------------
976 }// dbaxml
977 // -----------------------------------------------------------------------------
978