LCOV - code coverage report
Current view: top level - sd/source/ui/toolpanel/controls - MasterPagesSelector.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 1 100.0 %
Date: 2012-08-25 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 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                 :            : #ifndef SD_TASKPANE_CONTROLS_MASTER_PAGES_SELECTOR_HXX
      30                 :            : #define SD_TASKPANE_CONTROLS_MASTER_PAGES_SELECTOR_HXX
      31                 :            : 
      32                 :            : #include "taskpane/TaskPaneTreeNode.hxx"
      33                 :            : #include "MasterPageContainer.hxx"
      34                 :            : #include "SlideSorterViewShell.hxx"
      35                 :            : 
      36                 :            : #include "pres.hxx"
      37                 :            : #include <sfx2/shell.hxx>
      38                 :            : #include <vcl/image.hxx>
      39                 :            : #include "glob.hxx"
      40                 :            : #include <osl/mutex.hxx>
      41                 :            : 
      42                 :            : #include <queue>
      43                 :            : 
      44                 :            : class MouseEvent;
      45                 :            : class SdDrawDocument;
      46                 :            : class SdPage;
      47                 :            : 
      48                 :            : namespace sd {
      49                 :            : class ViewShellBase;
      50                 :            : }
      51                 :            : 
      52                 :            : namespace sd { namespace toolpanel { namespace controls {
      53                 :            : 
      54                 :            : class PreviewValueSet;
      55                 :            : 
      56                 :            : /** Base class of a menu that lets the user select from a list of
      57                 :            :     templates or designs that are loaded from files.
      58                 :            : */
      59                 :            : class MasterPagesSelector
      60                 :            :     : public TreeNode,
      61                 :            :       public SfxShell
      62                 :            : {
      63                 :            : public:
      64                 :            :     TYPEINFO();
      65                 :         25 :     SFX_DECL_INTERFACE(SD_IF_SDMASTERPAGESSELECTOR)
      66                 :            : 
      67                 :            :     MasterPagesSelector (
      68                 :            :         TreeNode* pParent,
      69                 :            :         SdDrawDocument& rDocument,
      70                 :            :         ViewShellBase& rBase,
      71                 :            :         const ::boost::shared_ptr<MasterPageContainer>& rpContainer);
      72                 :            :     virtual ~MasterPagesSelector (void);
      73                 :            : 
      74                 :            :     virtual void LateInit (void);
      75                 :            : 
      76                 :            :     /** Return the height that this control needs to show all of its lines.
      77                 :            :     */
      78                 :            :     long GetRequiredHeight (int nWidth) const;
      79                 :            : 
      80                 :            :     /** The given master page, either the master page of a slide or a notes
      81                 :            :         page, is cloned and inserted into mrDocument.  The necessary styles
      82                 :            :         are copied as well.
      83                 :            :     */
      84                 :            :     static SdPage* AddMasterPage (
      85                 :            :         SdDrawDocument* pTargetDocument,
      86                 :            :         SdPage* pMasterPage,
      87                 :            :         sal_uInt16 nInsertionIndex);
      88                 :            : 
      89                 :            :     virtual Size GetPreferredSize (void);
      90                 :            :     virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeight);
      91                 :            :     virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth);
      92                 :            :     virtual bool IsResizable (void);
      93                 :            :     virtual ::Window* GetWindow (void);
      94                 :            :     virtual sal_Int32 GetMinimumWidth (void);
      95                 :            : 
      96                 :            :     virtual void Execute (SfxRequest& rRequest);
      97                 :            :     virtual void GetState (SfxItemSet& rItemSet);
      98                 :            : 
      99                 :            :     /** Update the selection of previews according to whatever
     100                 :            :         influences them appart from mouse and keyboard.  If, for
     101                 :            :         example, the current page of the main pane changes, then call
     102                 :            :         this method at the CurrentMasterPagesSelector to select the
     103                 :            :         previews of the master pages that are assigned to the new
     104                 :            :         current page.
     105                 :            : 
     106                 :            :         The default implementation of this method ignores the call. This is
     107                 :            :         used by e.g. the RecentMasterPagesSelector because it does not show
     108                 :            :         the currently used master pages by default and thus is not
     109                 :            :         influenced by its changes.
     110                 :            :     */
     111                 :            :     virtual void UpdateSelection (void);
     112                 :            : 
     113                 :            :     void FillPageSet (void);
     114                 :            : 
     115                 :            :     /** Make the selector empty.  This method clear the value set from any
     116                 :            :         entries. Overload this method to add functionality, especially to
     117                 :            :         destroy objects set as data items at the value set.
     118                 :            :     */
     119                 :            :     void ClearPageSet (void);
     120                 :            : 
     121                 :            :     using SfxShell::SetHelpId;
     122                 :            :     void SetHelpId( const rtl::OString& aId );
     123                 :            : 
     124                 :            :     /** Mark the preview that belongs to the given index as not up-to-date
     125                 :            :         anymore with respect to page content or preview size.
     126                 :            :         The implementation of this method will either sunchronously or
     127                 :            :         asynchronously call UpdatePreview().
     128                 :            :         @param nIndex
     129                 :            :             Index into the value set control that is used for displaying the
     130                 :            :             previews.
     131                 :            :     */
     132                 :            :     void InvalidatePreview (const SdPage* pPage);
     133                 :            : 
     134                 :            :     void UpdateAllPreviews (void);
     135                 :            : 
     136                 :            : protected:
     137                 :            :     mutable ::osl::Mutex maMutex;
     138                 :            :     ::boost::shared_ptr<MasterPageContainer> mpContainer;
     139                 :            : 
     140                 :            :     SdDrawDocument& mrDocument;
     141                 :            :     ::std::auto_ptr<PreviewValueSet> mpPageSet;
     142                 :            :     bool mbSmallPreviewSize;
     143                 :            :     ViewShellBase& mrBase;
     144                 :            :     /** Slot that is executed as default action when the left mouse button is
     145                 :            :         clicked over a master page.
     146                 :            :     */
     147                 :            :     sal_uInt16 mnDefaultClickAction;
     148                 :            :     /** Pages with pointers in this queue have their previews updated
     149                 :            :         eventually.  Filled by InvalidatePreview() and operated upon by
     150                 :            :         UpdatePreviews().
     151                 :            :     */
     152                 :            :     ::std::queue<sal_uInt16> maPreviewUpdateQueue;
     153                 :            : 
     154                 :            :     virtual SdPage* GetSelectedMasterPage (void);
     155                 :            : 
     156                 :            :     /** Assign the given master page to all slides of the document.
     157                 :            :         @param pMasterPage
     158                 :            :             The master page to assign to all slides.
     159                 :            :     */
     160                 :            :     void AssignMasterPageToAllSlides (SdPage* pMasterPage);
     161                 :            : 
     162                 :            :     /** Assign the given master page to all slides that are selected in a
     163                 :            :         slide sorter that is displayed in the lef or center pane.  When both
     164                 :            :         panes display a slide sorter then the one in the center pane is
     165                 :            :         used.
     166                 :            :     */
     167                 :            :     void AssignMasterPageToSelectedSlides (SdPage* pMasterPage);
     168                 :            : 
     169                 :            :     virtual void AssignMasterPageToPageList (
     170                 :            :         SdPage* pMasterPage,
     171                 :            :         const ::sd::slidesorter::SharedPageSelection& rPageList);
     172                 :            : 
     173                 :            :     virtual void NotifyContainerChangeEvent (const MasterPageContainerChangeEvent& rEvent);
     174                 :            : 
     175                 :            :     typedef ::std::pair<int, MasterPageContainer::Token> UserData;
     176                 :            :     UserData* CreateUserData (int nIndex, MasterPageContainer::Token aToken) const;
     177                 :            :     UserData* GetUserData (int nIndex) const;
     178                 :            :     void SetUserData (int nIndex, UserData* pData);
     179                 :            : 
     180                 :            :     virtual sal_Int32 GetIndexForToken (MasterPageContainer::Token aToken) const;
     181                 :            :     typedef ::std::vector<MasterPageContainer::Token> ItemList;
     182                 :            :     void UpdateItemList (::std::auto_ptr<ItemList> pList);
     183                 :            :     void Clear (void);
     184                 :            :     /** Invalidate the specified item so that on the next Fill() this item
     185                 :            :         is updated.
     186                 :            :     */
     187                 :            :     void InvalidateItem (MasterPageContainer::Token aToken);
     188                 :            : 
     189                 :            :     // For every item in the ValueSet we store its associated token.  This
     190                 :            :     // allows a faster access and easier change tracking.
     191                 :            :     ItemList maCurrentItemList;
     192                 :            :     typedef ::std::map<MasterPageContainer::Token,sal_Int32> TokenToValueSetIndex;
     193                 :            :     TokenToValueSetIndex maTokenToValueSetIndex;
     194                 :            : 
     195                 :            :     ItemList maLockedMasterPages;
     196                 :            :     /** Lock master pages in the given list and release locks that where
     197                 :            :         previously aquired.
     198                 :            :     */
     199                 :            :     void UpdateLocks (const ItemList& rItemList);
     200                 :            : 
     201                 :            :     void Fill (void);
     202                 :            :     virtual void Fill (ItemList& rItemList) = 0;
     203                 :            : 
     204                 :            :     /** Give derived classes the oportunity to provide their own context
     205                 :            :         menu.  If they do then they probably have to provide their own
     206                 :            :         Execute() and GetState() methods as well.
     207                 :            :     */
     208                 :            :     virtual ResId GetContextMenuResId (void) const;
     209                 :            : 
     210                 :            : private:
     211                 :            :     /** The offset between ValueSet index and MasterPageContainer::Token
     212                 :            :         last seen.  This value is used heuristically to speed up the lookup
     213                 :            :         of an index for a token.
     214                 :            :     */
     215                 :            :     DECL_LINK(ClickHandler, void *);
     216                 :            :     DECL_LINK(RightClickHandler, MouseEvent*);
     217                 :            :     DECL_LINK(ContextMenuCallback, CommandEvent*);
     218                 :            :     DECL_LINK(ContainerChangeListener, MasterPageContainerChangeEvent*);
     219                 :            : 
     220                 :            :     void SetItem (
     221                 :            :         sal_uInt16 nIndex,
     222                 :            :         MasterPageContainer::Token aToken);
     223                 :            :     void AddTokenToIndexEntry (
     224                 :            :         sal_uInt16 nIndex,
     225                 :            :         MasterPageContainer::Token aToken);
     226                 :            :     void RemoveTokenToIndexEntry (
     227                 :            :         sal_uInt16 nIndex,
     228                 :            :         MasterPageContainer::Token aToken);
     229                 :            : };
     230                 :            : 
     231                 :            : } } } // end of namespace ::sd::toolpanel::controls
     232                 :            : 
     233                 :            : #endif
     234                 :            : 
     235                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10