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

Generated by: LCOV version 1.11