LCOV - code coverage report
Current view: top level - svx/source/gallery2 - galexpl.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 136 0.0 %
Date: 2014-04-11 Functions: 0 16 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 <unotools/pathoptions.hxx>
      22             : #include <rtl/instance.hxx>
      23             : #include <sfx2/viewfrm.hxx>
      24             : #include "svx/gallery1.hxx"
      25             : #include "svx/galtheme.hxx"
      26             : #include "svx/galbrws.hxx"
      27             : #include "svx/gallery.hxx"
      28             : #include "galobj.hxx"
      29             : 
      30             : namespace
      31             : {
      32             :     class theLockListener : public rtl::Static< SfxListener, theLockListener > {};
      33             : }
      34             : 
      35             : // - GalleryExplorer -
      36             : 
      37           0 : bool GalleryExplorer::FillThemeList( std::vector<OUString>& rThemeList )
      38             : {
      39           0 :     Gallery* pGal = ::Gallery::GetGalleryInstance();
      40             : 
      41           0 :     if( pGal )
      42             :     {
      43           0 :         for( sal_uIntPtr i = 0, nCount = pGal->GetThemeCount(); i < nCount; i++ )
      44             :         {
      45           0 :             const GalleryThemeEntry* pEntry = pGal->GetThemeInfo( i );
      46             : 
      47           0 :             if( pEntry && !pEntry->IsReadOnly() && !pEntry->IsHidden() )
      48           0 :                 rThemeList.push_back(pEntry->GetThemeName());
      49             :         }
      50             :     }
      51             : 
      52           0 :     return !rThemeList.empty();
      53             : }
      54             : 
      55           0 : bool GalleryExplorer::FillObjList( const OUString& rThemeName, std::vector<OUString> &rObjList )
      56             : {
      57           0 :     Gallery* pGal = ::Gallery::GetGalleryInstance();
      58             : 
      59           0 :     if( pGal )
      60             :     {
      61           0 :         SfxListener     aListener;
      62           0 :         GalleryTheme*   pTheme = pGal->AcquireTheme( rThemeName, aListener );
      63             : 
      64           0 :         if( pTheme )
      65             :         {
      66           0 :             for( sal_uInt32 i = 0, nCount = pTheme->GetObjectCount(); i < nCount; i++ )
      67           0 :                 rObjList.push_back( pTheme->GetObjectURL( i ).GetMainURL( INetURLObject::NO_DECODE ) );
      68             : 
      69           0 :             pGal->ReleaseTheme( pTheme, aListener );
      70           0 :         }
      71             :     }
      72             : 
      73           0 :     return !rObjList.empty();
      74             : }
      75             : 
      76           0 : bool GalleryExplorer::FillObjList( const sal_uInt32 nThemeId, std::vector<OUString> &rObjList )
      77             : {
      78           0 :     Gallery* pGal = ::Gallery::GetGalleryInstance();
      79             : 
      80           0 :     if (!pGal)
      81           0 :         return false;
      82             : 
      83           0 :     return FillObjList( pGal->GetThemeName( nThemeId ), rObjList );
      84             : }
      85             : 
      86           0 : bool GalleryExplorer::FillObjListTitle( const sal_uInt32 nThemeId, std::vector< OUString >& rList )
      87             : {
      88           0 :     Gallery* pGal = ::Gallery::GetGalleryInstance();
      89           0 :     if( pGal )
      90             :     {
      91           0 :         SfxListener     aListener;
      92           0 :         GalleryTheme*   pTheme = pGal->AcquireTheme( pGal->GetThemeName( nThemeId ), aListener );
      93             : 
      94           0 :         if( pTheme )
      95             :         {
      96           0 :             for( sal_uIntPtr i = 0, nCount = pTheme->GetObjectCount(); i < nCount; i++ )
      97             :             {
      98           0 :                 SgaObject*  pObj = pTheme->AcquireObject( i );
      99           0 :                 if ( pObj )
     100             :                 {
     101           0 :                     OUString aTitle( pObj->GetTitle() );
     102           0 :                     rList.push_back( aTitle );
     103           0 :                     pTheme->ReleaseObject( pObj );
     104             :                 }
     105             :             }
     106           0 :             pGal->ReleaseTheme( pTheme, aListener );
     107           0 :         }
     108             :     }
     109           0 :     return !rList.empty();
     110             : }
     111             : 
     112           0 : bool GalleryExplorer::InsertURL( const OUString& rThemeName, const OUString& rURL )
     113             : {
     114           0 :     Gallery*    pGal = ::Gallery::GetGalleryInstance();
     115           0 :     bool        bRet = false;
     116             : 
     117           0 :     if( pGal )
     118             :     {
     119           0 :         SfxListener   aListener;
     120           0 :         GalleryTheme* pTheme = pGal->AcquireTheme( rThemeName, aListener );
     121             : 
     122           0 :         if( pTheme )
     123             :         {
     124           0 :             INetURLObject aURL( rURL );
     125             :             DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
     126           0 :             bRet = pTheme->InsertURL( aURL );
     127           0 :             pGal->ReleaseTheme( pTheme, aListener );
     128           0 :         }
     129             :     }
     130             : 
     131           0 :     return bRet;
     132             : }
     133             : 
     134           0 : bool GalleryExplorer::InsertURL( sal_uIntPtr nThemeId, const OUString& rURL )
     135             : {
     136           0 :     Gallery* pGal = ::Gallery::GetGalleryInstance();
     137           0 :     return pGal && InsertURL( pGal->GetThemeName( nThemeId ), rURL );
     138             : }
     139             : 
     140           0 : bool GalleryExplorer::GetGraphicObj( const OUString& rThemeName, sal_uIntPtr nPos,
     141             :                                      Graphic* pGraphic, BitmapEx* pThumb,
     142             :                                      bool bProgress )
     143             : {
     144           0 :     Gallery*    pGal = ::Gallery::GetGalleryInstance();
     145           0 :     bool        bRet = false;
     146             : 
     147           0 :     if( pGal )
     148             :     {
     149           0 :         SfxListener     aListener;
     150           0 :         GalleryTheme*   pTheme = pGal->AcquireTheme( rThemeName, aListener );
     151             : 
     152           0 :         if( pTheme )
     153             :         {
     154           0 :             if( pGraphic )
     155           0 :                 bRet = bRet || pTheme->GetGraphic( nPos, *pGraphic, bProgress );
     156             : 
     157           0 :             if( pThumb )
     158           0 :                 bRet = bRet || pTheme->GetThumb( nPos, *pThumb, bProgress );
     159             : 
     160           0 :             pGal->ReleaseTheme( pTheme, aListener );
     161           0 :         }
     162             :     }
     163             : 
     164           0 :     return bRet;
     165             : }
     166             : 
     167           0 : bool GalleryExplorer::GetGraphicObj( sal_uIntPtr nThemeId, sal_uIntPtr nPos,
     168             :                                      Graphic* pGraphic, BitmapEx* pThumb,
     169             :                                      bool bProgress )
     170             : {
     171           0 :     Gallery* pGal = ::Gallery::GetGalleryInstance();
     172           0 :     return pGal && GetGraphicObj( pGal->GetThemeName( nThemeId ), nPos, pGraphic, pThumb, bProgress );
     173             : }
     174             : 
     175           0 : sal_uIntPtr GalleryExplorer::GetSdrObjCount( const OUString& rThemeName )
     176             : {
     177           0 :     Gallery*    pGal = ::Gallery::GetGalleryInstance();
     178           0 :     sal_uIntPtr     nRet = 0;
     179             : 
     180           0 :     if( pGal )
     181             :     {
     182           0 :         SfxListener     aListener;
     183           0 :         GalleryTheme*   pTheme = pGal->AcquireTheme( rThemeName, aListener );
     184             : 
     185           0 :         if( pTheme )
     186             :         {
     187           0 :             for( sal_uIntPtr i = 0, nCount = pTheme->GetObjectCount(); i < nCount; i++ )
     188           0 :                 if( SGA_OBJ_SVDRAW == pTheme->GetObjectKind( i ) )
     189           0 :                     nRet++;
     190             : 
     191           0 :             pGal->ReleaseTheme( pTheme, aListener );
     192           0 :         }
     193             :     }
     194             : 
     195           0 :     return nRet;
     196             : }
     197             : 
     198           0 : sal_uIntPtr GalleryExplorer::GetSdrObjCount( sal_uIntPtr nThemeId  )
     199             : {
     200           0 :     Gallery* pGal = ::Gallery::GetGalleryInstance();
     201           0 :     return( pGal ? GetSdrObjCount( pGal->GetThemeName( nThemeId ) ) : sal_False );
     202             : }
     203             : 
     204           0 : bool GalleryExplorer::GetSdrObj( const OUString& rThemeName, sal_uIntPtr nSdrModelPos,
     205             :                                  SdrModel* pModel, BitmapEx* pThumb )
     206             : {
     207           0 :     Gallery*    pGal = ::Gallery::GetGalleryInstance();
     208           0 :     bool        bRet = false;
     209             : 
     210           0 :     if( pGal )
     211             :     {
     212           0 :         SfxListener     aListener;
     213           0 :         GalleryTheme*   pTheme = pGal->AcquireTheme( rThemeName, aListener );
     214             : 
     215           0 :         if( pTheme )
     216             :         {
     217           0 :             for( sal_uIntPtr i = 0, nCount = pTheme->GetObjectCount(), nActPos = 0; ( i < nCount ) && !bRet; i++ )
     218             :             {
     219           0 :                 if( SGA_OBJ_SVDRAW == pTheme->GetObjectKind( i ) )
     220             :                 {
     221           0 :                     if( nActPos++ == nSdrModelPos )
     222             :                     {
     223           0 :                         if( pModel )
     224           0 :                             bRet = bRet || pTheme->GetModel( i, *pModel, false );
     225             : 
     226           0 :                         if( pThumb )
     227           0 :                             bRet = bRet || pTheme->GetThumb( i, *pThumb );
     228             :                     }
     229             :                 }
     230             :             }
     231             : 
     232           0 :             pGal->ReleaseTheme( pTheme, aListener );
     233           0 :         }
     234             :     }
     235             : 
     236           0 :     return bRet;
     237             : }
     238             : 
     239           0 : bool GalleryExplorer::GetSdrObj( sal_uIntPtr nThemeId, sal_uIntPtr nSdrModelPos,
     240             :                                  SdrModel* pModel, BitmapEx* pThumb )
     241             : {
     242           0 :     Gallery* pGal = ::Gallery::GetGalleryInstance();
     243           0 :     return pGal && GetSdrObj( pGal->GetThemeName( nThemeId ), nSdrModelPos, pModel, pThumb );
     244             : }
     245             : 
     246           0 : bool GalleryExplorer::BeginLocking( const OUString& rThemeName )
     247             : {
     248           0 :     Gallery*    pGal = ::Gallery::GetGalleryInstance();
     249           0 :     bool        bRet = false;
     250             : 
     251           0 :     if( pGal )
     252             :     {
     253           0 :         GalleryTheme* pTheme = pGal->AcquireTheme( rThemeName, theLockListener::get() );
     254             : 
     255           0 :         if( pTheme )
     256             :         {
     257           0 :             pTheme->LockTheme();
     258           0 :             bRet = true;
     259             :         }
     260             :     }
     261             : 
     262           0 :     return bRet;
     263             : }
     264             : 
     265           0 : bool GalleryExplorer::BeginLocking( sal_uIntPtr nThemeId )
     266             : {
     267           0 :     Gallery* pGal = ::Gallery::GetGalleryInstance();
     268           0 :     return pGal && BeginLocking( pGal->GetThemeName( nThemeId ) );
     269             : }
     270             : 
     271           0 : bool GalleryExplorer::EndLocking( const OUString& rThemeName )
     272             : {
     273           0 :     Gallery*    pGal = ::Gallery::GetGalleryInstance();
     274           0 :     bool        bRet = false;
     275             : 
     276           0 :     if( pGal )
     277             :     {
     278           0 :         SfxListener   aListener;
     279           0 :         GalleryTheme* pTheme = pGal->AcquireTheme( rThemeName, aListener );
     280             : 
     281           0 :         if( pTheme )
     282             :         {
     283           0 :             const sal_Bool bReleaseLockedTheme = pTheme->UnlockTheme();
     284             : 
     285             :             // release acquired theme
     286           0 :             pGal->ReleaseTheme( pTheme, aListener );
     287             : 
     288           0 :             if( bReleaseLockedTheme )
     289             :             {
     290             :                 // release locked theme
     291           0 :                 pGal->ReleaseTheme( pTheme, theLockListener::get() );
     292           0 :                 bRet = true;
     293             :             }
     294           0 :         }
     295             :     }
     296             : 
     297           0 :     return bRet;
     298             : }
     299             : 
     300           0 : bool GalleryExplorer::EndLocking( sal_uIntPtr nThemeId )
     301             : {
     302           0 :     Gallery* pGal = ::Gallery::GetGalleryInstance();
     303           0 :     return pGal && EndLocking( pGal->GetThemeName( nThemeId ) );
     304             : }
     305             : 
     306             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10