This is an automated email from the ASF dual-hosted git repository. mseidel pushed a commit to branch AOO42X in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/AOO42X by this push: new af1407b Fixed typos, removed whitespace af1407b is described below commit af1407b92dd487f389e9d0498dfd31aeef227a90 Author: mseidel <msei...@apache.org> AuthorDate: Wed Nov 3 21:30:41 2021 +0100 Fixed typos, removed whitespace (cherry picked from commit 124483a353bd96cd81c84b9ddbe78ff4bf5efad3) --- main/sd/source/ui/view/ViewShellImplementation.cxx | 440 ++--- main/sd/source/ui/view/ViewShellManager.cxx | 1944 ++++++++++---------- 2 files changed, 1192 insertions(+), 1192 deletions(-) diff --git a/main/sd/source/ui/view/ViewShellImplementation.cxx b/main/sd/source/ui/view/ViewShellImplementation.cxx index 7eb6cc4..2d13bc8 100644 --- a/main/sd/source/ui/view/ViewShellImplementation.cxx +++ b/main/sd/source/ui/view/ViewShellImplementation.cxx @@ -1,5 +1,5 @@ /************************************************************** - * + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -7,16 +7,16 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ @@ -69,13 +69,13 @@ using ::sd::framework::FrameworkHelper; namespace sd { ViewShell::Implementation::Implementation (ViewShell& rViewShell) - : mbIsShowingUIControls(false), - mbIsMainViewShell(false), - mbIsInitialized(false), - mbArrangeActive(false), - mpSubShellFactory(), - mpUpdateLockForMouse(), - mrViewShell(rViewShell) + : mbIsShowingUIControls(false), + mbIsMainViewShell(false), + mbIsInitialized(false), + mbArrangeActive(false), + mpSubShellFactory(), + mpUpdateLockForMouse(), + mrViewShell(rViewShell) { } @@ -84,114 +84,114 @@ ViewShell::Implementation::Implementation (ViewShell& rViewShell) ViewShell::Implementation::~Implementation (void) { - if ( ! mpUpdateLockForMouse.expired()) - { - ::boost::shared_ptr<ToolBarManagerLock> pLock(mpUpdateLockForMouse); - if (pLock.get() != NULL) - { - // Force the ToolBarManagerLock to be released even when the - // IsUICaptured() returns <TRUE/>. - pLock->Release(true); - } - } + if ( ! mpUpdateLockForMouse.expired()) + { + ::boost::shared_ptr<ToolBarManagerLock> pLock(mpUpdateLockForMouse); + if (pLock.get() != NULL) + { + // Force the ToolBarManagerLock to be released even when the + // IsUICaptured() returns <TRUE/>. + pLock->Release(true); + } + } } void ViewShell::Implementation::ProcessModifyPageSlot ( - SfxRequest& rRequest, - SdPage* pCurrentPage, - PageKind ePageKind) + SfxRequest& rRequest, + SdPage* pCurrentPage, + PageKind ePageKind) { - SdDrawDocument* pDocument = mrViewShell.GetDoc(); - SdrLayerAdmin& rLayerAdmin = pDocument->GetLayerAdmin(); - sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False); - sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False); - SetOfByte aVisibleLayers; - sal_Bool bHandoutMode = sal_False; - SdPage* pHandoutMPage = NULL; - String aNewName; - - // #95981# - String aOldName; - - AutoLayout aNewAutoLayout; - - sal_Bool bBVisible; - sal_Bool bBObjsVisible; - const SfxItemSet* pArgs = rRequest.GetArgs(); - - if (pCurrentPage != NULL && pCurrentPage->TRG_HasMasterPage()) - aVisibleLayers = pCurrentPage->TRG_GetMasterPageVisibleLayers(); - else - aVisibleLayers.SetAll(); - - do - { - if (pCurrentPage == NULL) - break; - - if (!pArgs || pArgs->Count() == 1 || pArgs->Count() == 2 ) - { - if (pArgs && pArgs->Count() == 2) - { - // We have been called with a request that contains two - // arguments. One was used as preselected layout in a - // dialog. We could select that layout in the - // layout panel instead. - /* - SFX_REQUEST_ARG (rRequest, pNewAutoLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, sal_False); - eNewAutoLayout = (AutoLayout) pNewAutoLayout->GetValue - (); - */ - } - - // Make the layout menu visible in the tool pane. - sfx2::sidebar::Sidebar::ShowPanel( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImpressLayoutsPanel")), - mrViewShell.GetViewFrame()->GetFrame().GetFrameInterface()); - break; - } - else if (pArgs->Count() == 4) - { - SFX_REQUEST_ARG (rRequest, pNewName, SfxStringItem, ID_VAL_PAGENAME, sal_False); - SFX_REQUEST_ARG (rRequest, pNewAutoLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, sal_False); - SFX_REQUEST_ARG (rRequest, pBVisible, SfxBoolItem, ID_VAL_ISPAGEBACK, sal_False); - SFX_REQUEST_ARG (rRequest, pBObjsVisible, SfxBoolItem, ID_VAL_ISPAGEOBJ, sal_False); - AutoLayout aLayout ((AutoLayout)pNewAutoLayout->GetValue ()); - if (aLayout >= AUTOLAYOUT__START - && aLayout < AUTOLAYOUT__END) - { - aNewName = pNewName->GetValue (); - aNewAutoLayout = (AutoLayout) pNewAutoLayout->GetValue (); - bBVisible = pBVisible->GetValue (); - bBObjsVisible = pBObjsVisible->GetValue (); - } - else - { - StarBASIC::FatalError (SbERR_BAD_PROP_VALUE); - rRequest.Ignore (); - break; - } - if (ePageKind == PK_HANDOUT) - { - bHandoutMode = sal_True; - pHandoutMPage = pDocument->GetMasterSdPage(0, PK_HANDOUT); - } - } - else - { - StarBASIC::FatalError (SbERR_WRONG_ARGS); - rRequest.Ignore (); - break; - } - - SdPage* pUndoPage = - bHandoutMode ? pHandoutMPage : pCurrentPage; - - ::svl::IUndoManager* pUndoManager = mrViewShell.GetDocSh()->GetUndoManager(); - DBG_ASSERT(pUndoManager, "No UNDO MANAGER ?!?"); + SdDrawDocument* pDocument = mrViewShell.GetDoc(); + SdrLayerAdmin& rLayerAdmin = pDocument->GetLayerAdmin(); + sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False); + sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False); + SetOfByte aVisibleLayers; + sal_Bool bHandoutMode = sal_False; + SdPage* pHandoutMPage = NULL; + String aNewName; + + // #95981# + String aOldName; + + AutoLayout aNewAutoLayout; + + sal_Bool bBVisible; + sal_Bool bBObjsVisible; + const SfxItemSet* pArgs = rRequest.GetArgs(); + + if (pCurrentPage != NULL && pCurrentPage->TRG_HasMasterPage()) + aVisibleLayers = pCurrentPage->TRG_GetMasterPageVisibleLayers(); + else + aVisibleLayers.SetAll(); + + do + { + if (pCurrentPage == NULL) + break; + + if (!pArgs || pArgs->Count() == 1 || pArgs->Count() == 2 ) + { + if (pArgs && pArgs->Count() == 2) + { + // We have been called with a request that contains two + // arguments. One was used as preselected layout in a + // dialog. We could select that layout in the + // layout panel instead. + /* + SFX_REQUEST_ARG (rRequest, pNewAutoLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, sal_False); + eNewAutoLayout = (AutoLayout) pNewAutoLayout->GetValue + (); + */ + } + + // Make the layout menu visible in the tool pane. + sfx2::sidebar::Sidebar::ShowPanel( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImpressLayoutsPanel")), + mrViewShell.GetViewFrame()->GetFrame().GetFrameInterface()); + break; + } + else if (pArgs->Count() == 4) + { + SFX_REQUEST_ARG (rRequest, pNewName, SfxStringItem, ID_VAL_PAGENAME, sal_False); + SFX_REQUEST_ARG (rRequest, pNewAutoLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, sal_False); + SFX_REQUEST_ARG (rRequest, pBVisible, SfxBoolItem, ID_VAL_ISPAGEBACK, sal_False); + SFX_REQUEST_ARG (rRequest, pBObjsVisible, SfxBoolItem, ID_VAL_ISPAGEOBJ, sal_False); + AutoLayout aLayout ((AutoLayout)pNewAutoLayout->GetValue ()); + if (aLayout >= AUTOLAYOUT__START + && aLayout < AUTOLAYOUT__END) + { + aNewName = pNewName->GetValue (); + aNewAutoLayout = (AutoLayout) pNewAutoLayout->GetValue (); + bBVisible = pBVisible->GetValue (); + bBObjsVisible = pBObjsVisible->GetValue (); + } + else + { + StarBASIC::FatalError (SbERR_BAD_PROP_VALUE); + rRequest.Ignore (); + break; + } + if (ePageKind == PK_HANDOUT) + { + bHandoutMode = sal_True; + pHandoutMPage = pDocument->GetMasterSdPage(0, PK_HANDOUT); + } + } + else + { + StarBASIC::FatalError (SbERR_WRONG_ARGS); + rRequest.Ignore (); + break; + } + + SdPage* pUndoPage = + bHandoutMode ? pHandoutMPage : pCurrentPage; + + ::svl::IUndoManager* pUndoManager = mrViewShell.GetDocSh()->GetUndoManager(); + DBG_ASSERT(pUndoManager, "No UNDO MANAGER ?!?"); if( pUndoManager ) { @@ -201,8 +201,8 @@ void ViewShell::Implementation::ProcessModifyPageSlot ( pDocument, pUndoPage, aNewName, aNewAutoLayout, bBVisible, bBObjsVisible); pUndoManager->AddUndoAction(pAction); - // Clear the selection because the selectec object may be removed as - // a result of the ssignment of the layout. + // Clear the selection because the selected object may be removed as + // a result of the assignment of the layout. mrViewShell.GetDrawView()->UnmarkAll(); if (!bHandoutMode) @@ -247,61 +247,61 @@ void ViewShell::Implementation::ProcessModifyPageSlot ( pUndoManager->LeaveListAction(); pDocument->SetChanged(bSetModified); - } - } - while (false); + } + } + while (false); - mrViewShell.Cancel(); - rRequest.Done (); + mrViewShell.Cancel(); + rRequest.Done (); } void ViewShell::Implementation::AssignLayout ( SfxRequest& rRequest, PageKind ePageKind ) { - const SfxUInt32Item* pWhatPage = static_cast< const SfxUInt32Item* > ( rRequest.GetArg( ID_VAL_WHATPAGE, sal_False, TYPE(SfxUInt32Item) ) ); - const SfxUInt32Item* pWhatLayout = static_cast< const SfxUInt32Item* > ( rRequest.GetArg( ID_VAL_WHATLAYOUT, sal_False, TYPE(SfxUInt32Item) ) ); + const SfxUInt32Item* pWhatPage = static_cast< const SfxUInt32Item* > ( rRequest.GetArg( ID_VAL_WHATPAGE, sal_False, TYPE(SfxUInt32Item) ) ); + const SfxUInt32Item* pWhatLayout = static_cast< const SfxUInt32Item* > ( rRequest.GetArg( ID_VAL_WHATLAYOUT, sal_False, TYPE(SfxUInt32Item) ) ); - SdDrawDocument* pDocument = mrViewShell.GetDoc(); + SdDrawDocument* pDocument = mrViewShell.GetDoc(); if( !pDocument ) return; - SdPage* pPage = 0; - if( pWhatPage ) - { + SdPage* pPage = 0; + if( pWhatPage ) + { pPage = pDocument->GetSdPage(static_cast<sal_uInt16>(pWhatPage->GetValue()), ePageKind); - } - - if( pPage == 0 ) - pPage = mrViewShell.getCurrentPage(); - - if( pPage ) - { - AutoLayout eLayout = pPage->GetAutoLayout(); - - if( pWhatLayout ) - eLayout = static_cast< AutoLayout >( pWhatLayout->GetValue() ); - - // Transform the given request into the four argument form that is - // understood by ProcessModifyPageSlot(). - SdrLayerAdmin& rLayerAdmin (mrViewShell.GetViewShellBase().GetDocument()->GetLayerAdmin()); - sal_uInt8 aBackground (rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False)); - sal_uInt8 aBackgroundObject (rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False)); - - SetOfByte aVisibleLayers; - + } + + if( pPage == 0 ) + pPage = mrViewShell.getCurrentPage(); + + if( pPage ) + { + AutoLayout eLayout = pPage->GetAutoLayout(); + + if( pWhatLayout ) + eLayout = static_cast< AutoLayout >( pWhatLayout->GetValue() ); + + // Transform the given request into the four argument form that is + // understood by ProcessModifyPageSlot(). + SdrLayerAdmin& rLayerAdmin (mrViewShell.GetViewShellBase().GetDocument()->GetLayerAdmin()); + sal_uInt8 aBackground (rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False)); + sal_uInt8 aBackgroundObject (rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False)); + + SetOfByte aVisibleLayers; + if( pPage->GetPageKind() == PK_HANDOUT ) aVisibleLayers.SetAll(); else aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers(); SfxRequest aRequest (mrViewShell.GetViewShellBase().GetViewFrame(), SID_MODIFYPAGE); - aRequest.AppendItem(SfxStringItem (ID_VAL_PAGENAME, pPage->GetName())); - aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, eLayout)); - aRequest.AppendItem(SfxBoolItem(ID_VAL_ISPAGEBACK, aVisibleLayers.IsSet(aBackground))); - aRequest.AppendItem(SfxBoolItem(ID_VAL_ISPAGEOBJ, aVisibleLayers.IsSet(aBackgroundObject))); - - // Forward the call with the new arguments. - ProcessModifyPageSlot( aRequest, pPage, pPage->GetPageKind()); - } + aRequest.AppendItem(SfxStringItem (ID_VAL_PAGENAME, pPage->GetName())); + aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, eLayout)); + aRequest.AppendItem(SfxBoolItem(ID_VAL_ISPAGEBACK, aVisibleLayers.IsSet(aBackground))); + aRequest.AppendItem(SfxBoolItem(ID_VAL_ISPAGEOBJ, aVisibleLayers.IsSet(aBackgroundObject))); + + // Forward the call with the new arguments. + ProcessModifyPageSlot( aRequest, pPage, pPage->GetPageKind()); + } } @@ -309,33 +309,33 @@ void ViewShell::Implementation::AssignLayout ( SfxRequest& rRequest, PageKind eP sal_uInt16 ViewShell::Implementation::GetViewId (void) { - switch (mrViewShell.GetShellType()) - { - case ViewShell::ST_IMPRESS: - case ViewShell::ST_NOTES: - case ViewShell::ST_HANDOUT: - return IMPRESS_FACTORY_ID; - - case ViewShell::ST_DRAW: - return DRAW_FACTORY_ID; - - case ViewShell::ST_OUTLINE: - return OUTLINE_FACTORY_ID; - - case ViewShell::ST_SLIDE_SORTER: - return SLIDE_SORTER_FACTORY_ID; - - case ViewShell::ST_PRESENTATION: - return PRESENTATION_FACTORY_ID; - - // Since we have to return a view id for every possible shell type - // and there is not (yet) a proper ViewShellBase sub class for the - // remaining types we chose the Impress factory as a fall back. - case ViewShell::ST_SIDEBAR: - case ViewShell::ST_NONE: - default: - return IMPRESS_FACTORY_ID; - } + switch (mrViewShell.GetShellType()) + { + case ViewShell::ST_IMPRESS: + case ViewShell::ST_NOTES: + case ViewShell::ST_HANDOUT: + return IMPRESS_FACTORY_ID; + + case ViewShell::ST_DRAW: + return DRAW_FACTORY_ID; + + case ViewShell::ST_OUTLINE: + return OUTLINE_FACTORY_ID; + + case ViewShell::ST_SLIDE_SORTER: + return SLIDE_SORTER_FACTORY_ID; + + case ViewShell::ST_PRESENTATION: + return PRESENTATION_FACTORY_ID; + + // Since we have to return a view id for every possible shell type + // and there is not (yet) a proper ViewShellBase sub class for the + // remaining types we chose the Impress factory as a fall back. + case ViewShell::ST_SIDEBAR: + case ViewShell::ST_NONE: + default: + return IMPRESS_FACTORY_ID; + } } @@ -343,12 +343,12 @@ sal_uInt16 ViewShell::Implementation::GetViewId (void) SvxIMapDlg* ViewShell::Implementation::GetImageMapDialog (void) { - SvxIMapDlg* pDialog = NULL; - SfxChildWindow* pChildWindow = SfxViewFrame::Current()->GetChildWindow( - SvxIMapDlgChildWindow::GetChildWindowId()); - if (pChildWindow != NULL) - pDialog = dynamic_cast<SvxIMapDlg*>(pChildWindow->GetWindow()); - return pDialog; + SvxIMapDlg* pDialog = NULL; + SfxChildWindow* pChildWindow = SfxViewFrame::Current()->GetChildWindow( + SvxIMapDlgChildWindow::GetChildWindowId()); + if (pChildWindow != NULL) + pDialog = dynamic_cast<SvxIMapDlg*>(pChildWindow->GetWindow()); + return pDialog; } @@ -356,33 +356,33 @@ SvxIMapDlg* ViewShell::Implementation::GetImageMapDialog (void) //===== ToolBarManagerLock ==================================================== class ViewShell::Implementation::ToolBarManagerLock::Deleter { public: - void operator() (ToolBarManagerLock* pObject) { delete pObject; } + void operator() (ToolBarManagerLock* pObject) { delete pObject; } }; ::boost::shared_ptr<ViewShell::Implementation::ToolBarManagerLock> - ViewShell::Implementation::ToolBarManagerLock::Create ( - const ::boost::shared_ptr<ToolBarManager>& rpManager) + ViewShell::Implementation::ToolBarManagerLock::Create ( + const ::boost::shared_ptr<ToolBarManager>& rpManager) { - ::boost::shared_ptr<ToolBarManagerLock> pLock ( - new ViewShell::Implementation::ToolBarManagerLock(rpManager), - ViewShell::Implementation::ToolBarManagerLock::Deleter()); - pLock->mpSelf = pLock; - return pLock; + ::boost::shared_ptr<ToolBarManagerLock> pLock ( + new ViewShell::Implementation::ToolBarManagerLock(rpManager), + ViewShell::Implementation::ToolBarManagerLock::Deleter()); + pLock->mpSelf = pLock; + return pLock; } ViewShell::Implementation::ToolBarManagerLock::ToolBarManagerLock ( - const ::boost::shared_ptr<ToolBarManager>& rpManager) - : mpLock(new ToolBarManager::UpdateLock(rpManager)), - maTimer() + const ::boost::shared_ptr<ToolBarManager>& rpManager) + : mpLock(new ToolBarManager::UpdateLock(rpManager)), + maTimer() { - // Start a timer that will unlock the ToolBarManager update lock when - // that is not done explicitly by calling Release(). - maTimer.SetTimeoutHdl(LINK(this,ToolBarManagerLock,TimeoutCallback)); - maTimer.SetTimeout(100); - maTimer.Start(); + // Start a timer that will unlock the ToolBarManager update lock when + // that is not done explicitly by calling Release(). + maTimer.SetTimeoutHdl(LINK(this,ToolBarManagerLock,TimeoutCallback)); + maTimer.SetTimeout(100); + maTimer.Start(); } @@ -390,17 +390,17 @@ ViewShell::Implementation::ToolBarManagerLock::ToolBarManagerLock ( IMPL_LINK(ViewShell::Implementation::ToolBarManagerLock,TimeoutCallback,Timer*,EMPTYARG) { - // If possible then release the lock now. Otherwise start the timer - // and try again later. - if (Application::IsUICaptured()) - { - maTimer.Start(); - } - else - { - mpSelf.reset(); - } - return 0; + // If possible then release the lock now. Otherwise start the timer + // and try again later. + if (Application::IsUICaptured()) + { + maTimer.Start(); + } + else + { + mpSelf.reset(); + } + return 0; } @@ -408,12 +408,12 @@ IMPL_LINK(ViewShell::Implementation::ToolBarManagerLock,TimeoutCallback,Timer*,E void ViewShell::Implementation::ToolBarManagerLock::Release (bool bForce) { - // If possible then release the lock now. Otherwise try again when the - // timer expires. - if (bForce || ! Application::IsUICaptured()) - { - mpSelf.reset(); - } + // If possible then release the lock now. Otherwise try again when the + // timer expires. + if (bForce || ! Application::IsUICaptured()) + { + mpSelf.reset(); + } } @@ -421,7 +421,7 @@ void ViewShell::Implementation::ToolBarManagerLock::Release (bool bForce) ViewShell::Implementation::ToolBarManagerLock::~ToolBarManagerLock (void) { - mpLock.reset(); + mpLock.reset(); } } // end of namespace sd diff --git a/main/sd/source/ui/view/ViewShellManager.cxx b/main/sd/source/ui/view/ViewShellManager.cxx index d68a154..696d571 100644 --- a/main/sd/source/ui/view/ViewShellManager.cxx +++ b/main/sd/source/ui/view/ViewShellManager.cxx @@ -1,5 +1,5 @@ /************************************************************** - * + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -7,16 +7,16 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ @@ -45,62 +45,62 @@ namespace sd { namespace { /** The ShellDescriptor class is used to shells together with their ids and - the factory that was used to create the shell. + the factory that was used to create the shell. - The shell pointer may be NULL. In that case the shell is created on - demand by a factory. + The shell pointer may be NULL. In that case the shell is created on + demand by a factory. - The factory pointer may be NULL. In that case the shell pointer is - given to the ViewShellManager. + The factory pointer may be NULL. In that case the shell pointer is + given to the ViewShellManager. - Shell pointer and factory pointer can but should not be NULL at the same - time. + Shell pointer and factory pointer can but should not be NULL at the same + time. */ class ShellDescriptor { public: - SfxShell* mpShell; - ShellId mnId; - ViewShellManager::SharedShellFactory mpFactory; - bool mbIsListenerAddedToWindow; - - ShellDescriptor (); - ShellDescriptor (SfxShell* pShell, ShellId nId); - ShellDescriptor (const ShellDescriptor& rDescriptor); - ShellDescriptor& operator= (const ShellDescriptor& rDescriptor); - bool IsMainViewShell (void) const; - ::Window* GetWindow (void) const; + SfxShell* mpShell; + ShellId mnId; + ViewShellManager::SharedShellFactory mpFactory; + bool mbIsListenerAddedToWindow; + + ShellDescriptor (); + ShellDescriptor (SfxShell* pShell, ShellId nId); + ShellDescriptor (const ShellDescriptor& rDescriptor); + ShellDescriptor& operator= (const ShellDescriptor& rDescriptor); + bool IsMainViewShell (void) const; + ::Window* GetWindow (void) const; }; /** This functor can be used to search for a shell in an STL container when the - shell pointer is given. + shell pointer is given. */ class IsShell : public ::std::unary_function<ShellDescriptor,bool> { public: - IsShell (const SfxShell* pShell) : mpShell(pShell) {} - bool operator() (const ShellDescriptor& rDescriptor) - { return rDescriptor.mpShell == mpShell; } + IsShell (const SfxShell* pShell) : mpShell(pShell) {} + bool operator() (const ShellDescriptor& rDescriptor) + { return rDescriptor.mpShell == mpShell; } private: - const SfxShell* mpShell; + const SfxShell* mpShell; }; /** This functor can be used to search for a shell in an STL container when the - id of the shell is given. + id of the shell is given. */ class IsId : public ::std::unary_function<ShellDescriptor,bool> { public: - IsId (ShellId nId) : mnId(nId) {} - bool operator() (const ShellDescriptor& rDescriptor) - { return rDescriptor.mnId == mnId; } + IsId (ShellId nId) : mnId(nId) {} + bool operator() (const ShellDescriptor& rDescriptor) + { return rDescriptor.mnId == mnId; } private: - ShellId mnId; + ShellId mnId; }; } // end of anonymous namespace @@ -111,142 +111,142 @@ private: class ViewShellManager::Implementation { public: - Implementation ( - ViewShellManager& rManager, - ViewShellBase& rBase); - ~Implementation (void); - - void AddShellFactory ( - const SfxShell* pViewShell, - const SharedShellFactory& rpFactory); - void RemoveShellFactory ( - const SfxShell* pViewShell, - const SharedShellFactory& rpFactory); - void ActivateViewShell ( - ViewShell* pViewShell); - void DeactivateViewShell (const ViewShell& rShell); - void ActivateShell (SfxShell& rShell); - void DeactivateShell (const SfxShell& rShell); - void ActivateShell (const ShellDescriptor& rDescriptor); - void SetFormShell (const ViewShell* pViewShell, FmFormShell* pFormShell, bool bAbove); - void ActivateSubShell (const SfxShell& rParentShell, ShellId nId); - void DeactivateSubShell (const SfxShell& rParentShell, ShellId nId); - void MoveSubShellToTop (const SfxShell& rParentShell, ShellId nId); - void MoveToTop (const SfxShell& rParentShell); - SfxShell* GetShell (ShellId nId) const; - SfxShell* GetTopShell (void) const; - void Shutdown (void); - void InvalidateAllSubShells (const SfxShell* pParentShell); - - /** Remove all shells from the SFX stack above and including the given - shell. - */ - void TakeShellsFromStack (const SfxShell* pShell); - - class UpdateLock - { - public: - UpdateLock (Implementation& rImpl) : mrImpl(rImpl) {mrImpl.LockUpdate();} - ~UpdateLock (void) {mrImpl.UnlockUpdate();}; - private: - Implementation& mrImpl; - }; - - - - /** Prevent updates of the shell stack. While the sub shell manager is - locked it will update its internal data structures but not alter the - shell stack. Use this method when there are several modifications - to the shell stack to prevent multiple rebuilds of the shell stack - and resulting broadcasts. - */ - void LockUpdate (void); - - /** Allow updates of the shell stack. This method has to be called the - same number of times as LockUpdate() to really allow a rebuild of - the shell stack. - */ - void UnlockUpdate (void); + Implementation ( + ViewShellManager& rManager, + ViewShellBase& rBase); + ~Implementation (void); + + void AddShellFactory ( + const SfxShell* pViewShell, + const SharedShellFactory& rpFactory); + void RemoveShellFactory ( + const SfxShell* pViewShell, + const SharedShellFactory& rpFactory); + void ActivateViewShell ( + ViewShell* pViewShell); + void DeactivateViewShell (const ViewShell& rShell); + void ActivateShell (SfxShell& rShell); + void DeactivateShell (const SfxShell& rShell); + void ActivateShell (const ShellDescriptor& rDescriptor); + void SetFormShell (const ViewShell* pViewShell, FmFormShell* pFormShell, bool bAbove); + void ActivateSubShell (const SfxShell& rParentShell, ShellId nId); + void DeactivateSubShell (const SfxShell& rParentShell, ShellId nId); + void MoveSubShellToTop (const SfxShell& rParentShell, ShellId nId); + void MoveToTop (const SfxShell& rParentShell); + SfxShell* GetShell (ShellId nId) const; + SfxShell* GetTopShell (void) const; + void Shutdown (void); + void InvalidateAllSubShells (const SfxShell* pParentShell); + + /** Remove all shells from the SFX stack above and including the given + shell. + */ + void TakeShellsFromStack (const SfxShell* pShell); + + class UpdateLock + { + public: + UpdateLock (Implementation& rImpl) : mrImpl(rImpl) {mrImpl.LockUpdate();} + ~UpdateLock (void) {mrImpl.UnlockUpdate();}; + private: + Implementation& mrImpl; + }; + + + + /** Prevent updates of the shell stack. While the sub shell manager is + locked it will update its internal data structures but not alter the + shell stack. Use this method when there are several modifications + to the shell stack to prevent multiple rebuilds of the shell stack + and resulting broadcasts. + */ + void LockUpdate (void); + + /** Allow updates of the shell stack. This method has to be called the + same number of times as LockUpdate() to really allow a rebuild of + the shell stack. + */ + void UnlockUpdate (void); private: - ViewShellBase& mrBase; - mutable ::osl::Mutex maMutex; - - class ShellHash{public: size_t operator()(const SfxShell* p) const { return (size_t)p;} }; - typedef ::std::hash_multimap<const SfxShell*,SharedShellFactory,ShellHash> - FactoryList; - FactoryList maShellFactories; - - /** List of the active view shells. In order to create gather all shells - to put on the shell stack each view shell in this list is asked for - its sub-shells (typically toolbars). - */ - typedef ::std::list<ShellDescriptor> ActiveShellList; - ActiveShellList maActiveViewShells; - - typedef ::std::list<ShellDescriptor> SubShellSubList; - typedef ::std::hash_map<const SfxShell*,SubShellSubList,ShellHash> SubShellList; - SubShellList maActiveSubShells; - - /** In this member we remember what shells we have pushed on the shell - stack. - */ - typedef ::std::vector<SfxShell*> ShellStack; - - int mnUpdateLockCount; - - /** When this flag is set then the main view shell is always kept at the - top of the shell stack. - */ - bool mbKeepMainViewShellOnTop; - - /** The UpdateShellStack() method can be called recursively. This flag - is used to communicate between different levels of invocation: if - the stack has been updated in an inner call the outer call can (has - to) stop and return immediately. - */ - bool mbShellStackIsUpToDate; - - SfxShell* mpFormShell; - const ViewShell* mpFormShellParent; - bool mbFormShellAboveParent; - - SfxShell* mpTopShell; - - void GatherActiveShells (ShellStack& rShellList); - - void UpdateShellStack (void); - - void CreateShells (void); - - /** This method rebuilds the stack of shells that are stacked upon the - view shell base. - */ - void CreateTargetStack (ShellStack& rStack) const; - - DECL_LINK(WindowEventHandler, VclWindowEvent*); + ViewShellBase& mrBase; + mutable ::osl::Mutex maMutex; + + class ShellHash{public: size_t operator()(const SfxShell* p) const { return (size_t)p;} }; + typedef ::std::hash_multimap<const SfxShell*,SharedShellFactory,ShellHash> + FactoryList; + FactoryList maShellFactories; + + /** List of the active view shells. In order to create gather all shells + to put on the shell stack each view shell in this list is asked for + its sub-shells (typically toolbars). + */ + typedef ::std::list<ShellDescriptor> ActiveShellList; + ActiveShellList maActiveViewShells; + + typedef ::std::list<ShellDescriptor> SubShellSubList; + typedef ::std::hash_map<const SfxShell*,SubShellSubList,ShellHash> SubShellList; + SubShellList maActiveSubShells; + + /** In this member we remember what shells we have pushed on the shell + stack. + */ + typedef ::std::vector<SfxShell*> ShellStack; + + int mnUpdateLockCount; + + /** When this flag is set then the main view shell is always kept at the + top of the shell stack. + */ + bool mbKeepMainViewShellOnTop; + + /** The UpdateShellStack() method can be called recursively. This flag + is used to communicate between different levels of invocation: if + the stack has been updated in an inner call the outer call can (has + to) stop and return immediately. + */ + bool mbShellStackIsUpToDate; + + SfxShell* mpFormShell; + const ViewShell* mpFormShellParent; + bool mbFormShellAboveParent; + + SfxShell* mpTopShell; + + void GatherActiveShells (ShellStack& rShellList); + + void UpdateShellStack (void); + + void CreateShells (void); + + /** This method rebuilds the stack of shells that are stacked upon the + view shell base. + */ + void CreateTargetStack (ShellStack& rStack) const; + + DECL_LINK(WindowEventHandler, VclWindowEvent*); #ifdef VERBOSE - void DumpShellStack (const ShellStack& rStack); - void DumpSfxShellStack (void); + void DumpShellStack (const ShellStack& rStack); + void DumpSfxShellStack (void); #endif - /** To be called before a shell is taken fom the SFX shell stack. This - method deactivates an active text editing to avoid problems with - undo managers. - Afterwards the Deactivate() of the shell is called. - */ - void Deactivate (SfxShell* pShell); - - ShellDescriptor CreateSubShell ( - SfxShell* pShell, - ShellId nShellId, - ::Window* pParentWindow, - FrameView* pFrameView); - void DestroyViewShell (ShellDescriptor& rDescriptor); - void DestroySubShell ( - const SfxShell& rViewShell, - const ShellDescriptor& rDescriptor); + /** To be called before a shell is taken from the SFX shell stack. This + method deactivates an active text editing to avoid problems with + undo managers. + Afterwards the Deactivate() of the shell is called. + */ + void Deactivate (SfxShell* pShell); + + ShellDescriptor CreateSubShell ( + SfxShell* pShell, + ShellId nShellId, + ::Window* pParentWindow, + FrameView* pFrameView); + void DestroyViewShell (ShellDescriptor& rDescriptor); + void DestroySubShell ( + const SfxShell& rViewShell, + const ShellDescriptor& rDescriptor); }; @@ -255,8 +255,8 @@ private: //===== ViewShellManager ====================================================== ViewShellManager::ViewShellManager (ViewShellBase& rBase) - : mpImpl(new Implementation(*this,rBase)), - mbValid(true) + : mpImpl(new Implementation(*this,rBase)), + mbValid(true) { } @@ -271,22 +271,22 @@ ViewShellManager::~ViewShellManager (void) void ViewShellManager::AddSubShellFactory ( - ViewShell* pViewShell, - const SharedShellFactory& rpFactory) + ViewShell* pViewShell, + const SharedShellFactory& rpFactory) { - if (mbValid) - mpImpl->AddShellFactory(pViewShell, rpFactory); + if (mbValid) + mpImpl->AddShellFactory(pViewShell, rpFactory); } void ViewShellManager::RemoveSubShellFactory ( - ViewShell* pViewShell, - const SharedShellFactory& rpFactory) + ViewShell* pViewShell, + const SharedShellFactory& rpFactory) { - if (mbValid) - mpImpl->RemoveShellFactory(pViewShell, rpFactory); + if (mbValid) + mpImpl->RemoveShellFactory(pViewShell, rpFactory); } @@ -294,8 +294,8 @@ void ViewShellManager::RemoveSubShellFactory ( void ViewShellManager::ActivateViewShell (ViewShell* pViewShell) { - if (mbValid) - return mpImpl->ActivateViewShell(pViewShell); + if (mbValid) + return mpImpl->ActivateViewShell(pViewShell); } @@ -303,31 +303,31 @@ void ViewShellManager::ActivateViewShell (ViewShell* pViewShell) void ViewShellManager::DeactivateViewShell (const ViewShell* pShell) { - if (mbValid && pShell!=NULL) - mpImpl->DeactivateViewShell(*pShell); + if (mbValid && pShell!=NULL) + mpImpl->DeactivateViewShell(*pShell); } void ViewShellManager::MoveSubShellToTop ( - const ViewShell& rParentShell, - ShellId nId) + const ViewShell& rParentShell, + ShellId nId) { - if (mbValid) - mpImpl->MoveSubShellToTop(rParentShell, nId); + if (mbValid) + mpImpl->MoveSubShellToTop(rParentShell, nId); } void ViewShellManager::SetFormShell ( - const ViewShell* pParentShell, - FmFormShell* pFormShell, - bool bAbove) + const ViewShell* pParentShell, + FmFormShell* pFormShell, + bool bAbove) { - if (mbValid) - mpImpl->SetFormShell(pParentShell,pFormShell,bAbove); + if (mbValid) + mpImpl->SetFormShell(pParentShell,pFormShell,bAbove); } @@ -335,8 +335,8 @@ void ViewShellManager::SetFormShell ( void ViewShellManager::ActivateSubShell (const ViewShell& rViewShell, ShellId nId) { - if (mbValid) - mpImpl->ActivateSubShell(rViewShell,nId); + if (mbValid) + mpImpl->ActivateSubShell(rViewShell,nId); } @@ -344,8 +344,8 @@ void ViewShellManager::ActivateSubShell (const ViewShell& rViewShell, ShellId nI void ViewShellManager::DeactivateSubShell (const ViewShell& rViewShell, ShellId nId) { - if (mbValid) - mpImpl->DeactivateSubShell(rViewShell,nId); + if (mbValid) + mpImpl->DeactivateSubShell(rViewShell,nId); } @@ -353,8 +353,8 @@ void ViewShellManager::DeactivateSubShell (const ViewShell& rViewShell, ShellId void ViewShellManager::InvalidateAllSubShells (ViewShell* pViewShell) { - if (mbValid) - mpImpl->InvalidateAllSubShells(pViewShell); + if (mbValid) + mpImpl->InvalidateAllSubShells(pViewShell); } @@ -362,8 +362,8 @@ void ViewShellManager::InvalidateAllSubShells (ViewShell* pViewShell) void ViewShellManager::ActivateShell (SfxShell* pShell) { - if (mbValid && pShell!=NULL) - mpImpl->ActivateShell(*pShell); + if (mbValid && pShell!=NULL) + mpImpl->ActivateShell(*pShell); } @@ -371,8 +371,8 @@ void ViewShellManager::ActivateShell (SfxShell* pShell) void ViewShellManager::DeactivateShell (const SfxShell* pShell) { - if (mbValid && pShell!=NULL) - mpImpl->DeactivateShell(*pShell); + if (mbValid && pShell!=NULL) + mpImpl->DeactivateShell(*pShell); } @@ -380,8 +380,8 @@ void ViewShellManager::DeactivateShell (const SfxShell* pShell) void ViewShellManager::MoveToTop (const ViewShell& rParentShell) { - if (mbValid) - mpImpl->MoveToTop(rParentShell); + if (mbValid) + mpImpl->MoveToTop(rParentShell); } @@ -389,10 +389,10 @@ void ViewShellManager::MoveToTop (const ViewShell& rParentShell) SfxShell* ViewShellManager::GetShell (ShellId nId) const { - if (mbValid) - return mpImpl->GetShell(nId); - else - return NULL; + if (mbValid) + return mpImpl->GetShell(nId); + else + return NULL; } @@ -400,10 +400,10 @@ SfxShell* ViewShellManager::GetShell (ShellId nId) const SfxShell* ViewShellManager::GetTopShell (void) const { - if (mbValid) - return mpImpl->GetTopShell(); - else - return NULL; + if (mbValid) + return mpImpl->GetTopShell(); + else + return NULL; } @@ -411,18 +411,18 @@ SfxShell* ViewShellManager::GetTopShell (void) const void ViewShellManager::Shutdown (void) { - if (mbValid) - { - mpImpl->Shutdown(); - mbValid = false; - } + if (mbValid) + { + mpImpl->Shutdown(); + mbValid = false; + } } void ViewShellManager::LockUpdate (void) { - mpImpl->LockUpdate(); + mpImpl->LockUpdate(); } @@ -430,7 +430,7 @@ void ViewShellManager::LockUpdate (void) void ViewShellManager::UnlockUpdate (void) { - mpImpl->UnlockUpdate(); + mpImpl->UnlockUpdate(); } @@ -439,21 +439,21 @@ void ViewShellManager::UnlockUpdate (void) //===== ViewShellManager::Implementation ====================================== ViewShellManager::Implementation::Implementation ( - ViewShellManager& rManager, - ViewShellBase& rBase) - : mrBase(rBase), - maMutex(), - maShellFactories(), - maActiveViewShells(), - mnUpdateLockCount(0), - mbKeepMainViewShellOnTop(false), - mbShellStackIsUpToDate(true), - mpFormShell(NULL), - mpFormShellParent(NULL), - mbFormShellAboveParent(true), - mpTopShell(NULL) + ViewShellManager& rManager, + ViewShellBase& rBase) + : mrBase(rBase), + maMutex(), + maShellFactories(), + maActiveViewShells(), + mnUpdateLockCount(0), + mbKeepMainViewShellOnTop(false), + mbShellStackIsUpToDate(true), + mpFormShell(NULL), + mpFormShellParent(NULL), + mbFormShellAboveParent(true), + mpTopShell(NULL) { - (void)rManager; + (void)rManager; } @@ -461,48 +461,48 @@ ViewShellManager::Implementation::Implementation ( ViewShellManager::Implementation::~Implementation (void) { - Shutdown(); + Shutdown(); } void ViewShellManager::Implementation::AddShellFactory ( - const SfxShell* pViewShell, - const SharedShellFactory& rpFactory) + const SfxShell* pViewShell, + const SharedShellFactory& rpFactory) { - bool bAlreadyAdded (false); - - // Check that the given factory has not already been added. - ::std::pair<FactoryList::iterator,FactoryList::iterator> aRange( - maShellFactories.equal_range(pViewShell)); - for (FactoryList::const_iterator iFactory=aRange.first; iFactory!=aRange.second; ++iFactory) - if (iFactory->second == rpFactory) - { - bAlreadyAdded = true; - break; - } - - // Add the factory if it is not already present. - if ( ! bAlreadyAdded) - maShellFactories.insert(FactoryList::value_type(pViewShell, rpFactory)); + bool bAlreadyAdded (false); + + // Check that the given factory has not already been added. + ::std::pair<FactoryList::iterator,FactoryList::iterator> aRange( + maShellFactories.equal_range(pViewShell)); + for (FactoryList::const_iterator iFactory=aRange.first; iFactory!=aRange.second; ++iFactory) + if (iFactory->second == rpFactory) + { + bAlreadyAdded = true; + break; + } + + // Add the factory if it is not already present. + if ( ! bAlreadyAdded) + maShellFactories.insert(FactoryList::value_type(pViewShell, rpFactory)); } void ViewShellManager::Implementation::RemoveShellFactory ( - const SfxShell* pViewShell, - const SharedShellFactory& rpFactory) + const SfxShell* pViewShell, + const SharedShellFactory& rpFactory) { - ::std::pair<FactoryList::iterator,FactoryList::iterator> aRange( - maShellFactories.equal_range(pViewShell)); - for (FactoryList::iterator iFactory=aRange.first; iFactory!=aRange.second; ++iFactory) - if (iFactory->second == rpFactory) - { - maShellFactories.erase(iFactory); - break; - } + ::std::pair<FactoryList::iterator,FactoryList::iterator> aRange( + maShellFactories.equal_range(pViewShell)); + for (FactoryList::iterator iFactory=aRange.first; iFactory!=aRange.second; ++iFactory) + if (iFactory->second == rpFactory) + { + maShellFactories.erase(iFactory); + break; + } } @@ -510,31 +510,31 @@ void ViewShellManager::Implementation::RemoveShellFactory ( void ViewShellManager::Implementation::ActivateViewShell (ViewShell* pViewShell) { - ::osl::MutexGuard aGuard (maMutex); - - ShellDescriptor aResult; - aResult.mpShell = pViewShell; - - // Register as window listener so that the shells of the current - // window can be moved to the top of the shell stack. - if (aResult.mpShell != NULL) - { - ::Window* pWindow = aResult.GetWindow(); - if (pWindow != NULL) - { - pWindow->AddEventListener( - LINK(this, ViewShellManager::Implementation, WindowEventHandler)); - aResult.mbIsListenerAddedToWindow = true; - } - else - { - DBG_ASSERT(false, - "ViewShellManager::ActivateViewShell: " - "new view shell has no active window"); - } - } - - ActivateShell(aResult); + ::osl::MutexGuard aGuard (maMutex); + + ShellDescriptor aResult; + aResult.mpShell = pViewShell; + + // Register as window listener so that the shells of the current + // window can be moved to the top of the shell stack. + if (aResult.mpShell != NULL) + { + ::Window* pWindow = aResult.GetWindow(); + if (pWindow != NULL) + { + pWindow->AddEventListener( + LINK(this, ViewShellManager::Implementation, WindowEventHandler)); + aResult.mbIsListenerAddedToWindow = true; + } + else + { + DBG_ASSERT(false, + "ViewShellManager::ActivateViewShell: " + "new view shell has no active window"); + } + } + + ActivateShell(aResult); } @@ -542,32 +542,32 @@ void ViewShellManager::Implementation::ActivateViewShell (ViewShell* pViewShell) void ViewShellManager::Implementation::DeactivateViewShell (const ViewShell& rShell) { - ::osl::MutexGuard aGuard (maMutex); - - ActiveShellList::iterator iShell (::std::find_if ( - maActiveViewShells.begin(), - maActiveViewShells.end(), - IsShell(&rShell))); - if (iShell != maActiveViewShells.end()) - { - UpdateLock aLocker (*this); - - ShellDescriptor aDescriptor(*iShell); - mrBase.GetDocShell()->Disconnect(dynamic_cast<ViewShell*>(aDescriptor.mpShell)); - maActiveViewShells.erase(iShell); - TakeShellsFromStack(aDescriptor.mpShell); - - // Deactivate sub shells. - SubShellList::iterator iList (maActiveSubShells.find(&rShell)); - if (iList != maActiveSubShells.end()) - { - SubShellSubList& rList (iList->second); - while ( ! rList.empty()) - DeactivateSubShell(rShell, rList.front().mnId); - } - - DestroyViewShell(aDescriptor); - } + ::osl::MutexGuard aGuard (maMutex); + + ActiveShellList::iterator iShell (::std::find_if ( + maActiveViewShells.begin(), + maActiveViewShells.end(), + IsShell(&rShell))); + if (iShell != maActiveViewShells.end()) + { + UpdateLock aLocker (*this); + + ShellDescriptor aDescriptor(*iShell); + mrBase.GetDocShell()->Disconnect(dynamic_cast<ViewShell*>(aDescriptor.mpShell)); + maActiveViewShells.erase(iShell); + TakeShellsFromStack(aDescriptor.mpShell); + + // Deactivate sub shells. + SubShellList::iterator iList (maActiveSubShells.find(&rShell)); + if (iList != maActiveSubShells.end()) + { + SubShellSubList& rList (iList->second); + while ( ! rList.empty()) + DeactivateSubShell(rShell, rList.front().mnId); + } + + DestroyViewShell(aDescriptor); + } } @@ -575,13 +575,13 @@ void ViewShellManager::Implementation::DeactivateViewShell (const ViewShell& rSh void ViewShellManager::Implementation::ActivateShell (SfxShell& rShell) { - ::osl::MutexGuard aGuard (maMutex); + ::osl::MutexGuard aGuard (maMutex); - // Create a new shell or recycle on in the cache. - ShellDescriptor aDescriptor; - aDescriptor.mpShell = &rShell; + // Create a new shell or recycle on in the cache. + ShellDescriptor aDescriptor; + aDescriptor.mpShell = &rShell; - ActivateShell(aDescriptor); + ActivateShell(aDescriptor); } @@ -589,26 +589,26 @@ void ViewShellManager::Implementation::ActivateShell (SfxShell& rShell) void ViewShellManager::Implementation::ActivateShell (const ShellDescriptor& rDescriptor) { - // Put shell on top of the active view shells. - if (rDescriptor.mpShell != NULL) - { - // Determine where to put the view shell on the stack. By default - // it is put on top of the stack. When the view shell of the center - // pane is to be kept top most and the new view shell is not - // displayed in the center pane then it is inserted at the position - // one below the top. - ActiveShellList::iterator iInsertPosition (maActiveViewShells.begin()); - if (iInsertPosition != maActiveViewShells.end() - && mbKeepMainViewShellOnTop - && ! rDescriptor.IsMainViewShell() - && iInsertPosition->IsMainViewShell()) - { - ++iInsertPosition; - } - maActiveViewShells.insert( - iInsertPosition, - rDescriptor); - } + // Put shell on top of the active view shells. + if (rDescriptor.mpShell != NULL) + { + // Determine where to put the view shell on the stack. By default + // it is put on top of the stack. When the view shell of the center + // pane is to be kept top most and the new view shell is not + // displayed in the center pane then it is inserted at the position + // one below the top. + ActiveShellList::iterator iInsertPosition (maActiveViewShells.begin()); + if (iInsertPosition != maActiveViewShells.end() + && mbKeepMainViewShellOnTop + && ! rDescriptor.IsMainViewShell() + && iInsertPosition->IsMainViewShell()) + { + ++iInsertPosition; + } + maActiveViewShells.insert( + iInsertPosition, + rDescriptor); + } } @@ -616,213 +616,213 @@ void ViewShellManager::Implementation::ActivateShell (const ShellDescriptor& rDe void ViewShellManager::Implementation::DeactivateShell (const SfxShell& rShell) { - ::osl::MutexGuard aGuard (maMutex); - - ActiveShellList::iterator iShell (::std::find_if ( - maActiveViewShells.begin(), - maActiveViewShells.end(), - IsShell(&rShell))); - if (iShell != maActiveViewShells.end()) - { - UpdateLock aLocker (*this); - - ShellDescriptor aDescriptor(*iShell); - mrBase.GetDocShell()->Disconnect(dynamic_cast<ViewShell*>(aDescriptor.mpShell)); - maActiveViewShells.erase(iShell); - TakeShellsFromStack(aDescriptor.mpShell); - - // Deactivate sub shells. - SubShellList::iterator iList (maActiveSubShells.find(&rShell)); - if (iList != maActiveSubShells.end()) - { - SubShellSubList& rList (iList->second); - while ( ! rList.empty()) - DeactivateSubShell(rShell, rList.front().mnId); - } - - DestroyViewShell(aDescriptor); - } + ::osl::MutexGuard aGuard (maMutex); + + ActiveShellList::iterator iShell (::std::find_if ( + maActiveViewShells.begin(), + maActiveViewShells.end(), + IsShell(&rShell))); + if (iShell != maActiveViewShells.end()) + { + UpdateLock aLocker (*this); + + ShellDescriptor aDescriptor(*iShell); + mrBase.GetDocShell()->Disconnect(dynamic_cast<ViewShell*>(aDescriptor.mpShell)); + maActiveViewShells.erase(iShell); + TakeShellsFromStack(aDescriptor.mpShell); + + // Deactivate sub shells. + SubShellList::iterator iList (maActiveSubShells.find(&rShell)); + if (iList != maActiveSubShells.end()) + { + SubShellSubList& rList (iList->second); + while ( ! rList.empty()) + DeactivateSubShell(rShell, rList.front().mnId); + } + + DestroyViewShell(aDescriptor); + } } void ViewShellManager::Implementation::ActivateSubShell ( - const SfxShell& rParentShell, - ShellId nId) + const SfxShell& rParentShell, + ShellId nId) { - ::osl::MutexGuard aGuard (maMutex); - - do - { - // Check that the given view shell is active. - ActiveShellList::iterator iShell (::std::find_if ( - maActiveViewShells.begin(), - maActiveViewShells.end(), - IsShell(&rParentShell))); - if (iShell == maActiveViewShells.end()) - break; - - // Create the sub shell list if it does not yet exist. - SubShellList::iterator iList (maActiveSubShells.find(&rParentShell)); - if (iList == maActiveSubShells.end()) - iList = maActiveSubShells.insert( - SubShellList::value_type(&rParentShell,SubShellSubList())).first; - - // Do not activate an object bar that is already active. Requesting - // this is not exactly an error but may be an indication of one. - SubShellSubList& rList (iList->second); - if (::std::find_if(rList.begin(),rList.end(), IsId(nId)) != rList.end()) - break; - - // Add just the id of the sub shell. The actual shell is created - // later in CreateShells(). - UpdateLock aLock (*this); - rList.push_back(ShellDescriptor(NULL, nId)); - } - while (false); + ::osl::MutexGuard aGuard (maMutex); + + do + { + // Check that the given view shell is active. + ActiveShellList::iterator iShell (::std::find_if ( + maActiveViewShells.begin(), + maActiveViewShells.end(), + IsShell(&rParentShell))); + if (iShell == maActiveViewShells.end()) + break; + + // Create the sub shell list if it does not yet exist. + SubShellList::iterator iList (maActiveSubShells.find(&rParentShell)); + if (iList == maActiveSubShells.end()) + iList = maActiveSubShells.insert( + SubShellList::value_type(&rParentShell,SubShellSubList())).first; + + // Do not activate an object bar that is already active. Requesting + // this is not exactly an error but may be an indication of one. + SubShellSubList& rList (iList->second); + if (::std::find_if(rList.begin(),rList.end(), IsId(nId)) != rList.end()) + break; + + // Add just the id of the sub shell. The actual shell is created + // later in CreateShells(). + UpdateLock aLock (*this); + rList.push_back(ShellDescriptor(NULL, nId)); + } + while (false); } void ViewShellManager::Implementation::DeactivateSubShell ( - const SfxShell& rParentShell, - ShellId nId) + const SfxShell& rParentShell, + ShellId nId) { - ::osl::MutexGuard aGuard (maMutex); - - do - { - // Check that the given view shell is active. - SubShellList::iterator iList (maActiveSubShells.find(&rParentShell)); - if (iList == maActiveSubShells.end()) - break; - - // Look up the sub shell. - SubShellSubList& rList (iList->second); - SubShellSubList::iterator iShell ( - ::std::find_if(rList.begin(),rList.end(), IsId(nId))); - if (iShell == rList.end()) - break; - SfxShell* pShell = iShell->mpShell; - if (pShell == NULL) - break; - - UpdateLock aLock (*this); - - ShellDescriptor aDescriptor(*iShell); - // Remove the sub shell from both the internal structure as well as the - // SFX shell stack above and including the sub shell. - rList.erase(iShell); - TakeShellsFromStack(pShell); - - DestroySubShell(rParentShell, aDescriptor); - } - while (false); + ::osl::MutexGuard aGuard (maMutex); + + do + { + // Check that the given view shell is active. + SubShellList::iterator iList (maActiveSubShells.find(&rParentShell)); + if (iList == maActiveSubShells.end()) + break; + + // Look up the sub shell. + SubShellSubList& rList (iList->second); + SubShellSubList::iterator iShell ( + ::std::find_if(rList.begin(),rList.end(), IsId(nId))); + if (iShell == rList.end()) + break; + SfxShell* pShell = iShell->mpShell; + if (pShell == NULL) + break; + + UpdateLock aLock (*this); + + ShellDescriptor aDescriptor(*iShell); + // Remove the sub shell from both the internal structure as well as the + // SFX shell stack above and including the sub shell. + rList.erase(iShell); + TakeShellsFromStack(pShell); + + DestroySubShell(rParentShell, aDescriptor); + } + while (false); } void ViewShellManager::Implementation::MoveSubShellToTop ( - const SfxShell& rParentShell, - ShellId nId) + const SfxShell& rParentShell, + ShellId nId) { - SubShellList::iterator iList (maActiveSubShells.find(&rParentShell)); - if (iList != maActiveSubShells.end()) - { - // Look up the sub shell. - SubShellSubList& rList (iList->second); - SubShellSubList::iterator iShell ( - ::std::find_if(rList.begin(),rList.end(), IsId(nId))); - if (iShell!=rList.end() && iShell!=rList.begin()) - { - SubShellSubList::value_type aEntry (*iShell); - rList.erase(iShell); - rList.push_front(aEntry); - } - } - else - { - // Ignore this call when there are no sub shells for the given - // parent shell. We could remember the sub shell to move to the top - // but we do not. Do call this method at a later time instead. - } + SubShellList::iterator iList (maActiveSubShells.find(&rParentShell)); + if (iList != maActiveSubShells.end()) + { + // Look up the sub shell. + SubShellSubList& rList (iList->second); + SubShellSubList::iterator iShell ( + ::std::find_if(rList.begin(),rList.end(), IsId(nId))); + if (iShell!=rList.end() && iShell!=rList.begin()) + { + SubShellSubList::value_type aEntry (*iShell); + rList.erase(iShell); + rList.push_front(aEntry); + } + } + else + { + // Ignore this call when there are no sub shells for the given + // parent shell. We could remember the sub shell to move to the top + // but we do not. Do call this method at a later time instead. + } } void ViewShellManager::Implementation::MoveToTop (const SfxShell& rShell) { - ::osl::MutexGuard aGuard (maMutex); - - // Check that we have access to a dispatcher. If not, then we are - // (probably) called while the view shell is still being created or - // initialized. Without dispatcher we can not rebuild the shell stack - // to move the requested shell to the top. So return right away instead - // of making a mess without being able to clean up afterwards. - if (mrBase.GetDispatcher() == NULL) - return; - - ActiveShellList::iterator iShell (::std::find_if ( - maActiveViewShells.begin(), - maActiveViewShells.end(), - IsShell(&rShell))); - bool bMove = true; - if (iShell != maActiveViewShells.end()) - { - // Is the shell already at the top of the stack? We have to keep - // the case in mind that mbKeepMainViewShellOnTop is true. Shells - // that are not the main view shell are placed on the second-to-top - // position in this case. - if (iShell == maActiveViewShells.begin() - && (iShell->IsMainViewShell() || ! mbKeepMainViewShellOnTop)) - { - // The shell is at the top position and is either a) the main - // view shell or b) another shell but the main view shell is not - // kept at the top position. We do not have to move the shell. - bMove = false; - } - else if (iShell == ++maActiveViewShells.begin() - && ! iShell->IsMainViewShell() - && mbKeepMainViewShellOnTop) - { - // The shell is a the second-to-top position, not the main view - // shell and the main view shell is kept at the top position. - // Therefore we do not have to move the shell. - bMove = false; - } - } - else - { - // The shell is not on the stack. Therefore it can not be moved. - // We could insert it but we don't. Use ActivateViewShell() for - // that. - bMove = false; - } - - // When the shell is not at the right position it is removed from the - // internal list of shells and inserted at the correct position. - if (bMove) - { - UpdateLock aLock (*this); - - ShellDescriptor aDescriptor(*iShell); - - TakeShellsFromStack(&rShell); - maActiveViewShells.erase(iShell); - - // Find out whether to insert at the top or one below. - ActiveShellList::iterator aInsertPosition (maActiveViewShells.begin()); - if (mbKeepMainViewShellOnTop && ! aDescriptor.IsMainViewShell()) - { - if (maActiveViewShells.back().IsMainViewShell()) - aInsertPosition++; - } - - maActiveViewShells.insert(aInsertPosition, aDescriptor); - } + ::osl::MutexGuard aGuard (maMutex); + + // Check that we have access to a dispatcher. If not, then we are + // (probably) called while the view shell is still being created or + // initialized. Without dispatcher we can not rebuild the shell stack + // to move the requested shell to the top. So return right away instead + // of making a mess without being able to clean up afterwards. + if (mrBase.GetDispatcher() == NULL) + return; + + ActiveShellList::iterator iShell (::std::find_if ( + maActiveViewShells.begin(), + maActiveViewShells.end(), + IsShell(&rShell))); + bool bMove = true; + if (iShell != maActiveViewShells.end()) + { + // Is the shell already at the top of the stack? We have to keep + // the case in mind that mbKeepMainViewShellOnTop is true. Shells + // that are not the main view shell are placed on the second-to-top + // position in this case. + if (iShell == maActiveViewShells.begin() + && (iShell->IsMainViewShell() || ! mbKeepMainViewShellOnTop)) + { + // The shell is at the top position and is either a) the main + // view shell or b) another shell but the main view shell is not + // kept at the top position. We do not have to move the shell. + bMove = false; + } + else if (iShell == ++maActiveViewShells.begin() + && ! iShell->IsMainViewShell() + && mbKeepMainViewShellOnTop) + { + // The shell is a the second-to-top position, not the main view + // shell and the main view shell is kept at the top position. + // Therefore we do not have to move the shell. + bMove = false; + } + } + else + { + // The shell is not on the stack. Therefore it can not be moved. + // We could insert it but we don't. Use ActivateViewShell() for + // that. + bMove = false; + } + + // When the shell is not at the right position it is removed from the + // internal list of shells and inserted at the correct position. + if (bMove) + { + UpdateLock aLock (*this); + + ShellDescriptor aDescriptor(*iShell); + + TakeShellsFromStack(&rShell); + maActiveViewShells.erase(iShell); + + // Find out whether to insert at the top or one below. + ActiveShellList::iterator aInsertPosition (maActiveViewShells.begin()); + if (mbKeepMainViewShellOnTop && ! aDescriptor.IsMainViewShell()) + { + if (maActiveViewShells.back().IsMainViewShell()) + aInsertPosition++; + } + + maActiveViewShells.insert(aInsertPosition, aDescriptor); + } } @@ -830,36 +830,36 @@ void ViewShellManager::Implementation::MoveToTop (const SfxShell& rShell) SfxShell* ViewShellManager::Implementation::GetShell (ShellId nId) const { - ::osl::MutexGuard aGuard (maMutex); - - SfxShell* pShell = NULL; - - // First search the active view shells. - ActiveShellList::const_iterator iShell ( - ::std::find_if ( - maActiveViewShells.begin(), - maActiveViewShells.end(), - IsId(nId))); - if (iShell != maActiveViewShells.end()) - pShell = iShell->mpShell; - else - { - // Now search the active sub shells of every active view shell. - SubShellList::const_iterator iList; - for (iList=maActiveSubShells.begin(); iList!=maActiveSubShells.end(); ++iList) - { - const SubShellSubList& rList (iList->second); - SubShellSubList::const_iterator iSubShell( - ::std::find_if(rList.begin(),rList.end(), IsId(nId))); - if (iSubShell != rList.end()) - { - pShell = iSubShell->mpShell; - break; - } - } - } - - return pShell; + ::osl::MutexGuard aGuard (maMutex); + + SfxShell* pShell = NULL; + + // First search the active view shells. + ActiveShellList::const_iterator iShell ( + ::std::find_if ( + maActiveViewShells.begin(), + maActiveViewShells.end(), + IsId(nId))); + if (iShell != maActiveViewShells.end()) + pShell = iShell->mpShell; + else + { + // Now search the active sub shells of every active view shell. + SubShellList::const_iterator iList; + for (iList=maActiveSubShells.begin(); iList!=maActiveSubShells.end(); ++iList) + { + const SubShellSubList& rList (iList->second); + SubShellSubList::const_iterator iSubShell( + ::std::find_if(rList.begin(),rList.end(), IsId(nId))); + if (iSubShell != rList.end()) + { + pShell = iSubShell->mpShell; + break; + } + } + } + + return pShell; } @@ -867,8 +867,8 @@ SfxShell* ViewShellManager::Implementation::GetShell (ShellId nId) const SfxShell* ViewShellManager::Implementation::GetTopShell (void) const { - OSL_ASSERT(mpTopShell == mrBase.GetSubShell(0)); - return mpTopShell; + OSL_ASSERT(mpTopShell == mrBase.GetSubShell(0)); + return mpTopShell; } @@ -876,7 +876,7 @@ SfxShell* ViewShellManager::Implementation::GetTopShell (void) const void ViewShellManager::Implementation::LockUpdate (void) { - mnUpdateLockCount++; + mnUpdateLockCount++; } @@ -884,126 +884,126 @@ void ViewShellManager::Implementation::LockUpdate (void) void ViewShellManager::Implementation::UnlockUpdate (void) { - ::osl::MutexGuard aGuard (maMutex); - - mnUpdateLockCount--; - if (mnUpdateLockCount < 0) - { - // This should not happen. - OSL_ASSERT (mnUpdateLockCount>=0); - mnUpdateLockCount = 0; - } - if (mnUpdateLockCount == 0) - UpdateShellStack(); + ::osl::MutexGuard aGuard (maMutex); + + mnUpdateLockCount--; + if (mnUpdateLockCount < 0) + { + // This should not happen. + OSL_ASSERT (mnUpdateLockCount>=0); + mnUpdateLockCount = 0; + } + if (mnUpdateLockCount == 0) + UpdateShellStack(); } /** Update the SFX shell stack (the portion that is visible to us) so that - it matches the internal shell stack. This is done in six steps: - 1. Create the missing view shells and sub shells. - 2. Set up the internal shell stack. - 3. Get the SFX shell stack. - 4. Find the lowest shell in which the two stacks differ. - 5. Remove all shells above and including that shell from the SFX stack. - 6. Push all shells of the internal stack on the SFX shell stack that are - not already present on the later. + it matches the internal shell stack. This is done in six steps: + 1. Create the missing view shells and sub shells. + 2. Set up the internal shell stack. + 3. Get the SFX shell stack. + 4. Find the lowest shell in which the two stacks differ. + 5. Remove all shells above and including that shell from the SFX stack. + 6. Push all shells of the internal stack on the SFX shell stack that are + not already present on the later. */ void ViewShellManager::Implementation::UpdateShellStack (void) { - ::osl::MutexGuard aGuard (maMutex); + ::osl::MutexGuard aGuard (maMutex); + + // Remember the undo manager from the top-most shell on the stack. + SfxShell* pTopMostShell = mrBase.GetSubShell(0); + ::svl::IUndoManager* pUndoManager = (pTopMostShell!=NULL) + ? pTopMostShell->GetUndoManager() + : NULL; - // Remember the undo manager from the top-most shell on the stack. - SfxShell* pTopMostShell = mrBase.GetSubShell(0); - ::svl::IUndoManager* pUndoManager = (pTopMostShell!=NULL) - ? pTopMostShell->GetUndoManager() - : NULL; + // 1. Create the missing shells. + CreateShells(); - // 1. Create the missing shells. - CreateShells(); - - // 2. Create the internal target stack. - ShellStack aTargetStack; - CreateTargetStack(aTargetStack); + // 2. Create the internal target stack. + ShellStack aTargetStack; + CreateTargetStack(aTargetStack); - - // 3. Get SFX shell stack. - ShellStack aSfxShellStack; - sal_uInt16 nIndex (0); - while (mrBase.GetSubShell(nIndex)!=NULL) - ++nIndex; - aSfxShellStack.reserve(nIndex); - while (nIndex-- > 0) - aSfxShellStack.push_back(mrBase.GetSubShell(nIndex)); + + // 3. Get SFX shell stack. + ShellStack aSfxShellStack; + sal_uInt16 nIndex (0); + while (mrBase.GetSubShell(nIndex)!=NULL) + ++nIndex; + aSfxShellStack.reserve(nIndex); + while (nIndex-- > 0) + aSfxShellStack.push_back(mrBase.GetSubShell(nIndex)); #ifdef VERBOSE - OSL_TRACE("Current SFX Stack\r"); - DumpShellStack(aSfxShellStack); - OSL_TRACE("Target Stack\r"); - DumpShellStack(aTargetStack); + OSL_TRACE("Current SFX Stack\r"); + DumpShellStack(aSfxShellStack); + OSL_TRACE("Target Stack\r"); + DumpShellStack(aTargetStack); #endif - - // 4. Find the lowest shell in which the two stacks differ. - ShellStack::const_iterator iSfxShell (aSfxShellStack.begin()); - ShellStack::iterator iTargetShell (aTargetStack.begin()); - while (iSfxShell != aSfxShellStack.end() - && iTargetShell!=aTargetStack.end() - && (*iSfxShell)==(*iTargetShell)) - { - ++iSfxShell; - ++iTargetShell; - } - - - // 5. Remove all shells above and including the differing shell from the - // SFX stack starting with the shell on top of the stack. - while (iSfxShell != aSfxShellStack.end()) - { - SfxShell* pShell = aSfxShellStack.back(); - aSfxShellStack.pop_back(); + + // 4. Find the lowest shell in which the two stacks differ. + ShellStack::const_iterator iSfxShell (aSfxShellStack.begin()); + ShellStack::iterator iTargetShell (aTargetStack.begin()); + while (iSfxShell != aSfxShellStack.end() + && iTargetShell!=aTargetStack.end() + && (*iSfxShell)==(*iTargetShell)) + { + ++iSfxShell; + ++iTargetShell; + } + + + // 5. Remove all shells above and including the differing shell from the + // SFX stack starting with the shell on top of the stack. + while (iSfxShell != aSfxShellStack.end()) + { + SfxShell* pShell = aSfxShellStack.back(); + aSfxShellStack.pop_back(); #ifdef VERBOSE - OSL_TRACE("removing shell %p from stack\r", pShell); + OSL_TRACE("removing shell %p from stack\r", pShell); #endif - mrBase.RemoveSubShell(pShell); - } - - - // 6. Push shells from the given stack onto the SFX stack. - mbShellStackIsUpToDate = false; - while (iTargetShell != aTargetStack.end()) - { + mrBase.RemoveSubShell(pShell); + } + + + // 6. Push shells from the given stack onto the SFX stack. + mbShellStackIsUpToDate = false; + while (iTargetShell != aTargetStack.end()) + { #ifdef VERBOSE - OSL_TRACE("pushing shell %p on stack\r", *iTargetShell); + OSL_TRACE("pushing shell %p on stack\r", *iTargetShell); #endif - mrBase.AddSubShell(**iTargetShell); - ++iTargetShell; - - // The pushing of the shell on to the shell stack may have lead to - // another invocation of this method. In this case we have to abort - // pushing shells on the stack and return immediately. - if (mbShellStackIsUpToDate) - break; - } - if (mrBase.GetDispatcher() != NULL) - mrBase.GetDispatcher()->Flush(); - - // Update the pointer to the top-most shell and set its undo manager - // to the one of the previous top-most shell. - mpTopShell = mrBase.GetSubShell(0); - if (mpTopShell!=NULL && pUndoManager!=NULL && mpTopShell->GetUndoManager()==NULL) - mpTopShell->SetUndoManager(pUndoManager); - - // Finally tell an invocation of this method on a higher level that it can (has - // to) abort and return immediately. - mbShellStackIsUpToDate = true; + mrBase.AddSubShell(**iTargetShell); + ++iTargetShell; + + // The pushing of the shell on to the shell stack may have lead to + // another invocation of this method. In this case we have to abort + // pushing shells on the stack and return immediately. + if (mbShellStackIsUpToDate) + break; + } + if (mrBase.GetDispatcher() != NULL) + mrBase.GetDispatcher()->Flush(); + + // Update the pointer to the top-most shell and set its undo manager + // to the one of the previous top-most shell. + mpTopShell = mrBase.GetSubShell(0); + if (mpTopShell!=NULL && pUndoManager!=NULL && mpTopShell->GetUndoManager()==NULL) + mpTopShell->SetUndoManager(pUndoManager); + + // Finally tell an invocation of this method on a higher level that it can (has + // to) abort and return immediately. + mbShellStackIsUpToDate = true; #ifdef VERBOSE - OSL_TRACE("New current stack\r"); - DumpSfxShellStack(); + OSL_TRACE("New current stack\r"); + DumpSfxShellStack(); #endif } @@ -1012,73 +1012,73 @@ void ViewShellManager::Implementation::UpdateShellStack (void) void ViewShellManager::Implementation::TakeShellsFromStack (const SfxShell* pShell) { - ::osl::MutexGuard aGuard (maMutex); + ::osl::MutexGuard aGuard (maMutex); - // Remember the undo manager from the top-most shell on the stack. - SfxShell* pTopMostShell = mrBase.GetSubShell(0); - ::svl::IUndoManager* pUndoManager = (pTopMostShell!=NULL) - ? pTopMostShell->GetUndoManager() - : NULL; + // Remember the undo manager from the top-most shell on the stack. + SfxShell* pTopMostShell = mrBase.GetSubShell(0); + ::svl::IUndoManager* pUndoManager = (pTopMostShell!=NULL) + ? pTopMostShell->GetUndoManager() + : NULL; #ifdef VERBOSE - OSL_TRACE("TakeShellsFromStack(%p)\r", pShell); - DumpSfxShellStack(); + OSL_TRACE("TakeShellsFromStack(%p)\r", pShell); + DumpSfxShellStack(); #endif - // 0.Make sure that the given shell is on the stack. This is a - // preparation for the following assertion. - for (sal_uInt16 nIndex=0; true; nIndex++) - { - SfxShell* pShellOnStack = mrBase.GetSubShell(nIndex); - if (pShellOnStack == NULL) - { - // Set pShell to NULL to indicate the following code that the - // shell is not on the stack. - pShell = NULL; - break; - } - else if (pShellOnStack == pShell) - break; - } - - if (pShell != NULL) - { - // 1. Deactivate our shells on the stack before they are removed so - // that during the Deactivation() calls the stack is still intact. - for (sal_uInt16 nIndex=0; true; nIndex++) - { - SfxShell* pShellOnStack = mrBase.GetSubShell(nIndex); - Deactivate(pShellOnStack); - if (pShellOnStack == pShell) - break; - } - - // 2. Remove the shells from the stack. - while (true) - { - SfxShell* pShellOnStack = mrBase.GetSubShell(0); + // 0.Make sure that the given shell is on the stack. This is a + // preparation for the following assertion. + for (sal_uInt16 nIndex=0; true; nIndex++) + { + SfxShell* pShellOnStack = mrBase.GetSubShell(nIndex); + if (pShellOnStack == NULL) + { + // Set pShell to NULL to indicate the following code that the + // shell is not on the stack. + pShell = NULL; + break; + } + else if (pShellOnStack == pShell) + break; + } + + if (pShell != NULL) + { + // 1. Deactivate our shells on the stack before they are removed so + // that during the Deactivation() calls the stack is still intact. + for (sal_uInt16 nIndex=0; true; nIndex++) + { + SfxShell* pShellOnStack = mrBase.GetSubShell(nIndex); + Deactivate(pShellOnStack); + if (pShellOnStack == pShell) + break; + } + + // 2. Remove the shells from the stack. + while (true) + { + SfxShell* pShellOnStack = mrBase.GetSubShell(0); #ifdef VERBOSE - OSL_TRACE("removing shell %p from stack\r", pShellOnStack); + OSL_TRACE("removing shell %p from stack\r", pShellOnStack); #endif - mrBase.RemoveSubShell(pShellOnStack); - if (pShellOnStack == pShell) - break; - } - - // 3. Update the stack. - if (mrBase.GetDispatcher() != NULL) - mrBase.GetDispatcher()->Flush(); - - // Update the pointer to the top-most shell and set its undo manager - // to the one of the previous top-most shell. - mpTopShell = mrBase.GetSubShell(0); - if (mpTopShell!=NULL && pUndoManager!=NULL && mpTopShell->GetUndoManager()==NULL) - mpTopShell->SetUndoManager(pUndoManager); - } + mrBase.RemoveSubShell(pShellOnStack); + if (pShellOnStack == pShell) + break; + } + + // 3. Update the stack. + if (mrBase.GetDispatcher() != NULL) + mrBase.GetDispatcher()->Flush(); + + // Update the pointer to the top-most shell and set its undo manager + // to the one of the previous top-most shell. + mpTopShell = mrBase.GetSubShell(0); + if (mpTopShell!=NULL && pUndoManager!=NULL && mpTopShell->GetUndoManager()==NULL) + mpTopShell->SetUndoManager(pUndoManager); + } #ifdef VERBOSE - OSL_TRACE("Sfx shell stack is:\r"); - DumpSfxShellStack(); + OSL_TRACE("Sfx shell stack is:\r"); + DumpSfxShellStack(); #endif } @@ -1087,30 +1087,30 @@ void ViewShellManager::Implementation::TakeShellsFromStack (const SfxShell* pShe void ViewShellManager::Implementation::CreateShells (void) { - ::osl::MutexGuard aGuard (maMutex); - - // Iterate over all view shells. - ShellStack aShellStack; - ActiveShellList::reverse_iterator iShell; - for (iShell=maActiveViewShells.rbegin(); iShell!=maActiveViewShells.rend(); ++iShell) - { - // Get the list of associated sub shells. - SubShellList::iterator iList (maActiveSubShells.find(iShell->mpShell)); - if (iList != maActiveSubShells.end()) - { - SubShellSubList& rList (iList->second); - - // Iterate over all sub shells of the current view shell. - SubShellSubList::iterator iSubShell; - for (iSubShell=rList.begin(); iSubShell!=rList.end(); ++iSubShell) - { - if (iSubShell->mpShell == NULL) - { - *iSubShell = CreateSubShell(iShell->mpShell,iSubShell->mnId,NULL,NULL); - } - } - } - } + ::osl::MutexGuard aGuard (maMutex); + + // Iterate over all view shells. + ShellStack aShellStack; + ActiveShellList::reverse_iterator iShell; + for (iShell=maActiveViewShells.rbegin(); iShell!=maActiveViewShells.rend(); ++iShell) + { + // Get the list of associated sub shells. + SubShellList::iterator iList (maActiveSubShells.find(iShell->mpShell)); + if (iList != maActiveSubShells.end()) + { + SubShellSubList& rList (iList->second); + + // Iterate over all sub shells of the current view shell. + SubShellSubList::iterator iSubShell; + for (iSubShell=rList.begin(); iSubShell!=rList.end(); ++iSubShell) + { + if (iSubShell->mpShell == NULL) + { + *iSubShell = CreateSubShell(iShell->mpShell,iSubShell->mnId,NULL,NULL); + } + } + } + } } @@ -1118,43 +1118,43 @@ void ViewShellManager::Implementation::CreateShells (void) void ViewShellManager::Implementation::CreateTargetStack (ShellStack& rStack) const { - // Create a local stack of the shells that are to push on the shell - // stack. We can thus safly create the required shells wile still - // having a valid shell stack. - for (ActiveShellList::const_reverse_iterator iViewShell (maActiveViewShells.rbegin()); - iViewShell != maActiveViewShells.rend(); - ++iViewShell) - { - // Possibly place the form shell below the current view shell. - if ( ! mbFormShellAboveParent - && mpFormShell!=NULL - && iViewShell->mpShell==mpFormShellParent) - { - rStack.push_back(mpFormShell); - } - - // Put the view shell itself on the local stack. - rStack.push_back (iViewShell->mpShell); - - // Possibly place the form shell above the current view shell. - if (mbFormShellAboveParent - && mpFormShell!=NULL - && iViewShell->mpShell==mpFormShellParent) - { - rStack.push_back(mpFormShell); - } - - // Add all other sub shells. - SubShellList::const_iterator iList (maActiveSubShells.find(iViewShell->mpShell)); - if (iList != maActiveSubShells.end()) - { - const SubShellSubList& rList (iList->second); - SubShellSubList::const_reverse_iterator iSubShell; - for (iSubShell=rList.rbegin(); iSubShell!=rList.rend(); ++iSubShell) - if (iSubShell->mpShell != mpFormShell) - rStack.push_back(iSubShell->mpShell); - } - } + // Create a local stack of the shells that are to push on the shell + // stack. We can thus safely create the required shells while still + // having a valid shell stack. + for (ActiveShellList::const_reverse_iterator iViewShell (maActiveViewShells.rbegin()); + iViewShell != maActiveViewShells.rend(); + ++iViewShell) + { + // Possibly place the form shell below the current view shell. + if ( ! mbFormShellAboveParent + && mpFormShell!=NULL + && iViewShell->mpShell==mpFormShellParent) + { + rStack.push_back(mpFormShell); + } + + // Put the view shell itself on the local stack. + rStack.push_back (iViewShell->mpShell); + + // Possibly place the form shell above the current view shell. + if (mbFormShellAboveParent + && mpFormShell!=NULL + && iViewShell->mpShell==mpFormShellParent) + { + rStack.push_back(mpFormShell); + } + + // Add all other sub shells. + SubShellList::const_iterator iList (maActiveSubShells.find(iViewShell->mpShell)); + if (iList != maActiveSubShells.end()) + { + const SubShellSubList& rList (iList->second); + SubShellSubList::const_reverse_iterator iSubShell; + for (iSubShell=rList.rbegin(); iSubShell!=rList.rend(); ++iSubShell) + if (iSubShell->mpShell != mpFormShell) + rStack.push_back(iSubShell->mpShell); + } + } } @@ -1162,127 +1162,127 @@ void ViewShellManager::Implementation::CreateTargetStack (ShellStack& rStack) co IMPL_LINK(ViewShellManager::Implementation, WindowEventHandler, VclWindowEvent*, pEvent) { - if (pEvent != NULL) - { - ::Window* pEventWindow - = static_cast<VclWindowEvent*>(pEvent)->GetWindow(); - - switch (pEvent->GetId()) - { - case VCLEVENT_WINDOW_GETFOCUS: - { - for (ActiveShellList::iterator aI(maActiveViewShells.begin()); - aI!=maActiveViewShells.end(); - aI++) - { - if (pEventWindow == static_cast< ::Window*>(aI->GetWindow())) - { - MoveToTop(*aI->mpShell); - break; - } - } - } - break; - - case VCLEVENT_WINDOW_LOSEFOCUS: - break; - - case VCLEVENT_OBJECT_DYING: - // Remember that we do not have to remove the window - // listener for this window. - for (ActiveShellList::iterator - iShell(maActiveViewShells.begin()), - iEnd(maActiveViewShells.end()); - iShell!=iEnd; - ++iShell) - { - if (iShell->GetWindow() == pEventWindow) - { - iShell->mbIsListenerAddedToWindow = false; - break; - } - } - break; - } - } - return sal_True; + if (pEvent != NULL) + { + ::Window* pEventWindow + = static_cast<VclWindowEvent*>(pEvent)->GetWindow(); + + switch (pEvent->GetId()) + { + case VCLEVENT_WINDOW_GETFOCUS: + { + for (ActiveShellList::iterator aI(maActiveViewShells.begin()); + aI!=maActiveViewShells.end(); + aI++) + { + if (pEventWindow == static_cast< ::Window*>(aI->GetWindow())) + { + MoveToTop(*aI->mpShell); + break; + } + } + } + break; + + case VCLEVENT_WINDOW_LOSEFOCUS: + break; + + case VCLEVENT_OBJECT_DYING: + // Remember that we do not have to remove the window + // listener for this window. + for (ActiveShellList::iterator + iShell(maActiveViewShells.begin()), + iEnd(maActiveViewShells.end()); + iShell!=iEnd; + ++iShell) + { + if (iShell->GetWindow() == pEventWindow) + { + iShell->mbIsListenerAddedToWindow = false; + break; + } + } + break; + } + } + return sal_True; } ShellDescriptor ViewShellManager::Implementation::CreateSubShell ( - SfxShell* pParentShell, - ShellId nShellId, - ::Window* pParentWindow, - FrameView* pFrameView) + SfxShell* pParentShell, + ShellId nShellId, + ::Window* pParentWindow, + FrameView* pFrameView) { - ::osl::MutexGuard aGuard (maMutex); - ShellDescriptor aResult; - - // Look up the factories for the parent shell. - ::std::pair<FactoryList::iterator,FactoryList::iterator> aRange( - maShellFactories.equal_range(pParentShell)); - - // Try all factories to create the shell. - for (FactoryList::const_iterator iFactory=aRange.first; iFactory!=aRange.second; ++iFactory) - { - SharedShellFactory pFactory = iFactory->second; - if( bool(pFactory)) - aResult.mpShell = pFactory->CreateShell(nShellId, pParentWindow, pFrameView); - - // Exit the loop when the shell has been successfully created. - if (aResult.mpShell != NULL) - { - aResult.mpFactory = pFactory; - aResult.mnId = nShellId; - break; - } - } - - return aResult; + ::osl::MutexGuard aGuard (maMutex); + ShellDescriptor aResult; + + // Look up the factories for the parent shell. + ::std::pair<FactoryList::iterator,FactoryList::iterator> aRange( + maShellFactories.equal_range(pParentShell)); + + // Try all factories to create the shell. + for (FactoryList::const_iterator iFactory=aRange.first; iFactory!=aRange.second; ++iFactory) + { + SharedShellFactory pFactory = iFactory->second; + if( bool(pFactory)) + aResult.mpShell = pFactory->CreateShell(nShellId, pParentWindow, pFrameView); + + // Exit the loop when the shell has been successfully created. + if (aResult.mpShell != NULL) + { + aResult.mpFactory = pFactory; + aResult.mnId = nShellId; + break; + } + } + + return aResult; } void ViewShellManager::Implementation::DestroyViewShell ( - ShellDescriptor& rDescriptor) + ShellDescriptor& rDescriptor) { - OSL_ASSERT(rDescriptor.mpShell != NULL); - - if (rDescriptor.mbIsListenerAddedToWindow) - { - rDescriptor.mbIsListenerAddedToWindow = false; - ::Window* pWindow = rDescriptor.GetWindow(); - if (pWindow != NULL) - { - pWindow->RemoveEventListener( - LINK(this, ViewShellManager::Implementation, WindowEventHandler)); - } - } - - // Destroy the sub shell factories. - ::std::pair<FactoryList::iterator,FactoryList::iterator> aRange( - maShellFactories.equal_range(rDescriptor.mpShell)); - if (aRange.first != maShellFactories.end()) - maShellFactories.erase(aRange.first, aRange.second); - - // Release the shell. - if (rDescriptor.mpFactory.get() != NULL) - rDescriptor.mpFactory->ReleaseShell(rDescriptor.mpShell); + OSL_ASSERT(rDescriptor.mpShell != NULL); + + if (rDescriptor.mbIsListenerAddedToWindow) + { + rDescriptor.mbIsListenerAddedToWindow = false; + ::Window* pWindow = rDescriptor.GetWindow(); + if (pWindow != NULL) + { + pWindow->RemoveEventListener( + LINK(this, ViewShellManager::Implementation, WindowEventHandler)); + } + } + + // Destroy the sub shell factories. + ::std::pair<FactoryList::iterator,FactoryList::iterator> aRange( + maShellFactories.equal_range(rDescriptor.mpShell)); + if (aRange.first != maShellFactories.end()) + maShellFactories.erase(aRange.first, aRange.second); + + // Release the shell. + if (rDescriptor.mpFactory.get() != NULL) + rDescriptor.mpFactory->ReleaseShell(rDescriptor.mpShell); } void ViewShellManager::Implementation::DestroySubShell ( - const SfxShell& rParentShell, - const ShellDescriptor& rDescriptor) + const SfxShell& rParentShell, + const ShellDescriptor& rDescriptor) { - (void)rParentShell; - OSL_ASSERT(rDescriptor.mpFactory.get() != NULL); - rDescriptor.mpFactory->ReleaseShell(rDescriptor.mpShell); + (void)rParentShell; + OSL_ASSERT(rDescriptor.mpFactory.get() != NULL); + rDescriptor.mpFactory->ReleaseShell(rDescriptor.mpShell); } @@ -1290,17 +1290,17 @@ void ViewShellManager::Implementation::DestroySubShell ( void ViewShellManager::Implementation::InvalidateAllSubShells (const SfxShell* pParentShell) { - ::osl::MutexGuard aGuard (maMutex); - - SubShellList::iterator iList (maActiveSubShells.find(pParentShell)); - if (iList != maActiveSubShells.end()) - { - SubShellSubList& rList (iList->second); - SubShellSubList::iterator iShell; - for (iShell=rList.begin(); iShell!=rList.end(); ++iShell) - if (iShell->mpShell != NULL) - iShell->mpShell->Invalidate(); - } + ::osl::MutexGuard aGuard (maMutex); + + SubShellList::iterator iList (maActiveSubShells.find(pParentShell)); + if (iList != maActiveSubShells.end()) + { + SubShellSubList& rList (iList->second); + SubShellSubList::iterator iShell; + for (iShell=rList.begin(); iShell!=rList.end(); ++iShell) + if (iShell->mpShell != NULL) + iShell->mpShell->Invalidate(); + } } @@ -1308,36 +1308,36 @@ void ViewShellManager::Implementation::InvalidateAllSubShells (const SfxShell* p void ViewShellManager::Implementation::Shutdown (void) { - ::osl::MutexGuard aGuard (maMutex); - - // Take stacked shells from stack. - if ( ! maActiveViewShells.empty()) - { - UpdateLock aLock (*this); - - - while ( ! maActiveViewShells.empty()) - { - SfxShell* pShell = maActiveViewShells.front().mpShell; - if (pShell != NULL) - { - ViewShell* pViewShell = dynamic_cast<ViewShell*>(pShell); - if (pViewShell != NULL) - DeactivateViewShell(*pViewShell); - else - DeactivateShell(*pShell); - } - else - { - DBG_ASSERT(false, - "ViewShellManager::Implementation::Shutdown(): empty active shell descriptor"); - maActiveViewShells.pop_front(); - } - } - } - mrBase.RemoveSubShell (NULL); - - maShellFactories.clear(); + ::osl::MutexGuard aGuard (maMutex); + + // Take stacked shells from stack. + if ( ! maActiveViewShells.empty()) + { + UpdateLock aLock (*this); + + + while ( ! maActiveViewShells.empty()) + { + SfxShell* pShell = maActiveViewShells.front().mpShell; + if (pShell != NULL) + { + ViewShell* pViewShell = dynamic_cast<ViewShell*>(pShell); + if (pViewShell != NULL) + DeactivateViewShell(*pViewShell); + else + DeactivateShell(*pShell); + } + else + { + DBG_ASSERT(false, + "ViewShellManager::Implementation::Shutdown(): empty active shell descriptor"); + maActiveViewShells.pop_front(); + } + } + } + mrBase.RemoveSubShell (NULL); + + maShellFactories.clear(); } @@ -1346,14 +1346,14 @@ void ViewShellManager::Implementation::Shutdown (void) #ifdef VERBOSE void ViewShellManager::Implementation::DumpShellStack (const ShellStack& rStack) { - ShellStack::const_reverse_iterator iEntry; - for (iEntry=rStack.rbegin(); iEntry!=rStack.rend(); ++iEntry) - if (*iEntry != NULL) - OSL_TRACE (" %p : %s\r", - *iEntry, - ::rtl::OUStringToOString((*iEntry)->GetName(),RTL_TEXTENCODING_UTF8).getStr()); - else - OSL_TRACE(" null\r"); + ShellStack::const_reverse_iterator iEntry; + for (iEntry=rStack.rbegin(); iEntry!=rStack.rend(); ++iEntry) + if (*iEntry != NULL) + OSL_TRACE (" %p : %s\r", + *iEntry, + ::rtl::OUStringToOString((*iEntry)->GetName(),RTL_TEXTENCODING_UTF8).getStr()); + else + OSL_TRACE(" null\r"); } @@ -1361,14 +1361,14 @@ void ViewShellManager::Implementation::DumpShellStack (const ShellStack& rStack) void ViewShellManager::Implementation::DumpSfxShellStack (void) { - ShellStack aSfxShellStack; - sal_uInt16 nIndex (0); - while (mrBase.GetSubShell(nIndex)!=NULL) - ++nIndex; - aSfxShellStack.reserve(nIndex); - while (nIndex-- > 0) - aSfxShellStack.push_back(mrBase.GetSubShell(nIndex)); - DumpShellStack(aSfxShellStack); + ShellStack aSfxShellStack; + sal_uInt16 nIndex (0); + while (mrBase.GetSubShell(nIndex)!=NULL) + ++nIndex; + aSfxShellStack.reserve(nIndex); + while (nIndex-- > 0) + aSfxShellStack.push_back(mrBase.GetSubShell(nIndex)); + DumpShellStack(aSfxShellStack); } #endif @@ -1376,41 +1376,41 @@ void ViewShellManager::Implementation::DumpSfxShellStack (void) void ViewShellManager::Implementation::Deactivate (SfxShell* pShell) { - OSL_ASSERT(pShell!=NULL); + OSL_ASSERT(pShell!=NULL); - // We have to end a text edit for view shells that are to be taken from - // the shell stack. - ViewShell* pViewShell = dynamic_cast<ViewShell*>(pShell); - if (pViewShell != NULL) - { + // We have to end a text edit for view shells that are to be taken from + // the shell stack. + ViewShell* pViewShell = dynamic_cast<ViewShell*>(pShell); + if (pViewShell != NULL) + { sd::View* pView = pViewShell->GetView(); - if (pView!=NULL && pView->IsTextEdit()) - { - pView->SdrEndTextEdit(); - pView->UnmarkAll(); - pViewShell->GetViewFrame()->GetDispatcher()->Execute( - SID_OBJECT_SELECT, - SFX_CALLMODE_ASYNCHRON); - } - } - - // Now we can deactivate the shell. - pShell->Deactivate(sal_True); + if (pView!=NULL && pView->IsTextEdit()) + { + pView->SdrEndTextEdit(); + pView->UnmarkAll(); + pViewShell->GetViewFrame()->GetDispatcher()->Execute( + SID_OBJECT_SELECT, + SFX_CALLMODE_ASYNCHRON); + } + } + + // Now we can deactivate the shell. + pShell->Deactivate(sal_True); } void ViewShellManager::Implementation::SetFormShell ( - const ViewShell* pFormShellParent, - FmFormShell* pFormShell, - bool bFormShellAboveParent) + const ViewShell* pFormShellParent, + FmFormShell* pFormShell, + bool bFormShellAboveParent) { - ::osl::MutexGuard aGuard (maMutex); + ::osl::MutexGuard aGuard (maMutex); - mpFormShellParent = pFormShellParent; - mpFormShell = pFormShell; - mbFormShellAboveParent = bFormShellAboveParent; + mpFormShellParent = pFormShellParent; + mpFormShell = pFormShell; + mbFormShellAboveParent = bFormShellAboveParent; } @@ -1419,10 +1419,10 @@ void ViewShellManager::Implementation::SetFormShell ( namespace { ShellDescriptor::ShellDescriptor (void) - : mpShell(NULL), - mnId(0), - mpFactory(), - mbIsListenerAddedToWindow(false) + : mpShell(NULL), + mnId(0), + mpFactory(), + mbIsListenerAddedToWindow(false) { } @@ -1430,12 +1430,12 @@ ShellDescriptor::ShellDescriptor (void) ShellDescriptor::ShellDescriptor ( - SfxShell* pShell, - ShellId nId) - : mpShell(pShell), - mnId(nId), - mpFactory(), - mbIsListenerAddedToWindow(false) + SfxShell* pShell, + ShellId nId) + : mpShell(pShell), + mnId(nId), + mpFactory(), + mbIsListenerAddedToWindow(false) { } @@ -1443,10 +1443,10 @@ ShellDescriptor::ShellDescriptor ( ShellDescriptor::ShellDescriptor (const ShellDescriptor& rDescriptor) - : mpShell(rDescriptor.mpShell), - mnId(rDescriptor.mnId), - mpFactory(rDescriptor.mpFactory), - mbIsListenerAddedToWindow(rDescriptor.mbIsListenerAddedToWindow) + : mpShell(rDescriptor.mpShell), + mnId(rDescriptor.mnId), + mpFactory(rDescriptor.mpFactory), + mbIsListenerAddedToWindow(rDescriptor.mbIsListenerAddedToWindow) { } @@ -1455,14 +1455,14 @@ ShellDescriptor::ShellDescriptor (const ShellDescriptor& rDescriptor) ShellDescriptor& ShellDescriptor::operator= (const ShellDescriptor& rDescriptor) { - if (this != &rDescriptor) - { - mpShell = rDescriptor.mpShell; - mnId = rDescriptor.mnId; - mpFactory = rDescriptor.mpFactory; - mbIsListenerAddedToWindow = rDescriptor.mbIsListenerAddedToWindow; - } - return *this; + if (this != &rDescriptor) + { + mpShell = rDescriptor.mpShell; + mnId = rDescriptor.mnId; + mpFactory = rDescriptor.mpFactory; + mbIsListenerAddedToWindow = rDescriptor.mbIsListenerAddedToWindow; + } + return *this; } @@ -1470,11 +1470,11 @@ ShellDescriptor& ShellDescriptor::operator= (const ShellDescriptor& rDescriptor) bool ShellDescriptor::IsMainViewShell (void) const { - ViewShell* pViewShell = dynamic_cast<ViewShell*>(mpShell); - if (pViewShell != NULL) - return pViewShell->IsMainViewShell(); - else - return false; + ViewShell* pViewShell = dynamic_cast<ViewShell*>(mpShell); + if (pViewShell != NULL) + return pViewShell->IsMainViewShell(); + else + return false; } @@ -1482,11 +1482,11 @@ bool ShellDescriptor::IsMainViewShell (void) const ::Window* ShellDescriptor::GetWindow (void) const { - ViewShell* pViewShell = dynamic_cast<ViewShell*>(mpShell); - if (pViewShell != NULL) - return pViewShell->GetActiveWindow(); - else - return NULL; + ViewShell* pViewShell = dynamic_cast<ViewShell*>(mpShell); + if (pViewShell != NULL) + return pViewShell->GetActiveWindow(); + else + return NULL; }