15b190011SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 35b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 45b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file 55b190011SAndrew Rist * distributed with this work for additional information 65b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file 75b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the 85b190011SAndrew Rist * "License"); you may not use this file except in compliance 95b190011SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 115b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 135b190011SAndrew Rist * Unless required by applicable law or agreed to in writing, 145b190011SAndrew Rist * software distributed under the License is distributed on an 155b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 165b190011SAndrew Rist * KIND, either express or implied. See the License for the 175b190011SAndrew Rist * specific language governing permissions and limitations 185b190011SAndrew Rist * under the License. 19cdf0e10cSrcweir * 205b190011SAndrew Rist *************************************************************/ 215b190011SAndrew Rist 225b190011SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sd.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "ViewShellImplementation.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "sdpage.hxx" 30cdf0e10cSrcweir #include "drawdoc.hxx" 31cdf0e10cSrcweir #include "sdresid.hxx" 32cdf0e10cSrcweir #include "glob.hrc" 33cdf0e10cSrcweir #include "app.hrc" 34cdf0e10cSrcweir #include "strings.hrc" 35cdf0e10cSrcweir #include "strings.hrc" 36cdf0e10cSrcweir #include "helpids.h" 37cdf0e10cSrcweir #include "sdattr.hxx" 38cdf0e10cSrcweir #include "sdabstdlg.hxx" 39cdf0e10cSrcweir #include "unmodpg.hxx" 40cdf0e10cSrcweir #include "Window.hxx" 41cdf0e10cSrcweir #include "optsitem.hxx" 42cdf0e10cSrcweir #include "DrawDocShell.hxx" 43cdf0e10cSrcweir #include "DrawController.hxx" 44cdf0e10cSrcweir #include "FactoryIds.hxx" 45cdf0e10cSrcweir #include "slideshow.hxx" 46cdf0e10cSrcweir #include "ViewShellBase.hxx" 47cdf0e10cSrcweir #include "FrameView.hxx" 48cdf0e10cSrcweir #include "DrawViewShell.hxx" 49cdf0e10cSrcweir #include "ViewShellHint.hxx" 507a32b0c8SAndre Fischer #include "SidebarPanelId.hxx" 51cdf0e10cSrcweir #include "framework/FrameworkHelper.hxx" 52cdf0e10cSrcweir 53cdf0e10cSrcweir #include <sfx2/bindings.hxx> 54cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 55cdf0e10cSrcweir #include <sfx2/request.hxx> 56*3091fa8aSAndre Fischer #include <sfx2/sidebar/Sidebar.hxx> 57cdf0e10cSrcweir #include <svl/aeitem.hxx> 58cdf0e10cSrcweir #include <svx/imapdlg.hxx> 59cdf0e10cSrcweir #include <vcl/msgbox.hxx> 60cdf0e10cSrcweir #include <basic/sbstar.hxx> 61cdf0e10cSrcweir #include "undo/undoobjects.hxx" 62cdf0e10cSrcweir 63cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XControllerManager.hpp> 64cdf0e10cSrcweir 65cdf0e10cSrcweir using namespace ::com::sun::star::uno; 66cdf0e10cSrcweir using namespace ::com::sun::star::drawing::framework; 67cdf0e10cSrcweir using ::sd::framework::FrameworkHelper; 68cdf0e10cSrcweir 69cdf0e10cSrcweir namespace sd { 70cdf0e10cSrcweir 71cdf0e10cSrcweir ViewShell::Implementation::Implementation (ViewShell& rViewShell) 72cdf0e10cSrcweir : mbIsShowingUIControls(false), 73cdf0e10cSrcweir mbIsMainViewShell(false), 74cdf0e10cSrcweir mbIsInitialized(false), 75cdf0e10cSrcweir mbArrangeActive(false), 76cdf0e10cSrcweir mpSubShellFactory(), 77cdf0e10cSrcweir mpUpdateLockForMouse(), 78cdf0e10cSrcweir mrViewShell(rViewShell) 79cdf0e10cSrcweir { 80cdf0e10cSrcweir } 81cdf0e10cSrcweir 82cdf0e10cSrcweir 83cdf0e10cSrcweir 84cdf0e10cSrcweir 85cdf0e10cSrcweir ViewShell::Implementation::~Implementation (void) 86cdf0e10cSrcweir { 87cdf0e10cSrcweir if ( ! mpUpdateLockForMouse.expired()) 88cdf0e10cSrcweir { 89cdf0e10cSrcweir ::boost::shared_ptr<ToolBarManagerLock> pLock(mpUpdateLockForMouse); 90cdf0e10cSrcweir if (pLock.get() != NULL) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir // Force the ToolBarManagerLock to be released even when the 93cdf0e10cSrcweir // IsUICaptured() returns <TRUE/>. 94cdf0e10cSrcweir pLock->Release(true); 95cdf0e10cSrcweir } 96cdf0e10cSrcweir } 97cdf0e10cSrcweir } 98cdf0e10cSrcweir 99cdf0e10cSrcweir 100cdf0e10cSrcweir 101cdf0e10cSrcweir 102cdf0e10cSrcweir void ViewShell::Implementation::ProcessModifyPageSlot ( 103cdf0e10cSrcweir SfxRequest& rRequest, 104cdf0e10cSrcweir SdPage* pCurrentPage, 105cdf0e10cSrcweir PageKind ePageKind) 106cdf0e10cSrcweir { 107cdf0e10cSrcweir SdDrawDocument* pDocument = mrViewShell.GetDoc(); 108cdf0e10cSrcweir SdrLayerAdmin& rLayerAdmin = pDocument->GetLayerAdmin(); 109cdf0e10cSrcweir sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False); 110cdf0e10cSrcweir sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False); 111cdf0e10cSrcweir SetOfByte aVisibleLayers; 112cdf0e10cSrcweir sal_Bool bHandoutMode = sal_False; 113cdf0e10cSrcweir SdPage* pHandoutMPage = NULL; 114cdf0e10cSrcweir String aNewName; 115cdf0e10cSrcweir 116cdf0e10cSrcweir // #95981# 117cdf0e10cSrcweir String aOldName; 118cdf0e10cSrcweir 119cdf0e10cSrcweir AutoLayout aNewAutoLayout; 120cdf0e10cSrcweir 121cdf0e10cSrcweir sal_Bool bBVisible; 122cdf0e10cSrcweir sal_Bool bBObjsVisible; 123cdf0e10cSrcweir const SfxItemSet* pArgs = rRequest.GetArgs(); 124cdf0e10cSrcweir 125cdf0e10cSrcweir if (pCurrentPage != NULL && pCurrentPage->TRG_HasMasterPage()) 126cdf0e10cSrcweir aVisibleLayers = pCurrentPage->TRG_GetMasterPageVisibleLayers(); 127cdf0e10cSrcweir else 128cdf0e10cSrcweir aVisibleLayers.SetAll(); 129cdf0e10cSrcweir 130cdf0e10cSrcweir do 131cdf0e10cSrcweir { 132cdf0e10cSrcweir if (pCurrentPage == NULL) 133cdf0e10cSrcweir break; 134cdf0e10cSrcweir 135cdf0e10cSrcweir if (!pArgs || pArgs->Count() == 1 || pArgs->Count() == 2 ) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir if (pArgs && pArgs->Count() == 2) 138cdf0e10cSrcweir { 139cdf0e10cSrcweir // We have been called with a request that contains two 140cdf0e10cSrcweir // arguments. One was used as preselected layout in a 141cdf0e10cSrcweir // dialog. We could select that layout in the 142cdf0e10cSrcweir // layout panel instead. 143cdf0e10cSrcweir /* 144cdf0e10cSrcweir SFX_REQUEST_ARG (rRequest, pNewAutoLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, sal_False); 145cdf0e10cSrcweir eNewAutoLayout = (AutoLayout) pNewAutoLayout->GetValue 146cdf0e10cSrcweir (); 147cdf0e10cSrcweir */ 148cdf0e10cSrcweir } 149cdf0e10cSrcweir 150cdf0e10cSrcweir // Make the layout menu visible in the tool pane. 151*3091fa8aSAndre Fischer sfx2::sidebar::Sidebar::ShowPanel( 152*3091fa8aSAndre Fischer rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImpressLayoutsPanel")), 153*3091fa8aSAndre Fischer mrViewShell.GetViewFrame()->GetFrame().GetFrameInterface()); 154cdf0e10cSrcweir break; 155cdf0e10cSrcweir } 156cdf0e10cSrcweir else if (pArgs->Count() == 4) 157cdf0e10cSrcweir { 158cdf0e10cSrcweir SFX_REQUEST_ARG (rRequest, pNewName, SfxStringItem, ID_VAL_PAGENAME, sal_False); 159cdf0e10cSrcweir SFX_REQUEST_ARG (rRequest, pNewAutoLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, sal_False); 160cdf0e10cSrcweir SFX_REQUEST_ARG (rRequest, pBVisible, SfxBoolItem, ID_VAL_ISPAGEBACK, sal_False); 161cdf0e10cSrcweir SFX_REQUEST_ARG (rRequest, pBObjsVisible, SfxBoolItem, ID_VAL_ISPAGEOBJ, sal_False); 162cdf0e10cSrcweir AutoLayout aLayout ((AutoLayout)pNewAutoLayout->GetValue ()); 163cdf0e10cSrcweir if (aLayout >= AUTOLAYOUT__START 164cdf0e10cSrcweir && aLayout < AUTOLAYOUT__END) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir aNewName = pNewName->GetValue (); 167cdf0e10cSrcweir aNewAutoLayout = (AutoLayout) pNewAutoLayout->GetValue (); 168cdf0e10cSrcweir bBVisible = pBVisible->GetValue (); 169cdf0e10cSrcweir bBObjsVisible = pBObjsVisible->GetValue (); 170cdf0e10cSrcweir } 171cdf0e10cSrcweir else 172cdf0e10cSrcweir { 173cdf0e10cSrcweir StarBASIC::FatalError (SbERR_BAD_PROP_VALUE); 174cdf0e10cSrcweir rRequest.Ignore (); 175cdf0e10cSrcweir break; 176cdf0e10cSrcweir } 177cdf0e10cSrcweir if (ePageKind == PK_HANDOUT) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir bHandoutMode = sal_True; 180cdf0e10cSrcweir pHandoutMPage = pDocument->GetMasterSdPage(0, PK_HANDOUT); 181cdf0e10cSrcweir } 182cdf0e10cSrcweir } 183cdf0e10cSrcweir else 184cdf0e10cSrcweir { 185cdf0e10cSrcweir StarBASIC::FatalError (SbERR_WRONG_ARGS); 186cdf0e10cSrcweir rRequest.Ignore (); 187cdf0e10cSrcweir break; 188cdf0e10cSrcweir } 189cdf0e10cSrcweir 190cdf0e10cSrcweir SdPage* pUndoPage = 191cdf0e10cSrcweir bHandoutMode ? pHandoutMPage : pCurrentPage; 192cdf0e10cSrcweir 193cdf0e10cSrcweir ::svl::IUndoManager* pUndoManager = mrViewShell.GetDocSh()->GetUndoManager(); 194cdf0e10cSrcweir DBG_ASSERT(pUndoManager, "No UNDO MANAGER ?!?"); 195cdf0e10cSrcweir 196cdf0e10cSrcweir if( pUndoManager ) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir String aComment( SdResId(STR_UNDO_MODIFY_PAGE) ); 199cdf0e10cSrcweir pUndoManager->EnterListAction(aComment, aComment); 200cdf0e10cSrcweir ModifyPageUndoAction* pAction = new ModifyPageUndoAction( 201cdf0e10cSrcweir pDocument, pUndoPage, aNewName, aNewAutoLayout, bBVisible, bBObjsVisible); 202cdf0e10cSrcweir pUndoManager->AddUndoAction(pAction); 203cdf0e10cSrcweir 204cdf0e10cSrcweir // Clear the selection because the selectec object may be removed as 205cdf0e10cSrcweir // a result of the ssignment of the layout. 206cdf0e10cSrcweir mrViewShell.GetDrawView()->UnmarkAll(); 207cdf0e10cSrcweir 208cdf0e10cSrcweir if (!bHandoutMode) 209cdf0e10cSrcweir { 210cdf0e10cSrcweir if (pCurrentPage->GetName() != aNewName) 211cdf0e10cSrcweir { 212cdf0e10cSrcweir pCurrentPage->SetName(aNewName); 213cdf0e10cSrcweir 214cdf0e10cSrcweir if (ePageKind == PK_STANDARD) 215cdf0e10cSrcweir { 216cdf0e10cSrcweir sal_uInt16 nPage = (pCurrentPage->GetPageNum()-1) / 2; 217cdf0e10cSrcweir SdPage* pNotesPage = pDocument->GetSdPage(nPage, PK_NOTES); 218cdf0e10cSrcweir if (pNotesPage != NULL) 219cdf0e10cSrcweir pNotesPage->SetName(aNewName); 220cdf0e10cSrcweir } 221cdf0e10cSrcweir } 222cdf0e10cSrcweir 223cdf0e10cSrcweir pCurrentPage->SetAutoLayout(aNewAutoLayout, sal_True); 224cdf0e10cSrcweir 225cdf0e10cSrcweir aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False); 226cdf0e10cSrcweir aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False); 227cdf0e10cSrcweir aVisibleLayers.Set(aBckgrnd, bBVisible); 228cdf0e10cSrcweir aVisibleLayers.Set(aBckgrndObj, bBObjsVisible); 229cdf0e10cSrcweir pCurrentPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers); 230cdf0e10cSrcweir } 231cdf0e10cSrcweir else 232cdf0e10cSrcweir { 233cdf0e10cSrcweir pHandoutMPage->SetAutoLayout(aNewAutoLayout, sal_True); 234cdf0e10cSrcweir } 235cdf0e10cSrcweir 236cdf0e10cSrcweir mrViewShell.GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHPAGE, 237cdf0e10cSrcweir SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD); 238cdf0e10cSrcweir 239cdf0e10cSrcweir sal_Bool bSetModified = sal_True; 240cdf0e10cSrcweir 241cdf0e10cSrcweir if (pArgs && pArgs->Count() == 1) 242cdf0e10cSrcweir { 243cdf0e10cSrcweir bSetModified = (sal_Bool) ((SfxBoolItem&) pArgs->Get(SID_MODIFYPAGE)).GetValue(); 244cdf0e10cSrcweir } 245cdf0e10cSrcweir 246cdf0e10cSrcweir pUndoManager->AddUndoAction( new UndoAutoLayoutPosAndSize( *pUndoPage ) ); 247cdf0e10cSrcweir pUndoManager->LeaveListAction(); 248cdf0e10cSrcweir 249cdf0e10cSrcweir pDocument->SetChanged(bSetModified); 250cdf0e10cSrcweir } 251cdf0e10cSrcweir } 252cdf0e10cSrcweir while (false); 253cdf0e10cSrcweir 254cdf0e10cSrcweir mrViewShell.Cancel(); 255cdf0e10cSrcweir rRequest.Done (); 256cdf0e10cSrcweir } 257cdf0e10cSrcweir 258cdf0e10cSrcweir void ViewShell::Implementation::AssignLayout ( SfxRequest& rRequest, PageKind ePageKind ) 259cdf0e10cSrcweir { 260cdf0e10cSrcweir const SfxUInt32Item* pWhatPage = static_cast< const SfxUInt32Item* > ( rRequest.GetArg( ID_VAL_WHATPAGE, sal_False, TYPE(SfxUInt32Item) ) ); 261cdf0e10cSrcweir const SfxUInt32Item* pWhatLayout = static_cast< const SfxUInt32Item* > ( rRequest.GetArg( ID_VAL_WHATLAYOUT, sal_False, TYPE(SfxUInt32Item) ) ); 262cdf0e10cSrcweir 263cdf0e10cSrcweir SdDrawDocument* pDocument = mrViewShell.GetDoc(); 264cdf0e10cSrcweir if( !pDocument ) 265cdf0e10cSrcweir return; 266cdf0e10cSrcweir 267cdf0e10cSrcweir SdPage* pPage = 0; 268cdf0e10cSrcweir if( pWhatPage ) 269cdf0e10cSrcweir { 270cdf0e10cSrcweir pPage = pDocument->GetSdPage(static_cast<sal_uInt16>(pWhatPage->GetValue()), ePageKind); 271cdf0e10cSrcweir } 272cdf0e10cSrcweir 273cdf0e10cSrcweir if( pPage == 0 ) 274cdf0e10cSrcweir pPage = mrViewShell.getCurrentPage(); 275cdf0e10cSrcweir 276cdf0e10cSrcweir if( pPage ) 277cdf0e10cSrcweir { 278cdf0e10cSrcweir AutoLayout eLayout = pPage->GetAutoLayout(); 279cdf0e10cSrcweir 280cdf0e10cSrcweir if( pWhatLayout ) 281cdf0e10cSrcweir eLayout = static_cast< AutoLayout >( pWhatLayout->GetValue() ); 282cdf0e10cSrcweir 283cdf0e10cSrcweir // Transform the given request into the four argument form that is 284cdf0e10cSrcweir // understood by ProcessModifyPageSlot(). 285cdf0e10cSrcweir SdrLayerAdmin& rLayerAdmin (mrViewShell.GetViewShellBase().GetDocument()->GetLayerAdmin()); 286cdf0e10cSrcweir sal_uInt8 aBackground (rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False)); 287cdf0e10cSrcweir sal_uInt8 aBackgroundObject (rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False)); 288cdf0e10cSrcweir 289cdf0e10cSrcweir SetOfByte aVisibleLayers; 290cdf0e10cSrcweir 291cdf0e10cSrcweir if( pPage->GetPageKind() == PK_HANDOUT ) 292cdf0e10cSrcweir aVisibleLayers.SetAll(); 293cdf0e10cSrcweir else 294cdf0e10cSrcweir aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers(); 295cdf0e10cSrcweir 296cdf0e10cSrcweir SfxRequest aRequest (mrViewShell.GetViewShellBase().GetViewFrame(), SID_MODIFYPAGE); 297cdf0e10cSrcweir aRequest.AppendItem(SfxStringItem (ID_VAL_PAGENAME, pPage->GetName())); 298cdf0e10cSrcweir aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, eLayout)); 299cdf0e10cSrcweir aRequest.AppendItem(SfxBoolItem(ID_VAL_ISPAGEBACK, aVisibleLayers.IsSet(aBackground))); 300cdf0e10cSrcweir aRequest.AppendItem(SfxBoolItem(ID_VAL_ISPAGEOBJ, aVisibleLayers.IsSet(aBackgroundObject))); 301cdf0e10cSrcweir 302cdf0e10cSrcweir // Forward the call with the new arguments. 303cdf0e10cSrcweir ProcessModifyPageSlot( aRequest, pPage, pPage->GetPageKind()); 304cdf0e10cSrcweir } 305cdf0e10cSrcweir } 306cdf0e10cSrcweir 307cdf0e10cSrcweir 308cdf0e10cSrcweir 309cdf0e10cSrcweir 310cdf0e10cSrcweir sal_uInt16 ViewShell::Implementation::GetViewId (void) 311cdf0e10cSrcweir { 312cdf0e10cSrcweir switch (mrViewShell.GetShellType()) 313cdf0e10cSrcweir { 314cdf0e10cSrcweir case ViewShell::ST_IMPRESS: 315cdf0e10cSrcweir case ViewShell::ST_NOTES: 316cdf0e10cSrcweir case ViewShell::ST_HANDOUT: 317cdf0e10cSrcweir return IMPRESS_FACTORY_ID; 318cdf0e10cSrcweir 319cdf0e10cSrcweir case ViewShell::ST_DRAW: 320cdf0e10cSrcweir return DRAW_FACTORY_ID; 321cdf0e10cSrcweir 322cdf0e10cSrcweir case ViewShell::ST_OUTLINE: 323cdf0e10cSrcweir return OUTLINE_FACTORY_ID; 324cdf0e10cSrcweir 325cdf0e10cSrcweir case ViewShell::ST_SLIDE_SORTER: 326cdf0e10cSrcweir return SLIDE_SORTER_FACTORY_ID; 327cdf0e10cSrcweir 328cdf0e10cSrcweir case ViewShell::ST_PRESENTATION: 329cdf0e10cSrcweir return PRESENTATION_FACTORY_ID; 330cdf0e10cSrcweir 331cdf0e10cSrcweir // Since we have to return a view id for every possible shell type 332cdf0e10cSrcweir // and there is not (yet) a proper ViewShellBase sub class for the 333cdf0e10cSrcweir // remaining types we chose the Impress factory as a fall back. 3347a32b0c8SAndre Fischer case ViewShell::ST_SIDEBAR: 335cdf0e10cSrcweir case ViewShell::ST_NONE: 336cdf0e10cSrcweir default: 337cdf0e10cSrcweir return IMPRESS_FACTORY_ID; 338cdf0e10cSrcweir } 339cdf0e10cSrcweir } 340cdf0e10cSrcweir 341cdf0e10cSrcweir 342cdf0e10cSrcweir 343cdf0e10cSrcweir 344cdf0e10cSrcweir SvxIMapDlg* ViewShell::Implementation::GetImageMapDialog (void) 345cdf0e10cSrcweir { 346cdf0e10cSrcweir SvxIMapDlg* pDialog = NULL; 347cdf0e10cSrcweir SfxChildWindow* pChildWindow = SfxViewFrame::Current()->GetChildWindow( 348cdf0e10cSrcweir SvxIMapDlgChildWindow::GetChildWindowId()); 349cdf0e10cSrcweir if (pChildWindow != NULL) 350cdf0e10cSrcweir pDialog = dynamic_cast<SvxIMapDlg*>(pChildWindow->GetWindow()); 351cdf0e10cSrcweir return pDialog; 352cdf0e10cSrcweir } 353cdf0e10cSrcweir 354cdf0e10cSrcweir 355cdf0e10cSrcweir 356cdf0e10cSrcweir //===== ToolBarManagerLock ==================================================== 357cdf0e10cSrcweir 358cdf0e10cSrcweir class ViewShell::Implementation::ToolBarManagerLock::Deleter { public: 359cdf0e10cSrcweir void operator() (ToolBarManagerLock* pObject) { delete pObject; } 360cdf0e10cSrcweir }; 361cdf0e10cSrcweir 362cdf0e10cSrcweir ::boost::shared_ptr<ViewShell::Implementation::ToolBarManagerLock> 363cdf0e10cSrcweir ViewShell::Implementation::ToolBarManagerLock::Create ( 364cdf0e10cSrcweir const ::boost::shared_ptr<ToolBarManager>& rpManager) 365cdf0e10cSrcweir { 366cdf0e10cSrcweir ::boost::shared_ptr<ToolBarManagerLock> pLock ( 367cdf0e10cSrcweir new ViewShell::Implementation::ToolBarManagerLock(rpManager), 368cdf0e10cSrcweir ViewShell::Implementation::ToolBarManagerLock::Deleter()); 369cdf0e10cSrcweir pLock->mpSelf = pLock; 370cdf0e10cSrcweir return pLock; 371cdf0e10cSrcweir } 372cdf0e10cSrcweir 373cdf0e10cSrcweir 374cdf0e10cSrcweir 375cdf0e10cSrcweir 376cdf0e10cSrcweir ViewShell::Implementation::ToolBarManagerLock::ToolBarManagerLock ( 377cdf0e10cSrcweir const ::boost::shared_ptr<ToolBarManager>& rpManager) 378cdf0e10cSrcweir : mpLock(new ToolBarManager::UpdateLock(rpManager)), 379cdf0e10cSrcweir maTimer() 380cdf0e10cSrcweir { 381cdf0e10cSrcweir // Start a timer that will unlock the ToolBarManager update lock when 382cdf0e10cSrcweir // that is not done explicitly by calling Release(). 383cdf0e10cSrcweir maTimer.SetTimeoutHdl(LINK(this,ToolBarManagerLock,TimeoutCallback)); 384cdf0e10cSrcweir maTimer.SetTimeout(100); 385cdf0e10cSrcweir maTimer.Start(); 386cdf0e10cSrcweir } 387cdf0e10cSrcweir 388cdf0e10cSrcweir 389cdf0e10cSrcweir 390cdf0e10cSrcweir 391cdf0e10cSrcweir IMPL_LINK(ViewShell::Implementation::ToolBarManagerLock,TimeoutCallback,Timer*,EMPTYARG) 392cdf0e10cSrcweir { 393cdf0e10cSrcweir // If possible then release the lock now. Otherwise start the timer 394cdf0e10cSrcweir // and try again later. 395cdf0e10cSrcweir if (Application::IsUICaptured()) 396cdf0e10cSrcweir { 397cdf0e10cSrcweir maTimer.Start(); 398cdf0e10cSrcweir } 399cdf0e10cSrcweir else 400cdf0e10cSrcweir { 401cdf0e10cSrcweir mpSelf.reset(); 402cdf0e10cSrcweir } 403cdf0e10cSrcweir return 0; 404cdf0e10cSrcweir } 405cdf0e10cSrcweir 406cdf0e10cSrcweir 407cdf0e10cSrcweir 408cdf0e10cSrcweir 409cdf0e10cSrcweir void ViewShell::Implementation::ToolBarManagerLock::Release (bool bForce) 410cdf0e10cSrcweir { 411cdf0e10cSrcweir // If possible then release the lock now. Otherwise try again when the 412cdf0e10cSrcweir // timer expires. 413cdf0e10cSrcweir if (bForce || ! Application::IsUICaptured()) 414cdf0e10cSrcweir { 415cdf0e10cSrcweir mpSelf.reset(); 416cdf0e10cSrcweir } 417cdf0e10cSrcweir } 418cdf0e10cSrcweir 419cdf0e10cSrcweir 420cdf0e10cSrcweir 421cdf0e10cSrcweir 422cdf0e10cSrcweir ViewShell::Implementation::ToolBarManagerLock::~ToolBarManagerLock (void) 423cdf0e10cSrcweir { 424cdf0e10cSrcweir mpLock.reset(); 425cdf0e10cSrcweir } 426cdf0e10cSrcweir 427cdf0e10cSrcweir } // end of namespace sd 428