LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/svx - galtheme.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 8 25 32.0 %
Date: 2013-07-09 Functions: 7 18 38.9 %
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             : #ifndef _SVX_GALTHEME_HXX_
      21             : #define _SVX_GALTHEME_HXX_
      22             : 
      23             : #include "svx/svxdllapi.h"
      24             : 
      25             : #include <tools/debug.hxx>
      26             : #include <tools/urlobj.hxx>
      27             : #include <vcl/salctype.hxx>
      28             : #include <svl/brdcst.hxx>
      29             : #include <svl/lstner.hxx>
      30             : #include <svtools/transfer.hxx>
      31             : #include <sot/storage.hxx>
      32             : #include <svx/svdmodel.hxx>
      33             : #include <svx/galmisc.hxx>
      34             : #include <vector>
      35             : 
      36             : // -----------------
      37             : // - GalleryObject -
      38             : // -----------------
      39             : // --------------
      40             : // - SgaObjKind -
      41             : // --------------
      42             : 
      43        1006 : struct GalleryObject
      44             : {
      45             :     INetURLObject   aURL;
      46             :     sal_uInt32      nOffset;
      47             :     SgaObjKind      eObjKind;
      48             :     bool            mbDelete;
      49             : 
      50             :     //UI visualization buffering
      51             :     BitmapEx        maPreviewBitmapEx;
      52             :     Size            maPreparedSize;
      53             :     String          maTitle;
      54             :     String          maPath;
      55             : };
      56             : 
      57             : typedef ::std::vector< GalleryObject* > GalleryObjectList;
      58             : 
      59             : class GalleryThemeEntry;
      60             : class SgaObject;
      61             : class FmFormModel;
      62             : class ListBox;
      63             : 
      64             : // -----------------
      65             : // - GalDragParams -
      66             : // -----------------
      67             : 
      68             : struct GalDragParams
      69             : {
      70             :     Region  aDragRegion;
      71             :     sal_uIntPtr nDragObjPos;
      72             :     OUString aThemeName;
      73             :     OUString aFileName;
      74             :     SgaObjKind  eObjKind;
      75             : };
      76             : 
      77             : // ----------------
      78             : // - GalleryTheme -
      79             : // ----------------
      80             : 
      81             : class Gallery;
      82             : class GalleryProgress;
      83             : namespace unogallery
      84             : {
      85             :     class GalleryTheme;
      86             :     class GalleryItem;
      87             : }
      88             : 
      89             : class GalleryTheme : public SfxBroadcaster
      90             : {
      91             :     friend class Gallery;
      92             :     friend class GalleryThemeCacheEntry;
      93             :     friend class ::unogallery::GalleryTheme;
      94             :     friend class ::unogallery::GalleryItem;
      95             : 
      96             : private:
      97             : 
      98             :     GalleryObjectList           aObjectList;
      99             :     String                      m_aDestDir;
     100             :     bool                        m_bDestDirRelative;
     101             :     SotStorageRef               aSvDrawStorageRef;
     102             :     Gallery*                    pParent;
     103             :     GalleryThemeEntry*          pThm;
     104             :     sal_uIntPtr                     mnThemeLockCount;
     105             :     sal_uIntPtr                     mnBroadcasterLockCount;
     106             :     sal_uIntPtr                     nDragPos;
     107             :     sal_Bool                        bDragging;
     108             :     sal_Bool                        bAbortActualize;
     109             : 
     110             :     void                        ImplCreateSvDrawStorage();
     111             :     SVX_DLLPUBLIC SgaObject*                    ImplReadSgaObject( GalleryObject* pEntry );
     112             :     sal_Bool                    ImplWriteSgaObject( const SgaObject& rObj, size_t nPos, GalleryObject* pExistentEntry );
     113             :     void                        ImplWrite();
     114         503 :     const GalleryObject*        ImplGetGalleryObject( size_t nPos ) const
     115         503 :                                 { return ( nPos < aObjectList.size() ) ? aObjectList[ nPos ] : NULL; }
     116             :     SVX_DLLPUBLIC const GalleryObject*      ImplGetGalleryObject( const INetURLObject& rURL );
     117             : 
     118           0 :     size_t                      ImplGetGalleryObjectPos( const GalleryObject* pObj ) const
     119             :                                 {
     120           0 :                                     for ( size_t i = 0, n = aObjectList.size(); i < n; ++i )
     121           0 :                                         if ( pObj == aObjectList[ i ] )
     122           0 :                                             return i;
     123           0 :                                     return size_t(-1);
     124             :                                 }
     125             :     INetURLObject               ImplGetURL( const GalleryObject* pObject ) const;
     126             :     INetURLObject               ImplCreateUniqueURL( SgaObjKind eObjKind, sal_uIntPtr nFormat = CVT_UNKNOWN );
     127             :     void                        ImplSetModified( sal_Bool bModified );
     128             :     void                        ImplBroadcast( sal_uIntPtr nUpdatePos );
     129             : 
     130             :                                 GalleryTheme();
     131             :                                 GalleryTheme( Gallery* pGallery, GalleryThemeEntry* pThemeEntry );
     132             :                                 ~GalleryTheme();
     133             : 
     134             : public:
     135             : 
     136             :     static GalleryThemeEntry*   CreateThemeEntry( const INetURLObject& rURL, sal_Bool bReadOnly );
     137             : 
     138        2034 :     size_t                      GetObjectCount() const { return aObjectList.size(); }
     139             : 
     140             :     SVX_DLLPUBLIC SgaObject*    AcquireObject( size_t nPos );
     141             :     SVX_DLLPUBLIC void          ReleaseObject( SgaObject* pObj );
     142             : 
     143             :     SVX_DLLPUBLIC bool          InsertObject( const SgaObject& rObj, sal_uIntPtr nPos = LIST_APPEND );
     144             :     SVX_DLLPUBLIC bool          RemoveObject( size_t nPos );
     145             :     bool                        ChangeObjectPos( size_t nOldPos, size_t nNewPos );
     146             : 
     147             :     SVX_DLLPUBLIC const OUString& GetName() const;
     148             :     const OUString&        GetRealName() const;
     149             : 
     150             :     // used for building gallery themes during compilation:
     151             :     const String&               GetDestDir() const { return m_aDestDir; }
     152          11 :     void                        SetDestDir(const String& rDestDir, bool bRelative = true)
     153          11 :                                 { m_aDestDir = rDestDir; m_bDestDirRelative = bRelative; }
     154             : 
     155             :     const INetURLObject&        GetThmURL() const;
     156             :     SVX_DLLPUBLIC const INetURLObject&      GetSdgURL() const;
     157             :     const INetURLObject&        GetSdvURL() const;
     158             : 
     159             :     SVX_DLLPUBLIC sal_uInt32        GetId() const;
     160             :     void                        SetId( sal_uInt32 nNewId, sal_Bool bResetThemeName );
     161             : 
     162           0 :     void                        SetDragging( sal_Bool bSet ) { bDragging = bSet; }
     163           0 :     sal_Bool                        IsDragging() const { return bDragging; }
     164             : 
     165           0 :     void                        LockTheme() { ++mnThemeLockCount; }
     166             :     sal_Bool                        UnlockTheme();
     167             : 
     168           0 :     void                        LockBroadcaster() { mnBroadcasterLockCount++; }
     169             :     SVX_DLLPUBLIC void          UnlockBroadcaster( sal_uIntPtr nUpdatePos = 0 );
     170         503 :     sal_Bool                        IsBroadcasterLocked() const { return mnBroadcasterLockCount > 0; }
     171             : 
     172           0 :     void                        SetDragPos( sal_uIntPtr nPos ) { nDragPos = nPos; }
     173           0 :     sal_uIntPtr                     GetDragPos() const { return nDragPos; }
     174             : 
     175             :     sal_Bool                        IsThemeNameFromResource() const;
     176             : 
     177             :     SVX_DLLPUBLIC sal_Bool          IsReadOnly() const;
     178             :     SVX_DLLPUBLIC sal_Bool          IsDefault() const;
     179             :     sal_Bool                        IsModified() const;
     180             : 
     181             :     SVX_DLLPUBLIC void                      Actualize( const Link& rActualizeLink, GalleryProgress* pProgress = NULL );
     182           0 :     void                        AbortActualize() { bAbortActualize = sal_True; }
     183             : 
     184          66 :     Gallery*                    GetParent() const { return pParent; }
     185           0 :     SotStorageRef               GetSvDrawStorage() const { return aSvDrawStorageRef; }
     186             : 
     187             : public:
     188             : 
     189           0 :     SgaObjKind                  GetObjectKind( sal_uIntPtr nPos ) const
     190             :                                 {
     191             :                                     DBG_ASSERT( nPos < GetObjectCount(), "Position out of range" );
     192           0 :                                     return ImplGetGalleryObject( nPos )->eObjKind;
     193             :                                 }
     194             : 
     195             : 
     196           0 :     const INetURLObject&        GetObjectURL( sal_uIntPtr nPos ) const
     197             :                                 {
     198             :                                     DBG_ASSERT( nPos < GetObjectCount(), "Position out of range" );
     199           0 :                                     return ImplGetGalleryObject( nPos )->aURL;
     200             :                                 }
     201             : 
     202             :     sal_Bool                        GetThumb( sal_uIntPtr nPos, BitmapEx& rBmp, sal_Bool bProgress = sal_False );
     203             : 
     204             :     SVX_DLLPUBLIC sal_Bool                      GetGraphic( sal_uIntPtr nPos, Graphic& rGraphic, sal_Bool bProgress = sal_False );
     205             :     SVX_DLLPUBLIC sal_Bool                      InsertGraphic( const Graphic& rGraphic, sal_uIntPtr nInsertPos = LIST_APPEND );
     206             : 
     207             :     SVX_DLLPUBLIC sal_Bool                      GetModel( sal_uIntPtr nPos, SdrModel& rModel, sal_Bool bProgress = sal_False );
     208             :     SVX_DLLPUBLIC sal_Bool                      InsertModel( const FmFormModel& rModel, sal_uIntPtr nInsertPos = LIST_APPEND );
     209             : 
     210             :     sal_Bool                        GetModelStream( sal_uIntPtr nPos, SotStorageStreamRef& rModelStreamRef, sal_Bool bProgress = sal_False );
     211             :     sal_Bool                        InsertModelStream( const SotStorageStreamRef& rModelStream, sal_uIntPtr nInsertPos = LIST_APPEND );
     212             : 
     213             :     sal_Bool                        GetURL( sal_uIntPtr nPos, INetURLObject& rURL, sal_Bool bProgress = sal_False );
     214             :     SVX_DLLPUBLIC sal_Bool                      InsertURL( const INetURLObject& rURL, sal_uIntPtr nInsertPos = LIST_APPEND );
     215             :     sal_Bool                        InsertFileOrDirURL( const INetURLObject& rFileOrDirURL, sal_uIntPtr nInsertPos = LIST_APPEND );
     216             : 
     217             :     sal_Bool                        InsertTransferable( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& rxTransferable, sal_uIntPtr nInsertPos );
     218             : 
     219             :     void                        CopyToClipboard( Window* pWindow, sal_uIntPtr nPos );
     220             :     void                        StartDrag( Window* pWindow, sal_uIntPtr nPos );
     221             : 
     222             : public:
     223             : 
     224             :     SvStream&                   WriteData( SvStream& rOut ) const;
     225             :     SvStream&                   ReadData( SvStream& rIn );
     226             :     static SVX_DLLPUBLIC void   InsertAllThemes( ListBox& rListBox );
     227             : 
     228             :     // for buffering PreviewBitmaps and strings for object and path
     229             :     void GetPreviewBitmapExAndStrings(sal_uIntPtr nPos, BitmapEx& rBitmapEx, Size& rSize, String& rTitle, String& rPath) const;
     230             :     void SetPreviewBitmapExAndStrings(sal_uIntPtr nPos, const BitmapEx& rBitmapEx, const Size& rSize, const String& rTitle, const String& rPath);
     231             : };
     232             : 
     233             : SvStream& operator<<( SvStream& rOut, const GalleryTheme& rTheme );
     234             : SvStream& operator>>( SvStream& rIn, GalleryTheme& rTheme );
     235             : 
     236             : #endif
     237             : 
     238             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10