summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-01-23 16:08:29 +0100
committerStephan Bergmann <sbergman@redhat.com>2015-01-23 16:13:48 +0100
commite753d31d5d2338da35b69b0a3b7742420c7562d2 (patch)
tree9a73933109f8f5a435bf15cec18048a0d0f20393
parent05e7b1db351ee964d155e49c55de7db3c917083f (diff)
Hold ScHeaderFooterContentObj by rtl::Reference
...there appears to be no good reason not to (it's a UNO implementation, deriving from WeakImplHelper), and witnessed at least one JunitTest_sc_unoapi failure where an incoming URP call on ScHeaderFooterTextObj::getString obtained an apparently dangling ScHeaderFooterContentObj& rContentObj = aTextData.GetContentObj() that pointed to garbage. Change-Id: I51a2a03ded18509ee61488d96bd30a6d364825d7
-rw-r--r--sc/inc/textuno.hxx10
-rw-r--r--sc/source/core/data/attrib.cxx4
-rw-r--r--sc/source/ui/unoobj/fielduno.cxx8
-rw-r--r--sc/source/ui/unoobj/textuno.cxx28
4 files changed, 25 insertions, 25 deletions
diff --git a/sc/inc/textuno.hxx b/sc/inc/textuno.hxx
index d716cbaffac2..303abfc2b136 100644
--- a/sc/inc/textuno.hxx
+++ b/sc/inc/textuno.hxx
@@ -94,7 +94,7 @@ public:
throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
- static ScHeaderFooterContentObj* getImplementation( const com::sun::star::uno::Reference<
+ static rtl::Reference<ScHeaderFooterContentObj> getImplementation( const com::sun::star::uno::Reference<
com::sun::star::sheet::XHeaderFooterContent> xObj );
// XServiceInfo
@@ -112,7 +112,7 @@ class ScHeaderFooterTextData : boost::noncopyable
{
private:
EditTextObject* mpTextObj;
- ScHeaderFooterContentObj& rContentObj;
+ rtl::Reference<ScHeaderFooterContentObj> rContentObj;
sal_uInt16 nPart;
ScEditEngineDefaulter* pEditEngine;
SvxEditEngineForwarder* pForwarder;
@@ -120,7 +120,7 @@ private:
public:
ScHeaderFooterTextData(
- ScHeaderFooterContentObj& rContent, sal_uInt16 nP, const EditTextObject* pTextObj);
+ rtl::Reference<ScHeaderFooterContentObj> const & rContent, sal_uInt16 nP, const EditTextObject* pTextObj);
~ScHeaderFooterTextData();
// helper functions
@@ -130,7 +130,7 @@ public:
ScEditEngineDefaulter* GetEditEngine() { GetTextForwarder(); return pEditEngine; }
sal_uInt16 GetPart() const { return nPart; }
- ScHeaderFooterContentObj& GetContentObj() const { return rContentObj; }
+ rtl::Reference<ScHeaderFooterContentObj> GetContentObj() const { return rContentObj; }
const EditTextObject* GetTextObject() const { return mpTextObj;}
};
@@ -156,7 +156,7 @@ private:
public:
ScHeaderFooterTextObj(
- ScHeaderFooterContentObj& rContent, sal_uInt16 nP, const EditTextObject* pTextObj);
+ rtl::Reference<ScHeaderFooterContentObj> const & rContent, sal_uInt16 nP, const EditTextObject* pTextObj);
virtual ~ScHeaderFooterTextObj();
const EditTextObject* GetTextObject() const;
diff --git a/sc/source/core/data/attrib.cxx b/sc/source/core/data/attrib.cxx
index 3af6849b9573..bb921c354039 100644
--- a/sc/source/core/data/attrib.cxx
+++ b/sc/source/core/data/attrib.cxx
@@ -591,9 +591,9 @@ bool ScPageHFItem::PutValue( const uno::Any& rVal, sal_uInt8 /* nMemberId */ )
{
if ( xContent.is() )
{
- ScHeaderFooterContentObj* pImp =
+ rtl::Reference<ScHeaderFooterContentObj> pImp =
ScHeaderFooterContentObj::getImplementation( xContent );
- if (pImp)
+ if (pImp.is())
{
const EditTextObject* pImpLeft = pImp->GetLeftEditObject();
delete pLeftArea;
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index c5c0f7eee266..8f18c92769a5 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -505,15 +505,15 @@ uno::Reference<text::XTextField> ScHeaderFieldsObj::GetObjectByIndex_Impl(sal_In
// Get the parent text range instance.
uno::Reference<text::XTextRange> xTextRange;
- ScHeaderFooterContentObj& rContentObj = mrData.GetContentObj();
+ rtl::Reference<ScHeaderFooterContentObj> rContentObj = mrData.GetContentObj();
uno::Reference<text::XText> xText;
sal_uInt16 nPart = mrData.GetPart();
if (nPart == SC_HDFT_LEFT)
- xText = rContentObj.getLeftText();
+ xText = rContentObj->getLeftText();
else if (nPart == SC_HDFT_CENTER)
- xText = rContentObj.getCenterText();
+ xText = rContentObj->getCenterText();
else
- xText = rContentObj.getRightText();
+ xText = rContentObj->getRightText();
uno::Reference<text::XTextRange> xTemp(xText, uno::UNO_QUERY);
xTextRange = xTemp;
diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx
index e7d9c6e47997..180752c9a695 100644
--- a/sc/source/ui/unoobj/textuno.cxx
+++ b/sc/source/ui/unoobj/textuno.cxx
@@ -91,9 +91,9 @@ SC_SIMPLE_SERVICE_INFO( ScHeaderFooterTextObj, "ScHeaderFooterTextObj", "stardiv
ScHeaderFooterContentObj::ScHeaderFooterContentObj( const EditTextObject* pLeft,
const EditTextObject* pCenter,
const EditTextObject* pRight ) :
- mxLeftText(new ScHeaderFooterTextObj(*this, SC_HDFT_LEFT, pLeft)),
- mxCenterText(new ScHeaderFooterTextObj(*this, SC_HDFT_CENTER, pCenter)),
- mxRightText(new ScHeaderFooterTextObj(*this, SC_HDFT_RIGHT, pRight))
+ mxLeftText(new ScHeaderFooterTextObj(this, SC_HDFT_LEFT, pLeft)),
+ mxCenterText(new ScHeaderFooterTextObj(this, SC_HDFT_CENTER, pCenter)),
+ mxRightText(new ScHeaderFooterTextObj(this, SC_HDFT_RIGHT, pRight))
{
}
@@ -164,10 +164,10 @@ const uno::Sequence<sal_Int8>& ScHeaderFooterContentObj::getUnoTunnelId()
return theScHeaderFooterContentObjUnoTunnelId::get().getSeq();
}
-ScHeaderFooterContentObj* ScHeaderFooterContentObj::getImplementation(
+rtl::Reference<ScHeaderFooterContentObj> ScHeaderFooterContentObj::getImplementation(
const uno::Reference<sheet::XHeaderFooterContent> xObj )
{
- ScHeaderFooterContentObj* pRet = NULL;
+ rtl::Reference<ScHeaderFooterContentObj> pRet;
uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
if (xUT.is())
pRet = reinterpret_cast<ScHeaderFooterContentObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
@@ -175,7 +175,7 @@ ScHeaderFooterContentObj* ScHeaderFooterContentObj::getImplementation(
}
ScHeaderFooterTextData::ScHeaderFooterTextData(
- ScHeaderFooterContentObj& rContent, sal_uInt16 nP, const EditTextObject* pTextObj) :
+ rtl::Reference<ScHeaderFooterContentObj> const & rContent, sal_uInt16 nP, const EditTextObject* pTextObj) :
mpTextObj(pTextObj ? pTextObj->Clone() : NULL),
rContentObj( rContent ),
nPart( nP ),
@@ -253,7 +253,7 @@ void ScHeaderFooterTextData::UpdateData(EditEngine& rEditEngine)
}
ScHeaderFooterTextObj::ScHeaderFooterTextObj(
- ScHeaderFooterContentObj& rContent, sal_uInt16 nP, const EditTextObject* pTextObj) :
+ rtl::Reference<ScHeaderFooterContentObj> const & rContent, sal_uInt16 nP, const EditTextObject* pTextObj) :
aTextData(rContent, nP, pTextObj)
{
// ScHeaderFooterTextData acquires rContent
@@ -322,14 +322,14 @@ OUString SAL_CALL ScHeaderFooterTextObj::getString() throw(uno::RuntimeException
const EditTextObject* pData;
sal_uInt16 nPart = aTextData.GetPart();
- ScHeaderFooterContentObj& rContentObj = aTextData.GetContentObj();
+ rtl::Reference<ScHeaderFooterContentObj> rContentObj = aTextData.GetContentObj();
if (nPart == SC_HDFT_LEFT)
- pData = rContentObj.GetLeftEditObject();
+ pData = rContentObj->GetLeftEditObject();
else if (nPart == SC_HDFT_CENTER)
- pData = rContentObj.GetCenterEditObject();
+ pData = rContentObj->GetCenterEditObject();
else
- pData = rContentObj.GetRightEditObject();
+ pData = rContentObj->GetRightEditObject();
if (pData)
{
// for pure text, no font info is needed in pool defaults
@@ -421,21 +421,21 @@ void SAL_CALL ScHeaderFooterTextObj::insertTextContent(
case SC_HDFT_LEFT:
{
uno::Reference<text::XTextRange> xTemp(
- aTextData.GetContentObj().getLeftText(), uno::UNO_QUERY);
+ aTextData.GetContentObj()->getLeftText(), uno::UNO_QUERY);
xTextRange = xTemp;
}
break;
case SC_HDFT_CENTER:
{
uno::Reference<text::XTextRange> xTemp(
- aTextData.GetContentObj().getCenterText(), uno::UNO_QUERY);
+ aTextData.GetContentObj()->getCenterText(), uno::UNO_QUERY);
xTextRange = xTemp;
}
break;
case SC_HDFT_RIGHT:
{
uno::Reference<text::XTextRange> xTemp(
- aTextData.GetContentObj().getRightText(), uno::UNO_QUERY);
+ aTextData.GetContentObj()->getRightText(), uno::UNO_QUERY);
xTextRange = xTemp;
}
break;