1*02c50d82SAndre Fischer /************************************************************** 2*02c50d82SAndre Fischer * 3*02c50d82SAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 4*02c50d82SAndre Fischer * or more contributor license agreements. See the NOTICE file 5*02c50d82SAndre Fischer * distributed with this work for additional information 6*02c50d82SAndre Fischer * regarding copyright ownership. The ASF licenses this file 7*02c50d82SAndre Fischer * to you under the Apache License, Version 2.0 (the 8*02c50d82SAndre Fischer * "License"); you may not use this file except in compliance 9*02c50d82SAndre Fischer * with the License. You may obtain a copy of the License at 10*02c50d82SAndre Fischer * 11*02c50d82SAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 12*02c50d82SAndre Fischer * 13*02c50d82SAndre Fischer * Unless required by applicable law or agreed to in writing, 14*02c50d82SAndre Fischer * software distributed under the License is distributed on an 15*02c50d82SAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*02c50d82SAndre Fischer * KIND, either express or implied. See the License for the 17*02c50d82SAndre Fischer * specific language governing permissions and limitations 18*02c50d82SAndre Fischer * under the License. 19*02c50d82SAndre Fischer * 20*02c50d82SAndre Fischer *************************************************************/ 21*02c50d82SAndre Fischer 22*02c50d82SAndre Fischer #include "precompiled_sd.hxx" 23*02c50d82SAndre Fischer 24*02c50d82SAndre Fischer #include "MasterPagesSelector.hxx" 25*02c50d82SAndre Fischer 26*02c50d82SAndre Fischer #include "MasterPageContainer.hxx" 27*02c50d82SAndre Fischer #include "DocumentHelper.hxx" 28*02c50d82SAndre Fischer #include "SidebarShellManager.hxx" 29*02c50d82SAndre Fischer #include "pres.hxx" 30*02c50d82SAndre Fischer #include "drawdoc.hxx" 31*02c50d82SAndre Fischer #include "DrawDocShell.hxx" 32*02c50d82SAndre Fischer #include "sdpage.hxx" 33*02c50d82SAndre Fischer #include "glob.hxx" 34*02c50d82SAndre Fischer #include "glob.hrc" 35*02c50d82SAndre Fischer #include "app.hrc" 36*02c50d82SAndre Fischer #include "res_bmp.hrc" 37*02c50d82SAndre Fischer #include "strings.hrc" 38*02c50d82SAndre Fischer #include "DrawViewShell.hxx" 39*02c50d82SAndre Fischer #include "DrawController.hxx" 40*02c50d82SAndre Fischer #include "SlideSorterViewShell.hxx" 41*02c50d82SAndre Fischer #include "PreviewValueSet.hxx" 42*02c50d82SAndre Fischer #include "ViewShellBase.hxx" 43*02c50d82SAndre Fischer #include <sfx2/objface.hxx> 44*02c50d82SAndre Fischer #include "sdresid.hxx" 45*02c50d82SAndre Fischer #include "drawview.hxx" 46*02c50d82SAndre Fischer #include <vcl/image.hxx> 47*02c50d82SAndre Fischer #include <vcl/floatwin.hxx> 48*02c50d82SAndre Fischer #include <svl/languageoptions.hxx> 49*02c50d82SAndre Fischer #include <sfx2/app.hxx> 50*02c50d82SAndre Fischer #include <sfx2/dispatch.hxx> 51*02c50d82SAndre Fischer #include <sfx2/mnumgr.hxx> 52*02c50d82SAndre Fischer #include <svl/itemset.hxx> 53*02c50d82SAndre Fischer #include <svl/eitem.hxx> 54*02c50d82SAndre Fischer #include <svx/dlgutil.hxx> 55*02c50d82SAndre Fischer #include <svx/svdpagv.hxx> 56*02c50d82SAndre Fischer #include <svx/svxids.hrc> 57*02c50d82SAndre Fischer #include "FrameView.hxx" 58*02c50d82SAndre Fischer #include "sdpage.hxx" 59*02c50d82SAndre Fischer #include "stlpool.hxx" 60*02c50d82SAndre Fischer #include "unmovss.hxx" 61*02c50d82SAndre Fischer #include <sfx2/request.hxx> 62*02c50d82SAndre Fischer #include <svl/itempool.hxx> 63*02c50d82SAndre Fischer 64*02c50d82SAndre Fischer 65*02c50d82SAndre Fischer using namespace ::com::sun::star::text; 66*02c50d82SAndre Fischer 67*02c50d82SAndre Fischer 68*02c50d82SAndre Fischer 69*02c50d82SAndre Fischer namespace sd { namespace sidebar { 70*02c50d82SAndre Fischer 71*02c50d82SAndre Fischer 72*02c50d82SAndre Fischer MasterPagesSelector::MasterPagesSelector ( 73*02c50d82SAndre Fischer ::Window* pParent, 74*02c50d82SAndre Fischer SdDrawDocument& rDocument, 75*02c50d82SAndre Fischer ViewShellBase& rBase, 76*02c50d82SAndre Fischer const ::boost::shared_ptr<MasterPageContainer>& rpContainer, 77*02c50d82SAndre Fischer const cssu::Reference<css::ui::XSidebar>& rxSidebar) 78*02c50d82SAndre Fischer : PreviewValueSet(pParent), 79*02c50d82SAndre Fischer maMutex(), 80*02c50d82SAndre Fischer mpContainer(rpContainer), 81*02c50d82SAndre Fischer mrDocument(rDocument), 82*02c50d82SAndre Fischer mrBase(rBase), 83*02c50d82SAndre Fischer mnDefaultClickAction(SID_TP_APPLY_TO_ALL_SLIDES), 84*02c50d82SAndre Fischer maPreviewUpdateQueue(), 85*02c50d82SAndre Fischer maCurrentItemList(), 86*02c50d82SAndre Fischer maTokenToValueSetIndex(), 87*02c50d82SAndre Fischer maLockedMasterPages(), 88*02c50d82SAndre Fischer mxSidebar(rxSidebar) 89*02c50d82SAndre Fischer { 90*02c50d82SAndre Fischer PreviewValueSet::SetSelectHdl ( 91*02c50d82SAndre Fischer LINK(this, MasterPagesSelector, ClickHandler)); 92*02c50d82SAndre Fischer PreviewValueSet::SetRightMouseClickHandler ( 93*02c50d82SAndre Fischer LINK(this, MasterPagesSelector, RightClickHandler)); 94*02c50d82SAndre Fischer PreviewValueSet::SetStyle(PreviewValueSet::GetStyle() | WB_NO_DIRECTSELECT); 95*02c50d82SAndre Fischer PreviewValueSet::SetPreviewSize(mpContainer->GetPreviewSizePixel()); 96*02c50d82SAndre Fischer PreviewValueSet::Show(); 97*02c50d82SAndre Fischer 98*02c50d82SAndre Fischer Link aChangeListener (LINK(this,MasterPagesSelector,ContainerChangeListener)); 99*02c50d82SAndre Fischer mpContainer->AddChangeListener(aChangeListener); 100*02c50d82SAndre Fischer } 101*02c50d82SAndre Fischer 102*02c50d82SAndre Fischer 103*02c50d82SAndre Fischer 104*02c50d82SAndre Fischer 105*02c50d82SAndre Fischer MasterPagesSelector::~MasterPagesSelector (void) 106*02c50d82SAndre Fischer { 107*02c50d82SAndre Fischer Clear(); 108*02c50d82SAndre Fischer UpdateLocks(ItemList()); 109*02c50d82SAndre Fischer 110*02c50d82SAndre Fischer Link aChangeListener (LINK(this,MasterPagesSelector,ContainerChangeListener)); 111*02c50d82SAndre Fischer mpContainer->RemoveChangeListener(aChangeListener); 112*02c50d82SAndre Fischer } 113*02c50d82SAndre Fischer 114*02c50d82SAndre Fischer 115*02c50d82SAndre Fischer 116*02c50d82SAndre Fischer 117*02c50d82SAndre Fischer void MasterPagesSelector::LateInit (void) 118*02c50d82SAndre Fischer { 119*02c50d82SAndre Fischer } 120*02c50d82SAndre Fischer 121*02c50d82SAndre Fischer 122*02c50d82SAndre Fischer 123*02c50d82SAndre Fischer 124*02c50d82SAndre Fischer sal_Int32 MasterPagesSelector::GetPreferredWidth (sal_Int32 nHeight) 125*02c50d82SAndre Fischer { 126*02c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 127*02c50d82SAndre Fischer 128*02c50d82SAndre Fischer return PreviewValueSet::GetPreferredWidth (nHeight); 129*02c50d82SAndre Fischer } 130*02c50d82SAndre Fischer 131*02c50d82SAndre Fischer 132*02c50d82SAndre Fischer 133*02c50d82SAndre Fischer 134*02c50d82SAndre Fischer sal_Int32 MasterPagesSelector::GetPreferredHeight (sal_Int32 nWidth) 135*02c50d82SAndre Fischer { 136*02c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 137*02c50d82SAndre Fischer 138*02c50d82SAndre Fischer return PreviewValueSet::GetPreferredHeight (nWidth); 139*02c50d82SAndre Fischer } 140*02c50d82SAndre Fischer 141*02c50d82SAndre Fischer 142*02c50d82SAndre Fischer 143*02c50d82SAndre Fischer 144*02c50d82SAndre Fischer Size MasterPagesSelector::GetPreferredSize (void) 145*02c50d82SAndre Fischer { 146*02c50d82SAndre Fischer int nPreferredWidth = GetPreferredWidth( 147*02c50d82SAndre Fischer PreviewValueSet::GetOutputSizePixel().Height()); 148*02c50d82SAndre Fischer int nPreferredHeight = GetPreferredHeight(nPreferredWidth); 149*02c50d82SAndre Fischer return Size (nPreferredWidth, nPreferredHeight); 150*02c50d82SAndre Fischer 151*02c50d82SAndre Fischer } 152*02c50d82SAndre Fischer 153*02c50d82SAndre Fischer 154*02c50d82SAndre Fischer 155*02c50d82SAndre Fischer 156*02c50d82SAndre Fischer void MasterPagesSelector::UpdateLocks (const ItemList& rItemList) 157*02c50d82SAndre Fischer { 158*02c50d82SAndre Fischer ItemList aNewLockList; 159*02c50d82SAndre Fischer 160*02c50d82SAndre Fischer // In here we first lock the master pages in the given list and then 161*02c50d82SAndre Fischer // release the locks acquired in a previous call to this method. When 162*02c50d82SAndre Fischer // this were done the other way round the lock count of some master 163*02c50d82SAndre Fischer // pages might drop temporarily to 0 and would lead to unnecessary 164*02c50d82SAndre Fischer // deletion and re-creation of MasterPageDescriptor objects. 165*02c50d82SAndre Fischer 166*02c50d82SAndre Fischer // Lock the master pages in the given list. 167*02c50d82SAndre Fischer ItemList::const_iterator iItem; 168*02c50d82SAndre Fischer for (iItem=rItemList.begin(); iItem!=rItemList.end(); ++iItem) 169*02c50d82SAndre Fischer { 170*02c50d82SAndre Fischer mpContainer->AcquireToken(*iItem); 171*02c50d82SAndre Fischer aNewLockList.push_back(*iItem); 172*02c50d82SAndre Fischer } 173*02c50d82SAndre Fischer 174*02c50d82SAndre Fischer // Release the previously locked master pages. 175*02c50d82SAndre Fischer ItemList::const_iterator iPage; 176*02c50d82SAndre Fischer ItemList::const_iterator iEnd (maLockedMasterPages.end()); 177*02c50d82SAndre Fischer for (iPage=maLockedMasterPages.begin(); iPage!=iEnd; ++iPage) 178*02c50d82SAndre Fischer mpContainer->ReleaseToken(*iPage); 179*02c50d82SAndre Fischer 180*02c50d82SAndre Fischer maLockedMasterPages.swap(aNewLockList); 181*02c50d82SAndre Fischer } 182*02c50d82SAndre Fischer 183*02c50d82SAndre Fischer 184*02c50d82SAndre Fischer 185*02c50d82SAndre Fischer 186*02c50d82SAndre Fischer void MasterPagesSelector::Fill (void) 187*02c50d82SAndre Fischer { 188*02c50d82SAndre Fischer ::std::auto_ptr<ItemList> pItemList (new ItemList()); 189*02c50d82SAndre Fischer 190*02c50d82SAndre Fischer Fill(*pItemList); 191*02c50d82SAndre Fischer 192*02c50d82SAndre Fischer UpdateLocks(*pItemList); 193*02c50d82SAndre Fischer UpdateItemList(pItemList); 194*02c50d82SAndre Fischer } 195*02c50d82SAndre Fischer 196*02c50d82SAndre Fischer 197*02c50d82SAndre Fischer 198*02c50d82SAndre Fischer 199*02c50d82SAndre Fischer ResId MasterPagesSelector::GetContextMenuResId (void) const 200*02c50d82SAndre Fischer { 201*02c50d82SAndre Fischer return SdResId(RID_TASKPANE_MASTERPAGESSELECTOR_POPUP); 202*02c50d82SAndre Fischer } 203*02c50d82SAndre Fischer 204*02c50d82SAndre Fischer 205*02c50d82SAndre Fischer 206*02c50d82SAndre Fischer 207*02c50d82SAndre Fischer IMPL_LINK(MasterPagesSelector, ClickHandler, PreviewValueSet*, EMPTYARG) 208*02c50d82SAndre Fischer { 209*02c50d82SAndre Fischer // We use the framework to assign the clicked-on master page because we 210*02c50d82SAndre Fischer // so use the same mechanism as the context menu does (where we do not 211*02c50d82SAndre Fischer // have the option to call the assignment method directly.) 212*02c50d82SAndre Fischer ExecuteCommand(mnDefaultClickAction); 213*02c50d82SAndre Fischer 214*02c50d82SAndre Fischer return 0; 215*02c50d82SAndre Fischer } 216*02c50d82SAndre Fischer 217*02c50d82SAndre Fischer 218*02c50d82SAndre Fischer 219*02c50d82SAndre Fischer 220*02c50d82SAndre Fischer IMPL_LINK(MasterPagesSelector, RightClickHandler, MouseEvent*, pEvent) 221*02c50d82SAndre Fischer { 222*02c50d82SAndre Fischer // Here we only prepare the display of the context menu: the item under 223*02c50d82SAndre Fischer // the mouse is selected. The actual display of the context menu is 224*02c50d82SAndre Fischer // done in ContextMenuCallback which is called indirectly through 225*02c50d82SAndre Fischer // PreviewValueSet::Command(). 226*02c50d82SAndre Fischer PreviewValueSet::GrabFocus (); 227*02c50d82SAndre Fischer PreviewValueSet::ReleaseMouse(); 228*02c50d82SAndre Fischer SfxViewFrame* pViewFrame = mrBase.GetViewFrame(); 229*02c50d82SAndre Fischer if (pViewFrame != NULL) 230*02c50d82SAndre Fischer { 231*02c50d82SAndre Fischer SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher(); 232*02c50d82SAndre Fischer if (pDispatcher != NULL && pEvent != NULL) 233*02c50d82SAndre Fischer { 234*02c50d82SAndre Fischer sal_uInt16 nIndex = PreviewValueSet::GetItemId (pEvent->GetPosPixel()); 235*02c50d82SAndre Fischer if (nIndex > 0) 236*02c50d82SAndre Fischer PreviewValueSet::SelectItem (nIndex); 237*02c50d82SAndre Fischer } 238*02c50d82SAndre Fischer } 239*02c50d82SAndre Fischer return 0; 240*02c50d82SAndre Fischer } 241*02c50d82SAndre Fischer 242*02c50d82SAndre Fischer 243*02c50d82SAndre Fischer 244*02c50d82SAndre Fischer 245*02c50d82SAndre Fischer void MasterPagesSelector::Command (const CommandEvent& rEvent) 246*02c50d82SAndre Fischer { 247*02c50d82SAndre Fischer switch (rEvent.GetCommand()) 248*02c50d82SAndre Fischer { 249*02c50d82SAndre Fischer case COMMAND_CONTEXTMENU: 250*02c50d82SAndre Fischer { 251*02c50d82SAndre Fischer // Use the currently selected item and show the popup menu in its 252*02c50d82SAndre Fischer // center. 253*02c50d82SAndre Fischer const sal_uInt16 nIndex = PreviewValueSet::GetSelectItemId(); 254*02c50d82SAndre Fischer if (nIndex > 0) 255*02c50d82SAndre Fischer { 256*02c50d82SAndre Fischer // The position of the upper left corner of the context menu is 257*02c50d82SAndre Fischer // taken either from the mouse position (when the command was sent 258*02c50d82SAndre Fischer // as reaction to a right click) or in the center of the selected 259*02c50d82SAndre Fischer // item (when the command was sent as reaction to Shift+F10.) 260*02c50d82SAndre Fischer Point aPosition (rEvent.GetMousePosPixel()); 261*02c50d82SAndre Fischer if ( ! rEvent.IsMouseEvent()) 262*02c50d82SAndre Fischer { 263*02c50d82SAndre Fischer Rectangle aBBox (PreviewValueSet::GetItemRect(nIndex)); 264*02c50d82SAndre Fischer aPosition = aBBox.Center(); 265*02c50d82SAndre Fischer } 266*02c50d82SAndre Fischer 267*02c50d82SAndre Fischer // Setup the menu. 268*02c50d82SAndre Fischer ::boost::scoped_ptr<PopupMenu> pMenu (new PopupMenu(GetContextMenuResId())); 269*02c50d82SAndre Fischer FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow()); 270*02c50d82SAndre Fischer if (pMenuWindow != NULL) 271*02c50d82SAndre Fischer pMenuWindow->SetPopupModeFlags( 272*02c50d82SAndre Fischer pMenuWindow->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE); 273*02c50d82SAndre Fischer pMenu->SetSelectHdl(LINK(this, MasterPagesSelector, OnMenuItemSelected)); 274*02c50d82SAndre Fischer 275*02c50d82SAndre Fischer ProcessPopupMenu(*pMenu); 276*02c50d82SAndre Fischer 277*02c50d82SAndre Fischer // Show the menu. 278*02c50d82SAndre Fischer pMenu->Execute(this, Rectangle(aPosition,Size(1,1)), POPUPMENU_EXECUTE_DOWN); 279*02c50d82SAndre Fischer } 280*02c50d82SAndre Fischer break; 281*02c50d82SAndre Fischer } 282*02c50d82SAndre Fischer } 283*02c50d82SAndre Fischer } 284*02c50d82SAndre Fischer 285*02c50d82SAndre Fischer 286*02c50d82SAndre Fischer 287*02c50d82SAndre Fischer 288*02c50d82SAndre Fischer void MasterPagesSelector::ProcessPopupMenu (Menu& rMenu) 289*02c50d82SAndre Fischer { 290*02c50d82SAndre Fischer // Disable some entries. 291*02c50d82SAndre Fischer if (mpContainer->GetPreviewSize() == MasterPageContainer::SMALL) 292*02c50d82SAndre Fischer rMenu.EnableItem(SID_TP_SHOW_SMALL_PREVIEW, sal_False); 293*02c50d82SAndre Fischer else 294*02c50d82SAndre Fischer rMenu.EnableItem(SID_TP_SHOW_LARGE_PREVIEW, sal_False); 295*02c50d82SAndre Fischer } 296*02c50d82SAndre Fischer 297*02c50d82SAndre Fischer 298*02c50d82SAndre Fischer 299*02c50d82SAndre Fischer 300*02c50d82SAndre Fischer IMPL_LINK(MasterPagesSelector, OnMenuItemSelected, Menu*, pMenu) 301*02c50d82SAndre Fischer { 302*02c50d82SAndre Fischer if (pMenu == NULL) 303*02c50d82SAndre Fischer { 304*02c50d82SAndre Fischer OSL_ENSURE(pMenu!=NULL, "MasterPagesSelector::OnMenuItemSelected: illegal menu!"); 305*02c50d82SAndre Fischer return 0; 306*02c50d82SAndre Fischer } 307*02c50d82SAndre Fischer 308*02c50d82SAndre Fischer pMenu->Deactivate(); 309*02c50d82SAndre Fischer ExecuteCommand(pMenu->GetCurItemId()); 310*02c50d82SAndre Fischer return 0; 311*02c50d82SAndre Fischer } 312*02c50d82SAndre Fischer 313*02c50d82SAndre Fischer 314*02c50d82SAndre Fischer 315*02c50d82SAndre Fischer 316*02c50d82SAndre Fischer void MasterPagesSelector::ExecuteCommand (const sal_Int32 nCommandId) 317*02c50d82SAndre Fischer { 318*02c50d82SAndre Fischer switch (nCommandId) 319*02c50d82SAndre Fischer { 320*02c50d82SAndre Fischer case SID_TP_APPLY_TO_ALL_SLIDES: 321*02c50d82SAndre Fischer mrBase.SetBusyState (true); 322*02c50d82SAndre Fischer AssignMasterPageToAllSlides (GetSelectedMasterPage()); 323*02c50d82SAndre Fischer mrBase.SetBusyState (false); 324*02c50d82SAndre Fischer break; 325*02c50d82SAndre Fischer 326*02c50d82SAndre Fischer case SID_TP_APPLY_TO_SELECTED_SLIDES: 327*02c50d82SAndre Fischer mrBase.SetBusyState (true); 328*02c50d82SAndre Fischer AssignMasterPageToSelectedSlides (GetSelectedMasterPage()); 329*02c50d82SAndre Fischer mrBase.SetBusyState (false); 330*02c50d82SAndre Fischer break; 331*02c50d82SAndre Fischer 332*02c50d82SAndre Fischer case SID_TP_USE_FOR_NEW_PRESENTATIONS: 333*02c50d82SAndre Fischer DBG_ASSERT (false, 334*02c50d82SAndre Fischer "Using slides as default for new presentations" 335*02c50d82SAndre Fischer " is not yet implemented"); 336*02c50d82SAndre Fischer break; 337*02c50d82SAndre Fischer 338*02c50d82SAndre Fischer case SID_TP_SHOW_SMALL_PREVIEW: 339*02c50d82SAndre Fischer case SID_TP_SHOW_LARGE_PREVIEW: 340*02c50d82SAndre Fischer { 341*02c50d82SAndre Fischer mrBase.SetBusyState (true); 342*02c50d82SAndre Fischer mpContainer->SetPreviewSize( 343*02c50d82SAndre Fischer nCommandId==SID_TP_SHOW_SMALL_PREVIEW 344*02c50d82SAndre Fischer ? MasterPageContainer::SMALL 345*02c50d82SAndre Fischer : MasterPageContainer::LARGE); 346*02c50d82SAndre Fischer mrBase.SetBusyState (false); 347*02c50d82SAndre Fischer if (mxSidebar.is()) 348*02c50d82SAndre Fischer mxSidebar->requestLayout(); 349*02c50d82SAndre Fischer break; 350*02c50d82SAndre Fischer } 351*02c50d82SAndre Fischer 352*02c50d82SAndre Fischer case SID_TP_EDIT_MASTER: 353*02c50d82SAndre Fischer { 354*02c50d82SAndre Fischer using namespace ::com::sun::star; 355*02c50d82SAndre Fischer uno::Reference<drawing::XDrawPage> xSelectedMaster ( 356*02c50d82SAndre Fischer GetSelectedMasterPage()->getUnoPage(), uno::UNO_QUERY); 357*02c50d82SAndre Fischer SfxViewFrame* pViewFrame = mrBase.GetViewFrame(); 358*02c50d82SAndre Fischer if (pViewFrame != NULL && xSelectedMaster.is()) 359*02c50d82SAndre Fischer { 360*02c50d82SAndre Fischer SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher(); 361*02c50d82SAndre Fischer if (pDispatcher != NULL) 362*02c50d82SAndre Fischer { 363*02c50d82SAndre Fischer sal_uInt16 nIndex = PreviewValueSet::GetSelectItemId(); 364*02c50d82SAndre Fischer pDispatcher->Execute(SID_MASTERPAGE, SFX_CALLMODE_SYNCHRON); 365*02c50d82SAndre Fischer PreviewValueSet::SelectItem (nIndex); 366*02c50d82SAndre Fischer mrBase.GetDrawController().setCurrentPage(xSelectedMaster); 367*02c50d82SAndre Fischer } 368*02c50d82SAndre Fischer } 369*02c50d82SAndre Fischer break; 370*02c50d82SAndre Fischer } 371*02c50d82SAndre Fischer 372*02c50d82SAndre Fischer case SID_CUT: 373*02c50d82SAndre Fischer case SID_COPY: 374*02c50d82SAndre Fischer case SID_PASTE: 375*02c50d82SAndre Fischer // Cut, copy, and paste are not supported and thus are ignored. 376*02c50d82SAndre Fischer break; 377*02c50d82SAndre Fischer } 378*02c50d82SAndre Fischer } 379*02c50d82SAndre Fischer 380*02c50d82SAndre Fischer 381*02c50d82SAndre Fischer 382*02c50d82SAndre Fischer 383*02c50d82SAndre Fischer IMPL_LINK(MasterPagesSelector, ContainerChangeListener, MasterPageContainerChangeEvent*, pEvent) 384*02c50d82SAndre Fischer { 385*02c50d82SAndre Fischer if (pEvent) 386*02c50d82SAndre Fischer NotifyContainerChangeEvent(*pEvent); 387*02c50d82SAndre Fischer return 0; 388*02c50d82SAndre Fischer } 389*02c50d82SAndre Fischer 390*02c50d82SAndre Fischer 391*02c50d82SAndre Fischer 392*02c50d82SAndre Fischer 393*02c50d82SAndre Fischer SdPage* MasterPagesSelector::GetSelectedMasterPage (void) 394*02c50d82SAndre Fischer { 395*02c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 396*02c50d82SAndre Fischer 397*02c50d82SAndre Fischer SdPage* pMasterPage = NULL; 398*02c50d82SAndre Fischer sal_uInt16 nIndex = PreviewValueSet::GetSelectItemId(); 399*02c50d82SAndre Fischer UserData* pData = GetUserData(nIndex); 400*02c50d82SAndre Fischer if (pData != NULL) 401*02c50d82SAndre Fischer { 402*02c50d82SAndre Fischer pMasterPage = mpContainer->GetPageObjectForToken(pData->second); 403*02c50d82SAndre Fischer } 404*02c50d82SAndre Fischer return pMasterPage; 405*02c50d82SAndre Fischer } 406*02c50d82SAndre Fischer 407*02c50d82SAndre Fischer 408*02c50d82SAndre Fischer 409*02c50d82SAndre Fischer 410*02c50d82SAndre Fischer /** Assemble a list of all slides of the document and pass it to 411*02c50d82SAndre Fischer AssignMasterPageToPageList(). 412*02c50d82SAndre Fischer */ 413*02c50d82SAndre Fischer void MasterPagesSelector::AssignMasterPageToAllSlides (SdPage* pMasterPage) 414*02c50d82SAndre Fischer { 415*02c50d82SAndre Fischer do 416*02c50d82SAndre Fischer { 417*02c50d82SAndre Fischer if (pMasterPage == NULL) 418*02c50d82SAndre Fischer break; 419*02c50d82SAndre Fischer 420*02c50d82SAndre Fischer sal_uInt16 nPageCount = mrDocument.GetSdPageCount(PK_STANDARD); 421*02c50d82SAndre Fischer if (nPageCount == 0) 422*02c50d82SAndre Fischer break; 423*02c50d82SAndre Fischer 424*02c50d82SAndre Fischer // Get a list of all pages. As a little optimization we only 425*02c50d82SAndre Fischer // include pages that do not already have the given master page 426*02c50d82SAndre Fischer // assigned. 427*02c50d82SAndre Fischer String sFullLayoutName (pMasterPage->GetLayoutName()); 428*02c50d82SAndre Fischer ::sd::slidesorter::SharedPageSelection pPageList ( 429*02c50d82SAndre Fischer new ::sd::slidesorter::SlideSorterViewShell::PageSelection()); 430*02c50d82SAndre Fischer for (sal_uInt16 nPageIndex=0; nPageIndex<nPageCount; nPageIndex++) 431*02c50d82SAndre Fischer { 432*02c50d82SAndre Fischer SdPage* pPage = mrDocument.GetSdPage (nPageIndex, PK_STANDARD); 433*02c50d82SAndre Fischer if (pPage != NULL 434*02c50d82SAndre Fischer && pPage->GetLayoutName().CompareTo(sFullLayoutName)!=0) 435*02c50d82SAndre Fischer { 436*02c50d82SAndre Fischer pPageList->push_back (pPage); 437*02c50d82SAndre Fischer } 438*02c50d82SAndre Fischer } 439*02c50d82SAndre Fischer 440*02c50d82SAndre Fischer AssignMasterPageToPageList(pMasterPage, pPageList); 441*02c50d82SAndre Fischer } 442*02c50d82SAndre Fischer while (false); 443*02c50d82SAndre Fischer } 444*02c50d82SAndre Fischer 445*02c50d82SAndre Fischer 446*02c50d82SAndre Fischer 447*02c50d82SAndre Fischer 448*02c50d82SAndre Fischer /** Assemble a list of the currently selected slides (selected in a visible 449*02c50d82SAndre Fischer slide sorter) and pass it to AssignMasterPageToPageList(). 450*02c50d82SAndre Fischer */ 451*02c50d82SAndre Fischer void MasterPagesSelector::AssignMasterPageToSelectedSlides ( 452*02c50d82SAndre Fischer SdPage* pMasterPage) 453*02c50d82SAndre Fischer { 454*02c50d82SAndre Fischer do 455*02c50d82SAndre Fischer { 456*02c50d82SAndre Fischer using namespace ::std; 457*02c50d82SAndre Fischer using namespace ::sd::slidesorter; 458*02c50d82SAndre Fischer using namespace ::sd::slidesorter::controller; 459*02c50d82SAndre Fischer 460*02c50d82SAndre Fischer if (pMasterPage == NULL) 461*02c50d82SAndre Fischer break; 462*02c50d82SAndre Fischer 463*02c50d82SAndre Fischer // Find a visible slide sorter. 464*02c50d82SAndre Fischer SlideSorterViewShell* pSlideSorter = SlideSorterViewShell::GetSlideSorter(mrBase); 465*02c50d82SAndre Fischer if (pSlideSorter == NULL) 466*02c50d82SAndre Fischer break; 467*02c50d82SAndre Fischer 468*02c50d82SAndre Fischer // Get a list of selected pages. 469*02c50d82SAndre Fischer ::sd::slidesorter::SharedPageSelection pPageSelection = pSlideSorter->GetPageSelection(); 470*02c50d82SAndre Fischer if (pPageSelection->empty()) 471*02c50d82SAndre Fischer break; 472*02c50d82SAndre Fischer 473*02c50d82SAndre Fischer AssignMasterPageToPageList(pMasterPage, pPageSelection); 474*02c50d82SAndre Fischer 475*02c50d82SAndre Fischer // Restore the previous selection. 476*02c50d82SAndre Fischer pSlideSorter->SetPageSelection(pPageSelection); 477*02c50d82SAndre Fischer } 478*02c50d82SAndre Fischer while (false); 479*02c50d82SAndre Fischer } 480*02c50d82SAndre Fischer 481*02c50d82SAndre Fischer 482*02c50d82SAndre Fischer 483*02c50d82SAndre Fischer 484*02c50d82SAndre Fischer void MasterPagesSelector::AssignMasterPageToPageList ( 485*02c50d82SAndre Fischer SdPage* pMasterPage, 486*02c50d82SAndre Fischer const ::sd::slidesorter::SharedPageSelection& rPageList) 487*02c50d82SAndre Fischer { 488*02c50d82SAndre Fischer DocumentHelper::AssignMasterPageToPageList(mrDocument, pMasterPage, rPageList); 489*02c50d82SAndre Fischer } 490*02c50d82SAndre Fischer 491*02c50d82SAndre Fischer 492*02c50d82SAndre Fischer 493*02c50d82SAndre Fischer 494*02c50d82SAndre Fischer void MasterPagesSelector::NotifyContainerChangeEvent (const MasterPageContainerChangeEvent& rEvent) 495*02c50d82SAndre Fischer { 496*02c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 497*02c50d82SAndre Fischer 498*02c50d82SAndre Fischer switch (rEvent.meEventType) 499*02c50d82SAndre Fischer { 500*02c50d82SAndre Fischer case MasterPageContainerChangeEvent::SIZE_CHANGED: 501*02c50d82SAndre Fischer PreviewValueSet::SetPreviewSize(mpContainer->GetPreviewSizePixel()); 502*02c50d82SAndre Fischer UpdateAllPreviews(); 503*02c50d82SAndre Fischer break; 504*02c50d82SAndre Fischer 505*02c50d82SAndre Fischer case MasterPageContainerChangeEvent::PREVIEW_CHANGED: 506*02c50d82SAndre Fischer { 507*02c50d82SAndre Fischer int nIndex (GetIndexForToken(rEvent.maChildToken)); 508*02c50d82SAndre Fischer if (nIndex >= 0) 509*02c50d82SAndre Fischer { 510*02c50d82SAndre Fischer PreviewValueSet::SetItemImage ( 511*02c50d82SAndre Fischer (sal_uInt16)nIndex, 512*02c50d82SAndre Fischer mpContainer->GetPreviewForToken(rEvent.maChildToken)); 513*02c50d82SAndre Fischer PreviewValueSet::Invalidate(PreviewValueSet::GetItemRect((sal_uInt16)nIndex)); 514*02c50d82SAndre Fischer } 515*02c50d82SAndre Fischer } 516*02c50d82SAndre Fischer break; 517*02c50d82SAndre Fischer 518*02c50d82SAndre Fischer case MasterPageContainerChangeEvent::DATA_CHANGED: 519*02c50d82SAndre Fischer { 520*02c50d82SAndre Fischer InvalidateItem(rEvent.maChildToken); 521*02c50d82SAndre Fischer Fill(); 522*02c50d82SAndre Fischer } 523*02c50d82SAndre Fischer break; 524*02c50d82SAndre Fischer 525*02c50d82SAndre Fischer default: 526*02c50d82SAndre Fischer break; 527*02c50d82SAndre Fischer } 528*02c50d82SAndre Fischer } 529*02c50d82SAndre Fischer 530*02c50d82SAndre Fischer 531*02c50d82SAndre Fischer 532*02c50d82SAndre Fischer 533*02c50d82SAndre Fischer MasterPagesSelector::UserData* MasterPagesSelector::CreateUserData ( 534*02c50d82SAndre Fischer int nIndex, 535*02c50d82SAndre Fischer MasterPageContainer::Token aToken) const 536*02c50d82SAndre Fischer { 537*02c50d82SAndre Fischer return new UserData(nIndex,aToken); 538*02c50d82SAndre Fischer } 539*02c50d82SAndre Fischer 540*02c50d82SAndre Fischer 541*02c50d82SAndre Fischer 542*02c50d82SAndre Fischer 543*02c50d82SAndre Fischer MasterPagesSelector::UserData* MasterPagesSelector::GetUserData (int nIndex) const 544*02c50d82SAndre Fischer { 545*02c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 546*02c50d82SAndre Fischer 547*02c50d82SAndre Fischer if (nIndex>0 && nIndex<=PreviewValueSet::GetItemCount()) 548*02c50d82SAndre Fischer return reinterpret_cast<UserData*>(PreviewValueSet::GetItemData((sal_uInt16)nIndex)); 549*02c50d82SAndre Fischer else 550*02c50d82SAndre Fischer return NULL; 551*02c50d82SAndre Fischer } 552*02c50d82SAndre Fischer 553*02c50d82SAndre Fischer 554*02c50d82SAndre Fischer 555*02c50d82SAndre Fischer 556*02c50d82SAndre Fischer void MasterPagesSelector::SetUserData (int nIndex, UserData* pData) 557*02c50d82SAndre Fischer { 558*02c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 559*02c50d82SAndre Fischer 560*02c50d82SAndre Fischer if (nIndex>0 && nIndex<=PreviewValueSet::GetItemCount()) 561*02c50d82SAndre Fischer { 562*02c50d82SAndre Fischer UserData* pOldData = GetUserData(nIndex); 563*02c50d82SAndre Fischer if (pOldData!=NULL && pOldData!=pData) 564*02c50d82SAndre Fischer delete pOldData; 565*02c50d82SAndre Fischer PreviewValueSet::SetItemData((sal_uInt16)nIndex, pData); 566*02c50d82SAndre Fischer } 567*02c50d82SAndre Fischer } 568*02c50d82SAndre Fischer 569*02c50d82SAndre Fischer 570*02c50d82SAndre Fischer 571*02c50d82SAndre Fischer 572*02c50d82SAndre Fischer bool MasterPagesSelector::IsResizable (void) 573*02c50d82SAndre Fischer { 574*02c50d82SAndre Fischer return false; 575*02c50d82SAndre Fischer } 576*02c50d82SAndre Fischer 577*02c50d82SAndre Fischer 578*02c50d82SAndre Fischer 579*02c50d82SAndre Fischer 580*02c50d82SAndre Fischer ::Window* MasterPagesSelector::GetWindow (void) 581*02c50d82SAndre Fischer { 582*02c50d82SAndre Fischer return this; 583*02c50d82SAndre Fischer } 584*02c50d82SAndre Fischer 585*02c50d82SAndre Fischer 586*02c50d82SAndre Fischer 587*02c50d82SAndre Fischer 588*02c50d82SAndre Fischer sal_Int32 MasterPagesSelector::GetMinimumWidth (void) 589*02c50d82SAndre Fischer { 590*02c50d82SAndre Fischer return mpContainer->GetPreviewSizePixel().Width() + 2*3; 591*02c50d82SAndre Fischer } 592*02c50d82SAndre Fischer 593*02c50d82SAndre Fischer 594*02c50d82SAndre Fischer 595*02c50d82SAndre Fischer 596*02c50d82SAndre Fischer void MasterPagesSelector::UpdateSelection (void) 597*02c50d82SAndre Fischer { 598*02c50d82SAndre Fischer } 599*02c50d82SAndre Fischer 600*02c50d82SAndre Fischer 601*02c50d82SAndre Fischer 602*02c50d82SAndre Fischer 603*02c50d82SAndre Fischer void MasterPagesSelector::SetItem ( 604*02c50d82SAndre Fischer sal_uInt16 nIndex, 605*02c50d82SAndre Fischer MasterPageContainer::Token aToken) 606*02c50d82SAndre Fischer { 607*02c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 608*02c50d82SAndre Fischer 609*02c50d82SAndre Fischer RemoveTokenToIndexEntry(nIndex,aToken); 610*02c50d82SAndre Fischer 611*02c50d82SAndre Fischer if (nIndex > 0) 612*02c50d82SAndre Fischer { 613*02c50d82SAndre Fischer if (aToken != MasterPageContainer::NIL_TOKEN) 614*02c50d82SAndre Fischer { 615*02c50d82SAndre Fischer Image aPreview (mpContainer->GetPreviewForToken(aToken)); 616*02c50d82SAndre Fischer MasterPageContainer::PreviewState eState (mpContainer->GetPreviewState(aToken)); 617*02c50d82SAndre Fischer 618*02c50d82SAndre Fischer if (aPreview.GetSizePixel().Width()>0) 619*02c50d82SAndre Fischer { 620*02c50d82SAndre Fischer if (PreviewValueSet::GetItemPos(nIndex) != VALUESET_ITEM_NOTFOUND) 621*02c50d82SAndre Fischer { 622*02c50d82SAndre Fischer PreviewValueSet::SetItemImage(nIndex,aPreview); 623*02c50d82SAndre Fischer PreviewValueSet::SetItemText(nIndex, mpContainer->GetPageNameForToken(aToken)); 624*02c50d82SAndre Fischer } 625*02c50d82SAndre Fischer else 626*02c50d82SAndre Fischer { 627*02c50d82SAndre Fischer PreviewValueSet::InsertItem ( 628*02c50d82SAndre Fischer nIndex, 629*02c50d82SAndre Fischer aPreview, 630*02c50d82SAndre Fischer mpContainer->GetPageNameForToken(aToken), 631*02c50d82SAndre Fischer nIndex); 632*02c50d82SAndre Fischer } 633*02c50d82SAndre Fischer SetUserData(nIndex, CreateUserData(nIndex,aToken)); 634*02c50d82SAndre Fischer 635*02c50d82SAndre Fischer AddTokenToIndexEntry(nIndex,aToken); 636*02c50d82SAndre Fischer } 637*02c50d82SAndre Fischer 638*02c50d82SAndre Fischer if (eState == MasterPageContainer::PS_CREATABLE) 639*02c50d82SAndre Fischer mpContainer->RequestPreview(aToken); 640*02c50d82SAndre Fischer } 641*02c50d82SAndre Fischer else 642*02c50d82SAndre Fischer { 643*02c50d82SAndre Fischer PreviewValueSet::RemoveItem(nIndex); 644*02c50d82SAndre Fischer } 645*02c50d82SAndre Fischer } 646*02c50d82SAndre Fischer 647*02c50d82SAndre Fischer } 648*02c50d82SAndre Fischer 649*02c50d82SAndre Fischer 650*02c50d82SAndre Fischer 651*02c50d82SAndre Fischer 652*02c50d82SAndre Fischer void MasterPagesSelector::AddTokenToIndexEntry ( 653*02c50d82SAndre Fischer sal_uInt16 nIndex, 654*02c50d82SAndre Fischer MasterPageContainer::Token aToken) 655*02c50d82SAndre Fischer { 656*02c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 657*02c50d82SAndre Fischer 658*02c50d82SAndre Fischer maTokenToValueSetIndex[aToken] = nIndex; 659*02c50d82SAndre Fischer } 660*02c50d82SAndre Fischer 661*02c50d82SAndre Fischer 662*02c50d82SAndre Fischer 663*02c50d82SAndre Fischer 664*02c50d82SAndre Fischer void MasterPagesSelector::RemoveTokenToIndexEntry ( 665*02c50d82SAndre Fischer sal_uInt16 nIndex, 666*02c50d82SAndre Fischer MasterPageContainer::Token aNewToken) 667*02c50d82SAndre Fischer { 668*02c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 669*02c50d82SAndre Fischer 670*02c50d82SAndre Fischer UserData* pData = GetUserData(nIndex); 671*02c50d82SAndre Fischer if (pData != NULL) 672*02c50d82SAndre Fischer { 673*02c50d82SAndre Fischer // Get the token that the index pointed to previously. 674*02c50d82SAndre Fischer MasterPageContainer::Token aOldToken (pData->second); 675*02c50d82SAndre Fischer 676*02c50d82SAndre Fischer if (aNewToken != aOldToken 677*02c50d82SAndre Fischer && nIndex == GetIndexForToken(aOldToken)) 678*02c50d82SAndre Fischer { 679*02c50d82SAndre Fischer maTokenToValueSetIndex[aOldToken] = 0; 680*02c50d82SAndre Fischer } 681*02c50d82SAndre Fischer } 682*02c50d82SAndre Fischer } 683*02c50d82SAndre Fischer 684*02c50d82SAndre Fischer 685*02c50d82SAndre Fischer 686*02c50d82SAndre Fischer 687*02c50d82SAndre Fischer void MasterPagesSelector::InvalidatePreview (const SdPage* pPage) 688*02c50d82SAndre Fischer { 689*02c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 690*02c50d82SAndre Fischer 691*02c50d82SAndre Fischer for (sal_uInt16 nIndex=1; nIndex<=PreviewValueSet::GetItemCount(); nIndex++) 692*02c50d82SAndre Fischer { 693*02c50d82SAndre Fischer UserData* pData = GetUserData(nIndex); 694*02c50d82SAndre Fischer if (pData != NULL) 695*02c50d82SAndre Fischer { 696*02c50d82SAndre Fischer MasterPageContainer::Token aToken (pData->second); 697*02c50d82SAndre Fischer if (pPage == mpContainer->GetPageObjectForToken(aToken,false)) 698*02c50d82SAndre Fischer { 699*02c50d82SAndre Fischer mpContainer->InvalidatePreview(aToken); 700*02c50d82SAndre Fischer mpContainer->RequestPreview(aToken); 701*02c50d82SAndre Fischer break; 702*02c50d82SAndre Fischer } 703*02c50d82SAndre Fischer } 704*02c50d82SAndre Fischer } 705*02c50d82SAndre Fischer } 706*02c50d82SAndre Fischer 707*02c50d82SAndre Fischer void MasterPagesSelector::UpdateAllPreviews (void) 708*02c50d82SAndre Fischer { 709*02c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 710*02c50d82SAndre Fischer 711*02c50d82SAndre Fischer for (sal_uInt16 nIndex=1; nIndex<=PreviewValueSet::GetItemCount(); nIndex++) 712*02c50d82SAndre Fischer { 713*02c50d82SAndre Fischer UserData* pData = GetUserData(nIndex); 714*02c50d82SAndre Fischer if (pData != NULL) 715*02c50d82SAndre Fischer { 716*02c50d82SAndre Fischer MasterPageContainer::Token aToken (pData->second); 717*02c50d82SAndre Fischer PreviewValueSet::SetItemImage( 718*02c50d82SAndre Fischer nIndex, 719*02c50d82SAndre Fischer mpContainer->GetPreviewForToken(aToken)); 720*02c50d82SAndre Fischer if (mpContainer->GetPreviewState(aToken) == MasterPageContainer::PS_CREATABLE) 721*02c50d82SAndre Fischer mpContainer->RequestPreview(aToken); 722*02c50d82SAndre Fischer } 723*02c50d82SAndre Fischer } 724*02c50d82SAndre Fischer PreviewValueSet::Rearrange(true); 725*02c50d82SAndre Fischer } 726*02c50d82SAndre Fischer 727*02c50d82SAndre Fischer 728*02c50d82SAndre Fischer 729*02c50d82SAndre Fischer 730*02c50d82SAndre Fischer void MasterPagesSelector::ClearPageSet (void) 731*02c50d82SAndre Fischer { 732*02c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 733*02c50d82SAndre Fischer 734*02c50d82SAndre Fischer for (sal_uInt16 nIndex=1; nIndex<=PreviewValueSet::GetItemCount(); nIndex++) 735*02c50d82SAndre Fischer { 736*02c50d82SAndre Fischer UserData* pData = GetUserData(nIndex); 737*02c50d82SAndre Fischer if (pData != NULL) 738*02c50d82SAndre Fischer delete pData; 739*02c50d82SAndre Fischer } 740*02c50d82SAndre Fischer PreviewValueSet::Clear(); 741*02c50d82SAndre Fischer } 742*02c50d82SAndre Fischer 743*02c50d82SAndre Fischer 744*02c50d82SAndre Fischer 745*02c50d82SAndre Fischer 746*02c50d82SAndre Fischer void MasterPagesSelector::SetHelpId( const rtl::OString& aId ) 747*02c50d82SAndre Fischer { 748*02c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 749*02c50d82SAndre Fischer 750*02c50d82SAndre Fischer PreviewValueSet::SetHelpId( aId ); 751*02c50d82SAndre Fischer } 752*02c50d82SAndre Fischer 753*02c50d82SAndre Fischer 754*02c50d82SAndre Fischer 755*02c50d82SAndre Fischer 756*02c50d82SAndre Fischer sal_Int32 MasterPagesSelector::GetIndexForToken (MasterPageContainer::Token aToken) const 757*02c50d82SAndre Fischer { 758*02c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 759*02c50d82SAndre Fischer 760*02c50d82SAndre Fischer TokenToValueSetIndex::const_iterator iIndex (maTokenToValueSetIndex.find(aToken)); 761*02c50d82SAndre Fischer if (iIndex != maTokenToValueSetIndex.end()) 762*02c50d82SAndre Fischer return iIndex->second; 763*02c50d82SAndre Fischer else 764*02c50d82SAndre Fischer return -1; 765*02c50d82SAndre Fischer } 766*02c50d82SAndre Fischer 767*02c50d82SAndre Fischer 768*02c50d82SAndre Fischer 769*02c50d82SAndre Fischer 770*02c50d82SAndre Fischer void MasterPagesSelector::Clear (void) 771*02c50d82SAndre Fischer { 772*02c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 773*02c50d82SAndre Fischer 774*02c50d82SAndre Fischer ClearPageSet(); 775*02c50d82SAndre Fischer } 776*02c50d82SAndre Fischer 777*02c50d82SAndre Fischer 778*02c50d82SAndre Fischer 779*02c50d82SAndre Fischer 780*02c50d82SAndre Fischer void MasterPagesSelector::InvalidateItem (MasterPageContainer::Token aToken) 781*02c50d82SAndre Fischer { 782*02c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 783*02c50d82SAndre Fischer 784*02c50d82SAndre Fischer ItemList::iterator iItem; 785*02c50d82SAndre Fischer for (iItem=maCurrentItemList.begin(); iItem!=maCurrentItemList.end(); ++iItem) 786*02c50d82SAndre Fischer { 787*02c50d82SAndre Fischer if (*iItem == aToken) 788*02c50d82SAndre Fischer { 789*02c50d82SAndre Fischer *iItem = MasterPageContainer::NIL_TOKEN; 790*02c50d82SAndre Fischer break; 791*02c50d82SAndre Fischer } 792*02c50d82SAndre Fischer } 793*02c50d82SAndre Fischer } 794*02c50d82SAndre Fischer 795*02c50d82SAndre Fischer 796*02c50d82SAndre Fischer 797*02c50d82SAndre Fischer 798*02c50d82SAndre Fischer void MasterPagesSelector::UpdateItemList (::std::auto_ptr<ItemList> pNewItemList) 799*02c50d82SAndre Fischer { 800*02c50d82SAndre Fischer const ::osl::MutexGuard aGuard (maMutex); 801*02c50d82SAndre Fischer 802*02c50d82SAndre Fischer ItemList::const_iterator iNewItem (pNewItemList->begin()); 803*02c50d82SAndre Fischer ItemList::const_iterator iCurrentItem (maCurrentItemList.begin()); 804*02c50d82SAndre Fischer ItemList::const_iterator iNewEnd (pNewItemList->end()); 805*02c50d82SAndre Fischer ItemList::const_iterator iCurrentEnd (maCurrentItemList.end()); 806*02c50d82SAndre Fischer sal_uInt16 nIndex (1); 807*02c50d82SAndre Fischer 808*02c50d82SAndre Fischer // Update existing items. 809*02c50d82SAndre Fischer for ( ; iNewItem!=iNewEnd && iCurrentItem!=iCurrentEnd; ++iNewItem, ++iCurrentItem,++nIndex) 810*02c50d82SAndre Fischer { 811*02c50d82SAndre Fischer if (*iNewItem != *iCurrentItem) 812*02c50d82SAndre Fischer { 813*02c50d82SAndre Fischer SetItem(nIndex,*iNewItem); 814*02c50d82SAndre Fischer } 815*02c50d82SAndre Fischer } 816*02c50d82SAndre Fischer 817*02c50d82SAndre Fischer // Append new items. 818*02c50d82SAndre Fischer for ( ; iNewItem!=iNewEnd; ++iNewItem,++nIndex) 819*02c50d82SAndre Fischer { 820*02c50d82SAndre Fischer SetItem(nIndex,*iNewItem); 821*02c50d82SAndre Fischer } 822*02c50d82SAndre Fischer 823*02c50d82SAndre Fischer // Remove trailing items. 824*02c50d82SAndre Fischer for ( ; iCurrentItem!=iCurrentEnd; ++iCurrentItem,++nIndex) 825*02c50d82SAndre Fischer { 826*02c50d82SAndre Fischer SetItem(nIndex,MasterPageContainer::NIL_TOKEN); 827*02c50d82SAndre Fischer } 828*02c50d82SAndre Fischer 829*02c50d82SAndre Fischer maCurrentItemList.swap(*pNewItemList); 830*02c50d82SAndre Fischer 831*02c50d82SAndre Fischer PreviewValueSet::Rearrange(); 832*02c50d82SAndre Fischer if (mxSidebar.is()) 833*02c50d82SAndre Fischer mxSidebar->requestLayout(); 834*02c50d82SAndre Fischer } 835*02c50d82SAndre Fischer 836*02c50d82SAndre Fischer 837*02c50d82SAndre Fischer 838*02c50d82SAndre Fischer 839*02c50d82SAndre Fischer css::ui::LayoutSize MasterPagesSelector::GetHeightForWidth (const sal_Int32 nWidth) 840*02c50d82SAndre Fischer { 841*02c50d82SAndre Fischer const sal_Int32 nHeight (GetPreferredHeight(nWidth)); 842*02c50d82SAndre Fischer return css::ui::LayoutSize(nHeight,nHeight,nHeight); 843*02c50d82SAndre Fischer } 844*02c50d82SAndre Fischer 845*02c50d82SAndre Fischer } } // end of namespace sd::sidebar 846