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" 45*8dcb2a10SAndre 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 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)); 158*8dcb2a10SAndre 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 176*8dcb2a10SAndre 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::UpdateEnabledState (const MasterMode eMode) 34302c50d82SAndre Fischer { 34402c50d82SAndre Fischer bool bIsEnabled (false); 34502c50d82SAndre Fischer 34602c50d82SAndre Fischer ::boost::shared_ptr<ViewShell> pMainViewShell (mrBase.GetMainViewShell()); 34702c50d82SAndre Fischer if (pMainViewShell) 34802c50d82SAndre Fischer { 34902c50d82SAndre Fischer switch (pMainViewShell->GetShellType()) 35002c50d82SAndre Fischer { 35102c50d82SAndre Fischer case ViewShell::ST_NONE: 35202c50d82SAndre Fischer case ViewShell::ST_OUTLINE: 35302c50d82SAndre Fischer case ViewShell::ST_PRESENTATION: 35402c50d82SAndre Fischer case ViewShell::ST_SIDEBAR: 35502c50d82SAndre Fischer // The complete task pane is disabled for these values or 35602c50d82SAndre Fischer // not even visible. Disabling the LayoutMenu would be 35702c50d82SAndre Fischer // logical but unnecessary. The main disadvantage is that 35802c50d82SAndre Fischer // after re-enabling it (typically) another panel is 35902c50d82SAndre Fischer // expanded. 36002c50d82SAndre Fischer bIsEnabled = true; 36102c50d82SAndre Fischer break; 36202c50d82SAndre Fischer 36302c50d82SAndre Fischer case ViewShell::ST_DRAW: 36402c50d82SAndre Fischer case ViewShell::ST_IMPRESS: 36502c50d82SAndre Fischer { 36602c50d82SAndre Fischer switch (eMode) 36702c50d82SAndre Fischer { 36802c50d82SAndre Fischer case MM_UNKNOWN: 36902c50d82SAndre Fischer { 37002c50d82SAndre Fischer ::boost::shared_ptr<DrawViewShell> pDrawViewShell ( 37102c50d82SAndre Fischer ::boost::dynamic_pointer_cast<DrawViewShell>(pMainViewShell)); 37202c50d82SAndre Fischer if (pDrawViewShell) 37302c50d82SAndre Fischer bIsEnabled = pDrawViewShell->GetEditMode() != EM_MASTERPAGE; 37402c50d82SAndre Fischer break; 37502c50d82SAndre Fischer } 37602c50d82SAndre Fischer case MM_NORMAL: 37702c50d82SAndre Fischer bIsEnabled = true; 37802c50d82SAndre Fischer break; 37902c50d82SAndre Fischer 38002c50d82SAndre Fischer case MM_MASTER: 38102c50d82SAndre Fischer bIsEnabled = false; 38202c50d82SAndre Fischer break; 38302c50d82SAndre Fischer } 38402c50d82SAndre Fischer break; 38502c50d82SAndre Fischer } 38602c50d82SAndre Fischer 38702c50d82SAndre Fischer case ViewShell::ST_HANDOUT: 38802c50d82SAndre Fischer case ViewShell::ST_NOTES: 38902c50d82SAndre Fischer case ViewShell::ST_SLIDE_SORTER: 39002c50d82SAndre Fischer default: 39102c50d82SAndre Fischer bIsEnabled = true; 39202c50d82SAndre Fischer break; 39302c50d82SAndre Fischer } 39402c50d82SAndre Fischer } 39502c50d82SAndre Fischer } 39602c50d82SAndre Fischer 39702c50d82SAndre Fischer 39802c50d82SAndre Fischer 39902c50d82SAndre Fischer 40002c50d82SAndre Fischer void LayoutMenu::Paint (const Rectangle& rRect) 40102c50d82SAndre Fischer { 40202c50d82SAndre Fischer if (mbSelectionUpdatePending) 40302c50d82SAndre Fischer { 40402c50d82SAndre Fischer mbSelectionUpdatePending = false; 40502c50d82SAndre Fischer UpdateSelection(); 40602c50d82SAndre Fischer } 40702c50d82SAndre Fischer ValueSet::Paint (rRect); 40802c50d82SAndre Fischer } 40902c50d82SAndre Fischer 41002c50d82SAndre Fischer 41102c50d82SAndre Fischer 41202c50d82SAndre Fischer 41302c50d82SAndre Fischer void LayoutMenu::Resize (void) 41402c50d82SAndre Fischer { 41502c50d82SAndre Fischer Size aWindowSize = GetOutputSizePixel(); 41602c50d82SAndre Fischer if (IsVisible() && aWindowSize.Width() > 0) 41702c50d82SAndre Fischer { 41802c50d82SAndre Fischer // Calculate the number of rows and columns. 41902c50d82SAndre Fischer if (GetItemCount() > 0) 42002c50d82SAndre Fischer { 42102c50d82SAndre Fischer Image aImage = GetItemImage(GetItemId(0)); 42202c50d82SAndre Fischer Size aItemSize = CalcItemSizePixel ( 42302c50d82SAndre Fischer aImage.GetSizePixel()); 42402c50d82SAndre Fischer aItemSize.Width() += 8; 42502c50d82SAndre Fischer aItemSize.Height() += 8; 42602c50d82SAndre Fischer int nColumnCount = aWindowSize.Width() / aItemSize.Width(); 42702c50d82SAndre Fischer if (nColumnCount < 1) 42802c50d82SAndre Fischer nColumnCount = 1; 42902c50d82SAndre Fischer else if (nColumnCount > 4) 43002c50d82SAndre Fischer nColumnCount = 4; 43102c50d82SAndre Fischer 43202c50d82SAndre Fischer int nRowCount = CalculateRowCount (aItemSize, nColumnCount); 43302c50d82SAndre Fischer 43402c50d82SAndre Fischer SetColCount ((sal_uInt16)nColumnCount); 43502c50d82SAndre Fischer SetLineCount ((sal_uInt16)nRowCount); 43602c50d82SAndre Fischer } 43702c50d82SAndre Fischer } 43802c50d82SAndre Fischer 43902c50d82SAndre Fischer ValueSet::Resize (); 44002c50d82SAndre Fischer } 44102c50d82SAndre Fischer 44202c50d82SAndre Fischer 44302c50d82SAndre Fischer 44402c50d82SAndre Fischer 44502c50d82SAndre Fischer void LayoutMenu::MouseButtonDown (const MouseEvent& rEvent) 44602c50d82SAndre Fischer { 44702c50d82SAndre Fischer // As a preparation for the context menu the item under the mouse is 44802c50d82SAndre Fischer // selected. 44902c50d82SAndre Fischer if (rEvent.IsRight()) 45002c50d82SAndre Fischer { 45102c50d82SAndre Fischer ReleaseMouse(); 45202c50d82SAndre Fischer sal_uInt16 nIndex = GetItemId (rEvent.GetPosPixel()); 45302c50d82SAndre Fischer if (nIndex > 0) 45402c50d82SAndre Fischer SelectItem(nIndex); 45502c50d82SAndre Fischer } 45602c50d82SAndre Fischer 45702c50d82SAndre Fischer ValueSet::MouseButtonDown (rEvent); 45802c50d82SAndre Fischer } 45902c50d82SAndre Fischer 46002c50d82SAndre Fischer 46102c50d82SAndre Fischer 46202c50d82SAndre Fischer 46302c50d82SAndre Fischer void LayoutMenu::InsertPageWithLayout (AutoLayout aLayout) 46402c50d82SAndre Fischer { 46502c50d82SAndre Fischer ViewShell* pViewShell = mrBase.GetMainViewShell().get(); 46602c50d82SAndre Fischer if (pViewShell == NULL) 46702c50d82SAndre Fischer return; 46802c50d82SAndre Fischer 46902c50d82SAndre Fischer SfxViewFrame* pViewFrame = mrBase.GetViewFrame(); 47002c50d82SAndre Fischer if (pViewFrame == NULL) 47102c50d82SAndre Fischer return; 47202c50d82SAndre Fischer 47302c50d82SAndre Fischer SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher(); 47402c50d82SAndre Fischer if (pDispatcher == NULL) 47502c50d82SAndre Fischer return; 47602c50d82SAndre Fischer 47702c50d82SAndre Fischer // Call SID_INSERTPAGE with the right arguments. This is because 47802c50d82SAndre Fischer // the popup menu can not call this slot with arguments directly. 47902c50d82SAndre Fischer SfxRequest aRequest (CreateRequest(SID_INSERTPAGE, aLayout)); 48002c50d82SAndre Fischer if (aRequest.GetArgs() != NULL) 48102c50d82SAndre Fischer { 48202c50d82SAndre Fischer pDispatcher->Execute( 48302c50d82SAndre Fischer SID_INSERTPAGE, 48402c50d82SAndre Fischer SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, 48502c50d82SAndre Fischer *aRequest.GetArgs()); 48602c50d82SAndre Fischer } 48702c50d82SAndre Fischer UpdateSelection(); 48802c50d82SAndre Fischer } 48902c50d82SAndre Fischer 49002c50d82SAndre Fischer 49102c50d82SAndre Fischer 49202c50d82SAndre Fischer 49302c50d82SAndre Fischer void LayoutMenu::InvalidateContent (void) 49402c50d82SAndre Fischer { 49502c50d82SAndre Fischer // Throw away the current set and fill the menu anew according to the 49602c50d82SAndre Fischer // current settings (this includes the support for vertical writing.) 49702c50d82SAndre Fischer Fill(); 49802c50d82SAndre Fischer 49902c50d82SAndre Fischer if (mxSidebar.is()) 50002c50d82SAndre Fischer mxSidebar->requestLayout(); 50102c50d82SAndre Fischer } 50202c50d82SAndre Fischer 50302c50d82SAndre Fischer 50402c50d82SAndre Fischer 50502c50d82SAndre Fischer 50602c50d82SAndre Fischer int LayoutMenu::CalculateRowCount (const Size&, int nColumnCount) 50702c50d82SAndre Fischer { 50802c50d82SAndre Fischer int nRowCount = 0; 50902c50d82SAndre Fischer 51002c50d82SAndre Fischer if (GetItemCount() > 0 && nColumnCount > 0) 51102c50d82SAndre Fischer { 51202c50d82SAndre Fischer nRowCount = (GetItemCount() + nColumnCount - 1) / nColumnCount; 51302c50d82SAndre Fischer // nRowCount = GetOutputSizePixel().Height() / rItemSize.Height(); 51402c50d82SAndre Fischer if (nRowCount < 1) 51502c50d82SAndre Fischer nRowCount = 1; 51602c50d82SAndre Fischer } 51702c50d82SAndre Fischer 51802c50d82SAndre Fischer return nRowCount; 51902c50d82SAndre Fischer } 52002c50d82SAndre Fischer 52102c50d82SAndre Fischer 52202c50d82SAndre Fischer 52302c50d82SAndre Fischer 52402c50d82SAndre Fischer IMPL_LINK(LayoutMenu, ClickHandler, ValueSet*, EMPTYARG) 52502c50d82SAndre Fischer { 52602c50d82SAndre Fischer AssignLayoutToSelectedSlides (GetSelectedAutoLayout()); 52702c50d82SAndre Fischer return 0; 52802c50d82SAndre Fischer } 52902c50d82SAndre Fischer 53002c50d82SAndre Fischer 53102c50d82SAndre Fischer 53202c50d82SAndre Fischer 53302c50d82SAndre Fischer /** The specified layout is assigned to the current page of the view shell 53402c50d82SAndre Fischer in the center pane. 53502c50d82SAndre Fischer */ 53602c50d82SAndre Fischer void LayoutMenu::AssignLayoutToSelectedSlides (AutoLayout aLayout) 53702c50d82SAndre Fischer { 53802c50d82SAndre Fischer using namespace ::sd::slidesorter; 53902c50d82SAndre Fischer using namespace ::sd::slidesorter::controller; 54002c50d82SAndre Fischer 54102c50d82SAndre Fischer do 54202c50d82SAndre Fischer { 54302c50d82SAndre Fischer // The view shell in the center pane has to be present. 54402c50d82SAndre Fischer ViewShell* pMainViewShell = mrBase.GetMainViewShell().get(); 54502c50d82SAndre Fischer if (pMainViewShell == NULL) 54602c50d82SAndre Fischer break; 54702c50d82SAndre Fischer 54802c50d82SAndre Fischer // Determine if the current view is in an invalid master page mode. 54902c50d82SAndre Fischer // The handout view is always in master page mode and therefore not 55002c50d82SAndre Fischer // invalid. 55102c50d82SAndre Fischer bool bMasterPageMode (false); 55202c50d82SAndre Fischer switch (pMainViewShell->GetShellType()) 55302c50d82SAndre Fischer { 55402c50d82SAndre Fischer case ViewShell::ST_NOTES: 55502c50d82SAndre Fischer case ViewShell::ST_IMPRESS: 55602c50d82SAndre Fischer { 55702c50d82SAndre Fischer DrawViewShell* pDrawViewShell = static_cast<DrawViewShell*>(pMainViewShell); 55802c50d82SAndre Fischer if (pDrawViewShell != NULL) 55902c50d82SAndre Fischer if (pDrawViewShell->GetEditMode() == EM_MASTERPAGE) 56002c50d82SAndre Fischer bMasterPageMode = true; 56102c50d82SAndre Fischer } 56202c50d82SAndre Fischer default: 56302c50d82SAndre Fischer break; 56402c50d82SAndre Fischer } 56502c50d82SAndre Fischer if (bMasterPageMode) 56602c50d82SAndre Fischer break; 56702c50d82SAndre Fischer 56802c50d82SAndre Fischer // Get a list of all selected slides and call the SID_MODIFYPAGE 56902c50d82SAndre Fischer // slot for all of them. 57002c50d82SAndre Fischer ::sd::slidesorter::SharedPageSelection pPageSelection; 57102c50d82SAndre Fischer 57202c50d82SAndre Fischer // Get a list of selected pages. 57302c50d82SAndre Fischer // First we try to obtain this list from a slide sorter. This is 57402c50d82SAndre Fischer // possible only some of the view shells in the center pane. When 57502c50d82SAndre Fischer // no valid slide sorter is available then ask the main view shell 57602c50d82SAndre Fischer // for its current page. 57702c50d82SAndre Fischer SlideSorterViewShell* pSlideSorter = NULL; 57802c50d82SAndre Fischer switch (pMainViewShell->GetShellType()) 57902c50d82SAndre Fischer { 58002c50d82SAndre Fischer case ViewShell::ST_IMPRESS: 58102c50d82SAndre Fischer case ViewShell::ST_NOTES: 58202c50d82SAndre Fischer case ViewShell::ST_SLIDE_SORTER: 58302c50d82SAndre Fischer pSlideSorter = SlideSorterViewShell::GetSlideSorter(mrBase); 58402c50d82SAndre Fischer break; 58502c50d82SAndre Fischer default: 58602c50d82SAndre Fischer break; 58702c50d82SAndre Fischer } 58802c50d82SAndre Fischer if (pSlideSorter != NULL) 58902c50d82SAndre Fischer { 59002c50d82SAndre Fischer // There is a slide sorter visible so get the list of selected pages from it. 59102c50d82SAndre Fischer pPageSelection = pSlideSorter->GetPageSelection(); 59202c50d82SAndre Fischer } 59302c50d82SAndre Fischer 59402c50d82SAndre Fischer if( (pSlideSorter == NULL) || (pPageSelection.get() == 0) || pPageSelection->empty() ) 59502c50d82SAndre Fischer { 59602c50d82SAndre Fischer // No valid slide sorter available. Ask the main view shell for 59702c50d82SAndre Fischer // its current page. 59802c50d82SAndre Fischer pPageSelection.reset(new ::sd::slidesorter::SlideSorterViewShell::PageSelection()); 59902c50d82SAndre Fischer pPageSelection->push_back(pMainViewShell->GetActualPage()); 60002c50d82SAndre Fischer } 60102c50d82SAndre Fischer 60202c50d82SAndre Fischer 60302c50d82SAndre Fischer if (pPageSelection->empty()) 60402c50d82SAndre Fischer break; 60502c50d82SAndre Fischer 60602c50d82SAndre Fischer ::std::vector<SdPage*>::iterator iPage; 60702c50d82SAndre Fischer for (iPage=pPageSelection->begin(); iPage!=pPageSelection->end(); ++iPage) 60802c50d82SAndre Fischer { 60902c50d82SAndre Fischer if ((*iPage) == NULL) 61002c50d82SAndre Fischer continue; 61102c50d82SAndre Fischer 61202c50d82SAndre Fischer // Call the SID_ASSIGN_LAYOUT slot with all the necessary parameters. 61302c50d82SAndre Fischer SfxRequest aRequest (mrBase.GetViewFrame(), SID_ASSIGN_LAYOUT); 61402c50d82SAndre Fischer aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATPAGE, ((*iPage)->GetPageNum()-1)/2)); 61502c50d82SAndre Fischer aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, aLayout)); 61602c50d82SAndre Fischer pMainViewShell->ExecuteSlot (aRequest, sal_Bool(sal_False)); 61702c50d82SAndre Fischer } 61802c50d82SAndre Fischer } 61902c50d82SAndre Fischer while(false); 62002c50d82SAndre Fischer } 62102c50d82SAndre Fischer 62202c50d82SAndre Fischer 62302c50d82SAndre Fischer 62402c50d82SAndre Fischer 62502c50d82SAndre Fischer SfxRequest LayoutMenu::CreateRequest ( 62602c50d82SAndre Fischer sal_uInt16 nSlotId, 62702c50d82SAndre Fischer AutoLayout aLayout) 62802c50d82SAndre Fischer { 62902c50d82SAndre Fischer SfxRequest aRequest (mrBase.GetViewFrame(), nSlotId); 63002c50d82SAndre Fischer 63102c50d82SAndre Fischer do 63202c50d82SAndre Fischer { 63302c50d82SAndre Fischer SdrLayerAdmin& rLayerAdmin (mrBase.GetDocument()->GetLayerAdmin()); 63402c50d82SAndre Fischer sal_uInt8 aBackground (rLayerAdmin.GetLayerID( 63502c50d82SAndre Fischer String(SdResId(STR_LAYER_BCKGRND)), sal_False)); 63602c50d82SAndre Fischer sal_uInt8 aBackgroundObject (rLayerAdmin.GetLayerID( 63702c50d82SAndre Fischer String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False)); 63802c50d82SAndre Fischer ViewShell* pViewShell = mrBase.GetMainViewShell().get(); 63902c50d82SAndre Fischer if (pViewShell == NULL) 64002c50d82SAndre Fischer break; 64102c50d82SAndre Fischer SdPage* pPage = pViewShell->GetActualPage(); 64202c50d82SAndre Fischer if (pPage == NULL) 64302c50d82SAndre Fischer break; 64402c50d82SAndre Fischer 64502c50d82SAndre Fischer SetOfByte aVisibleLayers (pPage->TRG_GetMasterPageVisibleLayers()); 64602c50d82SAndre Fischer 64702c50d82SAndre Fischer aRequest.AppendItem( 64802c50d82SAndre Fischer SfxStringItem (ID_VAL_PAGENAME, String()));//pPage->GetName())); 64902c50d82SAndre Fischer aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, aLayout)); 65002c50d82SAndre Fischer aRequest.AppendItem( 65102c50d82SAndre Fischer SfxBoolItem(ID_VAL_ISPAGEBACK, aVisibleLayers.IsSet(aBackground))); 65202c50d82SAndre Fischer aRequest.AppendItem( 65302c50d82SAndre Fischer SfxBoolItem( 65402c50d82SAndre Fischer ID_VAL_ISPAGEOBJ, 65502c50d82SAndre Fischer aVisibleLayers.IsSet(aBackgroundObject))); 65602c50d82SAndre Fischer } 65702c50d82SAndre Fischer while (false); 65802c50d82SAndre Fischer 65902c50d82SAndre Fischer return aRequest; 66002c50d82SAndre Fischer } 66102c50d82SAndre Fischer 66202c50d82SAndre Fischer 66302c50d82SAndre Fischer 66402c50d82SAndre Fischer 66502c50d82SAndre Fischer void LayoutMenu::Fill (void) 66602c50d82SAndre Fischer { 66702c50d82SAndre Fischer const bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode(); 66802c50d82SAndre Fischer SvtLanguageOptions aLanguageOptions; 66902c50d82SAndre Fischer sal_Bool bVertical = aLanguageOptions.IsVerticalTextEnabled(); 67002c50d82SAndre Fischer SdDrawDocument* pDocument = mrBase.GetDocument(); 67102c50d82SAndre Fischer sal_Bool bRightToLeft = (pDocument!=NULL 67202c50d82SAndre Fischer && pDocument->GetDefaultWritingMode() == WritingMode_RL_TB); 67302c50d82SAndre Fischer 67402c50d82SAndre Fischer // Get URL of the view in the center pane. 67502c50d82SAndre Fischer ::rtl::OUString sCenterPaneViewName; 67602c50d82SAndre Fischer try 67702c50d82SAndre Fischer { 67802c50d82SAndre Fischer Reference<XControllerManager> xControllerManager ( 67902c50d82SAndre Fischer Reference<XWeak>(&mrBase.GetDrawController()), UNO_QUERY_THROW); 68002c50d82SAndre Fischer Reference<XResourceId> xPaneId (ResourceId::create( 68102c50d82SAndre Fischer ::comphelper::getProcessComponentContext(), 68202c50d82SAndre Fischer FrameworkHelper::msCenterPaneURL)); 68302c50d82SAndre Fischer Reference<XView> xView (FrameworkHelper::Instance(mrBase)->GetView(xPaneId)); 68402c50d82SAndre Fischer if (xView.is()) 68502c50d82SAndre Fischer sCenterPaneViewName = xView->getResourceId()->getResourceURL(); 68602c50d82SAndre Fischer } 68702c50d82SAndre Fischer catch (RuntimeException&) 68802c50d82SAndre Fischer {} 68902c50d82SAndre Fischer 69002c50d82SAndre Fischer snewfoil_value_info* pInfo = NULL; 69102c50d82SAndre Fischer if (sCenterPaneViewName.equals(framework::FrameworkHelper::msNotesViewURL)) 69202c50d82SAndre Fischer { 69302c50d82SAndre Fischer pInfo = notes; 69402c50d82SAndre Fischer } 69502c50d82SAndre Fischer else if (sCenterPaneViewName.equals(framework::FrameworkHelper::msHandoutViewURL)) 69602c50d82SAndre Fischer { 69702c50d82SAndre Fischer pInfo = handout; 69802c50d82SAndre Fischer } 69902c50d82SAndre Fischer else if (sCenterPaneViewName.equals(framework::FrameworkHelper::msImpressViewURL) 70002c50d82SAndre Fischer || sCenterPaneViewName.equals(framework::FrameworkHelper::msSlideSorterURL)) 70102c50d82SAndre Fischer { 70202c50d82SAndre Fischer pInfo = standard; 70302c50d82SAndre Fischer } 70402c50d82SAndre Fischer else 70502c50d82SAndre Fischer { 70602c50d82SAndre Fischer pInfo = NULL; 70702c50d82SAndre Fischer } 70802c50d82SAndre Fischer 70902c50d82SAndre Fischer Clear(); 71002c50d82SAndre Fischer int n = 0; 71102c50d82SAndre Fischer for (sal_uInt16 i=1; pInfo!=NULL&&pInfo->mnBmpResId!=0; i++,pInfo++) 71202c50d82SAndre Fischer { 71302c50d82SAndre Fischer if ((WritingMode_TB_RL != pInfo->meWritingMode) || bVertical) 71402c50d82SAndre Fischer { 71502c50d82SAndre Fischer BitmapEx aBmp (SdResId (bHighContrast 71602c50d82SAndre Fischer ? pInfo->mnHCBmpResId 71702c50d82SAndre Fischer : pInfo->mnBmpResId)); 71802c50d82SAndre Fischer 71902c50d82SAndre Fischer if (bRightToLeft && (WritingMode_TB_RL != pInfo->meWritingMode)) 72002c50d82SAndre Fischer aBmp.Mirror (BMP_MIRROR_HORZ); 72102c50d82SAndre Fischer 72202c50d82SAndre Fischer InsertItem (i, aBmp, String (SdResId (pInfo->mnStrResId))); 72302c50d82SAndre Fischer SetItemData (i, new AutoLayout(pInfo->maAutoLayout)); 72402c50d82SAndre Fischer n++; 72502c50d82SAndre Fischer } 72602c50d82SAndre Fischer } 72702c50d82SAndre Fischer 72802c50d82SAndre Fischer mbSelectionUpdatePending = true; 72902c50d82SAndre Fischer } 73002c50d82SAndre Fischer 73102c50d82SAndre Fischer 73202c50d82SAndre Fischer 73302c50d82SAndre Fischer 73402c50d82SAndre Fischer void LayoutMenu::Clear (void) 73502c50d82SAndre Fischer { 73602c50d82SAndre Fischer for (sal_uInt16 nId=1; nId<=GetItemCount(); nId++) 73702c50d82SAndre Fischer delete static_cast<AutoLayout*>(GetItemData(nId)); 73802c50d82SAndre Fischer ValueSet::Clear(); 73902c50d82SAndre Fischer } 74002c50d82SAndre Fischer 74102c50d82SAndre Fischer 74202c50d82SAndre Fischer 74302c50d82SAndre Fischer void LayoutMenu::StartDrag (sal_Int8 , const Point& ) 74402c50d82SAndre Fischer { 74502c50d82SAndre Fischer } 74602c50d82SAndre Fischer 74702c50d82SAndre Fischer 74802c50d82SAndre Fischer 74902c50d82SAndre Fischer 75002c50d82SAndre Fischer sal_Int8 LayoutMenu::AcceptDrop (const AcceptDropEvent& ) 75102c50d82SAndre Fischer { 75202c50d82SAndre Fischer return 0; 75302c50d82SAndre Fischer } 75402c50d82SAndre Fischer 75502c50d82SAndre Fischer 75602c50d82SAndre Fischer 75702c50d82SAndre Fischer 75802c50d82SAndre Fischer sal_Int8 LayoutMenu::ExecuteDrop (const ExecuteDropEvent& ) 75902c50d82SAndre Fischer { 76002c50d82SAndre Fischer return 0; 76102c50d82SAndre Fischer } 76202c50d82SAndre Fischer 76302c50d82SAndre Fischer 76402c50d82SAndre Fischer 76502c50d82SAndre Fischer 76602c50d82SAndre Fischer void LayoutMenu::Command (const CommandEvent& rEvent) 76702c50d82SAndre Fischer { 76802c50d82SAndre Fischer switch (rEvent.GetCommand()) 76902c50d82SAndre Fischer { 77002c50d82SAndre Fischer case COMMAND_CONTEXTMENU: 77102c50d82SAndre Fischer if ( ! SD_MOD()->GetWaterCan()) 77202c50d82SAndre Fischer { 77302c50d82SAndre Fischer // Determine the position where to show the menu. 77402c50d82SAndre Fischer Point aMenuPosition; 77502c50d82SAndre Fischer if (rEvent.IsMouseEvent()) 77602c50d82SAndre Fischer { 77702c50d82SAndre Fischer if (GetItemId(rEvent.GetMousePosPixel()) <= 0) 77802c50d82SAndre Fischer return; 77902c50d82SAndre Fischer aMenuPosition = rEvent.GetMousePosPixel(); 78002c50d82SAndre Fischer } 78102c50d82SAndre Fischer else 78202c50d82SAndre Fischer { 78302c50d82SAndre Fischer if (GetSelectItemId() == (sal_uInt16)-1) 78402c50d82SAndre Fischer return; 78502c50d82SAndre Fischer Rectangle aBBox (GetItemRect(GetSelectItemId())); 78602c50d82SAndre Fischer aMenuPosition = aBBox.Center(); 78702c50d82SAndre 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); 80702c50d82SAndre Fischer } 80802c50d82SAndre Fischer break; 80902c50d82SAndre Fischer 81002c50d82SAndre Fischer default: 81102c50d82SAndre Fischer ValueSet::Command(rEvent); 81202c50d82SAndre Fischer break; 81302c50d82SAndre Fischer } 81402c50d82SAndre Fischer } 81502c50d82SAndre Fischer 81602c50d82SAndre Fischer 81702c50d82SAndre Fischer 81802c50d82SAndre Fischer 81902c50d82SAndre Fischer IMPL_LINK(LayoutMenu, StateChangeHandler, ::rtl::OUString*, EMPTYARG) 82002c50d82SAndre Fischer { 82102c50d82SAndre Fischer InvalidateContent(); 82202c50d82SAndre Fischer return 0; 82302c50d82SAndre Fischer } 82402c50d82SAndre Fischer 82502c50d82SAndre Fischer 82602c50d82SAndre Fischer 82702c50d82SAndre 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 85602c50d82SAndre Fischer void LayoutMenu::UpdateSelection (void) 85702c50d82SAndre Fischer { 85802c50d82SAndre Fischer bool bItemSelected = false; 85902c50d82SAndre Fischer 86002c50d82SAndre Fischer do 86102c50d82SAndre Fischer { 86202c50d82SAndre Fischer // Get current page of main view. 86302c50d82SAndre Fischer ViewShell* pViewShell = mrBase.GetMainViewShell().get(); 86402c50d82SAndre Fischer if (pViewShell == NULL) 86502c50d82SAndre Fischer break; 86602c50d82SAndre Fischer 86702c50d82SAndre Fischer SdPage* pCurrentPage = pViewShell->getCurrentPage(); 86802c50d82SAndre Fischer if (pCurrentPage == NULL) 86902c50d82SAndre Fischer break; 87002c50d82SAndre Fischer 87102c50d82SAndre Fischer // Get layout of current page. 87202c50d82SAndre Fischer AutoLayout aLayout (pCurrentPage->GetAutoLayout()); 87302c50d82SAndre Fischer if (aLayout<AUTOLAYOUT__START || aLayout>AUTOLAYOUT__END) 87402c50d82SAndre Fischer break; 87502c50d82SAndre Fischer 87602c50d82SAndre Fischer // Find the entry of the menu for to the layout. 87702c50d82SAndre Fischer sal_uInt16 nItemCount (GetItemCount()); 87802c50d82SAndre Fischer for (sal_uInt16 nId=1; nId<=nItemCount; nId++) 87902c50d82SAndre Fischer { 88002c50d82SAndre Fischer if (*static_cast<AutoLayout*>(GetItemData(nId)) == aLayout) 88102c50d82SAndre Fischer { 88202c50d82SAndre Fischer SelectItem(nId); 88302c50d82SAndre Fischer bItemSelected = true; 88402c50d82SAndre Fischer break; 88502c50d82SAndre Fischer } 88602c50d82SAndre Fischer } 88702c50d82SAndre Fischer } 88802c50d82SAndre Fischer while (false); 88902c50d82SAndre Fischer 89002c50d82SAndre Fischer if ( ! bItemSelected) 89102c50d82SAndre Fischer SetNoSelection(); 89202c50d82SAndre Fischer } 89302c50d82SAndre Fischer 89402c50d82SAndre Fischer 89502c50d82SAndre Fischer 89602c50d82SAndre Fischer 89702c50d82SAndre Fischer IMPL_LINK(LayoutMenu, EventMultiplexerListener, ::sd::tools::EventMultiplexerEvent*, pEvent) 89802c50d82SAndre Fischer { 89902c50d82SAndre Fischer switch (pEvent->meEventId) 90002c50d82SAndre Fischer { 90102c50d82SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_CURRENT_PAGE: 90202c50d82SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_SLIDE_SORTER_SELECTION: 90302c50d82SAndre Fischer if ( ! mbSelectionUpdatePending) 90402c50d82SAndre Fischer UpdateSelection(); 90502c50d82SAndre Fischer break; 90602c50d82SAndre Fischer 90702c50d82SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED: 90802c50d82SAndre Fischer mbIsMainViewChangePending = true; 90902c50d82SAndre Fischer UpdateEnabledState(MM_UNKNOWN); 91002c50d82SAndre Fischer break; 91102c50d82SAndre Fischer 91202c50d82SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED: 91302c50d82SAndre Fischer HideFocus(); 91402c50d82SAndre Fischer break; 91502c50d82SAndre Fischer 91602c50d82SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED: 91702c50d82SAndre Fischer if (mbIsMainViewChangePending) 91802c50d82SAndre Fischer { 91902c50d82SAndre Fischer mbIsMainViewChangePending = false; 92002c50d82SAndre Fischer InvalidateContent(); 92102c50d82SAndre Fischer } 92202c50d82SAndre Fischer break; 92302c50d82SAndre Fischer 92402c50d82SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_NORMAL: 92502c50d82SAndre Fischer UpdateEnabledState(MM_NORMAL); 92602c50d82SAndre Fischer break; 92702c50d82SAndre Fischer 92802c50d82SAndre Fischer case ::sd::tools::EventMultiplexerEvent::EID_EDIT_MODE_MASTER: 92902c50d82SAndre Fischer UpdateEnabledState(MM_MASTER); 93002c50d82SAndre Fischer break; 93102c50d82SAndre Fischer 93202c50d82SAndre Fischer default: 93302c50d82SAndre Fischer /* Ignored */ 93402c50d82SAndre Fischer break; 93502c50d82SAndre Fischer } 93602c50d82SAndre Fischer 93702c50d82SAndre Fischer return 0; 93802c50d82SAndre Fischer } 93902c50d82SAndre Fischer 94002c50d82SAndre Fischer 94102c50d82SAndre Fischer 94202c50d82SAndre Fischer 94302c50d82SAndre Fischer IMPL_LINK(LayoutMenu, WindowEventHandler, VclWindowEvent*, pEvent) 94402c50d82SAndre Fischer { 94502c50d82SAndre Fischer if (pEvent != NULL) 94602c50d82SAndre Fischer { 94702c50d82SAndre Fischer switch (pEvent->GetId()) 94802c50d82SAndre Fischer { 94902c50d82SAndre Fischer case VCLEVENT_WINDOW_SHOW: 95002c50d82SAndre Fischer case VCLEVENT_WINDOW_RESIZE: 95102c50d82SAndre Fischer SetSizePixel(GetParent()->GetSizePixel()); 95202c50d82SAndre Fischer return sal_True; 95302c50d82SAndre Fischer 95402c50d82SAndre Fischer default: 95502c50d82SAndre Fischer return sal_False; 95602c50d82SAndre Fischer } 95702c50d82SAndre Fischer 95802c50d82SAndre Fischer const SfxSimpleHint* pSimpleHint = PTR_CAST(SfxSimpleHint, pEvent); 95902c50d82SAndre Fischer if (pSimpleHint != NULL 96002c50d82SAndre Fischer && pSimpleHint->GetId() == SFX_HINT_DYING) 96102c50d82SAndre Fischer { 96202c50d82SAndre Fischer return sal_True; 96302c50d82SAndre Fischer } 96402c50d82SAndre Fischer } 96502c50d82SAndre Fischer 96602c50d82SAndre Fischer return sal_False; 96702c50d82SAndre Fischer } 96802c50d82SAndre Fischer 96902c50d82SAndre Fischer 97002c50d82SAndre Fischer 97102c50d82SAndre Fischer 97202c50d82SAndre Fischer void LayoutMenu::DataChanged (const DataChangedEvent& rEvent) 97302c50d82SAndre Fischer { 97402c50d82SAndre Fischer Fill(); 97502c50d82SAndre 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)); 97802c50d82SAndre Fischer } 97902c50d82SAndre Fischer 98002c50d82SAndre Fischer 98102c50d82SAndre Fischer 98202c50d82SAndre Fischer 98302c50d82SAndre Fischer 98402c50d82SAndre Fischer } } // end of namespace ::sd::sidebar 985