Hold ScAccessibleDocumentPagePreview::mpTable by rtl::Reference

Change-Id: I808f406c6c6c46c0a72e6e02503899e78ba7f7e4
This commit is contained in:
Stephan Bergmann
2015-10-06 10:02:17 +02:00
parent f9fe7235e1
commit 6b9b38fed9
2 changed files with 15 additions and 20 deletions

View File

@@ -1194,7 +1194,6 @@ ScAccessibleDocumentPagePreview::ScAccessibleDocumentPagePreview(
mpViewShell(pViewShell), mpViewShell(pViewShell),
mpNotesChildren(NULL), mpNotesChildren(NULL),
mpShapeChildren(NULL), mpShapeChildren(NULL),
mpTable(NULL),
mpHeader(NULL), mpHeader(NULL),
mpFooter(NULL) mpFooter(NULL)
{ {
@@ -1217,11 +1216,7 @@ ScAccessibleDocumentPagePreview::~ScAccessibleDocumentPagePreview()
void SAL_CALL ScAccessibleDocumentPagePreview::disposing() void SAL_CALL ScAccessibleDocumentPagePreview::disposing()
{ {
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
if (mpTable) mpTable.clear();
{
mpTable->release();
mpTable = NULL;
}
if (mpHeader) if (mpHeader)
{ {
mpHeader->release(); mpHeader->release();
@@ -1260,10 +1255,10 @@ void ScAccessibleDocumentPagePreview::Notify( SfxBroadcaster& rBC, const SfxHint
// only notify if child exist, otherwise it is not necessary // only notify if child exist, otherwise it is not necessary
if (pSimpleHint->GetId() == SC_HINT_DATACHANGED) if (pSimpleHint->GetId() == SC_HINT_DATACHANGED)
{ {
if (mpTable) // if there is no table there is nothing to notify, because no one recongnizes the change if (mpTable.is()) // if there is no table there is nothing to notify, because no one recongnizes the change
{ {
{ {
uno::Reference<XAccessible> xAcc = mpTable; uno::Reference<XAccessible> xAcc = mpTable.get();
AccessibleEventObject aEvent; AccessibleEventObject aEvent;
aEvent.EventId = AccessibleEventId::CHILD; aEvent.EventId = AccessibleEventId::CHILD;
aEvent.Source = uno::Reference< XAccessibleContext >(this); aEvent.Source = uno::Reference< XAccessibleContext >(this);
@@ -1272,8 +1267,7 @@ void ScAccessibleDocumentPagePreview::Notify( SfxBroadcaster& rBC, const SfxHint
} }
mpTable->dispose(); mpTable->dispose();
mpTable->release(); mpTable.clear();
mpTable = NULL;
} }
Size aOutputSize; Size aOutputSize;
@@ -1295,11 +1289,10 @@ void ScAccessibleDocumentPagePreview::Notify( SfxBroadcaster& rBC, const SfxHint
sal_Int32 nIndex (aCount.nBackShapes + aCount.nHeaders); sal_Int32 nIndex (aCount.nBackShapes + aCount.nHeaders);
mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex ); mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex );
mpTable->acquire();
mpTable->Init(); mpTable->Init();
{ {
uno::Reference<XAccessible> xAcc = mpTable; uno::Reference<XAccessible> xAcc = mpTable.get();
AccessibleEventObject aEvent; AccessibleEventObject aEvent;
aEvent.EventId = AccessibleEventId::CHILD; aEvent.EventId = AccessibleEventId::CHILD;
aEvent.Source = uno::Reference< XAccessibleContext >(this); aEvent.Source = uno::Reference< XAccessibleContext >(this);
@@ -1360,17 +1353,16 @@ uno::Reference< XAccessible > SAL_CALL ScAccessibleDocumentPagePreview::getAcces
const ScPreviewLocationData& rData = mpViewShell->GetLocationData(); const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), GetNotesChildren(), GetShapeChildren() ); ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), GetNotesChildren(), GetShapeChildren() );
if ( !mpTable && (aCount.nTables > 0) ) if ( !mpTable.is() && (aCount.nTables > 0) )
{ {
//! order is background shapes, header, table or notes, footer, foreground shapes, controls //! order is background shapes, header, table or notes, footer, foreground shapes, controls
sal_Int32 nIndex (aCount.nBackShapes + aCount.nHeaders); sal_Int32 nIndex (aCount.nBackShapes + aCount.nHeaders);
mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex ); mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex );
mpTable->acquire();
mpTable->Init(); mpTable->Init();
} }
if (mpTable && VCLRectangle(mpTable->getBounds()).IsInside(VCLPoint(rPoint))) if (mpTable.is() && VCLRectangle(mpTable->getBounds()).IsInside(VCLPoint(rPoint)))
xAccessible = mpTable; xAccessible = mpTable.get();
} }
if (!xAccessible.is()) if (!xAccessible.is())
xAccessible = GetNotesChildren()->GetAt(rPoint); xAccessible = GetNotesChildren()->GetAt(rPoint);
@@ -1469,13 +1461,12 @@ uno::Reference<XAccessible> SAL_CALL ScAccessibleDocumentPagePreview::getAccessi
} }
else if ( nIndex < aCount.nBackShapes + aCount.nHeaders + aCount.nTables ) else if ( nIndex < aCount.nBackShapes + aCount.nHeaders + aCount.nTables )
{ {
if ( !mpTable ) if ( !mpTable.is() )
{ {
mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex ); mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex );
mpTable->acquire();
mpTable->Init(); mpTable->Init();
} }
xAccessible = mpTable; xAccessible = mpTable.get();
} }
else if ( nIndex < aCount.nBackShapes + aCount.nHeaders + aCount.nNoteParagraphs ) else if ( nIndex < aCount.nBackShapes + aCount.nHeaders + aCount.nNoteParagraphs )
{ {

View File

@@ -20,6 +20,10 @@
#ifndef INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLEDOCUMENTPAGEPREVIEW_HXX #ifndef INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLEDOCUMENTPAGEPREVIEW_HXX
#define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLEDOCUMENTPAGEPREVIEW_HXX #define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLEDOCUMENTPAGEPREVIEW_HXX
#include <sal/config.h>
#include <rtl/ref.hxx>
#include "AccessibleDocumentBase.hxx" #include "AccessibleDocumentBase.hxx"
class ScPreviewShell; class ScPreviewShell;
@@ -131,7 +135,7 @@ private:
ScPreviewShell* mpViewShell; ScPreviewShell* mpViewShell;
ScNotesChildren* mpNotesChildren; ScNotesChildren* mpNotesChildren;
ScShapeChildren* mpShapeChildren; ScShapeChildren* mpShapeChildren;
ScAccessiblePreviewTable* mpTable; rtl::Reference<ScAccessiblePreviewTable> mpTable;
ScAccessiblePageHeader* mpHeader; ScAccessiblePageHeader* mpHeader;
ScAccessiblePageHeader* mpFooter; ScAccessiblePageHeader* mpFooter;