[Libreoffice-commits] core.git: 3 commits - sc/source

Stephan Bergmann sbergman at redhat.com
Tue Oct 6 01:03:41 PDT 2015


 sc/source/ui/Accessibility/AccessibleDocument.cxx            |   33 +++++------
 sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx |   29 +++------
 sc/source/ui/Accessibility/AccessiblePreviewTable.cxx        |   10 +--
 sc/source/ui/inc/AccessibleDocument.hxx                      |    2 
 sc/source/ui/inc/AccessibleDocumentPagePreview.hxx           |    6 +-
 5 files changed, 36 insertions(+), 44 deletions(-)

New commits:
commit d7f2db4b9ce445afdcabf370497bc66db76efbbc
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Oct 6 10:02:52 2015 +0200

    Hold some objects by rtl::Reference
    
    Change-Id: If42b0fea8417f5e8ce2cb68d79e92e628c77d9e5

diff --git a/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx b/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx
index aa2fa07..c63bf05 100644
--- a/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx
+++ b/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx
@@ -322,15 +322,15 @@ uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleCe
         {
             const bool bRotatedColHeader = rRowInfo.bIsHeader;
             const bool bRotatedRowHeader = rColInfo.bIsHeader;
-            ScAccessiblePreviewHeaderCell* pHeaderCell = new ScAccessiblePreviewHeaderCell(this, mpViewShell, aCellPos,
-                                        bRotatedColHeader, bRotatedRowHeader, nNewIndex);
-            xRet = pHeaderCell;
+            rtl::Reference<ScAccessiblePreviewHeaderCell> pHeaderCell(new ScAccessiblePreviewHeaderCell(this, mpViewShell, aCellPos,
+                                        bRotatedColHeader, bRotatedRowHeader, nNewIndex));
+            xRet = pHeaderCell.get();
             pHeaderCell->Init();
         }
         else
         {
-            ScAccessiblePreviewCell* pCell = new ScAccessiblePreviewCell( this, mpViewShell, aCellPos, nNewIndex );
-            xRet = pCell;
+            rtl::Reference<ScAccessiblePreviewCell> pCell(new ScAccessiblePreviewCell( this, mpViewShell, aCellPos, nNewIndex ));
+            xRet = pCell.get();
             pCell->Init();
         }
     }
commit 6b9b38fed94a8ebb13e5be0c4641de4e28f9345d
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Oct 6 10:02:17 2015 +0200

    Hold ScAccessibleDocumentPagePreview::mpTable by rtl::Reference
    
    Change-Id: I808f406c6c6c46c0a72e6e02503899e78ba7f7e4

diff --git a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
index 8816fd7..9ce4591 100644
--- a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
@@ -1194,7 +1194,6 @@ ScAccessibleDocumentPagePreview::ScAccessibleDocumentPagePreview(
     mpViewShell(pViewShell),
     mpNotesChildren(NULL),
     mpShapeChildren(NULL),
-    mpTable(NULL),
     mpHeader(NULL),
     mpFooter(NULL)
 {
@@ -1217,11 +1216,7 @@ ScAccessibleDocumentPagePreview::~ScAccessibleDocumentPagePreview()
 void SAL_CALL ScAccessibleDocumentPagePreview::disposing()
 {
     SolarMutexGuard aGuard;
-    if (mpTable)
-    {
-        mpTable->release();
-        mpTable = NULL;
-    }
+    mpTable.clear();
     if (mpHeader)
     {
         mpHeader->release();
@@ -1260,10 +1255,10 @@ void ScAccessibleDocumentPagePreview::Notify( SfxBroadcaster& rBC, const SfxHint
         // only notify if child exist, otherwise it is not necessary
         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;
                     aEvent.EventId = AccessibleEventId::CHILD;
                     aEvent.Source = uno::Reference< XAccessibleContext >(this);
@@ -1272,8 +1267,7 @@ void ScAccessibleDocumentPagePreview::Notify( SfxBroadcaster& rBC, const SfxHint
                 }
 
                 mpTable->dispose();
-                mpTable->release();
-                mpTable = NULL;
+                mpTable.clear();
             }
 
             Size aOutputSize;
@@ -1295,11 +1289,10 @@ void ScAccessibleDocumentPagePreview::Notify( SfxBroadcaster& rBC, const SfxHint
                 sal_Int32 nIndex (aCount.nBackShapes + aCount.nHeaders);
 
                 mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex );
-                mpTable->acquire();
                 mpTable->Init();
 
                 {
-                    uno::Reference<XAccessible> xAcc = mpTable;
+                    uno::Reference<XAccessible> xAcc = mpTable.get();
                     AccessibleEventObject aEvent;
                     aEvent.EventId = AccessibleEventId::CHILD;
                     aEvent.Source = uno::Reference< XAccessibleContext >(this);
@@ -1360,17 +1353,16 @@ uno::Reference< XAccessible > SAL_CALL ScAccessibleDocumentPagePreview::getAcces
                 const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
                 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
                     sal_Int32 nIndex (aCount.nBackShapes + aCount.nHeaders);
 
                     mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex );
-                    mpTable->acquire();
                     mpTable->Init();
                 }
-                if (mpTable && VCLRectangle(mpTable->getBounds()).IsInside(VCLPoint(rPoint)))
-                    xAccessible = mpTable;
+                if (mpTable.is() && VCLRectangle(mpTable->getBounds()).IsInside(VCLPoint(rPoint)))
+                    xAccessible = mpTable.get();
             }
             if (!xAccessible.is())
                 xAccessible = GetNotesChildren()->GetAt(rPoint);
@@ -1469,13 +1461,12 @@ uno::Reference<XAccessible> SAL_CALL ScAccessibleDocumentPagePreview::getAccessi
         }
         else if ( nIndex < aCount.nBackShapes + aCount.nHeaders + aCount.nTables )
         {
-            if ( !mpTable )
+            if ( !mpTable.is() )
             {
                 mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex );
-                mpTable->acquire();
                 mpTable->Init();
             }
-            xAccessible = mpTable;
+            xAccessible = mpTable.get();
         }
         else if ( nIndex < aCount.nBackShapes + aCount.nHeaders + aCount.nNoteParagraphs )
         {
diff --git a/sc/source/ui/inc/AccessibleDocumentPagePreview.hxx b/sc/source/ui/inc/AccessibleDocumentPagePreview.hxx
index b83a38c..4c144f3e 100644
--- a/sc/source/ui/inc/AccessibleDocumentPagePreview.hxx
+++ b/sc/source/ui/inc/AccessibleDocumentPagePreview.hxx
@@ -20,6 +20,10 @@
 #ifndef 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"
 
 class ScPreviewShell;
@@ -131,7 +135,7 @@ private:
     ScPreviewShell* mpViewShell;
     ScNotesChildren* mpNotesChildren;
     ScShapeChildren* mpShapeChildren;
-    ScAccessiblePreviewTable* mpTable;
+    rtl::Reference<ScAccessiblePreviewTable> mpTable;
     ScAccessiblePageHeader* mpHeader;
     ScAccessiblePageHeader* mpFooter;
 
commit f9fe7235e1e848913b76726789776ed5d67fb555
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Oct 6 10:01:45 2015 +0200

    Hold ScAccessibleDocument::mpAccessibleSpreadsheet by rtl::Reference
    
    Change-Id: If5b0c7603bb69697a53954b6adfd5ff91d196503

diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx
index 608fd6d..7740c19 100644
--- a/sc/source/ui/Accessibility/AccessibleDocument.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx
@@ -1404,7 +1404,6 @@ ScAccessibleDocument::ScAccessibleDocument(
     : ScAccessibleDocumentBase(rxParent),
     mpViewShell(pViewShell),
     meSplitPos(eSplitPos),
-    mpAccessibleSpreadsheet(NULL),
     mpChildrenShapes(NULL),
     mpTempAccEdit(NULL),
     mbCompleteSheetSelected(false)
@@ -1519,7 +1518,7 @@ void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
         {
             if (mxTempAcc.is() && mpTempAccEdit)
                 mpTempAccEdit->LostFocus();
-            else if (mpAccessibleSpreadsheet)
+            else if (mpAccessibleSpreadsheet.is())
                 mpAccessibleSpreadsheet->LostFocus();
             else
                 CommitFocusLost();
@@ -1549,7 +1548,7 @@ void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
             {
             if (mxTempAcc.is() && mpTempAccEdit)
                 mpTempAccEdit->GotFocus();
-            else if (mpAccessibleSpreadsheet)
+            else if (mpAccessibleSpreadsheet.is())
                 mpAccessibleSpreadsheet->GotFocus();
             else
                 CommitFocusGained();
@@ -1561,7 +1560,7 @@ void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
         const SfxSimpleHint* pSimpleHint = static_cast<const SfxSimpleHint*>(&rHint);
         // only notify if child exist, otherwise it is not necessary
         if ((pSimpleHint->GetId() == SC_HINT_ACC_TABLECHANGED) &&
-            mpAccessibleSpreadsheet)
+            mpAccessibleSpreadsheet.is())
         {
             FreeAccessibleSpreadsheet();
             if (mpChildrenShapes)
@@ -1581,7 +1580,7 @@ void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
             aEvent.Source = uno::Reference< XAccessibleContext >(this);
             CommitChange(aEvent); // all children changed
 
-            if (mpAccessibleSpreadsheet)
+            if (mpAccessibleSpreadsheet.is())
                 mpAccessibleSpreadsheet->FireFirstCellFocus();
         }
         else if (pSimpleHint->GetId() == SC_HINT_ACC_MAKEDRAWLAYER)
@@ -1604,7 +1603,7 @@ void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
 
                     AddChild(xAcc, true);
 
-                    if (mpAccessibleSpreadsheet)
+                    if (mpAccessibleSpreadsheet.is())
                         mpAccessibleSpreadsheet->LostFocus();
                     else
                         CommitFocusLost();
@@ -1622,7 +1621,7 @@ void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
 
                 mpTempAccEdit = NULL;
                 RemoveChild(mxTempAcc, true);
-                if (mpAccessibleSpreadsheet && mpViewShell && mpViewShell->IsActive())
+                if (mpAccessibleSpreadsheet.is() && mpViewShell && mpViewShell->IsActive())
                     mpAccessibleSpreadsheet->GotFocus();
                 else if( mpViewShell && mpViewShell->IsActive())
                     CommitFocusGained();
@@ -1643,12 +1642,12 @@ void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
 
                     CommitChange(aEvent);
 
-                    if (mpAccessibleSpreadsheet)
+                    if (mpAccessibleSpreadsheet.is())
                         mpAccessibleSpreadsheet->BoundingBoxChanged();
-                    if (mpAccessibleSpreadsheet && mpViewShell && mpViewShell->IsActive())
+                    if (mpAccessibleSpreadsheet.is() && mpViewShell && mpViewShell->IsActive())
                         mpAccessibleSpreadsheet->FireFirstCellFocus();
                 }
-                else if (mpAccessibleSpreadsheet)
+                else if (mpAccessibleSpreadsheet.is())
                 {
                     mpAccessibleSpreadsheet->VisAreaChanged();
                 }
@@ -1665,7 +1664,7 @@ void SAL_CALL ScAccessibleDocument::selectionChanged( const lang::EventObject& /
         throw (uno::RuntimeException, std::exception)
 {
     bool bSelectionChanged(false);
-    if (mpAccessibleSpreadsheet)
+    if (mpAccessibleSpreadsheet.is())
     {
         bool bOldSelected(mbCompleteSheetSelected);
         mbCompleteSheetSelected = IsTableSelected();
@@ -2218,23 +2217,21 @@ SCTAB ScAccessibleDocument::getVisibleTable() const
 uno::Reference < XAccessible >
     ScAccessibleDocument::GetAccessibleSpreadsheet()
 {
-    if (!mpAccessibleSpreadsheet && mpViewShell)
+    if (!mpAccessibleSpreadsheet.is() && mpViewShell)
     {
         mpAccessibleSpreadsheet = new ScAccessibleSpreadsheet(this, mpViewShell, getVisibleTable(), meSplitPos);
-        mpAccessibleSpreadsheet->acquire();
         mpAccessibleSpreadsheet->Init();
         mbCompleteSheetSelected = IsTableSelected();
     }
-    return mpAccessibleSpreadsheet;
+    return mpAccessibleSpreadsheet.get();
 }
 
 void ScAccessibleDocument::FreeAccessibleSpreadsheet()
 {
-    if (mpAccessibleSpreadsheet)
+    if (mpAccessibleSpreadsheet.is())
     {
         mpAccessibleSpreadsheet->dispose();
-        mpAccessibleSpreadsheet->release();
-        mpAccessibleSpreadsheet = NULL;
+        mpAccessibleSpreadsheet.clear();
     }
 }
 
@@ -2481,7 +2478,7 @@ com::sun::star::uno::Sequence< com::sun::star::uno::Any > ScAccessibleDocument::
             {
                 return aSeq;
             }
-            else if( mpAccessibleSpreadsheet )
+            else if( mpAccessibleSpreadsheet.is() )
             {
                 uno::Reference < XAccessible > xFindCellAcc = mpAccessibleSpreadsheet->GetActiveCell();
                 // add xFindCellAcc to the return the Sequence
diff --git a/sc/source/ui/inc/AccessibleDocument.hxx b/sc/source/ui/inc/AccessibleDocument.hxx
index 6e45caf..1c1b753 100644
--- a/sc/source/ui/inc/AccessibleDocument.hxx
+++ b/sc/source/ui/inc/AccessibleDocument.hxx
@@ -260,7 +260,7 @@ protected:
 private:
     ScTabViewShell* mpViewShell;
     ScSplitPos      meSplitPos;
-    ScAccessibleSpreadsheet* mpAccessibleSpreadsheet;
+    rtl::Reference<ScAccessibleSpreadsheet> mpAccessibleSpreadsheet;
     ScChildrenShapes* mpChildrenShapes;
     ScAccessibleEditObject* mpTempAccEdit;
     com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible> mxTempAcc;


More information about the Libreoffice-commits mailing list