Kaydet (Commit) 116fa3a3 authored tarafından Noel Grandin's avatar Noel Grandin

use rtl::Reference in SvxShowCharSet

instead of storing both a raw pointer and an uno::Reference

Change-Id: I71c9cc4cc643d4b73a34b74c803378da75fd8de0
üst 5794beab
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <vcl/vclptr.hxx> #include <vcl/vclptr.hxx>
#include <map> #include <map>
#include <memory> #include <memory>
#include <rtl/ref.hxx>
#include <svx/svxdllapi.h> #include <svx/svxdllapi.h>
#define COLUMN_COUNT 16 #define COLUMN_COUNT 16
...@@ -97,8 +98,7 @@ private: ...@@ -97,8 +98,7 @@ private:
Link<SvxShowCharSet*,void> aSelectHdl; Link<SvxShowCharSet*,void> aSelectHdl;
Link<SvxShowCharSet*,void> aHighHdl; Link<SvxShowCharSet*,void> aHighHdl;
Link<SvxShowCharSet*,void> aPreSelectHdl; Link<SvxShowCharSet*,void> aPreSelectHdl;
svx::SvxShowCharSetVirtualAcc* m_pAccessible; rtl::Reference<svx::SvxShowCharSetVirtualAcc> m_xAccessible;
css::uno::Reference<css::accessibility::XAccessible> m_xAccessible;
long nX; long nX;
long nY; long nY;
long m_nXGap; long m_nXGap;
......
...@@ -57,7 +57,6 @@ sal_uInt32& SvxShowCharSet::getSelectedChar() ...@@ -57,7 +57,6 @@ sal_uInt32& SvxShowCharSet::getSelectedChar()
SvxShowCharSet::SvxShowCharSet(vcl::Window* pParent) SvxShowCharSet::SvxShowCharSet(vcl::Window* pParent)
: Control(pParent, WB_TABSTOP | WB_BORDER) : Control(pParent, WB_TABSTOP | WB_BORDER)
, m_pAccessible(nullptr)
, maFontSize(0, 0) , maFontSize(0, 0)
, aVscrollSB( VclPtr<ScrollBar>::Create(this, WB_VERT) ) , aVscrollSB( VclPtr<ScrollBar>::Create(this, WB_VERT) )
, mbRecalculateFont(true) , mbRecalculateFont(true)
...@@ -624,14 +623,14 @@ void SvxShowCharSet::SelectIndex( int nNewIndex, bool bFocus ) ...@@ -624,14 +623,14 @@ void SvxShowCharSet::SelectIndex( int nNewIndex, bool bFocus )
if( nSelectedIndex >= 0 ) if( nSelectedIndex >= 0 )
{ {
getSelectedChar() = mxFontCharMap->GetCharFromIndex( nSelectedIndex ); getSelectedChar() = mxFontCharMap->GetCharFromIndex( nSelectedIndex );
if( m_pAccessible ) if( m_xAccessible.is() )
{ {
svx::SvxShowCharSetItem* pItem = ImplGetItem(nSelectedIndex); svx::SvxShowCharSetItem* pItem = ImplGetItem(nSelectedIndex);
// Don't fire the focus event. // Don't fire the focus event.
if ( bFocus ) if ( bFocus )
m_pAccessible->fireEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, Any(), makeAny(pItem->GetAccessible()) ); // this call assures that m_pItem is set m_xAccessible->fireEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, Any(), makeAny(pItem->GetAccessible()) ); // this call assures that m_pItem is set
else else
m_pAccessible->fireEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS, Any(), makeAny(pItem->GetAccessible()) ); // this call assures that m_pItem is set m_xAccessible->fireEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS, Any(), makeAny(pItem->GetAccessible()) ); // this call assures that m_pItem is set
assert(pItem->m_pItem && "No accessible created!"); assert(pItem->m_pItem && "No accessible created!");
Any aOldAny, aNewAny; Any aOldAny, aNewAny;
...@@ -680,14 +679,14 @@ IMPL_LINK_NOARG(SvxShowCharSet, VscrollHdl, ScrollBar*, void) ...@@ -680,14 +679,14 @@ IMPL_LINK_NOARG(SvxShowCharSet, VscrollHdl, ScrollBar*, void)
} }
else if( nSelectedIndex > LastInView() ) else if( nSelectedIndex > LastInView() )
{ {
if( m_pAccessible ) if( m_xAccessible.is() )
{ {
css::uno::Any aOldAny, aNewAny; css::uno::Any aOldAny, aNewAny;
int nLast = LastInView(); int nLast = LastInView();
for ( ; nLast != nSelectedIndex; ++nLast) for ( ; nLast != nSelectedIndex; ++nLast)
{ {
aOldAny <<= ImplGetItem(nLast)->GetAccessible(); aOldAny <<= ImplGetItem(nLast)->GetAccessible();
m_pAccessible ->fireEvent( AccessibleEventId::CHILD, aOldAny, aNewAny ); m_xAccessible ->fireEvent( AccessibleEventId::CHILD, aOldAny, aNewAny );
} }
} }
SelectIndex( (LastInView() - COLUMN_COUNT + 1) + (nSelectedIndex % COLUMN_COUNT) ); SelectIndex( (LastInView() - COLUMN_COUNT + 1) + (nSelectedIndex % COLUMN_COUNT) );
...@@ -704,7 +703,7 @@ SvxShowCharSet::~SvxShowCharSet() ...@@ -704,7 +703,7 @@ SvxShowCharSet::~SvxShowCharSet()
void SvxShowCharSet::dispose() void SvxShowCharSet::dispose()
{ {
if ( m_pAccessible ) if ( m_xAccessible.is() )
ReleaseAccessible(); ReleaseAccessible();
aVscrollSB.disposeAndClear(); aVscrollSB.disposeAndClear();
Control::dispose(); Control::dispose();
...@@ -713,16 +712,14 @@ void SvxShowCharSet::dispose() ...@@ -713,16 +712,14 @@ void SvxShowCharSet::dispose()
void SvxShowCharSet::ReleaseAccessible() void SvxShowCharSet::ReleaseAccessible()
{ {
m_aItems.clear(); m_aItems.clear();
m_pAccessible = nullptr; m_xAccessible.clear();
m_xAccessible = nullptr;
} }
css::uno::Reference< XAccessible > SvxShowCharSet::CreateAccessible() css::uno::Reference< XAccessible > SvxShowCharSet::CreateAccessible()
{ {
OSL_ENSURE(!m_pAccessible,"Accessible already created!"); OSL_ENSURE(!m_xAccessible.is(),"Accessible already created!");
m_pAccessible = new svx::SvxShowCharSetVirtualAcc(this); m_xAccessible = new svx::SvxShowCharSetVirtualAcc(this);
m_xAccessible = m_pAccessible; return m_xAccessible.get();
return m_xAccessible;
} }
svx::SvxShowCharSetItem* SvxShowCharSet::ImplGetItem( int _nPos ) svx::SvxShowCharSetItem* SvxShowCharSet::ImplGetItem( int _nPos )
...@@ -730,9 +727,9 @@ svx::SvxShowCharSetItem* SvxShowCharSet::ImplGetItem( int _nPos ) ...@@ -730,9 +727,9 @@ svx::SvxShowCharSetItem* SvxShowCharSet::ImplGetItem( int _nPos )
ItemsMap::iterator aFind = m_aItems.find(_nPos); ItemsMap::iterator aFind = m_aItems.find(_nPos);
if ( aFind == m_aItems.end() ) if ( aFind == m_aItems.end() )
{ {
OSL_ENSURE(m_pAccessible,"Who wants to create a child of my table without a parent?"); OSL_ENSURE(m_xAccessible.is(), "Who wants to create a child of my table without a parent?");
std::shared_ptr<svx::SvxShowCharSetItem> xItem(new svx::SvxShowCharSetItem(*this, std::shared_ptr<svx::SvxShowCharSetItem> xItem(new svx::SvxShowCharSetItem(*this,
m_pAccessible->getTable(), sal::static_int_cast< sal_uInt16 >(_nPos))); m_xAccessible->getTable(), sal::static_int_cast< sal_uInt16 >(_nPos)));
aFind = m_aItems.insert(ItemsMap::value_type(_nPos, xItem)).first; aFind = m_aItems.insert(ItemsMap::value_type(_nPos, xItem)).first;
OUStringBuffer buf; OUStringBuffer buf;
buf.appendUtf32( mxFontCharMap->GetCharFromIndex( _nPos ) ); buf.appendUtf32( mxFontCharMap->GetCharFromIndex( _nPos ) );
......
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