LCOV - code coverage report
Current view: top level - basic/source/uno - dlgcont.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 124 257 48.2 %
Date: 2014-11-03 Functions: 25 42 59.5 %
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 "sbservices.hxx"
      37             : #include <comphelper/processfactory.hxx>
      38             : #include <unotools/streamwrap.hxx>
      39             : #include <osl/mutex.hxx>
      40             : 
      41             : #include <vcl/svapp.hxx>
      42             : #include <vcl/settings.hxx>
      43             : #include <unotools/pathoptions.hxx>
      44             : #include <xmlscript/xmldlg_imexp.hxx>
      45             : #include <cppuhelper/factory.hxx>
      46             : #include <svtools/sfxecode.hxx>
      47             : #include <svtools/ehdl.hxx>
      48             : #include <svtools/grfmgr.hxx>
      49             : 
      50             : namespace basic
      51             : {
      52             : 
      53             : using namespace com::sun::star::document;
      54             : using namespace com::sun::star::container;
      55             : using namespace com::sun::star::io;
      56             : using namespace com::sun::star::uno;
      57             : using namespace com::sun::star::ucb;
      58             : using namespace com::sun::star::lang;
      59             : using namespace com::sun::star::script;
      60             : using namespace com::sun::star::xml::sax;
      61             : using namespace com::sun::star;
      62             : using namespace cppu;
      63             : using namespace osl;
      64             : 
      65             : using com::sun::star::uno::Reference;
      66             : 
      67             : 
      68             : // Implementation class SfxDialogLibraryContainer
      69             : 
      70        3814 : const sal_Char* SAL_CALL SfxDialogLibraryContainer::getInfoFileName() const { return "dialog"; }
      71        3814 : const sal_Char* SAL_CALL SfxDialogLibraryContainer::getOldInfoFileName() const { return "dialogs"; }
      72        3814 : const sal_Char* SAL_CALL SfxDialogLibraryContainer::getLibElementFileExtension() const { return "xdl"; }
      73        3814 : const sal_Char* SAL_CALL SfxDialogLibraryContainer::getLibrariesDir() const { return "Dialogs"; }
      74             : 
      75             : // Ctor for service
      76        3648 : SfxDialogLibraryContainer::SfxDialogLibraryContainer( void )
      77             : {
      78             :     // all initialisation has to be done
      79             :     // by calling XInitialization::initialize
      80        3648 : }
      81             : 
      82         166 : SfxDialogLibraryContainer::SfxDialogLibraryContainer( const uno::Reference< embed::XStorage >& xStorage )
      83             : {
      84         166 :     init( OUString(), xStorage );
      85         166 : }
      86             : 
      87             : // Methods to get library instances of the correct type
      88        3710 : SfxLibrary* SfxDialogLibraryContainer::implCreateLibrary( const OUString& aName )
      89             : {
      90        3710 :     SfxLibrary* pRet = new SfxDialogLibrary( maModifiable, aName, mxContext, mxSFI, this );
      91        3710 :     return pRet;
      92             : }
      93             : 
      94        1494 : SfxLibrary* SfxDialogLibraryContainer::implCreateLibraryLink
      95             :     ( const OUString& aName, const OUString& aLibInfoFileURL,
      96             :       const OUString& StorageURL, bool ReadOnly )
      97             : {
      98             :     SfxLibrary* pRet = new SfxDialogLibrary
      99        1494 :             ( maModifiable, aName, mxContext, mxSFI, aLibInfoFileURL, StorageURL, ReadOnly, this );
     100        1494 :     return pRet;
     101             : }
     102             : 
     103        1562 : Any SAL_CALL SfxDialogLibraryContainer::createEmptyLibraryElement( void )
     104             : {
     105        1562 :     Reference< XInputStreamProvider > xISP;
     106        1562 :     Any aRetAny;
     107        1562 :     aRetAny <<= xISP;
     108        1562 :     return aRetAny;
     109             : }
     110             : 
     111           0 : bool SAL_CALL SfxDialogLibraryContainer::isLibraryElementValid( Any aElement ) const
     112             : {
     113           0 :     return SfxDialogLibrary::containsValidDialog( aElement );
     114             : }
     115             : 
     116           0 : bool writeOasis2OOoLibraryElement(
     117             :     Reference< XInputStream > xInput, Reference< XOutputStream > xOutput )
     118             : {
     119             :     Reference< XComponentContext > xContext(
     120           0 :         comphelper::getProcessComponentContext() );
     121             : 
     122             :     Reference< lang::XMultiComponentFactory > xSMgr(
     123           0 :         xContext->getServiceManager() );
     124             : 
     125           0 :     Reference< xml::sax::XParser > xParser =  xml::sax::Parser::create(xContext);
     126             : 
     127           0 :     Reference< xml::sax::XWriter > xWriter = xml::sax::Writer::create(xContext);
     128             : 
     129           0 :     xWriter->setOutputStream( xOutput );
     130             : 
     131           0 :     Sequence<Any> aArgs( 1 );
     132           0 :     aArgs[0] <<= xWriter;
     133             : 
     134             :     Reference< xml::sax::XDocumentHandler > xHandler(
     135           0 :         xSMgr->createInstanceWithArgumentsAndContext(
     136             :             OUString("com.sun.star.comp.Oasis2OOoTransformer" ) ,
     137           0 :             aArgs, xContext ),
     138           0 :         UNO_QUERY );
     139             : 
     140           0 :     xParser->setDocumentHandler( xHandler );
     141             : 
     142           0 :     xml::sax::InputSource source;
     143           0 :     source.aInputStream = xInput;
     144           0 :     source.sSystemId = "virtual file";
     145             : 
     146           0 :     xParser->parseStream( source );
     147             : 
     148           0 :     return true;
     149             : }
     150             : 
     151           0 : void SAL_CALL SfxDialogLibraryContainer::writeLibraryElement
     152             : (
     153             :     const Reference < XNameContainer >& xLib,
     154             :     const OUString& aElementName,
     155             :     const Reference< XOutputStream >& xOutput
     156             : )
     157             :     throw(Exception)
     158             : {
     159           0 :     Any aElement = xLib->getByName( aElementName );
     160           0 :     Reference< XInputStreamProvider > xISP;
     161           0 :     aElement >>= xISP;
     162           0 :     if( !xISP.is() )
     163           0 :         return;
     164             : 
     165           0 :     Reference< XInputStream > xInput( xISP->createInputStream() );
     166             : 
     167           0 :     bool bComplete = false;
     168           0 :     if ( mbOasis2OOoFormat )
     169             :     {
     170           0 :         bComplete = writeOasis2OOoLibraryElement( xInput, xOutput );
     171             :     }
     172             : 
     173           0 :     if ( !bComplete )
     174             :     {
     175           0 :         Sequence< sal_Int8 > bytes;
     176           0 :         sal_Int32 nRead = xInput->readBytes( bytes, xInput->available() );
     177             :         for (;;)
     178             :         {
     179           0 :             if( nRead )
     180           0 :                 xOutput->writeBytes( bytes );
     181             : 
     182           0 :             nRead = xInput->readBytes( bytes, 1024 );
     183           0 :             if (! nRead)
     184           0 :                 break;
     185           0 :         }
     186             :     }
     187           0 :     xInput->closeInput();
     188             : }
     189             : 
     190        1218 : void SfxDialogLibraryContainer::storeLibrariesToStorage( const uno::Reference< embed::XStorage >& xStorage ) throw ( RuntimeException, WrappedTargetException, std::exception )
     191             : {
     192        1218 :     LibraryContainerMethodGuard aGuard( *this );
     193        1218 :     mbOasis2OOoFormat = false;
     194             : 
     195        1218 :     if ( mxStorage.is() && xStorage.is() )
     196             :     {
     197             :         try
     198             :         {
     199        1218 :             long nSource = SotStorage::GetVersion( mxStorage );
     200        1218 :             long nTarget = SotStorage::GetVersion( xStorage );
     201             : 
     202        1218 :             if ( nSource == SOFFICE_FILEFORMAT_CURRENT &&
     203             :                 nTarget != SOFFICE_FILEFORMAT_CURRENT )
     204             :             {
     205           0 :                 mbOasis2OOoFormat = true;
     206             :             }
     207             :         }
     208           0 :         catch (const Exception& )
     209             :         {
     210             :             // if we cannot get the version then the
     211             :             // Oasis2OOoTransformer will not be used
     212             :             OSL_ASSERT(false);
     213             :         }
     214             :     }
     215             : 
     216        1218 :     SfxLibraryContainer::storeLibrariesToStorage( xStorage );
     217             : 
     218             :     // we need to export out any embedded image object(s)
     219             :     // associated with any Dialogs. First, we need to actually gather any such urls
     220             :     // for each dialog in this container
     221        2436 :     Sequence< OUString > sLibraries = getElementNames();
     222        2436 :     for ( sal_Int32 i=0; i < sLibraries.getLength(); ++i )
     223             :     {
     224        1218 :         loadLibrary( sLibraries[ i ] );
     225        1218 :         Reference< XNameContainer > xLib;
     226        1218 :         getByName( sLibraries[ i ] ) >>= xLib;
     227        1218 :         if ( xLib.is() )
     228             :         {
     229        1218 :             Sequence< OUString > sDialogs = xLib->getElementNames();
     230        1218 :             sal_Int32 nDialogs( sDialogs.getLength() );
     231        1220 :             for ( sal_Int32 j=0; j < nDialogs; ++j )
     232             :             {
     233             :                 // Each Dialog has an associated xISP
     234           2 :                 Reference< io::XInputStreamProvider > xISP;
     235           2 :                 xLib->getByName( sDialogs[ j ] ) >>= xISP;
     236           2 :                 if ( xISP.is() )
     237             :                 {
     238           2 :                     Reference< io::XInputStream > xInput( xISP->createInputStream() );
     239             :                     Reference< XNameContainer > xDialogModel(
     240           4 :                         mxContext->getServiceManager()->createInstanceWithContext("com.sun.star.awt.UnoControlDialogModel", mxContext),
     241           4 :                         UNO_QUERY );
     242           2 :                     ::xmlscript::importDialogModel( xInput, xDialogModel, mxContext, mxOwnerDocument );
     243           4 :                     std::vector< OUString > vEmbeddedImageURLs;
     244           2 :                     GraphicObject::InspectForGraphicObjectImageURL( Reference<XInterface>(xDialogModel, UNO_QUERY),  vEmbeddedImageURLs );
     245           2 :                     if ( !vEmbeddedImageURLs.empty() )
     246             :                     {
     247             :                         // Export the images to the storage
     248             :                         Reference< document::XGraphicObjectResolver > xGraphicResolver =
     249           0 :                             document::GraphicObjectResolver::createWithStorage( mxContext, xStorage );
     250           0 :                         std::vector< OUString >::iterator it = vEmbeddedImageURLs.begin();
     251           0 :                         std::vector< OUString >::iterator it_end = vEmbeddedImageURLs.end();
     252           0 :                         if ( xGraphicResolver.is() )
     253             :                         {
     254           0 :                             for ( sal_Int32 count = 0; it != it_end; ++it, ++count )
     255           0 :                                 xGraphicResolver->resolveGraphicObjectURL( *it );
     256           0 :                         }
     257           2 :                     }
     258             :                 }
     259        1220 :             }
     260             :         }
     261        1218 :     }
     262        2436 :     mbOasis2OOoFormat = false;
     263        1218 : }
     264             : 
     265             : 
     266           6 : Any SAL_CALL SfxDialogLibraryContainer::importLibraryElement
     267             :     ( const Reference < XNameContainer >& /*xLib*/,
     268             :       const OUString& /*aElementName */, const OUString& aFile,
     269             :       const uno::Reference< io::XInputStream >& xElementStream )
     270             : {
     271           6 :     Any aRetAny;
     272             : 
     273             :     // TODO: Member because later it will be a component
     274             :     //Reference< XMultiServiceFactory > xMSF( comphelper::getProcessServiceFactory() );
     275             :     //if( !xMSF.is() )
     276             :     //{
     277             :     //  OSL_FAIL( "### couldn't get ProcessServiceFactory\n" );
     278             :     //  return aRetAny;
     279             :     //}
     280             : 
     281          12 :     Reference< XParser > xParser = xml::sax::Parser::create( mxContext );
     282             : 
     283             :     Reference< XNameContainer > xDialogModel(
     284          12 :         mxContext->getServiceManager()->createInstanceWithContext("com.sun.star.awt.UnoControlDialogModel", mxContext),
     285          12 :         UNO_QUERY );
     286           6 :     if( !xDialogModel.is() )
     287             :     {
     288             :         OSL_FAIL( "### couldn't create com.sun.star.awt.UnoControlDialogModel component\n" );
     289           0 :         return aRetAny;
     290             :     }
     291             : 
     292             :     // Read from storage?
     293           6 :     bool bStorage = xElementStream.is();
     294          12 :     Reference< XInputStream > xInput;
     295             : 
     296           6 :     if( bStorage )
     297             :     {
     298           6 :         xInput = xElementStream;
     299             :     }
     300             :     else
     301             :     {
     302             :         try
     303             :         {
     304           0 :             xInput = mxSFI->openFileRead( aFile );
     305             :         }
     306           0 :         catch(const Exception& )
     307             :         //catch( Exception& e )
     308             :         {
     309             :             // TODO:
     310             :             //throw WrappedTargetException( e );
     311             :         }
     312             :     }
     313           6 :     if( !xInput.is() )
     314           0 :         return aRetAny;
     315             : 
     316          12 :     InputSource source;
     317           6 :     source.aInputStream = xInput;
     318           6 :     source.sSystemId    = aFile;
     319             : 
     320             :     try {
     321             :         // start parsing
     322           6 :         xParser->setDocumentHandler( ::xmlscript::importDialogModel( xDialogModel, mxContext, mxOwnerDocument ) );
     323           6 :         xParser->parseStream( source );
     324             :     }
     325           0 :     catch(const Exception& )
     326             :     {
     327             :         OSL_FAIL( "Parsing error\n" );
     328           0 :         SfxErrorContext aEc( ERRCTX_SFX_LOADBASIC, aFile );
     329           0 :         ErrorHandler::HandleError( ERRCODE_IO_GENERAL );
     330           0 :         return aRetAny;
     331             :     }
     332             : 
     333             :     // Create InputStream, TODO: Implement own InputStreamProvider
     334             :     // to avoid creating the DialogModel here!
     335          12 :     Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, mxContext, mxOwnerDocument );
     336           6 :     aRetAny <<= xISP;
     337           6 :     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           4 :     SfxDialogLibraryContainer::implCreateStringResource( SfxDialogLibrary* pDialogLibrary )
     356             : {
     357           4 :     Reference< resource::XStringResourcePersistence > xRet;
     358           8 :     OUString aLibName = pDialogLibrary->getName();
     359           4 :     bool bReadOnly = pDialogLibrary->mbReadOnly;
     360             : 
     361             :     // get ui locale
     362           8 :     ::com::sun  ::star::lang::Locale aLocale = Application::GetSettings().GetUILanguageTag().getLocale();
     363             : 
     364           8 :     OUString aComment(aResourceFileCommentBase);
     365           4 :     aComment += aLibName;
     366             : 
     367           4 :     bool bStorage = mxStorage.is();
     368           4 :     if( bStorage )
     369             :     {
     370           4 :         uno::Reference< embed::XStorage > xLibrariesStor;
     371           4 :         uno::Reference< embed::XStorage > xLibraryStor;
     372             :         try {
     373           4 :             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           8 :         catch(const uno::Exception& )
     384             :         {
     385             :             // TODO: Error handling?
     386           4 :             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        2296 : void SfxDialogLibraryContainer::onNewRootStorage()
     404             : {
     405             :     // the library container is not modified, go through the libraries and check whether they are modified
     406        2296 :     Sequence< OUString > aNames = maNameContainer.getElementNames();
     407        2296 :     const OUString* pNames = aNames.getConstArray();
     408        2296 :     sal_Int32 nNameCount = aNames.getLength();
     409             : 
     410        4596 :     for( sal_Int32 i = 0 ; i < nNameCount ; i++ )
     411             :     {
     412        2300 :         OUString aName = pNames[ i ];
     413        2300 :         SfxDialogLibrary* pDialogLibrary = static_cast<SfxDialogLibrary*>( getImplLib( aName ) );
     414             : 
     415             :         Reference< resource::XStringResourcePersistence > xStringResourcePersistence =
     416        4600 :             pDialogLibrary->getStringResourcePersistence();
     417             : 
     418        2300 :         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        4596 :     }
     443        2296 : }
     444             : 
     445             : sal_Bool SAL_CALL
     446           0 : SfxDialogLibraryContainer:: HasExecutableCode( const OUString& /*Library*/ ) throw (uno::RuntimeException, std::exception)
     447             : {
     448           0 :     return sal_False; // dialog library has no executable code
     449             : }
     450             : 
     451             : // Service
     452             : 
     453         236 : void createRegistryInfo_SfxDialogLibraryContainer()
     454             : {
     455         236 :     static OAutoRegistration< SfxDialogLibraryContainer > aAutoRegistration;
     456         236 : }
     457             : 
     458           0 : OUString SAL_CALL SfxDialogLibraryContainer::getImplementationName( ) throw (RuntimeException, std::exception)
     459             : {
     460           0 :     return getImplementationName_static();
     461             : }
     462             : 
     463           0 : Sequence< OUString > SAL_CALL SfxDialogLibraryContainer::getSupportedServiceNames( ) throw (RuntimeException, std::exception)
     464             : {
     465           0 :     return getSupportedServiceNames_static();
     466             : }
     467             : 
     468         168 : Sequence< OUString > SfxDialogLibraryContainer::getSupportedServiceNames_static()
     469             : {
     470         168 :     Sequence< OUString > aServiceNames( 2 );
     471         168 :     aServiceNames[0] = "com.sun.star.script.DocumentDialogLibraryContainer";
     472             :     // plus, for compatibility:
     473         168 :     aServiceNames[1] = "com.sun.star.script.DialogLibraryContainer";
     474         168 :     return aServiceNames;
     475             : }
     476             : 
     477         168 : OUString SfxDialogLibraryContainer::getImplementationName_static()
     478             : {
     479         168 :     return OUString("com.sun.star.comp.sfx2.DialogLibraryContainer");
     480             : }
     481             : 
     482        3648 : Reference< XInterface > SAL_CALL SfxDialogLibraryContainer::Create( const Reference< XComponentContext >& ) throw( Exception )
     483             : {
     484             :     Reference< XInterface > xRet =
     485        3648 :         static_cast< XInterface* >( static_cast< OWeakObject* >(new SfxDialogLibraryContainer()) );
     486        3648 :     return xRet;
     487             : }
     488             : 
     489             : 
     490             : 
     491             : // Implementation class SfxDialogLibrary
     492             : 
     493             : // Ctor
     494        3710 : SfxDialogLibrary::SfxDialogLibrary( ModifiableHelper& _rModifiable,
     495             :                                     const OUString& aName,
     496             :                                     const Reference< XComponentContext >& xContext,
     497             :                                     const Reference< XSimpleFileAccess3 >& xSFI,
     498             :                                     SfxDialogLibraryContainer* pParent )
     499        3710 :     : SfxLibrary( _rModifiable, cppu::UnoType<XInputStreamProvider>::get(), xContext, xSFI )
     500             :     , m_pParent( pParent )
     501        3710 :     , m_aName( aName )
     502             : {
     503        3710 : }
     504             : 
     505        1494 : 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             :                                     bool ReadOnly,
     512             :                                     SfxDialogLibraryContainer* pParent )
     513        1494 :     : SfxLibrary( _rModifiable, cppu::UnoType<XInputStreamProvider>::get(),
     514             :                        xContext, xSFI, aLibInfoFileURL, aStorageURL, ReadOnly)
     515             :     , m_pParent( pParent )
     516        2988 :     , m_aName( aName )
     517             : {
     518        1494 : }
     519             : 
     520      152546 : 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 : bool SfxDialogLibrary::isModified( void )
     525             : {
     526           0 :     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           4 :     SAL_CALL SfxDialogLibrary::getStringResource(  ) throw (RuntimeException, std::exception)
     589             : {
     590           4 :     if( !m_xStringResourcePersistence.is() )
     591           4 :         m_xStringResourcePersistence = m_pParent->implCreateStringResource( this );
     592             : 
     593           4 :     Reference< resource::XStringResourceResolver > xRet( m_xStringResourcePersistence, UNO_QUERY );
     594           4 :     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        1203 : }
     610             : 
     611             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10