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 "MasterPagesSelector.hxx" 2502c50d82SAndre Fischer 2602c50d82SAndre Fischer #include "MasterPageContainer.hxx" 2702c50d82SAndre Fischer #include "DocumentHelper.hxx" 2802c50d82SAndre Fischer #include "SidebarShellManager.hxx" 2902c50d82SAndre Fischer #include "pres.hxx" 3002c50d82SAndre Fischer #include "drawdoc.hxx" 3102c50d82SAndre Fischer #include "DrawDocShell.hxx" 3202c50d82SAndre Fischer #include "sdpage.hxx" 3302c50d82SAndre Fischer #include "glob.hxx" 3402c50d82SAndre Fischer #include "glob.hrc" 3502c50d82SAndre Fischer #include "app.hrc" 3602c50d82SAndre Fischer #include "res_bmp.hrc" 3702c50d82SAndre Fischer #include "strings.hrc" 3802c50d82SAndre Fischer #include "DrawViewShell.hxx" 3902c50d82SAndre Fischer #include "DrawController.hxx" 4002c50d82SAndre Fischer #include "SlideSorterViewShell.hxx" 4102c50d82SAndre Fischer #include "PreviewValueSet.hxx" 4202c50d82SAndre Fischer #include "ViewShellBase.hxx" 4302c50d82SAndre Fischer #include <sfx2/objface.hxx> 4402c50d82SAndre Fischer #include "sdresid.hxx" 4502c50d82SAndre Fischer #include "drawview.hxx" 4602c50d82SAndre Fischer #include <vcl/image.hxx> 4702c50d82SAndre Fischer #include <vcl/floatwin.hxx> 4802c50d82SAndre Fischer #include <svl/languageoptions.hxx> 4902c50d82SAndre Fischer #include <sfx2/app.hxx> 5002c50d82SAndre Fischer #include <sfx2/dispatch.hxx> 5102c50d82SAndre Fischer #include <sfx2/mnumgr.hxx> 5202c50d82SAndre Fischer #include <svl/itemset.hxx> 5302c50d82SAndre Fischer #include <svl/eitem.hxx> 5402c50d82SAndre Fischer #include <svx/dlgutil.hxx> 5502c50d82SAndre Fischer #include <svx/svdpagv.hxx> 5602c50d82SAndre Fischer #include <svx/svxids.hrc> 5702c50d82SAndre Fischer #include "FrameView.hxx" 5802c50d82SAndre Fischer #include "sdpage.hxx" 5902c50d82SAndre Fischer #include "stlpool.hxx" 6002c50d82SAndre Fischer #include "unmovss.hxx" 6102c50d82SAndre Fischer #include <sfx2/request.hxx> 6202c50d82SAndre Fischer #include <svl/itempool.hxx> 63*37fee4fdSAndre Fischer #include <sfx2/sidebar/Theme.hxx> 6402c50d82SAndre Fischer 6502c50d82SAndre Fischer 6602c50d82SAndre Fischer using namespace ::com::sun::star::text; 6702c50d82SAndre Fischer 6802c50d82SAndre Fischer 6902c50d82SAndre Fischer 7002c50d82SAndre Fischer namespace sd { namespace sidebar { 7102c50d82SAndre Fischer 7202c50d82SAndre Fischer 7302c50d82SAndre Fischer MasterPagesSelector::MasterPagesSelector ( 7402c50d82SAndre Fischer ::Window* pParent, 7502c50d82SAndre Fischer SdDrawDocument& rDocument, 7602c50d82SAndre Fischer ViewShellBase& rBase, 7702c50d82SAndre Fischer const ::boost::shared_ptr<MasterPageContainer>& rpContainer, 7802c50d82SAndre Fischer const cssu::Reference<css::ui::XSidebar>& rxSidebar) 7902c50d82SAndre Fischer : PreviewValueSet(pParent), 8002c50d82SAndre Fischer maMutex(), 8102c50d82SAndre Fischer mpContainer(rpContainer), 8202c50d82SAndre Fischer mrDocument(rDocument), 8302c50d82SAndre Fischer mrBase(rBase), 8402c50d82SAndre Fischer mnDefaultClickAction(SID_TP_APPLY_TO_ALL_SLIDES), 8502c50d82SAndre Fischer maPreviewUpdateQueue(), 8602c50d82SAndre Fischer maCurrentItemList(), 8702c50d82SAndre Fischer maTokenToValueSetIndex(), 8802c50d82SAndre Fischer maLockedMasterPages(), 8902c50d82SAndre Fischer mxSidebar(rxSidebar) 9002c50d82SAndre Fischer { 9102c50d82SAndre Fischer PreviewValueSet::SetSelectHdl ( 9202c50d82SAndre Fischer LINK(this, MasterPagesSelector, ClickHandler)); 9302c50d82SAndre Fischer PreviewValueSet::SetRightMouseClickHandler ( 9402c50d82SAndre Fischer LINK(this, MasterPagesSelector, RightClickHandler)); 9502c50d82SAndre Fischer PreviewValueSet::SetStyle(PreviewValueSet::GetStyle() | WB_NO_DIRECTSELECT); 9602c50d82SAndre Fischer PreviewValueSet::SetPreviewSize(mpContainer->GetPreviewSizePixel()); 9702c50d82SAndre Fischer PreviewValueSet::Show(); 9802c50d82SAndre Fischer 99*37fee4fdSAndre Fischer SetBackground(sfx2::sidebar::Theme::GetWallpaper(sfx2::sidebar::Theme::Paint_PanelBackground)); 100*37fee4fdSAndre Fischer SetColor(sfx2::sidebar::Theme::GetColor(sfx2::sidebar::Theme::Paint_PanelBackground)); 101*37fee4fdSAndre Fischer 10202c50d82SAndre Fischer Link aChangeListener (LINK(this,MasterPagesSelector,ContainerChangeListener)); 10302c50d82SAndre Fischer mpContainer->AddChangeListener(aChangeListener); 10402c50d82SAndre Fischer } 10502c50d82SAndre Fischer 10602c50d82SAndre Fischer 10702c50d82SAndre Fischer 10802c50d82SAndre Fischer 10902c50d82SAndre Fischer MasterPagesSelector::~MasterPagesSelector (void) 11002c50d82SAndre Fischer { 11102c50d82SAndre Fischer Clear(); 11202c50d82SAndre Fischer UpdateLocks(ItemList()); 11302c50d82SAndre Fischer 11402c50d82SAndre Fischer Link aChangeListener (LINK(this,MasterPagesSelector,ContainerChangeListener)); 11502c50d82SAndre Fischer mpContainer->RemoveChangeListener(aChangeListener); 11602c50d82SAndre Fischer } 11702c50d82SAndre Fischer 11802c50d82SAndre Fischer 11902c50d82SAndre Fischer 12002c50d82SAndre Fischer 12102c50d82SAndre Fischer void MasterPagesSelector::LateInit (void) 12202c50d82SAndre Fischer { 12302c50d82SAndre Fischer } 12402c50d82SAndre Fischer 12502c50d82SAndre Fischer 12602c50d82SAndre Fischer 12702c50d82SAndre Fischer 12802c50d82SAndre Fischer sal_Int32 MasterPagesSelector::GetPreferredWidth (sal_Int32 nHeight) 12902c50d82SAndre Fischer { 13002c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 13102c50d82SAndre Fischer 13202c50d82SAndre Fischer return PreviewValueSet::GetPreferredWidth (nHeight); 13302c50d82SAndre Fischer } 13402c50d82SAndre Fischer 13502c50d82SAndre Fischer 13602c50d82SAndre Fischer 13702c50d82SAndre Fischer 13802c50d82SAndre Fischer sal_Int32 MasterPagesSelector::GetPreferredHeight (sal_Int32 nWidth) 13902c50d82SAndre Fischer { 14002c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 14102c50d82SAndre Fischer 14202c50d82SAndre Fischer return PreviewValueSet::GetPreferredHeight (nWidth); 14302c50d82SAndre Fischer } 14402c50d82SAndre Fischer 14502c50d82SAndre Fischer 14602c50d82SAndre Fischer 14702c50d82SAndre Fischer 14802c50d82SAndre Fischer Size MasterPagesSelector::GetPreferredSize (void) 14902c50d82SAndre Fischer { 15002c50d82SAndre Fischer int nPreferredWidth = GetPreferredWidth( 15102c50d82SAndre Fischer PreviewValueSet::GetOutputSizePixel().Height()); 15202c50d82SAndre Fischer int nPreferredHeight = GetPreferredHeight(nPreferredWidth); 15302c50d82SAndre Fischer return Size (nPreferredWidth, nPreferredHeight); 15402c50d82SAndre Fischer 15502c50d82SAndre Fischer } 15602c50d82SAndre Fischer 15702c50d82SAndre Fischer 15802c50d82SAndre Fischer 15902c50d82SAndre Fischer 16002c50d82SAndre Fischer void MasterPagesSelector::UpdateLocks (const ItemList& rItemList) 16102c50d82SAndre Fischer { 16202c50d82SAndre Fischer ItemList aNewLockList; 16302c50d82SAndre Fischer 16402c50d82SAndre Fischer // In here we first lock the master pages in the given list and then 16502c50d82SAndre Fischer // release the locks acquired in a previous call to this method. When 16602c50d82SAndre Fischer // this were done the other way round the lock count of some master 16702c50d82SAndre Fischer // pages might drop temporarily to 0 and would lead to unnecessary 16802c50d82SAndre Fischer // deletion and re-creation of MasterPageDescriptor objects. 16902c50d82SAndre Fischer 17002c50d82SAndre Fischer // Lock the master pages in the given list. 17102c50d82SAndre Fischer ItemList::const_iterator iItem; 17202c50d82SAndre Fischer for (iItem=rItemList.begin(); iItem!=rItemList.end(); ++iItem) 17302c50d82SAndre Fischer { 17402c50d82SAndre Fischer mpContainer->AcquireToken(*iItem); 17502c50d82SAndre Fischer aNewLockList.push_back(*iItem); 17602c50d82SAndre Fischer } 17702c50d82SAndre Fischer 17802c50d82SAndre Fischer // Release the previously locked master pages. 17902c50d82SAndre Fischer ItemList::const_iterator iPage; 18002c50d82SAndre Fischer ItemList::const_iterator iEnd (maLockedMasterPages.end()); 18102c50d82SAndre Fischer for (iPage=maLockedMasterPages.begin(); iPage!=iEnd; ++iPage) 18202c50d82SAndre Fischer mpContainer->ReleaseToken(*iPage); 18302c50d82SAndre Fischer 18402c50d82SAndre Fischer maLockedMasterPages.swap(aNewLockList); 18502c50d82SAndre Fischer } 18602c50d82SAndre Fischer 18702c50d82SAndre Fischer 18802c50d82SAndre Fischer 18902c50d82SAndre Fischer 19002c50d82SAndre Fischer void MasterPagesSelector::Fill (void) 19102c50d82SAndre Fischer { 19202c50d82SAndre Fischer ::std::auto_ptr<ItemList> pItemList (new ItemList()); 19302c50d82SAndre Fischer 19402c50d82SAndre Fischer Fill(*pItemList); 19502c50d82SAndre Fischer 19602c50d82SAndre Fischer UpdateLocks(*pItemList); 19702c50d82SAndre Fischer UpdateItemList(pItemList); 19802c50d82SAndre Fischer } 19902c50d82SAndre Fischer 20002c50d82SAndre Fischer 20102c50d82SAndre Fischer 20202c50d82SAndre Fischer 20302c50d82SAndre Fischer ResId MasterPagesSelector::GetContextMenuResId (void) const 20402c50d82SAndre Fischer { 20502c50d82SAndre Fischer return SdResId(RID_TASKPANE_MASTERPAGESSELECTOR_POPUP); 20602c50d82SAndre Fischer } 20702c50d82SAndre Fischer 20802c50d82SAndre Fischer 20902c50d82SAndre Fischer 21002c50d82SAndre Fischer 21102c50d82SAndre Fischer IMPL_LINK(MasterPagesSelector, ClickHandler, PreviewValueSet*, EMPTYARG) 21202c50d82SAndre Fischer { 21302c50d82SAndre Fischer // We use the framework to assign the clicked-on master page because we 21402c50d82SAndre Fischer // so use the same mechanism as the context menu does (where we do not 21502c50d82SAndre Fischer // have the option to call the assignment method directly.) 21602c50d82SAndre Fischer ExecuteCommand(mnDefaultClickAction); 21702c50d82SAndre Fischer 21802c50d82SAndre Fischer return 0; 21902c50d82SAndre Fischer } 22002c50d82SAndre Fischer 22102c50d82SAndre Fischer 22202c50d82SAndre Fischer 22302c50d82SAndre Fischer 22402c50d82SAndre Fischer IMPL_LINK(MasterPagesSelector, RightClickHandler, MouseEvent*, pEvent) 22502c50d82SAndre Fischer { 22602c50d82SAndre Fischer // Here we only prepare the display of the context menu: the item under 22702c50d82SAndre Fischer // the mouse is selected. The actual display of the context menu is 22802c50d82SAndre Fischer // done in ContextMenuCallback which is called indirectly through 22902c50d82SAndre Fischer // PreviewValueSet::Command(). 23002c50d82SAndre Fischer PreviewValueSet::GrabFocus (); 23102c50d82SAndre Fischer PreviewValueSet::ReleaseMouse(); 23202c50d82SAndre Fischer SfxViewFrame* pViewFrame = mrBase.GetViewFrame(); 23302c50d82SAndre Fischer if (pViewFrame != NULL) 23402c50d82SAndre Fischer { 23502c50d82SAndre Fischer SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher(); 23602c50d82SAndre Fischer if (pDispatcher != NULL && pEvent != NULL) 23702c50d82SAndre Fischer { 23802c50d82SAndre Fischer sal_uInt16 nIndex = PreviewValueSet::GetItemId (pEvent->GetPosPixel()); 23902c50d82SAndre Fischer if (nIndex > 0) 24002c50d82SAndre Fischer PreviewValueSet::SelectItem (nIndex); 24102c50d82SAndre Fischer } 24202c50d82SAndre Fischer } 24302c50d82SAndre Fischer return 0; 24402c50d82SAndre Fischer } 24502c50d82SAndre Fischer 24602c50d82SAndre Fischer 24702c50d82SAndre Fischer 24802c50d82SAndre Fischer 24902c50d82SAndre Fischer void MasterPagesSelector::Command (const CommandEvent& rEvent) 25002c50d82SAndre Fischer { 25102c50d82SAndre Fischer switch (rEvent.GetCommand()) 25202c50d82SAndre Fischer { 25302c50d82SAndre Fischer case COMMAND_CONTEXTMENU: 25402c50d82SAndre Fischer { 25502c50d82SAndre Fischer // Use the currently selected item and show the popup menu in its 25602c50d82SAndre Fischer // center. 25702c50d82SAndre Fischer const sal_uInt16 nIndex = PreviewValueSet::GetSelectItemId(); 25802c50d82SAndre Fischer if (nIndex > 0) 25902c50d82SAndre Fischer { 26002c50d82SAndre Fischer // The position of the upper left corner of the context menu is 26102c50d82SAndre Fischer // taken either from the mouse position (when the command was sent 26202c50d82SAndre Fischer // as reaction to a right click) or in the center of the selected 26302c50d82SAndre Fischer // item (when the command was sent as reaction to Shift+F10.) 26402c50d82SAndre Fischer Point aPosition (rEvent.GetMousePosPixel()); 26502c50d82SAndre Fischer if ( ! rEvent.IsMouseEvent()) 26602c50d82SAndre Fischer { 26702c50d82SAndre Fischer Rectangle aBBox (PreviewValueSet::GetItemRect(nIndex)); 26802c50d82SAndre Fischer aPosition = aBBox.Center(); 26902c50d82SAndre Fischer } 27002c50d82SAndre Fischer 27102c50d82SAndre Fischer // Setup the menu. 27202c50d82SAndre Fischer ::boost::scoped_ptr<PopupMenu> pMenu (new PopupMenu(GetContextMenuResId())); 27302c50d82SAndre Fischer FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow()); 27402c50d82SAndre Fischer if (pMenuWindow != NULL) 27502c50d82SAndre Fischer pMenuWindow->SetPopupModeFlags( 27602c50d82SAndre Fischer pMenuWindow->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE); 27702c50d82SAndre Fischer pMenu->SetSelectHdl(LINK(this, MasterPagesSelector, OnMenuItemSelected)); 27802c50d82SAndre Fischer 27902c50d82SAndre Fischer ProcessPopupMenu(*pMenu); 28002c50d82SAndre Fischer 28102c50d82SAndre Fischer // Show the menu. 28202c50d82SAndre Fischer pMenu->Execute(this, Rectangle(aPosition,Size(1,1)), POPUPMENU_EXECUTE_DOWN); 28302c50d82SAndre Fischer } 28402c50d82SAndre Fischer break; 28502c50d82SAndre Fischer } 28602c50d82SAndre Fischer } 28702c50d82SAndre Fischer } 28802c50d82SAndre Fischer 28902c50d82SAndre Fischer 29002c50d82SAndre Fischer 29102c50d82SAndre Fischer 29202c50d82SAndre Fischer void MasterPagesSelector::ProcessPopupMenu (Menu& rMenu) 29302c50d82SAndre Fischer { 29402c50d82SAndre Fischer // Disable some entries. 29502c50d82SAndre Fischer if (mpContainer->GetPreviewSize() == MasterPageContainer::SMALL) 29602c50d82SAndre Fischer rMenu.EnableItem(SID_TP_SHOW_SMALL_PREVIEW, sal_False); 29702c50d82SAndre Fischer else 29802c50d82SAndre Fischer rMenu.EnableItem(SID_TP_SHOW_LARGE_PREVIEW, sal_False); 29902c50d82SAndre Fischer } 30002c50d82SAndre Fischer 30102c50d82SAndre Fischer 30202c50d82SAndre Fischer 30302c50d82SAndre Fischer 30402c50d82SAndre Fischer IMPL_LINK(MasterPagesSelector, OnMenuItemSelected, Menu*, pMenu) 30502c50d82SAndre Fischer { 30602c50d82SAndre Fischer if (pMenu == NULL) 30702c50d82SAndre Fischer { 30802c50d82SAndre Fischer OSL_ENSURE(pMenu!=NULL, "MasterPagesSelector::OnMenuItemSelected: illegal menu!"); 30902c50d82SAndre Fischer return 0; 31002c50d82SAndre Fischer } 31102c50d82SAndre Fischer 31202c50d82SAndre Fischer pMenu->Deactivate(); 31302c50d82SAndre Fischer ExecuteCommand(pMenu->GetCurItemId()); 31402c50d82SAndre Fischer return 0; 31502c50d82SAndre Fischer } 31602c50d82SAndre Fischer 31702c50d82SAndre Fischer 31802c50d82SAndre Fischer 31902c50d82SAndre Fischer 32002c50d82SAndre Fischer void MasterPagesSelector::ExecuteCommand (const sal_Int32 nCommandId) 32102c50d82SAndre Fischer { 32202c50d82SAndre Fischer switch (nCommandId) 32302c50d82SAndre Fischer { 32402c50d82SAndre Fischer case SID_TP_APPLY_TO_ALL_SLIDES: 32502c50d82SAndre Fischer mrBase.SetBusyState (true); 32602c50d82SAndre Fischer AssignMasterPageToAllSlides (GetSelectedMasterPage()); 32702c50d82SAndre Fischer mrBase.SetBusyState (false); 32802c50d82SAndre Fischer break; 32902c50d82SAndre Fischer 33002c50d82SAndre Fischer case SID_TP_APPLY_TO_SELECTED_SLIDES: 33102c50d82SAndre Fischer mrBase.SetBusyState (true); 33202c50d82SAndre Fischer AssignMasterPageToSelectedSlides (GetSelectedMasterPage()); 33302c50d82SAndre Fischer mrBase.SetBusyState (false); 33402c50d82SAndre Fischer break; 33502c50d82SAndre Fischer 33602c50d82SAndre Fischer case SID_TP_USE_FOR_NEW_PRESENTATIONS: 33702c50d82SAndre Fischer DBG_ASSERT (false, 33802c50d82SAndre Fischer "Using slides as default for new presentations" 33902c50d82SAndre Fischer " is not yet implemented"); 34002c50d82SAndre Fischer break; 34102c50d82SAndre Fischer 34202c50d82SAndre Fischer case SID_TP_SHOW_SMALL_PREVIEW: 34302c50d82SAndre Fischer case SID_TP_SHOW_LARGE_PREVIEW: 34402c50d82SAndre Fischer { 34502c50d82SAndre Fischer mrBase.SetBusyState (true); 34602c50d82SAndre Fischer mpContainer->SetPreviewSize( 34702c50d82SAndre Fischer nCommandId==SID_TP_SHOW_SMALL_PREVIEW 34802c50d82SAndre Fischer ? MasterPageContainer::SMALL 34902c50d82SAndre Fischer : MasterPageContainer::LARGE); 35002c50d82SAndre Fischer mrBase.SetBusyState (false); 35102c50d82SAndre Fischer if (mxSidebar.is()) 35202c50d82SAndre Fischer mxSidebar->requestLayout(); 35302c50d82SAndre Fischer break; 35402c50d82SAndre Fischer } 35502c50d82SAndre Fischer 35602c50d82SAndre Fischer case SID_TP_EDIT_MASTER: 35702c50d82SAndre Fischer { 35802c50d82SAndre Fischer using namespace ::com::sun::star; 35902c50d82SAndre Fischer uno::Reference<drawing::XDrawPage> xSelectedMaster ( 36002c50d82SAndre Fischer GetSelectedMasterPage()->getUnoPage(), uno::UNO_QUERY); 36102c50d82SAndre Fischer SfxViewFrame* pViewFrame = mrBase.GetViewFrame(); 36202c50d82SAndre Fischer if (pViewFrame != NULL && xSelectedMaster.is()) 36302c50d82SAndre Fischer { 36402c50d82SAndre Fischer SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher(); 36502c50d82SAndre Fischer if (pDispatcher != NULL) 36602c50d82SAndre Fischer { 36702c50d82SAndre Fischer sal_uInt16 nIndex = PreviewValueSet::GetSelectItemId(); 36802c50d82SAndre Fischer pDispatcher->Execute(SID_MASTERPAGE, SFX_CALLMODE_SYNCHRON); 36902c50d82SAndre Fischer PreviewValueSet::SelectItem (nIndex); 37002c50d82SAndre Fischer mrBase.GetDrawController().setCurrentPage(xSelectedMaster); 37102c50d82SAndre Fischer } 37202c50d82SAndre Fischer } 37302c50d82SAndre Fischer break; 37402c50d82SAndre Fischer } 37502c50d82SAndre Fischer 37602c50d82SAndre Fischer case SID_CUT: 37702c50d82SAndre Fischer case SID_COPY: 37802c50d82SAndre Fischer case SID_PASTE: 37902c50d82SAndre Fischer // Cut, copy, and paste are not supported and thus are ignored. 38002c50d82SAndre Fischer break; 38102c50d82SAndre Fischer } 38202c50d82SAndre Fischer } 38302c50d82SAndre Fischer 38402c50d82SAndre Fischer 38502c50d82SAndre Fischer 38602c50d82SAndre Fischer 38702c50d82SAndre Fischer IMPL_LINK(MasterPagesSelector, ContainerChangeListener, MasterPageContainerChangeEvent*, pEvent) 38802c50d82SAndre Fischer { 38902c50d82SAndre Fischer if (pEvent) 39002c50d82SAndre Fischer NotifyContainerChangeEvent(*pEvent); 39102c50d82SAndre Fischer return 0; 39202c50d82SAndre Fischer } 39302c50d82SAndre Fischer 39402c50d82SAndre Fischer 39502c50d82SAndre Fischer 39602c50d82SAndre Fischer 39702c50d82SAndre Fischer SdPage* MasterPagesSelector::GetSelectedMasterPage (void) 39802c50d82SAndre Fischer { 39902c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 40002c50d82SAndre Fischer 40102c50d82SAndre Fischer SdPage* pMasterPage = NULL; 40202c50d82SAndre Fischer sal_uInt16 nIndex = PreviewValueSet::GetSelectItemId(); 40302c50d82SAndre Fischer UserData* pData = GetUserData(nIndex); 40402c50d82SAndre Fischer if (pData != NULL) 40502c50d82SAndre Fischer { 40602c50d82SAndre Fischer pMasterPage = mpContainer->GetPageObjectForToken(pData->second); 40702c50d82SAndre Fischer } 40802c50d82SAndre Fischer return pMasterPage; 40902c50d82SAndre Fischer } 41002c50d82SAndre Fischer 41102c50d82SAndre Fischer 41202c50d82SAndre Fischer 41302c50d82SAndre Fischer 41402c50d82SAndre Fischer /** Assemble a list of all slides of the document and pass it to 41502c50d82SAndre Fischer AssignMasterPageToPageList(). 41602c50d82SAndre Fischer */ 41702c50d82SAndre Fischer void MasterPagesSelector::AssignMasterPageToAllSlides (SdPage* pMasterPage) 41802c50d82SAndre Fischer { 41902c50d82SAndre Fischer do 42002c50d82SAndre Fischer { 42102c50d82SAndre Fischer if (pMasterPage == NULL) 42202c50d82SAndre Fischer break; 42302c50d82SAndre Fischer 42402c50d82SAndre Fischer sal_uInt16 nPageCount = mrDocument.GetSdPageCount(PK_STANDARD); 42502c50d82SAndre Fischer if (nPageCount == 0) 42602c50d82SAndre Fischer break; 42702c50d82SAndre Fischer 42802c50d82SAndre Fischer // Get a list of all pages. As a little optimization we only 42902c50d82SAndre Fischer // include pages that do not already have the given master page 43002c50d82SAndre Fischer // assigned. 43102c50d82SAndre Fischer String sFullLayoutName (pMasterPage->GetLayoutName()); 43202c50d82SAndre Fischer ::sd::slidesorter::SharedPageSelection pPageList ( 43302c50d82SAndre Fischer new ::sd::slidesorter::SlideSorterViewShell::PageSelection()); 43402c50d82SAndre Fischer for (sal_uInt16 nPageIndex=0; nPageIndex<nPageCount; nPageIndex++) 43502c50d82SAndre Fischer { 43602c50d82SAndre Fischer SdPage* pPage = mrDocument.GetSdPage (nPageIndex, PK_STANDARD); 43702c50d82SAndre Fischer if (pPage != NULL 43802c50d82SAndre Fischer && pPage->GetLayoutName().CompareTo(sFullLayoutName)!=0) 43902c50d82SAndre Fischer { 44002c50d82SAndre Fischer pPageList->push_back (pPage); 44102c50d82SAndre Fischer } 44202c50d82SAndre Fischer } 44302c50d82SAndre Fischer 44402c50d82SAndre Fischer AssignMasterPageToPageList(pMasterPage, pPageList); 44502c50d82SAndre Fischer } 44602c50d82SAndre Fischer while (false); 44702c50d82SAndre Fischer } 44802c50d82SAndre Fischer 44902c50d82SAndre Fischer 45002c50d82SAndre Fischer 45102c50d82SAndre Fischer 45202c50d82SAndre Fischer /** Assemble a list of the currently selected slides (selected in a visible 45302c50d82SAndre Fischer slide sorter) and pass it to AssignMasterPageToPageList(). 45402c50d82SAndre Fischer */ 45502c50d82SAndre Fischer void MasterPagesSelector::AssignMasterPageToSelectedSlides ( 45602c50d82SAndre Fischer SdPage* pMasterPage) 45702c50d82SAndre Fischer { 45802c50d82SAndre Fischer do 45902c50d82SAndre Fischer { 46002c50d82SAndre Fischer using namespace ::std; 46102c50d82SAndre Fischer using namespace ::sd::slidesorter; 46202c50d82SAndre Fischer using namespace ::sd::slidesorter::controller; 46302c50d82SAndre Fischer 46402c50d82SAndre Fischer if (pMasterPage == NULL) 46502c50d82SAndre Fischer break; 46602c50d82SAndre Fischer 46702c50d82SAndre Fischer // Find a visible slide sorter. 46802c50d82SAndre Fischer SlideSorterViewShell* pSlideSorter = SlideSorterViewShell::GetSlideSorter(mrBase); 46902c50d82SAndre Fischer if (pSlideSorter == NULL) 47002c50d82SAndre Fischer break; 47102c50d82SAndre Fischer 47202c50d82SAndre Fischer // Get a list of selected pages. 47302c50d82SAndre Fischer ::sd::slidesorter::SharedPageSelection pPageSelection = pSlideSorter->GetPageSelection(); 47402c50d82SAndre Fischer if (pPageSelection->empty()) 47502c50d82SAndre Fischer break; 47602c50d82SAndre Fischer 47702c50d82SAndre Fischer AssignMasterPageToPageList(pMasterPage, pPageSelection); 47802c50d82SAndre Fischer 47902c50d82SAndre Fischer // Restore the previous selection. 48002c50d82SAndre Fischer pSlideSorter->SetPageSelection(pPageSelection); 48102c50d82SAndre Fischer } 48202c50d82SAndre Fischer while (false); 48302c50d82SAndre Fischer } 48402c50d82SAndre Fischer 48502c50d82SAndre Fischer 48602c50d82SAndre Fischer 48702c50d82SAndre Fischer 48802c50d82SAndre Fischer void MasterPagesSelector::AssignMasterPageToPageList ( 48902c50d82SAndre Fischer SdPage* pMasterPage, 49002c50d82SAndre Fischer const ::sd::slidesorter::SharedPageSelection& rPageList) 49102c50d82SAndre Fischer { 49202c50d82SAndre Fischer DocumentHelper::AssignMasterPageToPageList(mrDocument, pMasterPage, rPageList); 49302c50d82SAndre Fischer } 49402c50d82SAndre Fischer 49502c50d82SAndre Fischer 49602c50d82SAndre Fischer 49702c50d82SAndre Fischer 49802c50d82SAndre Fischer void MasterPagesSelector::NotifyContainerChangeEvent (const MasterPageContainerChangeEvent& rEvent) 49902c50d82SAndre Fischer { 50002c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 50102c50d82SAndre Fischer 50202c50d82SAndre Fischer switch (rEvent.meEventType) 50302c50d82SAndre Fischer { 50402c50d82SAndre Fischer case MasterPageContainerChangeEvent::SIZE_CHANGED: 50502c50d82SAndre Fischer PreviewValueSet::SetPreviewSize(mpContainer->GetPreviewSizePixel()); 50602c50d82SAndre Fischer UpdateAllPreviews(); 50702c50d82SAndre Fischer break; 50802c50d82SAndre Fischer 50902c50d82SAndre Fischer case MasterPageContainerChangeEvent::PREVIEW_CHANGED: 51002c50d82SAndre Fischer { 51102c50d82SAndre Fischer int nIndex (GetIndexForToken(rEvent.maChildToken)); 51202c50d82SAndre Fischer if (nIndex >= 0) 51302c50d82SAndre Fischer { 51402c50d82SAndre Fischer PreviewValueSet::SetItemImage ( 51502c50d82SAndre Fischer (sal_uInt16)nIndex, 51602c50d82SAndre Fischer mpContainer->GetPreviewForToken(rEvent.maChildToken)); 51702c50d82SAndre Fischer PreviewValueSet::Invalidate(PreviewValueSet::GetItemRect((sal_uInt16)nIndex)); 51802c50d82SAndre Fischer } 51902c50d82SAndre Fischer } 52002c50d82SAndre Fischer break; 52102c50d82SAndre Fischer 52202c50d82SAndre Fischer case MasterPageContainerChangeEvent::DATA_CHANGED: 52302c50d82SAndre Fischer { 52402c50d82SAndre Fischer InvalidateItem(rEvent.maChildToken); 52502c50d82SAndre Fischer Fill(); 52602c50d82SAndre Fischer } 52702c50d82SAndre Fischer break; 52802c50d82SAndre Fischer 52902c50d82SAndre Fischer default: 53002c50d82SAndre Fischer break; 53102c50d82SAndre Fischer } 53202c50d82SAndre Fischer } 53302c50d82SAndre Fischer 53402c50d82SAndre Fischer 53502c50d82SAndre Fischer 53602c50d82SAndre Fischer 53702c50d82SAndre Fischer MasterPagesSelector::UserData* MasterPagesSelector::CreateUserData ( 53802c50d82SAndre Fischer int nIndex, 53902c50d82SAndre Fischer MasterPageContainer::Token aToken) const 54002c50d82SAndre Fischer { 54102c50d82SAndre Fischer return new UserData(nIndex,aToken); 54202c50d82SAndre Fischer } 54302c50d82SAndre Fischer 54402c50d82SAndre Fischer 54502c50d82SAndre Fischer 54602c50d82SAndre Fischer 54702c50d82SAndre Fischer MasterPagesSelector::UserData* MasterPagesSelector::GetUserData (int nIndex) const 54802c50d82SAndre Fischer { 54902c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 55002c50d82SAndre Fischer 55102c50d82SAndre Fischer if (nIndex>0 && nIndex<=PreviewValueSet::GetItemCount()) 55202c50d82SAndre Fischer return reinterpret_cast<UserData*>(PreviewValueSet::GetItemData((sal_uInt16)nIndex)); 55302c50d82SAndre Fischer else 55402c50d82SAndre Fischer return NULL; 55502c50d82SAndre Fischer } 55602c50d82SAndre Fischer 55702c50d82SAndre Fischer 55802c50d82SAndre Fischer 55902c50d82SAndre Fischer 56002c50d82SAndre Fischer void MasterPagesSelector::SetUserData (int nIndex, UserData* pData) 56102c50d82SAndre Fischer { 56202c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 56302c50d82SAndre Fischer 56402c50d82SAndre Fischer if (nIndex>0 && nIndex<=PreviewValueSet::GetItemCount()) 56502c50d82SAndre Fischer { 56602c50d82SAndre Fischer UserData* pOldData = GetUserData(nIndex); 56702c50d82SAndre Fischer if (pOldData!=NULL && pOldData!=pData) 56802c50d82SAndre Fischer delete pOldData; 56902c50d82SAndre Fischer PreviewValueSet::SetItemData((sal_uInt16)nIndex, pData); 57002c50d82SAndre Fischer } 57102c50d82SAndre Fischer } 57202c50d82SAndre Fischer 57302c50d82SAndre Fischer 57402c50d82SAndre Fischer 57502c50d82SAndre Fischer 57602c50d82SAndre Fischer bool MasterPagesSelector::IsResizable (void) 57702c50d82SAndre Fischer { 57802c50d82SAndre Fischer return false; 57902c50d82SAndre Fischer } 58002c50d82SAndre Fischer 58102c50d82SAndre Fischer 58202c50d82SAndre Fischer 58302c50d82SAndre Fischer 58402c50d82SAndre Fischer ::Window* MasterPagesSelector::GetWindow (void) 58502c50d82SAndre Fischer { 58602c50d82SAndre Fischer return this; 58702c50d82SAndre Fischer } 58802c50d82SAndre Fischer 58902c50d82SAndre Fischer 59002c50d82SAndre Fischer 59102c50d82SAndre Fischer 59202c50d82SAndre Fischer sal_Int32 MasterPagesSelector::GetMinimumWidth (void) 59302c50d82SAndre Fischer { 59402c50d82SAndre Fischer return mpContainer->GetPreviewSizePixel().Width() + 2*3; 59502c50d82SAndre Fischer } 59602c50d82SAndre Fischer 59702c50d82SAndre Fischer 59802c50d82SAndre Fischer 59902c50d82SAndre Fischer 60002c50d82SAndre Fischer void MasterPagesSelector::UpdateSelection (void) 60102c50d82SAndre Fischer { 60202c50d82SAndre Fischer } 60302c50d82SAndre Fischer 60402c50d82SAndre Fischer 60502c50d82SAndre Fischer 60602c50d82SAndre Fischer 60702c50d82SAndre Fischer void MasterPagesSelector::SetItem ( 60802c50d82SAndre Fischer sal_uInt16 nIndex, 60902c50d82SAndre Fischer MasterPageContainer::Token aToken) 61002c50d82SAndre Fischer { 61102c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 61202c50d82SAndre Fischer 61302c50d82SAndre Fischer RemoveTokenToIndexEntry(nIndex,aToken); 61402c50d82SAndre Fischer 61502c50d82SAndre Fischer if (nIndex > 0) 61602c50d82SAndre Fischer { 61702c50d82SAndre Fischer if (aToken != MasterPageContainer::NIL_TOKEN) 61802c50d82SAndre Fischer { 61902c50d82SAndre Fischer Image aPreview (mpContainer->GetPreviewForToken(aToken)); 62002c50d82SAndre Fischer MasterPageContainer::PreviewState eState (mpContainer->GetPreviewState(aToken)); 62102c50d82SAndre Fischer 62202c50d82SAndre Fischer if (aPreview.GetSizePixel().Width()>0) 62302c50d82SAndre Fischer { 62402c50d82SAndre Fischer if (PreviewValueSet::GetItemPos(nIndex) != VALUESET_ITEM_NOTFOUND) 62502c50d82SAndre Fischer { 62602c50d82SAndre Fischer PreviewValueSet::SetItemImage(nIndex,aPreview); 62702c50d82SAndre Fischer PreviewValueSet::SetItemText(nIndex, mpContainer->GetPageNameForToken(aToken)); 62802c50d82SAndre Fischer } 62902c50d82SAndre Fischer else 63002c50d82SAndre Fischer { 63102c50d82SAndre Fischer PreviewValueSet::InsertItem ( 63202c50d82SAndre Fischer nIndex, 63302c50d82SAndre Fischer aPreview, 63402c50d82SAndre Fischer mpContainer->GetPageNameForToken(aToken), 63502c50d82SAndre Fischer nIndex); 63602c50d82SAndre Fischer } 63702c50d82SAndre Fischer SetUserData(nIndex, CreateUserData(nIndex,aToken)); 63802c50d82SAndre Fischer 63902c50d82SAndre Fischer AddTokenToIndexEntry(nIndex,aToken); 64002c50d82SAndre Fischer } 64102c50d82SAndre Fischer 64202c50d82SAndre Fischer if (eState == MasterPageContainer::PS_CREATABLE) 64302c50d82SAndre Fischer mpContainer->RequestPreview(aToken); 64402c50d82SAndre Fischer } 64502c50d82SAndre Fischer else 64602c50d82SAndre Fischer { 64702c50d82SAndre Fischer PreviewValueSet::RemoveItem(nIndex); 64802c50d82SAndre Fischer } 64902c50d82SAndre Fischer } 65002c50d82SAndre Fischer 65102c50d82SAndre Fischer } 65202c50d82SAndre Fischer 65302c50d82SAndre Fischer 65402c50d82SAndre Fischer 65502c50d82SAndre Fischer 65602c50d82SAndre Fischer void MasterPagesSelector::AddTokenToIndexEntry ( 65702c50d82SAndre Fischer sal_uInt16 nIndex, 65802c50d82SAndre Fischer MasterPageContainer::Token aToken) 65902c50d82SAndre Fischer { 66002c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 66102c50d82SAndre Fischer 66202c50d82SAndre Fischer maTokenToValueSetIndex[aToken] = nIndex; 66302c50d82SAndre Fischer } 66402c50d82SAndre Fischer 66502c50d82SAndre Fischer 66602c50d82SAndre Fischer 66702c50d82SAndre Fischer 66802c50d82SAndre Fischer void MasterPagesSelector::RemoveTokenToIndexEntry ( 66902c50d82SAndre Fischer sal_uInt16 nIndex, 67002c50d82SAndre Fischer MasterPageContainer::Token aNewToken) 67102c50d82SAndre Fischer { 67202c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 67302c50d82SAndre Fischer 67402c50d82SAndre Fischer UserData* pData = GetUserData(nIndex); 67502c50d82SAndre Fischer if (pData != NULL) 67602c50d82SAndre Fischer { 67702c50d82SAndre Fischer // Get the token that the index pointed to previously. 67802c50d82SAndre Fischer MasterPageContainer::Token aOldToken (pData->second); 67902c50d82SAndre Fischer 68002c50d82SAndre Fischer if (aNewToken != aOldToken 68102c50d82SAndre Fischer && nIndex == GetIndexForToken(aOldToken)) 68202c50d82SAndre Fischer { 68302c50d82SAndre Fischer maTokenToValueSetIndex[aOldToken] = 0; 68402c50d82SAndre Fischer } 68502c50d82SAndre Fischer } 68602c50d82SAndre Fischer } 68702c50d82SAndre Fischer 68802c50d82SAndre Fischer 68902c50d82SAndre Fischer 69002c50d82SAndre Fischer 69102c50d82SAndre Fischer void MasterPagesSelector::InvalidatePreview (const SdPage* pPage) 69202c50d82SAndre Fischer { 69302c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 69402c50d82SAndre Fischer 69502c50d82SAndre Fischer for (sal_uInt16 nIndex=1; nIndex<=PreviewValueSet::GetItemCount(); nIndex++) 69602c50d82SAndre Fischer { 69702c50d82SAndre Fischer UserData* pData = GetUserData(nIndex); 69802c50d82SAndre Fischer if (pData != NULL) 69902c50d82SAndre Fischer { 70002c50d82SAndre Fischer MasterPageContainer::Token aToken (pData->second); 70102c50d82SAndre Fischer if (pPage == mpContainer->GetPageObjectForToken(aToken,false)) 70202c50d82SAndre Fischer { 70302c50d82SAndre Fischer mpContainer->InvalidatePreview(aToken); 70402c50d82SAndre Fischer mpContainer->RequestPreview(aToken); 70502c50d82SAndre Fischer break; 70602c50d82SAndre Fischer } 70702c50d82SAndre Fischer } 70802c50d82SAndre Fischer } 70902c50d82SAndre Fischer } 71002c50d82SAndre Fischer 71102c50d82SAndre Fischer void MasterPagesSelector::UpdateAllPreviews (void) 71202c50d82SAndre Fischer { 71302c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 71402c50d82SAndre Fischer 71502c50d82SAndre Fischer for (sal_uInt16 nIndex=1; nIndex<=PreviewValueSet::GetItemCount(); nIndex++) 71602c50d82SAndre Fischer { 71702c50d82SAndre Fischer UserData* pData = GetUserData(nIndex); 71802c50d82SAndre Fischer if (pData != NULL) 71902c50d82SAndre Fischer { 72002c50d82SAndre Fischer MasterPageContainer::Token aToken (pData->second); 72102c50d82SAndre Fischer PreviewValueSet::SetItemImage( 72202c50d82SAndre Fischer nIndex, 72302c50d82SAndre Fischer mpContainer->GetPreviewForToken(aToken)); 72402c50d82SAndre Fischer if (mpContainer->GetPreviewState(aToken) == MasterPageContainer::PS_CREATABLE) 72502c50d82SAndre Fischer mpContainer->RequestPreview(aToken); 72602c50d82SAndre Fischer } 72702c50d82SAndre Fischer } 72802c50d82SAndre Fischer PreviewValueSet::Rearrange(true); 72902c50d82SAndre Fischer } 73002c50d82SAndre Fischer 73102c50d82SAndre Fischer 73202c50d82SAndre Fischer 73302c50d82SAndre Fischer 73402c50d82SAndre Fischer void MasterPagesSelector::ClearPageSet (void) 73502c50d82SAndre Fischer { 73602c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 73702c50d82SAndre Fischer 73802c50d82SAndre Fischer for (sal_uInt16 nIndex=1; nIndex<=PreviewValueSet::GetItemCount(); nIndex++) 73902c50d82SAndre Fischer { 74002c50d82SAndre Fischer UserData* pData = GetUserData(nIndex); 74102c50d82SAndre Fischer if (pData != NULL) 74202c50d82SAndre Fischer delete pData; 74302c50d82SAndre Fischer } 74402c50d82SAndre Fischer PreviewValueSet::Clear(); 74502c50d82SAndre Fischer } 74602c50d82SAndre Fischer 74702c50d82SAndre Fischer 74802c50d82SAndre Fischer 74902c50d82SAndre Fischer 75002c50d82SAndre Fischer void MasterPagesSelector::SetHelpId( const rtl::OString& aId ) 75102c50d82SAndre Fischer { 75202c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 75302c50d82SAndre Fischer 75402c50d82SAndre Fischer PreviewValueSet::SetHelpId( aId ); 75502c50d82SAndre Fischer } 75602c50d82SAndre Fischer 75702c50d82SAndre Fischer 75802c50d82SAndre Fischer 75902c50d82SAndre Fischer 76002c50d82SAndre Fischer sal_Int32 MasterPagesSelector::GetIndexForToken (MasterPageContainer::Token aToken) const 76102c50d82SAndre Fischer { 76202c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 76302c50d82SAndre Fischer 76402c50d82SAndre Fischer TokenToValueSetIndex::const_iterator iIndex (maTokenToValueSetIndex.find(aToken)); 76502c50d82SAndre Fischer if (iIndex != maTokenToValueSetIndex.end()) 76602c50d82SAndre Fischer return iIndex->second; 76702c50d82SAndre Fischer else 76802c50d82SAndre Fischer return -1; 76902c50d82SAndre Fischer } 77002c50d82SAndre Fischer 77102c50d82SAndre Fischer 77202c50d82SAndre Fischer 77302c50d82SAndre Fischer 77402c50d82SAndre Fischer void MasterPagesSelector::Clear (void) 77502c50d82SAndre Fischer { 77602c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 77702c50d82SAndre Fischer 77802c50d82SAndre Fischer ClearPageSet(); 77902c50d82SAndre Fischer } 78002c50d82SAndre Fischer 78102c50d82SAndre Fischer 78202c50d82SAndre Fischer 78302c50d82SAndre Fischer 78402c50d82SAndre Fischer void MasterPagesSelector::InvalidateItem (MasterPageContainer::Token aToken) 78502c50d82SAndre Fischer { 78602c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 78702c50d82SAndre Fischer 78802c50d82SAndre Fischer ItemList::iterator iItem; 78902c50d82SAndre Fischer for (iItem=maCurrentItemList.begin(); iItem!=maCurrentItemList.end(); ++iItem) 79002c50d82SAndre Fischer { 79102c50d82SAndre Fischer if (*iItem == aToken) 79202c50d82SAndre Fischer { 79302c50d82SAndre Fischer *iItem = MasterPageContainer::NIL_TOKEN; 79402c50d82SAndre Fischer break; 79502c50d82SAndre Fischer } 79602c50d82SAndre Fischer } 79702c50d82SAndre Fischer } 79802c50d82SAndre Fischer 79902c50d82SAndre Fischer 80002c50d82SAndre Fischer 80102c50d82SAndre Fischer 80202c50d82SAndre Fischer void MasterPagesSelector::UpdateItemList (::std::auto_ptr<ItemList> pNewItemList) 80302c50d82SAndre Fischer { 80402c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 80502c50d82SAndre Fischer 80602c50d82SAndre Fischer ItemList::const_iterator iNewItem (pNewItemList->begin()); 80702c50d82SAndre Fischer ItemList::const_iterator iCurrentItem (maCurrentItemList.begin()); 80802c50d82SAndre Fischer ItemList::const_iterator iNewEnd (pNewItemList->end()); 80902c50d82SAndre Fischer ItemList::const_iterator iCurrentEnd (maCurrentItemList.end()); 81002c50d82SAndre Fischer sal_uInt16 nIndex (1); 81102c50d82SAndre Fischer 81202c50d82SAndre Fischer // Update existing items. 81302c50d82SAndre Fischer for ( ; iNewItem!=iNewEnd && iCurrentItem!=iCurrentEnd; ++iNewItem, ++iCurrentItem,++nIndex) 81402c50d82SAndre Fischer { 81502c50d82SAndre Fischer if (*iNewItem != *iCurrentItem) 81602c50d82SAndre Fischer { 81702c50d82SAndre Fischer SetItem(nIndex,*iNewItem); 81802c50d82SAndre Fischer } 81902c50d82SAndre Fischer } 82002c50d82SAndre Fischer 82102c50d82SAndre Fischer // Append new items. 82202c50d82SAndre Fischer for ( ; iNewItem!=iNewEnd; ++iNewItem,++nIndex) 82302c50d82SAndre Fischer { 82402c50d82SAndre Fischer SetItem(nIndex,*iNewItem); 82502c50d82SAndre Fischer } 82602c50d82SAndre Fischer 82702c50d82SAndre Fischer // Remove trailing items. 82802c50d82SAndre Fischer for ( ; iCurrentItem!=iCurrentEnd; ++iCurrentItem,++nIndex) 82902c50d82SAndre Fischer { 83002c50d82SAndre Fischer SetItem(nIndex,MasterPageContainer::NIL_TOKEN); 83102c50d82SAndre Fischer } 83202c50d82SAndre Fischer 83302c50d82SAndre Fischer maCurrentItemList.swap(*pNewItemList); 83402c50d82SAndre Fischer 83502c50d82SAndre Fischer PreviewValueSet::Rearrange(); 83602c50d82SAndre Fischer if (mxSidebar.is()) 83702c50d82SAndre Fischer mxSidebar->requestLayout(); 83802c50d82SAndre Fischer } 83902c50d82SAndre Fischer 84002c50d82SAndre Fischer 84102c50d82SAndre Fischer 84202c50d82SAndre Fischer 84302c50d82SAndre Fischer css::ui::LayoutSize MasterPagesSelector::GetHeightForWidth (const sal_Int32 nWidth) 84402c50d82SAndre Fischer { 84502c50d82SAndre Fischer const sal_Int32 nHeight (GetPreferredHeight(nWidth)); 84602c50d82SAndre Fischer return css::ui::LayoutSize(nHeight,nHeight,nHeight); 84702c50d82SAndre Fischer } 84802c50d82SAndre Fischer 84902c50d82SAndre Fischer } } // end of namespace sd::sidebar 850