17a32b0c8SAndre Fischer /************************************************************** 27a32b0c8SAndre Fischer * 37a32b0c8SAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 47a32b0c8SAndre Fischer * or more contributor license agreements. See the NOTICE file 57a32b0c8SAndre Fischer * distributed with this work for additional information 67a32b0c8SAndre Fischer * regarding copyright ownership. The ASF licenses this file 77a32b0c8SAndre Fischer * to you under the Apache License, Version 2.0 (the 87a32b0c8SAndre Fischer * "License"); you may not use this file except in compliance 97a32b0c8SAndre Fischer * with the License. You may obtain a copy of the License at 107a32b0c8SAndre Fischer * 117a32b0c8SAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 127a32b0c8SAndre Fischer * 137a32b0c8SAndre Fischer * Unless required by applicable law or agreed to in writing, 147a32b0c8SAndre Fischer * software distributed under the License is distributed on an 157a32b0c8SAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 167a32b0c8SAndre Fischer * KIND, either express or implied. See the License for the 177a32b0c8SAndre Fischer * specific language governing permissions and limitations 187a32b0c8SAndre Fischer * under the License. 197a32b0c8SAndre Fischer * 207a32b0c8SAndre Fischer *************************************************************/ 217a32b0c8SAndre Fischer 227a32b0c8SAndre Fischer #include "precompiled_sd.hxx" 237a32b0c8SAndre Fischer 247a32b0c8SAndre Fischer #include "LayoutMenu.hxx" 257a32b0c8SAndre Fischer 265d65efa0SAndre Fischer #include "SidebarShellManager.hxx" 277a32b0c8SAndre Fischer #include "app.hrc" 287a32b0c8SAndre Fischer #include "drawdoc.hxx" 297a32b0c8SAndre Fischer #include "framework/FrameworkHelper.hxx" 307a32b0c8SAndre Fischer #include "glob.hrc" 317a32b0c8SAndre Fischer #include "glob.hxx" 327a32b0c8SAndre Fischer #include "helpids.h" 337a32b0c8SAndre Fischer #include "pres.hxx" 347a32b0c8SAndre Fischer #include "res_bmp.hrc" 357a32b0c8SAndre Fischer #include "sdpage.hxx" 367a32b0c8SAndre Fischer #include "sdresid.hxx" 377a32b0c8SAndre Fischer #include "strings.hrc" 387a32b0c8SAndre Fischer #include "tools/SlotStateListener.hxx" 397a32b0c8SAndre Fischer #include "DrawController.hxx" 407a32b0c8SAndre Fischer #include "DrawDocShell.hxx" 417a32b0c8SAndre Fischer #include "DrawViewShell.hxx" 427a32b0c8SAndre Fischer #include "EventMultiplexer.hxx" 437a32b0c8SAndre Fischer #include "SlideSorterViewShell.hxx" 447a32b0c8SAndre Fischer #include "ViewShellBase.hxx" 457a32b0c8SAndre Fischer 467a32b0c8SAndre Fischer #include <comphelper/processfactory.hxx> 477a32b0c8SAndre Fischer #include <sfx2/app.hxx> 487a32b0c8SAndre Fischer #include <sfx2/dispatch.hxx> 497a32b0c8SAndre Fischer #include <sfx2/objface.hxx> 507a32b0c8SAndre Fischer #include <sfx2/request.hxx> 517a32b0c8SAndre Fischer #include <sfx2/viewfrm.hxx> 527a32b0c8SAndre Fischer #include <svl/languageoptions.hxx> 537a32b0c8SAndre Fischer #include <vcl/image.hxx> 54*02c50d82SAndre Fischer #include <vcl/floatwin.hxx> 557a32b0c8SAndre Fischer 567a32b0c8SAndre Fischer #include <com/sun/star/frame/XController.hpp> 577a32b0c8SAndre Fischer #include <com/sun/star/drawing/framework/XControllerManager.hpp> 587a32b0c8SAndre Fischer #include <com/sun/star/drawing/framework/XView.hpp> 597a32b0c8SAndre Fischer #include <com/sun/star/drawing/framework/ResourceId.hpp> 607a32b0c8SAndre Fischer 617a32b0c8SAndre Fischer #include <vector> 627a32b0c8SAndre Fischer #include <memory> 637a32b0c8SAndre Fischer 647a32b0c8SAndre Fischer using namespace ::com::sun::star; 657a32b0c8SAndre Fischer using namespace ::com::sun::star::text; 667a32b0c8SAndre Fischer using namespace ::com::sun::star::uno; 677a32b0c8SAndre Fischer using namespace ::com::sun::star::drawing::framework; 687a32b0c8SAndre Fischer using namespace ::sd::slidesorter; 697a32b0c8SAndre Fischer using ::sd::framework::FrameworkHelper; 707a32b0c8SAndre Fischer 717a32b0c8SAndre Fischer namespace sd { namespace sidebar { 727a32b0c8SAndre Fischer 737a32b0c8SAndre Fischer 747a32b0c8SAndre Fischer 757a32b0c8SAndre Fischer struct snewfoil_value_info 767a32b0c8SAndre Fischer { 777a32b0c8SAndre Fischer sal_uInt16 mnBmpResId; 787a32b0c8SAndre Fischer sal_uInt16 mnHCBmpResId; 797a32b0c8SAndre Fischer sal_uInt16 mnStrResId; 807a32b0c8SAndre Fischer WritingMode meWritingMode; 817a32b0c8SAndre Fischer AutoLayout maAutoLayout; 827a32b0c8SAndre Fischer }; 837a32b0c8SAndre Fischer 847a32b0c8SAndre Fischer static snewfoil_value_info notes[] = 857a32b0c8SAndre Fischer { 867a32b0c8SAndre Fischer {BMP_FOILN_01, BMP_FOILN_01_H, STR_AUTOLAYOUT_NOTES, WritingMode_LR_TB, 877a32b0c8SAndre Fischer AUTOLAYOUT_NOTES}, 887a32b0c8SAndre Fischer {0, 0, 0, WritingMode_LR_TB, AUTOLAYOUT_NONE}, 897a32b0c8SAndre Fischer }; 907a32b0c8SAndre Fischer 917a32b0c8SAndre Fischer static snewfoil_value_info handout[] = 927a32b0c8SAndre Fischer { 937a32b0c8SAndre Fischer {BMP_FOILH_01, BMP_FOILH_01_H, STR_AUTOLAYOUT_HANDOUT1, WritingMode_LR_TB, 947a32b0c8SAndre Fischer AUTOLAYOUT_HANDOUT1}, 957a32b0c8SAndre Fischer {BMP_FOILH_02, BMP_FOILH_02_H, STR_AUTOLAYOUT_HANDOUT2, WritingMode_LR_TB, 967a32b0c8SAndre Fischer AUTOLAYOUT_HANDOUT2}, 977a32b0c8SAndre Fischer {BMP_FOILH_03, BMP_FOILH_03_H, STR_AUTOLAYOUT_HANDOUT3, WritingMode_LR_TB, 987a32b0c8SAndre Fischer AUTOLAYOUT_HANDOUT3}, 997a32b0c8SAndre Fischer {BMP_FOILH_04, BMP_FOILH_04_H, STR_AUTOLAYOUT_HANDOUT4, WritingMode_LR_TB, 1007a32b0c8SAndre Fischer AUTOLAYOUT_HANDOUT4}, 1017a32b0c8SAndre Fischer {BMP_FOILH_06, BMP_FOILH_06_H, STR_AUTOLAYOUT_HANDOUT6, WritingMode_LR_TB, 1027a32b0c8SAndre Fischer AUTOLAYOUT_HANDOUT6}, 1037a32b0c8SAndre Fischer {BMP_FOILH_09, BMP_FOILH_09_H, STR_AUTOLAYOUT_HANDOUT9, WritingMode_LR_TB, 1047a32b0c8SAndre Fischer AUTOLAYOUT_HANDOUT9}, 1057a32b0c8SAndre Fischer {0, 0, 0, WritingMode_LR_TB, AUTOLAYOUT_NONE}, 1067a32b0c8SAndre Fischer }; 1077a32b0c8SAndre Fischer 1087a32b0c8SAndre Fischer static snewfoil_value_info standard[] = 1097a32b0c8SAndre Fischer { 1107a32b0c8SAndre Fischer {BMP_LAYOUT_EMPTY, BMP_LAYOUT_EMPTY_H, STR_AUTOLAYOUT_NONE, WritingMode_LR_TB, AUTOLAYOUT_NONE}, 1117a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD03, BMP_LAYOUT_HEAD03_H, STR_AUTOLAYOUT_TITLE, WritingMode_LR_TB, AUTOLAYOUT_TITLE}, 1127a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD02, BMP_LAYOUT_HEAD02_H, STR_AUTOLAYOUT_CONTENT, WritingMode_LR_TB, AUTOLAYOUT_ENUM}, 1137a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD02A, BMP_LAYOUT_HEAD02A_H, STR_AUTOLAYOUT_2CONTENT, WritingMode_LR_TB, AUTOLAYOUT_2TEXT}, 1147a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD01, BMP_LAYOUT_HEAD01_H, STR_AUTOLAYOUT_ONLY_TITLE, WritingMode_LR_TB, AUTOLAYOUT_ONLY_TITLE}, 1157a32b0c8SAndre Fischer {BMP_LAYOUT_TEXTONLY, BMP_LAYOUT_TEXTONLY_H, STR_AUTOLAYOUT_ONLY_TEXT, WritingMode_LR_TB, AUTOLAYOUT_ONLY_TEXT}, 1167a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD03B, BMP_LAYOUT_HEAD03B_H, STR_AUTOLAYOUT_2CONTENT_CONTENT, WritingMode_LR_TB, AUTOLAYOUT_2OBJTEXT}, 1177a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD03C, BMP_LAYOUT_HEAD03C_H, STR_AUTOLAYOUT_CONTENT_2CONTENT, WritingMode_LR_TB, AUTOLAYOUT_TEXT2OBJ}, 1187a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD03A, BMP_LAYOUT_HEAD03A_H, STR_AUTOLAYOUT_2CONTENT_OVER_CONTENT,WritingMode_LR_TB, AUTOLAYOUT_2OBJOVERTEXT}, 1197a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD02B, BMP_LAYOUT_HEAD02B_H, STR_AUTOLAYOUT_CONTENT_OVER_CONTENT, WritingMode_LR_TB, AUTOLAYOUT_OBJOVERTEXT}, 1207a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD04, BMP_LAYOUT_HEAD04_H, STR_AUTOLAYOUT_4CONTENT, WritingMode_LR_TB, AUTOLAYOUT_4OBJ}, 1217a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD06, BMP_LAYOUT_HEAD06_H, STR_AUTOLAYOUT_6CONTENT, WritingMode_LR_TB, AUTOLAYOUT_6CLIPART}, 1227a32b0c8SAndre Fischer 1237a32b0c8SAndre Fischer // vertical 1247a32b0c8SAndre Fischer {BMP_LAYOUT_VERTICAL02, BMP_LAYOUT_VERTICAL02_H, STR_AL_VERT_TITLE_TEXT_CHART, WritingMode_TB_RL,AUTOLAYOUT_VERTICAL_TITLE_TEXT_CHART}, 1257a32b0c8SAndre Fischer {BMP_LAYOUT_VERTICAL01, BMP_LAYOUT_VERTICAL01_H, STR_AL_VERT_TITLE_VERT_OUTLINE, WritingMode_TB_RL, AUTOLAYOUT_VERTICAL_TITLE_VERTICAL_OUTLINE}, 1267a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD02, BMP_LAYOUT_HEAD02_H, STR_AL_TITLE_VERT_OUTLINE, WritingMode_TB_RL, AUTOLAYOUT_TITLE_VERTICAL_OUTLINE}, 1277a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD02A, BMP_LAYOUT_HEAD02A_H, STR_AL_TITLE_VERT_OUTLINE_CLIPART, WritingMode_TB_RL, AUTOLAYOUT_TITLE_VERTICAL_OUTLINE_CLIPART}, 1287a32b0c8SAndre Fischer {0, 0, 0, WritingMode_LR_TB, AUTOLAYOUT_NONE} 1297a32b0c8SAndre Fischer }; 1307a32b0c8SAndre Fischer 1317a32b0c8SAndre Fischer 1327a32b0c8SAndre Fischer 1337a32b0c8SAndre Fischer 1347a32b0c8SAndre Fischer LayoutMenu::LayoutMenu ( 1357a32b0c8SAndre Fischer ::Window* pParent, 1367a32b0c8SAndre Fischer ViewShellBase& rViewShellBase, 137*02c50d82SAndre Fischer const cssu::Reference<css::ui::XSidebar>& rxSidebar) 1387a32b0c8SAndre Fischer : ValueSet (pParent), 1397a32b0c8SAndre Fischer DragSourceHelper(this), 1407a32b0c8SAndre Fischer DropTargetHelper(this), 1417a32b0c8SAndre Fischer mrBase(rViewShellBase), 1427a32b0c8SAndre Fischer mbUseOwnScrollBar(false), 1437a32b0c8SAndre Fischer mnPreferredColumnCount(3), 1447a32b0c8SAndre Fischer mxListener(NULL), 1457a32b0c8SAndre Fischer mbSelectionUpdatePending(true), 1467a32b0c8SAndre Fischer mbIsMainViewChangePending(false), 147*02c50d82SAndre Fischer mxSidebar(rxSidebar), 1487a32b0c8SAndre Fischer mbIsDisposed(false) 1497a32b0c8SAndre Fischer { 1507a32b0c8SAndre Fischer implConstruct( *mrBase.GetDocument()->GetDocSh() ); 151*02c50d82SAndre Fischer OSL_TRACE("created LayoutMenu at %x", this); 152*02c50d82SAndre Fischer 1537a32b0c8SAndre Fischer #ifdef DEBUG 1547a32b0c8SAndre Fischer SetText(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sd:LayoutMenu"))); 1557a32b0c8SAndre Fischer #endif 1567a32b0c8SAndre Fischer } 1577a32b0c8SAndre Fischer 1587a32b0c8SAndre Fischer 1597a32b0c8SAndre Fischer 1607a32b0c8SAndre Fischer 1617a32b0c8SAndre Fischer void LayoutMenu::implConstruct( DrawDocShell& rDocumentShell ) 1627a32b0c8SAndre Fischer { 1637a32b0c8SAndre Fischer OSL_ENSURE( mrBase.GetDocument()->GetDocSh() == &rDocumentShell, 1647a32b0c8SAndre Fischer "LayoutMenu::implConstruct: hmm?" ); 1657a32b0c8SAndre Fischer // if this fires, then my assumption that the rDocumentShell parameter to our first ctor is superfluous ... 1667a32b0c8SAndre Fischer 1677a32b0c8SAndre Fischer SetStyle ( 1687a32b0c8SAndre Fischer ( GetStyle() & ~(WB_ITEMBORDER) ) 1697a32b0c8SAndre Fischer | WB_TABSTOP 1707a32b0c8SAndre Fischer | WB_NO_DIRECTSELECT 1717a32b0c8SAndre Fischer ); 1727a32b0c8SAndre Fischer if (mbUseOwnScrollBar) 1737a32b0c8SAndre Fischer SetStyle (GetStyle() | WB_VSCROLL); 1747a32b0c8SAndre Fischer SetExtraSpacing(2); 1757a32b0c8SAndre Fischer SetSelectHdl (LINK(this, LayoutMenu, ClickHandler)); 1767a32b0c8SAndre Fischer InvalidateContent(); 1777a32b0c8SAndre Fischer 1787a32b0c8SAndre Fischer Link aEventListenerLink (LINK(this,LayoutMenu,EventMultiplexerListener)); 1797a32b0c8SAndre Fischer mrBase.GetEventMultiplexer()->AddEventListener(aEventListenerLink, 1807a32b0c8SAndre Fischer ::sd::tools::EventMultiplexerEvent::EID_CURRENT_PAGE 1817a32b0c8SAndre Fischer | ::sd::tools::EventMultiplexerEvent::EID_SLIDE_SORTER_SELECTION 1827a32b0c8SAndre Fischer | ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED 1837a32b0c8SAndre Fischer | ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED 1847a32b0c8SAndre Fischer | ::sd::tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED 1857a32b0c8SAndre Fischer | ::sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_NORMAL 1867a32b0c8SAndre Fischer | ::sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_MASTER); 1877a32b0c8SAndre Fischer 1887a32b0c8SAndre Fischer Window::SetHelpId(HID_SD_TASK_PANE_PREVIEW_LAYOUTS); 1897a32b0c8SAndre Fischer SetAccessibleName(SdResId(STR_TASKPANEL_LAYOUT_MENU_TITLE)); 1907a32b0c8SAndre Fischer 1917a32b0c8SAndre Fischer Link aStateChangeLink (LINK(this,LayoutMenu,StateChangeHandler)); 1927a32b0c8SAndre Fischer mxListener = new ::sd::tools::SlotStateListener( 1937a32b0c8SAndre Fischer aStateChangeLink, 1947a32b0c8SAndre Fischer Reference<frame::XDispatchProvider>(mrBase.GetController()->getFrame(), UNO_QUERY), 1957a32b0c8SAndre Fischer ::rtl::OUString::createFromAscii(".uno:VerticalTextState")); 1967a32b0c8SAndre Fischer 1977a32b0c8SAndre Fischer SetSizePixel(GetParent()->GetSizePixel()); 1987a32b0c8SAndre Fischer Link aWindowEventHandlerLink (LINK(this,LayoutMenu,WindowEventHandler)); 1997a32b0c8SAndre Fischer GetParent()->AddEventListener(aWindowEventHandlerLink); 2007a32b0c8SAndre Fischer } 2017a32b0c8SAndre Fischer 2027a32b0c8SAndre Fischer 2037a32b0c8SAndre Fischer 2047a32b0c8SAndre Fischer 2057a32b0c8SAndre Fischer LayoutMenu::~LayoutMenu (void) 2067a32b0c8SAndre Fischer { 207*02c50d82SAndre Fischer OSL_TRACE("destroying LayoutMenu at %x", this); 2087a32b0c8SAndre Fischer Dispose(); 2097a32b0c8SAndre Fischer } 2107a32b0c8SAndre Fischer 2117a32b0c8SAndre Fischer 2127a32b0c8SAndre Fischer 2137a32b0c8SAndre Fischer 2147a32b0c8SAndre Fischer void LayoutMenu::Dispose (void) 2157a32b0c8SAndre Fischer { 2167a32b0c8SAndre Fischer if (mbIsDisposed) 2177a32b0c8SAndre Fischer return; 2187a32b0c8SAndre Fischer 219*02c50d82SAndre Fischer OSL_TRACE("disposing LayoutMenu at %x", this); 220*02c50d82SAndre Fischer 2217a32b0c8SAndre Fischer mbIsDisposed = true; 2227a32b0c8SAndre Fischer 2237a32b0c8SAndre Fischer Reference<lang::XComponent> xComponent (mxListener, UNO_QUERY); 2247a32b0c8SAndre Fischer if (xComponent.is()) 2257a32b0c8SAndre Fischer xComponent->dispose(); 2267a32b0c8SAndre Fischer 2277a32b0c8SAndre Fischer Clear(); 2287a32b0c8SAndre Fischer Link aLink (LINK(this,LayoutMenu,EventMultiplexerListener)); 2297a32b0c8SAndre Fischer mrBase.GetEventMultiplexer()->RemoveEventListener (aLink); 2307a32b0c8SAndre Fischer 2317a32b0c8SAndre Fischer Link aWindowEventHandlerLink (LINK(this,LayoutMenu,WindowEventHandler)); 2327a32b0c8SAndre Fischer GetParent()->RemoveEventListener(aWindowEventHandlerLink); 2337a32b0c8SAndre Fischer } 2347a32b0c8SAndre Fischer 2357a32b0c8SAndre Fischer 2367a32b0c8SAndre Fischer 2377a32b0c8SAndre Fischer 2387a32b0c8SAndre Fischer AutoLayout LayoutMenu::GetSelectedAutoLayout (void) 2397a32b0c8SAndre Fischer { 2407a32b0c8SAndre Fischer AutoLayout aResult = AUTOLAYOUT_NONE; 2417a32b0c8SAndre Fischer 2427a32b0c8SAndre Fischer if ( ! IsNoSelection() && GetSelectItemId()!=0) 2437a32b0c8SAndre Fischer { 2447a32b0c8SAndre Fischer AutoLayout* pLayout = static_cast<AutoLayout*>(GetItemData(GetSelectItemId())); 2457a32b0c8SAndre Fischer if (pLayout != NULL) 2467a32b0c8SAndre Fischer aResult = *pLayout; 2477a32b0c8SAndre Fischer } 2487a32b0c8SAndre Fischer 2497a32b0c8SAndre Fischer return aResult; 2507a32b0c8SAndre Fischer } 2517a32b0c8SAndre Fischer 2527a32b0c8SAndre Fischer 2537a32b0c8SAndre Fischer 2547a32b0c8SAndre Fischer 2557a32b0c8SAndre Fischer /** The preferred size depends on the preferred number of columns, the 2567a32b0c8SAndre Fischer number of items, and the size of the items. 2577a32b0c8SAndre Fischer */ 2587a32b0c8SAndre Fischer Size LayoutMenu::GetPreferredSize (void) 2597a32b0c8SAndre Fischer { 2607a32b0c8SAndre Fischer Size aItemSize = CalcItemSizePixel (Size()); 2617a32b0c8SAndre Fischer Size aPreferredWindowSize = CalcWindowSizePixel ( 2627a32b0c8SAndre Fischer aItemSize, 2637a32b0c8SAndre Fischer (sal_uInt16)mnPreferredColumnCount, 2647a32b0c8SAndre Fischer (sal_uInt16)CalculateRowCount (aItemSize,mnPreferredColumnCount)); 2657a32b0c8SAndre Fischer return aPreferredWindowSize; 2667a32b0c8SAndre Fischer } 2677a32b0c8SAndre Fischer 2687a32b0c8SAndre Fischer 2697a32b0c8SAndre Fischer 2707a32b0c8SAndre Fischer 2717a32b0c8SAndre Fischer sal_Int32 LayoutMenu::GetPreferredWidth (sal_Int32 nHeight) 2727a32b0c8SAndre Fischer { 2737a32b0c8SAndre Fischer sal_Int32 nPreferredWidth = 100; 2747a32b0c8SAndre Fischer if (GetItemCount() > 0) 2757a32b0c8SAndre Fischer { 2767a32b0c8SAndre Fischer Image aImage = GetItemImage(GetItemId(0)); 2777a32b0c8SAndre Fischer Size aItemSize = CalcItemSizePixel (aImage.GetSizePixel()); 2787a32b0c8SAndre Fischer if (nHeight>0 && aItemSize.Height()>0) 2797a32b0c8SAndre Fischer { 2807a32b0c8SAndre Fischer int nRowCount = nHeight / aItemSize.Height(); 2817a32b0c8SAndre Fischer if (nRowCount <= 0) 2827a32b0c8SAndre Fischer nRowCount = 1; 2837a32b0c8SAndre Fischer int nColumnCount = (GetItemCount() + nRowCount-1) / nRowCount; 2847a32b0c8SAndre Fischer nPreferredWidth = nColumnCount * aItemSize.Width(); 2857a32b0c8SAndre Fischer } 2867a32b0c8SAndre Fischer } 2877a32b0c8SAndre Fischer 2887a32b0c8SAndre Fischer return nPreferredWidth; 2897a32b0c8SAndre Fischer } 2907a32b0c8SAndre Fischer 2917a32b0c8SAndre Fischer 2927a32b0c8SAndre Fischer 2937a32b0c8SAndre Fischer 2947a32b0c8SAndre Fischer ui::LayoutSize LayoutMenu::GetHeightForWidth (const sal_Int32 nWidth) 2957a32b0c8SAndre Fischer { 2967a32b0c8SAndre Fischer sal_Int32 nPreferredHeight = 200; 2977a32b0c8SAndre Fischer if ( ! mbUseOwnScrollBar && GetItemCount()>0) 2987a32b0c8SAndre Fischer { 2997a32b0c8SAndre Fischer Image aImage = GetItemImage(GetItemId(0)); 3007a32b0c8SAndre Fischer Size aItemSize = CalcItemSizePixel (aImage.GetSizePixel()); 3017a32b0c8SAndre Fischer if (nWidth>0 && aItemSize.Width()>0) 3027a32b0c8SAndre Fischer { 3037a32b0c8SAndre Fischer aItemSize.Width() += 8; 3047a32b0c8SAndre Fischer aItemSize.Height() += 8; 3057a32b0c8SAndre Fischer int nColumnCount = nWidth / aItemSize.Width(); 3067a32b0c8SAndre Fischer if (nColumnCount <= 0) 3077a32b0c8SAndre Fischer nColumnCount = 1; 3087a32b0c8SAndre Fischer else if (nColumnCount > 4) 3097a32b0c8SAndre Fischer nColumnCount = 4; 3107a32b0c8SAndre Fischer int nRowCount = (GetItemCount() + nColumnCount-1) / nColumnCount; 3117a32b0c8SAndre Fischer nPreferredHeight = nRowCount * aItemSize.Height(); 3127a32b0c8SAndre Fischer } 3137a32b0c8SAndre Fischer } 3147a32b0c8SAndre Fischer return ui::LayoutSize(nPreferredHeight,nPreferredHeight,nPreferredHeight); 3157a32b0c8SAndre Fischer } 3167a32b0c8SAndre Fischer 3177a32b0c8SAndre Fischer 3187a32b0c8SAndre Fischer 3197a32b0c8SAndre Fischer 3207a32b0c8SAndre Fischer sal_Int32 LayoutMenu::GetMinimumWidth (void) 3217a32b0c8SAndre Fischer { 3227a32b0c8SAndre Fischer sal_Int32 nMinimumWidth = 0; 3237a32b0c8SAndre Fischer if (GetItemCount()>0) 3247a32b0c8SAndre Fischer { 3257a32b0c8SAndre Fischer Image aImage = GetItemImage(GetItemId(0)); 3267a32b0c8SAndre Fischer Size aItemSize = CalcItemSizePixel (aImage.GetSizePixel()); 3277a32b0c8SAndre Fischer nMinimumWidth = aItemSize.Width(); 3287a32b0c8SAndre Fischer } 3297a32b0c8SAndre Fischer return nMinimumWidth; 3307a32b0c8SAndre Fischer } 3317a32b0c8SAndre Fischer 3327a32b0c8SAndre Fischer 3337a32b0c8SAndre Fischer 3347a32b0c8SAndre Fischer 3357a32b0c8SAndre Fischer void LayoutMenu::UpdateEnabledState (const MasterMode eMode) 3367a32b0c8SAndre Fischer { 3377a32b0c8SAndre Fischer bool bIsEnabled (false); 3387a32b0c8SAndre Fischer 3397a32b0c8SAndre Fischer ::boost::shared_ptr<ViewShell> pMainViewShell (mrBase.GetMainViewShell()); 3407a32b0c8SAndre Fischer if (pMainViewShell) 3417a32b0c8SAndre Fischer { 3427a32b0c8SAndre Fischer switch (pMainViewShell->GetShellType()) 3437a32b0c8SAndre Fischer { 3447a32b0c8SAndre Fischer case ViewShell::ST_NONE: 3457a32b0c8SAndre Fischer case ViewShell::ST_OUTLINE: 3467a32b0c8SAndre Fischer case ViewShell::ST_PRESENTATION: 3477a32b0c8SAndre Fischer case ViewShell::ST_SIDEBAR: 3487a32b0c8SAndre Fischer // The complete task pane is disabled for these values or 3497a32b0c8SAndre Fischer // not even visible. Disabling the LayoutMenu would be 3507a32b0c8SAndre Fischer // logical but unnecessary. The main disadvantage is that 3517a32b0c8SAndre Fischer // after re-enabling it (typically) another panel is 3527a32b0c8SAndre Fischer // expanded. 3537a32b0c8SAndre Fischer bIsEnabled = true; 3547a32b0c8SAndre Fischer break; 3557a32b0c8SAndre Fischer 3567a32b0c8SAndre Fischer case ViewShell::ST_DRAW: 3577a32b0c8SAndre Fischer case ViewShell::ST_IMPRESS: 3587a32b0c8SAndre Fischer { 3597a32b0c8SAndre Fischer switch (eMode) 3607a32b0c8SAndre Fischer { 3617a32b0c8SAndre Fischer case MM_UNKNOWN: 3627a32b0c8SAndre Fischer { 3637a32b0c8SAndre Fischer ::boost::shared_ptr<DrawViewShell> pDrawViewShell ( 3647a32b0c8SAndre Fischer ::boost::dynamic_pointer_cast<DrawViewShell>(pMainViewShell)); 3657a32b0c8SAndre Fischer if (pDrawViewShell) 3667a32b0c8SAndre Fischer bIsEnabled = pDrawViewShell->GetEditMode() != EM_MASTERPAGE; 3677a32b0c8SAndre Fischer break; 3687a32b0c8SAndre Fischer } 3697a32b0c8SAndre Fischer case MM_NORMAL: 3707a32b0c8SAndre Fischer bIsEnabled = true; 3717a32b0c8SAndre Fischer break; 3727a32b0c8SAndre Fischer 3737a32b0c8SAndre Fischer case MM_MASTER: 3747a32b0c8SAndre Fischer bIsEnabled = false; 3757a32b0c8SAndre Fischer break; 3767a32b0c8SAndre Fischer } 3777a32b0c8SAndre Fischer break; 3787a32b0c8SAndre Fischer } 3797a32b0c8SAndre Fischer 3807a32b0c8SAndre Fischer case ViewShell::ST_HANDOUT: 3817a32b0c8SAndre Fischer case ViewShell::ST_NOTES: 3827a32b0c8SAndre Fischer case ViewShell::ST_SLIDE_SORTER: 3837a32b0c8SAndre Fischer default: 3847a32b0c8SAndre Fischer bIsEnabled = true; 3857a32b0c8SAndre Fischer break; 3867a32b0c8SAndre Fischer } 3877a32b0c8SAndre Fischer } 3887a32b0c8SAndre Fischer } 3897a32b0c8SAndre Fischer 3907a32b0c8SAndre Fischer 3917a32b0c8SAndre Fischer 3927a32b0c8SAndre Fischer 3937a32b0c8SAndre Fischer void LayoutMenu::Paint (const Rectangle& rRect) 3947a32b0c8SAndre Fischer { 3957a32b0c8SAndre Fischer SetBackground (GetSettings().GetStyleSettings().GetWindowColor()); 3967a32b0c8SAndre Fischer 3977a32b0c8SAndre Fischer if (mbSelectionUpdatePending) 3987a32b0c8SAndre Fischer { 3997a32b0c8SAndre Fischer mbSelectionUpdatePending = false; 4007a32b0c8SAndre Fischer UpdateSelection(); 4017a32b0c8SAndre Fischer } 4027a32b0c8SAndre Fischer ValueSet::Paint (rRect); 4037a32b0c8SAndre Fischer 4047a32b0c8SAndre Fischer SetBackground (Wallpaper()); 4057a32b0c8SAndre Fischer } 4067a32b0c8SAndre Fischer 4077a32b0c8SAndre Fischer 4087a32b0c8SAndre Fischer 4097a32b0c8SAndre Fischer 4107a32b0c8SAndre Fischer void LayoutMenu::Resize (void) 4117a32b0c8SAndre Fischer { 4127a32b0c8SAndre Fischer Size aWindowSize = GetOutputSizePixel(); 4137a32b0c8SAndre Fischer if (IsVisible() && aWindowSize.Width() > 0) 4147a32b0c8SAndre Fischer { 4157a32b0c8SAndre Fischer // Calculate the number of rows and columns. 4167a32b0c8SAndre Fischer if (GetItemCount() > 0) 4177a32b0c8SAndre Fischer { 4187a32b0c8SAndre Fischer Image aImage = GetItemImage(GetItemId(0)); 4197a32b0c8SAndre Fischer Size aItemSize = CalcItemSizePixel ( 4207a32b0c8SAndre Fischer aImage.GetSizePixel()); 4217a32b0c8SAndre Fischer aItemSize.Width() += 8; 4227a32b0c8SAndre Fischer aItemSize.Height() += 8; 4237a32b0c8SAndre Fischer int nColumnCount = aWindowSize.Width() / aItemSize.Width(); 4247a32b0c8SAndre Fischer if (nColumnCount < 1) 4257a32b0c8SAndre Fischer nColumnCount = 1; 4267a32b0c8SAndre Fischer else if (nColumnCount > 4) 4277a32b0c8SAndre Fischer nColumnCount = 4; 4287a32b0c8SAndre Fischer 4297a32b0c8SAndre Fischer int nRowCount = CalculateRowCount (aItemSize, nColumnCount); 4307a32b0c8SAndre Fischer 4317a32b0c8SAndre Fischer SetColCount ((sal_uInt16)nColumnCount); 4327a32b0c8SAndre Fischer SetLineCount ((sal_uInt16)nRowCount); 4337a32b0c8SAndre Fischer } 4347a32b0c8SAndre Fischer } 4357a32b0c8SAndre Fischer 4367a32b0c8SAndre Fischer ValueSet::Resize (); 4377a32b0c8SAndre Fischer } 4387a32b0c8SAndre Fischer 4397a32b0c8SAndre Fischer 4407a32b0c8SAndre Fischer 4417a32b0c8SAndre Fischer 4427a32b0c8SAndre Fischer void LayoutMenu::MouseButtonDown (const MouseEvent& rEvent) 4437a32b0c8SAndre Fischer { 4447a32b0c8SAndre Fischer // As a preparation for the context menu the item under the mouse is 4457a32b0c8SAndre Fischer // selected. 4467a32b0c8SAndre Fischer if (rEvent.IsRight()) 4477a32b0c8SAndre Fischer { 4487a32b0c8SAndre Fischer ReleaseMouse(); 4497a32b0c8SAndre Fischer sal_uInt16 nIndex = GetItemId (rEvent.GetPosPixel()); 4507a32b0c8SAndre Fischer if (nIndex > 0) 4517a32b0c8SAndre Fischer SelectItem(nIndex); 4527a32b0c8SAndre Fischer } 4537a32b0c8SAndre Fischer 4547a32b0c8SAndre Fischer ValueSet::MouseButtonDown (rEvent); 4557a32b0c8SAndre Fischer } 4567a32b0c8SAndre Fischer 4577a32b0c8SAndre Fischer 4587a32b0c8SAndre Fischer 459*02c50d82SAndre Fischer /* 4607a32b0c8SAndre Fischer void LayoutMenu::GetState (SfxItemSet& rItemSet) 4617a32b0c8SAndre Fischer { 4627a32b0c8SAndre Fischer // Cut and paste is not supported. The SID_(CUT,COPY,PASTE) entries 4637a32b0c8SAndre Fischer // therefore must not show up in the context menu. 4647a32b0c8SAndre Fischer rItemSet.DisableItem (SID_CUT); 4657a32b0c8SAndre Fischer rItemSet.DisableItem (SID_COPY); 4667a32b0c8SAndre Fischer rItemSet.DisableItem (SID_PASTE); 4677a32b0c8SAndre Fischer 4687a32b0c8SAndre Fischer // The SID_INSERTPAGE_LAYOUT_MENU slot depends on the SID_INSERTPAGE 4697a32b0c8SAndre Fischer // slot being supported elsewhere. 4707a32b0c8SAndre Fischer const SfxPoolItem* pItem = NULL; 4717a32b0c8SAndre Fischer const SfxItemState aState ( 4727a32b0c8SAndre Fischer mrBase.GetViewFrame()->GetDispatcher()->QueryState(SID_INSERTPAGE, pItem)); 4737a32b0c8SAndre Fischer if (aState == SFX_ITEM_DISABLED) 4747a32b0c8SAndre Fischer rItemSet.DisableItem(SID_INSERTPAGE_LAYOUT_MENU); 4757a32b0c8SAndre Fischer } 476*02c50d82SAndre Fischer */ 4777a32b0c8SAndre Fischer 4787a32b0c8SAndre Fischer 4797a32b0c8SAndre Fischer 4807a32b0c8SAndre Fischer void LayoutMenu::InsertPageWithLayout (AutoLayout aLayout) 4817a32b0c8SAndre Fischer { 4827a32b0c8SAndre Fischer ViewShell* pViewShell = mrBase.GetMainViewShell().get(); 4837a32b0c8SAndre Fischer if (pViewShell == NULL) 4847a32b0c8SAndre Fischer return; 4857a32b0c8SAndre Fischer 4867a32b0c8SAndre Fischer SfxViewFrame* pViewFrame = mrBase.GetViewFrame(); 4877a32b0c8SAndre Fischer if (pViewFrame == NULL) 4887a32b0c8SAndre Fischer return; 4897a32b0c8SAndre Fischer 4907a32b0c8SAndre Fischer SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher(); 4917a32b0c8SAndre Fischer if (pDispatcher == NULL) 4927a32b0c8SAndre Fischer return; 4937a32b0c8SAndre Fischer 4947a32b0c8SAndre Fischer // Call SID_INSERTPAGE with the right arguments. This is because 4957a32b0c8SAndre Fischer // the popup menu can not call this slot with arguments directly. 4967a32b0c8SAndre Fischer SfxRequest aRequest (CreateRequest(SID_INSERTPAGE, aLayout)); 4977a32b0c8SAndre Fischer if (aRequest.GetArgs() != NULL) 4987a32b0c8SAndre Fischer { 4997a32b0c8SAndre Fischer pDispatcher->Execute( 5007a32b0c8SAndre Fischer SID_INSERTPAGE, 5017a32b0c8SAndre Fischer SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, 5027a32b0c8SAndre Fischer *aRequest.GetArgs()); 5037a32b0c8SAndre Fischer } 5047a32b0c8SAndre Fischer UpdateSelection(); 5057a32b0c8SAndre Fischer } 5067a32b0c8SAndre Fischer 5077a32b0c8SAndre Fischer 5087a32b0c8SAndre Fischer 5097a32b0c8SAndre Fischer 5107a32b0c8SAndre Fischer void LayoutMenu::InvalidateContent (void) 5117a32b0c8SAndre Fischer { 5127a32b0c8SAndre Fischer // The number of items may have changed. Request a resize so that the 5137a32b0c8SAndre Fischer // vertical size of this control can be adapted. 5147a32b0c8SAndre Fischer // RequestResize(); 5157a32b0c8SAndre Fischer 5167a32b0c8SAndre Fischer // Throw away the current set and fill the menu anew according to the 5177a32b0c8SAndre Fischer // current settings (this includes the support for vertical writing.) 5187a32b0c8SAndre Fischer Fill(); 519*02c50d82SAndre Fischer 520*02c50d82SAndre Fischer if (mxSidebar.is()) 521*02c50d82SAndre Fischer mxSidebar->requestLayout(); 5227a32b0c8SAndre Fischer } 5237a32b0c8SAndre Fischer 5247a32b0c8SAndre Fischer 5257a32b0c8SAndre Fischer 5267a32b0c8SAndre Fischer 5277a32b0c8SAndre Fischer int LayoutMenu::CalculateRowCount (const Size&, int nColumnCount) 5287a32b0c8SAndre Fischer { 5297a32b0c8SAndre Fischer int nRowCount = 0; 5307a32b0c8SAndre Fischer 5317a32b0c8SAndre Fischer if (GetItemCount() > 0 && nColumnCount > 0) 5327a32b0c8SAndre Fischer { 5337a32b0c8SAndre Fischer nRowCount = (GetItemCount() + nColumnCount - 1) / nColumnCount; 5347a32b0c8SAndre Fischer // nRowCount = GetOutputSizePixel().Height() / rItemSize.Height(); 5357a32b0c8SAndre Fischer if (nRowCount < 1) 5367a32b0c8SAndre Fischer nRowCount = 1; 5377a32b0c8SAndre Fischer } 5387a32b0c8SAndre Fischer 5397a32b0c8SAndre Fischer return nRowCount; 5407a32b0c8SAndre Fischer } 5417a32b0c8SAndre Fischer 5427a32b0c8SAndre Fischer 5437a32b0c8SAndre Fischer 5447a32b0c8SAndre Fischer 5457a32b0c8SAndre Fischer IMPL_LINK(LayoutMenu, ClickHandler, ValueSet*, EMPTYARG) 5467a32b0c8SAndre Fischer { 5477a32b0c8SAndre Fischer AssignLayoutToSelectedSlides (GetSelectedAutoLayout()); 5487a32b0c8SAndre Fischer return 0; 5497a32b0c8SAndre Fischer } 5507a32b0c8SAndre Fischer 5517a32b0c8SAndre Fischer 5527a32b0c8SAndre Fischer 5537a32b0c8SAndre Fischer 5547a32b0c8SAndre Fischer /** The specified layout is assigned to the current page of the view shell 5557a32b0c8SAndre Fischer in the center pane. 5567a32b0c8SAndre Fischer */ 5577a32b0c8SAndre Fischer void LayoutMenu::AssignLayoutToSelectedSlides (AutoLayout aLayout) 5587a32b0c8SAndre Fischer { 5597a32b0c8SAndre Fischer using namespace ::sd::slidesorter; 5607a32b0c8SAndre Fischer using namespace ::sd::slidesorter::controller; 5617a32b0c8SAndre Fischer 5627a32b0c8SAndre Fischer do 5637a32b0c8SAndre Fischer { 5647a32b0c8SAndre Fischer // The view shell in the center pane has to be present. 5657a32b0c8SAndre Fischer ViewShell* pMainViewShell = mrBase.GetMainViewShell().get(); 5667a32b0c8SAndre Fischer if (pMainViewShell == NULL) 5677a32b0c8SAndre Fischer break; 5687a32b0c8SAndre Fischer 5697a32b0c8SAndre Fischer // Determine if the current view is in an invalid master page mode. 5707a32b0c8SAndre Fischer // The handout view is always in master page mode and therefore not 5717a32b0c8SAndre Fischer // invalid. 5727a32b0c8SAndre Fischer bool bMasterPageMode (false); 5737a32b0c8SAndre Fischer switch (pMainViewShell->GetShellType()) 5747a32b0c8SAndre Fischer { 5757a32b0c8SAndre Fischer case ViewShell::ST_NOTES: 5767a32b0c8SAndre Fischer case ViewShell::ST_IMPRESS: 5777a32b0c8SAndre Fischer { 5787a32b0c8SAndre Fischer DrawViewShell* pDrawViewShell = static_cast<DrawViewShell*>(pMainViewShell); 5797a32b0c8SAndre Fischer if (pDrawViewShell != NULL) 5807a32b0c8SAndre Fischer if (pDrawViewShell->GetEditMode() == EM_MASTERPAGE) 5817a32b0c8SAndre Fischer bMasterPageMode = true; 5827a32b0c8SAndre Fischer } 5837a32b0c8SAndre Fischer default: 5847a32b0c8SAndre Fischer break; 5857a32b0c8SAndre Fischer } 5867a32b0c8SAndre Fischer if (bMasterPageMode) 5877a32b0c8SAndre Fischer break; 5887a32b0c8SAndre Fischer 5897a32b0c8SAndre Fischer // Get a list of all selected slides and call the SID_MODIFYPAGE 5907a32b0c8SAndre Fischer // slot for all of them. 5917a32b0c8SAndre Fischer ::sd::slidesorter::SharedPageSelection pPageSelection; 5927a32b0c8SAndre Fischer 5937a32b0c8SAndre Fischer // Get a list of selected pages. 5947a32b0c8SAndre Fischer // First we try to obtain this list from a slide sorter. This is 5957a32b0c8SAndre Fischer // possible only some of the view shells in the center pane. When 5967a32b0c8SAndre Fischer // no valid slide sorter is available then ask the main view shell 5977a32b0c8SAndre Fischer // for its current page. 5987a32b0c8SAndre Fischer SlideSorterViewShell* pSlideSorter = NULL; 5997a32b0c8SAndre Fischer switch (pMainViewShell->GetShellType()) 6007a32b0c8SAndre Fischer { 6017a32b0c8SAndre Fischer case ViewShell::ST_IMPRESS: 6027a32b0c8SAndre Fischer case ViewShell::ST_NOTES: 6037a32b0c8SAndre Fischer case ViewShell::ST_SLIDE_SORTER: 6047a32b0c8SAndre Fischer pSlideSorter = SlideSorterViewShell::GetSlideSorter(mrBase); 6057a32b0c8SAndre Fischer break; 6067a32b0c8SAndre Fischer default: 6077a32b0c8SAndre Fischer break; 6087a32b0c8SAndre Fischer } 6097a32b0c8SAndre Fischer if (pSlideSorter != NULL) 6107a32b0c8SAndre Fischer { 6117a32b0c8SAndre Fischer // There is a slide sorter visible so get the list of selected pages from it. 6127a32b0c8SAndre Fischer pPageSelection = pSlideSorter->GetPageSelection(); 6137a32b0c8SAndre Fischer } 6147a32b0c8SAndre Fischer 6157a32b0c8SAndre Fischer if( (pSlideSorter == NULL) || (pPageSelection.get() == 0) || pPageSelection->empty() ) 6167a32b0c8SAndre Fischer { 6177a32b0c8SAndre Fischer // No valid slide sorter available. Ask the main view shell for 6187a32b0c8SAndre Fischer // its current page. 6197a32b0c8SAndre Fischer pPageSelection.reset(new ::sd::slidesorter::SlideSorterViewShell::PageSelection()); 6207a32b0c8SAndre Fischer pPageSelection->push_back(pMainViewShell->GetActualPage()); 6217a32b0c8SAndre Fischer } 6227a32b0c8SAndre Fischer 6237a32b0c8SAndre Fischer 6247a32b0c8SAndre Fischer if (pPageSelection->empty()) 6257a32b0c8SAndre Fischer break; 6267a32b0c8SAndre Fischer 6277a32b0c8SAndre Fischer ::std::vector<SdPage*>::iterator iPage; 6287a32b0c8SAndre Fischer for (iPage=pPageSelection->begin(); iPage!=pPageSelection->end(); ++iPage) 6297a32b0c8SAndre Fischer { 6307a32b0c8SAndre Fischer if ((*iPage) == NULL) 6317a32b0c8SAndre Fischer continue; 6327a32b0c8SAndre Fischer 6337a32b0c8SAndre Fischer // Call the SID_ASSIGN_LAYOUT slot with all the necessary parameters. 6347a32b0c8SAndre Fischer SfxRequest aRequest (mrBase.GetViewFrame(), SID_ASSIGN_LAYOUT); 6357a32b0c8SAndre Fischer aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATPAGE, ((*iPage)->GetPageNum()-1)/2)); 6367a32b0c8SAndre Fischer aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, aLayout)); 6377a32b0c8SAndre Fischer pMainViewShell->ExecuteSlot (aRequest, sal_Bool(sal_False)); 6387a32b0c8SAndre Fischer } 6397a32b0c8SAndre Fischer } 6407a32b0c8SAndre Fischer while(false); 6417a32b0c8SAndre Fischer } 6427a32b0c8SAndre Fischer 6437a32b0c8SAndre Fischer 6447a32b0c8SAndre Fischer 6457a32b0c8SAndre Fischer 6467a32b0c8SAndre Fischer SfxRequest LayoutMenu::CreateRequest ( 6477a32b0c8SAndre Fischer sal_uInt16 nSlotId, 6487a32b0c8SAndre Fischer AutoLayout aLayout) 6497a32b0c8SAndre Fischer { 6507a32b0c8SAndre Fischer SfxRequest aRequest (mrBase.GetViewFrame(), nSlotId); 6517a32b0c8SAndre Fischer 6527a32b0c8SAndre Fischer do 6537a32b0c8SAndre Fischer { 6547a32b0c8SAndre Fischer SdrLayerAdmin& rLayerAdmin (mrBase.GetDocument()->GetLayerAdmin()); 6557a32b0c8SAndre Fischer sal_uInt8 aBackground (rLayerAdmin.GetLayerID( 6567a32b0c8SAndre Fischer String(SdResId(STR_LAYER_BCKGRND)), sal_False)); 6577a32b0c8SAndre Fischer sal_uInt8 aBackgroundObject (rLayerAdmin.GetLayerID( 6587a32b0c8SAndre Fischer String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False)); 6597a32b0c8SAndre Fischer ViewShell* pViewShell = mrBase.GetMainViewShell().get(); 6607a32b0c8SAndre Fischer if (pViewShell == NULL) 6617a32b0c8SAndre Fischer break; 6627a32b0c8SAndre Fischer SdPage* pPage = pViewShell->GetActualPage(); 6637a32b0c8SAndre Fischer if (pPage == NULL) 6647a32b0c8SAndre Fischer break; 6657a32b0c8SAndre Fischer 6667a32b0c8SAndre Fischer SetOfByte aVisibleLayers (pPage->TRG_GetMasterPageVisibleLayers()); 6677a32b0c8SAndre Fischer 6687a32b0c8SAndre Fischer aRequest.AppendItem( 6697a32b0c8SAndre Fischer SfxStringItem (ID_VAL_PAGENAME, String()));//pPage->GetName())); 6707a32b0c8SAndre Fischer aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, aLayout)); 6717a32b0c8SAndre Fischer aRequest.AppendItem( 6727a32b0c8SAndre Fischer SfxBoolItem(ID_VAL_ISPAGEBACK, aVisibleLayers.IsSet(aBackground))); 6737a32b0c8SAndre Fischer aRequest.AppendItem( 6747a32b0c8SAndre Fischer SfxBoolItem( 6757a32b0c8SAndre Fischer ID_VAL_ISPAGEOBJ, 6767a32b0c8SAndre Fischer aVisibleLayers.IsSet(aBackgroundObject))); 6777a32b0c8SAndre Fischer } 6787a32b0c8SAndre Fischer while (false); 6797a32b0c8SAndre Fischer 6807a32b0c8SAndre Fischer return aRequest; 6817a32b0c8SAndre Fischer } 6827a32b0c8SAndre Fischer 6837a32b0c8SAndre Fischer 6847a32b0c8SAndre Fischer 6857a32b0c8SAndre Fischer 6867a32b0c8SAndre Fischer void LayoutMenu::Fill (void) 6877a32b0c8SAndre Fischer { 6887a32b0c8SAndre Fischer const bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode(); 6897a32b0c8SAndre Fischer SvtLanguageOptions aLanguageOptions; 6907a32b0c8SAndre Fischer sal_Bool bVertical = aLanguageOptions.IsVerticalTextEnabled(); 6917a32b0c8SAndre Fischer SdDrawDocument* pDocument = mrBase.GetDocument(); 6927a32b0c8SAndre Fischer sal_Bool bRightToLeft = (pDocument!=NULL 6937a32b0c8SAndre Fischer && pDocument->GetDefaultWritingMode() == WritingMode_RL_TB); 6947a32b0c8SAndre Fischer 6957a32b0c8SAndre Fischer // Get URL of the view in the center pane. 6967a32b0c8SAndre Fischer ::rtl::OUString sCenterPaneViewName; 6977a32b0c8SAndre Fischer try 6987a32b0c8SAndre Fischer { 6997a32b0c8SAndre Fischer Reference<XControllerManager> xControllerManager ( 7007a32b0c8SAndre Fischer Reference<XWeak>(&mrBase.GetDrawController()), UNO_QUERY_THROW); 7017a32b0c8SAndre Fischer Reference<XResourceId> xPaneId (ResourceId::create( 7027a32b0c8SAndre Fischer ::comphelper::getProcessComponentContext(), 7037a32b0c8SAndre Fischer FrameworkHelper::msCenterPaneURL)); 7047a32b0c8SAndre Fischer Reference<XView> xView (FrameworkHelper::Instance(mrBase)->GetView(xPaneId)); 7057a32b0c8SAndre Fischer if (xView.is()) 7067a32b0c8SAndre Fischer sCenterPaneViewName = xView->getResourceId()->getResourceURL(); 7077a32b0c8SAndre Fischer } 7087a32b0c8SAndre Fischer catch (RuntimeException&) 7097a32b0c8SAndre Fischer {} 7107a32b0c8SAndre Fischer 7117a32b0c8SAndre Fischer snewfoil_value_info* pInfo = NULL; 7127a32b0c8SAndre Fischer if (sCenterPaneViewName.equals(framework::FrameworkHelper::msNotesViewURL)) 7137a32b0c8SAndre Fischer { 7147a32b0c8SAndre Fischer pInfo = notes; 7157a32b0c8SAndre Fischer } 7167a32b0c8SAndre Fischer else if (sCenterPaneViewName.equals(framework::FrameworkHelper::msHandoutViewURL)) 7177a32b0c8SAndre Fischer { 7187a32b0c8SAndre Fischer pInfo = handout; 7197a32b0c8SAndre Fischer } 7207a32b0c8SAndre Fischer else if (sCenterPaneViewName.equals(framework::FrameworkHelper::msImpressViewURL) 7217a32b0c8SAndre Fischer || sCenterPaneViewName.equals(framework::FrameworkHelper::msSlideSorterURL)) 7227a32b0c8SAndre Fischer { 7237a32b0c8SAndre Fischer pInfo = standard; 7247a32b0c8SAndre Fischer } 7257a32b0c8SAndre Fischer else 7267a32b0c8SAndre Fischer { 7277a32b0c8SAndre Fischer pInfo = NULL; 7287a32b0c8SAndre Fischer } 7297a32b0c8SAndre Fischer 7307a32b0c8SAndre Fischer Clear(); 7317a32b0c8SAndre Fischer int n = 0; 7327a32b0c8SAndre Fischer for (sal_uInt16 i=1; pInfo!=NULL&&pInfo->mnBmpResId!=0; i++,pInfo++) 7337a32b0c8SAndre Fischer { 7347a32b0c8SAndre Fischer if ((WritingMode_TB_RL != pInfo->meWritingMode) || bVertical) 7357a32b0c8SAndre Fischer { 7367a32b0c8SAndre Fischer BitmapEx aBmp (SdResId (bHighContrast 7377a32b0c8SAndre Fischer ? pInfo->mnHCBmpResId 7387a32b0c8SAndre Fischer : pInfo->mnBmpResId)); 7397a32b0c8SAndre Fischer 7407a32b0c8SAndre Fischer if (bRightToLeft && (WritingMode_TB_RL != pInfo->meWritingMode)) 7417a32b0c8SAndre Fischer aBmp.Mirror (BMP_MIRROR_HORZ); 7427a32b0c8SAndre Fischer 7437a32b0c8SAndre Fischer InsertItem (i, aBmp, String (SdResId (pInfo->mnStrResId))); 7447a32b0c8SAndre Fischer SetItemData (i, new AutoLayout(pInfo->maAutoLayout)); 7457a32b0c8SAndre Fischer n++; 7467a32b0c8SAndre Fischer } 7477a32b0c8SAndre Fischer } 7487a32b0c8SAndre Fischer 7497a32b0c8SAndre Fischer mbSelectionUpdatePending = true; 7507a32b0c8SAndre Fischer } 7517a32b0c8SAndre Fischer 7527a32b0c8SAndre Fischer 7537a32b0c8SAndre Fischer 7547a32b0c8SAndre Fischer 7557a32b0c8SAndre Fischer void LayoutMenu::Clear (void) 7567a32b0c8SAndre Fischer { 7577a32b0c8SAndre Fischer for (sal_uInt16 nId=1; nId<=GetItemCount(); nId++) 7587a32b0c8SAndre Fischer delete static_cast<AutoLayout*>(GetItemData(nId)); 7597a32b0c8SAndre Fischer ValueSet::Clear(); 7607a32b0c8SAndre Fischer } 7617a32b0c8SAndre Fischer 7627a32b0c8SAndre Fischer 7637a32b0c8SAndre Fischer 7647a32b0c8SAndre Fischer void LayoutMenu::StartDrag (sal_Int8 , const Point& ) 7657a32b0c8SAndre Fischer { 7667a32b0c8SAndre Fischer } 7677a32b0c8SAndre Fischer 7687a32b0c8SAndre Fischer 7697a32b0c8SAndre Fischer 7707a32b0c8SAndre Fischer 7717a32b0c8SAndre Fischer sal_Int8 LayoutMenu::AcceptDrop (const AcceptDropEvent& ) 7727a32b0c8SAndre Fischer { 7737a32b0c8SAndre Fischer return 0; 7747a32b0c8SAndre Fischer } 7757a32b0c8SAndre Fischer 7767a32b0c8SAndre Fischer 7777a32b0c8SAndre Fischer 7787a32b0c8SAndre Fischer 7797a32b0c8SAndre Fischer sal_Int8 LayoutMenu::ExecuteDrop (const ExecuteDropEvent& ) 7807a32b0c8SAndre Fischer { 7817a32b0c8SAndre Fischer return 0; 7827a32b0c8SAndre Fischer } 7837a32b0c8SAndre Fischer 7847a32b0c8SAndre Fischer 7857a32b0c8SAndre Fischer 7867a32b0c8SAndre Fischer 7877a32b0c8SAndre Fischer void LayoutMenu::Command (const CommandEvent& rEvent) 7887a32b0c8SAndre Fischer { 7897a32b0c8SAndre Fischer switch (rEvent.GetCommand()) 7907a32b0c8SAndre Fischer { 7917a32b0c8SAndre Fischer case COMMAND_CONTEXTMENU: 7927a32b0c8SAndre Fischer if ( ! SD_MOD()->GetWaterCan()) 7937a32b0c8SAndre Fischer { 794*02c50d82SAndre Fischer // Determine the position where to show the menu. 795*02c50d82SAndre Fischer Point aMenuPosition; 7967a32b0c8SAndre Fischer if (rEvent.IsMouseEvent()) 7977a32b0c8SAndre Fischer { 798*02c50d82SAndre Fischer if (GetItemId(rEvent.GetMousePosPixel()) <= 0) 799*02c50d82SAndre Fischer return; 800*02c50d82SAndre Fischer aMenuPosition = rEvent.GetMousePosPixel(); 8017a32b0c8SAndre Fischer } 8027a32b0c8SAndre Fischer else 8037a32b0c8SAndre Fischer { 804*02c50d82SAndre Fischer if (GetSelectItemId() == (sal_uInt16)-1) 805*02c50d82SAndre Fischer return; 806*02c50d82SAndre Fischer Rectangle aBBox (GetItemRect(GetSelectItemId())); 807*02c50d82SAndre Fischer aMenuPosition = aBBox.Center(); 8087a32b0c8SAndre Fischer } 809*02c50d82SAndre Fischer 810*02c50d82SAndre Fischer // Setup the menu. 811*02c50d82SAndre Fischer ::boost::shared_ptr<PopupMenu> pMenu (new PopupMenu(SdResId(RID_TASKPANE_LAYOUTMENU_POPUP))); 812*02c50d82SAndre Fischer FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow()); 813*02c50d82SAndre Fischer if (pMenuWindow != NULL) 814*02c50d82SAndre Fischer pMenuWindow->SetPopupModeFlags( 815*02c50d82SAndre Fischer pMenuWindow->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE); 816*02c50d82SAndre Fischer pMenu->SetSelectHdl(LINK(this, LayoutMenu, OnMenuItemSelected)); 817*02c50d82SAndre Fischer 818*02c50d82SAndre Fischer // Disable the SID_INSERTPAGE_LAYOUT_MENU item when 819*02c50d82SAndre Fischer // the document is read-only. 820*02c50d82SAndre Fischer const SfxPoolItem* pItem = NULL; 821*02c50d82SAndre Fischer const SfxItemState aState ( 822*02c50d82SAndre Fischer mrBase.GetViewFrame()->GetDispatcher()->QueryState(SID_INSERTPAGE, pItem)); 823*02c50d82SAndre Fischer if (aState == SFX_ITEM_DISABLED) 824*02c50d82SAndre Fischer pMenu->EnableItem(SID_INSERTPAGE_LAYOUT_MENU, sal_False); 825*02c50d82SAndre Fischer 826*02c50d82SAndre Fischer // Show the menu. 827*02c50d82SAndre Fischer pMenu->Execute(this, Rectangle(aMenuPosition,Size(1,1)), POPUPMENU_EXECUTE_DOWN); 8287a32b0c8SAndre Fischer } 8297a32b0c8SAndre Fischer break; 8307a32b0c8SAndre Fischer 8317a32b0c8SAndre Fischer default: 8327a32b0c8SAndre Fischer ValueSet::Command(rEvent); 8337a32b0c8SAndre Fischer break; 8347a32b0c8SAndre Fischer } 8357a32b0c8SAndre Fischer } 8367a32b0c8SAndre Fischer 8377a32b0c8SAndre Fischer 8387a32b0c8SAndre Fischer 8397a32b0c8SAndre Fischer 8407a32b0c8SAndre Fischer IMPL_LINK(LayoutMenu, StateChangeHandler, ::rtl::OUString*, EMPTYARG) 8417a32b0c8SAndre Fischer { 8427a32b0c8SAndre Fischer InvalidateContent(); 8437a32b0c8SAndre Fischer return 0; 8447a32b0c8SAndre Fischer } 8457a32b0c8SAndre Fischer 8467a32b0c8SAndre Fischer 8477a32b0c8SAndre Fischer 8487a32b0c8SAndre Fischer 849*02c50d82SAndre Fischer IMPL_LINK(LayoutMenu, OnMenuItemSelected, Menu*, pMenu) 850*02c50d82SAndre Fischer { 851*02c50d82SAndre Fischer if (pMenu == NULL) 852*02c50d82SAndre Fischer { 853*02c50d82SAndre Fischer OSL_ENSURE(pMenu!=NULL, "LayoutMenu::OnMenuItemSelected: illegal menu!"); 854*02c50d82SAndre Fischer return 0; 855*02c50d82SAndre Fischer } 856*02c50d82SAndre Fischer 857*02c50d82SAndre Fischer pMenu->Deactivate(); 858*02c50d82SAndre Fischer const sal_Int32 nIndex (pMenu->GetCurItemId()); 859*02c50d82SAndre Fischer 860*02c50d82SAndre Fischer if (nIndex == SID_TP_APPLY_TO_SELECTED_SLIDES) 861*02c50d82SAndre Fischer { 862*02c50d82SAndre Fischer AssignLayoutToSelectedSlides(GetSelectedAutoLayout()); 863*02c50d82SAndre Fischer } 864*02c50d82SAndre Fischer else if (nIndex == SID_INSERTPAGE_LAYOUT_MENU) 865*02c50d82SAndre Fischer { 866*02c50d82SAndre Fischer // Add arguments to this slot and forward it to the main view 867*02c50d82SAndre Fischer // shell. 868*02c50d82SAndre Fischer InsertPageWithLayout(GetSelectedAutoLayout()); 869*02c50d82SAndre Fischer } 870*02c50d82SAndre Fischer 871*02c50d82SAndre Fischer return 0; 872*02c50d82SAndre Fischer } 873*02c50d82SAndre Fischer 874*02c50d82SAndre Fischer 875*02c50d82SAndre Fischer 876*02c50d82SAndre Fischer 8777a32b0c8SAndre Fischer void LayoutMenu::UpdateSelection (void) 8787a32b0c8SAndre Fischer { 8797a32b0c8SAndre Fischer bool bItemSelected = false; 8807a32b0c8SAndre Fischer 8817a32b0c8SAndre Fischer do 8827a32b0c8SAndre Fischer { 8837a32b0c8SAndre Fischer // Get current page of main view. 8847a32b0c8SAndre Fischer ViewShell* pViewShell = mrBase.GetMainViewShell().get(); 8857a32b0c8SAndre Fischer if (pViewShell == NULL) 8867a32b0c8SAndre Fischer break; 8877a32b0c8SAndre Fischer 8887a32b0c8SAndre Fischer SdPage* pCurrentPage = pViewShell->getCurrentPage(); 8897a32b0c8SAndre Fischer if (pCurrentPage == NULL) 8907a32b0c8SAndre Fischer break; 8917a32b0c8SAndre Fischer 8927a32b0c8SAndre Fischer // Get layout of current page. 8937a32b0c8SAndre Fischer AutoLayout aLayout (pCurrentPage->GetAutoLayout()); 8947a32b0c8SAndre Fischer if (aLayout<AUTOLAYOUT__START || aLayout>AUTOLAYOUT__END) 8957a32b0c8SAndre Fischer break; 8967a32b0c8SAndre Fischer 8977a32b0c8SAndre Fischer // Find the entry of the menu for to the layout. 8987a32b0c8SAndre Fischer sal_uInt16 nItemCount (GetItemCount()); 8997a32b0c8SAndre Fischer for (sal_uInt16 nId=1; nId<=nItemCount; nId++) 9007a32b0c8SAndre Fischer { 9017a32b0c8SAndre Fischer if (*static_cast<AutoLayout*>(GetItemData(nId)) == aLayout) 9027a32b0c8SAndre Fischer { 9037a32b0c8SAndre Fischer SelectItem(nId); 9047a32b0c8SAndre Fischer bItemSelected = true; 9057a32b0c8SAndre Fischer break; 9067a32b0c8SAndre Fischer } 9077a32b0c8SAndre Fischer } 9087a32b0c8SAndre Fischer } 9097a32b0c8SAndre Fischer while (false); 9107a32b0c8SAndre Fischer 9117a32b0c8SAndre Fischer if ( ! bItemSelected) 9127a32b0c8SAndre Fischer SetNoSelection(); 9137a32b0c8SAndre Fischer } 9147a32b0c8SAndre Fischer 9157a32b0c8SAndre Fischer 9167a32b0c8SAndre Fischer 9177a32b0c8SAndre Fischer 9187a32b0c8SAndre Fischer IMPL_LINK(LayoutMenu, EventMultiplexerListener, ::sd::tools::EventMultiplexerEvent*, pEvent) 9197a32b0c8SAndre Fischer { 9207a32b0c8SAndre Fischer switch (pEvent->meEventId) 9217a32b0c8SAndre Fischer { 9227a32b0c8SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_CURRENT_PAGE: 9237a32b0c8SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_SLIDE_SORTER_SELECTION: 9247a32b0c8SAndre Fischer if ( ! mbSelectionUpdatePending) 9257a32b0c8SAndre Fischer UpdateSelection(); 9267a32b0c8SAndre Fischer break; 9277a32b0c8SAndre Fischer 9287a32b0c8SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED: 9297a32b0c8SAndre Fischer mbIsMainViewChangePending = true; 9307a32b0c8SAndre Fischer UpdateEnabledState(MM_UNKNOWN); 9317a32b0c8SAndre Fischer break; 9327a32b0c8SAndre Fischer 9337a32b0c8SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED: 9347a32b0c8SAndre Fischer HideFocus(); 9357a32b0c8SAndre Fischer break; 9367a32b0c8SAndre Fischer 9377a32b0c8SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED: 9387a32b0c8SAndre Fischer if (mbIsMainViewChangePending) 9397a32b0c8SAndre Fischer { 9407a32b0c8SAndre Fischer mbIsMainViewChangePending = false; 9417a32b0c8SAndre Fischer InvalidateContent(); 9427a32b0c8SAndre Fischer } 9437a32b0c8SAndre Fischer break; 9447a32b0c8SAndre Fischer 9457a32b0c8SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_NORMAL: 9467a32b0c8SAndre Fischer UpdateEnabledState(MM_NORMAL); 9477a32b0c8SAndre Fischer break; 9487a32b0c8SAndre Fischer 9497a32b0c8SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_MASTER: 9507a32b0c8SAndre Fischer UpdateEnabledState(MM_MASTER); 9517a32b0c8SAndre Fischer break; 9527a32b0c8SAndre Fischer 9537a32b0c8SAndre Fischer default: 9547a32b0c8SAndre Fischer /* Ignored */ 9557a32b0c8SAndre Fischer break; 9567a32b0c8SAndre Fischer } 9577a32b0c8SAndre Fischer 9587a32b0c8SAndre Fischer return 0; 9597a32b0c8SAndre Fischer } 9607a32b0c8SAndre Fischer 9617a32b0c8SAndre Fischer 9627a32b0c8SAndre Fischer 9637a32b0c8SAndre Fischer 9647a32b0c8SAndre Fischer IMPL_LINK(LayoutMenu, WindowEventHandler, VclWindowEvent*, pEvent) 9657a32b0c8SAndre Fischer { 9667a32b0c8SAndre Fischer if (pEvent != NULL) 9677a32b0c8SAndre Fischer { 9687a32b0c8SAndre Fischer switch (pEvent->GetId()) 9697a32b0c8SAndre Fischer { 9707a32b0c8SAndre Fischer case VCLEVENT_WINDOW_SHOW: 9717a32b0c8SAndre Fischer case VCLEVENT_WINDOW_RESIZE: 9727a32b0c8SAndre Fischer SetSizePixel(GetParent()->GetSizePixel()); 9737a32b0c8SAndre Fischer return sal_True; 9747a32b0c8SAndre Fischer 9757a32b0c8SAndre Fischer default: 9767a32b0c8SAndre Fischer return sal_False; 9777a32b0c8SAndre Fischer } 9787a32b0c8SAndre Fischer 9797a32b0c8SAndre Fischer const SfxSimpleHint* pSimpleHint = PTR_CAST(SfxSimpleHint, pEvent); 9807a32b0c8SAndre Fischer if (pSimpleHint != NULL 9817a32b0c8SAndre Fischer && pSimpleHint->GetId() == SFX_HINT_DYING) 9827a32b0c8SAndre Fischer { 9837a32b0c8SAndre Fischer return sal_True; 9847a32b0c8SAndre Fischer } 9857a32b0c8SAndre Fischer } 9867a32b0c8SAndre Fischer 9877a32b0c8SAndre Fischer return sal_False; 9887a32b0c8SAndre Fischer } 9897a32b0c8SAndre Fischer 9907a32b0c8SAndre Fischer 9917a32b0c8SAndre Fischer 9927a32b0c8SAndre Fischer 9937a32b0c8SAndre Fischer void LayoutMenu::DataChanged (const DataChangedEvent& rEvent) 9947a32b0c8SAndre Fischer { 9957a32b0c8SAndre Fischer Fill(); 9967a32b0c8SAndre Fischer ValueSet::DataChanged(rEvent); 9977a32b0c8SAndre Fischer } 9987a32b0c8SAndre Fischer 9997a32b0c8SAndre Fischer 10007a32b0c8SAndre Fischer 10017a32b0c8SAndre Fischer 10027a32b0c8SAndre Fischer 10037a32b0c8SAndre Fischer } } // end of namespace ::sd::sidebar 1004