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