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

Generated by: LCOV version 1.10