LCOV - code coverage report
Current view: top level - svx/source/unogallery - unogalthemeprovider.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 4 98 4.1 %
Date: 2012-08-25 Functions: 2 21 9.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 220 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "unogalthemeprovider.hxx"
      31                 :            : #include "unogaltheme.hxx"
      32                 :            : #include "svx/gallery1.hxx"
      33                 :            : #include <osl/mutex.hxx>
      34                 :            : #include <vcl/svapp.hxx>
      35                 :            : #include <unotools/pathoptions.hxx>
      36                 :            : #include <comphelper/servicehelper.hxx>
      37                 :            : #include <com/sun/star/gallery/XGalleryTheme.hpp>
      38                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      39                 :            : 
      40                 :            : using namespace ::com::sun::star;
      41                 :            : 
      42                 :            : namespace unogallery {
      43                 :            : 
      44                 :            : // --------------------
      45                 :            : // - Helper functions -
      46                 :            : // --------------------
      47                 :            : 
      48                 :          0 : uno::Reference< uno::XInterface > SAL_CALL GalleryThemeProvider_createInstance(
      49                 :            :     const uno::Reference< lang::XMultiServiceFactory > & )
      50                 :            :     throw( uno::Exception )
      51                 :            : {
      52         [ #  # ]:          0 :     return *( new GalleryThemeProvider() );
      53                 :            : }
      54                 :            : 
      55                 :            : // -----------------------------------------------------------------------------
      56                 :            : 
      57                 :          0 : uno::Sequence< ::rtl::OUString > SAL_CALL GalleryThemeProvider_getSupportedServiceNames()
      58                 :            :     throw()
      59                 :            : {
      60                 :          0 :     return GalleryThemeProvider::getSupportedServiceNames_Static();
      61                 :            : }
      62                 :            : 
      63                 :            : // -----------------------------------------------------------------------------
      64                 :            : 
      65                 :          7 : ::rtl::OUString SAL_CALL GalleryThemeProvider_getImplementationName()
      66                 :            :     throw()
      67                 :            : {
      68                 :          7 :     return GalleryThemeProvider::getImplementationName_Static();
      69                 :            : }
      70                 :            : 
      71                 :            : // -----------------
      72                 :            : // - GalleryThemeProvider -
      73                 :            : // -----------------
      74                 :            : 
      75                 :          0 : GalleryThemeProvider::GalleryThemeProvider() :
      76                 :          0 :     mbHiddenThemes( sal_False )
      77                 :            : {
      78         [ #  # ]:          0 :     mpGallery = ::Gallery::GetGalleryInstance();
      79                 :          0 : }
      80                 :            : 
      81                 :            : // ------------------------------------------------------------------------------
      82                 :            : 
      83                 :          0 : GalleryThemeProvider::~GalleryThemeProvider()
      84                 :            : {
      85         [ #  # ]:          0 : }
      86                 :            : 
      87                 :            : // ------------------------------------------------------------------------------
      88                 :            : 
      89                 :          7 : SVX_DLLPUBLIC ::rtl::OUString GalleryThemeProvider::getImplementationName_Static()
      90                 :            :     throw()
      91                 :            : {
      92                 :          7 :     return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.gallery.GalleryThemeProvider" ) );
      93                 :            : }
      94                 :            : 
      95                 :            : // ------------------------------------------------------------------------------
      96                 :            : 
      97                 :          0 : SVX_DLLPUBLIC uno::Sequence< ::rtl::OUString > GalleryThemeProvider::getSupportedServiceNames_Static()
      98                 :            :     throw()
      99                 :            : {
     100                 :          0 :     uno::Sequence< ::rtl::OUString > aSeq( 1 );
     101                 :            : 
     102 [ #  # ][ #  # ]:          0 :     aSeq.getArray()[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.gallery.GalleryThemeProvider" ) );
     103                 :            : 
     104                 :          0 :     return aSeq;
     105                 :            : }
     106                 :            : 
     107                 :            : // ------------------------------------------------------------------------------
     108                 :            : 
     109                 :          0 : ::rtl::OUString SAL_CALL GalleryThemeProvider::getImplementationName()
     110                 :            :     throw( uno::RuntimeException )
     111                 :            : {
     112                 :          0 :     return getImplementationName_Static();
     113                 :            : }
     114                 :            : 
     115                 :            : // ------------------------------------------------------------------------------
     116                 :            : 
     117                 :          0 : sal_Bool SAL_CALL GalleryThemeProvider::supportsService( const ::rtl::OUString& ServiceName )
     118                 :            :     throw( uno::RuntimeException )
     119                 :            : {
     120         [ #  # ]:          0 :     uno::Sequence< ::rtl::OUString >    aSNL( getSupportedServiceNames() );
     121                 :          0 :     const ::rtl::OUString*              pArray = aSNL.getConstArray();
     122                 :            : 
     123         [ #  # ]:          0 :     for( int i = 0; i < aSNL.getLength(); i++ )
     124         [ #  # ]:          0 :         if( pArray[i] == ServiceName )
     125                 :          0 :             return true;
     126                 :            : 
     127         [ #  # ]:          0 :     return false;
     128                 :            : }
     129                 :            : 
     130                 :            : // ------------------------------------------------------------------------------
     131                 :            : 
     132                 :          0 : uno::Sequence< ::rtl::OUString > SAL_CALL GalleryThemeProvider::getSupportedServiceNames()
     133                 :            :     throw( uno::RuntimeException )
     134                 :            : {
     135                 :          0 :     return getSupportedServiceNames_Static();
     136                 :            : }
     137                 :            : 
     138                 :            : // ------------------------------------------------------------------------------
     139                 :            : 
     140                 :          0 : uno::Sequence< uno::Type > SAL_CALL GalleryThemeProvider::getTypes()
     141                 :            :     throw(uno::RuntimeException)
     142                 :            : {
     143                 :          0 :     uno::Sequence< uno::Type >  aTypes( 6 );
     144         [ #  # ]:          0 :     uno::Type*                  pTypes = aTypes.getArray();
     145                 :            : 
     146         [ #  # ]:          0 :     *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo>*)0);
     147         [ #  # ]:          0 :     *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider>*)0);
     148         [ #  # ]:          0 :     *pTypes++ = ::getCppuType((const uno::Reference< lang::XInitialization>*)0);
     149         [ #  # ]:          0 :     *pTypes++ = ::getCppuType((const uno::Reference< container::XElementAccess>*)0);
     150         [ #  # ]:          0 :     *pTypes++ = ::getCppuType((const uno::Reference< container::XNameAccess>*)0);
     151         [ #  # ]:          0 :     *pTypes++ = ::getCppuType((const uno::Reference< gallery::XGalleryThemeProvider>*)0);
     152                 :            : 
     153                 :          0 :     return aTypes;
     154                 :            : }
     155                 :            : 
     156                 :            : namespace
     157                 :            : {
     158                 :            :     class theGalleryThemeProviderImplementationId : public rtl::Static< UnoTunnelIdInit, theGalleryThemeProviderImplementationId > {};
     159                 :            : }
     160                 :            : 
     161                 :          0 : uno::Sequence< sal_Int8 > SAL_CALL GalleryThemeProvider::getImplementationId()
     162                 :            :     throw(uno::RuntimeException)
     163                 :            : {
     164                 :          0 :     return theGalleryThemeProviderImplementationId::get().getSeq();
     165                 :            : }
     166                 :            : 
     167                 :            : // ------------------------------------------------------------------------------
     168                 :            : 
     169                 :          0 : void SAL_CALL GalleryThemeProvider::initialize( const uno::Sequence< uno::Any >& rArguments )
     170                 :            :     throw ( uno::Exception, uno::RuntimeException )
     171                 :            : {
     172         [ #  # ]:          0 :     uno::Sequence< beans::PropertyValue >   aParams;
     173                 :            :     sal_Int32                               i;
     174                 :            : 
     175         [ #  # ]:          0 :     for( i = 0; i < rArguments.getLength(); ++i )
     176                 :            :     {
     177 [ #  # ][ #  # ]:          0 :         if( rArguments[ i ] >>= aParams )
     178                 :          0 :             break;
     179                 :            :     }
     180                 :            : 
     181         [ #  # ]:          0 :     for( i = 0; i < aParams.getLength(); ++i )
     182                 :            :     {
     183         [ #  # ]:          0 :         const beans::PropertyValue& rProp = aParams[ i ];
     184                 :            : 
     185         [ #  # ]:          0 :         if ( rProp.Name == "ProvideHiddenThemes" )
     186                 :          0 :             rProp.Value >>= mbHiddenThemes;
     187         [ #  # ]:          0 :     }
     188                 :          0 : }
     189                 :            : 
     190                 :            : // ------------------------------------------------------------------------------
     191                 :            : 
     192                 :          0 : uno::Type SAL_CALL GalleryThemeProvider::getElementType()
     193                 :            :     throw (uno::RuntimeException)
     194                 :            : {
     195                 :          0 :     return ::getCppuType( (const uno::Reference< gallery::XGalleryTheme >*) 0);
     196                 :            : }
     197                 :            : 
     198                 :            : // ------------------------------------------------------------------------------
     199                 :            : 
     200                 :          0 : sal_Bool SAL_CALL GalleryThemeProvider::hasElements()
     201                 :            :     throw (uno::RuntimeException)
     202                 :            : {
     203         [ #  # ]:          0 :     const SolarMutexGuard aGuard;
     204                 :            : 
     205 [ #  # ][ #  # ]:          0 :     return( ( mpGallery != NULL ) && ( mpGallery->GetThemeCount() > 0 ) );
                 [ #  # ]
     206                 :            : }
     207                 :            : 
     208                 :            : // ------------------------------------------------------------------------------
     209                 :            : 
     210                 :          0 : uno::Any SAL_CALL GalleryThemeProvider::getByName( const ::rtl::OUString& rName )
     211                 :            :     throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
     212                 :            : {
     213         [ #  # ]:          0 :     const SolarMutexGuard aGuard;
     214                 :          0 :     uno::Any            aRet;
     215                 :            : 
     216 [ #  # ][ #  # ]:          0 :     if( !mpGallery || !mpGallery->HasTheme( rName ) )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
     217                 :            :     {
     218         [ #  # ]:          0 :         throw container::NoSuchElementException();
     219                 :            :     }
     220                 :            :     else
     221                 :            :     {
     222 [ #  # ][ #  # ]:          0 :         aRet = uno::makeAny( uno::Reference< gallery::XGalleryTheme >( new ::unogallery::GalleryTheme( rName ) ) );
         [ #  # ][ #  # ]
     223                 :            :     }
     224                 :            : 
     225         [ #  # ]:          0 :     return aRet;
     226                 :            : }
     227                 :            : 
     228                 :            : // ------------------------------------------------------------------------------
     229                 :            : 
     230                 :          0 : uno::Sequence< ::rtl::OUString > SAL_CALL GalleryThemeProvider::getElementNames()
     231                 :            :     throw (uno::RuntimeException)
     232                 :            : {
     233         [ #  # ]:          0 :     const SolarMutexGuard aGuard;
     234         [ #  # ]:          0 :     sal_uInt32                          i = 0, nCount = ( mpGallery ? mpGallery->GetThemeCount() : 0 ), nRealCount = 0;
     235         [ #  # ]:          0 :     uno::Sequence< ::rtl::OUString >    aSeq( nCount );
     236                 :            : 
     237         [ #  # ]:          0 :     for( ; i < nCount; ++i )
     238                 :            :     {
     239         [ #  # ]:          0 :         const GalleryThemeEntry* pEntry = mpGallery->GetThemeInfo( i );
     240                 :            : 
     241 [ #  # ][ #  # ]:          0 :         if( mbHiddenThemes || !pEntry->IsHidden() )
         [ #  # ][ #  # ]
     242         [ #  # ]:          0 :             aSeq[ nRealCount++ ] = pEntry->GetThemeName();
     243                 :            :     }
     244                 :            : 
     245         [ #  # ]:          0 :     aSeq.realloc( nRealCount );
     246                 :            : 
     247         [ #  # ]:          0 :     return aSeq;
     248                 :            : }
     249                 :            : 
     250                 :            : // ------------------------------------------------------------------------------
     251                 :            : 
     252                 :          0 : sal_Bool SAL_CALL GalleryThemeProvider::hasByName( const ::rtl::OUString& rName )
     253                 :            :     throw (uno::RuntimeException)
     254                 :            : {
     255         [ #  # ]:          0 :     const SolarMutexGuard aGuard;
     256                 :            : 
     257                 :          0 :     sal_Bool bRet = sal_False;
     258                 :            : 
     259 [ #  # ][ #  # ]:          0 :     if( mpGallery && mpGallery->HasTheme( rName ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     260 [ #  # ][ #  # ]:          0 :         bRet = ( mbHiddenThemes || !mpGallery->GetThemeInfo( rName )->IsHidden() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     261                 :            : 
     262         [ #  # ]:          0 :     return( bRet );
     263                 :            : }
     264                 :            : 
     265                 :            : // ------------------------------------------------------------------------------
     266                 :            : 
     267                 :          0 : uno::Reference< gallery::XGalleryTheme > SAL_CALL GalleryThemeProvider::insertNewByName( const ::rtl::OUString& rThemeName )
     268                 :            :     throw (container::ElementExistException, uno::RuntimeException)
     269                 :            : {
     270         [ #  # ]:          0 :     const SolarMutexGuard aGuard;
     271                 :          0 :     uno::Reference< gallery::XGalleryTheme >    xRet;
     272                 :            : 
     273         [ #  # ]:          0 :     if( mpGallery )
     274                 :            :     {
     275 [ #  # ][ #  # ]:          0 :         if( mpGallery->HasTheme( rThemeName ) )
         [ #  # ][ #  # ]
     276                 :            :         {
     277         [ #  # ]:          0 :             throw container::ElementExistException();
     278                 :            :         }
     279 [ #  # ][ #  # ]:          0 :         else if( mpGallery->CreateTheme( rThemeName ) )
         [ #  # ][ #  # ]
     280                 :            :         {
     281 [ #  # ][ #  # ]:          0 :             xRet = new ::unogallery::GalleryTheme( rThemeName );
                 [ #  # ]
     282                 :            :         }
     283                 :            :     }
     284                 :            : 
     285         [ #  # ]:          0 :     return xRet;
     286                 :            : }
     287                 :            : 
     288                 :            : // ------------------------------------------------------------------------------
     289                 :            : 
     290                 :          0 : void SAL_CALL GalleryThemeProvider::removeByName( const ::rtl::OUString& rName )
     291                 :            :     throw (container::NoSuchElementException, uno::RuntimeException)
     292                 :            : {
     293         [ #  # ]:          0 :     const SolarMutexGuard aGuard;
     294                 :            : 
     295 [ #  # ][ #  # ]:          0 :     if( !mpGallery ||
         [ #  # ][ #  # ]
                 [ #  # ]
     296 [ #  # ][ #  # ]:          0 :         !mpGallery->HasTheme( rName ) ||
         [ #  # ][ #  # ]
                 [ #  # ]
     297 [ #  # ][ #  # ]:          0 :         ( !mbHiddenThemes && mpGallery->GetThemeInfo( rName )->IsHidden() ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     298                 :            :     {
     299         [ #  # ]:          0 :         throw container::NoSuchElementException();
     300                 :            :     }
     301                 :            :     else
     302                 :            :     {
     303 [ #  # ][ #  # ]:          0 :         mpGallery->RemoveTheme( rName );
                 [ #  # ]
     304         [ #  # ]:          0 :     }
     305                 :          0 : }
     306                 :            : 
     307                 :            : }
     308                 :            : 
     309                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10