diff options
author | Michael Stahl <mst@apache.org> | 2011-09-17 21:43:23 +0000 |
---|---|---|
committer | Michael Stahl <mst@apache.org> | 2011-09-17 21:43:23 +0000 |
commit | be42404ba844436584f4f475f2553b53af49ffbc (patch) | |
tree | 9b2276bf3f2296dfb88ed737fa92fd7158fa654a /sd | |
parent | b72e5fbd8b3bf9239510936a39ec170a4c82f1b8 (diff) |
slidesorter1: #i116014# Outliner holds ViewShell as weak_ptr.
# HG changeset patch
# User Andre Fischer<andre.f.fischer@oracle.com>
# Date 1300869929 -3600
# Node ID dd74093681332c51934ab449c4b7c9eaec89359a
# Parent bca8ed5c98e5c645a6c69c7fb90cd3da84627212
Diffstat (limited to 'sd')
-rwxr-xr-x | sd/inc/Outliner.hxx | 17 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx | 1 | ||||
-rwxr-xr-x | sd/source/ui/view/Outliner.cxx | 367 | ||||
-rwxr-xr-x | sd/source/ui/view/OutlinerIterator.cxx | 4 |
4 files changed, 213 insertions, 176 deletions
diff --git a/sd/inc/Outliner.hxx b/sd/inc/Outliner.hxx index 45db437e9370..2eeebaec4454 100755 --- a/sd/inc/Outliner.hxx +++ b/sd/inc/Outliner.hxx @@ -35,6 +35,8 @@ #include <editeng/SpellPortions.hxx> #include <memory> #include <boost/shared_ptr.hpp> +#include <boost/weak_ptr.hpp> +#include <boost/noncopyable.hpp> class Dialog; class SdPage; @@ -104,7 +106,8 @@ class Window; </p> */ class Outliner - : public SdrOutliner + : public SdrOutliner, + public ::boost::noncopyable { public: friend class ::sd::outliner::OutlinerContainer; @@ -193,8 +196,11 @@ private: /// The view which displays the searched objects. ::sd::View* mpView; - /// The view shell containing the view. - ::boost::shared_ptr<ViewShell> mpViewShell; + /** The view shell containing the view. It is held as weak + pointer to avoid keeping it alive when the view is changed + during searching. + */ + ::boost::weak_ptr<ViewShell> mpWeakViewShell; /// This window contains the view. ::sd::Window* mpWindow; /// The document on whose objects and pages this class operates. @@ -346,11 +352,6 @@ private: */ bool mbPrepareSpellingPending; - /** In this flag we store whether the view shell is valid and may be - accessed. - */ - bool mbViewShellValid; - /** Initialize the object iterator. Call this method after being invoked from the search or spellcheck dialog. It creates a new iterator pointing at the current object when this has not been done diff --git a/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx b/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx index 97051d52f003..82e3f16543d3 100644 --- a/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx +++ b/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx @@ -505,7 +505,6 @@ Bitmap PageObjectPainter::CreateBackgroundBitmap( // Fill the background with the background color of the slide sorter. const Color aBackgroundColor (mpTheme->GetColor(Theme::Color_Background)); - OSL_TRACE("filling background of page object bitmap with color %x", aBackgroundColor.GetColor()); aBitmapDevice.SetFillColor(aBackgroundColor); aBitmapDevice.SetLineColor(aBackgroundColor); aBitmapDevice.DrawRect(Rectangle(Point(0,0), aSize)); diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx index 29440af545bc..9fd874db2f51 100755 --- a/sd/source/ui/view/Outliner.cxx +++ b/sd/source/ui/view/Outliner.cxx @@ -149,7 +149,7 @@ Outliner::Outliner( SdDrawDocument* pDoc, sal_uInt16 nMode ) mpImpl(new Implementation()), meMode(SEARCH), mpView(NULL), - mpViewShell(), + mpWeakViewShell(), mpWindow(NULL), mpDrawDocument(pDoc), mnConversionLanguage(LANGUAGE_NONE), @@ -183,8 +183,7 @@ Outliner::Outliner( SdDrawDocument* pDoc, sal_uInt16 nMode ) mbSelectionHasChanged(false), mbExpectingSelectionChangeEvent(false), mbWholeDocumentProcessed(false), - mbPrepareSpellingPending(true), - mbViewShellValid(true) + mbPrepareSpellingPending(true) { SetStyleSheetPool((SfxStyleSheetPool*) mpDrawDocument->GetStyleSheetPool()); SetEditTextObjectPool( &pDoc->GetItemPool() ); @@ -278,35 +277,33 @@ Outliner::~Outliner (void) */ void Outliner::PrepareSpelling (void) { - if (mbViewShellValid) - { - mbPrepareSpellingPending = false; + mbPrepareSpellingPending = false; - ViewShellBase* pBase = PTR_CAST(ViewShellBase,SfxViewShell::Current()); - if (pBase != NULL) - SetViewShell (pBase->GetMainViewShell()); - SetRefDevice( SD_MOD()->GetRefDevice( *mpDrawDocument->GetDocSh() ) ); + ViewShellBase* pBase = PTR_CAST(ViewShellBase,SfxViewShell::Current()); + if (pBase != NULL) + SetViewShell (pBase->GetMainViewShell()); + SetRefDevice( SD_MOD()->GetRefDevice( *mpDrawDocument->GetDocSh() ) ); - if (mpViewShell.get() != NULL) - { - mbStringFound = sal_False; + ::boost::shared_ptr<ViewShell> pViewShell (mpWeakViewShell.lock()); + if (pViewShell) + { + mbStringFound = sal_False; - mbWholeDocumentProcessed = false; - // Supposed that we are not located at the very beginning/end of - // the document then there may be a match in the document - // prior/after the current position. - mbMatchMayExist = sal_True; + mbWholeDocumentProcessed = false; + // Supposed that we are not located at the very beginning/end of + // the document then there may be a match in the document + // prior/after the current position. + mbMatchMayExist = sal_True; - maObjectIterator = ::sd::outliner::Iterator(); - maSearchStartPosition = ::sd::outliner::Iterator(); - RememberStartPosition(); + maObjectIterator = ::sd::outliner::Iterator(); + maSearchStartPosition = ::sd::outliner::Iterator(); + RememberStartPosition(); - mpImpl->ProvideOutlinerView(*this, mpViewShell, mpWindow); + mpImpl->ProvideOutlinerView(*this, pViewShell, mpWindow); - HandleChangedSelection (); - } - ClearModifyFlag(); + HandleChangedSelection (); } + ClearModifyFlag(); } @@ -331,64 +328,62 @@ void Outliner::StartSpelling(EditView& rView, unsigned char c) */ void Outliner::EndSpelling (void) { - if (mbViewShellValid) - { - // Keep old view shell alive until we release the outliner view. - ::boost::shared_ptr<ViewShell> pOldViewShell (mpViewShell); + // Keep old view shell alive until we release the outliner view. + ::boost::shared_ptr<ViewShell> pViewShell (mpWeakViewShell.lock()); + ::boost::shared_ptr<ViewShell> pOldViewShell (pViewShell); - ViewShellBase* pBase = PTR_CAST(ViewShellBase,SfxViewShell::Current()); - if (pBase != NULL) - mpViewShell = pBase->GetMainViewShell(); - else - mpViewShell.reset(); - - // When in <member>PrepareSpelling()</member> a new outline view has - // been created then delete it here. - sal_Bool bViewIsDrawViewShell(mpViewShell.get()!=NULL - && mpViewShell->ISA(DrawViewShell)); - if (bViewIsDrawViewShell) - { - SetStatusEventHdl(Link()); - mpView = mpViewShell->GetView(); - mpView->UnmarkAllObj (mpView->GetSdrPageView()); - mpView->SdrEndTextEdit(); - // Make FuSelection the current function. - mpViewShell->GetDispatcher()->Execute( - SID_OBJECT_SELECT, - SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD); - - // Remove and, if previously created by us, delete the outline - // view. - OutlinerView* pOutlinerView = mpImpl->GetOutlinerView(); - if (pOutlinerView != NULL) - { - RemoveView(pOutlinerView); - mpImpl->ReleaseOutlinerView(); - } + ViewShellBase* pBase = PTR_CAST(ViewShellBase,SfxViewShell::Current()); + if (pBase != NULL) + pViewShell = pBase->GetMainViewShell(); + else + pViewShell.reset(); + mpWeakViewShell = pViewShell; - SetUpdateMode(sal_True); - } + // When in <member>PrepareSpelling()</member> a new outline view has + // been created then delete it here. + sal_Bool bViewIsDrawViewShell(pViewShell && pViewShell->ISA(DrawViewShell)); + if (bViewIsDrawViewShell) + { + SetStatusEventHdl(Link()); + mpView = pViewShell->GetView(); + mpView->UnmarkAllObj (mpView->GetSdrPageView()); + mpView->SdrEndTextEdit(); + // Make FuSelection the current function. + pViewShell->GetDispatcher()->Execute( + SID_OBJECT_SELECT, + SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD); - // #95811# Before clearing the modify flag use it as a hint that - // changes were done at SpellCheck - if(IsModified()) + // Remove and, if previously created by us, delete the outline + // view. + OutlinerView* pOutlinerView = mpImpl->GetOutlinerView(); + if (pOutlinerView != NULL) { - if(mpView && mpView->ISA(OutlineView)) - static_cast<OutlineView*>(mpView)->PrepareClose(sal_False); - if(mpDrawDocument && !mpDrawDocument->IsChanged()) - mpDrawDocument->SetChanged(sal_True); + RemoveView(pOutlinerView); + mpImpl->ReleaseOutlinerView(); } - // #95811# now clear the modify flag to have a specified state of - // Outliner - ClearModifyFlag(); + SetUpdateMode(sal_True); + } - // When spell checking then restore the start position. - if (meMode==SPELL || meMode==TEXT_CONVERSION) - RestoreStartPosition (); + // #95811# Before clearing the modify flag use it as a hint that + // changes were done at SpellCheck + if(IsModified()) + { + if(mpView && mpView->ISA(OutlineView)) + static_cast<OutlineView*>(mpView)->PrepareClose(sal_False); + if(mpDrawDocument && !mpDrawDocument->IsChanged()) + mpDrawDocument->SetChanged(sal_True); } - mpViewShell.reset(); + // #95811# now clear the modify flag to have a specified state of + // Outliner + ClearModifyFlag(); + + // When spell checking then restore the start position. + if (meMode==SPELL || meMode==TEXT_CONVERSION) + RestoreStartPosition (); + + mpWeakViewShell.reset(); mpView = NULL; mpWindow = NULL; } @@ -398,7 +393,8 @@ void Outliner::EndSpelling (void) sal_Bool Outliner::SpellNextDocument (void) { - if (mpViewShell->ISA(OutlineViewShell)) + ::boost::shared_ptr<ViewShell> pViewShell (mpWeakViewShell.lock()); + if (pViewShell->ISA(OutlineViewShell)) { // When doing a spell check in the outline view then there is // only one document. @@ -413,7 +409,7 @@ sal_Bool Outliner::SpellNextDocument (void) Initialize (true); - mpWindow = mpViewShell->GetActiveWindow(); + mpWindow = pViewShell->GetActiveWindow(); OutlinerView* pOutlinerView = mpImpl->GetOutlinerView(); if (pOutlinerView != NULL) pOutlinerView->SetWindow(mpWindow); @@ -485,63 +481,67 @@ bool Outliner::StartSearchAndReplace (const SvxSearchItem* pSearchItem) { sal_Bool bEndOfSearch = sal_True; - if (mbViewShellValid) + mpDrawDocument->GetDocSh()->SetWaitCursor( sal_True ); + if (mbPrepareSpellingPending) + PrepareSpelling(); + ViewShellBase* pBase = PTR_CAST(ViewShellBase,SfxViewShell::Current()); + // Determine whether we have to abort the search. This is necessary + // when the main view shell does not support searching. + bool bAbort = false; + if (pBase != NULL) { - mpDrawDocument->GetDocSh()->SetWaitCursor( sal_True ); - if (mbPrepareSpellingPending) - PrepareSpelling(); - ViewShellBase* pBase = PTR_CAST(ViewShellBase,SfxViewShell::Current()); - // Determine whether we have to abort the search. This is necessary - // when the main view shell does not support searching. - bool bAbort = false; - if (pBase != NULL) - { - ::boost::shared_ptr<ViewShell> pShell (pBase->GetMainViewShell()); - SetViewShell(pShell); - if (pShell.get() == NULL) - bAbort = true; - else - switch (pShell->GetShellType()) - { - case ViewShell::ST_DRAW: - case ViewShell::ST_IMPRESS: - case ViewShell::ST_NOTES: - case ViewShell::ST_HANDOUT: - case ViewShell::ST_OUTLINE: - bAbort = false; - break; - default: - bAbort = true; - break; - } - } + ::boost::shared_ptr<ViewShell> pShell (pBase->GetMainViewShell()); + SetViewShell(pShell); + if (pShell.get() == NULL) + bAbort = true; + else + switch (pShell->GetShellType()) + { + case ViewShell::ST_DRAW: + case ViewShell::ST_IMPRESS: + case ViewShell::ST_NOTES: + case ViewShell::ST_HANDOUT: + case ViewShell::ST_OUTLINE: + bAbort = false; + break; + default: + bAbort = true; + break; + } + } - if ( ! bAbort) - { - meMode = SEARCH; - mpSearchItem = pSearchItem; + ::boost::shared_ptr<ViewShell> pViewShell (mpWeakViewShell.lock()); + if ( ! pViewShell) + { + OSL_ASSERT(pViewShell); + return true; + } + + if ( ! bAbort) + { + meMode = SEARCH; + mpSearchItem = pSearchItem; - mbFoundObject = sal_False; + mbFoundObject = sal_False; - Initialize ( ! mpSearchItem->GetBackward()); + Initialize ( ! mpSearchItem->GetBackward()); - sal_uInt16 nCommand = mpSearchItem->GetCommand(); - if (nCommand == SVX_SEARCHCMD_REPLACE_ALL) - bEndOfSearch = SearchAndReplaceAll (); + sal_uInt16 nCommand = mpSearchItem->GetCommand(); + if (nCommand == SVX_SEARCHCMD_REPLACE_ALL) + bEndOfSearch = SearchAndReplaceAll (); + else + { + RememberStartPosition (); + bEndOfSearch = SearchAndReplaceOnce (); + //#107233# restore start position if nothing was found + if(!mbStringFound) + RestoreStartPosition (); else - { - RememberStartPosition (); - bEndOfSearch = SearchAndReplaceOnce (); - //#107233# restore start position if nothing was found - if(!mbStringFound) - RestoreStartPosition (); - else - mnStartPageIndex = (sal_uInt16)-1; - } + mnStartPageIndex = (sal_uInt16)-1; } - else - mpDrawDocument->GetDocSh()->SetWaitCursor( sal_False ); } + else + mpDrawDocument->GetDocSh()->SetWaitCursor( sal_False ); return bEndOfSearch; } @@ -561,9 +561,16 @@ void Outliner::Initialize (bool bDirectionIsForward) maObjectIterator = ::sd::outliner::OutlinerContainer(this).current(); maCurrentPosition = *maObjectIterator; + ::boost::shared_ptr<ViewShell> pViewShell (mpWeakViewShell.lock()); + if ( ! pViewShell) + { + OSL_ASSERT(pViewShell); + return; + } + // In case we are searching in an outline view then first remove the // current selection and place cursor at its start or end. - if (mpViewShell->ISA(OutlineViewShell)) + if (pViewShell->ISA(OutlineViewShell)) { ESelection aSelection = mpImpl->GetOutlinerView()->GetSelection (); if (mbDirectionIsForward) @@ -618,7 +625,14 @@ bool Outliner::SearchAndReplaceAll (void) // matches. RememberStartPosition (); - if (mpViewShell->ISA(OutlineViewShell)) + ::boost::shared_ptr<ViewShell> pViewShell (mpWeakViewShell.lock()); + if ( ! pViewShell) + { + OSL_ASSERT(pViewShell); + return true; + } + + if (pViewShell->ISA(OutlineViewShell)) { // Put the cursor to the beginning/end of the outliner. mpImpl->GetOutlinerView()->SetSelection (GetSearchStartPosition ()); @@ -626,7 +640,7 @@ bool Outliner::SearchAndReplaceAll (void) // The outliner does all the work for us when we are in this mode. SearchAndReplaceOnce(); } - else if (mpViewShell->ISA(DrawViewShell)) + else if (pViewShell->ISA(DrawViewShell)) { // Go to beginning/end of document. maObjectIterator = ::sd::outliner::OutlinerContainer(this).begin(); @@ -666,13 +680,14 @@ bool Outliner::SearchAndReplaceOnce (void) if( NULL == pOutlinerView || !GetEditEngine().HasView( &pOutlinerView->GetEditView() ) ) return true; - if (mpViewShell != NULL) + ::boost::shared_ptr<ViewShell> pViewShell (mpWeakViewShell.lock()); + if (pViewShell != NULL) { - mpView = mpViewShell->GetView(); - mpWindow = mpViewShell->GetActiveWindow(); + mpView = pViewShell->GetView(); + mpWindow = pViewShell->GetActiveWindow(); pOutlinerView->SetWindow(mpWindow); - if (mpViewShell->ISA(DrawViewShell) ) + if (pViewShell->ISA(DrawViewShell) ) { // When replacing we first check if there is a selection // indicating a match. If there is then replace it. The @@ -717,7 +732,7 @@ bool Outliner::SearchAndReplaceOnce (void) } } } - else if (mpViewShell->ISA(OutlineViewShell)) + else if (pViewShell->ISA(OutlineViewShell)) { mpDrawDocument->GetDocSh()->SetWaitCursor (sal_False); // The following loop is executed more then once only when a @@ -755,8 +770,9 @@ void Outliner::DetectChange (void) { ::sd::outliner::IteratorPosition aPosition (maCurrentPosition); + ::boost::shared_ptr<ViewShell> pViewShell (mpWeakViewShell.lock()); ::boost::shared_ptr<DrawViewShell> pDrawViewShell ( - ::boost::dynamic_pointer_cast<DrawViewShell>(mpViewShell)); + ::boost::dynamic_pointer_cast<DrawViewShell>(pViewShell)); // Detect whether the view has been switched from the outside. if (pDrawViewShell.get() != NULL @@ -852,10 +868,17 @@ bool Outliner::DetectSelectionChange (void) void Outliner::RememberStartPosition (void) { - if (mpViewShell->ISA(DrawViewShell)) + ::boost::shared_ptr<ViewShell> pViewShell (mpWeakViewShell.lock()); + if ( ! pViewShell) + { + OSL_ASSERT(pViewShell); + return; + } + + if (pViewShell->ISA(DrawViewShell)) { ::boost::shared_ptr<DrawViewShell> pDrawViewShell ( - ::boost::dynamic_pointer_cast<DrawViewShell>(mpViewShell)); + ::boost::dynamic_pointer_cast<DrawViewShell>(pViewShell)); if (pDrawViewShell.get() != NULL) { meStartViewMode = pDrawViewShell->GetPageKind(); @@ -880,7 +903,7 @@ void Outliner::RememberStartPosition (void) } } } - else if (mpViewShell->ISA(OutlineViewShell)) + else if (pViewShell->ISA(OutlineViewShell)) { // Remember the current cursor position. OutlinerView* pView = GetView(0); @@ -903,18 +926,17 @@ void Outliner::RestoreStartPosition (void) // start position is not requested. if (mnStartPageIndex == (sal_uInt16)-1 ) bRestore = false; - // Dont't resore when the view shell is not valid. - if (mpViewShell == NULL) - bRestore = false; - if ( ! mbViewShellValid) + // Dont't restore when the view shell is not valid. + ::boost::shared_ptr<ViewShell> pViewShell (mpWeakViewShell.lock()); + if (pViewShell == NULL) bRestore = false; if (bRestore) { - if (mpViewShell->ISA(DrawViewShell)) + if (pViewShell->ISA(DrawViewShell)) { ::boost::shared_ptr<DrawViewShell> pDrawViewShell ( - ::boost::dynamic_pointer_cast<DrawViewShell>(mpViewShell)); + ::boost::dynamic_pointer_cast<DrawViewShell>(pViewShell)); SetViewMode (meStartViewMode); if (pDrawViewShell.get() != NULL) SetPage (meStartEditMode, mnStartPageIndex); @@ -925,7 +947,7 @@ void Outliner::RestoreStartPosition (void) // Turn on the text toolbar as it is done in FuText so that // undo manager setting/restoring in // sd::View::{Beg,End}TextEdit() works on the same view shell. - mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBarShell( + pViewShell->GetViewShellBase().GetToolBarManager()->SetToolBarShell( ToolBarManager::TBG_FUNCTION, RID_DRAW_TEXT_TOOLBOX); @@ -939,7 +961,7 @@ void Outliner::RestoreStartPosition (void) } } } - else if (mpViewShell->ISA(OutlineViewShell)) + else if (pViewShell->ISA(OutlineViewShell)) { // Set cursor to its old position. OutlinerView* pView = GetView(0); @@ -1003,7 +1025,8 @@ void Outliner::ProvideNextTextObject (void) { PutTextIntoOutliner (); - if (mpViewShell != NULL) + ::boost::shared_ptr<ViewShell> pViewShell (mpWeakViewShell.lock()); + if (pViewShell != NULL) switch (meMode) { case SEARCH: @@ -1032,10 +1055,17 @@ void Outliner::ProvideNextTextObject (void) void Outliner::EndOfSearch (void) { + ::boost::shared_ptr<ViewShell> pViewShell (mpWeakViewShell.lock()); + if ( ! pViewShell) + { + OSL_ASSERT(pViewShell); + return; + } + // Before we display a dialog we first jump to where the last valid text // object was found. All page and view mode switching since then was // temporary and should not be visible to the user. - if ( ! mpViewShell->ISA(OutlineViewShell)) + if ( ! pViewShell->ISA(OutlineViewShell)) SetObject (maLastValidPosition); if (mbRestrictSearchToSelection) @@ -1055,7 +1085,7 @@ void Outliner::EndOfSearch (void) mbMatchMayExist = false; // Everything back to beginning (or end?) of the document. maObjectIterator = ::sd::outliner::OutlinerContainer(this).begin(); - if (mpViewShell->ISA(OutlineViewShell)) + if (pViewShell->ISA(OutlineViewShell)) { // Set cursor to first character of the document. OutlinerView* pOutlinerView = mpImpl->GetOutlinerView(); @@ -1244,8 +1274,9 @@ void Outliner::PrepareSearchAndReplace (void) void Outliner::SetViewMode (PageKind ePageKind) { + ::boost::shared_ptr<ViewShell> pViewShell (mpWeakViewShell.lock()); ::boost::shared_ptr<DrawViewShell> pDrawViewShell( - ::boost::dynamic_pointer_cast<DrawViewShell>(mpViewShell)); + ::boost::dynamic_pointer_cast<DrawViewShell>(pViewShell)); if (pDrawViewShell.get()!=NULL && ePageKind != pDrawViewShell->GetPageKind()) { // Restore old edit mode. @@ -1271,7 +1302,7 @@ void Outliner::SetViewMode (PageKind ePageKind) ::sd::outliner::Iterator aIterator (maObjectIterator); bool bMatchMayExist = mbMatchMayExist; - ViewShellBase& rBase = mpViewShell->GetViewShellBase(); + ViewShellBase& rBase = pViewShell->GetViewShellBase(); SetViewShell(::boost::shared_ptr<ViewShell>()); framework::FrameworkHelper::Instance(rBase)->RequestView( sViewURL, @@ -1298,7 +1329,7 @@ void Outliner::SetViewMode (PageKind ePageKind) // Save edit mode so that it can be restored when switching the view // shell again. - pDrawViewShell = ::boost::dynamic_pointer_cast<DrawViewShell>(mpViewShell); + pDrawViewShell = ::boost::dynamic_pointer_cast<DrawViewShell>(pViewShell); OSL_ASSERT(pDrawViewShell.get()!=NULL); if (pDrawViewShell.get() != NULL) mpImpl->meOriginalEditMode = pDrawViewShell->GetEditMode(); @@ -1312,8 +1343,9 @@ void Outliner::SetPage (EditMode eEditMode, sal_uInt16 nPageIndex) { if ( ! mbRestrictSearchToSelection) { + ::boost::shared_ptr<ViewShell> pViewShell (mpWeakViewShell.lock()); ::boost::shared_ptr<DrawViewShell> pDrawViewShell( - ::boost::dynamic_pointer_cast<DrawViewShell>(mpViewShell)); + ::boost::dynamic_pointer_cast<DrawViewShell>(pViewShell)); OSL_ASSERT(pDrawViewShell.get()!=NULL); if (pDrawViewShell.get() != NULL) { @@ -1329,7 +1361,7 @@ void Outliner::SetPage (EditMode eEditMode, sal_uInt16 nPageIndex) void Outliner::EnterEditMode (sal_Bool bGrabFocus) { OutlinerView* pOutlinerView = mpImpl->GetOutlinerView(); - if (mbViewShellValid && pOutlinerView != NULL) + if (pOutlinerView != NULL) { pOutlinerView->SetOutputArea( Rectangle( Point(), Size(1, 1))); SetPaperSize( mpTextObj->GetLogicRect().GetSize() ); @@ -1337,7 +1369,8 @@ void Outliner::EnterEditMode (sal_Bool bGrabFocus) // Make FuText the current function. SfxUInt16Item aItem (SID_TEXTEDIT, 1); - mpViewShell->GetDispatcher()-> + ::boost::shared_ptr<ViewShell> pViewShell (mpWeakViewShell.lock()); + pViewShell->GetDispatcher()-> Execute(SID_TEXTEDIT, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L); @@ -1469,22 +1502,23 @@ SdrObject* Outliner::SetObject ( void Outliner::SetViewShell (const ::boost::shared_ptr<ViewShell>& rpViewShell) { - if (mpViewShell != rpViewShell) + ::boost::shared_ptr<ViewShell> pViewShell (mpWeakViewShell.lock()); + if (pViewShell != rpViewShell) { // Set the new view shell. - mpViewShell = rpViewShell; + mpWeakViewShell = rpViewShell; // When the outline view is not owned by us then we have to clear // that pointer so that the current one for the new view shell will // be used (in ProvideOutlinerView). // if ( ! mbOwnOutlineView) // mpOutlineView = NULL; - if (mpViewShell.get() != NULL) + if (rpViewShell) { - mpView = mpViewShell->GetView(); + mpView = rpViewShell->GetView(); - mpWindow = mpViewShell->GetActiveWindow(); + mpWindow = rpViewShell->GetActiveWindow(); - mpImpl->ProvideOutlinerView(*this, mpViewShell, mpWindow); + mpImpl->ProvideOutlinerView(*this, rpViewShell, mpWindow); OutlinerView* pOutlinerView = mpImpl->GetOutlinerView(); if (pOutlinerView != NULL) pOutlinerView->SetWindow(mpWindow); @@ -1529,7 +1563,8 @@ void Outliner::HandleChangedSelection (void) void Outliner::StartConversion( sal_Int16 nSourceLanguage, sal_Int16 nTargetLanguage, const Font *pTargetFont, sal_Int32 nOptions, sal_Bool bIsInteractive ) { - sal_Bool bMultiDoc = mpViewShell->ISA(DrawViewShell); + ::boost::shared_ptr<ViewShell> pViewShell (mpWeakViewShell.lock()); + sal_Bool bMultiDoc = pViewShell->ISA(DrawViewShell); meMode = TEXT_CONVERSION; mbDirectionIsForward = true; @@ -1592,7 +1627,8 @@ void Outliner::BeginConversion (void) if (pBase != NULL) SetViewShell (pBase->GetMainViewShell()); - if (mpViewShell != NULL) + ::boost::shared_ptr<ViewShell> pViewShell (mpWeakViewShell.lock()); + if (pViewShell) { mbStringFound = sal_False; @@ -1605,7 +1641,7 @@ void Outliner::BeginConversion (void) maSearchStartPosition = ::sd::outliner::Iterator(); RememberStartPosition(); - mpImpl->ProvideOutlinerView(*this, mpViewShell, mpWindow); + mpImpl->ProvideOutlinerView(*this, pViewShell, mpWindow); HandleChangedSelection (); } @@ -1625,7 +1661,8 @@ void Outliner::EndConversion() sal_Bool Outliner::ConvertNextDocument() { - if( mpViewShell && mpViewShell->ISA(OutlineViewShell) ) + ::boost::shared_ptr<ViewShell> pViewShell (mpWeakViewShell.lock()); + if (pViewShell && pViewShell->ISA(OutlineViewShell) ) return false; mpDrawDocument->GetDocSh()->SetWaitCursor( sal_True ); @@ -1635,7 +1672,7 @@ sal_Bool Outliner::ConvertNextDocument() OutlinerView* pOutlinerView = mpImpl->GetOutlinerView(); if (pOutlinerView != NULL) { - mpWindow = mpViewShell->GetActiveWindow(); + mpWindow = pViewShell->GetActiveWindow(); pOutlinerView->SetWindow(mpWindow); } ProvideNextTextObject (); diff --git a/sd/source/ui/view/OutlinerIterator.cxx b/sd/source/ui/view/OutlinerIterator.cxx index d2f1a97ad698..45bea8831b95 100755 --- a/sd/source/ui/view/OutlinerIterator.cxx +++ b/sd/source/ui/view/OutlinerIterator.cxx @@ -200,14 +200,14 @@ Iterator OutlinerContainer::CreateIterator (IteratorLocation aLocation) return CreateSelectionIterator ( mpOutliner->maMarkListCopy, mpOutliner->mpDrawDocument, - mpOutliner->mpViewShell, + mpOutliner->mpWeakViewShell.lock(), mpOutliner->mbDirectionIsForward, aLocation); else // Search in the whole document. return CreateDocumentIterator ( mpOutliner->mpDrawDocument, - mpOutliner->mpViewShell, + mpOutliner->mpWeakViewShell.lock(), mpOutliner->mbDirectionIsForward, aLocation); } |