102c50d82SAndre Fischer /************************************************************** 202c50d82SAndre Fischer * 302c50d82SAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 402c50d82SAndre Fischer * or more contributor license agreements. See the NOTICE file 502c50d82SAndre Fischer * distributed with this work for additional information 602c50d82SAndre Fischer * regarding copyright ownership. The ASF licenses this file 702c50d82SAndre Fischer * to you under the Apache License, Version 2.0 (the 802c50d82SAndre Fischer * "License"); you may not use this file except in compliance 902c50d82SAndre Fischer * with the License. You may obtain a copy of the License at 1002c50d82SAndre Fischer * 1102c50d82SAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 1202c50d82SAndre Fischer * 1302c50d82SAndre Fischer * Unless required by applicable law or agreed to in writing, 1402c50d82SAndre Fischer * software distributed under the License is distributed on an 1502c50d82SAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1602c50d82SAndre Fischer * KIND, either express or implied. See the License for the 1702c50d82SAndre Fischer * specific language governing permissions and limitations 1802c50d82SAndre Fischer * under the License. 1902c50d82SAndre Fischer * 2002c50d82SAndre Fischer *************************************************************/ 2102c50d82SAndre Fischer 2202c50d82SAndre Fischer #include "precompiled_sd.hxx" 2302c50d82SAndre Fischer 2402c50d82SAndre Fischer #include "LayoutMenu.hxx" 2502c50d82SAndre Fischer 2602c50d82SAndre Fischer #include "SidebarShellManager.hxx" 2702c50d82SAndre Fischer #include "app.hrc" 2802c50d82SAndre Fischer #include "drawdoc.hxx" 2902c50d82SAndre Fischer #include "framework/FrameworkHelper.hxx" 3002c50d82SAndre Fischer #include "glob.hrc" 3102c50d82SAndre Fischer #include "glob.hxx" 3202c50d82SAndre Fischer #include "helpids.h" 3302c50d82SAndre Fischer #include "pres.hxx" 3402c50d82SAndre Fischer #include "res_bmp.hrc" 3502c50d82SAndre Fischer #include "sdpage.hxx" 3602c50d82SAndre Fischer #include "sdresid.hxx" 3702c50d82SAndre Fischer #include "strings.hrc" 3802c50d82SAndre Fischer #include "tools/SlotStateListener.hxx" 3902c50d82SAndre Fischer #include "DrawController.hxx" 4002c50d82SAndre Fischer #include "DrawDocShell.hxx" 4102c50d82SAndre Fischer #include "DrawViewShell.hxx" 4202c50d82SAndre Fischer #include "EventMultiplexer.hxx" 4302c50d82SAndre Fischer #include "SlideSorterViewShell.hxx" 4402c50d82SAndre Fischer #include "ViewShellBase.hxx" 458dcb2a10SAndre Fischer #include <sfx2/sidebar/Theme.hxx> 4602c50d82SAndre Fischer 4702c50d82SAndre Fischer #include <comphelper/processfactory.hxx> 4802c50d82SAndre Fischer #include <sfx2/app.hxx> 4902c50d82SAndre Fischer #include <sfx2/dispatch.hxx> 5002c50d82SAndre Fischer #include <sfx2/objface.hxx> 5102c50d82SAndre Fischer #include <sfx2/request.hxx> 5202c50d82SAndre Fischer #include <sfx2/viewfrm.hxx> 5302c50d82SAndre Fischer #include <svl/languageoptions.hxx> 5402c50d82SAndre Fischer #include <vcl/image.hxx> 5502c50d82SAndre Fischer #include <vcl/floatwin.hxx> 5602c50d82SAndre Fischer 5702c50d82SAndre Fischer #include <com/sun/star/frame/XController.hpp> 5802c50d82SAndre Fischer #include <com/sun/star/drawing/framework/XControllerManager.hpp> 5902c50d82SAndre Fischer #include <com/sun/star/drawing/framework/XView.hpp> 6002c50d82SAndre Fischer #include <com/sun/star/drawing/framework/ResourceId.hpp> 6102c50d82SAndre Fischer 6202c50d82SAndre Fischer #include <vector> 6302c50d82SAndre Fischer #include <memory> 6402c50d82SAndre Fischer 6502c50d82SAndre Fischer using namespace ::com::sun::star; 6602c50d82SAndre Fischer using namespace ::com::sun::star::text; 6702c50d82SAndre Fischer using namespace ::com::sun::star::uno; 6802c50d82SAndre Fischer using namespace ::com::sun::star::drawing::framework; 6902c50d82SAndre Fischer using namespace ::sd::slidesorter; 7002c50d82SAndre Fischer using ::sd::framework::FrameworkHelper; 7102c50d82SAndre Fischer 7202c50d82SAndre Fischer namespace sd { namespace sidebar { 7302c50d82SAndre Fischer 7402c50d82SAndre Fischer 7502c50d82SAndre Fischer 7602c50d82SAndre Fischer struct snewfoil_value_info 7702c50d82SAndre Fischer { 7802c50d82SAndre Fischer sal_uInt16 mnBmpResId; 7902c50d82SAndre Fischer sal_uInt16 mnHCBmpResId; 8002c50d82SAndre Fischer sal_uInt16 mnStrResId; 8102c50d82SAndre Fischer WritingMode meWritingMode; 8202c50d82SAndre Fischer AutoLayout maAutoLayout; 8302c50d82SAndre Fischer }; 8402c50d82SAndre Fischer 8502c50d82SAndre Fischer static snewfoil_value_info notes[] = 8602c50d82SAndre Fischer { 8702c50d82SAndre Fischer {BMP_FOILN_01, BMP_FOILN_01_H, STR_AUTOLAYOUT_NOTES, WritingMode_LR_TB, 8802c50d82SAndre Fischer AUTOLAYOUT_NOTES}, 8902c50d82SAndre Fischer {0, 0, 0, WritingMode_LR_TB, AUTOLAYOUT_NONE}, 9002c50d82SAndre Fischer }; 9102c50d82SAndre Fischer 9202c50d82SAndre Fischer static snewfoil_value_info handout[] = 9302c50d82SAndre Fischer { 9402c50d82SAndre Fischer {BMP_FOILH_01, BMP_FOILH_01_H, STR_AUTOLAYOUT_HANDOUT1, WritingMode_LR_TB, 9502c50d82SAndre Fischer AUTOLAYOUT_HANDOUT1}, 9602c50d82SAndre Fischer {BMP_FOILH_02, BMP_FOILH_02_H, STR_AUTOLAYOUT_HANDOUT2, WritingMode_LR_TB, 9702c50d82SAndre Fischer AUTOLAYOUT_HANDOUT2}, 9802c50d82SAndre Fischer {BMP_FOILH_03, BMP_FOILH_03_H, STR_AUTOLAYOUT_HANDOUT3, WritingMode_LR_TB, 9902c50d82SAndre Fischer AUTOLAYOUT_HANDOUT3}, 10002c50d82SAndre Fischer {BMP_FOILH_04, BMP_FOILH_04_H, STR_AUTOLAYOUT_HANDOUT4, WritingMode_LR_TB, 10102c50d82SAndre Fischer AUTOLAYOUT_HANDOUT4}, 10202c50d82SAndre Fischer {BMP_FOILH_06, BMP_FOILH_06_H, STR_AUTOLAYOUT_HANDOUT6, WritingMode_LR_TB, 10302c50d82SAndre Fischer AUTOLAYOUT_HANDOUT6}, 10402c50d82SAndre Fischer {BMP_FOILH_09, BMP_FOILH_09_H, STR_AUTOLAYOUT_HANDOUT9, WritingMode_LR_TB, 10502c50d82SAndre Fischer AUTOLAYOUT_HANDOUT9}, 10602c50d82SAndre Fischer {0, 0, 0, WritingMode_LR_TB, AUTOLAYOUT_NONE}, 10702c50d82SAndre Fischer }; 10802c50d82SAndre Fischer 10902c50d82SAndre Fischer static snewfoil_value_info standard[] = 11002c50d82SAndre Fischer { 11102c50d82SAndre Fischer {BMP_LAYOUT_EMPTY, BMP_LAYOUT_EMPTY_H, STR_AUTOLAYOUT_NONE, WritingMode_LR_TB, AUTOLAYOUT_NONE}, 11202c50d82SAndre Fischer {BMP_LAYOUT_HEAD03, BMP_LAYOUT_HEAD03_H, STR_AUTOLAYOUT_TITLE, WritingMode_LR_TB, AUTOLAYOUT_TITLE}, 11302c50d82SAndre Fischer {BMP_LAYOUT_HEAD02, BMP_LAYOUT_HEAD02_H, STR_AUTOLAYOUT_CONTENT, WritingMode_LR_TB, AUTOLAYOUT_ENUM}, 11402c50d82SAndre Fischer {BMP_LAYOUT_HEAD02A, BMP_LAYOUT_HEAD02A_H, STR_AUTOLAYOUT_2CONTENT, WritingMode_LR_TB, AUTOLAYOUT_2TEXT}, 11502c50d82SAndre Fischer {BMP_LAYOUT_HEAD01, BMP_LAYOUT_HEAD01_H, STR_AUTOLAYOUT_ONLY_TITLE, WritingMode_LR_TB, AUTOLAYOUT_ONLY_TITLE}, 11602c50d82SAndre Fischer {BMP_LAYOUT_TEXTONLY, BMP_LAYOUT_TEXTONLY_H, STR_AUTOLAYOUT_ONLY_TEXT, WritingMode_LR_TB, AUTOLAYOUT_ONLY_TEXT}, 11702c50d82SAndre Fischer {BMP_LAYOUT_HEAD03B, BMP_LAYOUT_HEAD03B_H, STR_AUTOLAYOUT_2CONTENT_CONTENT, WritingMode_LR_TB, AUTOLAYOUT_2OBJTEXT}, 11802c50d82SAndre Fischer {BMP_LAYOUT_HEAD03C, BMP_LAYOUT_HEAD03C_H, STR_AUTOLAYOUT_CONTENT_2CONTENT, WritingMode_LR_TB, AUTOLAYOUT_TEXT2OBJ}, 11902c50d82SAndre Fischer {BMP_LAYOUT_HEAD03A, BMP_LAYOUT_HEAD03A_H, STR_AUTOLAYOUT_2CONTENT_OVER_CONTENT,WritingMode_LR_TB, AUTOLAYOUT_2OBJOVERTEXT}, 12002c50d82SAndre Fischer {BMP_LAYOUT_HEAD02B, BMP_LAYOUT_HEAD02B_H, STR_AUTOLAYOUT_CONTENT_OVER_CONTENT, WritingMode_LR_TB, AUTOLAYOUT_OBJOVERTEXT}, 12102c50d82SAndre Fischer {BMP_LAYOUT_HEAD04, BMP_LAYOUT_HEAD04_H, STR_AUTOLAYOUT_4CONTENT, WritingMode_LR_TB, AUTOLAYOUT_4OBJ}, 12202c50d82SAndre Fischer {BMP_LAYOUT_HEAD06, BMP_LAYOUT_HEAD06_H, STR_AUTOLAYOUT_6CONTENT, WritingMode_LR_TB, AUTOLAYOUT_6CLIPART}, 12302c50d82SAndre Fischer 12402c50d82SAndre Fischer // vertical 12502c50d82SAndre Fischer {BMP_LAYOUT_VERTICAL02, BMP_LAYOUT_VERTICAL02_H, STR_AL_VERT_TITLE_TEXT_CHART, WritingMode_TB_RL,AUTOLAYOUT_VERTICAL_TITLE_TEXT_CHART}, 12602c50d82SAndre Fischer {BMP_LAYOUT_VERTICAL01, BMP_LAYOUT_VERTICAL01_H, STR_AL_VERT_TITLE_VERT_OUTLINE, WritingMode_TB_RL, AUTOLAYOUT_VERTICAL_TITLE_VERTICAL_OUTLINE}, 12702c50d82SAndre Fischer {BMP_LAYOUT_HEAD02, BMP_LAYOUT_HEAD02_H, STR_AL_TITLE_VERT_OUTLINE, WritingMode_TB_RL, AUTOLAYOUT_TITLE_VERTICAL_OUTLINE}, 12802c50d82SAndre Fischer {BMP_LAYOUT_HEAD02A, BMP_LAYOUT_HEAD02A_H, STR_AL_TITLE_VERT_OUTLINE_CLIPART, WritingMode_TB_RL, AUTOLAYOUT_TITLE_VERTICAL_OUTLINE_CLIPART}, 12902c50d82SAndre Fischer {0, 0, 0, WritingMode_LR_TB, AUTOLAYOUT_NONE} 13002c50d82SAndre Fischer }; 13102c50d82SAndre Fischer 13202c50d82SAndre Fischer 13302c50d82SAndre Fischer 13402c50d82SAndre Fischer 13502c50d82SAndre Fischer LayoutMenu::LayoutMenu ( 13602c50d82SAndre Fischer ::Window* pParent, 13702c50d82SAndre Fischer ViewShellBase& rViewShellBase, 13802c50d82SAndre Fischer const cssu::Reference<css::ui::XSidebar>& rxSidebar) 13902c50d82SAndre Fischer : ValueSet (pParent), 14002c50d82SAndre Fischer DragSourceHelper(this), 14102c50d82SAndre Fischer DropTargetHelper(this), 14202c50d82SAndre Fischer mrBase(rViewShellBase), 14302c50d82SAndre Fischer mbUseOwnScrollBar(false), 14402c50d82SAndre Fischer mnPreferredColumnCount(3), 14502c50d82SAndre Fischer mxListener(NULL), 14602c50d82SAndre Fischer mbSelectionUpdatePending(true), 14702c50d82SAndre Fischer mbIsMainViewChangePending(false), 14802c50d82SAndre Fischer mxSidebar(rxSidebar), 14902c50d82SAndre Fischer mbIsDisposed(false) 15002c50d82SAndre Fischer { 15102c50d82SAndre Fischer implConstruct( *mrBase.GetDocument()->GetDocSh() ); 15202c50d82SAndre Fischer OSL_TRACE("created LayoutMenu at %x", this); 15302c50d82SAndre Fischer 1548dcb2a10SAndre Fischer SetStyle(GetStyle() | WB_ITEMBORDER | WB_FLATVALUESET | WB_TABSTOP); 1558dcb2a10SAndre Fischer 1568dcb2a10SAndre Fischer SetBackground(sfx2::sidebar::Theme::GetWallpaper(sfx2::sidebar::Theme::Paint_PanelBackground)); 1578dcb2a10SAndre Fischer SetColor(sfx2::sidebar::Theme::GetColor(sfx2::sidebar::Theme::Paint_PanelBackground)); 1588dcb2a10SAndre Fischer 15902c50d82SAndre Fischer #ifdef DEBUG 16002c50d82SAndre Fischer SetText(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sd:LayoutMenu"))); 16102c50d82SAndre Fischer #endif 16202c50d82SAndre Fischer } 16302c50d82SAndre Fischer 16402c50d82SAndre Fischer 16502c50d82SAndre Fischer 16602c50d82SAndre Fischer 16702c50d82SAndre Fischer void LayoutMenu::implConstruct( DrawDocShell& rDocumentShell ) 16802c50d82SAndre Fischer { 16902c50d82SAndre Fischer OSL_ENSURE( mrBase.GetDocument()->GetDocSh() == &rDocumentShell, 17002c50d82SAndre Fischer "LayoutMenu::implConstruct: hmm?" ); 17102c50d82SAndre Fischer // if this fires, then my assumption that the rDocumentShell parameter to our first ctor is superfluous ... 17202c50d82SAndre Fischer 17302c50d82SAndre Fischer SetStyle ( 17402c50d82SAndre Fischer ( GetStyle() & ~(WB_ITEMBORDER) ) 17502c50d82SAndre Fischer | WB_TABSTOP 1768dcb2a10SAndre Fischer | WB_MENUSTYLEVALUESET 17702c50d82SAndre Fischer | WB_NO_DIRECTSELECT 17802c50d82SAndre Fischer ); 17902c50d82SAndre Fischer if (mbUseOwnScrollBar) 18002c50d82SAndre Fischer SetStyle (GetStyle() | WB_VSCROLL); 18102c50d82SAndre Fischer SetExtraSpacing(2); 18202c50d82SAndre Fischer SetSelectHdl (LINK(this, LayoutMenu, ClickHandler)); 18302c50d82SAndre Fischer InvalidateContent(); 18402c50d82SAndre Fischer 18502c50d82SAndre Fischer Link aEventListenerLink (LINK(this,LayoutMenu,EventMultiplexerListener)); 18602c50d82SAndre Fischer mrBase.GetEventMultiplexer()->AddEventListener(aEventListenerLink, 18702c50d82SAndre Fischer ::sd::tools::EventMultiplexerEvent::EID_CURRENT_PAGE 18802c50d82SAndre Fischer | ::sd::tools::EventMultiplexerEvent::EID_SLIDE_SORTER_SELECTION 18902c50d82SAndre Fischer | ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED 19002c50d82SAndre Fischer | ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED 19102c50d82SAndre Fischer | ::sd::tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED 19202c50d82SAndre Fischer | ::sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_NORMAL 19302c50d82SAndre Fischer | ::sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_MASTER); 19402c50d82SAndre Fischer 19502c50d82SAndre Fischer Window::SetHelpId(HID_SD_TASK_PANE_PREVIEW_LAYOUTS); 19602c50d82SAndre Fischer SetAccessibleName(SdResId(STR_TASKPANEL_LAYOUT_MENU_TITLE)); 19702c50d82SAndre Fischer 19802c50d82SAndre Fischer Link aStateChangeLink (LINK(this,LayoutMenu,StateChangeHandler)); 19902c50d82SAndre Fischer mxListener = new ::sd::tools::SlotStateListener( 20002c50d82SAndre Fischer aStateChangeLink, 20102c50d82SAndre Fischer Reference<frame::XDispatchProvider>(mrBase.GetController()->getFrame(), UNO_QUERY), 20202c50d82SAndre Fischer ::rtl::OUString::createFromAscii(".uno:VerticalTextState")); 20302c50d82SAndre Fischer 20402c50d82SAndre Fischer SetSizePixel(GetParent()->GetSizePixel()); 20502c50d82SAndre Fischer Link aWindowEventHandlerLink (LINK(this,LayoutMenu,WindowEventHandler)); 20602c50d82SAndre Fischer GetParent()->AddEventListener(aWindowEventHandlerLink); 20702c50d82SAndre Fischer } 20802c50d82SAndre Fischer 20902c50d82SAndre Fischer 21002c50d82SAndre Fischer 21102c50d82SAndre Fischer 21202c50d82SAndre Fischer LayoutMenu::~LayoutMenu (void) 21302c50d82SAndre Fischer { 21402c50d82SAndre Fischer OSL_TRACE("destroying LayoutMenu at %x", this); 21502c50d82SAndre Fischer Dispose(); 21602c50d82SAndre Fischer } 21702c50d82SAndre Fischer 21802c50d82SAndre Fischer 21902c50d82SAndre Fischer 22002c50d82SAndre Fischer 22102c50d82SAndre Fischer void LayoutMenu::Dispose (void) 22202c50d82SAndre Fischer { 22302c50d82SAndre Fischer if (mbIsDisposed) 22402c50d82SAndre Fischer return; 22502c50d82SAndre Fischer 22602c50d82SAndre Fischer OSL_TRACE("disposing LayoutMenu at %x", this); 22702c50d82SAndre Fischer 22802c50d82SAndre Fischer mbIsDisposed = true; 22902c50d82SAndre Fischer 23002c50d82SAndre Fischer Reference<lang::XComponent> xComponent (mxListener, UNO_QUERY); 23102c50d82SAndre Fischer if (xComponent.is()) 23202c50d82SAndre Fischer xComponent->dispose(); 23302c50d82SAndre Fischer 23402c50d82SAndre Fischer Clear(); 23502c50d82SAndre Fischer Link aLink (LINK(this,LayoutMenu,EventMultiplexerListener)); 23602c50d82SAndre Fischer mrBase.GetEventMultiplexer()->RemoveEventListener (aLink); 23702c50d82SAndre Fischer 23802c50d82SAndre Fischer Link aWindowEventHandlerLink (LINK(this,LayoutMenu,WindowEventHandler)); 23902c50d82SAndre Fischer GetParent()->RemoveEventListener(aWindowEventHandlerLink); 24002c50d82SAndre Fischer } 24102c50d82SAndre Fischer 24202c50d82SAndre Fischer 24302c50d82SAndre Fischer 24402c50d82SAndre Fischer 24502c50d82SAndre Fischer AutoLayout LayoutMenu::GetSelectedAutoLayout (void) 24602c50d82SAndre Fischer { 24702c50d82SAndre Fischer AutoLayout aResult = AUTOLAYOUT_NONE; 24802c50d82SAndre Fischer 24902c50d82SAndre Fischer if ( ! IsNoSelection() && GetSelectItemId()!=0) 25002c50d82SAndre Fischer { 25102c50d82SAndre Fischer AutoLayout* pLayout = static_cast<AutoLayout*>(GetItemData(GetSelectItemId())); 25202c50d82SAndre Fischer if (pLayout != NULL) 25302c50d82SAndre Fischer aResult = *pLayout; 25402c50d82SAndre Fischer } 25502c50d82SAndre Fischer 25602c50d82SAndre Fischer return aResult; 25702c50d82SAndre Fischer } 25802c50d82SAndre Fischer 25902c50d82SAndre Fischer 26002c50d82SAndre Fischer 26102c50d82SAndre Fischer 26202c50d82SAndre Fischer /** The preferred size depends on the preferred number of columns, the 26302c50d82SAndre Fischer number of items, and the size of the items. 26402c50d82SAndre Fischer */ 26502c50d82SAndre Fischer Size LayoutMenu::GetPreferredSize (void) 26602c50d82SAndre Fischer { 26702c50d82SAndre Fischer Size aItemSize = CalcItemSizePixel (Size()); 26802c50d82SAndre Fischer Size aPreferredWindowSize = CalcWindowSizePixel ( 26902c50d82SAndre Fischer aItemSize, 27002c50d82SAndre Fischer (sal_uInt16)mnPreferredColumnCount, 27102c50d82SAndre Fischer (sal_uInt16)CalculateRowCount (aItemSize,mnPreferredColumnCount)); 27202c50d82SAndre Fischer return aPreferredWindowSize; 27302c50d82SAndre Fischer } 27402c50d82SAndre Fischer 27502c50d82SAndre Fischer 27602c50d82SAndre Fischer 27702c50d82SAndre Fischer 27802c50d82SAndre Fischer sal_Int32 LayoutMenu::GetPreferredWidth (sal_Int32 nHeight) 27902c50d82SAndre Fischer { 28002c50d82SAndre Fischer sal_Int32 nPreferredWidth = 100; 28102c50d82SAndre Fischer if (GetItemCount() > 0) 28202c50d82SAndre Fischer { 28302c50d82SAndre Fischer Image aImage = GetItemImage(GetItemId(0)); 28402c50d82SAndre Fischer Size aItemSize = CalcItemSizePixel (aImage.GetSizePixel()); 28502c50d82SAndre Fischer if (nHeight>0 && aItemSize.Height()>0) 28602c50d82SAndre Fischer { 28702c50d82SAndre Fischer int nRowCount = nHeight / aItemSize.Height(); 28802c50d82SAndre Fischer if (nRowCount <= 0) 28902c50d82SAndre Fischer nRowCount = 1; 29002c50d82SAndre Fischer int nColumnCount = (GetItemCount() + nRowCount-1) / nRowCount; 29102c50d82SAndre Fischer nPreferredWidth = nColumnCount * aItemSize.Width(); 29202c50d82SAndre Fischer } 29302c50d82SAndre Fischer } 29402c50d82SAndre Fischer 29502c50d82SAndre Fischer return nPreferredWidth; 29602c50d82SAndre Fischer } 29702c50d82SAndre Fischer 29802c50d82SAndre Fischer 29902c50d82SAndre Fischer 30002c50d82SAndre Fischer 30102c50d82SAndre Fischer ui::LayoutSize LayoutMenu::GetHeightForWidth (const sal_Int32 nWidth) 30202c50d82SAndre Fischer { 30302c50d82SAndre Fischer sal_Int32 nPreferredHeight = 200; 30402c50d82SAndre Fischer if ( ! mbUseOwnScrollBar && GetItemCount()>0) 30502c50d82SAndre Fischer { 30602c50d82SAndre Fischer Image aImage = GetItemImage(GetItemId(0)); 30702c50d82SAndre Fischer Size aItemSize = CalcItemSizePixel (aImage.GetSizePixel()); 30802c50d82SAndre Fischer if (nWidth>0 && aItemSize.Width()>0) 30902c50d82SAndre Fischer { 31002c50d82SAndre Fischer aItemSize.Width() += 8; 31102c50d82SAndre Fischer aItemSize.Height() += 8; 31202c50d82SAndre Fischer int nColumnCount = nWidth / aItemSize.Width(); 31302c50d82SAndre Fischer if (nColumnCount <= 0) 31402c50d82SAndre Fischer nColumnCount = 1; 31502c50d82SAndre Fischer else if (nColumnCount > 4) 31602c50d82SAndre Fischer nColumnCount = 4; 31702c50d82SAndre Fischer int nRowCount = (GetItemCount() + nColumnCount-1) / nColumnCount; 31802c50d82SAndre Fischer nPreferredHeight = nRowCount * aItemSize.Height(); 31902c50d82SAndre Fischer } 32002c50d82SAndre Fischer } 32102c50d82SAndre Fischer return ui::LayoutSize(nPreferredHeight,nPreferredHeight,nPreferredHeight); 32202c50d82SAndre Fischer } 32302c50d82SAndre Fischer 32402c50d82SAndre Fischer 32502c50d82SAndre Fischer 32602c50d82SAndre Fischer 32702c50d82SAndre Fischer sal_Int32 LayoutMenu::GetMinimumWidth (void) 32802c50d82SAndre Fischer { 32902c50d82SAndre Fischer sal_Int32 nMinimumWidth = 0; 33002c50d82SAndre Fischer if (GetItemCount()>0) 33102c50d82SAndre Fischer { 33202c50d82SAndre Fischer Image aImage = GetItemImage(GetItemId(0)); 33302c50d82SAndre Fischer Size aItemSize = CalcItemSizePixel (aImage.GetSizePixel()); 33402c50d82SAndre Fischer nMinimumWidth = aItemSize.Width(); 33502c50d82SAndre Fischer } 33602c50d82SAndre Fischer return nMinimumWidth; 33702c50d82SAndre Fischer } 33802c50d82SAndre Fischer 33902c50d82SAndre Fischer 34002c50d82SAndre Fischer 34102c50d82SAndre Fischer 34202c50d82SAndre Fischer void LayoutMenu::Paint (const Rectangle& rRect) 34302c50d82SAndre Fischer { 34402c50d82SAndre Fischer if (mbSelectionUpdatePending) 34502c50d82SAndre Fischer { 34602c50d82SAndre Fischer mbSelectionUpdatePending = false; 34702c50d82SAndre Fischer UpdateSelection(); 34802c50d82SAndre Fischer } 34902c50d82SAndre Fischer ValueSet::Paint (rRect); 35002c50d82SAndre Fischer } 35102c50d82SAndre Fischer 35202c50d82SAndre Fischer 35302c50d82SAndre Fischer 35402c50d82SAndre Fischer 35502c50d82SAndre Fischer void LayoutMenu::Resize (void) 35602c50d82SAndre Fischer { 35702c50d82SAndre Fischer Size aWindowSize = GetOutputSizePixel(); 35802c50d82SAndre Fischer if (IsVisible() && aWindowSize.Width() > 0) 35902c50d82SAndre Fischer { 36002c50d82SAndre Fischer // Calculate the number of rows and columns. 36102c50d82SAndre Fischer if (GetItemCount() > 0) 36202c50d82SAndre Fischer { 36302c50d82SAndre Fischer Image aImage = GetItemImage(GetItemId(0)); 36402c50d82SAndre Fischer Size aItemSize = CalcItemSizePixel ( 36502c50d82SAndre Fischer aImage.GetSizePixel()); 36602c50d82SAndre Fischer aItemSize.Width() += 8; 36702c50d82SAndre Fischer aItemSize.Height() += 8; 36802c50d82SAndre Fischer int nColumnCount = aWindowSize.Width() / aItemSize.Width(); 36902c50d82SAndre Fischer if (nColumnCount < 1) 37002c50d82SAndre Fischer nColumnCount = 1; 37102c50d82SAndre Fischer else if (nColumnCount > 4) 37202c50d82SAndre Fischer nColumnCount = 4; 37302c50d82SAndre Fischer 37402c50d82SAndre Fischer int nRowCount = CalculateRowCount (aItemSize, nColumnCount); 37502c50d82SAndre Fischer 37602c50d82SAndre Fischer SetColCount ((sal_uInt16)nColumnCount); 37702c50d82SAndre Fischer SetLineCount ((sal_uInt16)nRowCount); 37802c50d82SAndre Fischer } 37902c50d82SAndre Fischer } 38002c50d82SAndre Fischer 38102c50d82SAndre Fischer ValueSet::Resize (); 38202c50d82SAndre Fischer } 38302c50d82SAndre Fischer 38402c50d82SAndre Fischer 38502c50d82SAndre Fischer 38602c50d82SAndre Fischer 38702c50d82SAndre Fischer void LayoutMenu::MouseButtonDown (const MouseEvent& rEvent) 38802c50d82SAndre Fischer { 38902c50d82SAndre Fischer // As a preparation for the context menu the item under the mouse is 39002c50d82SAndre Fischer // selected. 39102c50d82SAndre Fischer if (rEvent.IsRight()) 39202c50d82SAndre Fischer { 39302c50d82SAndre Fischer ReleaseMouse(); 39402c50d82SAndre Fischer sal_uInt16 nIndex = GetItemId (rEvent.GetPosPixel()); 39502c50d82SAndre Fischer if (nIndex > 0) 39602c50d82SAndre Fischer SelectItem(nIndex); 39702c50d82SAndre Fischer } 39802c50d82SAndre Fischer 39902c50d82SAndre Fischer ValueSet::MouseButtonDown (rEvent); 40002c50d82SAndre Fischer } 40102c50d82SAndre Fischer 40202c50d82SAndre Fischer 40302c50d82SAndre Fischer 40402c50d82SAndre Fischer 40502c50d82SAndre Fischer void LayoutMenu::InsertPageWithLayout (AutoLayout aLayout) 40602c50d82SAndre Fischer { 40702c50d82SAndre Fischer ViewShell* pViewShell = mrBase.GetMainViewShell().get(); 40802c50d82SAndre Fischer if (pViewShell == NULL) 40902c50d82SAndre Fischer return; 41002c50d82SAndre Fischer 41102c50d82SAndre Fischer SfxViewFrame* pViewFrame = mrBase.GetViewFrame(); 41202c50d82SAndre Fischer if (pViewFrame == NULL) 41302c50d82SAndre Fischer return; 41402c50d82SAndre Fischer 41502c50d82SAndre Fischer SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher(); 41602c50d82SAndre Fischer if (pDispatcher == NULL) 41702c50d82SAndre Fischer return; 41802c50d82SAndre Fischer 41902c50d82SAndre Fischer // Call SID_INSERTPAGE with the right arguments. This is because 42002c50d82SAndre Fischer // the popup menu can not call this slot with arguments directly. 42102c50d82SAndre Fischer SfxRequest aRequest (CreateRequest(SID_INSERTPAGE, aLayout)); 42202c50d82SAndre Fischer if (aRequest.GetArgs() != NULL) 42302c50d82SAndre Fischer { 42402c50d82SAndre Fischer pDispatcher->Execute( 42502c50d82SAndre Fischer SID_INSERTPAGE, 42602c50d82SAndre Fischer SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, 42702c50d82SAndre Fischer *aRequest.GetArgs()); 42802c50d82SAndre Fischer } 42902c50d82SAndre Fischer UpdateSelection(); 43002c50d82SAndre Fischer } 43102c50d82SAndre Fischer 43202c50d82SAndre Fischer 43302c50d82SAndre Fischer 43402c50d82SAndre Fischer 43502c50d82SAndre Fischer void LayoutMenu::InvalidateContent (void) 43602c50d82SAndre Fischer { 43702c50d82SAndre Fischer // Throw away the current set and fill the menu anew according to the 43802c50d82SAndre Fischer // current settings (this includes the support for vertical writing.) 43902c50d82SAndre Fischer Fill(); 44002c50d82SAndre Fischer 44102c50d82SAndre Fischer if (mxSidebar.is()) 44202c50d82SAndre Fischer mxSidebar->requestLayout(); 44302c50d82SAndre Fischer } 44402c50d82SAndre Fischer 44502c50d82SAndre Fischer 44602c50d82SAndre Fischer 44702c50d82SAndre Fischer 44802c50d82SAndre Fischer int LayoutMenu::CalculateRowCount (const Size&, int nColumnCount) 44902c50d82SAndre Fischer { 45002c50d82SAndre Fischer int nRowCount = 0; 45102c50d82SAndre Fischer 45202c50d82SAndre Fischer if (GetItemCount() > 0 && nColumnCount > 0) 45302c50d82SAndre Fischer { 45402c50d82SAndre Fischer nRowCount = (GetItemCount() + nColumnCount - 1) / nColumnCount; 45502c50d82SAndre Fischer // nRowCount = GetOutputSizePixel().Height() / rItemSize.Height(); 45602c50d82SAndre Fischer if (nRowCount < 1) 45702c50d82SAndre Fischer nRowCount = 1; 45802c50d82SAndre Fischer } 45902c50d82SAndre Fischer 46002c50d82SAndre Fischer return nRowCount; 46102c50d82SAndre Fischer } 46202c50d82SAndre Fischer 46302c50d82SAndre Fischer 46402c50d82SAndre Fischer 46502c50d82SAndre Fischer 46602c50d82SAndre Fischer IMPL_LINK(LayoutMenu, ClickHandler, ValueSet*, EMPTYARG) 46702c50d82SAndre Fischer { 46802c50d82SAndre Fischer AssignLayoutToSelectedSlides (GetSelectedAutoLayout()); 46902c50d82SAndre Fischer return 0; 47002c50d82SAndre Fischer } 47102c50d82SAndre Fischer 47202c50d82SAndre Fischer 47302c50d82SAndre Fischer 47402c50d82SAndre Fischer 47502c50d82SAndre Fischer /** The specified layout is assigned to the current page of the view shell 47602c50d82SAndre Fischer in the center pane. 47702c50d82SAndre Fischer */ 47802c50d82SAndre Fischer void LayoutMenu::AssignLayoutToSelectedSlides (AutoLayout aLayout) 47902c50d82SAndre Fischer { 48002c50d82SAndre Fischer using namespace ::sd::slidesorter; 48102c50d82SAndre Fischer using namespace ::sd::slidesorter::controller; 48202c50d82SAndre Fischer 48302c50d82SAndre Fischer do 48402c50d82SAndre Fischer { 48502c50d82SAndre Fischer // The view shell in the center pane has to be present. 48602c50d82SAndre Fischer ViewShell* pMainViewShell = mrBase.GetMainViewShell().get(); 48702c50d82SAndre Fischer if (pMainViewShell == NULL) 48802c50d82SAndre Fischer break; 48902c50d82SAndre Fischer 49002c50d82SAndre Fischer // Determine if the current view is in an invalid master page mode. 49102c50d82SAndre Fischer // The handout view is always in master page mode and therefore not 49202c50d82SAndre Fischer // invalid. 49302c50d82SAndre Fischer bool bMasterPageMode (false); 49402c50d82SAndre Fischer switch (pMainViewShell->GetShellType()) 49502c50d82SAndre Fischer { 49602c50d82SAndre Fischer case ViewShell::ST_NOTES: 49702c50d82SAndre Fischer case ViewShell::ST_IMPRESS: 49802c50d82SAndre Fischer { 49902c50d82SAndre Fischer DrawViewShell* pDrawViewShell = static_cast<DrawViewShell*>(pMainViewShell); 50002c50d82SAndre Fischer if (pDrawViewShell != NULL) 50102c50d82SAndre Fischer if (pDrawViewShell->GetEditMode() == EM_MASTERPAGE) 50202c50d82SAndre Fischer bMasterPageMode = true; 50302c50d82SAndre Fischer } 50402c50d82SAndre Fischer default: 50502c50d82SAndre Fischer break; 50602c50d82SAndre Fischer } 50702c50d82SAndre Fischer if (bMasterPageMode) 50802c50d82SAndre Fischer break; 50902c50d82SAndre Fischer 51002c50d82SAndre Fischer // Get a list of all selected slides and call the SID_MODIFYPAGE 51102c50d82SAndre Fischer // slot for all of them. 51202c50d82SAndre Fischer ::sd::slidesorter::SharedPageSelection pPageSelection; 51302c50d82SAndre Fischer 51402c50d82SAndre Fischer // Get a list of selected pages. 51502c50d82SAndre Fischer // First we try to obtain this list from a slide sorter. This is 51602c50d82SAndre Fischer // possible only some of the view shells in the center pane. When 51702c50d82SAndre Fischer // no valid slide sorter is available then ask the main view shell 51802c50d82SAndre Fischer // for its current page. 51902c50d82SAndre Fischer SlideSorterViewShell* pSlideSorter = NULL; 52002c50d82SAndre Fischer switch (pMainViewShell->GetShellType()) 52102c50d82SAndre Fischer { 52202c50d82SAndre Fischer case ViewShell::ST_IMPRESS: 52302c50d82SAndre Fischer case ViewShell::ST_NOTES: 52402c50d82SAndre Fischer case ViewShell::ST_SLIDE_SORTER: 52502c50d82SAndre Fischer pSlideSorter = SlideSorterViewShell::GetSlideSorter(mrBase); 52602c50d82SAndre Fischer break; 52702c50d82SAndre Fischer default: 52802c50d82SAndre Fischer break; 52902c50d82SAndre Fischer } 53002c50d82SAndre Fischer if (pSlideSorter != NULL) 53102c50d82SAndre Fischer { 53202c50d82SAndre Fischer // There is a slide sorter visible so get the list of selected pages from it. 53302c50d82SAndre Fischer pPageSelection = pSlideSorter->GetPageSelection(); 53402c50d82SAndre Fischer } 53502c50d82SAndre Fischer 53602c50d82SAndre Fischer if( (pSlideSorter == NULL) || (pPageSelection.get() == 0) || pPageSelection->empty() ) 53702c50d82SAndre Fischer { 53802c50d82SAndre Fischer // No valid slide sorter available. Ask the main view shell for 53902c50d82SAndre Fischer // its current page. 54002c50d82SAndre Fischer pPageSelection.reset(new ::sd::slidesorter::SlideSorterViewShell::PageSelection()); 54102c50d82SAndre Fischer pPageSelection->push_back(pMainViewShell->GetActualPage()); 54202c50d82SAndre Fischer } 54302c50d82SAndre Fischer 54402c50d82SAndre Fischer 54502c50d82SAndre Fischer if (pPageSelection->empty()) 54602c50d82SAndre Fischer break; 54702c50d82SAndre Fischer 54802c50d82SAndre Fischer ::std::vector<SdPage*>::iterator iPage; 54902c50d82SAndre Fischer for (iPage=pPageSelection->begin(); iPage!=pPageSelection->end(); ++iPage) 55002c50d82SAndre Fischer { 55102c50d82SAndre Fischer if ((*iPage) == NULL) 55202c50d82SAndre Fischer continue; 55302c50d82SAndre Fischer 55402c50d82SAndre Fischer // Call the SID_ASSIGN_LAYOUT slot with all the necessary parameters. 55502c50d82SAndre Fischer SfxRequest aRequest (mrBase.GetViewFrame(), SID_ASSIGN_LAYOUT); 55602c50d82SAndre Fischer aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATPAGE, ((*iPage)->GetPageNum()-1)/2)); 55702c50d82SAndre Fischer aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, aLayout)); 55802c50d82SAndre Fischer pMainViewShell->ExecuteSlot (aRequest, sal_Bool(sal_False)); 55902c50d82SAndre Fischer } 56002c50d82SAndre Fischer } 56102c50d82SAndre Fischer while(false); 56202c50d82SAndre Fischer } 56302c50d82SAndre Fischer 56402c50d82SAndre Fischer 56502c50d82SAndre Fischer 56602c50d82SAndre Fischer 56702c50d82SAndre Fischer SfxRequest LayoutMenu::CreateRequest ( 56802c50d82SAndre Fischer sal_uInt16 nSlotId, 56902c50d82SAndre Fischer AutoLayout aLayout) 57002c50d82SAndre Fischer { 57102c50d82SAndre Fischer SfxRequest aRequest (mrBase.GetViewFrame(), nSlotId); 57202c50d82SAndre Fischer 57302c50d82SAndre Fischer do 57402c50d82SAndre Fischer { 57502c50d82SAndre Fischer SdrLayerAdmin& rLayerAdmin (mrBase.GetDocument()->GetLayerAdmin()); 57602c50d82SAndre Fischer sal_uInt8 aBackground (rLayerAdmin.GetLayerID( 57702c50d82SAndre Fischer String(SdResId(STR_LAYER_BCKGRND)), sal_False)); 57802c50d82SAndre Fischer sal_uInt8 aBackgroundObject (rLayerAdmin.GetLayerID( 57902c50d82SAndre Fischer String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False)); 58002c50d82SAndre Fischer ViewShell* pViewShell = mrBase.GetMainViewShell().get(); 58102c50d82SAndre Fischer if (pViewShell == NULL) 58202c50d82SAndre Fischer break; 58302c50d82SAndre Fischer SdPage* pPage = pViewShell->GetActualPage(); 58402c50d82SAndre Fischer if (pPage == NULL) 58502c50d82SAndre Fischer break; 58602c50d82SAndre Fischer 58702c50d82SAndre Fischer SetOfByte aVisibleLayers (pPage->TRG_GetMasterPageVisibleLayers()); 58802c50d82SAndre Fischer 58902c50d82SAndre Fischer aRequest.AppendItem( 59002c50d82SAndre Fischer SfxStringItem (ID_VAL_PAGENAME, String()));//pPage->GetName())); 59102c50d82SAndre Fischer aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, aLayout)); 59202c50d82SAndre Fischer aRequest.AppendItem( 59302c50d82SAndre Fischer SfxBoolItem(ID_VAL_ISPAGEBACK, aVisibleLayers.IsSet(aBackground))); 59402c50d82SAndre Fischer aRequest.AppendItem( 59502c50d82SAndre Fischer SfxBoolItem( 59602c50d82SAndre Fischer ID_VAL_ISPAGEOBJ, 59702c50d82SAndre Fischer aVisibleLayers.IsSet(aBackgroundObject))); 59802c50d82SAndre Fischer } 59902c50d82SAndre Fischer while (false); 60002c50d82SAndre Fischer 60102c50d82SAndre Fischer return aRequest; 60202c50d82SAndre Fischer } 60302c50d82SAndre Fischer 60402c50d82SAndre Fischer 60502c50d82SAndre Fischer 60602c50d82SAndre Fischer 60702c50d82SAndre Fischer void LayoutMenu::Fill (void) 60802c50d82SAndre Fischer { 60902c50d82SAndre Fischer const bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode(); 61002c50d82SAndre Fischer SvtLanguageOptions aLanguageOptions; 61102c50d82SAndre Fischer sal_Bool bVertical = aLanguageOptions.IsVerticalTextEnabled(); 61202c50d82SAndre Fischer SdDrawDocument* pDocument = mrBase.GetDocument(); 61302c50d82SAndre Fischer sal_Bool bRightToLeft = (pDocument!=NULL 61402c50d82SAndre Fischer && pDocument->GetDefaultWritingMode() == WritingMode_RL_TB); 61502c50d82SAndre Fischer 61602c50d82SAndre Fischer // Get URL of the view in the center pane. 61702c50d82SAndre Fischer ::rtl::OUString sCenterPaneViewName; 61802c50d82SAndre Fischer try 61902c50d82SAndre Fischer { 62002c50d82SAndre Fischer Reference<XControllerManager> xControllerManager ( 62102c50d82SAndre Fischer Reference<XWeak>(&mrBase.GetDrawController()), UNO_QUERY_THROW); 62202c50d82SAndre Fischer Reference<XResourceId> xPaneId (ResourceId::create( 62302c50d82SAndre Fischer ::comphelper::getProcessComponentContext(), 62402c50d82SAndre Fischer FrameworkHelper::msCenterPaneURL)); 62502c50d82SAndre Fischer Reference<XView> xView (FrameworkHelper::Instance(mrBase)->GetView(xPaneId)); 62602c50d82SAndre Fischer if (xView.is()) 62702c50d82SAndre Fischer sCenterPaneViewName = xView->getResourceId()->getResourceURL(); 62802c50d82SAndre Fischer } 62902c50d82SAndre Fischer catch (RuntimeException&) 63002c50d82SAndre Fischer {} 63102c50d82SAndre Fischer 63202c50d82SAndre Fischer snewfoil_value_info* pInfo = NULL; 63302c50d82SAndre Fischer if (sCenterPaneViewName.equals(framework::FrameworkHelper::msNotesViewURL)) 63402c50d82SAndre Fischer { 63502c50d82SAndre Fischer pInfo = notes; 63602c50d82SAndre Fischer } 63702c50d82SAndre Fischer else if (sCenterPaneViewName.equals(framework::FrameworkHelper::msHandoutViewURL)) 63802c50d82SAndre Fischer { 63902c50d82SAndre Fischer pInfo = handout; 64002c50d82SAndre Fischer } 64102c50d82SAndre Fischer else if (sCenterPaneViewName.equals(framework::FrameworkHelper::msImpressViewURL) 64202c50d82SAndre Fischer || sCenterPaneViewName.equals(framework::FrameworkHelper::msSlideSorterURL)) 64302c50d82SAndre Fischer { 64402c50d82SAndre Fischer pInfo = standard; 64502c50d82SAndre Fischer } 64602c50d82SAndre Fischer else 64702c50d82SAndre Fischer { 64802c50d82SAndre Fischer pInfo = NULL; 64902c50d82SAndre Fischer } 65002c50d82SAndre Fischer 65102c50d82SAndre Fischer Clear(); 65202c50d82SAndre Fischer int n = 0; 65302c50d82SAndre Fischer for (sal_uInt16 i=1; pInfo!=NULL&&pInfo->mnBmpResId!=0; i++,pInfo++) 65402c50d82SAndre Fischer { 65502c50d82SAndre Fischer if ((WritingMode_TB_RL != pInfo->meWritingMode) || bVertical) 65602c50d82SAndre Fischer { 65702c50d82SAndre Fischer BitmapEx aBmp (SdResId (bHighContrast 65802c50d82SAndre Fischer ? pInfo->mnHCBmpResId 65902c50d82SAndre Fischer : pInfo->mnBmpResId)); 66002c50d82SAndre Fischer 66102c50d82SAndre Fischer if (bRightToLeft && (WritingMode_TB_RL != pInfo->meWritingMode)) 66202c50d82SAndre Fischer aBmp.Mirror (BMP_MIRROR_HORZ); 66302c50d82SAndre Fischer 66402c50d82SAndre Fischer InsertItem (i, aBmp, String (SdResId (pInfo->mnStrResId))); 66502c50d82SAndre Fischer SetItemData (i, new AutoLayout(pInfo->maAutoLayout)); 66602c50d82SAndre Fischer n++; 66702c50d82SAndre Fischer } 66802c50d82SAndre Fischer } 66902c50d82SAndre Fischer 67002c50d82SAndre Fischer mbSelectionUpdatePending = true; 67102c50d82SAndre Fischer } 67202c50d82SAndre Fischer 67302c50d82SAndre Fischer 67402c50d82SAndre Fischer 67502c50d82SAndre Fischer 67602c50d82SAndre Fischer void LayoutMenu::Clear (void) 67702c50d82SAndre Fischer { 67802c50d82SAndre Fischer for (sal_uInt16 nId=1; nId<=GetItemCount(); nId++) 67902c50d82SAndre Fischer delete static_cast<AutoLayout*>(GetItemData(nId)); 68002c50d82SAndre Fischer ValueSet::Clear(); 68102c50d82SAndre Fischer } 68202c50d82SAndre Fischer 68302c50d82SAndre Fischer 68402c50d82SAndre Fischer 68502c50d82SAndre Fischer void LayoutMenu::StartDrag (sal_Int8 , const Point& ) 68602c50d82SAndre Fischer { 68702c50d82SAndre Fischer } 68802c50d82SAndre Fischer 68902c50d82SAndre Fischer 69002c50d82SAndre Fischer 69102c50d82SAndre Fischer 69202c50d82SAndre Fischer sal_Int8 LayoutMenu::AcceptDrop (const AcceptDropEvent& ) 69302c50d82SAndre Fischer { 69402c50d82SAndre Fischer return 0; 69502c50d82SAndre Fischer } 69602c50d82SAndre Fischer 69702c50d82SAndre Fischer 69802c50d82SAndre Fischer 69902c50d82SAndre Fischer 70002c50d82SAndre Fischer sal_Int8 LayoutMenu::ExecuteDrop (const ExecuteDropEvent& ) 70102c50d82SAndre Fischer { 70202c50d82SAndre Fischer return 0; 70302c50d82SAndre Fischer } 70402c50d82SAndre Fischer 70502c50d82SAndre Fischer 70602c50d82SAndre Fischer 70702c50d82SAndre Fischer 70802c50d82SAndre Fischer void LayoutMenu::Command (const CommandEvent& rEvent) 70902c50d82SAndre Fischer { 71002c50d82SAndre Fischer switch (rEvent.GetCommand()) 71102c50d82SAndre Fischer { 71202c50d82SAndre Fischer case COMMAND_CONTEXTMENU: 71302c50d82SAndre Fischer if ( ! SD_MOD()->GetWaterCan()) 71402c50d82SAndre Fischer { 71502c50d82SAndre Fischer // Determine the position where to show the menu. 71602c50d82SAndre Fischer Point aMenuPosition; 71702c50d82SAndre Fischer if (rEvent.IsMouseEvent()) 71802c50d82SAndre Fischer { 71902c50d82SAndre Fischer if (GetItemId(rEvent.GetMousePosPixel()) <= 0) 72002c50d82SAndre Fischer return; 72102c50d82SAndre Fischer aMenuPosition = rEvent.GetMousePosPixel(); 72202c50d82SAndre Fischer } 72302c50d82SAndre Fischer else 72402c50d82SAndre Fischer { 72502c50d82SAndre Fischer if (GetSelectItemId() == (sal_uInt16)-1) 72602c50d82SAndre Fischer return; 72702c50d82SAndre Fischer Rectangle aBBox (GetItemRect(GetSelectItemId())); 72802c50d82SAndre Fischer aMenuPosition = aBBox.Center(); 72902c50d82SAndre Fischer } 73002c50d82SAndre Fischer 73102c50d82SAndre Fischer // Setup the menu. 73202c50d82SAndre Fischer ::boost::shared_ptr<PopupMenu> pMenu (new PopupMenu(SdResId(RID_TASKPANE_LAYOUTMENU_POPUP))); 73302c50d82SAndre Fischer FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow()); 73402c50d82SAndre Fischer if (pMenuWindow != NULL) 73502c50d82SAndre Fischer pMenuWindow->SetPopupModeFlags( 73602c50d82SAndre Fischer pMenuWindow->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE); 73702c50d82SAndre Fischer pMenu->SetSelectHdl(LINK(this, LayoutMenu, OnMenuItemSelected)); 73802c50d82SAndre Fischer 73902c50d82SAndre Fischer // Disable the SID_INSERTPAGE_LAYOUT_MENU item when 74002c50d82SAndre Fischer // the document is read-only. 74102c50d82SAndre Fischer const SfxPoolItem* pItem = NULL; 74202c50d82SAndre Fischer const SfxItemState aState ( 74302c50d82SAndre Fischer mrBase.GetViewFrame()->GetDispatcher()->QueryState(SID_INSERTPAGE, pItem)); 74402c50d82SAndre Fischer if (aState == SFX_ITEM_DISABLED) 74502c50d82SAndre Fischer pMenu->EnableItem(SID_INSERTPAGE_LAYOUT_MENU, sal_False); 74602c50d82SAndre Fischer 74702c50d82SAndre Fischer // Show the menu. 74802c50d82SAndre Fischer pMenu->Execute(this, Rectangle(aMenuPosition,Size(1,1)), POPUPMENU_EXECUTE_DOWN); 74902c50d82SAndre Fischer } 75002c50d82SAndre Fischer break; 75102c50d82SAndre Fischer 75202c50d82SAndre Fischer default: 75302c50d82SAndre Fischer ValueSet::Command(rEvent); 75402c50d82SAndre Fischer break; 75502c50d82SAndre Fischer } 75602c50d82SAndre Fischer } 75702c50d82SAndre Fischer 75802c50d82SAndre Fischer 75902c50d82SAndre Fischer 76002c50d82SAndre Fischer 76102c50d82SAndre Fischer IMPL_LINK(LayoutMenu, StateChangeHandler, ::rtl::OUString*, EMPTYARG) 76202c50d82SAndre Fischer { 76302c50d82SAndre Fischer InvalidateContent(); 76402c50d82SAndre Fischer return 0; 76502c50d82SAndre Fischer } 76602c50d82SAndre Fischer 76702c50d82SAndre Fischer 76802c50d82SAndre Fischer 76902c50d82SAndre Fischer 77002c50d82SAndre Fischer IMPL_LINK(LayoutMenu, OnMenuItemSelected, Menu*, pMenu) 77102c50d82SAndre Fischer { 77202c50d82SAndre Fischer if (pMenu == NULL) 77302c50d82SAndre Fischer { 77402c50d82SAndre Fischer OSL_ENSURE(pMenu!=NULL, "LayoutMenu::OnMenuItemSelected: illegal menu!"); 77502c50d82SAndre Fischer return 0; 77602c50d82SAndre Fischer } 77702c50d82SAndre Fischer 77802c50d82SAndre Fischer pMenu->Deactivate(); 77902c50d82SAndre Fischer const sal_Int32 nIndex (pMenu->GetCurItemId()); 78002c50d82SAndre Fischer 78102c50d82SAndre Fischer if (nIndex == SID_TP_APPLY_TO_SELECTED_SLIDES) 78202c50d82SAndre Fischer { 78302c50d82SAndre Fischer AssignLayoutToSelectedSlides(GetSelectedAutoLayout()); 78402c50d82SAndre Fischer } 78502c50d82SAndre Fischer else if (nIndex == SID_INSERTPAGE_LAYOUT_MENU) 78602c50d82SAndre Fischer { 78702c50d82SAndre Fischer // Add arguments to this slot and forward it to the main view 78802c50d82SAndre Fischer // shell. 78902c50d82SAndre Fischer InsertPageWithLayout(GetSelectedAutoLayout()); 79002c50d82SAndre Fischer } 79102c50d82SAndre Fischer 79202c50d82SAndre Fischer return 0; 79302c50d82SAndre Fischer } 79402c50d82SAndre Fischer 79502c50d82SAndre Fischer 79602c50d82SAndre Fischer 79702c50d82SAndre Fischer 79802c50d82SAndre Fischer void LayoutMenu::UpdateSelection (void) 79902c50d82SAndre Fischer { 80002c50d82SAndre Fischer bool bItemSelected = false; 80102c50d82SAndre Fischer 80202c50d82SAndre Fischer do 80302c50d82SAndre Fischer { 80402c50d82SAndre Fischer // Get current page of main view. 80502c50d82SAndre Fischer ViewShell* pViewShell = mrBase.GetMainViewShell().get(); 80602c50d82SAndre Fischer if (pViewShell == NULL) 80702c50d82SAndre Fischer break; 80802c50d82SAndre Fischer 80902c50d82SAndre Fischer SdPage* pCurrentPage = pViewShell->getCurrentPage(); 81002c50d82SAndre Fischer if (pCurrentPage == NULL) 81102c50d82SAndre Fischer break; 81202c50d82SAndre Fischer 81302c50d82SAndre Fischer // Get layout of current page. 81402c50d82SAndre Fischer AutoLayout aLayout (pCurrentPage->GetAutoLayout()); 81502c50d82SAndre Fischer if (aLayout<AUTOLAYOUT__START || aLayout>AUTOLAYOUT__END) 81602c50d82SAndre Fischer break; 81702c50d82SAndre Fischer 81802c50d82SAndre Fischer // Find the entry of the menu for to the layout. 819*6dc7b748SAndre Fischer SetNoSelection(); 82002c50d82SAndre Fischer sal_uInt16 nItemCount (GetItemCount()); 82102c50d82SAndre Fischer for (sal_uInt16 nId=1; nId<=nItemCount; nId++) 82202c50d82SAndre Fischer { 82302c50d82SAndre Fischer if (*static_cast<AutoLayout*>(GetItemData(nId)) == aLayout) 82402c50d82SAndre Fischer { 82502c50d82SAndre Fischer SelectItem(nId); 82602c50d82SAndre Fischer bItemSelected = true; 82702c50d82SAndre Fischer break; 82802c50d82SAndre Fischer } 82902c50d82SAndre Fischer } 83002c50d82SAndre Fischer } 83102c50d82SAndre Fischer while (false); 83202c50d82SAndre Fischer 83302c50d82SAndre Fischer if ( ! bItemSelected) 83402c50d82SAndre Fischer SetNoSelection(); 83502c50d82SAndre Fischer } 83602c50d82SAndre Fischer 83702c50d82SAndre Fischer 83802c50d82SAndre Fischer 83902c50d82SAndre Fischer 84002c50d82SAndre Fischer IMPL_LINK(LayoutMenu, EventMultiplexerListener, ::sd::tools::EventMultiplexerEvent*, pEvent) 84102c50d82SAndre Fischer { 84202c50d82SAndre Fischer switch (pEvent->meEventId) 84302c50d82SAndre Fischer { 84402c50d82SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_CURRENT_PAGE: 84502c50d82SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_SLIDE_SORTER_SELECTION: 84602c50d82SAndre Fischer if ( ! mbSelectionUpdatePending) 84702c50d82SAndre Fischer UpdateSelection(); 84802c50d82SAndre Fischer break; 84902c50d82SAndre Fischer 85002c50d82SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED: 85102c50d82SAndre Fischer mbIsMainViewChangePending = true; 85202c50d82SAndre Fischer break; 85302c50d82SAndre Fischer 85402c50d82SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED: 85502c50d82SAndre Fischer HideFocus(); 85602c50d82SAndre Fischer break; 85702c50d82SAndre Fischer 85802c50d82SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED: 85902c50d82SAndre Fischer if (mbIsMainViewChangePending) 86002c50d82SAndre Fischer { 86102c50d82SAndre Fischer mbIsMainViewChangePending = false; 86202c50d82SAndre Fischer InvalidateContent(); 86302c50d82SAndre Fischer } 86402c50d82SAndre Fischer break; 86502c50d82SAndre Fischer 86602c50d82SAndre Fischer default: 86702c50d82SAndre Fischer /* Ignored */ 86802c50d82SAndre Fischer break; 86902c50d82SAndre Fischer } 87002c50d82SAndre Fischer 87102c50d82SAndre Fischer return 0; 87202c50d82SAndre Fischer } 87302c50d82SAndre Fischer 87402c50d82SAndre Fischer 87502c50d82SAndre Fischer 87602c50d82SAndre Fischer 87702c50d82SAndre Fischer IMPL_LINK(LayoutMenu, WindowEventHandler, VclWindowEvent*, pEvent) 87802c50d82SAndre Fischer { 87902c50d82SAndre Fischer if (pEvent != NULL) 88002c50d82SAndre Fischer { 88102c50d82SAndre Fischer switch (pEvent->GetId()) 88202c50d82SAndre Fischer { 88302c50d82SAndre Fischer case VCLEVENT_WINDOW_SHOW: 88402c50d82SAndre Fischer case VCLEVENT_WINDOW_RESIZE: 88502c50d82SAndre Fischer SetSizePixel(GetParent()->GetSizePixel()); 88602c50d82SAndre Fischer return sal_True; 88702c50d82SAndre Fischer 88802c50d82SAndre Fischer default: 88902c50d82SAndre Fischer return sal_False; 89002c50d82SAndre Fischer } 89102c50d82SAndre Fischer 89202c50d82SAndre Fischer const SfxSimpleHint* pSimpleHint = PTR_CAST(SfxSimpleHint, pEvent); 89302c50d82SAndre Fischer if (pSimpleHint != NULL 89402c50d82SAndre Fischer && pSimpleHint->GetId() == SFX_HINT_DYING) 89502c50d82SAndre Fischer { 89602c50d82SAndre Fischer return sal_True; 89702c50d82SAndre Fischer } 89802c50d82SAndre Fischer } 89902c50d82SAndre Fischer 90002c50d82SAndre Fischer return sal_False; 90102c50d82SAndre Fischer } 90202c50d82SAndre Fischer 90302c50d82SAndre Fischer 90402c50d82SAndre Fischer 90502c50d82SAndre Fischer 90602c50d82SAndre Fischer void LayoutMenu::DataChanged (const DataChangedEvent& rEvent) 90702c50d82SAndre Fischer { 90802c50d82SAndre Fischer Fill(); 90902c50d82SAndre Fischer ValueSet::DataChanged(rEvent); 9108dcb2a10SAndre Fischer SetBackground(sfx2::sidebar::Theme::GetWallpaper(sfx2::sidebar::Theme::Paint_PanelBackground)); 9118dcb2a10SAndre Fischer SetColor(sfx2::sidebar::Theme::GetColor(sfx2::sidebar::Theme::Paint_PanelBackground)); 91202c50d82SAndre Fischer } 91302c50d82SAndre Fischer 91402c50d82SAndre Fischer 91502c50d82SAndre Fischer 91602c50d82SAndre Fischer 91702c50d82SAndre Fischer 91802c50d82SAndre Fischer } } // end of namespace ::sd::sidebar 919