From bdfbbb33a491f3ce34375de14ba33436b047e88b Mon Sep 17 00:00:00 2001 From: mst Date: Sat, 17 Sep 2011 22:43:23 +0000 Subject: [PATCH] slidesorter1: #i116014# Outliner holds ViewShell as weak_ptr. * found as LGPLv3-only fix at svn rev 1172131 (http://svn.apache.org/viewvc?view=revision&revision=1172131) --- sd/inc/Outliner.hxx | 17 +- .../slidesorter/view/SlsPageObjectPainter.cxx | 1 - sd/source/ui/view/Outliner.cxx | 383 ++++++++++-------- sd/source/ui/view/OutlinerIterator.cxx | 4 +- 4 files changed, 221 insertions(+), 184 deletions(-) diff --git a/sd/inc/Outliner.hxx b/sd/inc/Outliner.hxx index aa75c763a459..805b1ef1516e 100644 --- a/sd/inc/Outliner.hxx +++ b/sd/inc/Outliner.hxx @@ -36,6 +36,8 @@ #include #include #include +#include +#include class Dialog; class SdPage; @@ -105,7 +107,8 @@ class Window;

*/ class Outliner - : public SdrOutliner + : public SdrOutliner, + public ::boost::noncopyable { public: friend class ::sd::outliner::OutlinerContainer; @@ -194,8 +197,11 @@ private: /// The view which displays the searched objects. ::sd::View* mpView; - /// The view shell containing the view. - ::boost::shared_ptr 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 mpWeakViewShell; /// This window contains the view. ::sd::Window* mpWindow; /// The document on whose objects and pages this class operates. @@ -347,11 +353,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 40fed6929b8f..c376e45b1f4e 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 c06a7c0d13b0..137163ba81e8 100644 --- a/sd/source/ui/view/Outliner.cxx +++ b/sd/source/ui/view/Outliner.cxx @@ -148,7 +148,7 @@ Outliner::Outliner( SdDrawDocument* pDoc, sal_uInt16 nMode ) mpImpl(new Implementation()), meMode(SEARCH), mpView(NULL), - mpViewShell(), + mpWeakViewShell(), mpWindow(NULL), mpDrawDocument(pDoc), mnConversionLanguage(LANGUAGE_NONE), @@ -182,8 +182,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() ); @@ -275,35 +274,33 @@ Outliner::~Outliner (void) */ void Outliner::PrepareSpelling (void) { - if (mbViewShellValid) + mbPrepareSpellingPending = false; + + ViewShellBase* pBase = PTR_CAST(ViewShellBase,SfxViewShell::Current()); + if (pBase != NULL) + SetViewShell (pBase->GetMainViewShell()); + SetRefDevice( SD_MOD()->GetRefDevice( *mpDrawDocument->GetDocSh() ) ); + + ::boost::shared_ptr pViewShell (mpWeakViewShell.lock()); + if (pViewShell) { - mbPrepareSpellingPending = false; + mbStringFound = sal_False; - ViewShellBase* pBase = PTR_CAST(ViewShellBase,SfxViewShell::Current()); - if (pBase != NULL) - SetViewShell (pBase->GetMainViewShell()); - SetRefDevice( SD_MOD()->GetRefDevice( *mpDrawDocument->GetDocSh() ) ); + 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; - if (mpViewShell.get() != NULL) - { - mbStringFound = sal_False; + maObjectIterator = ::sd::outliner::Iterator(); + maSearchStartPosition = ::sd::outliner::Iterator(); + RememberStartPosition(); - 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; + mpImpl->ProvideOutlinerView(*this, pViewShell, mpWindow); - maObjectIterator = ::sd::outliner::Iterator(); - maSearchStartPosition = ::sd::outliner::Iterator(); - RememberStartPosition(); - - mpImpl->ProvideOutlinerView(*this, mpViewShell, mpWindow); - - HandleChangedSelection (); - } - ClearModifyFlag(); + HandleChangedSelection (); } + ClearModifyFlag(); } @@ -328,64 +325,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 pViewShell (mpWeakViewShell.lock()); + ::boost::shared_ptr pOldViewShell (pViewShell); + + ViewShellBase* pBase = PTR_CAST(ViewShellBase,SfxViewShell::Current()); + if (pBase != NULL) + pViewShell = pBase->GetMainViewShell(); + else + pViewShell.reset(); + mpWeakViewShell = pViewShell; + + // When in PrepareSpelling() a new outline view has + // been created then delete it here. + sal_Bool bViewIsDrawViewShell(pViewShell && pViewShell->ISA(DrawViewShell)); + if (bViewIsDrawViewShell) { - // Keep old view shell alive until we release the outliner view. - ::boost::shared_ptr pOldViewShell (mpViewShell); + 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); - ViewShellBase* pBase = PTR_CAST(ViewShellBase,SfxViewShell::Current()); - if (pBase != NULL) - mpViewShell = pBase->GetMainViewShell(); - else - mpViewShell.reset(); - - // When in PrepareSpelling() a new outline view has - // been created then delete it here. - sal_Bool bViewIsDrawViewShell(mpViewShell.get()!=NULL - && mpViewShell->ISA(DrawViewShell)); - if (bViewIsDrawViewShell) + // Remove and, if previously created by us, delete the outline + // view. + OutlinerView* pOutlinerView = mpImpl->GetOutlinerView(); + if (pOutlinerView != NULL) { - 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(); - } - - SetUpdateMode(sal_True); + RemoveView(pOutlinerView); + mpImpl->ReleaseOutlinerView(); } - // 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(mpView)->PrepareClose(sal_False); - if(mpDrawDocument && !mpDrawDocument->IsChanged()) - mpDrawDocument->SetChanged(sal_True); - } - - // 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 (); + SetUpdateMode(sal_True); } - mpViewShell.reset(); + // 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(mpView)->PrepareClose(sal_False); + if(mpDrawDocument && !mpDrawDocument->IsChanged()) + mpDrawDocument->SetChanged(sal_True); + } + + // 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; } @@ -395,7 +390,8 @@ void Outliner::EndSpelling (void) sal_Bool Outliner::SpellNextDocument (void) { - if (mpViewShell->ISA(OutlineViewShell)) + ::boost::shared_ptr pViewShell (mpWeakViewShell.lock()); + if (pViewShell->ISA(OutlineViewShell)) { // When doing a spell check in the outline view then there is // only one document. @@ -410,7 +406,7 @@ sal_Bool Outliner::SpellNextDocument (void) Initialize (true); - mpWindow = mpViewShell->GetActiveWindow(); + mpWindow = pViewShell->GetActiveWindow(); OutlinerView* pOutlinerView = mpImpl->GetOutlinerView(); if (pOutlinerView != NULL) pOutlinerView->SetWindow(mpWindow); @@ -482,64 +478,68 @@ 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 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; - - mbFoundObject = sal_False; - - Initialize ( ! mpSearchItem->GetBackward()); - - sal_uInt16 nCommand = mpSearchItem->GetCommand(); - if (nCommand == SVX_SEARCHCMD_REPLACE_ALL) - bEndOfSearch = SearchAndReplaceAll (); - else - { - RememberStartPosition (); - bEndOfSearch = SearchAndReplaceOnce (); - // restore start position if nothing was found - if(!mbStringFound) - RestoreStartPosition (); - else - mnStartPageIndex = (sal_uInt16)-1; - } - } + ::boost::shared_ptr pShell (pBase->GetMainViewShell()); + SetViewShell(pShell); + if (pShell.get() == NULL) + bAbort = true; else - mpDrawDocument->GetDocSh()->SetWaitCursor( sal_False ); + 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 pViewShell (mpWeakViewShell.lock()); + if ( ! pViewShell) + { + OSL_ASSERT(pViewShell); + return true; + } + + if ( ! bAbort) + { + meMode = SEARCH; + mpSearchItem = pSearchItem; + + mbFoundObject = sal_False; + + Initialize ( ! mpSearchItem->GetBackward()); + + sal_uInt16 nCommand = mpSearchItem->GetCommand(); + if (nCommand == SVX_SEARCHCMD_REPLACE_ALL) + bEndOfSearch = SearchAndReplaceAll (); + else + { + RememberStartPosition (); + bEndOfSearch = SearchAndReplaceOnce (); + // restore start position if nothing was found + if(!mbStringFound) + RestoreStartPosition (); + else + mnStartPageIndex = (sal_uInt16)-1; + } + } + else + mpDrawDocument->GetDocSh()->SetWaitCursor( sal_False ); + return bEndOfSearch; } @@ -558,9 +558,16 @@ void Outliner::Initialize (bool bDirectionIsForward) maObjectIterator = ::sd::outliner::OutlinerContainer(this).current(); maCurrentPosition = *maObjectIterator; + ::boost::shared_ptr 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) @@ -615,7 +622,14 @@ bool Outliner::SearchAndReplaceAll (void) // matches. RememberStartPosition (); - if (mpViewShell->ISA(OutlineViewShell)) + ::boost::shared_ptr 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 ()); @@ -623,7 +637,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(); @@ -663,13 +677,14 @@ bool Outliner::SearchAndReplaceOnce (void) if( NULL == pOutlinerView || !GetEditEngine().HasView( &pOutlinerView->GetEditView() ) ) return true; - if (mpViewShell != NULL) + ::boost::shared_ptr 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 @@ -714,7 +729,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 @@ -752,8 +767,9 @@ void Outliner::DetectChange (void) { ::sd::outliner::IteratorPosition aPosition (maCurrentPosition); + ::boost::shared_ptr pViewShell (mpWeakViewShell.lock()); ::boost::shared_ptr pDrawViewShell ( - ::boost::dynamic_pointer_cast(mpViewShell)); + ::boost::dynamic_pointer_cast(pViewShell)); // Detect whether the view has been switched from the outside. if (pDrawViewShell.get() != NULL @@ -849,10 +865,17 @@ bool Outliner::DetectSelectionChange (void) void Outliner::RememberStartPosition (void) { - if (mpViewShell->ISA(DrawViewShell)) + ::boost::shared_ptr pViewShell (mpWeakViewShell.lock()); + if ( ! pViewShell) + { + OSL_ASSERT(pViewShell); + return; + } + + if (pViewShell->ISA(DrawViewShell)) { ::boost::shared_ptr pDrawViewShell ( - ::boost::dynamic_pointer_cast(mpViewShell)); + ::boost::dynamic_pointer_cast(pViewShell)); if (pDrawViewShell.get() != NULL) { meStartViewMode = pDrawViewShell->GetPageKind(); @@ -877,7 +900,7 @@ void Outliner::RememberStartPosition (void) } } } - else if (mpViewShell->ISA(OutlineViewShell)) + else if (pViewShell->ISA(OutlineViewShell)) { // Remember the current cursor position. OutlinerView* pView = GetView(0); @@ -900,18 +923,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 pViewShell (mpWeakViewShell.lock()); + if (pViewShell == NULL) bRestore = false; if (bRestore) { - if (mpViewShell->ISA(DrawViewShell)) + if (pViewShell->ISA(DrawViewShell)) { ::boost::shared_ptr pDrawViewShell ( - ::boost::dynamic_pointer_cast(mpViewShell)); + ::boost::dynamic_pointer_cast(pViewShell)); SetViewMode (meStartViewMode); if (pDrawViewShell.get() != NULL) SetPage (meStartEditMode, mnStartPageIndex); @@ -922,7 +944,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); @@ -936,7 +958,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); @@ -1000,7 +1022,8 @@ void Outliner::ProvideNextTextObject (void) { PutTextIntoOutliner (); - if (mpViewShell != NULL) + ::boost::shared_ptr pViewShell (mpWeakViewShell.lock()); + if (pViewShell != NULL) switch (meMode) { case SEARCH: @@ -1029,10 +1052,17 @@ void Outliner::ProvideNextTextObject (void) void Outliner::EndOfSearch (void) { + ::boost::shared_ptr 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) @@ -1052,7 +1082,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(); @@ -1241,8 +1271,9 @@ void Outliner::PrepareSearchAndReplace (void) void Outliner::SetViewMode (PageKind ePageKind) { + ::boost::shared_ptr pViewShell (mpWeakViewShell.lock()); ::boost::shared_ptr pDrawViewShell( - ::boost::dynamic_pointer_cast(mpViewShell)); + ::boost::dynamic_pointer_cast(pViewShell)); if (pDrawViewShell.get()!=NULL && ePageKind != pDrawViewShell->GetPageKind()) { // Restore old edit mode. @@ -1268,7 +1299,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()); framework::FrameworkHelper::Instance(rBase)->RequestView( sViewURL, @@ -1295,7 +1326,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(mpViewShell); + pDrawViewShell = ::boost::dynamic_pointer_cast(pViewShell); OSL_ASSERT(pDrawViewShell.get()!=NULL); if (pDrawViewShell.get() != NULL) mpImpl->meOriginalEditMode = pDrawViewShell->GetEditMode(); @@ -1309,8 +1340,9 @@ void Outliner::SetPage (EditMode eEditMode, sal_uInt16 nPageIndex) { if ( ! mbRestrictSearchToSelection) { + ::boost::shared_ptr pViewShell (mpWeakViewShell.lock()); ::boost::shared_ptr pDrawViewShell( - ::boost::dynamic_pointer_cast(mpViewShell)); + ::boost::dynamic_pointer_cast(pViewShell)); OSL_ASSERT(pDrawViewShell.get()!=NULL); if (pDrawViewShell.get() != NULL) { @@ -1326,7 +1358,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() ); @@ -1334,7 +1366,8 @@ void Outliner::EnterEditMode (sal_Bool bGrabFocus) // Make FuText the current function. SfxUInt16Item aItem (SID_TEXTEDIT, 1); - mpViewShell->GetDispatcher()-> + ::boost::shared_ptr pViewShell (mpWeakViewShell.lock()); + pViewShell->GetDispatcher()-> Execute(SID_TEXTEDIT, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L); @@ -1466,20 +1499,21 @@ SdrObject* Outliner::SetObject ( void Outliner::SetViewShell (const ::boost::shared_ptr& rpViewShell) { - if (mpViewShell != rpViewShell) + ::boost::shared_ptr 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 (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); @@ -1524,7 +1558,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 pViewShell (mpWeakViewShell.lock()); + sal_Bool bMultiDoc = pViewShell->ISA(DrawViewShell); meMode = TEXT_CONVERSION; mbDirectionIsForward = true; @@ -1586,7 +1621,8 @@ void Outliner::BeginConversion (void) if (pBase != NULL) SetViewShell (pBase->GetMainViewShell()); - if (mpViewShell != NULL) + ::boost::shared_ptr pViewShell (mpWeakViewShell.lock()); + if (pViewShell) { mbStringFound = sal_False; @@ -1599,7 +1635,7 @@ void Outliner::BeginConversion (void) maSearchStartPosition = ::sd::outliner::Iterator(); RememberStartPosition(); - mpImpl->ProvideOutlinerView(*this, mpViewShell, mpWindow); + mpImpl->ProvideOutlinerView(*this, pViewShell, mpWindow); HandleChangedSelection (); } @@ -1619,7 +1655,8 @@ void Outliner::EndConversion() sal_Bool Outliner::ConvertNextDocument() { - if( mpViewShell && mpViewShell->ISA(OutlineViewShell) ) + ::boost::shared_ptr pViewShell (mpWeakViewShell.lock()); + if (pViewShell && pViewShell->ISA(OutlineViewShell) ) return false; mpDrawDocument->GetDocSh()->SetWaitCursor( sal_True ); @@ -1629,7 +1666,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 1e24dd373d49..be50a50ac3c4 100644 --- a/sd/source/ui/view/OutlinerIterator.cxx +++ b/sd/source/ui/view/OutlinerIterator.cxx @@ -199,14 +199,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); }