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" 45*8dcb2a10SAndre Fischer #include <sfx2/sidebar/Theme.hxx> 467a32b0c8SAndre Fischer 477a32b0c8SAndre Fischer #include <comphelper/processfactory.hxx> 487a32b0c8SAndre Fischer #include <sfx2/app.hxx> 497a32b0c8SAndre Fischer #include <sfx2/dispatch.hxx> 507a32b0c8SAndre Fischer #include <sfx2/objface.hxx> 517a32b0c8SAndre Fischer #include <sfx2/request.hxx> 527a32b0c8SAndre Fischer #include <sfx2/viewfrm.hxx> 537a32b0c8SAndre Fischer #include <svl/languageoptions.hxx> 547a32b0c8SAndre Fischer #include <vcl/image.hxx> 5502c50d82SAndre Fischer #include <vcl/floatwin.hxx> 567a32b0c8SAndre Fischer 577a32b0c8SAndre Fischer #include <com/sun/star/frame/XController.hpp> 587a32b0c8SAndre Fischer #include <com/sun/star/drawing/framework/XControllerManager.hpp> 597a32b0c8SAndre Fischer #include <com/sun/star/drawing/framework/XView.hpp> 607a32b0c8SAndre Fischer #include <com/sun/star/drawing/framework/ResourceId.hpp> 617a32b0c8SAndre Fischer 627a32b0c8SAndre Fischer #include <vector> 637a32b0c8SAndre Fischer #include <memory> 647a32b0c8SAndre Fischer 657a32b0c8SAndre Fischer using namespace ::com::sun::star; 667a32b0c8SAndre Fischer using namespace ::com::sun::star::text; 677a32b0c8SAndre Fischer using namespace ::com::sun::star::uno; 687a32b0c8SAndre Fischer using namespace ::com::sun::star::drawing::framework; 697a32b0c8SAndre Fischer using namespace ::sd::slidesorter; 707a32b0c8SAndre Fischer using ::sd::framework::FrameworkHelper; 717a32b0c8SAndre Fischer 727a32b0c8SAndre Fischer namespace sd { namespace sidebar { 737a32b0c8SAndre Fischer 747a32b0c8SAndre Fischer 757a32b0c8SAndre Fischer 767a32b0c8SAndre Fischer struct snewfoil_value_info 777a32b0c8SAndre Fischer { 787a32b0c8SAndre Fischer sal_uInt16 mnBmpResId; 797a32b0c8SAndre Fischer sal_uInt16 mnHCBmpResId; 807a32b0c8SAndre Fischer sal_uInt16 mnStrResId; 817a32b0c8SAndre Fischer WritingMode meWritingMode; 827a32b0c8SAndre Fischer AutoLayout maAutoLayout; 837a32b0c8SAndre Fischer }; 847a32b0c8SAndre Fischer 857a32b0c8SAndre Fischer static snewfoil_value_info notes[] = 867a32b0c8SAndre Fischer { 877a32b0c8SAndre Fischer {BMP_FOILN_01, BMP_FOILN_01_H, STR_AUTOLAYOUT_NOTES, WritingMode_LR_TB, 887a32b0c8SAndre Fischer AUTOLAYOUT_NOTES}, 897a32b0c8SAndre Fischer {0, 0, 0, WritingMode_LR_TB, AUTOLAYOUT_NONE}, 907a32b0c8SAndre Fischer }; 917a32b0c8SAndre Fischer 927a32b0c8SAndre Fischer static snewfoil_value_info handout[] = 937a32b0c8SAndre Fischer { 947a32b0c8SAndre Fischer {BMP_FOILH_01, BMP_FOILH_01_H, STR_AUTOLAYOUT_HANDOUT1, WritingMode_LR_TB, 957a32b0c8SAndre Fischer AUTOLAYOUT_HANDOUT1}, 967a32b0c8SAndre Fischer {BMP_FOILH_02, BMP_FOILH_02_H, STR_AUTOLAYOUT_HANDOUT2, WritingMode_LR_TB, 977a32b0c8SAndre Fischer AUTOLAYOUT_HANDOUT2}, 987a32b0c8SAndre Fischer {BMP_FOILH_03, BMP_FOILH_03_H, STR_AUTOLAYOUT_HANDOUT3, WritingMode_LR_TB, 997a32b0c8SAndre Fischer AUTOLAYOUT_HANDOUT3}, 1007a32b0c8SAndre Fischer {BMP_FOILH_04, BMP_FOILH_04_H, STR_AUTOLAYOUT_HANDOUT4, WritingMode_LR_TB, 1017a32b0c8SAndre Fischer AUTOLAYOUT_HANDOUT4}, 1027a32b0c8SAndre Fischer {BMP_FOILH_06, BMP_FOILH_06_H, STR_AUTOLAYOUT_HANDOUT6, WritingMode_LR_TB, 1037a32b0c8SAndre Fischer AUTOLAYOUT_HANDOUT6}, 1047a32b0c8SAndre Fischer {BMP_FOILH_09, BMP_FOILH_09_H, STR_AUTOLAYOUT_HANDOUT9, WritingMode_LR_TB, 1057a32b0c8SAndre Fischer AUTOLAYOUT_HANDOUT9}, 1067a32b0c8SAndre Fischer {0, 0, 0, WritingMode_LR_TB, AUTOLAYOUT_NONE}, 1077a32b0c8SAndre Fischer }; 1087a32b0c8SAndre Fischer 1097a32b0c8SAndre Fischer static snewfoil_value_info standard[] = 1107a32b0c8SAndre Fischer { 1117a32b0c8SAndre Fischer {BMP_LAYOUT_EMPTY, BMP_LAYOUT_EMPTY_H, STR_AUTOLAYOUT_NONE, WritingMode_LR_TB, AUTOLAYOUT_NONE}, 1127a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD03, BMP_LAYOUT_HEAD03_H, STR_AUTOLAYOUT_TITLE, WritingMode_LR_TB, AUTOLAYOUT_TITLE}, 1137a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD02, BMP_LAYOUT_HEAD02_H, STR_AUTOLAYOUT_CONTENT, WritingMode_LR_TB, AUTOLAYOUT_ENUM}, 1147a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD02A, BMP_LAYOUT_HEAD02A_H, STR_AUTOLAYOUT_2CONTENT, WritingMode_LR_TB, AUTOLAYOUT_2TEXT}, 1157a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD01, BMP_LAYOUT_HEAD01_H, STR_AUTOLAYOUT_ONLY_TITLE, WritingMode_LR_TB, AUTOLAYOUT_ONLY_TITLE}, 1167a32b0c8SAndre Fischer {BMP_LAYOUT_TEXTONLY, BMP_LAYOUT_TEXTONLY_H, STR_AUTOLAYOUT_ONLY_TEXT, WritingMode_LR_TB, AUTOLAYOUT_ONLY_TEXT}, 1177a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD03B, BMP_LAYOUT_HEAD03B_H, STR_AUTOLAYOUT_2CONTENT_CONTENT, WritingMode_LR_TB, AUTOLAYOUT_2OBJTEXT}, 1187a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD03C, BMP_LAYOUT_HEAD03C_H, STR_AUTOLAYOUT_CONTENT_2CONTENT, WritingMode_LR_TB, AUTOLAYOUT_TEXT2OBJ}, 1197a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD03A, BMP_LAYOUT_HEAD03A_H, STR_AUTOLAYOUT_2CONTENT_OVER_CONTENT,WritingMode_LR_TB, AUTOLAYOUT_2OBJOVERTEXT}, 1207a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD02B, BMP_LAYOUT_HEAD02B_H, STR_AUTOLAYOUT_CONTENT_OVER_CONTENT, WritingMode_LR_TB, AUTOLAYOUT_OBJOVERTEXT}, 1217a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD04, BMP_LAYOUT_HEAD04_H, STR_AUTOLAYOUT_4CONTENT, WritingMode_LR_TB, AUTOLAYOUT_4OBJ}, 1227a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD06, BMP_LAYOUT_HEAD06_H, STR_AUTOLAYOUT_6CONTENT, WritingMode_LR_TB, AUTOLAYOUT_6CLIPART}, 1237a32b0c8SAndre Fischer 1247a32b0c8SAndre Fischer // vertical 1257a32b0c8SAndre Fischer {BMP_LAYOUT_VERTICAL02, BMP_LAYOUT_VERTICAL02_H, STR_AL_VERT_TITLE_TEXT_CHART, WritingMode_TB_RL,AUTOLAYOUT_VERTICAL_TITLE_TEXT_CHART}, 1267a32b0c8SAndre Fischer {BMP_LAYOUT_VERTICAL01, BMP_LAYOUT_VERTICAL01_H, STR_AL_VERT_TITLE_VERT_OUTLINE, WritingMode_TB_RL, AUTOLAYOUT_VERTICAL_TITLE_VERTICAL_OUTLINE}, 1277a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD02, BMP_LAYOUT_HEAD02_H, STR_AL_TITLE_VERT_OUTLINE, WritingMode_TB_RL, AUTOLAYOUT_TITLE_VERTICAL_OUTLINE}, 1287a32b0c8SAndre Fischer {BMP_LAYOUT_HEAD02A, BMP_LAYOUT_HEAD02A_H, STR_AL_TITLE_VERT_OUTLINE_CLIPART, WritingMode_TB_RL, AUTOLAYOUT_TITLE_VERTICAL_OUTLINE_CLIPART}, 1297a32b0c8SAndre Fischer {0, 0, 0, WritingMode_LR_TB, AUTOLAYOUT_NONE} 1307a32b0c8SAndre Fischer }; 1317a32b0c8SAndre Fischer 1327a32b0c8SAndre Fischer 1337a32b0c8SAndre Fischer 1347a32b0c8SAndre Fischer 1357a32b0c8SAndre Fischer LayoutMenu::LayoutMenu ( 1367a32b0c8SAndre Fischer ::Window* pParent, 1377a32b0c8SAndre Fischer ViewShellBase& rViewShellBase, 13802c50d82SAndre Fischer const cssu::Reference<css::ui::XSidebar>& rxSidebar) 1397a32b0c8SAndre Fischer : ValueSet (pParent), 1407a32b0c8SAndre Fischer DragSourceHelper(this), 1417a32b0c8SAndre Fischer DropTargetHelper(this), 1427a32b0c8SAndre Fischer mrBase(rViewShellBase), 1437a32b0c8SAndre Fischer mbUseOwnScrollBar(false), 1447a32b0c8SAndre Fischer mnPreferredColumnCount(3), 1457a32b0c8SAndre Fischer mxListener(NULL), 1467a32b0c8SAndre Fischer mbSelectionUpdatePending(true), 1477a32b0c8SAndre Fischer mbIsMainViewChangePending(false), 14802c50d82SAndre Fischer mxSidebar(rxSidebar), 1497a32b0c8SAndre Fischer mbIsDisposed(false) 1507a32b0c8SAndre Fischer { 1517a32b0c8SAndre Fischer implConstruct( *mrBase.GetDocument()->GetDocSh() ); 15202c50d82SAndre Fischer OSL_TRACE("created LayoutMenu at %x", this); 153*8dcb2a10SAndre Fischer 154*8dcb2a10SAndre Fischer SetStyle(GetStyle() | WB_ITEMBORDER | WB_FLATVALUESET | WB_TABSTOP); 155*8dcb2a10SAndre Fischer 156*8dcb2a10SAndre Fischer SetBackground(sfx2::sidebar::Theme::GetWallpaper(sfx2::sidebar::Theme::Paint_PanelBackground)); 157*8dcb2a10SAndre Fischer SetColor(sfx2::sidebar::Theme::GetColor(sfx2::sidebar::Theme::Paint_PanelBackground)); 15802c50d82SAndre Fischer 1597a32b0c8SAndre Fischer #ifdef DEBUG 1607a32b0c8SAndre Fischer SetText(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sd:LayoutMenu"))); 1617a32b0c8SAndre Fischer #endif 1627a32b0c8SAndre Fischer } 1637a32b0c8SAndre Fischer 1647a32b0c8SAndre Fischer 1657a32b0c8SAndre Fischer 1667a32b0c8SAndre Fischer 1677a32b0c8SAndre Fischer void LayoutMenu::implConstruct( DrawDocShell& rDocumentShell ) 1687a32b0c8SAndre Fischer { 1697a32b0c8SAndre Fischer OSL_ENSURE( mrBase.GetDocument()->GetDocSh() == &rDocumentShell, 1707a32b0c8SAndre Fischer "LayoutMenu::implConstruct: hmm?" ); 1717a32b0c8SAndre Fischer // if this fires, then my assumption that the rDocumentShell parameter to our first ctor is superfluous ... 1727a32b0c8SAndre Fischer 1737a32b0c8SAndre Fischer SetStyle ( 1747a32b0c8SAndre Fischer ( GetStyle() & ~(WB_ITEMBORDER) ) 1757a32b0c8SAndre Fischer | WB_TABSTOP 176*8dcb2a10SAndre Fischer | WB_MENUSTYLEVALUESET 1777a32b0c8SAndre Fischer | WB_NO_DIRECTSELECT 1787a32b0c8SAndre Fischer ); 1797a32b0c8SAndre Fischer if (mbUseOwnScrollBar) 1807a32b0c8SAndre Fischer SetStyle (GetStyle() | WB_VSCROLL); 1817a32b0c8SAndre Fischer SetExtraSpacing(2); 1827a32b0c8SAndre Fischer SetSelectHdl (LINK(this, LayoutMenu, ClickHandler)); 1837a32b0c8SAndre Fischer InvalidateContent(); 1847a32b0c8SAndre Fischer 1857a32b0c8SAndre Fischer Link aEventListenerLink (LINK(this,LayoutMenu,EventMultiplexerListener)); 1867a32b0c8SAndre Fischer mrBase.GetEventMultiplexer()->AddEventListener(aEventListenerLink, 1877a32b0c8SAndre Fischer ::sd::tools::EventMultiplexerEvent::EID_CURRENT_PAGE 1887a32b0c8SAndre Fischer | ::sd::tools::EventMultiplexerEvent::EID_SLIDE_SORTER_SELECTION 1897a32b0c8SAndre Fischer | ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED 1907a32b0c8SAndre Fischer | ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED 1917a32b0c8SAndre Fischer | ::sd::tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED 1927a32b0c8SAndre Fischer | ::sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_NORMAL 1937a32b0c8SAndre Fischer | ::sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_MASTER); 1947a32b0c8SAndre Fischer 1957a32b0c8SAndre Fischer Window::SetHelpId(HID_SD_TASK_PANE_PREVIEW_LAYOUTS); 1967a32b0c8SAndre Fischer SetAccessibleName(SdResId(STR_TASKPANEL_LAYOUT_MENU_TITLE)); 1977a32b0c8SAndre Fischer 1987a32b0c8SAndre Fischer Link aStateChangeLink (LINK(this,LayoutMenu,StateChangeHandler)); 1997a32b0c8SAndre Fischer mxListener = new ::sd::tools::SlotStateListener( 2007a32b0c8SAndre Fischer aStateChangeLink, 2017a32b0c8SAndre Fischer Reference<frame::XDispatchProvider>(mrBase.GetController()->getFrame(), UNO_QUERY), 2027a32b0c8SAndre Fischer ::rtl::OUString::createFromAscii(".uno:VerticalTextState")); 2037a32b0c8SAndre Fischer 2047a32b0c8SAndre Fischer SetSizePixel(GetParent()->GetSizePixel()); 2057a32b0c8SAndre Fischer Link aWindowEventHandlerLink (LINK(this,LayoutMenu,WindowEventHandler)); 2067a32b0c8SAndre Fischer GetParent()->AddEventListener(aWindowEventHandlerLink); 2077a32b0c8SAndre Fischer } 2087a32b0c8SAndre Fischer 2097a32b0c8SAndre Fischer 2107a32b0c8SAndre Fischer 2117a32b0c8SAndre Fischer 2127a32b0c8SAndre Fischer LayoutMenu::~LayoutMenu (void) 2137a32b0c8SAndre Fischer { 21402c50d82SAndre Fischer OSL_TRACE("destroying LayoutMenu at %x", this); 2157a32b0c8SAndre Fischer Dispose(); 2167a32b0c8SAndre Fischer } 2177a32b0c8SAndre Fischer 2187a32b0c8SAndre Fischer 2197a32b0c8SAndre Fischer 2207a32b0c8SAndre Fischer 2217a32b0c8SAndre Fischer void LayoutMenu::Dispose (void) 2227a32b0c8SAndre Fischer { 2237a32b0c8SAndre Fischer if (mbIsDisposed) 2247a32b0c8SAndre Fischer return; 2257a32b0c8SAndre Fischer 22602c50d82SAndre Fischer OSL_TRACE("disposing LayoutMenu at %x", this); 22702c50d82SAndre Fischer 2287a32b0c8SAndre Fischer mbIsDisposed = true; 2297a32b0c8SAndre Fischer 2307a32b0c8SAndre Fischer Reference<lang::XComponent> xComponent (mxListener, UNO_QUERY); 2317a32b0c8SAndre Fischer if (xComponent.is()) 2327a32b0c8SAndre Fischer xComponent->dispose(); 2337a32b0c8SAndre Fischer 2347a32b0c8SAndre Fischer Clear(); 2357a32b0c8SAndre Fischer Link aLink (LINK(this,LayoutMenu,EventMultiplexerListener)); 2367a32b0c8SAndre Fischer mrBase.GetEventMultiplexer()->RemoveEventListener (aLink); 2377a32b0c8SAndre Fischer 2387a32b0c8SAndre Fischer Link aWindowEventHandlerLink (LINK(this,LayoutMenu,WindowEventHandler)); 2397a32b0c8SAndre Fischer GetParent()->RemoveEventListener(aWindowEventHandlerLink); 2407a32b0c8SAndre Fischer } 2417a32b0c8SAndre Fischer 2427a32b0c8SAndre Fischer 2437a32b0c8SAndre Fischer 2447a32b0c8SAndre Fischer 2457a32b0c8SAndre Fischer AutoLayout LayoutMenu::GetSelectedAutoLayout (void) 2467a32b0c8SAndre Fischer { 2477a32b0c8SAndre Fischer AutoLayout aResult = AUTOLAYOUT_NONE; 2487a32b0c8SAndre Fischer 2497a32b0c8SAndre Fischer if ( ! IsNoSelection() && GetSelectItemId()!=0) 2507a32b0c8SAndre Fischer { 2517a32b0c8SAndre Fischer AutoLayout* pLayout = static_cast<AutoLayout*>(GetItemData(GetSelectItemId())); 2527a32b0c8SAndre Fischer if (pLayout != NULL) 2537a32b0c8SAndre Fischer aResult = *pLayout; 2547a32b0c8SAndre Fischer } 2557a32b0c8SAndre Fischer 2567a32b0c8SAndre Fischer return aResult; 2577a32b0c8SAndre Fischer } 2587a32b0c8SAndre Fischer 2597a32b0c8SAndre Fischer 2607a32b0c8SAndre Fischer 2617a32b0c8SAndre Fischer 2627a32b0c8SAndre Fischer /** The preferred size depends on the preferred number of columns, the 2637a32b0c8SAndre Fischer number of items, and the size of the items. 2647a32b0c8SAndre Fischer */ 2657a32b0c8SAndre Fischer Size LayoutMenu::GetPreferredSize (void) 2667a32b0c8SAndre Fischer { 2677a32b0c8SAndre Fischer Size aItemSize = CalcItemSizePixel (Size()); 2687a32b0c8SAndre Fischer Size aPreferredWindowSize = CalcWindowSizePixel ( 2697a32b0c8SAndre Fischer aItemSize, 2707a32b0c8SAndre Fischer (sal_uInt16)mnPreferredColumnCount, 2717a32b0c8SAndre Fischer (sal_uInt16)CalculateRowCount (aItemSize,mnPreferredColumnCount)); 2727a32b0c8SAndre Fischer return aPreferredWindowSize; 2737a32b0c8SAndre Fischer } 2747a32b0c8SAndre Fischer 2757a32b0c8SAndre Fischer 2767a32b0c8SAndre Fischer 2777a32b0c8SAndre Fischer 2787a32b0c8SAndre Fischer sal_Int32 LayoutMenu::GetPreferredWidth (sal_Int32 nHeight) 2797a32b0c8SAndre Fischer { 2807a32b0c8SAndre Fischer sal_Int32 nPreferredWidth = 100; 2817a32b0c8SAndre Fischer if (GetItemCount() > 0) 2827a32b0c8SAndre Fischer { 2837a32b0c8SAndre Fischer Image aImage = GetItemImage(GetItemId(0)); 2847a32b0c8SAndre Fischer Size aItemSize = CalcItemSizePixel (aImage.GetSizePixel()); 2857a32b0c8SAndre Fischer if (nHeight>0 && aItemSize.Height()>0) 2867a32b0c8SAndre Fischer { 2877a32b0c8SAndre Fischer int nRowCount = nHeight / aItemSize.Height(); 2887a32b0c8SAndre Fischer if (nRowCount <= 0) 2897a32b0c8SAndre Fischer nRowCount = 1; 2907a32b0c8SAndre Fischer int nColumnCount = (GetItemCount() + nRowCount-1) / nRowCount; 2917a32b0c8SAndre Fischer nPreferredWidth = nColumnCount * aItemSize.Width(); 2927a32b0c8SAndre Fischer } 2937a32b0c8SAndre Fischer } 2947a32b0c8SAndre Fischer 2957a32b0c8SAndre Fischer return nPreferredWidth; 2967a32b0c8SAndre Fischer } 2977a32b0c8SAndre Fischer 2987a32b0c8SAndre Fischer 2997a32b0c8SAndre Fischer 3007a32b0c8SAndre Fischer 3017a32b0c8SAndre Fischer ui::LayoutSize LayoutMenu::GetHeightForWidth (const sal_Int32 nWidth) 3027a32b0c8SAndre Fischer { 3037a32b0c8SAndre Fischer sal_Int32 nPreferredHeight = 200; 3047a32b0c8SAndre Fischer if ( ! mbUseOwnScrollBar && GetItemCount()>0) 3057a32b0c8SAndre Fischer { 3067a32b0c8SAndre Fischer Image aImage = GetItemImage(GetItemId(0)); 3077a32b0c8SAndre Fischer Size aItemSize = CalcItemSizePixel (aImage.GetSizePixel()); 3087a32b0c8SAndre Fischer if (nWidth>0 && aItemSize.Width()>0) 3097a32b0c8SAndre Fischer { 3107a32b0c8SAndre Fischer aItemSize.Width() += 8; 3117a32b0c8SAndre Fischer aItemSize.Height() += 8; 3127a32b0c8SAndre Fischer int nColumnCount = nWidth / aItemSize.Width(); 3137a32b0c8SAndre Fischer if (nColumnCount <= 0) 3147a32b0c8SAndre Fischer nColumnCount = 1; 3157a32b0c8SAndre Fischer else if (nColumnCount > 4) 3167a32b0c8SAndre Fischer nColumnCount = 4; 3177a32b0c8SAndre Fischer int nRowCount = (GetItemCount() + nColumnCount-1) / nColumnCount; 3187a32b0c8SAndre Fischer nPreferredHeight = nRowCount * aItemSize.Height(); 3197a32b0c8SAndre Fischer } 3207a32b0c8SAndre Fischer } 3217a32b0c8SAndre Fischer return ui::LayoutSize(nPreferredHeight,nPreferredHeight,nPreferredHeight); 3227a32b0c8SAndre Fischer } 3237a32b0c8SAndre Fischer 3247a32b0c8SAndre Fischer 3257a32b0c8SAndre Fischer 3267a32b0c8SAndre Fischer 3277a32b0c8SAndre Fischer sal_Int32 LayoutMenu::GetMinimumWidth (void) 3287a32b0c8SAndre Fischer { 3297a32b0c8SAndre Fischer sal_Int32 nMinimumWidth = 0; 3307a32b0c8SAndre Fischer if (GetItemCount()>0) 3317a32b0c8SAndre Fischer { 3327a32b0c8SAndre Fischer Image aImage = GetItemImage(GetItemId(0)); 3337a32b0c8SAndre Fischer Size aItemSize = CalcItemSizePixel (aImage.GetSizePixel()); 3347a32b0c8SAndre Fischer nMinimumWidth = aItemSize.Width(); 3357a32b0c8SAndre Fischer } 3367a32b0c8SAndre Fischer return nMinimumWidth; 3377a32b0c8SAndre Fischer } 3387a32b0c8SAndre Fischer 3397a32b0c8SAndre Fischer 3407a32b0c8SAndre Fischer 3417a32b0c8SAndre Fischer 3427a32b0c8SAndre Fischer void LayoutMenu::UpdateEnabledState (const MasterMode eMode) 3437a32b0c8SAndre Fischer { 3447a32b0c8SAndre Fischer bool bIsEnabled (false); 3457a32b0c8SAndre Fischer 3467a32b0c8SAndre Fischer ::boost::shared_ptr<ViewShell> pMainViewShell (mrBase.GetMainViewShell()); 3477a32b0c8SAndre Fischer if (pMainViewShell) 3487a32b0c8SAndre Fischer { 3497a32b0c8SAndre Fischer switch (pMainViewShell->GetShellType()) 3507a32b0c8SAndre Fischer { 3517a32b0c8SAndre Fischer case ViewShell::ST_NONE: 3527a32b0c8SAndre Fischer case ViewShell::ST_OUTLINE: 3537a32b0c8SAndre Fischer case ViewShell::ST_PRESENTATION: 3547a32b0c8SAndre Fischer case ViewShell::ST_SIDEBAR: 3557a32b0c8SAndre Fischer // The complete task pane is disabled for these values or 3567a32b0c8SAndre Fischer // not even visible. Disabling the LayoutMenu would be 3577a32b0c8SAndre Fischer // logical but unnecessary. The main disadvantage is that 3587a32b0c8SAndre Fischer // after re-enabling it (typically) another panel is 3597a32b0c8SAndre Fischer // expanded. 3607a32b0c8SAndre Fischer bIsEnabled = true; 3617a32b0c8SAndre Fischer break; 3627a32b0c8SAndre Fischer 3637a32b0c8SAndre Fischer case ViewShell::ST_DRAW: 3647a32b0c8SAndre Fischer case ViewShell::ST_IMPRESS: 3657a32b0c8SAndre Fischer { 3667a32b0c8SAndre Fischer switch (eMode) 3677a32b0c8SAndre Fischer { 3687a32b0c8SAndre Fischer case MM_UNKNOWN: 3697a32b0c8SAndre Fischer { 3707a32b0c8SAndre Fischer ::boost::shared_ptr<DrawViewShell> pDrawViewShell ( 3717a32b0c8SAndre Fischer ::boost::dynamic_pointer_cast<DrawViewShell>(pMainViewShell)); 3727a32b0c8SAndre Fischer if (pDrawViewShell) 3737a32b0c8SAndre Fischer bIsEnabled = pDrawViewShell->GetEditMode() != EM_MASTERPAGE; 3747a32b0c8SAndre Fischer break; 3757a32b0c8SAndre Fischer } 3767a32b0c8SAndre Fischer case MM_NORMAL: 3777a32b0c8SAndre Fischer bIsEnabled = true; 3787a32b0c8SAndre Fischer break; 3797a32b0c8SAndre Fischer 3807a32b0c8SAndre Fischer case MM_MASTER: 3817a32b0c8SAndre Fischer bIsEnabled = false; 3827a32b0c8SAndre Fischer break; 3837a32b0c8SAndre Fischer } 3847a32b0c8SAndre Fischer break; 3857a32b0c8SAndre Fischer } 3867a32b0c8SAndre Fischer 3877a32b0c8SAndre Fischer case ViewShell::ST_HANDOUT: 3887a32b0c8SAndre Fischer case ViewShell::ST_NOTES: 3897a32b0c8SAndre Fischer case ViewShell::ST_SLIDE_SORTER: 3907a32b0c8SAndre Fischer default: 3917a32b0c8SAndre Fischer bIsEnabled = true; 3927a32b0c8SAndre Fischer break; 3937a32b0c8SAndre Fischer } 3947a32b0c8SAndre Fischer } 3957a32b0c8SAndre Fischer } 3967a32b0c8SAndre Fischer 3977a32b0c8SAndre Fischer 3987a32b0c8SAndre Fischer 3997a32b0c8SAndre Fischer 4007a32b0c8SAndre Fischer void LayoutMenu::Paint (const Rectangle& rRect) 4017a32b0c8SAndre Fischer { 4027a32b0c8SAndre Fischer if (mbSelectionUpdatePending) 4037a32b0c8SAndre Fischer { 4047a32b0c8SAndre Fischer mbSelectionUpdatePending = false; 4057a32b0c8SAndre Fischer UpdateSelection(); 4067a32b0c8SAndre Fischer } 4077a32b0c8SAndre Fischer ValueSet::Paint (rRect); 4087a32b0c8SAndre Fischer } 4097a32b0c8SAndre Fischer 4107a32b0c8SAndre Fischer 4117a32b0c8SAndre Fischer 4127a32b0c8SAndre Fischer 4137a32b0c8SAndre Fischer void LayoutMenu::Resize (void) 4147a32b0c8SAndre Fischer { 4157a32b0c8SAndre Fischer Size aWindowSize = GetOutputSizePixel(); 4167a32b0c8SAndre Fischer if (IsVisible() && aWindowSize.Width() > 0) 4177a32b0c8SAndre Fischer { 4187a32b0c8SAndre Fischer // Calculate the number of rows and columns. 4197a32b0c8SAndre Fischer if (GetItemCount() > 0) 4207a32b0c8SAndre Fischer { 4217a32b0c8SAndre Fischer Image aImage = GetItemImage(GetItemId(0)); 4227a32b0c8SAndre Fischer Size aItemSize = CalcItemSizePixel ( 4237a32b0c8SAndre Fischer aImage.GetSizePixel()); 4247a32b0c8SAndre Fischer aItemSize.Width() += 8; 4257a32b0c8SAndre Fischer aItemSize.Height() += 8; 4267a32b0c8SAndre Fischer int nColumnCount = aWindowSize.Width() / aItemSize.Width(); 4277a32b0c8SAndre Fischer if (nColumnCount < 1) 4287a32b0c8SAndre Fischer nColumnCount = 1; 4297a32b0c8SAndre Fischer else if (nColumnCount > 4) 4307a32b0c8SAndre Fischer nColumnCount = 4; 4317a32b0c8SAndre Fischer 4327a32b0c8SAndre Fischer int nRowCount = CalculateRowCount (aItemSize, nColumnCount); 4337a32b0c8SAndre Fischer 4347a32b0c8SAndre Fischer SetColCount ((sal_uInt16)nColumnCount); 4357a32b0c8SAndre Fischer SetLineCount ((sal_uInt16)nRowCount); 4367a32b0c8SAndre Fischer } 4377a32b0c8SAndre Fischer } 4387a32b0c8SAndre Fischer 4397a32b0c8SAndre Fischer ValueSet::Resize (); 4407a32b0c8SAndre Fischer } 4417a32b0c8SAndre Fischer 4427a32b0c8SAndre Fischer 4437a32b0c8SAndre Fischer 4447a32b0c8SAndre Fischer 4457a32b0c8SAndre Fischer void LayoutMenu::MouseButtonDown (const MouseEvent& rEvent) 4467a32b0c8SAndre Fischer { 4477a32b0c8SAndre Fischer // As a preparation for the context menu the item under the mouse is 4487a32b0c8SAndre Fischer // selected. 4497a32b0c8SAndre Fischer if (rEvent.IsRight()) 4507a32b0c8SAndre Fischer { 4517a32b0c8SAndre Fischer ReleaseMouse(); 4527a32b0c8SAndre Fischer sal_uInt16 nIndex = GetItemId (rEvent.GetPosPixel()); 4537a32b0c8SAndre Fischer if (nIndex > 0) 4547a32b0c8SAndre Fischer SelectItem(nIndex); 4557a32b0c8SAndre Fischer } 4567a32b0c8SAndre Fischer 4577a32b0c8SAndre Fischer ValueSet::MouseButtonDown (rEvent); 4587a32b0c8SAndre Fischer } 4597a32b0c8SAndre Fischer 4607a32b0c8SAndre Fischer 4617a32b0c8SAndre Fischer 4627a32b0c8SAndre Fischer 4637a32b0c8SAndre Fischer void LayoutMenu::InsertPageWithLayout (AutoLayout aLayout) 4647a32b0c8SAndre Fischer { 4657a32b0c8SAndre Fischer ViewShell* pViewShell = mrBase.GetMainViewShell().get(); 4667a32b0c8SAndre Fischer if (pViewShell == NULL) 4677a32b0c8SAndre Fischer return; 4687a32b0c8SAndre Fischer 4697a32b0c8SAndre Fischer SfxViewFrame* pViewFrame = mrBase.GetViewFrame(); 4707a32b0c8SAndre Fischer if (pViewFrame == NULL) 4717a32b0c8SAndre Fischer return; 4727a32b0c8SAndre Fischer 4737a32b0c8SAndre Fischer SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher(); 4747a32b0c8SAndre Fischer if (pDispatcher == NULL) 4757a32b0c8SAndre Fischer return; 4767a32b0c8SAndre Fischer 4777a32b0c8SAndre Fischer // Call SID_INSERTPAGE with the right arguments. This is because 4787a32b0c8SAndre Fischer // the popup menu can not call this slot with arguments directly. 4797a32b0c8SAndre Fischer SfxRequest aRequest (CreateRequest(SID_INSERTPAGE, aLayout)); 4807a32b0c8SAndre Fischer if (aRequest.GetArgs() != NULL) 4817a32b0c8SAndre Fischer { 4827a32b0c8SAndre Fischer pDispatcher->Execute( 4837a32b0c8SAndre Fischer SID_INSERTPAGE, 4847a32b0c8SAndre Fischer SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, 4857a32b0c8SAndre Fischer *aRequest.GetArgs()); 4867a32b0c8SAndre Fischer } 4877a32b0c8SAndre Fischer UpdateSelection(); 4887a32b0c8SAndre Fischer } 4897a32b0c8SAndre Fischer 4907a32b0c8SAndre Fischer 4917a32b0c8SAndre Fischer 4927a32b0c8SAndre Fischer 4937a32b0c8SAndre Fischer void LayoutMenu::InvalidateContent (void) 4947a32b0c8SAndre Fischer { 4957a32b0c8SAndre Fischer // Throw away the current set and fill the menu anew according to the 4967a32b0c8SAndre Fischer // current settings (this includes the support for vertical writing.) 4977a32b0c8SAndre Fischer Fill(); 49802c50d82SAndre Fischer 49902c50d82SAndre Fischer if (mxSidebar.is()) 50002c50d82SAndre Fischer mxSidebar->requestLayout(); 5017a32b0c8SAndre Fischer } 5027a32b0c8SAndre Fischer 5037a32b0c8SAndre Fischer 5047a32b0c8SAndre Fischer 5057a32b0c8SAndre Fischer 5067a32b0c8SAndre Fischer int LayoutMenu::CalculateRowCount (const Size&, int nColumnCount) 5077a32b0c8SAndre Fischer { 5087a32b0c8SAndre Fischer int nRowCount = 0; 5097a32b0c8SAndre Fischer 5107a32b0c8SAndre Fischer if (GetItemCount() > 0 && nColumnCount > 0) 5117a32b0c8SAndre Fischer { 5127a32b0c8SAndre Fischer nRowCount = (GetItemCount() + nColumnCount - 1) / nColumnCount; 5137a32b0c8SAndre Fischer // nRowCount = GetOutputSizePixel().Height() / rItemSize.Height(); 5147a32b0c8SAndre Fischer if (nRowCount < 1) 5157a32b0c8SAndre Fischer nRowCount = 1; 5167a32b0c8SAndre Fischer } 5177a32b0c8SAndre Fischer 5187a32b0c8SAndre Fischer return nRowCount; 5197a32b0c8SAndre Fischer } 5207a32b0c8SAndre Fischer 5217a32b0c8SAndre Fischer 5227a32b0c8SAndre Fischer 5237a32b0c8SAndre Fischer 5247a32b0c8SAndre Fischer IMPL_LINK(LayoutMenu, ClickHandler, ValueSet*, EMPTYARG) 5257a32b0c8SAndre Fischer { 5267a32b0c8SAndre Fischer AssignLayoutToSelectedSlides (GetSelectedAutoLayout()); 5277a32b0c8SAndre Fischer return 0; 5287a32b0c8SAndre Fischer } 5297a32b0c8SAndre Fischer 5307a32b0c8SAndre Fischer 5317a32b0c8SAndre Fischer 5327a32b0c8SAndre Fischer 5337a32b0c8SAndre Fischer /** The specified layout is assigned to the current page of the view shell 5347a32b0c8SAndre Fischer in the center pane. 5357a32b0c8SAndre Fischer */ 5367a32b0c8SAndre Fischer void LayoutMenu::AssignLayoutToSelectedSlides (AutoLayout aLayout) 5377a32b0c8SAndre Fischer { 5387a32b0c8SAndre Fischer using namespace ::sd::slidesorter; 5397a32b0c8SAndre Fischer using namespace ::sd::slidesorter::controller; 5407a32b0c8SAndre Fischer 5417a32b0c8SAndre Fischer do 5427a32b0c8SAndre Fischer { 5437a32b0c8SAndre Fischer // The view shell in the center pane has to be present. 5447a32b0c8SAndre Fischer ViewShell* pMainViewShell = mrBase.GetMainViewShell().get(); 5457a32b0c8SAndre Fischer if (pMainViewShell == NULL) 5467a32b0c8SAndre Fischer break; 5477a32b0c8SAndre Fischer 5487a32b0c8SAndre Fischer // Determine if the current view is in an invalid master page mode. 5497a32b0c8SAndre Fischer // The handout view is always in master page mode and therefore not 5507a32b0c8SAndre Fischer // invalid. 5517a32b0c8SAndre Fischer bool bMasterPageMode (false); 5527a32b0c8SAndre Fischer switch (pMainViewShell->GetShellType()) 5537a32b0c8SAndre Fischer { 5547a32b0c8SAndre Fischer case ViewShell::ST_NOTES: 5557a32b0c8SAndre Fischer case ViewShell::ST_IMPRESS: 5567a32b0c8SAndre Fischer { 5577a32b0c8SAndre Fischer DrawViewShell* pDrawViewShell = static_cast<DrawViewShell*>(pMainViewShell); 5587a32b0c8SAndre Fischer if (pDrawViewShell != NULL) 5597a32b0c8SAndre Fischer if (pDrawViewShell->GetEditMode() == EM_MASTERPAGE) 5607a32b0c8SAndre Fischer bMasterPageMode = true; 5617a32b0c8SAndre Fischer } 5627a32b0c8SAndre Fischer default: 5637a32b0c8SAndre Fischer break; 5647a32b0c8SAndre Fischer } 5657a32b0c8SAndre Fischer if (bMasterPageMode) 5667a32b0c8SAndre Fischer break; 5677a32b0c8SAndre Fischer 5687a32b0c8SAndre Fischer // Get a list of all selected slides and call the SID_MODIFYPAGE 5697a32b0c8SAndre Fischer // slot for all of them. 5707a32b0c8SAndre Fischer ::sd::slidesorter::SharedPageSelection pPageSelection; 5717a32b0c8SAndre Fischer 5727a32b0c8SAndre Fischer // Get a list of selected pages. 5737a32b0c8SAndre Fischer // First we try to obtain this list from a slide sorter. This is 5747a32b0c8SAndre Fischer // possible only some of the view shells in the center pane. When 5757a32b0c8SAndre Fischer // no valid slide sorter is available then ask the main view shell 5767a32b0c8SAndre Fischer // for its current page. 5777a32b0c8SAndre Fischer SlideSorterViewShell* pSlideSorter = NULL; 5787a32b0c8SAndre Fischer switch (pMainViewShell->GetShellType()) 5797a32b0c8SAndre Fischer { 5807a32b0c8SAndre Fischer case ViewShell::ST_IMPRESS: 5817a32b0c8SAndre Fischer case ViewShell::ST_NOTES: 5827a32b0c8SAndre Fischer case ViewShell::ST_SLIDE_SORTER: 5837a32b0c8SAndre Fischer pSlideSorter = SlideSorterViewShell::GetSlideSorter(mrBase); 5847a32b0c8SAndre Fischer break; 5857a32b0c8SAndre Fischer default: 5867a32b0c8SAndre Fischer break; 5877a32b0c8SAndre Fischer } 5887a32b0c8SAndre Fischer if (pSlideSorter != NULL) 5897a32b0c8SAndre Fischer { 5907a32b0c8SAndre Fischer // There is a slide sorter visible so get the list of selected pages from it. 5917a32b0c8SAndre Fischer pPageSelection = pSlideSorter->GetPageSelection(); 5927a32b0c8SAndre Fischer } 5937a32b0c8SAndre Fischer 5947a32b0c8SAndre Fischer if( (pSlideSorter == NULL) || (pPageSelection.get() == 0) || pPageSelection->empty() ) 5957a32b0c8SAndre Fischer { 5967a32b0c8SAndre Fischer // No valid slide sorter available. Ask the main view shell for 5977a32b0c8SAndre Fischer // its current page. 5987a32b0c8SAndre Fischer pPageSelection.reset(new ::sd::slidesorter::SlideSorterViewShell::PageSelection()); 5997a32b0c8SAndre Fischer pPageSelection->push_back(pMainViewShell->GetActualPage()); 6007a32b0c8SAndre Fischer } 6017a32b0c8SAndre Fischer 6027a32b0c8SAndre Fischer 6037a32b0c8SAndre Fischer if (pPageSelection->empty()) 6047a32b0c8SAndre Fischer break; 6057a32b0c8SAndre Fischer 6067a32b0c8SAndre Fischer ::std::vector<SdPage*>::iterator iPage; 6077a32b0c8SAndre Fischer for (iPage=pPageSelection->begin(); iPage!=pPageSelection->end(); ++iPage) 6087a32b0c8SAndre Fischer { 6097a32b0c8SAndre Fischer if ((*iPage) == NULL) 6107a32b0c8SAndre Fischer continue; 6117a32b0c8SAndre Fischer 6127a32b0c8SAndre Fischer // Call the SID_ASSIGN_LAYOUT slot with all the necessary parameters. 6137a32b0c8SAndre Fischer SfxRequest aRequest (mrBase.GetViewFrame(), SID_ASSIGN_LAYOUT); 6147a32b0c8SAndre Fischer aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATPAGE, ((*iPage)->GetPageNum()-1)/2)); 6157a32b0c8SAndre Fischer aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, aLayout)); 6167a32b0c8SAndre Fischer pMainViewShell->ExecuteSlot (aRequest, sal_Bool(sal_False)); 6177a32b0c8SAndre Fischer } 6187a32b0c8SAndre Fischer } 6197a32b0c8SAndre Fischer while(false); 6207a32b0c8SAndre Fischer } 6217a32b0c8SAndre Fischer 6227a32b0c8SAndre Fischer 6237a32b0c8SAndre Fischer 6247a32b0c8SAndre Fischer 6257a32b0c8SAndre Fischer SfxRequest LayoutMenu::CreateRequest ( 6267a32b0c8SAndre Fischer sal_uInt16 nSlotId, 6277a32b0c8SAndre Fischer AutoLayout aLayout) 6287a32b0c8SAndre Fischer { 6297a32b0c8SAndre Fischer SfxRequest aRequest (mrBase.GetViewFrame(), nSlotId); 6307a32b0c8SAndre Fischer 6317a32b0c8SAndre Fischer do 6327a32b0c8SAndre Fischer { 6337a32b0c8SAndre Fischer SdrLayerAdmin& rLayerAdmin (mrBase.GetDocument()->GetLayerAdmin()); 6347a32b0c8SAndre Fischer sal_uInt8 aBackground (rLayerAdmin.GetLayerID( 6357a32b0c8SAndre Fischer String(SdResId(STR_LAYER_BCKGRND)), sal_False)); 6367a32b0c8SAndre Fischer sal_uInt8 aBackgroundObject (rLayerAdmin.GetLayerID( 6377a32b0c8SAndre Fischer String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False)); 6387a32b0c8SAndre Fischer ViewShell* pViewShell = mrBase.GetMainViewShell().get(); 6397a32b0c8SAndre Fischer if (pViewShell == NULL) 6407a32b0c8SAndre Fischer break; 6417a32b0c8SAndre Fischer SdPage* pPage = pViewShell->GetActualPage(); 6427a32b0c8SAndre Fischer if (pPage == NULL) 6437a32b0c8SAndre Fischer break; 6447a32b0c8SAndre Fischer 6457a32b0c8SAndre Fischer SetOfByte aVisibleLayers (pPage->TRG_GetMasterPageVisibleLayers()); 6467a32b0c8SAndre Fischer 6477a32b0c8SAndre Fischer aRequest.AppendItem( 6487a32b0c8SAndre Fischer SfxStringItem (ID_VAL_PAGENAME, String()));//pPage->GetName())); 6497a32b0c8SAndre Fischer aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, aLayout)); 6507a32b0c8SAndre Fischer aRequest.AppendItem( 6517a32b0c8SAndre Fischer SfxBoolItem(ID_VAL_ISPAGEBACK, aVisibleLayers.IsSet(aBackground))); 6527a32b0c8SAndre Fischer aRequest.AppendItem( 6537a32b0c8SAndre Fischer SfxBoolItem( 6547a32b0c8SAndre Fischer ID_VAL_ISPAGEOBJ, 6557a32b0c8SAndre Fischer aVisibleLayers.IsSet(aBackgroundObject))); 6567a32b0c8SAndre Fischer } 6577a32b0c8SAndre Fischer while (false); 6587a32b0c8SAndre Fischer 6597a32b0c8SAndre Fischer return aRequest; 6607a32b0c8SAndre Fischer } 6617a32b0c8SAndre Fischer 6627a32b0c8SAndre Fischer 6637a32b0c8SAndre Fischer 6647a32b0c8SAndre Fischer 6657a32b0c8SAndre Fischer void LayoutMenu::Fill (void) 6667a32b0c8SAndre Fischer { 6677a32b0c8SAndre Fischer const bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode(); 6687a32b0c8SAndre Fischer SvtLanguageOptions aLanguageOptions; 6697a32b0c8SAndre Fischer sal_Bool bVertical = aLanguageOptions.IsVerticalTextEnabled(); 6707a32b0c8SAndre Fischer SdDrawDocument* pDocument = mrBase.GetDocument(); 6717a32b0c8SAndre Fischer sal_Bool bRightToLeft = (pDocument!=NULL 6727a32b0c8SAndre Fischer && pDocument->GetDefaultWritingMode() == WritingMode_RL_TB); 6737a32b0c8SAndre Fischer 6747a32b0c8SAndre Fischer // Get URL of the view in the center pane. 6757a32b0c8SAndre Fischer ::rtl::OUString sCenterPaneViewName; 6767a32b0c8SAndre Fischer try 6777a32b0c8SAndre Fischer { 6787a32b0c8SAndre Fischer Reference<XControllerManager> xControllerManager ( 6797a32b0c8SAndre Fischer Reference<XWeak>(&mrBase.GetDrawController()), UNO_QUERY_THROW); 6807a32b0c8SAndre Fischer Reference<XResourceId> xPaneId (ResourceId::create( 6817a32b0c8SAndre Fischer ::comphelper::getProcessComponentContext(), 6827a32b0c8SAndre Fischer FrameworkHelper::msCenterPaneURL)); 6837a32b0c8SAndre Fischer Reference<XView> xView (FrameworkHelper::Instance(mrBase)->GetView(xPaneId)); 6847a32b0c8SAndre Fischer if (xView.is()) 6857a32b0c8SAndre Fischer sCenterPaneViewName = xView->getResourceId()->getResourceURL(); 6867a32b0c8SAndre Fischer } 6877a32b0c8SAndre Fischer catch (RuntimeException&) 6887a32b0c8SAndre Fischer {} 6897a32b0c8SAndre Fischer 6907a32b0c8SAndre Fischer snewfoil_value_info* pInfo = NULL; 6917a32b0c8SAndre Fischer if (sCenterPaneViewName.equals(framework::FrameworkHelper::msNotesViewURL)) 6927a32b0c8SAndre Fischer { 6937a32b0c8SAndre Fischer pInfo = notes; 6947a32b0c8SAndre Fischer } 6957a32b0c8SAndre Fischer else if (sCenterPaneViewName.equals(framework::FrameworkHelper::msHandoutViewURL)) 6967a32b0c8SAndre Fischer { 6977a32b0c8SAndre Fischer pInfo = handout; 6987a32b0c8SAndre Fischer } 6997a32b0c8SAndre Fischer else if (sCenterPaneViewName.equals(framework::FrameworkHelper::msImpressViewURL) 7007a32b0c8SAndre Fischer || sCenterPaneViewName.equals(framework::FrameworkHelper::msSlideSorterURL)) 7017a32b0c8SAndre Fischer { 7027a32b0c8SAndre Fischer pInfo = standard; 7037a32b0c8SAndre Fischer } 7047a32b0c8SAndre Fischer else 7057a32b0c8SAndre Fischer { 7067a32b0c8SAndre Fischer pInfo = NULL; 7077a32b0c8SAndre Fischer } 7087a32b0c8SAndre Fischer 7097a32b0c8SAndre Fischer Clear(); 7107a32b0c8SAndre Fischer int n = 0; 7117a32b0c8SAndre Fischer for (sal_uInt16 i=1; pInfo!=NULL&&pInfo->mnBmpResId!=0; i++,pInfo++) 7127a32b0c8SAndre Fischer { 7137a32b0c8SAndre Fischer if ((WritingMode_TB_RL != pInfo->meWritingMode) || bVertical) 7147a32b0c8SAndre Fischer { 7157a32b0c8SAndre Fischer BitmapEx aBmp (SdResId (bHighContrast 7167a32b0c8SAndre Fischer ? pInfo->mnHCBmpResId 7177a32b0c8SAndre Fischer : pInfo->mnBmpResId)); 7187a32b0c8SAndre Fischer 7197a32b0c8SAndre Fischer if (bRightToLeft && (WritingMode_TB_RL != pInfo->meWritingMode)) 7207a32b0c8SAndre Fischer aBmp.Mirror (BMP_MIRROR_HORZ); 7217a32b0c8SAndre Fischer 7227a32b0c8SAndre Fischer InsertItem (i, aBmp, String (SdResId (pInfo->mnStrResId))); 7237a32b0c8SAndre Fischer SetItemData (i, new AutoLayout(pInfo->maAutoLayout)); 7247a32b0c8SAndre Fischer n++; 7257a32b0c8SAndre Fischer } 7267a32b0c8SAndre Fischer } 7277a32b0c8SAndre Fischer 7287a32b0c8SAndre Fischer mbSelectionUpdatePending = true; 7297a32b0c8SAndre Fischer } 7307a32b0c8SAndre Fischer 7317a32b0c8SAndre Fischer 7327a32b0c8SAndre Fischer 7337a32b0c8SAndre Fischer 7347a32b0c8SAndre Fischer void LayoutMenu::Clear (void) 7357a32b0c8SAndre Fischer { 7367a32b0c8SAndre Fischer for (sal_uInt16 nId=1; nId<=GetItemCount(); nId++) 7377a32b0c8SAndre Fischer delete static_cast<AutoLayout*>(GetItemData(nId)); 7387a32b0c8SAndre Fischer ValueSet::Clear(); 7397a32b0c8SAndre Fischer } 7407a32b0c8SAndre Fischer 7417a32b0c8SAndre Fischer 7427a32b0c8SAndre Fischer 7437a32b0c8SAndre Fischer void LayoutMenu::StartDrag (sal_Int8 , const Point& ) 7447a32b0c8SAndre Fischer { 7457a32b0c8SAndre Fischer } 7467a32b0c8SAndre Fischer 7477a32b0c8SAndre Fischer 7487a32b0c8SAndre Fischer 7497a32b0c8SAndre Fischer 7507a32b0c8SAndre Fischer sal_Int8 LayoutMenu::AcceptDrop (const AcceptDropEvent& ) 7517a32b0c8SAndre Fischer { 7527a32b0c8SAndre Fischer return 0; 7537a32b0c8SAndre Fischer } 7547a32b0c8SAndre Fischer 7557a32b0c8SAndre Fischer 7567a32b0c8SAndre Fischer 7577a32b0c8SAndre Fischer 7587a32b0c8SAndre Fischer sal_Int8 LayoutMenu::ExecuteDrop (const ExecuteDropEvent& ) 7597a32b0c8SAndre Fischer { 7607a32b0c8SAndre Fischer return 0; 7617a32b0c8SAndre Fischer } 7627a32b0c8SAndre Fischer 7637a32b0c8SAndre Fischer 7647a32b0c8SAndre Fischer 7657a32b0c8SAndre Fischer 7667a32b0c8SAndre Fischer void LayoutMenu::Command (const CommandEvent& rEvent) 7677a32b0c8SAndre Fischer { 7687a32b0c8SAndre Fischer switch (rEvent.GetCommand()) 7697a32b0c8SAndre Fischer { 7707a32b0c8SAndre Fischer case COMMAND_CONTEXTMENU: 7717a32b0c8SAndre Fischer if ( ! SD_MOD()->GetWaterCan()) 7727a32b0c8SAndre Fischer { 77302c50d82SAndre Fischer // Determine the position where to show the menu. 77402c50d82SAndre Fischer Point aMenuPosition; 7757a32b0c8SAndre Fischer if (rEvent.IsMouseEvent()) 7767a32b0c8SAndre Fischer { 77702c50d82SAndre Fischer if (GetItemId(rEvent.GetMousePosPixel()) <= 0) 77802c50d82SAndre Fischer return; 77902c50d82SAndre Fischer aMenuPosition = rEvent.GetMousePosPixel(); 7807a32b0c8SAndre Fischer } 7817a32b0c8SAndre Fischer else 7827a32b0c8SAndre Fischer { 78302c50d82SAndre Fischer if (GetSelectItemId() == (sal_uInt16)-1) 78402c50d82SAndre Fischer return; 78502c50d82SAndre Fischer Rectangle aBBox (GetItemRect(GetSelectItemId())); 78602c50d82SAndre Fischer aMenuPosition = aBBox.Center(); 7877a32b0c8SAndre Fischer } 78802c50d82SAndre Fischer 78902c50d82SAndre Fischer // Setup the menu. 79002c50d82SAndre Fischer ::boost::shared_ptr<PopupMenu> pMenu (new PopupMenu(SdResId(RID_TASKPANE_LAYOUTMENU_POPUP))); 79102c50d82SAndre Fischer FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow()); 79202c50d82SAndre Fischer if (pMenuWindow != NULL) 79302c50d82SAndre Fischer pMenuWindow->SetPopupModeFlags( 79402c50d82SAndre Fischer pMenuWindow->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE); 79502c50d82SAndre Fischer pMenu->SetSelectHdl(LINK(this, LayoutMenu, OnMenuItemSelected)); 79602c50d82SAndre Fischer 79702c50d82SAndre Fischer // Disable the SID_INSERTPAGE_LAYOUT_MENU item when 79802c50d82SAndre Fischer // the document is read-only. 79902c50d82SAndre Fischer const SfxPoolItem* pItem = NULL; 80002c50d82SAndre Fischer const SfxItemState aState ( 80102c50d82SAndre Fischer mrBase.GetViewFrame()->GetDispatcher()->QueryState(SID_INSERTPAGE, pItem)); 80202c50d82SAndre Fischer if (aState == SFX_ITEM_DISABLED) 80302c50d82SAndre Fischer pMenu->EnableItem(SID_INSERTPAGE_LAYOUT_MENU, sal_False); 80402c50d82SAndre Fischer 80502c50d82SAndre Fischer // Show the menu. 80602c50d82SAndre Fischer pMenu->Execute(this, Rectangle(aMenuPosition,Size(1,1)), POPUPMENU_EXECUTE_DOWN); 8077a32b0c8SAndre Fischer } 8087a32b0c8SAndre Fischer break; 8097a32b0c8SAndre Fischer 8107a32b0c8SAndre Fischer default: 8117a32b0c8SAndre Fischer ValueSet::Command(rEvent); 8127a32b0c8SAndre Fischer break; 8137a32b0c8SAndre Fischer } 8147a32b0c8SAndre Fischer } 8157a32b0c8SAndre Fischer 8167a32b0c8SAndre Fischer 8177a32b0c8SAndre Fischer 8187a32b0c8SAndre Fischer 8197a32b0c8SAndre Fischer IMPL_LINK(LayoutMenu, StateChangeHandler, ::rtl::OUString*, EMPTYARG) 8207a32b0c8SAndre Fischer { 8217a32b0c8SAndre Fischer InvalidateContent(); 8227a32b0c8SAndre Fischer return 0; 8237a32b0c8SAndre Fischer } 8247a32b0c8SAndre Fischer 8257a32b0c8SAndre Fischer 8267a32b0c8SAndre Fischer 8277a32b0c8SAndre Fischer 82802c50d82SAndre Fischer IMPL_LINK(LayoutMenu, OnMenuItemSelected, Menu*, pMenu) 82902c50d82SAndre Fischer { 83002c50d82SAndre Fischer if (pMenu == NULL) 83102c50d82SAndre Fischer { 83202c50d82SAndre Fischer OSL_ENSURE(pMenu!=NULL, "LayoutMenu::OnMenuItemSelected: illegal menu!"); 83302c50d82SAndre Fischer return 0; 83402c50d82SAndre Fischer } 83502c50d82SAndre Fischer 83602c50d82SAndre Fischer pMenu->Deactivate(); 83702c50d82SAndre Fischer const sal_Int32 nIndex (pMenu->GetCurItemId()); 83802c50d82SAndre Fischer 83902c50d82SAndre Fischer if (nIndex == SID_TP_APPLY_TO_SELECTED_SLIDES) 84002c50d82SAndre Fischer { 84102c50d82SAndre Fischer AssignLayoutToSelectedSlides(GetSelectedAutoLayout()); 84202c50d82SAndre Fischer } 84302c50d82SAndre Fischer else if (nIndex == SID_INSERTPAGE_LAYOUT_MENU) 84402c50d82SAndre Fischer { 84502c50d82SAndre Fischer // Add arguments to this slot and forward it to the main view 84602c50d82SAndre Fischer // shell. 84702c50d82SAndre Fischer InsertPageWithLayout(GetSelectedAutoLayout()); 84802c50d82SAndre Fischer } 84902c50d82SAndre Fischer 85002c50d82SAndre Fischer return 0; 85102c50d82SAndre Fischer } 85202c50d82SAndre Fischer 85302c50d82SAndre Fischer 85402c50d82SAndre Fischer 85502c50d82SAndre Fischer 8567a32b0c8SAndre Fischer void LayoutMenu::UpdateSelection (void) 8577a32b0c8SAndre Fischer { 8587a32b0c8SAndre Fischer bool bItemSelected = false; 8597a32b0c8SAndre Fischer 8607a32b0c8SAndre Fischer do 8617a32b0c8SAndre Fischer { 8627a32b0c8SAndre Fischer // Get current page of main view. 8637a32b0c8SAndre Fischer ViewShell* pViewShell = mrBase.GetMainViewShell().get(); 8647a32b0c8SAndre Fischer if (pViewShell == NULL) 8657a32b0c8SAndre Fischer break; 8667a32b0c8SAndre Fischer 8677a32b0c8SAndre Fischer SdPage* pCurrentPage = pViewShell->getCurrentPage(); 8687a32b0c8SAndre Fischer if (pCurrentPage == NULL) 8697a32b0c8SAndre Fischer break; 8707a32b0c8SAndre Fischer 8717a32b0c8SAndre Fischer // Get layout of current page. 8727a32b0c8SAndre Fischer AutoLayout aLayout (pCurrentPage->GetAutoLayout()); 8737a32b0c8SAndre Fischer if (aLayout<AUTOLAYOUT__START || aLayout>AUTOLAYOUT__END) 8747a32b0c8SAndre Fischer break; 8757a32b0c8SAndre Fischer 8767a32b0c8SAndre Fischer // Find the entry of the menu for to the layout. 8777a32b0c8SAndre Fischer sal_uInt16 nItemCount (GetItemCount()); 8787a32b0c8SAndre Fischer for (sal_uInt16 nId=1; nId<=nItemCount; nId++) 8797a32b0c8SAndre Fischer { 8807a32b0c8SAndre Fischer if (*static_cast<AutoLayout*>(GetItemData(nId)) == aLayout) 8817a32b0c8SAndre Fischer { 8827a32b0c8SAndre Fischer SelectItem(nId); 8837a32b0c8SAndre Fischer bItemSelected = true; 8847a32b0c8SAndre Fischer break; 8857a32b0c8SAndre Fischer } 8867a32b0c8SAndre Fischer } 8877a32b0c8SAndre Fischer } 8887a32b0c8SAndre Fischer while (false); 8897a32b0c8SAndre Fischer 8907a32b0c8SAndre Fischer if ( ! bItemSelected) 8917a32b0c8SAndre Fischer SetNoSelection(); 8927a32b0c8SAndre Fischer } 8937a32b0c8SAndre Fischer 8947a32b0c8SAndre Fischer 8957a32b0c8SAndre Fischer 8967a32b0c8SAndre Fischer 8977a32b0c8SAndre Fischer IMPL_LINK(LayoutMenu, EventMultiplexerListener, ::sd::tools::EventMultiplexerEvent*, pEvent) 8987a32b0c8SAndre Fischer { 8997a32b0c8SAndre Fischer switch (pEvent->meEventId) 9007a32b0c8SAndre Fischer { 9017a32b0c8SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_CURRENT_PAGE: 9027a32b0c8SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_SLIDE_SORTER_SELECTION: 9037a32b0c8SAndre Fischer if ( ! mbSelectionUpdatePending) 9047a32b0c8SAndre Fischer UpdateSelection(); 9057a32b0c8SAndre Fischer break; 9067a32b0c8SAndre Fischer 9077a32b0c8SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED: 9087a32b0c8SAndre Fischer mbIsMainViewChangePending = true; 9097a32b0c8SAndre Fischer UpdateEnabledState(MM_UNKNOWN); 9107a32b0c8SAndre Fischer break; 9117a32b0c8SAndre Fischer 9127a32b0c8SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED: 9137a32b0c8SAndre Fischer HideFocus(); 9147a32b0c8SAndre Fischer break; 9157a32b0c8SAndre Fischer 9167a32b0c8SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED: 9177a32b0c8SAndre Fischer if (mbIsMainViewChangePending) 9187a32b0c8SAndre Fischer { 9197a32b0c8SAndre Fischer mbIsMainViewChangePending = false; 9207a32b0c8SAndre Fischer InvalidateContent(); 9217a32b0c8SAndre Fischer } 9227a32b0c8SAndre Fischer break; 9237a32b0c8SAndre Fischer 9247a32b0c8SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_NORMAL: 9257a32b0c8SAndre Fischer UpdateEnabledState(MM_NORMAL); 9267a32b0c8SAndre Fischer break; 9277a32b0c8SAndre Fischer 9287a32b0c8SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_MASTER: 9297a32b0c8SAndre Fischer UpdateEnabledState(MM_MASTER); 9307a32b0c8SAndre Fischer break; 9317a32b0c8SAndre Fischer 9327a32b0c8SAndre Fischer default: 9337a32b0c8SAndre Fischer /* Ignored */ 9347a32b0c8SAndre Fischer break; 9357a32b0c8SAndre Fischer } 9367a32b0c8SAndre Fischer 9377a32b0c8SAndre Fischer return 0; 9387a32b0c8SAndre Fischer } 9397a32b0c8SAndre Fischer 9407a32b0c8SAndre Fischer 9417a32b0c8SAndre Fischer 9427a32b0c8SAndre Fischer 9437a32b0c8SAndre Fischer IMPL_LINK(LayoutMenu, WindowEventHandler, VclWindowEvent*, pEvent) 9447a32b0c8SAndre Fischer { 9457a32b0c8SAndre Fischer if (pEvent != NULL) 9467a32b0c8SAndre Fischer { 9477a32b0c8SAndre Fischer switch (pEvent->GetId()) 9487a32b0c8SAndre Fischer { 9497a32b0c8SAndre Fischer case VCLEVENT_WINDOW_SHOW: 9507a32b0c8SAndre Fischer case VCLEVENT_WINDOW_RESIZE: 9517a32b0c8SAndre Fischer SetSizePixel(GetParent()->GetSizePixel()); 9527a32b0c8SAndre Fischer return sal_True; 9537a32b0c8SAndre Fischer 9547a32b0c8SAndre Fischer default: 9557a32b0c8SAndre Fischer return sal_False; 9567a32b0c8SAndre Fischer } 9577a32b0c8SAndre Fischer 9587a32b0c8SAndre Fischer const SfxSimpleHint* pSimpleHint = PTR_CAST(SfxSimpleHint, pEvent); 9597a32b0c8SAndre Fischer if (pSimpleHint != NULL 9607a32b0c8SAndre Fischer && pSimpleHint->GetId() == SFX_HINT_DYING) 9617a32b0c8SAndre Fischer { 9627a32b0c8SAndre Fischer return sal_True; 9637a32b0c8SAndre Fischer } 9647a32b0c8SAndre Fischer } 9657a32b0c8SAndre Fischer 9667a32b0c8SAndre Fischer return sal_False; 9677a32b0c8SAndre Fischer } 9687a32b0c8SAndre Fischer 9697a32b0c8SAndre Fischer 9707a32b0c8SAndre Fischer 9717a32b0c8SAndre Fischer 9727a32b0c8SAndre Fischer void LayoutMenu::DataChanged (const DataChangedEvent& rEvent) 9737a32b0c8SAndre Fischer { 9747a32b0c8SAndre Fischer Fill(); 9757a32b0c8SAndre Fischer ValueSet::DataChanged(rEvent); 976*8dcb2a10SAndre Fischer SetBackground(sfx2::sidebar::Theme::GetWallpaper(sfx2::sidebar::Theme::Paint_PanelBackground)); 977*8dcb2a10SAndre Fischer SetColor(sfx2::sidebar::Theme::GetColor(sfx2::sidebar::Theme::Paint_PanelBackground)); 9787a32b0c8SAndre Fischer } 9797a32b0c8SAndre Fischer 9807a32b0c8SAndre Fischer 9817a32b0c8SAndre Fischer 9827a32b0c8SAndre Fischer 9837a32b0c8SAndre Fischer 9847a32b0c8SAndre Fischer } } // end of namespace ::sd::sidebar 985