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_basic.hxx"
26 #include <com/sun/star/container/XNameContainer.hpp>
27 #include <com/sun/star/xml/sax/XParser.hpp>
28 #include <com/sun/star/xml/sax/InputSource.hpp>
29 #include <com/sun/star/io/XOutputStream.hpp>
30 #include <com/sun/star/io/XInputStream.hpp>
31 #include <com/sun/star/embed/ElementModes.hpp>
32 #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
33 #include <com/sun/star/beans/XPropertySet.hpp>
34 #include <com/sun/star/io/XActiveDataSource.hpp>
35 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
36 #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
37 #include "com/sun/star/resource/XStringResourceWithStorage.hpp"
38 #include "com/sun/star/resource/XStringResourceWithLocation.hpp"
39 #include "dlgcont.hxx"
40 #include "sbmodule.hxx"
41 #include <comphelper/processfactory.hxx>
42 #include <unotools/streamwrap.hxx>
43 #include <osl/mutex.hxx>
44
45 #include <vcl/svapp.hxx>
46 #include <vcl/settings.hxx>
47 #include <unotools/pathoptions.hxx>
48 #include <xmlscript/xmldlg_imexp.hxx>
49 #include <cppuhelper/factory.hxx>
50 #include <svtools/sfxecode.hxx>
51 #include <svtools/ehdl.hxx>
52
53
54 namespace basic
55 {
56
57 using namespace com::sun::star::document;
58 using namespace com::sun::star::container;
59 using namespace com::sun::star::io;
60 using namespace com::sun::star::uno;
61 using namespace com::sun::star::ucb;
62 using namespace com::sun::star::lang;
63 using namespace com::sun::star::script;
64 using namespace com::sun::star::xml::sax;
65 using namespace com::sun::star;
66 using namespace cppu;
67 using namespace rtl;
68 using namespace osl;
69
70 using com::sun::star::uno::Reference;
71
72 //============================================================================
73 // Implementation class SfxDialogLibraryContainer
74
getInfoFileName() const75 const sal_Char* SAL_CALL SfxDialogLibraryContainer::getInfoFileName() const { return "dialog"; }
getOldInfoFileName() const76 const sal_Char* SAL_CALL SfxDialogLibraryContainer::getOldInfoFileName() const { return "dialogs"; }
getLibElementFileExtension() const77 const sal_Char* SAL_CALL SfxDialogLibraryContainer::getLibElementFileExtension() const { return "xdl"; }
getLibrariesDir() const78 const sal_Char* SAL_CALL SfxDialogLibraryContainer::getLibrariesDir() const { return "Dialogs"; }
79
80 // Ctor for service
SfxDialogLibraryContainer(void)81 SfxDialogLibraryContainer::SfxDialogLibraryContainer( void )
82 {
83 // all initialisation has to be done
84 // by calling XInitialization::initialize
85 }
86
SfxDialogLibraryContainer(const uno::Reference<embed::XStorage> & xStorage)87 SfxDialogLibraryContainer::SfxDialogLibraryContainer( const uno::Reference< embed::XStorage >& xStorage )
88 {
89 init( OUString(), xStorage );
90 }
91
92 // Methods to get library instances of the correct type
implCreateLibrary(const::rtl::OUString & aName)93 SfxLibrary* SfxDialogLibraryContainer::implCreateLibrary( const ::rtl::OUString& aName )
94 {
95 SfxLibrary* pRet = new SfxDialogLibrary( maModifiable, aName, mxMSF, mxSFI, this );
96 return pRet;
97 }
98
implCreateLibraryLink(const::rtl::OUString & aName,const OUString & aLibInfoFileURL,const OUString & StorageURL,sal_Bool ReadOnly)99 SfxLibrary* SfxDialogLibraryContainer::implCreateLibraryLink
100 ( const ::rtl::OUString& aName, const OUString& aLibInfoFileURL,
101 const OUString& StorageURL, sal_Bool ReadOnly )
102 {
103 SfxLibrary* pRet = new SfxDialogLibrary
104 ( maModifiable, aName, mxMSF, mxSFI, aLibInfoFileURL, StorageURL, ReadOnly, this );
105 return pRet;
106 }
107
createEmptyLibraryElement(void)108 Any SAL_CALL SfxDialogLibraryContainer::createEmptyLibraryElement( void )
109 {
110 Reference< XInputStreamProvider > xISP;
111 Any aRetAny;
112 aRetAny <<= xISP;
113 return aRetAny;
114 }
115
isLibraryElementValid(Any aElement) const116 bool SAL_CALL SfxDialogLibraryContainer::isLibraryElementValid( Any aElement ) const
117 {
118 return SfxDialogLibrary::containsValidDialog( aElement );
119 }
120
writeOasis2OOoLibraryElement(Reference<XInputStream> xInput,Reference<XOutputStream> xOutput)121 bool writeOasis2OOoLibraryElement(
122 Reference< XInputStream > xInput, Reference< XOutputStream > xOutput )
123 {
124 Reference< XMultiServiceFactory > xMSF(
125 comphelper::getProcessServiceFactory() );
126
127 Reference< XComponentContext > xContext;
128 Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY );
129 OSL_ASSERT( xProps.is() );
130 OSL_VERIFY( xProps->getPropertyValue(
131 OUString::createFromAscii(("DefaultContext")) ) >>= xContext );
132
133 Reference< lang::XMultiComponentFactory > xSMgr(
134 xContext->getServiceManager() );
135
136 if (! xSMgr.is())
137 {
138 return sal_False;
139 }
140
141 Reference< xml::sax::XParser > xParser(
142 xSMgr->createInstanceWithContext(
143 OUString( RTL_CONSTASCII_USTRINGPARAM(
144 "com.sun.star.xml.sax.Parser" ) ),
145 xContext ),
146 UNO_QUERY );
147
148 Reference< xml::sax::XExtendedDocumentHandler > xWriter(
149 xSMgr->createInstanceWithContext(
150 OUString( RTL_CONSTASCII_USTRINGPARAM(
151 "com.sun.star.xml.sax.Writer" ) ),
152 xContext ),
153 UNO_QUERY );
154
155 Reference< io::XActiveDataSource > xSource( xWriter, UNO_QUERY );
156 xSource->setOutputStream( xOutput );
157
158 if ( !xParser.is() || !xWriter.is() )
159 {
160 return sal_False;
161 }
162
163 Sequence<Any> aArgs( 1 );
164 aArgs[0] <<= xWriter;
165
166 Reference< xml::sax::XDocumentHandler > xHandler(
167 xSMgr->createInstanceWithArgumentsAndContext(
168 OUString( RTL_CONSTASCII_USTRINGPARAM(
169 "com.sun.star.comp.Oasis2OOoTransformer" ) ),
170 aArgs, xContext ),
171 UNO_QUERY );
172
173 xParser->setDocumentHandler( xHandler );
174
175 xml::sax::InputSource source;
176 source.aInputStream = xInput;
177 source.sSystemId = OUString::createFromAscii( "virtual file" );
178
179 xParser->parseStream( source );
180
181 return sal_True;
182 }
183
writeLibraryElement(const Reference<XNameContainer> & xLib,const OUString & aElementName,const Reference<XOutputStream> & xOutput)184 void SAL_CALL SfxDialogLibraryContainer::writeLibraryElement
185 (
186 const Reference < XNameContainer >& xLib,
187 const OUString& aElementName,
188 const Reference< XOutputStream >& xOutput
189 )
190 {
191 Any aElement = xLib->getByName( aElementName );
192 Reference< XInputStreamProvider > xISP;
193 aElement >>= xISP;
194 if( !xISP.is() )
195 return;
196
197 Reference< XInputStream > xInput( xISP->createInputStream() );
198
199 bool bComplete = sal_False;
200 if ( mbOasis2OOoFormat )
201 {
202 bComplete = writeOasis2OOoLibraryElement( xInput, xOutput );
203 }
204
205 if ( bComplete == sal_False )
206 {
207 Sequence< sal_Int8 > bytes;
208 sal_Int32 nRead = xInput->readBytes( bytes, xInput->available() );
209 for (;;)
210 {
211 if( nRead )
212 xOutput->writeBytes( bytes );
213
214 nRead = xInput->readBytes( bytes, 1024 );
215 if (! nRead)
216 break;
217 }
218 }
219 xInput->closeInput();
220 }
221
storeLibrariesToStorage(const uno::Reference<embed::XStorage> & xStorage)222 void SfxDialogLibraryContainer::storeLibrariesToStorage( const uno::Reference< embed::XStorage >& xStorage )
223 {
224 LibraryContainerMethodGuard aGuard( *this );
225 mbOasis2OOoFormat = sal_False;
226
227 if ( mxStorage.is() && xStorage.is() )
228 {
229 try
230 {
231 long nSource = SotStorage::GetVersion( mxStorage );
232 long nTarget = SotStorage::GetVersion( xStorage );
233
234 if ( nSource == SOFFICE_FILEFORMAT_CURRENT &&
235 nTarget != SOFFICE_FILEFORMAT_CURRENT )
236 {
237 mbOasis2OOoFormat = sal_True;
238 }
239 }
240 catch ( Exception& )
241 {
242 // if we cannot get the version then the
243 // Oasis2OOoTransformer will not be used
244 OSL_ASSERT(sal_False);
245 }
246 }
247
248 SfxLibraryContainer::storeLibrariesToStorage( xStorage );
249
250 mbOasis2OOoFormat = sal_False;
251 }
252
253
importLibraryElement(const Reference<XNameContainer> &,const OUString &,const OUString & aFile,const uno::Reference<io::XInputStream> & xElementStream)254 Any SAL_CALL SfxDialogLibraryContainer::importLibraryElement
255 ( const Reference < XNameContainer >& /*xLib*/,
256 const OUString& /*aElementName */, const OUString& aFile,
257 const uno::Reference< io::XInputStream >& xElementStream )
258 {
259 Any aRetAny;
260
261 // TODO: Member because later it will be a component
262 //Reference< XMultiServiceFactory > xMSF( comphelper::getProcessServiceFactory() );
263 //if( !xMSF.is() )
264 //{
265 // OSL_ENSURE( 0, "### couldn't get ProcessServiceFactory\n" );
266 // return aRetAny;
267 //}
268
269 Reference< XParser > xParser( mxMSF->createInstance(
270 OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Parser") ) ), UNO_QUERY );
271 if( !xParser.is() )
272 {
273 OSL_ENSURE( 0, "### couldn't create sax parser component\n" );
274 return aRetAny;
275 }
276
277 Reference< XNameContainer > xDialogModel( mxMSF->createInstance
278 ( OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), UNO_QUERY );
279 if( !xDialogModel.is() )
280 {
281 OSL_ENSURE( 0, "### couldn't create com.sun.star.awt.UnoControlDialogModel component\n" );
282 return aRetAny;
283 }
284
285 // Read from storage?
286 sal_Bool bStorage = xElementStream.is();
287 Reference< XInputStream > xInput;
288
289 if( bStorage )
290 {
291 xInput = xElementStream;
292 }
293 else
294 {
295 try
296 {
297 xInput = mxSFI->openFileRead( aFile );
298 }
299 catch( Exception& )
300 //catch( Exception& e )
301 {
302 // TODO:
303 //throw WrappedTargetException( e );
304 }
305 }
306 if( !xInput.is() )
307 return aRetAny;
308
309 Reference< XComponentContext > xContext;
310 Reference< beans::XPropertySet > xProps( mxMSF, UNO_QUERY );
311 OSL_ASSERT( xProps.is() );
312 OSL_VERIFY( xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
313
314 InputSource source;
315 source.aInputStream = xInput;
316 source.sSystemId = aFile;
317
318 try {
319 // start parsing
320 xParser->setDocumentHandler( ::xmlscript::importDialogModel( xDialogModel, xContext ) );
321 xParser->parseStream( source );
322 }
323 catch( Exception& )
324 {
325 OSL_ENSURE( 0, "Parsing error\n" );
326 SfxErrorContext aEc( ERRCTX_SFX_LOADBASIC, aFile );
327 sal_uIntPtr nErrorCode = ERRCODE_IO_GENERAL;
328 ErrorHandler::HandleError( nErrorCode );
329 return aRetAny;
330 }
331
332 // Create InputStream, TODO: Implement own InputStreamProvider
333 // to avoid creating the DialogModel here!
334 Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext );
335 aRetAny <<= xISP;
336 return aRetAny;
337 }
338
importFromOldStorage(const OUString &)339 void SAL_CALL SfxDialogLibraryContainer::importFromOldStorage( const OUString& )
340 {
341 // Nothing to do here, old dialogs cannot be imported
342 }
343
createInstanceImpl(void)344 SfxLibraryContainer* SfxDialogLibraryContainer::createInstanceImpl( void )
345 {
346 return new SfxDialogLibraryContainer();
347 }
348
349
350 static OUString aResourceFileNameBase = OUString::createFromAscii( "DialogStrings" );
351 static OUString aResourceFileCommentBase = OUString::createFromAscii( "# Strings for Dialog Library " );
352
353 // Resource handling
354 Reference< ::com::sun::star::resource::XStringResourcePersistence >
implCreateStringResource(SfxDialogLibrary * pDialogLibrary)355 SfxDialogLibraryContainer::implCreateStringResource( SfxDialogLibrary* pDialogLibrary )
356 {
357 Reference< resource::XStringResourcePersistence > xRet;
358 OUString aLibName = pDialogLibrary->getName();
359 bool bReadOnly = pDialogLibrary->mbReadOnly;
360
361 // get ui locale
362 ::com::sun ::star::lang::Locale aLocale = Application::GetSettings().GetUILocale();
363
364 OUString aComment = aResourceFileCommentBase;
365 aComment += aLibName;
366
367 sal_Bool bStorage = mxStorage.is();
368 if( bStorage )
369 {
370 Sequence<Any> aArgs( 5 );
371 aArgs[1] <<= bReadOnly;
372 aArgs[2] <<= aLocale;
373 aArgs[3] <<= aResourceFileNameBase;
374 aArgs[4] <<= aComment;
375
376 // TODO: Ctor
377 xRet = Reference< resource::XStringResourcePersistence >( mxMSF->createInstance
378 ( OUString::createFromAscii( "com.sun.star.resource.StringResourceWithStorage" ) ), UNO_QUERY );
379
380 uno::Reference< embed::XStorage > xLibrariesStor;
381 uno::Reference< embed::XStorage > xLibraryStor;
382 try {
383 xLibrariesStor = mxStorage->openStorageElement( maLibrariesDir, embed::ElementModes::READ );
384 // TODO: Should be READWRITE with new storage concept using store() instead of storeTo()
385 if ( !xLibrariesStor.is() )
386 throw uno::RuntimeException();
387
388 xLibraryStor = xLibrariesStor->openStorageElement( aLibName, embed::ElementModes::READ );
389 // TODO: Should be READWRITE with new storage concept using store() instead of storeTo()
390 if ( !xLibraryStor.is() )
391 throw uno::RuntimeException();
392
393 aArgs[0] <<= xLibraryStor;
394 }
395 catch( uno::Exception& )
396 {
397 // TODO: Error handling?
398 return xRet;
399 }
400
401 // TODO: Ctor
402 if( xRet.is() )
403 {
404 Reference< XInitialization > xInit( xRet, UNO_QUERY );
405 if( xInit.is() )
406 xInit->initialize( aArgs );
407 }
408 }
409 else
410 {
411 Sequence<Any> aArgs( 6 );
412
413 OUString aLocation = createAppLibraryFolder( pDialogLibrary, aLibName );
414 aArgs[0] <<= aLocation;
415 aArgs[1] <<= bReadOnly;
416 aArgs[2] <<= aLocale;
417 aArgs[3] <<= aResourceFileNameBase;
418 aArgs[4] <<= aComment;
419
420 // TODO: Real handler?
421 Reference< task::XInteractionHandler > xDummyHandler;
422 aArgs[5] <<= xDummyHandler;
423
424 // TODO: Ctor
425 xRet = Reference< resource::XStringResourcePersistence >( mxMSF->createInstance
426 ( OUString::createFromAscii( "com.sun.star.resource.StringResourceWithLocation" ) ), UNO_QUERY );
427
428 // TODO: Ctor
429 if( xRet.is() )
430 {
431 Reference< XInitialization > xInit( xRet, UNO_QUERY );
432 if( xInit.is() )
433 xInit->initialize( aArgs );
434 }
435 }
436
437 return xRet;
438 }
439
onNewRootStorage()440 void SfxDialogLibraryContainer::onNewRootStorage()
441 {
442 // the library container is not modified, go through the libraries and check whether they are modified
443 Sequence< OUString > aNames = maNameContainer.getElementNames();
444 const OUString* pNames = aNames.getConstArray();
445 sal_Int32 nNameCount = aNames.getLength();
446
447 for( sal_Int32 i = 0 ; i < nNameCount ; i++ )
448 {
449 OUString aName = pNames[ i ];
450 SfxDialogLibrary* pDialogLibrary = static_cast<SfxDialogLibrary*>( getImplLib( aName ) );
451
452 Reference< resource::XStringResourcePersistence > xStringResourcePersistence =
453 pDialogLibrary->getStringResourcePersistence();
454
455 if( xStringResourcePersistence.is() )
456 {
457 Reference< embed::XStorage > xLibrariesStor;
458 Reference< embed::XStorage > xLibraryStor;
459 try {
460 xLibrariesStor = mxStorage->openStorageElement( maLibrariesDir, embed::ElementModes::READWRITE );
461 if ( !xLibrariesStor.is() )
462 throw uno::RuntimeException();
463
464 OUString aLibName = pDialogLibrary->getName();
465 xLibraryStor = xLibrariesStor->openStorageElement( aLibName, embed::ElementModes::READWRITE );
466 if ( !xLibraryStor.is() )
467 throw uno::RuntimeException();
468
469 Reference< resource::XStringResourceWithStorage >
470 xStringResourceWithStorage( xStringResourcePersistence, UNO_QUERY );
471 if( xStringResourceWithStorage.is() )
472 xStringResourceWithStorage->setStorage( xLibraryStor );
473 }
474 catch( uno::Exception& )
475 {
476 // TODO: Error handling?
477 }
478 }
479 }
480 }
481
482
483 //============================================================================
484 // Service
485
createRegistryInfo_SfxDialogLibraryContainer()486 void createRegistryInfo_SfxDialogLibraryContainer()
487 {
488 static OAutoRegistration< SfxDialogLibraryContainer > aAutoRegistration;
489 }
490
getImplementationName()491 ::rtl::OUString SAL_CALL SfxDialogLibraryContainer::getImplementationName( )
492 {
493 return getImplementationName_static();
494 }
495
getSupportedServiceNames()496 Sequence< ::rtl::OUString > SAL_CALL SfxDialogLibraryContainer::getSupportedServiceNames( )
497 {
498 return getSupportedServiceNames_static();
499 }
500
getSupportedServiceNames_static()501 Sequence< OUString > SfxDialogLibraryContainer::getSupportedServiceNames_static()
502 {
503 Sequence< OUString > aServiceNames( 2 );
504 aServiceNames[0] = OUString::createFromAscii( "com.sun.star.script.DocumentDialogLibraryContainer" );
505 // plus, for compatibility:
506 aServiceNames[1] = OUString::createFromAscii( "com.sun.star.script.DialogLibraryContainer" );
507 return aServiceNames;
508 }
509
getImplementationName_static()510 OUString SfxDialogLibraryContainer::getImplementationName_static()
511 {
512 static OUString aImplName;
513 static sal_Bool bNeedsInit = sal_True;
514
515 MutexGuard aGuard( Mutex::getGlobalMutex() );
516 if( bNeedsInit )
517 {
518 aImplName = OUString::createFromAscii( "com.sun.star.comp.sfx2.DialogLibraryContainer" );
519 bNeedsInit = sal_False;
520 }
521 return aImplName;
522 }
523
Create(const Reference<XComponentContext> &)524 Reference< XInterface > SAL_CALL SfxDialogLibraryContainer::Create( const Reference< XComponentContext >& )
525 {
526 Reference< XInterface > xRet =
527 static_cast< XInterface* >( static_cast< OWeakObject* >(new SfxDialogLibraryContainer()) );
528 return xRet;
529 }
530
531
532 //============================================================================
533 // Implementation class SfxDialogLibrary
534
535 // Ctor
SfxDialogLibrary(ModifiableHelper & _rModifiable,const::rtl::OUString & aName,const Reference<XMultiServiceFactory> & xMSF,const Reference<XSimpleFileAccess> & xSFI,SfxDialogLibraryContainer * pParent)536 SfxDialogLibrary::SfxDialogLibrary( ModifiableHelper& _rModifiable,
537 const ::rtl::OUString& aName,
538 const Reference< XMultiServiceFactory >& xMSF,
539 const Reference< XSimpleFileAccess >& xSFI,
540 SfxDialogLibraryContainer* pParent )
541 : SfxLibrary( _rModifiable, getCppuType( (const Reference< XInputStreamProvider > *)0 ), xMSF, xSFI )
542 , m_pParent( pParent )
543 , m_aName( aName )
544 {
545 }
546
SfxDialogLibrary(ModifiableHelper & _rModifiable,const::rtl::OUString & aName,const Reference<XMultiServiceFactory> & xMSF,const Reference<XSimpleFileAccess> & xSFI,const OUString & aLibInfoFileURL,const OUString & aStorageURL,sal_Bool ReadOnly,SfxDialogLibraryContainer * pParent)547 SfxDialogLibrary::SfxDialogLibrary( ModifiableHelper& _rModifiable,
548 const ::rtl::OUString& aName,
549 const Reference< XMultiServiceFactory >& xMSF,
550 const Reference< XSimpleFileAccess >& xSFI,
551 const OUString& aLibInfoFileURL,
552 const OUString& aStorageURL,
553 sal_Bool ReadOnly,
554 SfxDialogLibraryContainer* pParent )
555 : SfxLibrary( _rModifiable, getCppuType( (const Reference< XInputStreamProvider > *)0 ),
556 xMSF, xSFI, aLibInfoFileURL, aStorageURL, ReadOnly)
557 , m_pParent( pParent )
558 , m_aName( aName )
559 {
560 }
561
562 IMPLEMENT_FORWARD_XINTERFACE2( SfxDialogLibrary, SfxLibrary, SfxDialogLibrary_BASE );
563 IMPLEMENT_FORWARD_XTYPEPROVIDER2( SfxDialogLibrary, SfxLibrary, SfxDialogLibrary_BASE );
564
565 // Provide modify state including resources
isModified(void)566 sal_Bool SfxDialogLibrary::isModified( void )
567 {
568 sal_Bool bRet = implIsModified();
569
570 if( !bRet && m_xStringResourcePersistence.is() )
571 bRet = m_xStringResourcePersistence->isModified();
572 // else: Resources not accessed so far -> not modified
573
574 return bRet;
575 }
576
storeResources(void)577 void SfxDialogLibrary::storeResources( void )
578 {
579 if( m_xStringResourcePersistence.is() )
580 m_xStringResourcePersistence->store();
581 }
582
storeResourcesAsURL(const::rtl::OUString & URL,const::rtl::OUString & NewName)583 void SfxDialogLibrary::storeResourcesAsURL
584 ( const ::rtl::OUString& URL, const ::rtl::OUString& NewName )
585 {
586 OUString aComment = aResourceFileCommentBase;
587 m_aName = NewName;
588 aComment += m_aName;
589
590 if( m_xStringResourcePersistence.is() )
591 {
592 m_xStringResourcePersistence->setComment( aComment );
593
594 Reference< resource::XStringResourceWithLocation >
595 xStringResourceWithLocation( m_xStringResourcePersistence, UNO_QUERY );
596 if( xStringResourceWithLocation.is() )
597 xStringResourceWithLocation->storeAsURL( URL );
598 }
599 }
600
storeResourcesToURL(const OUString & URL,const Reference<task::XInteractionHandler> & xHandler)601 void SfxDialogLibrary::storeResourcesToURL( const OUString& URL,
602 const Reference< task::XInteractionHandler >& xHandler )
603 {
604 OUString aComment = aResourceFileCommentBase;
605 aComment += m_aName;
606
607 if( m_xStringResourcePersistence.is() )
608 {
609 m_xStringResourcePersistence->storeToURL
610 ( URL, aResourceFileNameBase, aComment, xHandler );
611 }
612 }
613
storeResourcesToStorage(const::com::sun::star::uno::Reference<::com::sun::star::embed::XStorage> & xStorage)614 void SfxDialogLibrary::storeResourcesToStorage( const ::com::sun::star::uno::Reference
615 < ::com::sun::star::embed::XStorage >& xStorage )
616 {
617 OUString aComment = aResourceFileCommentBase;
618 aComment += m_aName;
619
620 if( m_xStringResourcePersistence.is() )
621 {
622 m_xStringResourcePersistence->storeToStorage
623 ( xStorage, aResourceFileNameBase, aComment );
624 }
625 }
626
627
628 // XStringResourceSupplier
629 Reference< resource::XStringResourceResolver >
getStringResource()630 SAL_CALL SfxDialogLibrary::getStringResource( )
631 {
632 if( !m_xStringResourcePersistence.is() )
633 m_xStringResourcePersistence = m_pParent->implCreateStringResource( this );
634
635 Reference< resource::XStringResourceResolver > xRet( m_xStringResourcePersistence, UNO_QUERY );
636 return xRet;
637 }
638
containsValidDialog(const::com::sun::star::uno::Any & aElement)639 bool SfxDialogLibrary::containsValidDialog( const ::com::sun::star::uno::Any& aElement )
640 {
641 Reference< XInputStreamProvider > xISP;
642 aElement >>= xISP;
643 return xISP.is();
644 }
645
isLibraryElementValid(::com::sun::star::uno::Any aElement) const646 bool SAL_CALL SfxDialogLibrary::isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const
647 {
648 return SfxDialogLibrary::containsValidDialog( aElement );
649 }
650
651 }
652 //============================================================================
653