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" 50*7a32b0c8SAndre 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> 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); 151*7a32b0c8SAndre Fischer SfxUInt32Item aPanelId (ID_VAL_PANEL_INDEX, sidebar::PID_LAYOUT); 152cdf0e10cSrcweir SfxViewFrame* pFrame = mrViewShell.GetViewFrame(); 153cdf0e10cSrcweir if (pFrame!=NULL && pFrame->GetDispatcher()!=NULL) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir pFrame->GetDispatcher()->Execute ( 156cdf0e10cSrcweir SID_SHOW_TOOL_PANEL, 157cdf0e10cSrcweir SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, 158cdf0e10cSrcweir &aMakeToolPaneVisible, 159cdf0e10cSrcweir &aPanelId, 160cdf0e10cSrcweir NULL); 161cdf0e10cSrcweir } 162cdf0e10cSrcweir else 163cdf0e10cSrcweir { 164cdf0e10cSrcweir DBG_ASSERT(pFrame!=NULL && pFrame->GetDispatcher()!=NULL, 165cdf0e10cSrcweir "ViewShell::Implementation::ProcessModifyPageSlot(): can not get dispatcher"); 166cdf0e10cSrcweir } 167cdf0e10cSrcweir 168cdf0e10cSrcweir // We have activated a non-modal control in the task pane. 169cdf0e10cSrcweir // Because it does not return anything we can not do anything 170cdf0e10cSrcweir // more right now and have to exit here. 171cdf0e10cSrcweir break; 172cdf0e10cSrcweir } 173cdf0e10cSrcweir else if (pArgs->Count() == 4) 174cdf0e10cSrcweir { 175cdf0e10cSrcweir SFX_REQUEST_ARG (rRequest, pNewName, SfxStringItem, ID_VAL_PAGENAME, sal_False); 176cdf0e10cSrcweir SFX_REQUEST_ARG (rRequest, pNewAutoLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, sal_False); 177cdf0e10cSrcweir SFX_REQUEST_ARG (rRequest, pBVisible, SfxBoolItem, ID_VAL_ISPAGEBACK, sal_False); 178cdf0e10cSrcweir SFX_REQUEST_ARG (rRequest, pBObjsVisible, SfxBoolItem, ID_VAL_ISPAGEOBJ, sal_False); 179cdf0e10cSrcweir AutoLayout aLayout ((AutoLayout)pNewAutoLayout->GetValue ()); 180cdf0e10cSrcweir if (aLayout >= AUTOLAYOUT__START 181cdf0e10cSrcweir && aLayout < AUTOLAYOUT__END) 182cdf0e10cSrcweir { 183cdf0e10cSrcweir aNewName = pNewName->GetValue (); 184cdf0e10cSrcweir aNewAutoLayout = (AutoLayout) pNewAutoLayout->GetValue (); 185cdf0e10cSrcweir bBVisible = pBVisible->GetValue (); 186cdf0e10cSrcweir bBObjsVisible = pBObjsVisible->GetValue (); 187cdf0e10cSrcweir } 188cdf0e10cSrcweir else 189cdf0e10cSrcweir { 190cdf0e10cSrcweir StarBASIC::FatalError (SbERR_BAD_PROP_VALUE); 191cdf0e10cSrcweir rRequest.Ignore (); 192cdf0e10cSrcweir break; 193cdf0e10cSrcweir } 194cdf0e10cSrcweir if (ePageKind == PK_HANDOUT) 195cdf0e10cSrcweir { 196cdf0e10cSrcweir bHandoutMode = sal_True; 197cdf0e10cSrcweir pHandoutMPage = pDocument->GetMasterSdPage(0, PK_HANDOUT); 198cdf0e10cSrcweir } 199cdf0e10cSrcweir } 200cdf0e10cSrcweir else 201cdf0e10cSrcweir { 202cdf0e10cSrcweir StarBASIC::FatalError (SbERR_WRONG_ARGS); 203cdf0e10cSrcweir rRequest.Ignore (); 204cdf0e10cSrcweir break; 205cdf0e10cSrcweir } 206cdf0e10cSrcweir 207cdf0e10cSrcweir SdPage* pUndoPage = 208cdf0e10cSrcweir bHandoutMode ? pHandoutMPage : pCurrentPage; 209cdf0e10cSrcweir 210cdf0e10cSrcweir ::svl::IUndoManager* pUndoManager = mrViewShell.GetDocSh()->GetUndoManager(); 211cdf0e10cSrcweir DBG_ASSERT(pUndoManager, "No UNDO MANAGER ?!?"); 212cdf0e10cSrcweir 213cdf0e10cSrcweir if( pUndoManager ) 214cdf0e10cSrcweir { 215cdf0e10cSrcweir String aComment( SdResId(STR_UNDO_MODIFY_PAGE) ); 216cdf0e10cSrcweir pUndoManager->EnterListAction(aComment, aComment); 217cdf0e10cSrcweir ModifyPageUndoAction* pAction = new ModifyPageUndoAction( 218cdf0e10cSrcweir pDocument, pUndoPage, aNewName, aNewAutoLayout, bBVisible, bBObjsVisible); 219cdf0e10cSrcweir pUndoManager->AddUndoAction(pAction); 220cdf0e10cSrcweir 221cdf0e10cSrcweir // Clear the selection because the selectec object may be removed as 222cdf0e10cSrcweir // a result of the ssignment of the layout. 223cdf0e10cSrcweir mrViewShell.GetDrawView()->UnmarkAll(); 224cdf0e10cSrcweir 225cdf0e10cSrcweir if (!bHandoutMode) 226cdf0e10cSrcweir { 227cdf0e10cSrcweir if (pCurrentPage->GetName() != aNewName) 228cdf0e10cSrcweir { 229cdf0e10cSrcweir pCurrentPage->SetName(aNewName); 230cdf0e10cSrcweir 231cdf0e10cSrcweir if (ePageKind == PK_STANDARD) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir sal_uInt16 nPage = (pCurrentPage->GetPageNum()-1) / 2; 234cdf0e10cSrcweir SdPage* pNotesPage = pDocument->GetSdPage(nPage, PK_NOTES); 235cdf0e10cSrcweir if (pNotesPage != NULL) 236cdf0e10cSrcweir pNotesPage->SetName(aNewName); 237cdf0e10cSrcweir } 238cdf0e10cSrcweir } 239cdf0e10cSrcweir 240cdf0e10cSrcweir pCurrentPage->SetAutoLayout(aNewAutoLayout, sal_True); 241cdf0e10cSrcweir 242cdf0e10cSrcweir aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False); 243cdf0e10cSrcweir aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False); 244cdf0e10cSrcweir aVisibleLayers.Set(aBckgrnd, bBVisible); 245cdf0e10cSrcweir aVisibleLayers.Set(aBckgrndObj, bBObjsVisible); 246cdf0e10cSrcweir pCurrentPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers); 247cdf0e10cSrcweir } 248cdf0e10cSrcweir else 249cdf0e10cSrcweir { 250cdf0e10cSrcweir pHandoutMPage->SetAutoLayout(aNewAutoLayout, sal_True); 251cdf0e10cSrcweir } 252cdf0e10cSrcweir 253cdf0e10cSrcweir mrViewShell.GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHPAGE, 254cdf0e10cSrcweir SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD); 255cdf0e10cSrcweir 256cdf0e10cSrcweir sal_Bool bSetModified = sal_True; 257cdf0e10cSrcweir 258cdf0e10cSrcweir if (pArgs && pArgs->Count() == 1) 259cdf0e10cSrcweir { 260cdf0e10cSrcweir bSetModified = (sal_Bool) ((SfxBoolItem&) pArgs->Get(SID_MODIFYPAGE)).GetValue(); 261cdf0e10cSrcweir } 262cdf0e10cSrcweir 263cdf0e10cSrcweir pUndoManager->AddUndoAction( new UndoAutoLayoutPosAndSize( *pUndoPage ) ); 264cdf0e10cSrcweir pUndoManager->LeaveListAction(); 265cdf0e10cSrcweir 266cdf0e10cSrcweir pDocument->SetChanged(bSetModified); 267cdf0e10cSrcweir } 268cdf0e10cSrcweir } 269cdf0e10cSrcweir while (false); 270cdf0e10cSrcweir 271cdf0e10cSrcweir mrViewShell.Cancel(); 272cdf0e10cSrcweir rRequest.Done (); 273cdf0e10cSrcweir } 274cdf0e10cSrcweir 275cdf0e10cSrcweir void ViewShell::Implementation::AssignLayout ( SfxRequest& rRequest, PageKind ePageKind ) 276cdf0e10cSrcweir { 277cdf0e10cSrcweir const SfxUInt32Item* pWhatPage = static_cast< const SfxUInt32Item* > ( rRequest.GetArg( ID_VAL_WHATPAGE, sal_False, TYPE(SfxUInt32Item) ) ); 278cdf0e10cSrcweir const SfxUInt32Item* pWhatLayout = static_cast< const SfxUInt32Item* > ( rRequest.GetArg( ID_VAL_WHATLAYOUT, sal_False, TYPE(SfxUInt32Item) ) ); 279cdf0e10cSrcweir 280cdf0e10cSrcweir SdDrawDocument* pDocument = mrViewShell.GetDoc(); 281cdf0e10cSrcweir if( !pDocument ) 282cdf0e10cSrcweir return; 283cdf0e10cSrcweir 284cdf0e10cSrcweir SdPage* pPage = 0; 285cdf0e10cSrcweir if( pWhatPage ) 286cdf0e10cSrcweir { 287cdf0e10cSrcweir pPage = pDocument->GetSdPage(static_cast<sal_uInt16>(pWhatPage->GetValue()), ePageKind); 288cdf0e10cSrcweir } 289cdf0e10cSrcweir 290cdf0e10cSrcweir if( pPage == 0 ) 291cdf0e10cSrcweir pPage = mrViewShell.getCurrentPage(); 292cdf0e10cSrcweir 293cdf0e10cSrcweir if( pPage ) 294cdf0e10cSrcweir { 295cdf0e10cSrcweir AutoLayout eLayout = pPage->GetAutoLayout(); 296cdf0e10cSrcweir 297cdf0e10cSrcweir if( pWhatLayout ) 298cdf0e10cSrcweir eLayout = static_cast< AutoLayout >( pWhatLayout->GetValue() ); 299cdf0e10cSrcweir 300cdf0e10cSrcweir // Transform the given request into the four argument form that is 301cdf0e10cSrcweir // understood by ProcessModifyPageSlot(). 302cdf0e10cSrcweir SdrLayerAdmin& rLayerAdmin (mrViewShell.GetViewShellBase().GetDocument()->GetLayerAdmin()); 303cdf0e10cSrcweir sal_uInt8 aBackground (rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False)); 304cdf0e10cSrcweir sal_uInt8 aBackgroundObject (rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False)); 305cdf0e10cSrcweir 306cdf0e10cSrcweir SetOfByte aVisibleLayers; 307cdf0e10cSrcweir 308cdf0e10cSrcweir if( pPage->GetPageKind() == PK_HANDOUT ) 309cdf0e10cSrcweir aVisibleLayers.SetAll(); 310cdf0e10cSrcweir else 311cdf0e10cSrcweir aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers(); 312cdf0e10cSrcweir 313cdf0e10cSrcweir SfxRequest aRequest (mrViewShell.GetViewShellBase().GetViewFrame(), SID_MODIFYPAGE); 314cdf0e10cSrcweir aRequest.AppendItem(SfxStringItem (ID_VAL_PAGENAME, pPage->GetName())); 315cdf0e10cSrcweir aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, eLayout)); 316cdf0e10cSrcweir aRequest.AppendItem(SfxBoolItem(ID_VAL_ISPAGEBACK, aVisibleLayers.IsSet(aBackground))); 317cdf0e10cSrcweir aRequest.AppendItem(SfxBoolItem(ID_VAL_ISPAGEOBJ, aVisibleLayers.IsSet(aBackgroundObject))); 318cdf0e10cSrcweir 319cdf0e10cSrcweir // Forward the call with the new arguments. 320cdf0e10cSrcweir ProcessModifyPageSlot( aRequest, pPage, pPage->GetPageKind()); 321cdf0e10cSrcweir } 322cdf0e10cSrcweir } 323cdf0e10cSrcweir 324cdf0e10cSrcweir 325cdf0e10cSrcweir 326cdf0e10cSrcweir 327cdf0e10cSrcweir sal_uInt16 ViewShell::Implementation::GetViewId (void) 328cdf0e10cSrcweir { 329cdf0e10cSrcweir switch (mrViewShell.GetShellType()) 330cdf0e10cSrcweir { 331cdf0e10cSrcweir case ViewShell::ST_IMPRESS: 332cdf0e10cSrcweir case ViewShell::ST_NOTES: 333cdf0e10cSrcweir case ViewShell::ST_HANDOUT: 334cdf0e10cSrcweir return IMPRESS_FACTORY_ID; 335cdf0e10cSrcweir 336cdf0e10cSrcweir case ViewShell::ST_DRAW: 337cdf0e10cSrcweir return DRAW_FACTORY_ID; 338cdf0e10cSrcweir 339cdf0e10cSrcweir case ViewShell::ST_OUTLINE: 340cdf0e10cSrcweir return OUTLINE_FACTORY_ID; 341cdf0e10cSrcweir 342cdf0e10cSrcweir case ViewShell::ST_SLIDE_SORTER: 343cdf0e10cSrcweir return SLIDE_SORTER_FACTORY_ID; 344cdf0e10cSrcweir 345cdf0e10cSrcweir case ViewShell::ST_PRESENTATION: 346cdf0e10cSrcweir return PRESENTATION_FACTORY_ID; 347cdf0e10cSrcweir 348cdf0e10cSrcweir // Since we have to return a view id for every possible shell type 349cdf0e10cSrcweir // and there is not (yet) a proper ViewShellBase sub class for the 350cdf0e10cSrcweir // remaining types we chose the Impress factory as a fall back. 351*7a32b0c8SAndre Fischer case ViewShell::ST_SIDEBAR: 352cdf0e10cSrcweir case ViewShell::ST_NONE: 353cdf0e10cSrcweir default: 354cdf0e10cSrcweir return IMPRESS_FACTORY_ID; 355cdf0e10cSrcweir } 356cdf0e10cSrcweir } 357cdf0e10cSrcweir 358cdf0e10cSrcweir 359cdf0e10cSrcweir 360cdf0e10cSrcweir 361cdf0e10cSrcweir SvxIMapDlg* ViewShell::Implementation::GetImageMapDialog (void) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir SvxIMapDlg* pDialog = NULL; 364cdf0e10cSrcweir SfxChildWindow* pChildWindow = SfxViewFrame::Current()->GetChildWindow( 365cdf0e10cSrcweir SvxIMapDlgChildWindow::GetChildWindowId()); 366cdf0e10cSrcweir if (pChildWindow != NULL) 367cdf0e10cSrcweir pDialog = dynamic_cast<SvxIMapDlg*>(pChildWindow->GetWindow()); 368cdf0e10cSrcweir return pDialog; 369cdf0e10cSrcweir } 370cdf0e10cSrcweir 371cdf0e10cSrcweir 372cdf0e10cSrcweir 373cdf0e10cSrcweir //===== ToolBarManagerLock ==================================================== 374cdf0e10cSrcweir 375cdf0e10cSrcweir class ViewShell::Implementation::ToolBarManagerLock::Deleter { public: 376cdf0e10cSrcweir void operator() (ToolBarManagerLock* pObject) { delete pObject; } 377cdf0e10cSrcweir }; 378cdf0e10cSrcweir 379cdf0e10cSrcweir ::boost::shared_ptr<ViewShell::Implementation::ToolBarManagerLock> 380cdf0e10cSrcweir ViewShell::Implementation::ToolBarManagerLock::Create ( 381cdf0e10cSrcweir const ::boost::shared_ptr<ToolBarManager>& rpManager) 382cdf0e10cSrcweir { 383cdf0e10cSrcweir ::boost::shared_ptr<ToolBarManagerLock> pLock ( 384cdf0e10cSrcweir new ViewShell::Implementation::ToolBarManagerLock(rpManager), 385cdf0e10cSrcweir ViewShell::Implementation::ToolBarManagerLock::Deleter()); 386cdf0e10cSrcweir pLock->mpSelf = pLock; 387cdf0e10cSrcweir return pLock; 388cdf0e10cSrcweir } 389cdf0e10cSrcweir 390cdf0e10cSrcweir 391cdf0e10cSrcweir 392cdf0e10cSrcweir 393cdf0e10cSrcweir ViewShell::Implementation::ToolBarManagerLock::ToolBarManagerLock ( 394cdf0e10cSrcweir const ::boost::shared_ptr<ToolBarManager>& rpManager) 395cdf0e10cSrcweir : mpLock(new ToolBarManager::UpdateLock(rpManager)), 396cdf0e10cSrcweir maTimer() 397cdf0e10cSrcweir { 398cdf0e10cSrcweir // Start a timer that will unlock the ToolBarManager update lock when 399cdf0e10cSrcweir // that is not done explicitly by calling Release(). 400cdf0e10cSrcweir maTimer.SetTimeoutHdl(LINK(this,ToolBarManagerLock,TimeoutCallback)); 401cdf0e10cSrcweir maTimer.SetTimeout(100); 402cdf0e10cSrcweir maTimer.Start(); 403cdf0e10cSrcweir } 404cdf0e10cSrcweir 405cdf0e10cSrcweir 406cdf0e10cSrcweir 407cdf0e10cSrcweir 408cdf0e10cSrcweir IMPL_LINK(ViewShell::Implementation::ToolBarManagerLock,TimeoutCallback,Timer*,EMPTYARG) 409cdf0e10cSrcweir { 410cdf0e10cSrcweir // If possible then release the lock now. Otherwise start the timer 411cdf0e10cSrcweir // and try again later. 412cdf0e10cSrcweir if (Application::IsUICaptured()) 413cdf0e10cSrcweir { 414cdf0e10cSrcweir maTimer.Start(); 415cdf0e10cSrcweir } 416cdf0e10cSrcweir else 417cdf0e10cSrcweir { 418cdf0e10cSrcweir mpSelf.reset(); 419cdf0e10cSrcweir } 420cdf0e10cSrcweir return 0; 421cdf0e10cSrcweir } 422cdf0e10cSrcweir 423cdf0e10cSrcweir 424cdf0e10cSrcweir 425cdf0e10cSrcweir 426cdf0e10cSrcweir void ViewShell::Implementation::ToolBarManagerLock::Release (bool bForce) 427cdf0e10cSrcweir { 428cdf0e10cSrcweir // If possible then release the lock now. Otherwise try again when the 429cdf0e10cSrcweir // timer expires. 430cdf0e10cSrcweir if (bForce || ! Application::IsUICaptured()) 431cdf0e10cSrcweir { 432cdf0e10cSrcweir mpSelf.reset(); 433cdf0e10cSrcweir } 434cdf0e10cSrcweir } 435cdf0e10cSrcweir 436cdf0e10cSrcweir 437cdf0e10cSrcweir 438cdf0e10cSrcweir 439cdf0e10cSrcweir ViewShell::Implementation::ToolBarManagerLock::~ToolBarManagerLock (void) 440cdf0e10cSrcweir { 441cdf0e10cSrcweir mpLock.reset(); 442cdf0e10cSrcweir } 443cdf0e10cSrcweir 444cdf0e10cSrcweir } // end of namespace sd 445