LCOV - code coverage report
Current view: top level - sd/source/ui/toolpanel - LayoutMenu.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 171 364 47.0 %
Date: 2012-08-25 Functions: 31 51 60.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 183 641 28.5 %

           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 "LayoutMenu.hxx"
      31                 :            : 
      32                 :            : #include "TaskPaneShellManager.hxx"
      33                 :            : #include "pres.hxx"
      34                 :            : #include "drawdoc.hxx"
      35                 :            : #include "DrawDocShell.hxx"
      36                 :            : #include "sdpage.hxx"
      37                 :            : #include "glob.hxx"
      38                 :            : #include "glob.hrc"
      39                 :            : #include "app.hrc"
      40                 :            : #include "helpids.h"
      41                 :            : #include "res_bmp.hrc"
      42                 :            : #include "strings.hrc"
      43                 :            : #include "ViewShellBase.hxx"
      44                 :            : #include "DrawViewShell.hxx"
      45                 :            : #include "SlideSorterViewShell.hxx"
      46                 :            : #include "controller/SlideSorterController.hxx"
      47                 :            : #include "controller/SlsPageSelector.hxx"
      48                 :            : #include "taskpane/TaskPaneControlFactory.hxx"
      49                 :            : #include "taskpane/ToolPanelViewShell.hxx"
      50                 :            : #include "taskpane/ScrollPanel.hxx"
      51                 :            : #include "tools/SlotStateListener.hxx"
      52                 :            : #include "EventMultiplexer.hxx"
      53                 :            : #include "DrawController.hxx"
      54                 :            : #include "framework/FrameworkHelper.hxx"
      55                 :            : 
      56                 :            : #include <vector>
      57                 :            : #include <memory>
      58                 :            : #include <sfx2/objface.hxx>
      59                 :            : #include "sdresid.hxx"
      60                 :            : #include <vcl/image.hxx>
      61                 :            : #include <svl/languageoptions.hxx>
      62                 :            : #include <sfx2/app.hxx>
      63                 :            : #include "taskpane/TitledControl.hxx"
      64                 :            : #include <sfx2/dispatch.hxx>
      65                 :            : #include <sfx2/request.hxx>
      66                 :            : #include <comphelper/processfactory.hxx>
      67                 :            : #include <sfx2/viewfrm.hxx>
      68                 :            : 
      69                 :            : #include <com/sun/star/frame/XController.hpp>
      70                 :            : #include <com/sun/star/drawing/framework/XControllerManager.hpp>
      71                 :            : #include <com/sun/star/drawing/framework/XView.hpp>
      72                 :            : #include <com/sun/star/drawing/framework/ResourceId.hpp>
      73                 :            : 
      74                 :            : using namespace ::sd::toolpanel;
      75                 :            : #define LayoutMenu
      76                 :            : #include "sdslots.hxx"
      77                 :            : 
      78                 :            : using namespace ::com::sun::star;
      79                 :            : using namespace ::com::sun::star::text;
      80                 :            : using namespace ::com::sun::star::uno;
      81                 :            : using namespace ::com::sun::star::drawing::framework;
      82                 :            : using namespace ::sd::slidesorter;
      83                 :            : using ::sd::framework::FrameworkHelper;
      84                 :            : 
      85                 :            : namespace sd { namespace toolpanel {
      86                 :            : 
      87         [ -  + ]:         30 : class LayoutMenuRootFactory
      88                 :            :     : public ControlFactory
      89                 :            : {
      90                 :            : public:
      91                 :         15 :     LayoutMenuRootFactory (ToolPanelViewShell& i_rPanelViewShell)
      92                 :         15 :         :mrPanelViewShell(i_rPanelViewShell)
      93                 :            :     {
      94                 :         15 :     }
      95                 :            : 
      96                 :            : protected:
      97                 :         15 :     virtual TreeNode* InternalCreateControl( ::Window& i_rParent )
      98                 :            :     {
      99 [ +  - ][ +  - ]:         15 :         ScrollPanel* pScrollPanel = new ScrollPanel (i_rParent);
     100                 :            :         ::std::auto_ptr<TreeNode> pMenu (
     101                 :            :             new LayoutMenu (
     102                 :            :                 pScrollPanel,
     103 [ +  - ][ +  - ]:         15 :                 mrPanelViewShell));
         [ +  - ][ +  - ]
     104 [ +  - ][ +  - ]:         15 :         pScrollPanel->AddControl(pMenu);
     105 [ +  - ][ +  - ]:         15 :         return pScrollPanel;
     106                 :            :     }
     107                 :            : 
     108                 :            : private:
     109                 :            :     ToolPanelViewShell& mrPanelViewShell;
     110                 :            : };
     111                 :            : 
     112                 :            : 
     113 [ +  + ][ +  - ]:        591 : SFX_IMPL_INTERFACE(LayoutMenu, SfxShell,
                 [ +  - ]
     114                 :            :     SdResId(STR_TASKPANELAYOUTMENU))
     115                 :            : {
     116 [ +  - ][ +  - ]:         25 :     SFX_POPUPMENU_REGISTRATION(SdResId(RID_TASKPANE_LAYOUTMENU_POPUP));
     117                 :         25 : }
     118                 :            : 
     119 [ -  + ][ -  + ]:        117 : TYPEINIT1(LayoutMenu, SfxShell);
     120                 :            : 
     121                 :            : struct snewfoil_value_info
     122                 :            : {
     123                 :            :     sal_uInt16 mnBmpResId;
     124                 :            :     sal_uInt16 mnStrResId;
     125                 :            :     WritingMode meWritingMode;
     126                 :            :     AutoLayout maAutoLayout;
     127                 :            : };
     128                 :            : 
     129                 :            : static snewfoil_value_info notes[] =
     130                 :            : {
     131                 :            :     {BMP_FOILN_01, STR_AUTOLAYOUT_NOTES, WritingMode_LR_TB,
     132                 :            :      AUTOLAYOUT_NOTES},
     133                 :            :     {0, 0, WritingMode_LR_TB, AUTOLAYOUT_NONE},
     134                 :            : };
     135                 :            : 
     136                 :            : static snewfoil_value_info handout[] =
     137                 :            : {
     138                 :            :     {BMP_FOILH_01, STR_AUTOLAYOUT_HANDOUT1, WritingMode_LR_TB,
     139                 :            :      AUTOLAYOUT_HANDOUT1},
     140                 :            :     {BMP_FOILH_02, STR_AUTOLAYOUT_HANDOUT2, WritingMode_LR_TB,
     141                 :            :      AUTOLAYOUT_HANDOUT2},
     142                 :            :     {BMP_FOILH_03, STR_AUTOLAYOUT_HANDOUT3, WritingMode_LR_TB,
     143                 :            :      AUTOLAYOUT_HANDOUT3},
     144                 :            :     {BMP_FOILH_04, STR_AUTOLAYOUT_HANDOUT4, WritingMode_LR_TB,
     145                 :            :      AUTOLAYOUT_HANDOUT4},
     146                 :            :     {BMP_FOILH_06, STR_AUTOLAYOUT_HANDOUT6, WritingMode_LR_TB,
     147                 :            :      AUTOLAYOUT_HANDOUT6},
     148                 :            :     {BMP_FOILH_09, STR_AUTOLAYOUT_HANDOUT9, WritingMode_LR_TB,
     149                 :            :      AUTOLAYOUT_HANDOUT9},
     150                 :            :     {0, 0, WritingMode_LR_TB, AUTOLAYOUT_NONE},
     151                 :            : };
     152                 :            : 
     153                 :            : static snewfoil_value_info standard[] =
     154                 :            : {
     155                 :            :     {BMP_LAYOUT_EMPTY, STR_AUTOLAYOUT_NONE, WritingMode_LR_TB,        AUTOLAYOUT_NONE},
     156                 :            :     {BMP_LAYOUT_HEAD03, STR_AUTOLAYOUT_TITLE, WritingMode_LR_TB,       AUTOLAYOUT_TITLE},
     157                 :            :     {BMP_LAYOUT_HEAD02, STR_AUTOLAYOUT_CONTENT, WritingMode_LR_TB,        AUTOLAYOUT_ENUM},
     158                 :            :     {BMP_LAYOUT_HEAD02A, STR_AUTOLAYOUT_2CONTENT, WritingMode_LR_TB,       AUTOLAYOUT_2TEXT},
     159                 :            :     {BMP_LAYOUT_HEAD01, STR_AUTOLAYOUT_ONLY_TITLE, WritingMode_LR_TB,  AUTOLAYOUT_ONLY_TITLE},
     160                 :            :     {BMP_LAYOUT_TEXTONLY, STR_AUTOLAYOUT_ONLY_TEXT, WritingMode_LR_TB,   AUTOLAYOUT_ONLY_TEXT},
     161                 :            :     {BMP_LAYOUT_HEAD03B, STR_AUTOLAYOUT_2CONTENT_CONTENT, WritingMode_LR_TB,    AUTOLAYOUT_2OBJTEXT},
     162                 :            :     {BMP_LAYOUT_HEAD03C, STR_AUTOLAYOUT_CONTENT_2CONTENT, WritingMode_LR_TB,    AUTOLAYOUT_TEXT2OBJ},
     163                 :            :     {BMP_LAYOUT_HEAD03A, STR_AUTOLAYOUT_2CONTENT_OVER_CONTENT,WritingMode_LR_TB, AUTOLAYOUT_2OBJOVERTEXT},
     164                 :            :     {BMP_LAYOUT_HEAD02B, STR_AUTOLAYOUT_CONTENT_OVER_CONTENT, WritingMode_LR_TB, AUTOLAYOUT_OBJOVERTEXT},
     165                 :            :     {BMP_LAYOUT_HEAD04, STR_AUTOLAYOUT_4CONTENT, WritingMode_LR_TB,        AUTOLAYOUT_4OBJ},
     166                 :            :     {BMP_LAYOUT_HEAD06, STR_AUTOLAYOUT_6CONTENT, WritingMode_LR_TB,    AUTOLAYOUT_6CLIPART},
     167                 :            : 
     168                 :            :     // vertical
     169                 :            :     {BMP_LAYOUT_VERTICAL02, STR_AL_VERT_TITLE_TEXT_CHART, WritingMode_TB_RL,AUTOLAYOUT_VERTICAL_TITLE_TEXT_CHART},
     170                 :            :     {BMP_LAYOUT_VERTICAL01, STR_AL_VERT_TITLE_VERT_OUTLINE, WritingMode_TB_RL, AUTOLAYOUT_VERTICAL_TITLE_VERTICAL_OUTLINE},
     171                 :            :     {BMP_LAYOUT_HEAD02, STR_AL_TITLE_VERT_OUTLINE, WritingMode_TB_RL, AUTOLAYOUT_TITLE_VERTICAL_OUTLINE},
     172                 :            :     {BMP_LAYOUT_HEAD02A, STR_AL_TITLE_VERT_OUTLINE_CLIPART,   WritingMode_TB_RL, AUTOLAYOUT_TITLE_VERTICAL_OUTLINE_CLIPART},
     173                 :            :     {0, 0, WritingMode_LR_TB, AUTOLAYOUT_NONE}
     174                 :            : };
     175                 :            : 
     176                 :         15 : LayoutMenu::LayoutMenu( TreeNode* pParent, ToolPanelViewShell& i_rPanelViewShell )
     177                 :         15 :     : ValueSet (pParent->GetWindow()),
     178                 :            :       TreeNode(pParent),
     179                 :            :       DragSourceHelper(this),
     180                 :            :       DropTargetHelper(this),
     181         [ +  - ]:         15 :       mrBase( i_rPanelViewShell.GetViewShellBase() ),
     182         [ +  - ]:         15 :       mpShellManager (&i_rPanelViewShell.GetSubShellManager()),
     183                 :            :       mbUseOwnScrollBar( false ),
     184                 :            :       mnPreferredColumnCount(3),
     185                 :            :       mxListener(NULL),
     186                 :            :       mbSelectionUpdatePending(true),
     187 [ +  - ][ +  - ]:         30 :       mbIsMainViewChangePending(false)
         [ +  - ][ +  - ]
                 [ +  - ]
     188                 :            : {
     189 [ +  - ][ +  - ]:         15 :     implConstruct( *mrBase.GetDocument()->GetDocSh() );
     190                 :         15 : }
     191                 :            : 
     192                 :            : 
     193                 :         15 : void LayoutMenu::implConstruct( DrawDocShell& rDocumentShell )
     194                 :            : {
     195                 :            :     OSL_ENSURE( mrBase.GetDocument()->GetDocSh() == &rDocumentShell,
     196                 :            :         "LayoutMenu::implConstruct: hmm?" );
     197                 :            :     // if this fires, then my assumption that the rDocumentShell parameter to our first ctor is superfluous ...
     198                 :            : 
     199                 :            :     SetStyle (
     200         [ +  - ]:         15 :         ( GetStyle()  & ~(WB_ITEMBORDER) )
     201                 :            :         | WB_TABSTOP
     202                 :            :         | WB_NO_DIRECTSELECT
     203         [ +  - ]:         15 :         );
     204         [ -  + ]:         15 :     if (mbUseOwnScrollBar)
     205 [ #  # ][ #  # ]:          0 :         SetStyle (GetStyle() | WB_VSCROLL);
     206         [ +  - ]:         15 :     SetExtraSpacing(2);
     207         [ +  - ]:         15 :     SetSelectHdl (LINK(this, LayoutMenu, ClickHandler));
     208         [ +  - ]:         15 :     SetPool (&rDocumentShell.GetDoc()->GetPool());
     209 [ +  - ][ +  - ]:         15 :     SetName(rtl::OUString("LayoutMenu"));
                 [ +  - ]
     210         [ +  - ]:         15 :     InvalidateContent();
     211                 :            : 
     212         [ +  - ]:         15 :     Link aEventListenerLink (LINK(this,LayoutMenu,EventMultiplexerListener));
     213                 :            :     mrBase.GetEventMultiplexer()->AddEventListener(aEventListenerLink,
     214                 :            :         ::sd::tools::EventMultiplexerEvent::EID_CURRENT_PAGE
     215                 :            :         | ::sd::tools::EventMultiplexerEvent::EID_SLIDE_SORTER_SELECTION
     216                 :            :         | ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED
     217                 :            :         | ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED
     218                 :            :         | ::sd::tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED
     219                 :            :         | ::sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_NORMAL
     220 [ +  - ][ +  - ]:         15 :         | ::sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_MASTER);
                 [ +  - ]
     221                 :            : 
     222         [ +  - ]:         15 :     Window::SetHelpId(HID_SD_TASK_PANE_PREVIEW_LAYOUTS);
     223 [ +  - ][ +  - ]:         15 :     SetAccessibleName(SdResId(STR_TASKPANEL_LAYOUT_MENU_TITLE));
         [ +  - ][ +  - ]
     224                 :            : 
     225         [ +  - ]:         15 :     Link aStateChangeLink (LINK(this,LayoutMenu,StateChangeHandler));
     226                 :            :     mxListener = new ::sd::tools::SlotStateListener(
     227                 :            :         aStateChangeLink,
     228 [ +  - ][ +  - ]:         30 :         Reference<frame::XDispatchProvider>(mrBase.GetController()->getFrame(), UNO_QUERY),
     229 [ +  - ][ +  - ]:         15 :         ".uno:VerticalTextState");
         [ +  - ][ +  - ]
                 [ +  - ]
     230                 :            : 
     231                 :            :     // Add this new object as shell to the shell factory.
     232 [ +  - ][ +  - ]:         15 :     GetShellManager()->AddSubShell(SHELLID_SD_TASK_PANE_PREVIEW_LAYOUTS,this,this);
     233                 :         15 : }
     234                 :            : 
     235                 :            : 
     236                 :            : 
     237 [ +  - ][ +  - ]:         15 : LayoutMenu::~LayoutMenu (void)
         [ +  - ][ +  - ]
     238                 :            : {
     239                 :            :     // Tell the shell factory that this object is no longer available.
     240 [ +  - ][ +  - ]:         15 :     if (GetShellManager() != NULL)
     241 [ +  - ][ +  - ]:         15 :         GetShellManager()->RemoveSubShell(this);
     242                 :            : 
     243         [ +  - ]:         15 :     Reference<lang::XComponent> xComponent (mxListener, UNO_QUERY);
     244         [ +  - ]:         15 :     if (xComponent.is())
     245 [ +  - ][ +  - ]:         15 :         xComponent->dispose();
     246                 :            : 
     247         [ +  - ]:         15 :     Clear();
     248         [ +  - ]:         15 :     Link aLink (LINK(this,LayoutMenu,EventMultiplexerListener));
     249 [ +  - ][ +  - ]:         15 :     mrBase.GetEventMultiplexer()->RemoveEventListener (aLink);
                 [ +  - ]
     250         [ -  + ]:         30 : }
     251                 :            : 
     252                 :            : 
     253                 :            : 
     254                 :            : 
     255                 :         15 : ::std::auto_ptr<ControlFactory> LayoutMenu::CreateControlFactory (
     256                 :            :     ToolPanelViewShell& i_rPanelViewShell )
     257                 :            : {
     258         [ +  - ]:         15 :     return ::std::auto_ptr<ControlFactory>(new LayoutMenuRootFactory(i_rPanelViewShell));
     259                 :            : }
     260                 :            : 
     261                 :            : 
     262                 :            : 
     263                 :            : 
     264                 :          0 : AutoLayout LayoutMenu::GetSelectedAutoLayout (void)
     265                 :            : {
     266                 :          0 :     AutoLayout aResult = AUTOLAYOUT_NONE;
     267                 :            : 
     268 [ #  # ][ #  # ]:          0 :     if ( ! IsNoSelection() && GetSelectItemId()!=0)
                 [ #  # ]
     269                 :            :     {
     270                 :          0 :         AutoLayout* pLayout = static_cast<AutoLayout*>(GetItemData(GetSelectItemId()));
     271         [ #  # ]:          0 :         if (pLayout != NULL)
     272                 :          0 :             aResult = *pLayout;
     273                 :            :     }
     274                 :            : 
     275                 :          0 :     return aResult;
     276                 :            : }
     277                 :            : 
     278                 :            : 
     279                 :            : 
     280                 :            : 
     281                 :            : /** The preferred size depends on the preferred number of columns, the
     282                 :            :     number of items, and the size of the items.
     283                 :            : */
     284                 :          0 : Size LayoutMenu::GetPreferredSize (void)
     285                 :            : {
     286         [ #  # ]:          0 :     Size aItemSize = CalcItemSizePixel (Size());
     287                 :            :     Size aPreferredWindowSize = CalcWindowSizePixel (
     288                 :            :         aItemSize,
     289                 :            :          (sal_uInt16)mnPreferredColumnCount,
     290 [ #  # ][ #  # ]:          0 :         (sal_uInt16)CalculateRowCount (aItemSize,mnPreferredColumnCount));
     291                 :          0 :     return aPreferredWindowSize;
     292                 :            : }
     293                 :            : 
     294                 :            : 
     295                 :            : 
     296                 :            : 
     297                 :          0 : sal_Int32 LayoutMenu::GetPreferredWidth (sal_Int32 nHeight)
     298                 :            : {
     299                 :          0 :     sal_Int32 nPreferredWidth = 100;
     300         [ #  # ]:          0 :     if (GetItemCount() > 0)
     301                 :            :     {
     302 [ #  # ][ #  # ]:          0 :         Image aImage = GetItemImage(GetItemId(0));
     303 [ #  # ][ #  # ]:          0 :         Size aItemSize = CalcItemSizePixel (aImage.GetSizePixel());
     304 [ #  # ][ #  # ]:          0 :         if (nHeight>0 && aItemSize.Height()>0)
                 [ #  # ]
     305                 :            :         {
     306                 :          0 :             int nRowCount = nHeight / aItemSize.Height();
     307         [ #  # ]:          0 :             if (nRowCount <= 0)
     308                 :          0 :                 nRowCount = 1;
     309         [ #  # ]:          0 :             int nColumnCount = (GetItemCount() + nRowCount-1) / nRowCount;
     310                 :          0 :             nPreferredWidth = nColumnCount * aItemSize.Width();
     311         [ #  # ]:          0 :         }
     312                 :            :     }
     313                 :            : 
     314                 :          0 :     return nPreferredWidth;
     315                 :            : }
     316                 :            : 
     317                 :            : 
     318                 :            : 
     319                 :            : 
     320                 :         46 : sal_Int32 LayoutMenu::GetPreferredHeight (sal_Int32 nWidth)
     321                 :            : {
     322                 :         46 :     sal_Int32 nPreferredHeight = 200;
     323 [ +  - ][ +  - ]:         46 :     if ( ! mbUseOwnScrollBar && GetItemCount()>0)
                 [ +  - ]
     324                 :            :     {
     325 [ +  - ][ +  - ]:         46 :         Image aImage = GetItemImage(GetItemId(0));
     326 [ +  - ][ +  - ]:         46 :         Size aItemSize = CalcItemSizePixel (aImage.GetSizePixel());
     327 [ +  - ][ +  - ]:         46 :         if (nWidth>0 && aItemSize.Width()>0)
                 [ +  - ]
     328                 :            :         {
     329                 :         46 :             aItemSize.Width() += 8;
     330                 :         46 :             aItemSize.Height() += 8;
     331                 :         46 :             int nColumnCount = nWidth / aItemSize.Width();
     332         [ -  + ]:         46 :             if (nColumnCount <= 0)
     333                 :          0 :                 nColumnCount = 1;
     334         [ -  + ]:         46 :             else if (nColumnCount > 4)
     335                 :          0 :                 nColumnCount = 4;
     336         [ +  - ]:         46 :             int nRowCount = (GetItemCount() + nColumnCount-1) / nColumnCount;
     337                 :         46 :             nPreferredHeight = nRowCount * aItemSize.Height();
     338         [ +  - ]:         46 :         }
     339                 :            :     }
     340                 :         46 :     return nPreferredHeight;
     341                 :            : }
     342                 :            : 
     343                 :            : 
     344                 :            : 
     345                 :            : 
     346                 :         44 : sal_Int32 LayoutMenu::GetMinimumWidth (void)
     347                 :            : {
     348                 :         44 :     sal_Int32 nMinimumWidth = 0;
     349         [ +  - ]:         44 :     if (GetItemCount()>0)
     350                 :            :     {
     351 [ +  - ][ +  - ]:         44 :         Image aImage = GetItemImage(GetItemId(0));
     352 [ +  - ][ +  - ]:         44 :         Size aItemSize = CalcItemSizePixel (aImage.GetSizePixel());
     353         [ +  - ]:         44 :         nMinimumWidth = aItemSize.Width();
     354                 :            :     }
     355                 :         44 :     return nMinimumWidth;
     356                 :            : }
     357                 :            : 
     358                 :            : 
     359                 :            : 
     360                 :            : 
     361                 :          0 : bool LayoutMenu::IsResizable (void)
     362                 :            : {
     363                 :          0 :     return true;
     364                 :            : }
     365                 :            : 
     366                 :            : 
     367                 :            : 
     368                 :            : 
     369                 :          0 : void LayoutMenu::UpdateEnabledState (const MasterMode eMode)
     370                 :            : {
     371                 :          0 :     bool bIsEnabled (false);
     372                 :            : 
     373         [ #  # ]:          0 :     ::boost::shared_ptr<ViewShell> pMainViewShell (mrBase.GetMainViewShell());
     374         [ #  # ]:          0 :     if (pMainViewShell)
     375                 :            :     {
     376         [ #  # ]:          0 :         switch (pMainViewShell->GetShellType())
              [ #  #  # ]
     377                 :            :         {
     378                 :            :             case ViewShell::ST_NONE:
     379                 :            :             case ViewShell::ST_OUTLINE:
     380                 :            :             case ViewShell::ST_PRESENTATION:
     381                 :            :             case ViewShell::ST_TASK_PANE:
     382                 :            :                 // The complete task pane is disabled for these values or
     383                 :            :                 // not even visible.  Disabling the LayoutMenu would be
     384                 :            :                 // logical but unnecessary.  The main disadvantage is that
     385                 :            :                 // after re-enabling it (typically) another panel is
     386                 :            :                 // expanded.
     387                 :          0 :                 bIsEnabled = true;
     388                 :          0 :                 break;
     389                 :            : 
     390                 :            :             case ViewShell::ST_DRAW:
     391                 :            :             case ViewShell::ST_IMPRESS:
     392                 :            :             {
     393   [ #  #  #  # ]:          0 :                 switch (eMode)
     394                 :            :                 {
     395                 :            :                     case MM_UNKNOWN:
     396                 :            :                     {
     397                 :            :                         ::boost::shared_ptr<DrawViewShell> pDrawViewShell (
     398         [ #  # ]:          0 :                             ::boost::dynamic_pointer_cast<DrawViewShell>(pMainViewShell));
     399         [ #  # ]:          0 :                         if (pDrawViewShell)
     400                 :          0 :                             bIsEnabled = pDrawViewShell->GetEditMode() != EM_MASTERPAGE;
     401         [ #  # ]:          0 :                         break;
     402                 :            :                     }
     403                 :            :                     case MM_NORMAL:
     404                 :          0 :                         bIsEnabled = true;
     405                 :          0 :                         break;
     406                 :            : 
     407                 :            :                     case MM_MASTER:
     408                 :          0 :                         bIsEnabled = false;
     409                 :          0 :                         break;
     410                 :            :                 }
     411                 :          0 :                 break;
     412                 :            :             }
     413                 :            : 
     414                 :            :             case ViewShell::ST_HANDOUT:
     415                 :            :             case ViewShell::ST_NOTES:
     416                 :            :             case ViewShell::ST_SLIDE_SORTER:
     417                 :            :             default:
     418                 :          0 :                 bIsEnabled = true;
     419                 :          0 :                 break;
     420                 :            :         }
     421                 :            : 
     422         [ #  # ]:          0 :         TreeNode* pParentNode = GetParentNode();
     423         [ #  # ]:          0 :         if (pParentNode != NULL)
     424                 :            :         {
     425                 :            :             TitledControl* pGrandParentNode
     426 [ #  # ][ #  # ]:          0 :                 = dynamic_cast<TitledControl*>(pParentNode->GetParentNode());
     427         [ #  # ]:          0 :             if (pGrandParentNode != NULL)
     428         [ #  # ]:          0 :                 pGrandParentNode->SetEnabledState(bIsEnabled);
     429                 :            :         }
     430                 :            : 
     431         [ #  # ]:          0 :     }
     432                 :          0 : }
     433                 :            : 
     434                 :            : 
     435                 :            : 
     436                 :            : 
     437                 :        173 : ::Window* LayoutMenu::GetWindow (void)
     438                 :            : {
     439                 :        173 :     return this;
     440                 :            : }
     441                 :            : 
     442                 :            : 
     443                 :            : 
     444                 :            : 
     445                 :         36 : void LayoutMenu::Paint (const Rectangle& rRect)
     446                 :            : {
     447         [ +  - ]:         36 :     SetBackground (GetSettings().GetStyleSettings().GetWindowColor());
     448                 :            : 
     449         [ +  + ]:         36 :     if (mbSelectionUpdatePending)
     450                 :            :     {
     451                 :         18 :         mbSelectionUpdatePending = false;
     452                 :         18 :         UpdateSelection();
     453                 :            :     }
     454                 :         36 :     ValueSet::Paint (rRect);
     455                 :            : 
     456         [ +  - ]:         36 :     SetBackground (Wallpaper());
     457                 :         36 : }
     458                 :            : 
     459                 :            : 
     460                 :            : 
     461                 :            : 
     462                 :         32 : void LayoutMenu::Resize (void)
     463                 :            : {
     464                 :         32 :     Size aWindowSize = GetOutputSizePixel();
     465 [ +  - ][ +  + ]:         32 :     if (IsVisible() && aWindowSize.Width() > 0)
         [ +  + ][ +  - ]
     466                 :            :     {
     467                 :            :         // Calculate the number of rows and columns.
     468 [ +  - ][ +  - ]:         17 :         if (GetItemCount() > 0)
     469                 :            :         {
     470 [ +  - ][ +  - ]:         17 :             Image aImage = GetItemImage(GetItemId(0));
     471                 :            :             Size aItemSize = CalcItemSizePixel (
     472 [ +  - ][ +  - ]:         17 :                 aImage.GetSizePixel());
     473                 :         17 :             aItemSize.Width() += 8;
     474                 :         17 :             aItemSize.Height() += 8;
     475                 :         17 :             int nColumnCount = aWindowSize.Width() / aItemSize.Width();
     476         [ -  + ]:         17 :             if (nColumnCount < 1)
     477                 :          0 :                 nColumnCount = 1;
     478         [ -  + ]:         17 :             else if (nColumnCount > 4)
     479                 :          0 :                 nColumnCount = 4;
     480                 :            : 
     481         [ +  - ]:         17 :             int nRowCount = CalculateRowCount (aItemSize, nColumnCount);
     482                 :            : 
     483         [ +  - ]:         17 :             SetColCount ((sal_uInt16)nColumnCount);
     484 [ +  - ][ +  - ]:         17 :             SetLineCount ((sal_uInt16)nRowCount);
     485                 :            :         }
     486                 :            :     }
     487                 :            : 
     488         [ +  - ]:         32 :     ValueSet::Resize ();
     489                 :         32 : }
     490                 :            : 
     491                 :            : 
     492                 :            : 
     493                 :            : 
     494                 :          0 : void LayoutMenu::MouseButtonDown (const MouseEvent& rEvent)
     495                 :            : {
     496                 :            :     // As a preparation for the context menu the item under the mouse is
     497                 :            :     // selected.
     498         [ #  # ]:          0 :     if (rEvent.IsRight())
     499                 :            :     {
     500                 :          0 :         ReleaseMouse();
     501                 :          0 :         sal_uInt16 nIndex = GetItemId (rEvent.GetPosPixel());
     502         [ #  # ]:          0 :         if (nIndex > 0)
     503                 :          0 :             SelectItem(nIndex);
     504                 :            :     }
     505                 :            : 
     506                 :          0 :     ValueSet::MouseButtonDown (rEvent);
     507                 :          0 : }
     508                 :            : 
     509                 :            : 
     510                 :            : 
     511                 :            : 
     512                 :          0 : void LayoutMenu::Execute (SfxRequest& rRequest)
     513                 :            : {
     514      [ #  #  # ]:          0 :     switch (rRequest.GetSlot())
     515                 :            :     {
     516                 :            :         case SID_TP_APPLY_TO_SELECTED_SLIDES:
     517                 :          0 :             AssignLayoutToSelectedSlides(GetSelectedAutoLayout());
     518                 :          0 :             rRequest.Done();
     519                 :          0 :             break;
     520                 :            : 
     521                 :            :         case SID_INSERTPAGE_LAYOUT_MENU:
     522                 :            :             // Add arguments to this slot and forward it to the main view
     523                 :            :             // shell.
     524                 :          0 :             InsertPageWithLayout(GetSelectedAutoLayout());
     525                 :          0 :             break;
     526                 :            :     }
     527                 :          0 : }
     528                 :            : 
     529                 :            : 
     530                 :            : 
     531                 :            : 
     532                 :          0 : void LayoutMenu::GetState (SfxItemSet& rItemSet)
     533                 :            : {
     534                 :            :     // Cut and paste is not supported.  The SID_(CUT,COPY,PASTE) entries
     535                 :            :     // therefore must not show up in the context menu.
     536         [ #  # ]:          0 :     rItemSet.DisableItem (SID_CUT);
     537         [ #  # ]:          0 :     rItemSet.DisableItem (SID_COPY);
     538         [ #  # ]:          0 :     rItemSet.DisableItem (SID_PASTE);
     539                 :            : 
     540                 :            :     // The SID_INSERTPAGE_LAYOUT_MENU slot depends on the SID_INSERTPAGE
     541                 :            :     // slot being supported elsewhere.
     542                 :          0 :     const SfxPoolItem* pItem = NULL;
     543                 :            :     const SfxItemState aState (
     544         [ #  # ]:          0 :         mrBase.GetViewFrame()->GetDispatcher()->QueryState(SID_INSERTPAGE, pItem));
     545         [ #  # ]:          0 :     if (aState == SFX_ITEM_DISABLED)
     546         [ #  # ]:          0 :         rItemSet.DisableItem(SID_INSERTPAGE_LAYOUT_MENU);
     547                 :          0 : }
     548                 :            : 
     549                 :            : 
     550                 :            : 
     551                 :            : 
     552                 :          0 : void LayoutMenu::InsertPageWithLayout (AutoLayout aLayout)
     553                 :            : {
     554 [ #  # ][ #  # ]:          0 :     ViewShell* pViewShell = mrBase.GetMainViewShell().get();
     555         [ #  # ]:          0 :     if (pViewShell == NULL)
     556                 :            :         return;
     557                 :            : 
     558                 :          0 :     SfxViewFrame* pViewFrame = mrBase.GetViewFrame();
     559         [ #  # ]:          0 :     if (pViewFrame == NULL)
     560                 :            :         return;
     561                 :            : 
     562                 :          0 :     SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher();
     563         [ #  # ]:          0 :     if (pDispatcher == NULL)
     564                 :            :         return;
     565                 :            : 
     566                 :            :     // Call SID_INSERTPAGE with the right arguments.  This is because
     567                 :            :     // the popup menu can not call this slot with arguments directly.
     568         [ #  # ]:          0 :     SfxRequest aRequest (CreateRequest(SID_INSERTPAGE, aLayout));
     569         [ #  # ]:          0 :     if (aRequest.GetArgs() != NULL)
     570                 :            :     {
     571                 :            :         pDispatcher->Execute(
     572                 :            :             SID_INSERTPAGE,
     573                 :            :             SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
     574         [ #  # ]:          0 :             *aRequest.GetArgs());
     575                 :            :     }
     576 [ #  # ][ #  # ]:          0 :     UpdateSelection();
     577                 :            : }
     578                 :            : 
     579                 :            : 
     580                 :            : 
     581                 :            : 
     582                 :         45 : TaskPaneShellManager* LayoutMenu::GetShellManager()
     583                 :            : {
     584         [ +  - ]:         45 :     if ( mpShellManager )
     585                 :         45 :         return mpShellManager;
     586                 :         45 :     return TreeNode::GetShellManager();
     587                 :            : }
     588                 :            : 
     589                 :         33 : void LayoutMenu::InvalidateContent (void)
     590                 :            : {
     591                 :            :     // The number of items may have changed.  Request a resize so that the
     592                 :            :     // vertical size of this control can be adapted.
     593                 :         33 :     RequestResize();
     594                 :            : 
     595                 :            :     // Throw away the current set and fill the menu anew according to the
     596                 :            :     // current settings (this includes the support for vertical writing.)
     597                 :         33 :     Fill();
     598                 :         33 : }
     599                 :            : 
     600                 :            : 
     601                 :            : 
     602                 :            : 
     603                 :         17 : int LayoutMenu::CalculateRowCount (const Size&, int nColumnCount)
     604                 :            : {
     605                 :         17 :     int nRowCount = 0;
     606                 :            : 
     607 [ +  - ][ +  - ]:         17 :     if (GetItemCount() > 0 && nColumnCount > 0)
                 [ +  - ]
     608                 :            :     {
     609                 :         17 :         nRowCount = (GetItemCount() + nColumnCount - 1) / nColumnCount;
     610                 :            :         //        nRowCount = GetOutputSizePixel().Height() / rItemSize.Height();
     611         [ -  + ]:         17 :         if (nRowCount < 1)
     612                 :          0 :             nRowCount = 1;
     613                 :            :     }
     614                 :            : 
     615                 :         17 :     return nRowCount;
     616                 :            : }
     617                 :            : 
     618                 :            : 
     619                 :            : 
     620                 :            : 
     621                 :          0 : IMPL_LINK_NOARG(LayoutMenu, ClickHandler)
     622                 :            : {
     623                 :          0 :     AssignLayoutToSelectedSlides (GetSelectedAutoLayout());
     624                 :          0 :     return 0;
     625                 :            : }
     626                 :            : 
     627                 :            : 
     628                 :            : 
     629                 :            : 
     630                 :            : /** The specified layout is assigned to the current page of the view shell
     631                 :            :     in the center pane.
     632                 :            : */
     633                 :          0 : void LayoutMenu::AssignLayoutToSelectedSlides (AutoLayout aLayout)
     634                 :            : {
     635                 :            :     using namespace ::sd::slidesorter;
     636                 :            :     using namespace ::sd::slidesorter::controller;
     637                 :            : 
     638                 :            :     do
     639                 :            :     {
     640                 :            :         // The view shell in the center pane has to be present.
     641 [ #  # ][ #  # ]:          0 :         ViewShell* pMainViewShell = mrBase.GetMainViewShell().get();
     642         [ #  # ]:          0 :         if (pMainViewShell == NULL)
     643                 :            :             break;
     644                 :            : 
     645                 :            :         // Determine if the current view is in an invalid master page mode.
     646                 :            :         // The handout view is always in master page mode and therefore not
     647                 :            :         // invalid.
     648                 :          0 :         bool bMasterPageMode (false);
     649 [ #  # ][ #  # ]:          0 :         switch (pMainViewShell->GetShellType())
     650                 :            :         {
     651                 :            :             case ViewShell::ST_NOTES:
     652                 :            :             case ViewShell::ST_IMPRESS:
     653                 :            :             {
     654                 :          0 :                 DrawViewShell* pDrawViewShell = static_cast<DrawViewShell*>(pMainViewShell);
     655         [ #  # ]:          0 :                 if (pDrawViewShell != NULL)
     656         [ #  # ]:          0 :                     if (pDrawViewShell->GetEditMode() == EM_MASTERPAGE)
     657                 :          0 :                         bMasterPageMode = true;
     658                 :            :             }
     659                 :            :             default:
     660                 :          0 :                 break;
     661                 :            :         }
     662         [ #  # ]:          0 :         if (bMasterPageMode)
     663                 :            :             break;
     664                 :            : 
     665                 :            :         // Get a list of all selected slides and call the SID_MODIFYPAGE
     666                 :            :         // slot for all of them.
     667         [ #  # ]:          0 :         ::sd::slidesorter::SharedPageSelection pPageSelection;
     668                 :            : 
     669                 :            :         // Get a list of selected pages.
     670                 :            :         // First we try to obtain this list from a slide sorter.  This is
     671                 :            :         // possible only some of the view shells in the center pane.  When
     672                 :            :         // no valid slide sorter is available then ask the main view shell
     673                 :            :         // for its current page.
     674                 :          0 :         SlideSorterViewShell* pSlideSorter = NULL;
     675 [ #  # ][ #  # ]:          0 :         switch (pMainViewShell->GetShellType())
     676                 :            :         {
     677                 :            :             case ViewShell::ST_IMPRESS:
     678                 :            :             case ViewShell::ST_NOTES:
     679                 :            :             case ViewShell::ST_SLIDE_SORTER:
     680         [ #  # ]:          0 :                 pSlideSorter = SlideSorterViewShell::GetSlideSorter(mrBase);
     681                 :          0 :                 break;
     682                 :            :             default:
     683                 :          0 :                 break;
     684                 :            :         }
     685         [ #  # ]:          0 :         if (pSlideSorter != NULL)
     686                 :            :         {
     687                 :            :             // There is a slide sorter visible so get the list of selected pages from it.
     688 [ #  # ][ #  # ]:          0 :             pPageSelection = pSlideSorter->GetPageSelection();
                 [ #  # ]
     689                 :            :         }
     690                 :            : 
     691 [ #  # ][ #  # ]:          0 :         if( (pSlideSorter == NULL) || (pPageSelection.get() == 0) || pPageSelection->empty() )
         [ #  # ][ #  # ]
     692                 :            :         {
     693                 :            :             // No valid slide sorter available.  Ask the main view shell for
     694                 :            :             // its current page.
     695 [ #  # ][ #  # ]:          0 :             pPageSelection.reset(new ::sd::slidesorter::SlideSorterViewShell::PageSelection());
                 [ #  # ]
     696 [ #  # ][ #  # ]:          0 :             pPageSelection->push_back(pMainViewShell->GetActualPage());
     697                 :            :         }
     698                 :            : 
     699                 :            : 
     700         [ #  # ]:          0 :         if (pPageSelection->empty())
     701                 :            :             break;
     702                 :            : 
     703                 :          0 :         ::std::vector<SdPage*>::iterator iPage;
     704 [ #  # ][ #  # ]:          0 :         for (iPage=pPageSelection->begin(); iPage!=pPageSelection->end(); ++iPage)
                 [ #  # ]
     705                 :            :             {
     706 [ #  # ][ #  # ]:          0 :                 if ((*iPage) == NULL)
     707                 :          0 :                     continue;
     708                 :            : 
     709                 :            :                 // Call the SID_ASSIGN_LAYOUT slot with all the necessary parameters.
     710         [ #  # ]:          0 :                 SfxRequest aRequest (mrBase.GetViewFrame(), SID_ASSIGN_LAYOUT);
     711 [ #  # ][ #  # ]:          0 :                 aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATPAGE, ((*iPage)->GetPageNum()-1)/2));
         [ #  # ][ #  # ]
                 [ #  # ]
     712 [ #  # ][ #  # ]:          0 :                 aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, aLayout));
                 [ #  # ]
     713         [ #  # ]:          0 :                 pMainViewShell->ExecuteSlot (aRequest, sal_Bool(sal_False));
     714 [ #  # ][ #  # ]:          0 :             }
                 [ #  # ]
     715                 :            :     }
     716                 :            :     while(false);
     717                 :          0 : }
     718                 :            : 
     719                 :            : 
     720                 :            : 
     721                 :            : 
     722                 :          0 : SfxRequest LayoutMenu::CreateRequest (
     723                 :            :     sal_uInt16 nSlotId,
     724                 :            :     AutoLayout aLayout)
     725                 :            : {
     726                 :          0 :     SfxRequest aRequest (mrBase.GetViewFrame(), nSlotId);
     727                 :            : 
     728                 :            :     do
     729                 :            :     {
     730         [ #  # ]:          0 :         SdrLayerAdmin& rLayerAdmin (mrBase.GetDocument()->GetLayerAdmin());
     731                 :            :         sal_uInt8 aBackground (rLayerAdmin.GetLayerID(
     732 [ #  # ][ #  # ]:          0 :             String(SdResId(STR_LAYER_BCKGRND)), sal_False));
         [ #  # ][ #  # ]
     733                 :            :         sal_uInt8 aBackgroundObject (rLayerAdmin.GetLayerID(
     734 [ #  # ][ #  # ]:          0 :             String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False));
         [ #  # ][ #  # ]
     735 [ #  # ][ #  # ]:          0 :         ViewShell* pViewShell = mrBase.GetMainViewShell().get();
     736         [ #  # ]:          0 :         if (pViewShell == NULL)
     737                 :            :             break;
     738         [ #  # ]:          0 :         SdPage* pPage = pViewShell->GetActualPage();
     739         [ #  # ]:          0 :         if (pPage == NULL)
     740                 :            :             break;
     741                 :            : 
     742         [ #  # ]:          0 :         SetOfByte aVisibleLayers (pPage->TRG_GetMasterPageVisibleLayers());
     743                 :            : 
     744                 :            :         aRequest.AppendItem(
     745 [ #  # ][ #  # ]:          0 :             SfxStringItem (ID_VAL_PAGENAME, String()));//pPage->GetName()));
         [ #  # ][ #  # ]
                 [ #  # ]
     746 [ #  # ][ #  # ]:          0 :         aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, aLayout));
                 [ #  # ]
     747                 :            :         aRequest.AppendItem(
     748 [ #  # ][ #  # ]:          0 :             SfxBoolItem(ID_VAL_ISPAGEBACK, aVisibleLayers.IsSet(aBackground)));
                 [ #  # ]
     749                 :            :         aRequest.AppendItem(
     750                 :            :             SfxBoolItem(
     751                 :            :                 ID_VAL_ISPAGEOBJ,
     752 [ #  # ][ #  # ]:          0 :                 aVisibleLayers.IsSet(aBackgroundObject)));
                 [ #  # ]
     753                 :            :     }
     754                 :            :     while (false);
     755                 :            : 
     756                 :          0 :     return aRequest;
     757                 :            : }
     758                 :            : 
     759                 :            : 
     760                 :            : 
     761                 :            : 
     762                 :         33 : void LayoutMenu::Fill (void)
     763                 :            : {
     764         [ +  - ]:         33 :     SvtLanguageOptions aLanguageOptions;
     765         [ +  - ]:         33 :     sal_Bool bVertical = aLanguageOptions.IsVerticalTextEnabled();
     766         [ +  - ]:         33 :     SdDrawDocument* pDocument = mrBase.GetDocument();
     767                 :            :     sal_Bool bRightToLeft = (pDocument!=NULL
     768 [ +  - ][ +  - ]:         33 :         && pDocument->GetDefaultWritingMode() == WritingMode_RL_TB);
                 [ -  + ]
     769                 :            : 
     770                 :            :     // Get URL of the view in the center pane.
     771                 :         33 :     ::rtl::OUString sCenterPaneViewName;
     772                 :            :     try
     773                 :            :     {
     774                 :            :         Reference<XControllerManager> xControllerManager (
     775 [ +  - ][ +  - ]:         33 :             Reference<XWeak>(&mrBase.GetDrawController()), UNO_QUERY_THROW);
                 [ +  - ]
     776                 :            :         Reference<XResourceId> xPaneId (ResourceId::create(
     777                 :            :             ::comphelper::getProcessComponentContext(),
     778 [ +  - ][ +  - ]:         33 :             FrameworkHelper::msCenterPaneURL));
     779 [ +  - ][ +  - ]:         33 :         Reference<XView> xView (FrameworkHelper::Instance(mrBase)->GetView(xPaneId));
                 [ +  - ]
     780         [ +  - ]:         33 :         if (xView.is())
     781 [ +  - ][ +  - ]:         33 :             sCenterPaneViewName = xView->getResourceId()->getResourceURL();
         [ +  - ][ +  - ]
                 [ #  # ]
     782                 :            :     }
     783         [ #  # ]:          0 :     catch (RuntimeException&)
     784                 :            :     {}
     785                 :            : 
     786                 :         33 :     snewfoil_value_info* pInfo = NULL;
     787         [ -  + ]:         33 :     if (sCenterPaneViewName.equals(framework::FrameworkHelper::msNotesViewURL))
     788                 :            :     {
     789                 :          0 :         pInfo = notes;
     790                 :            :     }
     791         [ -  + ]:         33 :     else if (sCenterPaneViewName.equals(framework::FrameworkHelper::msHandoutViewURL))
     792                 :            :     {
     793                 :          0 :         pInfo = handout;
     794                 :            :     }
     795   [ -  +  #  # ]:         33 :     else if (sCenterPaneViewName.equals(framework::FrameworkHelper::msImpressViewURL)
                 [ +  - ]
     796                 :          0 :         || sCenterPaneViewName.equals(framework::FrameworkHelper::msSlideSorterURL))
     797                 :            :     {
     798                 :         33 :         pInfo = standard;
     799                 :            :     }
     800                 :            :     else
     801                 :            :     {
     802                 :          0 :         pInfo = NULL;
     803                 :            :     }
     804                 :            : 
     805         [ +  - ]:         33 :     Clear();
     806                 :         33 :     int n = 0;
     807 [ +  - ][ +  + ]:        561 :     for (sal_uInt16 i=1; pInfo!=NULL&&pInfo->mnBmpResId!=0; i++,pInfo++)
                 [ +  + ]
     808                 :            :     {
     809 [ +  + ][ -  + ]:        528 :         if ((WritingMode_TB_RL != pInfo->meWritingMode) || bVertical)
     810                 :            :         {
     811 [ +  - ][ +  - ]:        396 :             BitmapEx aBmp(SdResId(pInfo->mnBmpResId));
     812                 :            : 
     813 [ -  + ][ #  # ]:        396 :             if (bRightToLeft && (WritingMode_TB_RL != pInfo->meWritingMode))
     814         [ #  # ]:          0 :                 aBmp.Mirror (BMP_MIRROR_HORZ);
     815                 :            : 
     816 [ +  - ][ +  - ]:        396 :             InsertItem (i, aBmp, String (SdResId (pInfo->mnStrResId)));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     817 [ +  - ][ +  - ]:        396 :             SetItemData (i, new AutoLayout(pInfo->maAutoLayout));
     818         [ +  - ]:        396 :             n++;
     819                 :            :         }
     820                 :            :     }
     821                 :            : 
     822         [ +  - ]:         33 :     mbSelectionUpdatePending = true;
     823                 :         33 : }
     824                 :            : 
     825                 :            : 
     826                 :            : 
     827                 :            : 
     828                 :         48 : void LayoutMenu::Clear (void)
     829                 :            : {
     830         [ +  + ]:        444 :     for (sal_uInt16 nId=1; nId<=GetItemCount(); nId++)
     831                 :        396 :         delete static_cast<AutoLayout*>(GetItemData(nId));
     832                 :         48 :     ValueSet::Clear();
     833                 :         48 : }
     834                 :            : 
     835                 :            : 
     836                 :            : 
     837                 :          0 : void LayoutMenu::StartDrag (sal_Int8 , const Point& )
     838                 :            : {
     839                 :          0 : }
     840                 :            : 
     841                 :            : 
     842                 :            : 
     843                 :            : 
     844                 :          0 : sal_Int8 LayoutMenu::AcceptDrop (const AcceptDropEvent& )
     845                 :            : {
     846                 :          0 :     return 0;
     847                 :            : }
     848                 :            : 
     849                 :            : 
     850                 :            : 
     851                 :            : 
     852                 :          0 : sal_Int8 LayoutMenu::ExecuteDrop (const ExecuteDropEvent& )
     853                 :            : {
     854                 :          0 :     return 0;
     855                 :            : }
     856                 :            : 
     857                 :            : 
     858                 :            : 
     859                 :            : 
     860                 :          0 : void LayoutMenu::Command (const CommandEvent& rEvent)
     861                 :            : {
     862         [ #  # ]:          0 :     switch (rEvent.GetCommand())
     863                 :            :     {
     864                 :            :         case COMMAND_CONTEXTMENU:
     865         [ #  # ]:          0 :             if ( ! SD_MOD()->GetWaterCan())
     866                 :            :             {
     867         [ #  # ]:          0 :                 if (GetShellManager() != NULL)
     868                 :          0 :                     GetShellManager()->MoveToTop(this);
     869         [ #  # ]:          0 :                 if (rEvent.IsMouseEvent())
     870                 :            :                 {
     871                 :            :                     // Do not show the context menu when the mouse was not
     872                 :            :                     // pressed over an item.
     873         [ #  # ]:          0 :                     if (GetItemId(rEvent.GetMousePosPixel()) > 0)
     874                 :            :                         mrBase.GetViewFrame()->GetDispatcher()->ExecutePopup(
     875         [ #  # ]:          0 :                             SdResId(RID_TASKPANE_LAYOUTMENU_POPUP));
     876                 :            :                 }
     877                 :            :                 else
     878                 :            :                 {
     879                 :            :                     // When the command event was not caused by a mouse
     880                 :            :                     // event (for example a key press instead) then show the
     881                 :            :                     // popup menu at the center of the current item.
     882         [ #  # ]:          0 :                     if (GetSelectItemId() != (sal_uInt16)-1)
     883                 :            :                     {
     884         [ #  # ]:          0 :                         Rectangle aBBox (GetItemRect(GetSelectItemId()));
     885         [ #  # ]:          0 :                         Point aPosition (aBBox.Center());
     886                 :            :                         mrBase.GetViewFrame()->GetDispatcher()->ExecutePopup(
     887                 :            :                             SdResId(RID_TASKPANE_LAYOUTMENU_POPUP),
     888                 :            :                             this,
     889 [ #  # ][ #  # ]:          0 :                             &aPosition);
     890                 :            :                     }
     891                 :            :                 }
     892                 :            :             }
     893                 :          0 :             break;
     894                 :            : 
     895                 :            :         default:
     896                 :          0 :             ValueSet::Command(rEvent);
     897                 :          0 :             break;
     898                 :            :     }
     899                 :          0 : }
     900                 :            : 
     901                 :            : 
     902                 :            : 
     903                 :            : 
     904                 :         18 : IMPL_LINK_NOARG(LayoutMenu, StateChangeHandler)
     905                 :            : {
     906                 :         18 :     InvalidateContent();
     907                 :         18 :     return 0;
     908                 :            : }
     909                 :            : 
     910                 :            : 
     911                 :            : 
     912                 :            : 
     913                 :         18 : void LayoutMenu::UpdateSelection (void)
     914                 :            : {
     915                 :         18 :     bool bItemSelected = false;
     916                 :            : 
     917                 :            :     do
     918                 :            :     {
     919                 :            :         // Get current page of main view.
     920                 :         18 :         ViewShell* pViewShell = mrBase.GetMainViewShell().get();
     921         [ -  + ]:         18 :         if (pViewShell == NULL)
     922                 :          0 :             break;
     923                 :            : 
     924                 :         18 :         SdPage* pCurrentPage = pViewShell->getCurrentPage();
     925         [ -  + ]:         18 :         if (pCurrentPage == NULL)
     926                 :          0 :             break;
     927                 :            : 
     928                 :            :         // Get layout of current page.
     929                 :         18 :         AutoLayout aLayout (pCurrentPage->GetAutoLayout());
     930 [ -  + ][ +  - ]:         18 :         if (aLayout<AUTOLAYOUT__START || aLayout>AUTOLAYOUT__END)
     931                 :          0 :             break;
     932                 :            : 
     933                 :            :         // Find the entry of the menu for to the layout.
     934                 :         18 :         sal_uInt16 nItemCount (GetItemCount());
     935         [ +  - ]:         36 :         for (sal_uInt16 nId=1; nId<=nItemCount; nId++)
     936                 :            :         {
     937         [ +  + ]:         36 :             if (*static_cast<AutoLayout*>(GetItemData(nId)) == aLayout)
     938                 :            :             {
     939                 :         18 :                 SelectItem(nId);
     940                 :         18 :                 bItemSelected = true;
     941                 :         18 :                 break;
     942                 :            :             }
     943                 :            :         }
     944                 :            :     }
     945                 :            :     while (false);
     946                 :            : 
     947         [ -  + ]:         18 :     if ( ! bItemSelected)
     948                 :          0 :         SetNoSelection();
     949                 :         18 : }
     950                 :            : 
     951                 :            : 
     952                 :            : 
     953                 :            : 
     954                 :        220 : IMPL_LINK(LayoutMenu, EventMultiplexerListener, ::sd::tools::EventMultiplexerEvent*, pEvent)
     955                 :            : {
     956   [ -  -  +  +  :        220 :     switch (pEvent->meEventId)
                -  -  + ]
     957                 :            :     {
     958                 :            :         case ::sd::tools::EventMultiplexerEvent::EID_CURRENT_PAGE:
     959                 :            :         case ::sd::tools::EventMultiplexerEvent::EID_SLIDE_SORTER_SELECTION:
     960         [ #  # ]:          0 :             if ( ! mbSelectionUpdatePending)
     961                 :          0 :                 UpdateSelection();
     962                 :          0 :             break;
     963                 :            : 
     964                 :            :         case ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED:
     965                 :          0 :             mbIsMainViewChangePending = true;
     966                 :          0 :             UpdateEnabledState(MM_UNKNOWN);
     967                 :          0 :             break;
     968                 :            : 
     969                 :            :         case ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED:
     970                 :         15 :             HideFocus();
     971                 :         15 :             break;
     972                 :            : 
     973                 :            :         case ::sd::tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED:
     974         [ -  + ]:         33 :             if (mbIsMainViewChangePending)
     975                 :            :             {
     976                 :          0 :                 mbIsMainViewChangePending = false;
     977                 :          0 :                 InvalidateContent();
     978                 :            :             }
     979                 :         33 :             break;
     980                 :            : 
     981                 :            :         case ::sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_NORMAL:
     982                 :          0 :             UpdateEnabledState(MM_NORMAL);
     983                 :          0 :             break;
     984                 :            : 
     985                 :            :         case ::sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_MASTER:
     986                 :          0 :             UpdateEnabledState(MM_MASTER);
     987                 :          0 :             break;
     988                 :            : 
     989                 :            :         default:
     990                 :            :             /* Ignored */
     991                 :        172 :             break;
     992                 :            :     }
     993                 :            : 
     994                 :        220 :     return 0;
     995                 :            : }
     996                 :            : 
     997                 :            : 
     998                 :            : 
     999                 :            : 
    1000                 :          0 : void LayoutMenu::DataChanged (const DataChangedEvent& rEvent)
    1001                 :            : {
    1002                 :          0 :     Fill();
    1003                 :          0 :     ValueSet::DataChanged(rEvent);
    1004                 :          0 : }
    1005                 :            : 
    1006                 :            : 
    1007                 :            : } } // end of namespace ::sd::toolpanel
    1008                 :            : 
    1009                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10