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