Kaydet (Commit) 639fc498 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Only call ScAccessibleCell::Init once on freshly created cells

Change-Id: I64542af7585cea9d361a99f83e110e1e8135bf2d
üst f7b67547
...@@ -50,7 +50,19 @@ ...@@ -50,7 +50,19 @@
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace ::com::sun::star::accessibility; 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( ScAccessibleCell::ScAccessibleCell(
const uno::Reference<XAccessible>& rxParent, const uno::Reference<XAccessible>& rxParent,
......
...@@ -258,7 +258,6 @@ ScAccessibleSpreadsheet::ScAccessibleSpreadsheet( ...@@ -258,7 +258,6 @@ ScAccessibleSpreadsheet::ScAccessibleSpreadsheet(
mbIsSpreadsheet( sal_True ), mbIsSpreadsheet( sal_True ),
m_bFormulaMode(sal_False), m_bFormulaMode(sal_False),
m_bFormulaLastMode(sal_False), m_bFormulaLastMode(sal_False),
m_pAccFormulaCell(NULL),
m_nMinX(0),m_nMaxX(0),m_nMinY(0),m_nMaxY(0) m_nMinX(0),m_nMaxX(0),m_nMinY(0),m_nMaxY(0)
{ {
ConstructScAccessibleSpreadsheet( pAccDoc, pViewShell, nTab, eSplitPos ); ConstructScAccessibleSpreadsheet( pAccDoc, pViewShell, nTab, eSplitPos );
...@@ -289,7 +288,7 @@ void ScAccessibleSpreadsheet::ConstructScAccessibleSpreadsheet( ...@@ -289,7 +288,7 @@ void ScAccessibleSpreadsheet::ConstructScAccessibleSpreadsheet(
mpMarkedRanges = 0; mpMarkedRanges = 0;
mpSortedMarkedCells = 0; mpSortedMarkedCells = 0;
mpAccDoc = pAccDoc; mpAccDoc = pAccDoc;
mpAccCell = 0; mpAccCell.clear();
meSplitPos = eSplitPos; meSplitPos = eSplitPos;
mnTab = nTab; mnTab = nTab;
mbHasSelection = false; mbHasSelection = false;
...@@ -306,8 +305,6 @@ void ScAccessibleSpreadsheet::ConstructScAccessibleSpreadsheet( ...@@ -306,8 +305,6 @@ void ScAccessibleSpreadsheet::ConstructScAccessibleSpreadsheet(
mbHasSelection = rMarkData.GetTableSelect(maActiveCell.Tab()) && mbHasSelection = rMarkData.GetTableSelect(maActiveCell.Tab()) &&
(rMarkData.IsMarked() || rMarkData.IsMultiMarked()); (rMarkData.IsMarked() || rMarkData.IsMultiMarked());
mpAccCell = GetAccessibleCellAt(maActiveCell.Row(), maActiveCell.Col()); mpAccCell = GetAccessibleCellAt(maActiveCell.Row(), maActiveCell.Col());
mpAccCell->acquire();
mpAccCell->Init();
ScDocument* pScDoc= GetDocument(mpViewShell); ScDocument* pScDoc= GetDocument(mpViewShell);
if (pScDoc) if (pScDoc)
{ {
...@@ -324,11 +321,7 @@ void SAL_CALL ScAccessibleSpreadsheet::disposing() ...@@ -324,11 +321,7 @@ void SAL_CALL ScAccessibleSpreadsheet::disposing()
mpViewShell->RemoveAccessibilityObject(*this); mpViewShell->RemoveAccessibilityObject(*this);
mpViewShell = NULL; mpViewShell = NULL;
} }
if (mpAccCell) mpAccCell.clear();
{
mpAccCell->release();
mpAccCell = NULL;
}
ScAccessibleTableBase::disposing(); ScAccessibleTableBase::disposing();
} }
...@@ -359,8 +352,7 @@ void ScAccessibleSpreadsheet::LostFocus() ...@@ -359,8 +352,7 @@ void ScAccessibleSpreadsheet::LostFocus()
AccessibleEventObject aEvent; AccessibleEventObject aEvent;
aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED;
aEvent.Source = uno::Reference< XAccessibleContext >(this); aEvent.Source = uno::Reference< XAccessibleContext >(this);
uno::Reference< XAccessible > xOld = mpAccCell; aEvent.OldValue <<= uno::Reference<XAccessible>(mpAccCell.get());
aEvent.OldValue <<= xOld;
CommitChange(aEvent); CommitChange(aEvent);
...@@ -375,7 +367,7 @@ void ScAccessibleSpreadsheet::GotFocus() ...@@ -375,7 +367,7 @@ void ScAccessibleSpreadsheet::GotFocus()
uno::Reference< XAccessible > xNew; uno::Reference< XAccessible > xNew;
if (IsFormulaMode()) if (IsFormulaMode())
{ {
if (!m_pAccFormulaCell || !m_bFormulaLastMode) if (!m_pAccFormulaCell.is() || !m_bFormulaLastMode)
{ {
ScAddress aFormulaAddr; ScAddress aFormulaAddr;
if(!GetFormulaCurrentFocusCell(aFormulaAddr)) if(!GetFormulaCurrentFocusCell(aFormulaAddr))
...@@ -383,19 +375,14 @@ void ScAccessibleSpreadsheet::GotFocus() ...@@ -383,19 +375,14 @@ void ScAccessibleSpreadsheet::GotFocus()
return; return;
} }
m_pAccFormulaCell = GetAccessibleCellAt(aFormulaAddr.Row(),aFormulaAddr.Col()); m_pAccFormulaCell = GetAccessibleCellAt(aFormulaAddr.Row(),aFormulaAddr.Col());
m_pAccFormulaCell->acquire();
m_pAccFormulaCell->Init();
} }
xNew = m_pAccFormulaCell; xNew = m_pAccFormulaCell.get();
} }
else else
{ {
if(mpAccCell->GetCellAddress() == maActiveCell) if(mpAccCell->GetCellAddress() == maActiveCell)
{ {
xNew = mpAccCell; xNew = mpAccCell.get();
} }
else else
{ {
...@@ -450,11 +437,7 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ...@@ -450,11 +437,7 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint
{//Last Notify Mode Is Formula Mode. {//Last Notify Mode Is Formula Mode.
m_vecFormulaLastMyAddr.clear(); m_vecFormulaLastMyAddr.clear();
RemoveFormulaSelection(sal_True); RemoveFormulaSelection(sal_True);
if(m_pAccFormulaCell) m_pAccFormulaCell.clear();
{
m_pAccFormulaCell->release();
m_pAccFormulaCell =NULL;
}
//Remove All Selection //Remove All Selection
} }
m_bFormulaLastMode = m_bFormulaMode; m_bFormulaLastMode = m_bFormulaMode;
...@@ -547,13 +530,12 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ...@@ -547,13 +530,12 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint
uno::Reference< XAccessible > xChild ; uno::Reference< XAccessible > xChild ;
if (bNewPosCellFocus) if (bNewPosCellFocus)
{ {
xChild = mpAccCell; xChild = mpAccCell.get();
} }
else else
{ {
mpAccCell = GetAccessibleCellAt(aNewCell.Row(),aNewCell.Col()); mpAccCell = GetAccessibleCellAt(aNewCell.Row(),aNewCell.Col());
xChild = mpAccCell; xChild = mpAccCell.get();
mpAccCell->Init();
maActiveCell = aNewCell; maActiveCell = aNewCell;
aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS; aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS;
...@@ -728,8 +710,7 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ...@@ -728,8 +710,7 @@ void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint
AccessibleEventObject aEvent; AccessibleEventObject aEvent;
aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED;
aEvent.Source = uno::Reference< XAccessibleContext >(this); aEvent.Source = uno::Reference< XAccessibleContext >(this);
uno::Reference< XAccessible > xNew = mpAccCell; aEvent.NewValue <<= uno::Reference<XAccessible>(mpAccCell.get());
aEvent.NewValue <<= xNew;
CommitChange(aEvent); CommitChange(aEvent);
} }
...@@ -772,15 +753,10 @@ void ScAccessibleSpreadsheet::CommitFocusCell(const ScAddress &aNewCell) ...@@ -772,15 +753,10 @@ void ScAccessibleSpreadsheet::CommitFocusCell(const ScAddress &aNewCell)
AccessibleEventObject aEvent; AccessibleEventObject aEvent;
aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED;
aEvent.Source = uno::Reference< XAccessible >(this); aEvent.Source = uno::Reference< XAccessible >(this);
uno::Reference< XAccessible > xOld = mpAccCell; aEvent.OldValue <<= uno::Reference<XAccessible>(mpAccCell.get());
mpAccCell->release(); mpAccCell.clear();
mpAccCell=NULL;
aEvent.OldValue <<= xOld;
mpAccCell = GetAccessibleCellAt(aNewCell.Row(), aNewCell.Col()); mpAccCell = GetAccessibleCellAt(aNewCell.Row(), aNewCell.Col());
mpAccCell->acquire(); aEvent.NewValue <<= uno::Reference<XAccessible>(mpAccCell.get());
mpAccCell->Init();
uno::Reference< XAccessible > xNew = mpAccCell;
aEvent.NewValue <<= xNew;
maActiveCell = aNewCell; maActiveCell = aNewCell;
ScDocument* pScDoc= GetDocument(mpViewShell); ScDocument* pScDoc= GetDocument(mpViewShell);
if (pScDoc) if (pScDoc)
...@@ -941,32 +917,29 @@ sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleColumnSelected( sal_Int32 ...@@ -941,32 +917,29 @@ sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleColumnSelected( sal_Int32
return bResult; 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()) if (IsFormulaMode())
{ {
ScAddress aCellAddress(static_cast<SCCOL>(nColumn), nRow, mpViewShell->GetViewData()->GetTabNo()); 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 else
pAccessibleCell = new ScAccessibleCell(this, mpViewShell, aCellAddress, GetAccessibleIndexFormula(nRow, nColumn), meSplitPos, mpAccDoc); return ScAccessibleCell::create(this, mpViewShell, aCellAddress, GetAccessibleIndexFormula(nRow, nColumn), meSplitPos, mpAccDoc);
} }
else else
{ {
ScAddress aCellAddress(static_cast<SCCOL>(maRange.aStart.Col() + nColumn), ScAddress aCellAddress(static_cast<SCCOL>(maRange.aStart.Col() + nColumn),
static_cast<SCROW>(maRange.aStart.Row() + nRow), maRange.aStart.Tab()); static_cast<SCROW>(maRange.aStart.Row() + nRow), maRange.aStart.Tab());
if ((aCellAddress == maActiveCell) && mpAccCell) if ((aCellAddress == maActiveCell) && mpAccCell.is())
{ {
pAccessibleCell = mpAccCell; return mpAccCell;
} }
else 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 ) uno::Reference< XAccessible > SAL_CALL ScAccessibleSpreadsheet::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
...@@ -982,11 +955,8 @@ uno::Reference< XAccessible > SAL_CALL ScAccessibleSpreadsheet::getAccessibleCel ...@@ -982,11 +955,8 @@ uno::Reference< XAccessible > SAL_CALL ScAccessibleSpreadsheet::getAccessibleCel
nColumn < 0) nColumn < 0)
throw lang::IndexOutOfBoundsException(); throw lang::IndexOutOfBoundsException();
} }
uno::Reference<XAccessible> xAccessible; rtl::Reference<ScAccessibleCell> pAccessibleCell = GetAccessibleCellAt(nRow, nColumn);
ScAccessibleCell* pAccessibleCell = GetAccessibleCellAt(nRow, nColumn); return pAccessibleCell.get();
xAccessible = pAccessibleCell;
pAccessibleCell->Init();
return xAccessible;
} }
sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn )
...@@ -1609,12 +1579,9 @@ void ScAccessibleSpreadsheet::NotifyRefMode() ...@@ -1609,12 +1579,9 @@ void ScAccessibleSpreadsheet::NotifyRefMode()
aEvent.Source = uno::Reference< XAccessible >(this); aEvent.Source = uno::Reference< XAccessible >(this);
aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED; aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED;
aEvent.Source = uno::Reference< XAccessible >(this); aEvent.Source = uno::Reference< XAccessible >(this);
uno::Reference< XAccessible > xOld = m_pAccFormulaCell; aEvent.OldValue <<= uno::Reference<XAccessible>(m_pAccFormulaCell.get());
aEvent.OldValue <<= xOld;
m_pAccFormulaCell = GetAccessibleCellAt(aFormulaAddr.Row(), aFormulaAddr.Col()); m_pAccFormulaCell = GetAccessibleCellAt(aFormulaAddr.Row(), aFormulaAddr.Col());
m_pAccFormulaCell->acquire(); uno::Reference< XAccessible > xNew = m_pAccFormulaCell.get();
m_pAccFormulaCell->Init();
uno::Reference< XAccessible > xNew = m_pAccFormulaCell;
aEvent.NewValue <<= xNew; aEvent.NewValue <<= xNew;
CommitChange(aEvent); CommitChange(aEvent);
if (nRefStartX == nRefEndX && nRefStartY == nRefEndY) if (nRefStartX == nRefEndX && nRefStartY == nRefEndY)
...@@ -1659,7 +1626,7 @@ void ScAccessibleSpreadsheet::NotifyRefMode() ...@@ -1659,7 +1626,7 @@ void ScAccessibleSpreadsheet::NotifyRefMode()
uno::Reference< XAccessible > xChild; uno::Reference< XAccessible > xChild;
if (*viAddr == aFormulaAddr) if (*viAddr == aFormulaAddr)
{ {
xChild = m_pAccFormulaCell; xChild = m_pAccFormulaCell.get();
} }
else else
{ {
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "viewdata.hxx" #include "viewdata.hxx"
#include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp> #include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp>
#include <com/sun/star/accessibility/XAccessibleRelationSet.hpp> #include <com/sun/star/accessibility/XAccessibleRelationSet.hpp>
#include <rtl/ref.hxx>
#include <unotools/accessiblerelationsethelper.hxx> #include <unotools/accessiblerelationsethelper.hxx>
#include <editeng/AccessibleStaticTextBase.hxx> #include <editeng/AccessibleStaticTextBase.hxx>
#include <comphelper/uno3.hxx> #include <comphelper/uno3.hxx>
...@@ -46,7 +47,16 @@ class ScAccessibleCell ...@@ -46,7 +47,16 @@ class ScAccessibleCell
public ScAccessibleCellAttributeImpl public ScAccessibleCellAttributeImpl
{ {
public: 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( ScAccessibleCell(
const ::com::sun::star::uno::Reference< const ::com::sun::star::uno::Reference<
::com::sun::star::accessibility::XAccessible>& rxParent, ::com::sun::star::accessibility::XAccessible>& rxParent,
......
...@@ -21,6 +21,10 @@ ...@@ -21,6 +21,10 @@
#ifndef _SC_ACCESSIBLESPREADSHEET_HXX #ifndef _SC_ACCESSIBLESPREADSHEET_HXX
#define _SC_ACCESSIBLESPREADSHEET_HXX #define _SC_ACCESSIBLESPREADSHEET_HXX
#include <sal/config.h>
#include <rtl/ref.hxx>
#include "AccessibleTableBase.hxx" #include "AccessibleTableBase.hxx"
#include "viewdata.hxx" #include "viewdata.hxx"
...@@ -92,6 +96,7 @@ public: ...@@ -92,6 +96,7 @@ public:
void BoundingBoxChanged(); void BoundingBoxChanged();
void VisAreaChanged(); void VisAreaChanged();
private:
///===== SfxListener ===================================================== ///===== SfxListener =====================================================
virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
...@@ -135,7 +140,7 @@ public: ...@@ -135,7 +140,7 @@ public:
throw (::com::sun::star::uno::RuntimeException, throw (::com::sun::star::uno::RuntimeException,
::com::sun::star::lang::IndexOutOfBoundsException); ::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. /// Returns a boolean value indicating whether the accessible at a specified row and column is selected.
virtual sal_Bool SAL_CALL virtual sal_Bool SAL_CALL
...@@ -258,7 +263,7 @@ private: ...@@ -258,7 +263,7 @@ private:
ScRangeList* mpMarkedRanges; ScRangeList* mpMarkedRanges;
std::vector<ScMyAddress>* mpSortedMarkedCells; std::vector<ScMyAddress>* mpSortedMarkedCells;
ScAccessibleDocument* mpAccDoc; ScAccessibleDocument* mpAccDoc;
ScAccessibleCell* mpAccCell; rtl::Reference<ScAccessibleCell> mpAccCell;
Rectangle maVisCells; Rectangle maVisCells;
ScSplitPos meSplitPos; ScSplitPos meSplitPos;
ScAddress maActiveCell; ScAddress maActiveCell;
...@@ -300,7 +305,7 @@ private: ...@@ -300,7 +305,7 @@ private:
ScAddress m_aFormulaActiveCell; ScAddress m_aFormulaActiveCell;
MAP_ADDR_XACC m_mapFormulaSelectionSend; MAP_ADDR_XACC m_mapFormulaSelectionSend;
VEC_MYADDR m_vecFormulaLastMyAddr; VEC_MYADDR m_vecFormulaLastMyAddr;
ScAccessibleCell* m_pAccFormulaCell; rtl::Reference<ScAccessibleCell> m_pAccFormulaCell;
sal_uInt16 m_nMinX; sal_uInt16 m_nMinX;
sal_uInt16 m_nMaxX; sal_uInt16 m_nMaxX;
sal_Int32 m_nMinY; sal_Int32 m_nMinY;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment