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

Generated by: LCOV version 1.10