summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-02-09 18:30:54 +0100
committerStephan Bergmann <sbergman@redhat.com>2016-02-09 18:30:54 +0100
commit5a5dbb31d559fb8d3cf9831863bea1f215a34f3d (patch)
tree5cdef958f12c98975501dc81c2da968ee543e183
parent05554bc47840659e1b9826523c100edfbc8a4ecd (diff)
Use rtl::Reference<CppType> instead of HardCppRef<UnoType,CppType>
Change-Id: I089b5caca5e05726105f78aeb00db1869d0a17f4
-rw-r--r--compilerplugins/clang/refcounting.cxx1
-rw-r--r--editeng/source/accessibility/AccessibleEditableTextPara.cxx16
-rw-r--r--editeng/source/accessibility/AccessibleParaManager.cxx13
-rw-r--r--include/editeng/AccessibleParaManager.hxx64
-rw-r--r--svx/source/accessibility/AccessibleTextHelper.cxx11
5 files changed, 29 insertions, 76 deletions
diff --git a/compilerplugins/clang/refcounting.cxx b/compilerplugins/clang/refcounting.cxx
index 7681a6e52496..61854e47b981 100644
--- a/compilerplugins/clang/refcounting.cxx
+++ b/compilerplugins/clang/refcounting.cxx
@@ -110,7 +110,6 @@ static std::vector<std::string> PROBABLY_GOOD_TEMPLATES = {
"com::sun::star::uno::Reference",
"com::sun::star::uno::WeakReference",
"com::sun::star::uno::Sequence",
- "accessibility::HardCppRef",
"accessibility::WeakCppRef",
"dba::OAutoRegistration",
"dba::OSingletonRegistration",
diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
index a51fbbac7e2b..66080c248361 100644
--- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx
+++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
@@ -258,7 +258,7 @@ namespace accessibility
mnParagraphIndex = nIndex;
- WeakBullet::HardRefType aChild( maImageBullet.get() );
+ auto aChild( maImageBullet.get() );
if( aChild.is() )
aChild->SetParagraphIndex(mnParagraphIndex);
@@ -318,7 +318,7 @@ namespace accessibility
void AccessibleEditableTextPara::SetEditSource( SvxEditSourceAdapter* pEditSource )
{
- WeakBullet::HardRefType aChild( maImageBullet.get() );
+ auto aChild( maImageBullet.get() );
if( aChild.is() )
aChild->SetEditSource(pEditSource);
@@ -561,7 +561,7 @@ namespace accessibility
void AccessibleEditableTextPara::SetEEOffset( const Point& rOffset )
{
- WeakBullet::HardRefType aChild( maImageBullet.get() );
+ auto aChild( maImageBullet.get() );
if( aChild.is() )
aChild->SetEEOffset(rOffset);
@@ -700,7 +700,7 @@ namespace accessibility
uno::Reference< uno::XInterface >
( static_cast< ::cppu::OWeakObject* > (this) ) ); // static_cast: disambiguate hierarchy
- WeakBullet::HardRefType aChild( maImageBullet.get() );
+ auto aChild( maImageBullet.get() );
if( !aChild.is() )
{
@@ -713,7 +713,7 @@ namespace accessibility
uno::Reference< uno::XInterface >
( static_cast< ::cppu::OWeakObject* > (this) ) );
- aChild = WeakBullet::HardRefType( xChild, pChild );
+ aChild = pChild;
aChild->SetEditSource( &GetEditSource() );
aChild->SetParagraphIndex( GetParagraphIndex() );
@@ -722,7 +722,7 @@ namespace accessibility
maImageBullet = aChild;
}
- return aChild.getRef();
+ return aChild.get();
}
uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleParent() throw (uno::RuntimeException, std::exception)
@@ -817,7 +817,7 @@ namespace accessibility
mpParaManager->IsReferencable( nMyParaIndex - 1 ) )
{
uno::Sequence<uno::Reference<XInterface> > aSequence
- { mpParaManager->GetChild( nMyParaIndex - 1 ).first.get().getRef() };
+ { static_cast<cppu::OWeakObject *>(mpParaManager->GetChild( nMyParaIndex - 1 ).first.get().get()) };
AccessibleRelation aAccRel( AccessibleRelationType::CONTENT_FLOWS_FROM,
aSequence );
pAccRelSetHelper->AddRelation( aAccRel );
@@ -828,7 +828,7 @@ namespace accessibility
mpParaManager->IsReferencable( nMyParaIndex + 1 ) )
{
uno::Sequence<uno::Reference<XInterface> > aSequence
- { mpParaManager->GetChild( nMyParaIndex + 1 ).first.get().getRef() };
+ { static_cast<cppu::OWeakObject *>(mpParaManager->GetChild( nMyParaIndex + 1 ).first.get().get()) };
AccessibleRelation aAccRel( AccessibleRelationType::CONTENT_FLOWS_TO,
aSequence );
pAccRelSetHelper->AddRelation( aAccRel );
diff --git a/editeng/source/accessibility/AccessibleParaManager.cxx b/editeng/source/accessibility/AccessibleParaManager.cxx
index 30fbdb56dd1b..bed5541b3f5e 100644
--- a/editeng/source/accessibility/AccessibleParaManager.cxx
+++ b/editeng/source/accessibility/AccessibleParaManager.cxx
@@ -104,13 +104,14 @@ namespace accessibility
if( 0 <= nPara && maChildren.size() > static_cast<size_t>(nPara) )
{
- WeakPara::HardRefType maChild( GetChild( nPara ).first.get() );
+ auto maChild( GetChild( nPara ).first.get() );
if( maChild.is() )
maChild->FireEvent( nEventId, rNewValue, rOldValue );
}
}
- bool AccessibleParaManager::IsReferencable( WeakPara::HardRefType aChild )
+ bool AccessibleParaManager::IsReferencable(
+ rtl::Reference<AccessibleEditableTextPara> const & aChild)
{
return aChild.is();
}
@@ -157,7 +158,7 @@ namespace accessibility
if( 0 <= nParagraphIndex && maChildren.size() > static_cast<size_t>(nParagraphIndex) )
{
// retrieve hard reference from weak one
- WeakPara::HardRefType aChild( GetChild( nParagraphIndex ).first.get() );
+ auto aChild( GetChild( nParagraphIndex ).first.get() );
if( !IsReferencable( nParagraphIndex ) )
{
@@ -169,14 +170,14 @@ namespace accessibility
if( !xChild.is() )
throw uno::RuntimeException("Child creation failed", xFrontEnd);
- aChild = WeakPara::HardRefType( xChild, pChild );
+ aChild = pChild;
InitChild( *aChild, rEditSource, nChild, nParagraphIndex );
maChildren[ nParagraphIndex ] = WeakChild( aChild, pChild->getBounds() );
}
- return Child( aChild.getRef(), GetChild( nParagraphIndex ).second );
+ return Child( aChild.get(), GetChild( nParagraphIndex ).second );
}
else
{
@@ -377,7 +378,7 @@ namespace accessibility
void AccessibleParaManager::ShutdownPara( const WeakChild& rChild )
{
- WeakPara::HardRefType aChild( rChild.first.get() );
+ auto aChild( rChild.first.get() );
if( IsReferencable( aChild ) )
aChild->SetEditSource( nullptr );
diff --git a/include/editeng/AccessibleParaManager.hxx b/include/editeng/AccessibleParaManager.hxx
index 295d7b12a4be..704af2e40767 100644
--- a/include/editeng/AccessibleParaManager.hxx
+++ b/include/editeng/AccessibleParaManager.hxx
@@ -37,52 +37,6 @@ namespace accessibility
{
class AccessibleEditableTextPara;
- /** Helper class for WeakCppRef
-
- This class is returned by WeakChild::get() and contains a hard
- reference and a reference to the c++ object. This combination
- prevents the c++ object from destruction during usage. Hold
- this object only as long as absolutely necessary, prevents
- referenced object from vanishing otherwise
- */
- template < class UnoType, class CppType > class HardCppRef
- {
- public:
-
- typedef UnoType UnoInterfaceType;
- typedef CppType InterfaceType;
-
- HardCppRef( const css::uno::WeakReference< UnoInterfaceType >& xRef, InterfaceType* rImpl ) :
- mxRef( xRef ),
- mpImpl( rImpl )
- {
- }
-
- /** Query whether the reference is still valid.
-
- Hands off also from the implementation pointer if this
- returns sal_False!
- */
- bool is() const { return mxRef.is(); }
- InterfaceType* operator->() const { return mpImpl; }
- InterfaceType& operator*() const { return *mpImpl; }
- css::uno::Reference< UnoInterfaceType >& getRef() { return mxRef; }
- const css::uno::Reference< UnoInterfaceType >& getRef() const { return mxRef; }
-
- // default copy constructor and assignment will do
- // HardCppRef( const HardCppRef& );
- // HardCppRef& operator= ( const HardCppRef& );
-
- private:
-
- // the interface, hard reference to prevent object from vanishing
- css::uno::Reference< UnoInterfaceType > mxRef;
-
- // the c++ object, for our internal stuff
- InterfaceType* mpImpl;
-
- };
-
/** Helper class for weak object references plus implementation
This class combines a weak reference (to facilitate automatic
@@ -96,7 +50,6 @@ namespace accessibility
typedef UnoType UnoInterfaceType;
typedef CppType InterfaceType;
- typedef HardCppRef< UnoInterfaceType, InterfaceType > HardRefType;
WeakCppRef() : maWeakRef(), maUnsafeRef( nullptr ) {}
WeakCppRef( InterfaceType& rImpl ) :
@@ -105,15 +58,18 @@ namespace accessibility
{
}
- WeakCppRef( HardRefType& rImpl ) :
- maWeakRef( rImpl.getRef() ),
- maUnsafeRef( rImpl.operator->() )
+ WeakCppRef(rtl::Reference<InterfaceType> const & rImpl):
+ maWeakRef(rImpl.get()),
+ maUnsafeRef(rImpl.get())
{
}
// get object with c++ object and hard reference (which
// prevents the c++ object from destruction during use)
- HardRefType get() const { return HardRefType( maWeakRef, maUnsafeRef ); }
+ rtl::Reference<InterfaceType> get() const {
+ css::uno::Reference<UnoInterfaceType> ref(maWeakRef);
+ return ref.is() ? maUnsafeRef : rtl::Reference<InterfaceType>();
+ }
// default copy constructor and assignment will do
// WeakCppRef( const WeakCppRef& );
@@ -178,7 +134,7 @@ namespace accessibility
const css::uno::Any& rNewValue = css::uno::Any(),
const css::uno::Any& rOldValue = css::uno::Any() ) const;
- static bool IsReferencable( WeakPara::HardRefType aChild );
+ static bool IsReferencable(rtl::Reference<AccessibleEditableTextPara> const & aChild);
bool IsReferencable( sal_Int32 nChild ) const;
static void ShutdownPara( const WeakChild& rChild );
@@ -248,7 +204,7 @@ namespace accessibility
void operator()( const WeakChild& rPara )
{
// retrieve hard reference from weak one
- WeakPara::HardRefType aHardRef( rPara.first.get() );
+ auto aHardRef( rPara.first.get() );
if( aHardRef.is() )
mrFunctor( *aHardRef );
@@ -276,7 +232,7 @@ namespace accessibility
void operator()( const WeakChild& rPara )
{
// retrieve hard reference from weak one
- WeakPara::HardRefType aHardRef( rPara.first.get() );
+ auto aHardRef( rPara.first.get() );
if( aHardRef.is() )
(*aHardRef.*maFunPtr)( maArg );
diff --git a/svx/source/accessibility/AccessibleTextHelper.cxx b/svx/source/accessibility/AccessibleTextHelper.cxx
index 7d811b54fe51..cf8e50f5c997 100644
--- a/svx/source/accessibility/AccessibleTextHelper.cxx
+++ b/svx/source/accessibility/AccessibleTextHelper.cxx
@@ -848,7 +848,7 @@ namespace accessibility
::accessibility::AccessibleParaManager::WeakChild operator()( const ::accessibility::AccessibleParaManager::WeakChild& rChild )
{
// retrieve hard reference from weak one
- ::accessibility::AccessibleParaManager::WeakPara::HardRefType aHardRef( rChild.first.get() );
+ auto aHardRef( rChild.first.get() );
if( aHardRef.is() )
{
@@ -899,10 +899,10 @@ namespace accessibility
void operator()( const ::accessibility::AccessibleParaManager::WeakChild& rPara )
{
// retrieve hard reference from weak one
- ::accessibility::AccessibleParaManager::WeakPara::HardRefType aHardRef( rPara.first.get() );
+ auto aHardRef( rPara.first.get() );
if( aHardRef.is() )
- mrImpl.FireEvent(AccessibleEventId::CHILD, uno::Any(), uno::makeAny( aHardRef.getRef() ) );
+ mrImpl.FireEvent(AccessibleEventId::CHILD, uno::Any(), uno::makeAny<css::uno::Reference<css::accessibility::XAccessible>>(aHardRef.get()) );
}
private:
@@ -1126,10 +1126,7 @@ namespace accessibility
// #i61812# remember para to be removed for later notification
// AFTER the new state is applied (that after the para got removed)
- ::uno::Reference< XAccessible > xPara;
- ::accessibility::AccessibleParaManager::WeakPara::HardRefType aHardRef( begin->first.get() );
- if( aHardRef.is() )
- xPara.set( aHardRef.getRef(), ::uno::UNO_QUERY );
+ ::uno::Reference< XAccessible > xPara(begin->first.get().get());
// release everything from the remove position until the end
maParaManager.Release(aFunctor.GetParaIndex(), nCurrParas);