LCOV - code coverage report
Current view: top level - basic/source/uno - dlgcont.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 112 248 45.2 %
Date: 2015-06-13 12:38:46 Functions: 20 37 54.1 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11