summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-04-24 16:54:23 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-04-26 09:58:01 -0400
commit1de32aeca83edb2c8e6a575e4f7132ec39b9ca52 (patch)
treee53bdf3cca3db3d477b2fa8d3b61ba4a6db1a7af /sc
parent399727e98353c24719408780ad9d7e7eee198176 (diff)
Ok, the regression I had introduced in my prev commit is now fixed.
The idea is to keep a reference to the ScHeaderFooterTextData instance in ScHeaderFooterTextObj which is the authoritative copy, instead of making copies of it everywhere. This way when the text is updated in ScHeaderFooterTextObj all the other places will see it too without needing to propagate the change.
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/editsrc.hxx6
-rw-r--r--sc/inc/fielduno.hxx13
-rw-r--r--sc/source/ui/unoobj/editsrc.cxx24
-rw-r--r--sc/source/ui/unoobj/fielduno.cxx76
-rw-r--r--sc/source/ui/unoobj/servuno.cxx2
-rw-r--r--sc/source/ui/unoobj/textuno.cxx12
6 files changed, 46 insertions, 87 deletions
diff --git a/sc/inc/editsrc.hxx b/sc/inc/editsrc.hxx
index 435fb856bcd7..76911d5d8463 100644
--- a/sc/inc/editsrc.hxx
+++ b/sc/inc/editsrc.hxx
@@ -66,15 +66,15 @@ public:
class ScHeaderFooterEditSource : public SvxEditSource
{
private:
- ScHeaderFooterTextData* pTextData;
+ ScHeaderFooterTextData* mpTextData;
public:
- ScHeaderFooterEditSource(const ScHeaderFooterTextData& rData);
- ScHeaderFooterEditSource(ScHeaderFooterContentObj& rContent, sal_uInt16 nP, const EditTextObject* pTextObj);
+ ScHeaderFooterEditSource(ScHeaderFooterTextData* pData);
virtual ~ScHeaderFooterEditSource();
// GetEditEngine is needed because the forwarder doesn't have field functions
ScEditEngineDefaulter* GetEditEngine();
+ void SetTextData(ScHeaderFooterTextData* pData);
virtual SvxEditSource* Clone() const;
virtual SvxTextForwarder* GetTextForwarder();
diff --git a/sc/inc/fielduno.hxx b/sc/inc/fielduno.hxx
index 86c6f524ae05..153ea338306f 100644
--- a/sc/inc/fielduno.hxx
+++ b/sc/inc/fielduno.hxx
@@ -59,6 +59,7 @@ class ScHeaderFieldObj;
class ScHeaderFooterContentObj;
class ScDocShell;
class EditTextObject;
+class ScHeaderFooterTextData;
class ScCellFieldsObj : public cppu::WeakImplHelper5<
@@ -271,8 +272,7 @@ class ScHeaderFieldsObj : public cppu::WeakImplHelper5<
com::sun::star::lang::XServiceInfo >
{
private:
- ScHeaderFooterContentObj* pContentObj;
- sal_uInt16 nPart;
+ ScHeaderFooterTextData& mrData;
sal_uInt16 nType;
SvxEditSource* pEditSource;
@@ -284,8 +284,7 @@ private:
ScHeaderFieldObj* GetObjectByIndex_Impl(sal_Int32 Index) const;
public:
- ScHeaderFieldsObj(
- ScHeaderFooterContentObj* pContent, sal_uInt16 nP, const EditTextObject* pTextObj, sal_uInt16 nT);
+ ScHeaderFieldsObj(ScHeaderFooterTextData& rData);
virtual ~ScHeaderFieldsObj();
// XIndexAccess
@@ -342,8 +341,6 @@ class ScHeaderFieldObj : public ScMutexHelper,
private:
const SfxItemPropertySet* pPropSet;
com::sun::star::uno::Reference<com::sun::star::text::XTextRange> mpContent;
- ScHeaderFooterContentObj* pContentObj;
- sal_uInt16 nPart;
sal_uInt16 nType;
SvxEditSource* pEditSource;
ESelection aSelection;
@@ -353,7 +350,7 @@ private:
public:
ScHeaderFieldObj(
const com::sun::star::uno::Reference<com::sun::star::text::XTextRange>& rContent,
- ScHeaderFooterContentObj* pContent, sal_uInt16 nP, sal_uInt16 nT, const ESelection& rSel);
+ ScHeaderFooterTextData* pData, sal_uInt16 nT, const ESelection& rSel);
virtual ~ScHeaderFieldObj();
// called by getImplementation:
@@ -362,7 +359,7 @@ public:
SvxFieldItem CreateFieldItem();
void InitDoc(
const com::sun::star::uno::Reference<com::sun::star::text::XTextRange>& rContent,
- ScHeaderFooterContentObj* pContent, sal_uInt16 nP, const EditTextObject* pTextObj, const ESelection& rSel);
+ ScHeaderFooterTextData& rData, const ESelection& rSel);
virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(
const ::com::sun::star::uno::Type & rType )
diff --git a/sc/source/ui/unoobj/editsrc.cxx b/sc/source/ui/unoobj/editsrc.cxx
index e52a9e9c56d7..1128596e6263 100644
--- a/sc/source/ui/unoobj/editsrc.cxx
+++ b/sc/source/ui/unoobj/editsrc.cxx
@@ -67,37 +67,35 @@ ScHeaderFooterChangedHint::~ScHeaderFooterChangedHint()
// each ScHeaderFooterEditSource object has its own ScHeaderFooterTextData
-ScHeaderFooterEditSource::ScHeaderFooterEditSource(const ScHeaderFooterTextData& rData) :
- pTextData(new ScHeaderFooterTextData(rData.GetContentObj(), rData.GetPart(), rData.GetTextObject())) {}
+ScHeaderFooterEditSource::ScHeaderFooterEditSource(ScHeaderFooterTextData* pData) :
+ mpTextData(pData) {}
-ScHeaderFooterEditSource::ScHeaderFooterEditSource(
- ScHeaderFooterContentObj& rContent, sal_uInt16 nP, const EditTextObject* pTextObj) :
- pTextData(new ScHeaderFooterTextData(rContent, nP, pTextObj)) {}
+ScHeaderFooterEditSource::~ScHeaderFooterEditSource() {}
-ScHeaderFooterEditSource::~ScHeaderFooterEditSource()
+ScEditEngineDefaulter* ScHeaderFooterEditSource::GetEditEngine()
{
- delete pTextData; // not accessed in ScSharedHeaderFooterEditSource dtor
+ return mpTextData ? mpTextData->GetEditEngine() : NULL;
}
-ScEditEngineDefaulter* ScHeaderFooterEditSource::GetEditEngine()
+void ScHeaderFooterEditSource::SetTextData(ScHeaderFooterTextData* pData)
{
- return pTextData->GetEditEngine();
+ mpTextData = pData;
}
SvxEditSource* ScHeaderFooterEditSource::Clone() const
{
- return new ScHeaderFooterEditSource(
- pTextData->GetContentObj(), pTextData->GetPart(), pTextData->GetTextObject());
+ return new ScHeaderFooterEditSource(mpTextData);
}
SvxTextForwarder* ScHeaderFooterEditSource::GetTextForwarder()
{
- return pTextData->GetTextForwarder();
+ return mpTextData ? mpTextData->GetTextForwarder() : NULL;
}
void ScHeaderFooterEditSource::UpdateData()
{
- pTextData->UpdateData();
+ if (mpTextData)
+ mpTextData->UpdateData();
}
//------------------------------------------------------------------------
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index edd7b9e94dee..74811bfde95f 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -848,31 +848,18 @@ uno::Sequence<rtl::OUString> SAL_CALL ScCellFieldObj::getSupportedServiceNames()
//------------------------------------------------------------------------
-ScHeaderFieldsObj::ScHeaderFieldsObj(
- ScHeaderFooterContentObj* pContent, sal_uInt16 nP, const EditTextObject* pTextObj, sal_uInt16 nT) :
- pContentObj( pContent ),
- nPart( nP ),
- nType( nT ),
+ScHeaderFieldsObj::ScHeaderFieldsObj(ScHeaderFooterTextData& rData) :
+ mrData(rData),
+ nType(SC_SERVICE_INVALID),
mpRefreshListeners( NULL )
{
- OSL_ENSURE( pContentObj, "ScHeaderFieldsObj ohne Objekt?" );
-
- if (pContentObj)
- {
- pContentObj->acquire(); // darf nicht wegkommen
- pEditSource = new ScHeaderFooterEditSource(*pContentObj, nPart, pTextObj);
- }
- else
- pEditSource = NULL;
+ pEditSource = new ScHeaderFooterEditSource(&rData);
}
ScHeaderFieldsObj::~ScHeaderFieldsObj()
{
delete pEditSource;
- if (pContentObj)
- pContentObj->release();
-
// increment refcount to prevent double call off dtor
osl_incrementInterlockedCount( &m_refCount );
@@ -928,20 +915,19 @@ ScHeaderFieldObj* ScHeaderFieldsObj::GetObjectByIndex_Impl(sal_Int32 Index) cons
ESelection aSelection( nPar, nPos, nPar, nPos+1 ); // Field is 1 character
uno::Reference<text::XTextRange> xTextRange;
- if (pContentObj)
- {
- uno::Reference<text::XText> xText;
- if ( nPart == SC_HDFT_LEFT )
- xText = pContentObj->getLeftText();
- else if (nPart == SC_HDFT_CENTER)
- xText = pContentObj->getCenterText();
- else
- xText = pContentObj->getRightText();
+ ScHeaderFooterContentObj& rContentObj = mrData.GetContentObj();
+ uno::Reference<text::XText> xText;
+ sal_uInt16 nPart = mrData.GetPart();
+ if ( nPart == SC_HDFT_LEFT )
+ xText = rContentObj.getLeftText();
+ else if (nPart == SC_HDFT_CENTER)
+ xText = rContentObj.getCenterText();
+ else
+ xText = rContentObj.getRightText();
- uno::Reference<text::XTextRange> xTemp(xText, uno::UNO_QUERY);
- xTextRange = xTemp;
- }
- return new ScHeaderFieldObj(xTextRange, pContentObj, nPart, nFieldType, aSelection);
+ uno::Reference<text::XTextRange> xTemp(xText, uno::UNO_QUERY);
+ xTextRange = xTemp;
+ return new ScHeaderFieldObj(xTextRange, &mrData, nFieldType, aSelection);
}
return NULL;
}
@@ -1103,26 +1089,19 @@ sal_Int16 lcl_SvxToUnoFileFormat( SvxFileFormat nSvxValue )
ScHeaderFieldObj::ScHeaderFieldObj(
const uno::Reference<text::XTextRange>& rContent,
- ScHeaderFooterContentObj* pContent, sal_uInt16 nP,
+ ScHeaderFooterTextData* pData,
sal_uInt16 nT, const ESelection& rSel) :
OComponentHelper( getMutex() ),
pPropSet( (nT == SC_SERVICE_FILEFIELD) ? lcl_GetFileFieldPropertySet() : lcl_GetHeaderFieldPropertySet() ),
mpContent(rContent),
- pContentObj( pContent ),
- nPart( nP ),
nType( nT ),
+ pEditSource(NULL),
aSelection( rSel ),
nFileFormat( SVXFILEFORMAT_NAME_EXT )
{
// pContent ist Null, wenn per ServiceProvider erzeugt
-
- if (pContentObj)
- {
- pContentObj->acquire(); // darf nicht wegkommen
- pEditSource = new ScHeaderFooterEditSource(*pContentObj, nPart, NULL);
- }
- else
- pEditSource = NULL;
+ if (pData)
+ pEditSource = new ScHeaderFooterEditSource(pData);
}
uno::Any SAL_CALL ScHeaderFieldObj::queryAggregation( const uno::Type& rType )
@@ -1187,29 +1166,20 @@ void SAL_CALL ScHeaderFieldObj::release() throw()
}
void ScHeaderFieldObj::InitDoc(
- const uno::Reference<text::XTextRange>& rContent,
- ScHeaderFooterContentObj* pContent, sal_uInt16 nP, const EditTextObject* pTextObj, const ESelection& rSel)
+ const uno::Reference<text::XTextRange>& rContent, ScHeaderFooterTextData& rData, const ESelection& rSel)
{
- if ( pContent && !pEditSource )
+ if (!pEditSource)
{
- OSL_ENSURE( !pContentObj, "ContentObj, aber kein EditSource?" );
-
aSelection = rSel;
- nPart = nP;
- pContentObj = pContent;
mpContent = rContent;
- pContentObj->acquire(); // darf nicht wegkommen
- pEditSource = new ScHeaderFooterEditSource(*pContentObj, nPart, pTextObj);
+ pEditSource = new ScHeaderFooterEditSource(&rData);
}
}
ScHeaderFieldObj::~ScHeaderFieldObj()
{
delete pEditSource;
-
- if (pContentObj)
- pContentObj->release();
}
// per getImplementation gerufen:
diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx
index 9227423954dc..816be4140cf4 100644
--- a/sc/source/ui/unoobj/servuno.cxx
+++ b/sc/source/ui/unoobj/servuno.cxx
@@ -445,7 +445,7 @@ uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance(
{
uno::Reference<text::XTextRange> xNullContent;
xRet.set(static_cast<text::XTextField*>(
- new ScHeaderFieldObj(xNullContent, NULL, 0, nType, ESelection())));
+ new ScHeaderFieldObj(xNullContent, NULL, nType, ESelection())));
}
break;
case SC_SERVICE_CELLSTYLE:
diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx
index faaabd3c800f..5bab305e7776 100644
--- a/sc/source/ui/unoobj/textuno.cxx
+++ b/sc/source/ui/unoobj/textuno.cxx
@@ -205,8 +205,6 @@ ScHeaderFooterTextData::ScHeaderFooterTextData(
bDataValid( false ),
bInUpdate( false )
{
- if (!mpTextObj)
- fprintf(stdout, "ScHeaderFooterTextData::ScHeaderFooterTextData: mpTextObj = %p\n", mpTextObj);
rContentObj.acquire(); // must not go away
}
@@ -264,7 +262,6 @@ SvxTextForwarder* ScHeaderFooterTextData::GetTextForwarder()
void ScHeaderFooterTextData::UpdateData()
{
- fprintf(stdout, "ScHeaderFooterTextData::UpdateData: 1\n");
if (pEditEngine)
{
delete mpTextObj;
@@ -275,7 +272,6 @@ void ScHeaderFooterTextData::UpdateData()
void ScHeaderFooterTextData::UpdateData(EditEngine& rEditEngine)
{
- fprintf(stdout, "ScHeaderFooterTextData::UpdateData: 2\n");
delete mpTextObj;
mpTextObj = rEditEngine.CreateTextObject();
bDataValid = false;
@@ -302,7 +298,7 @@ void ScHeaderFooterTextObj::CreateUnoText_Impl()
if ( !pUnoText )
{
// can't be aggregated because getString/setString is handled here
- ScHeaderFooterEditSource aEditSource(aTextData);
+ ScHeaderFooterEditSource aEditSource(&aTextData);
pUnoText = new SvxUnoText( &aEditSource, lcl_GetHdFtPropertySet(), uno::Reference<text::XText>() );
pUnoText->acquire();
}
@@ -483,8 +479,7 @@ void SAL_CALL ScHeaderFooterTextObj::insertTextContent(
break;
}
- pHeaderField->InitDoc(
- xTextRange, &aTextData.GetContentObj(), aTextData.GetPart(), aTextData.GetTextObject(), aSelection);
+ pHeaderField->InitDoc(xTextRange, aTextData, aSelection);
// for bAbsorb=FALSE, the new selection must be behind the inserted content
// (the xml filter relies on this)
@@ -553,8 +548,7 @@ uno::Reference<container::XEnumerationAccess> SAL_CALL ScHeaderFooterTextObj::ge
{
SolarMutexGuard aGuard;
// all fields
- return new ScHeaderFieldsObj(
- &aTextData.GetContentObj(), aTextData.GetPart(), aTextData.GetTextObject(), SC_SERVICE_INVALID);
+ return new ScHeaderFieldsObj(aTextData);
}
uno::Reference<container::XNameAccess> SAL_CALL ScHeaderFooterTextObj::getTextFieldMasters()