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
This commit is contained in:
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user