diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-12-12 18:10:56 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-12-12 19:19:31 +0100 |
commit | 639fc4988f43eaf7866f17095293cbf1de268ddb (patch) | |
tree | b7305a24660809dfd0ecfbb886750b6665bc42e7 | |
parent | f7b675475b88d35728ddc1b38eaf26ea5600a30e (diff) |
Only call ScAccessibleCell::Init once on freshly created cells
Change-Id: I64542af7585cea9d361a99f83e110e1e8135bf2d
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleCell.cxx | 14 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx | 83 | ||||
-rw-r--r-- | sc/source/ui/inc/AccessibleCell.hxx | 12 | ||||
-rw-r--r-- | sc/source/ui/inc/AccessibleSpreadsheet.hxx | 11 |
4 files changed, 57 insertions, 63 deletions
diff --git a/sc/source/ui/Accessibility/AccessibleCell.cxx b/sc/source/ui/Accessibility/AccessibleCell.cxx index 74c9d7200cd4..742496ca569d 100644 --- a/sc/source/ui/Accessibility/AccessibleCell.cxx +++ b/sc/source/ui/Accessibility/AccessibleCell.cxx @@ -50,7 +50,19 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; -//===== internal ============================================================ +rtl::Reference<ScAccessibleCell> ScAccessibleCell::create( + const uno::Reference<XAccessible>& rxParent, + ScTabViewShell* pViewShell, + ScAddress& rCellAddress, + sal_Int32 nIndex, + ScSplitPos eSplitPos, + ScAccessibleDocument* pAccDoc) +{ + rtl::Reference<ScAccessibleCell> x(new ScAccessibleCell( + rxParent, pViewShell, rCellAddress, nIndex, eSplitPos, pAccDoc)); + x->Init(); + return x; +} ScAccessibleCell::ScAccessibleCell( const uno::Reference<XAccessible>& rxParent, diff --git a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx index 6aa263b35d4a..40d2d3985d7a 100644 --- a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx +++ b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx @@ -258,7 +258,6 @@ ScAccessibleSpreadsheet::ScAccessibleSpreadsheet( mbIsSpreadsheet( sal_True ), m_bFormulaMode(sal_False), m_bFormulaLastMode(sal_False), - m_pAccFormulaCell(NULL), m_nMinX(0),m_nMaxX(0),m_nMinY(0),m_nMaxY(0) { ConstructScAccessibleSpreadsheet( pAccDoc, pViewShell, nTab, eSplitPos ); @@ -289,7 +288,7 @@ void ScAccessibleSpreadsheet::ConstructScAccessibleSpreadsheet( mpMarkedRanges = 0; mpSortedMarkedCells = 0; mpAccDoc = pAccDoc; - mpAccCell = 0; + mpAccCell.clear(); meSplitPos = eSplitPos; mnTab = nTab; mbHasSelection = false; @@ -306,8 +305,6 @@ void ScAccessibleSpreadsheet::ConstructScAccessibleSpreadsheet( mbHasSelection = rMarkData.GetTableSelect(maActiveCell.Tab()) && (rMarkData.IsMarked() || rMarkData.IsMultiMarked()); mpAccCell = GetAccessibleCellAt(maActiveCell.Row(), maActiveCell.Col()); - mpAccCell->acquire(); - mpAccCell->Init(); ScDocument* pScDoc= GetDocument(mpViewShell); if (pScDoc) { @@ -324,11 +321,7 @@ void SAL_CALL ScAccessibleSpreadsheet::disposing() mpViewShell->RemoveAccessibilityObject(*this); mpViewShell = NULL; } - if (mpAccCell) - { - mpAccCell->release(); - mpAccCell = NULL; - } + mpAccCell.clear(); ScAccessibleTableBase::disposing(); } @@ -359,8 +352,7 @@ void ScAccessibleSpreadsheet::LostFocus() AccessibleEventObject aEvent; aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; aEvent.Source = uno::Reference< XAccessibleContext >(this); - uno::Reference< XAccessible > xOld = mpAccCell; - aEvent.OldValue <<= xOld; + aEvent.OldValue <<= uno::Reference<XAccessible>(mpAccCell.get()); CommitChange(aEvent); @@ -375,7 +367,7 @@ void ScAccessibleSpreadsheet::GotFocus() uno::Reference< XAccessible > xNew; if (IsFormulaMode()) { - if (!m_pAccFormulaCell || !m_bFormulaLastMode) + if (!m_pAccFormulaCell.is() || !m_bFormulaLastMode) { ScAddress aFormulaAddr; if(!GetFormulaCurrentFocusCell(aFormulaAddr)) @@ -383,19 +375,14 @@ void ScAccessibleSpreadsheet::GotFocus() return; } m_pAccFormulaCell = GetAccessibleCellAt(aFormulaAddr.Row(),aFormulaAddr.Col()); - - m_pAccFormulaCell->acquire(); - m_pAccFormulaCell->Init(); - - } - xNew = m_pAccFormulaCell; + xNew = m_pAccFormulaCell.get(); } else { if(mpAccCell->GetCellAddress() == maActiveCell) { - xNew = mpAccCell; + xNew = mpAccCell.get(); } else { @@ -450,11 +437,7 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint {//Last Notify Mode Is Formula Mode. m_vecFormulaLastMyAddr.clear(); RemoveFormulaSelection(sal_True); - if(m_pAccFormulaCell) - { - m_pAccFormulaCell->release(); - m_pAccFormulaCell =NULL; - } + m_pAccFormulaCell.clear(); //Remove All Selection } m_bFormulaLastMode = m_bFormulaMode; @@ -547,13 +530,12 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint uno::Reference< XAccessible > xChild ; if (bNewPosCellFocus) { - xChild = mpAccCell; + xChild = mpAccCell.get(); } else { mpAccCell = GetAccessibleCellAt(aNewCell.Row(),aNewCell.Col()); - xChild = mpAccCell; - mpAccCell->Init(); + xChild = mpAccCell.get(); maActiveCell = aNewCell; aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS; @@ -728,8 +710,7 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint AccessibleEventObject aEvent; aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; aEvent.Source = uno::Reference< XAccessibleContext >(this); - uno::Reference< XAccessible > xNew = mpAccCell; - aEvent.NewValue <<= xNew; + aEvent.NewValue <<= uno::Reference<XAccessible>(mpAccCell.get()); CommitChange(aEvent); } @@ -772,15 +753,10 @@ void ScAccessibleSpreadsheet::CommitFocusCell(const ScAddress &aNewCell) AccessibleEventObject aEvent; aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; aEvent.Source = uno::Reference< XAccessible >(this); - uno::Reference< XAccessible > xOld = mpAccCell; - mpAccCell->release(); - mpAccCell=NULL; - aEvent.OldValue <<= xOld; + aEvent.OldValue <<= uno::Reference<XAccessible>(mpAccCell.get()); + mpAccCell.clear(); mpAccCell = GetAccessibleCellAt(aNewCell.Row(), aNewCell.Col()); - mpAccCell->acquire(); - mpAccCell->Init(); - uno::Reference< XAccessible > xNew = mpAccCell; - aEvent.NewValue <<= xNew; + aEvent.NewValue <<= uno::Reference<XAccessible>(mpAccCell.get()); maActiveCell = aNewCell; ScDocument* pScDoc= GetDocument(mpViewShell); if (pScDoc) @@ -941,32 +917,29 @@ sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleColumnSelected( sal_Int32 return bResult; } -ScAccessibleCell* ScAccessibleSpreadsheet::GetAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn) +rtl::Reference<ScAccessibleCell> ScAccessibleSpreadsheet::GetAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn) { - ScAccessibleCell* pAccessibleCell = NULL; if (IsFormulaMode()) { ScAddress aCellAddress(static_cast<SCCOL>(nColumn), nRow, mpViewShell->GetViewData()->GetTabNo()); - if ((aCellAddress == m_aFormulaActiveCell) && m_pAccFormulaCell) + if ((aCellAddress == m_aFormulaActiveCell) && m_pAccFormulaCell.is()) { - pAccessibleCell = m_pAccFormulaCell; + return m_pAccFormulaCell; } else - pAccessibleCell = new ScAccessibleCell(this, mpViewShell, aCellAddress, GetAccessibleIndexFormula(nRow, nColumn), meSplitPos, mpAccDoc); + return ScAccessibleCell::create(this, mpViewShell, aCellAddress, GetAccessibleIndexFormula(nRow, nColumn), meSplitPos, mpAccDoc); } else { ScAddress aCellAddress(static_cast<SCCOL>(maRange.aStart.Col() + nColumn), static_cast<SCROW>(maRange.aStart.Row() + nRow), maRange.aStart.Tab()); - if ((aCellAddress == maActiveCell) && mpAccCell) + if ((aCellAddress == maActiveCell) && mpAccCell.is()) { - pAccessibleCell = mpAccCell; + return mpAccCell; } else - pAccessibleCell = new ScAccessibleCell(this, mpViewShell, aCellAddress, getAccessibleIndex(nRow, nColumn), meSplitPos, mpAccDoc); + return ScAccessibleCell::create(this, mpViewShell, aCellAddress, getAccessibleIndex(nRow, nColumn), meSplitPos, mpAccDoc); } - - return pAccessibleCell; } uno::Reference< XAccessible > SAL_CALL ScAccessibleSpreadsheet::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) @@ -982,11 +955,8 @@ uno::Reference< XAccessible > SAL_CALL ScAccessibleSpreadsheet::getAccessibleCel nColumn < 0) throw lang::IndexOutOfBoundsException(); } - uno::Reference<XAccessible> xAccessible; - ScAccessibleCell* pAccessibleCell = GetAccessibleCellAt(nRow, nColumn); - xAccessible = pAccessibleCell; - pAccessibleCell->Init(); - return xAccessible; + rtl::Reference<ScAccessibleCell> pAccessibleCell = GetAccessibleCellAt(nRow, nColumn); + return pAccessibleCell.get(); } sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) @@ -1609,12 +1579,9 @@ void ScAccessibleSpreadsheet::NotifyRefMode() aEvent.Source = uno::Reference< XAccessible >(this); aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; aEvent.Source = uno::Reference< XAccessible >(this); - uno::Reference< XAccessible > xOld = m_pAccFormulaCell; - aEvent.OldValue <<= xOld; + aEvent.OldValue <<= uno::Reference<XAccessible>(m_pAccFormulaCell.get()); m_pAccFormulaCell = GetAccessibleCellAt(aFormulaAddr.Row(), aFormulaAddr.Col()); - m_pAccFormulaCell->acquire(); - m_pAccFormulaCell->Init(); - uno::Reference< XAccessible > xNew = m_pAccFormulaCell; + uno::Reference< XAccessible > xNew = m_pAccFormulaCell.get(); aEvent.NewValue <<= xNew; CommitChange(aEvent); if (nRefStartX == nRefEndX && nRefStartY == nRefEndY) @@ -1659,7 +1626,7 @@ void ScAccessibleSpreadsheet::NotifyRefMode() uno::Reference< XAccessible > xChild; if (*viAddr == aFormulaAddr) { - xChild = m_pAccFormulaCell; + xChild = m_pAccFormulaCell.get(); } else { diff --git a/sc/source/ui/inc/AccessibleCell.hxx b/sc/source/ui/inc/AccessibleCell.hxx index bd8185d2c725..dd53521c650b 100644 --- a/sc/source/ui/inc/AccessibleCell.hxx +++ b/sc/source/ui/inc/AccessibleCell.hxx @@ -26,6 +26,7 @@ #include "viewdata.hxx" #include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp> #include <com/sun/star/accessibility/XAccessibleRelationSet.hpp> +#include <rtl/ref.hxx> #include <unotools/accessiblerelationsethelper.hxx> #include <editeng/AccessibleStaticTextBase.hxx> #include <comphelper/uno3.hxx> @@ -46,7 +47,16 @@ class ScAccessibleCell public ScAccessibleCellAttributeImpl { public: - //===== internal ======================================================== + static rtl::Reference<ScAccessibleCell> create( + const ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible>& rxParent, + ScTabViewShell* pViewShell, + ScAddress& rCellAddress, + sal_Int32 nIndex, + ScSplitPos eSplitPos, + ScAccessibleDocument* pAccDoc); + +private: ScAccessibleCell( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible>& rxParent, diff --git a/sc/source/ui/inc/AccessibleSpreadsheet.hxx b/sc/source/ui/inc/AccessibleSpreadsheet.hxx index 56749beda960..b2354aacec7a 100644 --- a/sc/source/ui/inc/AccessibleSpreadsheet.hxx +++ b/sc/source/ui/inc/AccessibleSpreadsheet.hxx @@ -21,6 +21,10 @@ #ifndef _SC_ACCESSIBLESPREADSHEET_HXX #define _SC_ACCESSIBLESPREADSHEET_HXX +#include <sal/config.h> + +#include <rtl/ref.hxx> + #include "AccessibleTableBase.hxx" #include "viewdata.hxx" @@ -92,6 +96,7 @@ public: void BoundingBoxChanged(); void VisAreaChanged(); +private: ///===== SfxListener ===================================================== virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); @@ -135,7 +140,7 @@ public: throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException); - ScAccessibleCell* GetAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn); + rtl::Reference<ScAccessibleCell> GetAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn); /// Returns a boolean value indicating whether the accessible at a specified row and column is selected. virtual sal_Bool SAL_CALL @@ -258,7 +263,7 @@ private: ScRangeList* mpMarkedRanges; std::vector<ScMyAddress>* mpSortedMarkedCells; ScAccessibleDocument* mpAccDoc; - ScAccessibleCell* mpAccCell; + rtl::Reference<ScAccessibleCell> mpAccCell; Rectangle maVisCells; ScSplitPos meSplitPos; ScAddress maActiveCell; @@ -300,7 +305,7 @@ private: ScAddress m_aFormulaActiveCell; MAP_ADDR_XACC m_mapFormulaSelectionSend; VEC_MYADDR m_vecFormulaLastMyAddr; - ScAccessibleCell* m_pAccFormulaCell; + rtl::Reference<ScAccessibleCell> m_pAccFormulaCell; sal_uInt16 m_nMinX; sal_uInt16 m_nMaxX; sal_Int32 m_nMinY; |