LCOV - code coverage report
Current view: top level - svx/source/unogallery - unogalthemeprovider.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 85 0.0 %
Date: 2014-04-14 Functions: 0 17 0.0 %
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             : 
      21             : #include "unogalthemeprovider.hxx"
      22             : #include "unogaltheme.hxx"
      23             : #include "svx/gallery1.hxx"
      24             : #include <osl/mutex.hxx>
      25             : #include <rtl/ref.hxx>
      26             : #include <vcl/svapp.hxx>
      27             : #include <unotools/pathoptions.hxx>
      28             : #include <comphelper/servicehelper.hxx>
      29             : #include <cppuhelper/supportsservice.hxx>
      30             : #include <com/sun/star/gallery/XGalleryTheme.hpp>
      31             : #include <com/sun/star/beans/PropertyValue.hpp>
      32             : 
      33             : using namespace ::com::sun::star;
      34             : 
      35             : namespace {
      36             : 
      37           0 : GalleryThemeProvider::GalleryThemeProvider() :
      38           0 :     mbHiddenThemes( sal_False )
      39             : {
      40           0 :     mpGallery = ::Gallery::GetGalleryInstance();
      41           0 : }
      42             : 
      43           0 : GalleryThemeProvider::~GalleryThemeProvider()
      44             : {
      45           0 : }
      46             : 
      47           0 : OUString SAL_CALL GalleryThemeProvider::getImplementationName()
      48             :     throw( uno::RuntimeException, std::exception )
      49             : {
      50           0 :     return OUString( "com.sun.star.comp.gallery.GalleryThemeProvider" );
      51             : }
      52             : 
      53           0 : sal_Bool SAL_CALL GalleryThemeProvider::supportsService( const OUString& ServiceName )
      54             :     throw( uno::RuntimeException, std::exception )
      55             : {
      56           0 :     return cppu::supportsService( this, ServiceName );
      57             : }
      58             : 
      59           0 : uno::Sequence< OUString > SAL_CALL GalleryThemeProvider::getSupportedServiceNames()
      60             :     throw( uno::RuntimeException, std::exception )
      61             : {
      62           0 :     uno::Sequence< OUString > aSeq( 1 );
      63           0 :     aSeq.getArray()[ 0 ] = "com.sun.star.gallery.GalleryThemeProvider";
      64           0 :     return aSeq;
      65             : }
      66             : 
      67           0 : uno::Sequence< uno::Type > SAL_CALL GalleryThemeProvider::getTypes()
      68             :     throw(uno::RuntimeException, std::exception)
      69             : {
      70           0 :     uno::Sequence< uno::Type >  aTypes( 6 );
      71           0 :     uno::Type*                  pTypes = aTypes.getArray();
      72             : 
      73           0 :     *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo>*)0);
      74           0 :     *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider>*)0);
      75           0 :     *pTypes++ = ::getCppuType((const uno::Reference< lang::XInitialization>*)0);
      76           0 :     *pTypes++ = ::getCppuType((const uno::Reference< container::XElementAccess>*)0);
      77           0 :     *pTypes++ = ::getCppuType((const uno::Reference< container::XNameAccess>*)0);
      78           0 :     *pTypes++ = ::getCppuType((const uno::Reference< gallery::XGalleryThemeProvider>*)0);
      79             : 
      80           0 :     return aTypes;
      81             : }
      82             : 
      83           0 : uno::Sequence< sal_Int8 > SAL_CALL GalleryThemeProvider::getImplementationId()
      84             :     throw(uno::RuntimeException, std::exception)
      85             : {
      86           0 :     return css::uno::Sequence<sal_Int8>();
      87             : }
      88             : 
      89           0 : void SAL_CALL GalleryThemeProvider::initialize( const uno::Sequence< uno::Any >& rArguments )
      90             :     throw ( uno::Exception, uno::RuntimeException, std::exception )
      91             : {
      92           0 :     uno::Sequence< beans::PropertyValue >   aParams;
      93             :     sal_Int32                               i;
      94             : 
      95           0 :     for( i = 0; i < rArguments.getLength(); ++i )
      96             :     {
      97           0 :         if( rArguments[ i ] >>= aParams )
      98           0 :             break;
      99             :     }
     100             : 
     101           0 :     for( i = 0; i < aParams.getLength(); ++i )
     102             :     {
     103           0 :         const beans::PropertyValue& rProp = aParams[ i ];
     104             : 
     105           0 :         if ( rProp.Name == "ProvideHiddenThemes" )
     106           0 :             rProp.Value >>= mbHiddenThemes;
     107           0 :     }
     108           0 : }
     109             : 
     110             : 
     111             : 
     112           0 : uno::Type SAL_CALL GalleryThemeProvider::getElementType()
     113             :     throw (uno::RuntimeException, std::exception)
     114             : {
     115           0 :     return ::getCppuType( (const uno::Reference< gallery::XGalleryTheme >*) 0);
     116             : }
     117             : 
     118             : 
     119             : 
     120           0 : sal_Bool SAL_CALL GalleryThemeProvider::hasElements()
     121             :     throw (uno::RuntimeException, std::exception)
     122             : {
     123           0 :     const SolarMutexGuard aGuard;
     124             : 
     125           0 :     return( ( mpGallery != NULL ) && ( mpGallery->GetThemeCount() > 0 ) );
     126             : }
     127             : 
     128             : 
     129             : 
     130           0 : uno::Any SAL_CALL GalleryThemeProvider::getByName( const OUString& rName )
     131             :     throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     132             : {
     133           0 :     const SolarMutexGuard aGuard;
     134           0 :     uno::Any            aRet;
     135             : 
     136           0 :     if( !mpGallery || !mpGallery->HasTheme( rName ) )
     137             :     {
     138           0 :         throw container::NoSuchElementException();
     139             :     }
     140             :     else
     141             :     {
     142           0 :         aRet = uno::makeAny( uno::Reference< gallery::XGalleryTheme >( new ::unogallery::GalleryTheme( rName ) ) );
     143             :     }
     144             : 
     145           0 :     return aRet;
     146             : }
     147             : 
     148             : 
     149             : 
     150           0 : uno::Sequence< OUString > SAL_CALL GalleryThemeProvider::getElementNames()
     151             :     throw (uno::RuntimeException, std::exception)
     152             : {
     153           0 :     const SolarMutexGuard aGuard;
     154           0 :     sal_uInt32                          i = 0, nCount = ( mpGallery ? mpGallery->GetThemeCount() : 0 ), nRealCount = 0;
     155           0 :     uno::Sequence< OUString >    aSeq( nCount );
     156             : 
     157           0 :     for( ; i < nCount; ++i )
     158             :     {
     159           0 :         const GalleryThemeEntry* pEntry = mpGallery->GetThemeInfo( i );
     160             : 
     161           0 :         if( mbHiddenThemes || !pEntry->IsHidden() )
     162           0 :             aSeq[ nRealCount++ ] = pEntry->GetThemeName();
     163             :     }
     164             : 
     165           0 :     aSeq.realloc( nRealCount );
     166             : 
     167           0 :     return aSeq;
     168             : }
     169             : 
     170             : 
     171             : 
     172           0 : sal_Bool SAL_CALL GalleryThemeProvider::hasByName( const OUString& rName )
     173             :     throw (uno::RuntimeException, std::exception)
     174             : {
     175           0 :     const SolarMutexGuard aGuard;
     176             : 
     177           0 :     sal_Bool bRet = sal_False;
     178             : 
     179           0 :     if( mpGallery && mpGallery->HasTheme( rName ) )
     180           0 :         bRet = ( mbHiddenThemes || !mpGallery->GetThemeInfo( rName )->IsHidden() );
     181             : 
     182           0 :     return( bRet );
     183             : }
     184             : 
     185             : 
     186             : 
     187           0 : uno::Reference< gallery::XGalleryTheme > SAL_CALL GalleryThemeProvider::insertNewByName( const OUString& rThemeName )
     188             :     throw (container::ElementExistException, uno::RuntimeException, std::exception)
     189             : {
     190           0 :     const SolarMutexGuard aGuard;
     191           0 :     uno::Reference< gallery::XGalleryTheme >    xRet;
     192             : 
     193           0 :     if( mpGallery )
     194             :     {
     195           0 :         if( mpGallery->HasTheme( rThemeName ) )
     196             :         {
     197           0 :             throw container::ElementExistException();
     198             :         }
     199           0 :         else if( mpGallery->CreateTheme( rThemeName ) )
     200             :         {
     201           0 :             xRet = new ::unogallery::GalleryTheme( rThemeName );
     202             :         }
     203             :     }
     204             : 
     205           0 :     return xRet;
     206             : }
     207             : 
     208             : 
     209             : 
     210           0 : void SAL_CALL GalleryThemeProvider::removeByName( const OUString& rName )
     211             :     throw (container::NoSuchElementException, uno::RuntimeException, std::exception)
     212             : {
     213           0 :     const SolarMutexGuard aGuard;
     214             : 
     215           0 :     if( !mpGallery ||
     216           0 :         !mpGallery->HasTheme( rName ) ||
     217           0 :         ( !mbHiddenThemes && mpGallery->GetThemeInfo( rName )->IsHidden() ) )
     218             :     {
     219           0 :         throw container::NoSuchElementException();
     220             :     }
     221             :     else
     222             :     {
     223           0 :         mpGallery->RemoveTheme( rName );
     224           0 :     }
     225           0 : }
     226             : 
     227             : }
     228             : 
     229             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
     230           0 : com_sun_star_comp_gallery_GalleryThemeProvider_get_implementation(
     231             :     css::uno::XComponentContext *,
     232             :     css::uno::Sequence<css::uno::Any> const &)
     233             : {
     234           0 :     return cppu::acquire(new GalleryThemeProvider);
     235             : }
     236             : 
     237             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10