LCOV - code coverage report
Current view: top level - sd/source/ui/toolpanel/controls - MasterPagesSelector.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 310 1.0 %
Date: 2012-08-25 Functions: 3 52 5.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 583 1.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                 :            : 
      30                 :            : #include "MasterPagesSelector.hxx"
      31                 :            : 
      32                 :            : #include "MasterPageContainer.hxx"
      33                 :            : #include "DocumentHelper.hxx"
      34                 :            : #include "pres.hxx"
      35                 :            : #include "drawdoc.hxx"
      36                 :            : #include "DrawDocShell.hxx"
      37                 :            : #include "sdpage.hxx"
      38                 :            : #include "glob.hxx"
      39                 :            : #include "glob.hrc"
      40                 :            : #include "app.hrc"
      41                 :            : #include "res_bmp.hrc"
      42                 :            : #include "strings.hrc"
      43                 :            : #include "DrawViewShell.hxx"
      44                 :            : #include "DrawController.hxx"
      45                 :            : #include "SlideSorterViewShell.hxx"
      46                 :            : #include "PreviewValueSet.hxx"
      47                 :            : #include "ViewShellBase.hxx"
      48                 :            : #include "../TaskPaneShellManager.hxx"
      49                 :            : #include "taskpane/TitledControl.hxx"
      50                 :            : #include "taskpane/ControlContainer.hxx"
      51                 :            : #include "controller/SlideSorterController.hxx"
      52                 :            : #include "controller/SlsPageSelector.hxx"
      53                 :            : #include <sfx2/objface.hxx>
      54                 :            : #include "sdresid.hxx"
      55                 :            : #include "TemplateScanner.hxx"
      56                 :            : #include "drawview.hxx"
      57                 :            : #include <vcl/image.hxx>
      58                 :            : #include <svl/languageoptions.hxx>
      59                 :            : #include <sfx2/app.hxx>
      60                 :            : #include <sfx2/dispatch.hxx>
      61                 :            : #include <sfx2/mnumgr.hxx>
      62                 :            : #include <svl/itemset.hxx>
      63                 :            : #include <svl/eitem.hxx>
      64                 :            : #include <svx/dlgutil.hxx>
      65                 :            : #include <svx/svdpagv.hxx>
      66                 :            : #include <svx/svxids.hrc>
      67                 :            : #include "FrameView.hxx"
      68                 :            : #include "stlpool.hxx"
      69                 :            : #include "unmovss.hxx"
      70                 :            : #include <sfx2/request.hxx>
      71                 :            : #include <svl/itempool.hxx>
      72                 :            : 
      73                 :            : using namespace ::sd::toolpanel::controls;
      74                 :            : #define MasterPagesSelector
      75                 :            : #include "sdslots.hxx"
      76                 :            : 
      77                 :            : using namespace ::com::sun::star::text;
      78                 :            : 
      79                 :            : 
      80                 :            : 
      81                 :            : namespace sd { namespace toolpanel { namespace controls {
      82                 :            : 
      83                 :            : 
      84 [ +  + ][ +  - ]:         75 : SFX_IMPL_INTERFACE(MasterPagesSelector, SfxShell,
                 [ +  - ]
      85                 :            :     SdResId(STR_MASTERPAGESSELECTOR))
      86                 :            : {
      87 [ +  - ][ +  - ]:         25 :     SFX_POPUPMENU_REGISTRATION( SdResId(RID_TASKPANE_MASTERPAGESSELECTOR_POPUP) );
      88                 :         25 : }
      89                 :            : 
      90 [ #  # ][ #  # ]:          0 : TYPEINIT1(MasterPagesSelector, SfxShell);
      91                 :            : 
      92                 :            : 
      93                 :            : 
      94                 :          0 : MasterPagesSelector::MasterPagesSelector (
      95                 :            :     TreeNode* pParent,
      96                 :            :     SdDrawDocument& rDocument,
      97                 :            :     ViewShellBase& rBase,
      98                 :            :     const ::boost::shared_ptr<MasterPageContainer>& rpContainer)
      99                 :            :     : TreeNode (pParent),
     100                 :            :       SfxShell(),
     101                 :            :       maMutex(),
     102                 :            :       mpContainer(rpContainer),
     103                 :            :       mrDocument(rDocument),
     104         [ #  # ]:          0 :       mpPageSet (new PreviewValueSet(pParent)),
     105                 :            :       mrBase(rBase),
     106                 :            :       mnDefaultClickAction(SID_TP_APPLY_TO_ALL_SLIDES),
     107                 :            :       maPreviewUpdateQueue(),
     108                 :            :       maCurrentItemList(),
     109                 :            :       maTokenToValueSetIndex(),
     110 [ #  # ][ #  # ]:          0 :       maLockedMasterPages()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     111                 :            : {
     112                 :          0 :     SetPool (&rDocument.GetPool());
     113                 :            : 
     114                 :          0 :     mpPageSet->SetSelectHdl (
     115         [ #  # ]:          0 :         LINK(this, MasterPagesSelector, ClickHandler));
     116                 :            :     mpPageSet->SetRightMouseClickHandler (
     117 [ #  # ][ #  # ]:          0 :         LINK(this, MasterPagesSelector, RightClickHandler));
     118                 :            :     mpPageSet->SetContextMenuCallback (
     119 [ #  # ][ #  # ]:          0 :         LINK(this, MasterPagesSelector, ContextMenuCallback));
     120 [ #  # ][ #  # ]:          0 :     mpPageSet->SetStyle(mpPageSet->GetStyle() | WB_NO_DIRECTSELECT);
     121 [ #  # ][ #  # ]:          0 :     mpPageSet->SetPreviewSize(mpContainer->GetPreviewSizePixel());
     122         [ #  # ]:          0 :     mpPageSet->Show();
     123                 :            : 
     124         [ #  # ]:          0 :     Link aChangeListener (LINK(this,MasterPagesSelector,ContainerChangeListener));
     125         [ #  # ]:          0 :     mpContainer->AddChangeListener(aChangeListener);
     126                 :          0 : }
     127                 :            : 
     128                 :            : 
     129                 :            : 
     130                 :            : 
     131 [ #  # ][ #  # ]:          0 : MasterPagesSelector::~MasterPagesSelector (void)
         [ #  # ][ #  # ]
     132                 :            : {
     133         [ #  # ]:          0 :     Clear();
     134                 :          0 :     mpPageSet.reset();
     135 [ #  # ][ #  # ]:          0 :     UpdateLocks(ItemList());
     136                 :            : 
     137 [ #  # ][ #  # ]:          0 :     if (GetShellManager() != NULL)
     138 [ #  # ][ #  # ]:          0 :         GetShellManager()->RemoveSubShell (this);
     139                 :            : 
     140         [ #  # ]:          0 :     Link aChangeListener (LINK(this,MasterPagesSelector,ContainerChangeListener));
     141         [ #  # ]:          0 :     mpContainer->RemoveChangeListener(aChangeListener);
     142         [ #  # ]:          0 : }
     143                 :            : 
     144                 :            : 
     145                 :            : 
     146                 :            : 
     147                 :          0 : void MasterPagesSelector::LateInit (void)
     148                 :            : {
     149                 :          0 : }
     150                 :            : 
     151                 :            : 
     152                 :            : 
     153                 :            : 
     154                 :          0 : sal_Int32 MasterPagesSelector::GetPreferredWidth (sal_Int32 nHeight)
     155                 :            : {
     156         [ #  # ]:          0 :     const ::osl::MutexGuard aGuard (maMutex);
     157                 :            : 
     158 [ #  # ][ #  # ]:          0 :     return mpPageSet->GetPreferredWidth (nHeight);
     159                 :            : }
     160                 :            : 
     161                 :            : 
     162                 :            : 
     163                 :            : 
     164                 :          0 : sal_Int32 MasterPagesSelector::GetPreferredHeight (sal_Int32 nWidth)
     165                 :            : {
     166         [ #  # ]:          0 :     const ::osl::MutexGuard aGuard (maMutex);
     167                 :            : 
     168 [ #  # ][ #  # ]:          0 :     return mpPageSet->GetPreferredHeight (nWidth);
     169                 :            : }
     170                 :            : 
     171                 :            : 
     172                 :            : 
     173                 :            : 
     174                 :          0 : Size MasterPagesSelector::GetPreferredSize (void)
     175                 :            : {
     176                 :            :     int nPreferredWidth = GetPreferredWidth(
     177         [ #  # ]:          0 :         mpPageSet->GetOutputSizePixel().Height());
     178                 :          0 :     int nPreferredHeight = GetPreferredHeight(nPreferredWidth);
     179                 :          0 :     return Size (nPreferredWidth, nPreferredHeight);
     180                 :            : 
     181                 :            : }
     182                 :            : 
     183                 :            : 
     184                 :            : 
     185                 :            : 
     186                 :          0 : void MasterPagesSelector::UpdateLocks (const ItemList& rItemList)
     187                 :            : {
     188         [ #  # ]:          0 :     ItemList aNewLockList;
     189                 :            : 
     190                 :            :     // In here we first lock the master pages in the given list and then
     191                 :            :     // release the locks acquired in a previous call to this method.  When
     192                 :            :     // this were done the other way round the lock count of some master
     193                 :            :     // pages might drop temporarily to 0 and would lead to unnecessary
     194                 :            :     // deletion and re-creation of MasterPageDescriptor objects.
     195                 :            : 
     196                 :            :     // Lock the master pages in the given list.
     197                 :          0 :     ItemList::const_iterator iItem;
     198 [ #  # ][ #  # ]:          0 :     for (iItem=rItemList.begin(); iItem!=rItemList.end(); ++iItem)
                 [ #  # ]
     199                 :            :     {
     200 [ #  # ][ #  # ]:          0 :         mpContainer->AcquireToken(*iItem);
     201 [ #  # ][ #  # ]:          0 :         aNewLockList.push_back(*iItem);
     202                 :            :     }
     203                 :            : 
     204                 :            :     // Release the previously locked master pages.
     205                 :          0 :     ItemList::const_iterator iPage;
     206         [ #  # ]:          0 :     ItemList::const_iterator iEnd (maLockedMasterPages.end());
     207 [ #  # ][ #  # ]:          0 :     for (iPage=maLockedMasterPages.begin(); iPage!=iEnd; ++iPage)
         [ #  # ][ #  # ]
     208 [ #  # ][ #  # ]:          0 :         mpContainer->ReleaseToken(*iPage);
     209                 :            : 
     210                 :          0 :     maLockedMasterPages.swap(aNewLockList);
     211                 :          0 : }
     212                 :            : 
     213                 :            : 
     214                 :            : 
     215                 :            : 
     216                 :          0 : void MasterPagesSelector::Fill (void)
     217                 :            : {
     218 [ #  # ][ #  # ]:          0 :     ::std::auto_ptr<ItemList> pItemList (new ItemList());
     219                 :            : 
     220         [ #  # ]:          0 :     Fill(*pItemList);
     221                 :            : 
     222         [ #  # ]:          0 :     UpdateLocks(*pItemList);
     223 [ #  # ][ #  # ]:          0 :     UpdateItemList(pItemList);
                 [ #  # ]
     224                 :          0 : }
     225                 :            : 
     226                 :            : 
     227                 :            : 
     228                 :            : 
     229                 :          0 : ResId MasterPagesSelector::GetContextMenuResId (void) const
     230                 :            : {
     231                 :          0 :     return SdResId(RID_TASKPANE_MASTERPAGESSELECTOR_POPUP);
     232                 :            : }
     233                 :            : 
     234                 :            : 
     235                 :            : 
     236                 :            : 
     237                 :          0 : IMPL_LINK_NOARG(MasterPagesSelector, ClickHandler)
     238                 :            : {
     239                 :            :     // We use the framework to assign the clicked-on master page because we
     240                 :            :     // so use the same mechanism as the context menu does (where we do not
     241                 :            :     // have the option to call the assignment method directly.)
     242         [ #  # ]:          0 :     if (GetShellManager() != NULL)
     243                 :          0 :         GetShellManager()->MoveToTop (this);
     244                 :            : 
     245                 :          0 :     SfxViewFrame* pViewFrame = mrBase.GetViewFrame();
     246         [ #  # ]:          0 :     if (pViewFrame != NULL)
     247                 :            :     {
     248                 :          0 :         SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher();
     249         [ #  # ]:          0 :         if (pDispatcher != NULL)
     250                 :          0 :             pDispatcher->Execute(mnDefaultClickAction);
     251                 :            :     }
     252                 :            : 
     253                 :          0 :     return 0;
     254                 :            : }
     255                 :            : 
     256                 :            : 
     257                 :            : 
     258                 :            : 
     259                 :          0 : IMPL_LINK(MasterPagesSelector, RightClickHandler, MouseEvent*, pEvent)
     260                 :            : {
     261                 :            :     // Here we only prepare the display of the context menu: the item under
     262                 :            :     // the mouse is selected.  The actual display of the context menu is
     263                 :            :     // done in ContextMenuCallback which is called indirectly through
     264                 :            :     // PreviewValueSet::Command().
     265                 :          0 :     mpPageSet->GrabFocus ();
     266                 :          0 :     mpPageSet->ReleaseMouse();
     267 [ #  # ][ #  # ]:          0 :     if (GetDispatcher() != NULL &&  pEvent != NULL)
                 [ #  # ]
     268                 :            :     {
     269                 :          0 :         sal_uInt16 nIndex = mpPageSet->GetItemId (pEvent->GetPosPixel());
     270         [ #  # ]:          0 :         if (nIndex > 0)
     271                 :          0 :             mpPageSet->SelectItem (nIndex);
     272                 :            :     }
     273                 :          0 :     return 0;
     274                 :            : }
     275                 :            : 
     276                 :            : 
     277                 :            : 
     278                 :            : 
     279                 :          0 : IMPL_LINK(MasterPagesSelector, ContextMenuCallback, CommandEvent*, pEvent)
     280                 :            : {
     281                 :            :     // Use the currently selected item and show the popup menu in its
     282                 :            :     // center.
     283         [ #  # ]:          0 :     if (GetShellManager() != NULL)
     284                 :          0 :         GetShellManager()->MoveToTop (this);
     285                 :          0 :     const sal_uInt16 nIndex = mpPageSet->GetSelectItemId();
     286 [ #  # ][ #  # ]:          0 :     if (nIndex > 0 && pEvent!=NULL)
     287                 :            :     {
     288                 :            :         // The position of the upper left corner of the context menu is
     289                 :            :         // taken either from the mouse position (when the command was sent
     290                 :            :         // as reaction to a right click) or in the center of the selected
     291                 :            :         // item (when the command was sent as reaction to Shift+F10.)
     292                 :          0 :         Point aPosition (pEvent->GetMousePosPixel());
     293         [ #  # ]:          0 :         if ( ! pEvent->IsMouseEvent())
     294                 :            :         {
     295         [ #  # ]:          0 :             Rectangle aBBox (mpPageSet->GetItemRect(nIndex));
     296         [ #  # ]:          0 :             aPosition = aBBox.Center();
     297                 :            :         }
     298                 :            : 
     299         [ #  # ]:          0 :         const ResId aPopupResId (GetContextMenuResId());
     300                 :            :         mrBase.GetViewFrame()->GetDispatcher()->ExecutePopup(
     301                 :            :             aPopupResId,
     302                 :          0 :             mpPageSet.get(),
     303         [ #  # ]:          0 :             &aPosition);
     304                 :            :     }
     305                 :            : 
     306                 :          0 :     return 0;
     307                 :            : }
     308                 :            : 
     309                 :            : 
     310                 :            : 
     311                 :            : 
     312                 :          0 : IMPL_LINK(MasterPagesSelector, ContainerChangeListener, MasterPageContainerChangeEvent*, pEvent)
     313                 :            : {
     314         [ #  # ]:          0 :     if (pEvent)
     315                 :          0 :         NotifyContainerChangeEvent(*pEvent);
     316                 :          0 :     return 0;
     317                 :            : }
     318                 :            : 
     319                 :            : 
     320                 :            : 
     321                 :            : 
     322                 :          0 : SdPage* MasterPagesSelector::GetSelectedMasterPage (void)
     323                 :            : {
     324         [ #  # ]:          0 :     const ::osl::MutexGuard aGuard (maMutex);
     325                 :            : 
     326                 :          0 :     SdPage* pMasterPage = NULL;
     327                 :          0 :     sal_uInt16 nIndex = mpPageSet->GetSelectItemId();
     328         [ #  # ]:          0 :     UserData* pData = GetUserData(nIndex);
     329         [ #  # ]:          0 :     if (pData != NULL)
     330                 :            :     {
     331         [ #  # ]:          0 :         pMasterPage = mpContainer->GetPageObjectForToken(pData->second);
     332                 :            :     }
     333         [ #  # ]:          0 :     return pMasterPage;
     334                 :            : }
     335                 :            : 
     336                 :            : 
     337                 :            : 
     338                 :            : 
     339                 :            : /** Assemble a list of all slides of the document and pass it to
     340                 :            :     AssignMasterPageToPageList().
     341                 :            : */
     342                 :          0 : void MasterPagesSelector::AssignMasterPageToAllSlides (SdPage* pMasterPage)
     343                 :            : {
     344         [ #  # ]:          0 :     if (pMasterPage == NULL)
     345                 :            :         return;
     346                 :            : 
     347         [ #  # ]:          0 :     sal_uInt16 nPageCount = mrDocument.GetSdPageCount(PK_STANDARD);
     348         [ #  # ]:          0 :     if (nPageCount == 0)
     349                 :            :         return;
     350                 :            : 
     351                 :            :     // Get a list of all pages.  As a little optimization we only
     352                 :            :     // include pages that do not already have the given master page
     353                 :            :     // assigned.
     354         [ #  # ]:          0 :     String sFullLayoutName (pMasterPage->GetLayoutName());
     355                 :            :     ::sd::slidesorter::SharedPageSelection pPageList (
     356 [ #  # ][ #  # ]:          0 :         new ::sd::slidesorter::SlideSorterViewShell::PageSelection());
                 [ #  # ]
     357         [ #  # ]:          0 :     for (sal_uInt16 nPageIndex=0; nPageIndex<nPageCount; nPageIndex++)
     358                 :            :     {
     359         [ #  # ]:          0 :         SdPage* pPage = mrDocument.GetSdPage (nPageIndex, PK_STANDARD);
     360 [ #  # ][ #  # ]:          0 :         if (pPage != NULL
                 [ #  # ]
     361 [ #  # ][ #  # ]:          0 :             && pPage->GetLayoutName().CompareTo(sFullLayoutName)!=0)
         [ #  # ][ #  # ]
                 [ #  # ]
     362                 :            :         {
     363         [ #  # ]:          0 :             pPageList->push_back (pPage);
     364                 :            :         }
     365                 :            :     }
     366                 :            : 
     367 [ #  # ][ #  # ]:          0 :     AssignMasterPageToPageList(pMasterPage, pPageList);
                 [ #  # ]
     368                 :            : }
     369                 :            : 
     370                 :            : 
     371                 :            : 
     372                 :            : 
     373                 :            : /** Assemble a list of the currently selected slides (selected in a visible
     374                 :            :     slide sorter) and pass it to AssignMasterPageToPageList().
     375                 :            : */
     376                 :          0 : void MasterPagesSelector::AssignMasterPageToSelectedSlides (
     377                 :            :     SdPage* pMasterPage)
     378                 :            : {
     379                 :            :     using namespace ::sd::slidesorter;
     380                 :            :     using namespace ::sd::slidesorter::controller;
     381                 :            : 
     382         [ #  # ]:          0 :     if (pMasterPage == NULL)
     383                 :            :         return;
     384                 :            : 
     385                 :            :     // Find a visible slide sorter.
     386         [ #  # ]:          0 :     SlideSorterViewShell* pSlideSorter = SlideSorterViewShell::GetSlideSorter(mrBase);
     387         [ #  # ]:          0 :     if (pSlideSorter == NULL)
     388                 :            :         return;
     389                 :            : 
     390                 :            :     // Get a list of selected pages.
     391         [ #  # ]:          0 :     SharedPageSelection pPageSelection = pSlideSorter->GetPageSelection();
     392         [ #  # ]:          0 :     if (pPageSelection->empty())
     393                 :            :         return;
     394                 :            : 
     395         [ #  # ]:          0 :     AssignMasterPageToPageList(pMasterPage, pPageSelection);
     396                 :            : 
     397                 :            :     // Restore the previous selection.
     398 [ #  # ][ #  # ]:          0 :     pSlideSorter->SetPageSelection(pPageSelection);
                 [ #  # ]
     399                 :            : }
     400                 :            : 
     401                 :            : 
     402                 :            : 
     403                 :            : 
     404                 :          0 : void MasterPagesSelector::AssignMasterPageToPageList (
     405                 :            :     SdPage* pMasterPage,
     406                 :            :     const ::sd::slidesorter::SharedPageSelection& rPageList)
     407                 :            : {
     408                 :          0 :     DocumentHelper::AssignMasterPageToPageList(mrDocument, pMasterPage, rPageList);
     409                 :          0 : }
     410                 :            : 
     411                 :            : 
     412                 :            : 
     413                 :            : 
     414                 :          0 : void MasterPagesSelector::NotifyContainerChangeEvent (const MasterPageContainerChangeEvent& rEvent)
     415                 :            : {
     416         [ #  # ]:          0 :     const ::osl::MutexGuard aGuard (maMutex);
     417                 :            : 
     418   [ #  #  #  # ]:          0 :     switch (rEvent.meEventType)
     419                 :            :     {
     420                 :            :         case MasterPageContainerChangeEvent::SIZE_CHANGED:
     421 [ #  # ][ #  # ]:          0 :             mpPageSet->SetPreviewSize(mpContainer->GetPreviewSizePixel());
     422         [ #  # ]:          0 :             UpdateAllPreviews();
     423                 :          0 :             break;
     424                 :            : 
     425                 :            :         case MasterPageContainerChangeEvent::PREVIEW_CHANGED:
     426                 :            :         {
     427         [ #  # ]:          0 :             int nIndex (GetIndexForToken(rEvent.maChildToken));
     428         [ #  # ]:          0 :             if (nIndex >= 0)
     429                 :            :             {
     430                 :          0 :                 mpPageSet->SetItemImage (
     431                 :            :                     (sal_uInt16)nIndex,
     432   [ #  #  #  # ]:          0 :                     mpContainer->GetPreviewForToken(rEvent.maChildToken));
                 [ #  # ]
     433 [ #  # ][ #  # ]:          0 :                 mpPageSet->Invalidate(mpPageSet->GetItemRect((sal_uInt16)nIndex));
     434                 :            :             }
     435                 :            :         }
     436                 :          0 :         break;
     437                 :            : 
     438                 :            :         case MasterPageContainerChangeEvent::DATA_CHANGED:
     439                 :            :         {
     440         [ #  # ]:          0 :             InvalidateItem(rEvent.maChildToken);
     441         [ #  # ]:          0 :             Fill();
     442                 :            :         }
     443                 :          0 :         break;
     444                 :            : 
     445                 :            :         default:
     446                 :          0 :             break;
     447         [ #  # ]:          0 :    }
     448                 :          0 : }
     449                 :            : 
     450                 :            : 
     451                 :            : 
     452                 :            : 
     453                 :          0 : MasterPagesSelector::UserData* MasterPagesSelector::CreateUserData (
     454                 :            :     int nIndex,
     455                 :            :     MasterPageContainer::Token aToken) const
     456                 :            : {
     457         [ #  # ]:          0 :     return new UserData(nIndex,aToken);
     458                 :            : }
     459                 :            : 
     460                 :            : 
     461                 :            : 
     462                 :            : 
     463                 :          0 : MasterPagesSelector::UserData* MasterPagesSelector::GetUserData (int nIndex) const
     464                 :            : {
     465         [ #  # ]:          0 :     const ::osl::MutexGuard aGuard (maMutex);
     466                 :            : 
     467 [ #  # ][ #  # ]:          0 :     if (nIndex>0 && static_cast<unsigned int>(nIndex)<=mpPageSet->GetItemCount())
         [ #  # ][ #  # ]
     468         [ #  # ]:          0 :         return reinterpret_cast<UserData*>(mpPageSet->GetItemData((sal_uInt16)nIndex));
     469                 :            :     else
     470         [ #  # ]:          0 :         return NULL;
     471                 :            : }
     472                 :            : 
     473                 :            : 
     474                 :            : 
     475                 :            : 
     476                 :          0 : void MasterPagesSelector::SetUserData (int nIndex, UserData* pData)
     477                 :            : {
     478         [ #  # ]:          0 :     const ::osl::MutexGuard aGuard (maMutex);
     479                 :            : 
     480 [ #  # ][ #  # ]:          0 :     if (nIndex>0 && static_cast<unsigned int>(nIndex)<=mpPageSet->GetItemCount())
         [ #  # ][ #  # ]
     481                 :            :     {
     482         [ #  # ]:          0 :         UserData* pOldData = GetUserData(nIndex);
     483 [ #  # ][ #  # ]:          0 :         if (pOldData!=NULL && pOldData!=pData)
     484                 :          0 :             delete pOldData;
     485         [ #  # ]:          0 :         mpPageSet->SetItemData((sal_uInt16)nIndex, pData);
     486         [ #  # ]:          0 :     }
     487                 :          0 : }
     488                 :            : 
     489                 :            : 
     490                 :            : 
     491                 :            : 
     492                 :          0 : bool MasterPagesSelector::IsResizable (void)
     493                 :            : {
     494                 :          0 :     return false;
     495                 :            : }
     496                 :            : 
     497                 :            : 
     498                 :            : 
     499                 :            : 
     500                 :          0 : ::Window* MasterPagesSelector::GetWindow (void)
     501                 :            : {
     502                 :          0 :     return mpPageSet.get();
     503                 :            : }
     504                 :            : 
     505                 :            : 
     506                 :            : 
     507                 :            : 
     508                 :          0 : sal_Int32 MasterPagesSelector::GetMinimumWidth (void)
     509                 :            : {
     510                 :          0 :     return mpContainer->GetPreviewSizePixel().Width() + 2*3;
     511                 :            : }
     512                 :            : 
     513                 :            : 
     514                 :            : 
     515                 :            : 
     516                 :          0 : void MasterPagesSelector::UpdateSelection (void)
     517                 :            : {
     518                 :          0 : }
     519                 :            : 
     520                 :            : 
     521                 :            : 
     522                 :            : 
     523                 :          0 : void MasterPagesSelector::Execute (SfxRequest& rRequest)
     524                 :            : {
     525   [ #  #  #  #  :          0 :     switch (rRequest.GetSlot())
                #  #  # ]
     526                 :            :     {
     527                 :            :         case SID_TP_APPLY_TO_ALL_SLIDES:
     528                 :          0 :             mrBase.SetBusyState (true);
     529                 :          0 :             AssignMasterPageToAllSlides (GetSelectedMasterPage());
     530                 :          0 :             mrBase.SetBusyState (false);
     531                 :          0 :             break;
     532                 :            : 
     533                 :            :         case SID_TP_APPLY_TO_SELECTED_SLIDES:
     534                 :          0 :             mrBase.SetBusyState (true);
     535                 :          0 :             AssignMasterPageToSelectedSlides (GetSelectedMasterPage());
     536                 :          0 :             mrBase.SetBusyState (false);
     537                 :          0 :             break;
     538                 :            : 
     539                 :            :         case SID_TP_USE_FOR_NEW_PRESENTATIONS:
     540                 :            :             DBG_ASSERT (false,
     541                 :            :                 "Using slides as default for new presentations"
     542                 :            :                 " is not yet implemented");
     543                 :          0 :             break;
     544                 :            : 
     545                 :            :         case SID_TP_SHOW_SMALL_PREVIEW:
     546                 :            :         case SID_TP_SHOW_LARGE_PREVIEW:
     547                 :            :         {
     548                 :          0 :             mrBase.SetBusyState (true);
     549                 :            :             mpContainer->SetPreviewSize(
     550                 :          0 :                 rRequest.GetSlot()==SID_TP_SHOW_SMALL_PREVIEW
     551                 :            :                 ? MasterPageContainer::SMALL
     552                 :          0 :                 : MasterPageContainer::LARGE);
     553                 :          0 :             mrBase.SetBusyState (false);
     554                 :          0 :             break;
     555                 :            :         }
     556                 :            : 
     557                 :            :         case SID_TP_EDIT_MASTER:
     558                 :            :         {
     559                 :            :             using namespace ::com::sun::star;
     560                 :            :             uno::Reference<drawing::XDrawPage> xSelectedMaster (
     561 [ #  # ][ #  # ]:          0 :                 GetSelectedMasterPage()->getUnoPage(), uno::UNO_QUERY);
                 [ #  # ]
     562                 :          0 :             SfxViewFrame* pViewFrame = mrBase.GetViewFrame();
     563 [ #  # ][ #  # ]:          0 :             if (pViewFrame != NULL && xSelectedMaster.is())
                 [ #  # ]
     564                 :            :             {
     565                 :          0 :                 SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher();
     566         [ #  # ]:          0 :                 if (pDispatcher != NULL)
     567                 :            :                 {
     568                 :          0 :                     sal_uInt16 nIndex = mpPageSet->GetSelectItemId();
     569         [ #  # ]:          0 :                     pDispatcher->Execute(SID_MASTERPAGE, SFX_CALLMODE_SYNCHRON);
     570         [ #  # ]:          0 :                     mpPageSet->SelectItem (nIndex);
     571 [ #  # ][ #  # ]:          0 :                     mrBase.GetDrawController().setCurrentPage(xSelectedMaster);
     572                 :            :                 }
     573                 :            :             }
     574                 :          0 :             break;
     575                 :            :         }
     576                 :            : 
     577                 :            :         case SID_CUT:
     578                 :            :         case SID_COPY:
     579                 :            :         case SID_PASTE:
     580                 :            :             // Cut, copy, and paste are not supported and thus are ignored.
     581                 :          0 :             break;
     582                 :            :     }
     583                 :          0 : }
     584                 :            : 
     585                 :            : 
     586                 :            : 
     587                 :            : 
     588                 :          0 : void MasterPagesSelector::GetState (SfxItemSet& rItemSet)
     589                 :            : {
     590         [ #  # ]:          0 :     if (mpContainer->GetPreviewSize() == MasterPageContainer::SMALL)
     591                 :          0 :         rItemSet.DisableItem (SID_TP_SHOW_SMALL_PREVIEW);
     592                 :            :     else
     593                 :          0 :         rItemSet.DisableItem (SID_TP_SHOW_LARGE_PREVIEW);
     594                 :            : 
     595                 :            :     // Cut and paste is not supported so do not show the menu entries.
     596                 :          0 :     rItemSet.DisableItem (SID_CUT);
     597                 :          0 :     rItemSet.DisableItem (SID_COPY);
     598                 :          0 :     rItemSet.DisableItem (SID_PASTE);
     599                 :          0 : }
     600                 :            : 
     601                 :            : 
     602                 :            : 
     603                 :            : 
     604                 :          0 : void MasterPagesSelector::SetItem (
     605                 :            :     sal_uInt16 nIndex,
     606                 :            :     MasterPageContainer::Token aToken)
     607                 :            : {
     608         [ #  # ]:          0 :     const ::osl::MutexGuard aGuard (maMutex);
     609                 :            : 
     610         [ #  # ]:          0 :     RemoveTokenToIndexEntry(nIndex,aToken);
     611                 :            : 
     612         [ #  # ]:          0 :     if (nIndex > 0)
     613                 :            :     {
     614         [ #  # ]:          0 :         if (aToken != MasterPageContainer::NIL_TOKEN)
     615                 :            :         {
     616         [ #  # ]:          0 :             Image aPreview (mpContainer->GetPreviewForToken(aToken));
     617         [ #  # ]:          0 :             MasterPageContainer::PreviewState eState (mpContainer->GetPreviewState(aToken));
     618                 :            : 
     619 [ #  # ][ #  # ]:          0 :             if (aPreview.GetSizePixel().Width()>0)
     620                 :            :             {
     621 [ #  # ][ #  # ]:          0 :                 if (mpPageSet->GetItemPos(nIndex) != VALUESET_ITEM_NOTFOUND)
     622                 :            :                 {
     623         [ #  # ]:          0 :                     mpPageSet->SetItemImage(nIndex,aPreview);
     624 [ #  # ][ #  # ]:          0 :                     mpPageSet->SetItemText(nIndex, mpContainer->GetPageNameForToken(aToken));
                 [ #  # ]
     625                 :            :                 }
     626                 :            :                 else
     627                 :            :                 {
     628                 :          0 :                     mpPageSet->InsertItem (
     629                 :            :                         nIndex,
     630                 :            :                         aPreview,
     631                 :            :                         mpContainer->GetPageNameForToken(aToken),
     632   [ #  #  #  # ]:          0 :                         nIndex);
                 [ #  # ]
     633                 :            :                 }
     634 [ #  # ][ #  # ]:          0 :                 SetUserData(nIndex, CreateUserData(nIndex,aToken));
     635                 :            : 
     636         [ #  # ]:          0 :                 AddTokenToIndexEntry(nIndex,aToken);
     637                 :            :             }
     638                 :            : 
     639         [ #  # ]:          0 :             if (eState == MasterPageContainer::PS_CREATABLE)
     640 [ #  # ][ #  # ]:          0 :                 mpContainer->RequestPreview(aToken);
     641                 :            :         }
     642                 :            :         else
     643                 :            :         {
     644         [ #  # ]:          0 :             mpPageSet->RemoveItem(nIndex);
     645                 :            :         }
     646         [ #  # ]:          0 :     }
     647                 :            : 
     648                 :          0 : }
     649                 :            : 
     650                 :            : 
     651                 :            : 
     652                 :            : 
     653                 :          0 : void MasterPagesSelector::AddTokenToIndexEntry (
     654                 :            :     sal_uInt16 nIndex,
     655                 :            :     MasterPageContainer::Token aToken)
     656                 :            : {
     657         [ #  # ]:          0 :     const ::osl::MutexGuard aGuard (maMutex);
     658                 :            : 
     659 [ #  # ][ #  # ]:          0 :     maTokenToValueSetIndex[aToken] = nIndex;
     660                 :          0 : }
     661                 :            : 
     662                 :            : 
     663                 :            : 
     664                 :            : 
     665                 :          0 : void MasterPagesSelector::RemoveTokenToIndexEntry (
     666                 :            :     sal_uInt16 nIndex,
     667                 :            :     MasterPageContainer::Token aNewToken)
     668                 :            : {
     669         [ #  # ]:          0 :     const ::osl::MutexGuard aGuard (maMutex);
     670                 :            : 
     671         [ #  # ]:          0 :     UserData* pData = GetUserData(nIndex);
     672         [ #  # ]:          0 :     if (pData != NULL)
     673                 :            :     {
     674                 :            :         // Get the token that the index pointed to previously.
     675                 :          0 :         MasterPageContainer::Token aOldToken (pData->second);
     676                 :            : 
     677 [ #  # ][ #  # ]:          0 :         if (aNewToken != aOldToken
                 [ #  # ]
     678         [ #  # ]:          0 :             && nIndex == GetIndexForToken(aOldToken))
     679                 :            :         {
     680         [ #  # ]:          0 :             maTokenToValueSetIndex[aOldToken] = 0;
     681                 :            :         }
     682         [ #  # ]:          0 :     }
     683                 :          0 : }
     684                 :            : 
     685                 :            : 
     686                 :            : 
     687                 :            : 
     688                 :          0 : void MasterPagesSelector::InvalidatePreview (const SdPage* pPage)
     689                 :            : {
     690         [ #  # ]:          0 :     const ::osl::MutexGuard aGuard (maMutex);
     691                 :            : 
     692 [ #  # ][ #  # ]:          0 :     for (sal_uInt16 nIndex=1; nIndex<=mpPageSet->GetItemCount(); nIndex++)
     693                 :            :     {
     694         [ #  # ]:          0 :         UserData* pData = GetUserData(nIndex);
     695         [ #  # ]:          0 :         if (pData != NULL)
     696                 :            :         {
     697                 :          0 :             MasterPageContainer::Token aToken (pData->second);
     698 [ #  # ][ #  # ]:          0 :             if (pPage == mpContainer->GetPageObjectForToken(aToken,false))
     699                 :            :             {
     700         [ #  # ]:          0 :                 mpContainer->InvalidatePreview(aToken);
     701         [ #  # ]:          0 :                 mpContainer->RequestPreview(aToken);
     702                 :          0 :                 break;
     703                 :            :             }
     704                 :            :         }
     705         [ #  # ]:          0 :     }
     706                 :          0 : }
     707                 :            : 
     708                 :          0 : void MasterPagesSelector::UpdateAllPreviews (void)
     709                 :            : {
     710         [ #  # ]:          0 :     const ::osl::MutexGuard aGuard (maMutex);
     711                 :            : 
     712 [ #  # ][ #  # ]:          0 :     for (sal_uInt16 nIndex=1; nIndex<=mpPageSet->GetItemCount(); nIndex++)
     713                 :            :     {
     714         [ #  # ]:          0 :         UserData* pData = GetUserData(nIndex);
     715         [ #  # ]:          0 :         if (pData != NULL)
     716                 :            :         {
     717                 :          0 :             MasterPageContainer::Token aToken (pData->second);
     718                 :          0 :             mpPageSet->SetItemImage(
     719                 :            :                 nIndex,
     720   [ #  #  #  # ]:          0 :                 mpContainer->GetPreviewForToken(aToken));
                 [ #  # ]
     721 [ #  # ][ #  # ]:          0 :             if (mpContainer->GetPreviewState(aToken) == MasterPageContainer::PS_CREATABLE)
     722         [ #  # ]:          0 :                 mpContainer->RequestPreview(aToken);
     723                 :            :         }
     724                 :            :     }
     725 [ #  # ][ #  # ]:          0 :     mpPageSet->Rearrange(true);
     726                 :          0 : }
     727                 :            : 
     728                 :            : 
     729                 :            : 
     730                 :            : 
     731                 :          0 : void MasterPagesSelector::ClearPageSet (void)
     732                 :            : {
     733         [ #  # ]:          0 :     const ::osl::MutexGuard aGuard (maMutex);
     734                 :            : 
     735 [ #  # ][ #  # ]:          0 :     for (sal_uInt16 nIndex=1; nIndex<=mpPageSet->GetItemCount(); nIndex++)
     736                 :            :     {
     737         [ #  # ]:          0 :         UserData* pData = GetUserData(nIndex);
     738         [ #  # ]:          0 :         if (pData != NULL)
     739                 :          0 :             delete pData;
     740                 :            :     }
     741 [ #  # ][ #  # ]:          0 :     mpPageSet->Clear();
     742                 :          0 : }
     743                 :            : 
     744                 :            : 
     745                 :            : 
     746                 :            : 
     747                 :          0 : void MasterPagesSelector::SetHelpId( const rtl::OString& aId )
     748                 :            : {
     749         [ #  # ]:          0 :     const ::osl::MutexGuard aGuard (maMutex);
     750                 :            : 
     751 [ #  # ][ #  # ]:          0 :     mpPageSet->SetHelpId( aId );
     752                 :          0 : }
     753                 :            : 
     754                 :            : 
     755                 :            : 
     756                 :            : 
     757                 :          0 : sal_Int32 MasterPagesSelector::GetIndexForToken (MasterPageContainer::Token aToken) const
     758                 :            : {
     759         [ #  # ]:          0 :     const ::osl::MutexGuard aGuard (maMutex);
     760                 :            : 
     761         [ #  # ]:          0 :     TokenToValueSetIndex::const_iterator iIndex (maTokenToValueSetIndex.find(aToken));
     762 [ #  # ][ #  # ]:          0 :     if (iIndex != maTokenToValueSetIndex.end())
     763         [ #  # ]:          0 :         return iIndex->second;
     764                 :            :     else
     765         [ #  # ]:          0 :         return -1;
     766                 :            : }
     767                 :            : 
     768                 :            : 
     769                 :            : 
     770                 :            : 
     771                 :          0 : void MasterPagesSelector::Clear (void)
     772                 :            : {
     773         [ #  # ]:          0 :     const ::osl::MutexGuard aGuard (maMutex);
     774                 :            : 
     775 [ #  # ][ #  # ]:          0 :     ClearPageSet();
     776                 :          0 : }
     777                 :            : 
     778                 :            : 
     779                 :            : 
     780                 :            : 
     781                 :          0 : void MasterPagesSelector::InvalidateItem (MasterPageContainer::Token aToken)
     782                 :            : {
     783         [ #  # ]:          0 :     const ::osl::MutexGuard aGuard (maMutex);
     784                 :            : 
     785                 :          0 :     ItemList::iterator iItem;
     786 [ #  # ][ #  # ]:          0 :     for (iItem=maCurrentItemList.begin(); iItem!=maCurrentItemList.end(); ++iItem)
                 [ #  # ]
     787                 :            :     {
     788 [ #  # ][ #  # ]:          0 :         if (*iItem == aToken)
     789                 :            :         {
     790         [ #  # ]:          0 :             *iItem = MasterPageContainer::NIL_TOKEN;
     791                 :          0 :             break;
     792                 :            :         }
     793         [ #  # ]:          0 :     }
     794                 :          0 : }
     795                 :            : 
     796                 :            : 
     797                 :            : 
     798                 :            : SAL_WNODEPRECATED_DECLARATIONS_PUSH
     799                 :          0 : void MasterPagesSelector::UpdateItemList (::std::auto_ptr<ItemList> pNewItemList)
     800                 :            : {
     801         [ #  # ]:          0 :     const ::osl::MutexGuard aGuard (maMutex);
     802                 :            : 
     803         [ #  # ]:          0 :     ItemList::const_iterator iNewItem (pNewItemList->begin());
     804         [ #  # ]:          0 :     ItemList::const_iterator iCurrentItem (maCurrentItemList.begin());
     805         [ #  # ]:          0 :     ItemList::const_iterator iNewEnd (pNewItemList->end());
     806         [ #  # ]:          0 :     ItemList::const_iterator iCurrentEnd (maCurrentItemList.end());
     807                 :          0 :     sal_uInt16 nIndex (1);
     808                 :            : 
     809                 :            :     // Update existing items.
     810 [ #  # ][ #  # ]:          0 :     for ( ; iNewItem!=iNewEnd && iCurrentItem!=iCurrentEnd; ++iNewItem, ++iCurrentItem,++nIndex)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     811                 :            :     {
     812 [ #  # ][ #  # ]:          0 :         if (*iNewItem != *iCurrentItem)
                 [ #  # ]
     813                 :            :         {
     814 [ #  # ][ #  # ]:          0 :             SetItem(nIndex,*iNewItem);
     815                 :            :         }
     816                 :            :     }
     817                 :            : 
     818                 :            :     // Append new items.
     819 [ #  # ][ #  # ]:          0 :     for ( ; iNewItem!=iNewEnd; ++iNewItem,++nIndex)
                 [ #  # ]
     820                 :            :     {
     821 [ #  # ][ #  # ]:          0 :         SetItem(nIndex,*iNewItem);
     822                 :            :     }
     823                 :            : 
     824                 :            :     // Remove trailing items.
     825 [ #  # ][ #  # ]:          0 :     for ( ; iCurrentItem!=iCurrentEnd; ++iCurrentItem,++nIndex)
                 [ #  # ]
     826                 :            :     {
     827         [ #  # ]:          0 :         SetItem(nIndex,MasterPageContainer::NIL_TOKEN);
     828                 :            :     }
     829                 :            : 
     830                 :          0 :     maCurrentItemList.swap(*pNewItemList);
     831                 :            : 
     832         [ #  # ]:          0 :     mpPageSet->Rearrange();
     833 [ #  # ][ #  # ]:          0 :     if (GetParentNode() != NULL)
     834 [ #  # ][ #  # ]:          0 :         GetParentNode()->RequestResize();
                 [ #  # ]
     835                 :          0 : }
     836                 :            : SAL_WNODEPRECATED_DECLARATIONS_POP
     837                 :            : 
     838                 :            : 
     839                 :            : 
     840                 :            : 
     841                 :            : } } } // end of namespace ::sd::toolpanel::controls
     842                 :            : 
     843                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10