summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-04-24 17:21:29 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-04-26 09:58:01 -0400
commit58cb46341c8037c0fc2adeac69f72f09d0ffa952 (patch)
tree2aa0dcd83a655a069c317318192bac8c10ce43bf /sc
parentd4a99ec456c3169ab6c3ef385c43221a9871bc9a (diff)
Construct the edit source instance outside ScHeaderFieldObj.
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/fielduno.hxx9
-rw-r--r--sc/source/ui/unoobj/fielduno.cxx41
-rw-r--r--sc/source/ui/unoobj/textuno.cxx2
3 files changed, 23 insertions, 29 deletions
diff --git a/sc/inc/fielduno.hxx b/sc/inc/fielduno.hxx
index 153ea338306f..e8f37da27ce2 100644
--- a/sc/inc/fielduno.hxx
+++ b/sc/inc/fielduno.hxx
@@ -61,7 +61,6 @@ class ScDocShell;
class EditTextObject;
class ScHeaderFooterTextData;
-
class ScCellFieldsObj : public cppu::WeakImplHelper5<
com::sun::star::container::XEnumerationAccess,
com::sun::star::container::XIndexAccess,
@@ -342,7 +341,7 @@ private:
const SfxItemPropertySet* pPropSet;
com::sun::star::uno::Reference<com::sun::star::text::XTextRange> mpContent;
sal_uInt16 nType;
- SvxEditSource* pEditSource;
+ SvxEditSource* mpEditSource;
ESelection aSelection;
sal_Int16 nFileFormat; // enum SvxFileFormat, valid if not inserted
@@ -350,16 +349,16 @@ private:
public:
ScHeaderFieldObj(
const com::sun::star::uno::Reference<com::sun::star::text::XTextRange>& rContent,
- ScHeaderFooterTextData* pData, sal_uInt16 nT, const ESelection& rSel);
+ SvxEditSource* pEditSrc, sal_uInt16 nT, const ESelection& rSel);
virtual ~ScHeaderFieldObj();
// called by getImplementation:
void DeleteField();
- sal_Bool IsInserted() const { return pEditSource != NULL; }
+ sal_Bool IsInserted() const { return mpEditSource != NULL; }
SvxFieldItem CreateFieldItem();
void InitDoc(
const com::sun::star::uno::Reference<com::sun::star::text::XTextRange>& rContent,
- ScHeaderFooterTextData& rData, const ESelection& rSel);
+ SvxEditSource* pEditSrc, 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/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index 74811bfde95f..bc95fa0963a2 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -927,7 +927,7 @@ ScHeaderFieldObj* ScHeaderFieldsObj::GetObjectByIndex_Impl(sal_Int32 Index) cons
uno::Reference<text::XTextRange> xTemp(xText, uno::UNO_QUERY);
xTextRange = xTemp;
- return new ScHeaderFieldObj(xTextRange, &mrData, nFieldType, aSelection);
+ return new ScHeaderFieldObj(xTextRange, new ScHeaderFooterEditSource(&mrData), nFieldType, aSelection);
}
return NULL;
}
@@ -1089,19 +1089,15 @@ sal_Int16 lcl_SvxToUnoFileFormat( SvxFileFormat nSvxValue )
ScHeaderFieldObj::ScHeaderFieldObj(
const uno::Reference<text::XTextRange>& rContent,
- ScHeaderFooterTextData* pData,
- sal_uInt16 nT, const ESelection& rSel) :
+ SvxEditSource* pEditSrc, sal_uInt16 nT, const ESelection& rSel) :
OComponentHelper( getMutex() ),
pPropSet( (nT == SC_SERVICE_FILEFIELD) ? lcl_GetFileFieldPropertySet() : lcl_GetHeaderFieldPropertySet() ),
mpContent(rContent),
nType( nT ),
- pEditSource(NULL),
+ mpEditSource(pEditSrc),
aSelection( rSel ),
nFileFormat( SVXFILEFORMAT_NAME_EXT )
{
- // pContent ist Null, wenn per ServiceProvider erzeugt
- if (pData)
- pEditSource = new ScHeaderFooterEditSource(pData);
}
uno::Any SAL_CALL ScHeaderFieldObj::queryAggregation( const uno::Type& rType )
@@ -1166,27 +1162,26 @@ void SAL_CALL ScHeaderFieldObj::release() throw()
}
void ScHeaderFieldObj::InitDoc(
- const uno::Reference<text::XTextRange>& rContent, ScHeaderFooterTextData& rData, const ESelection& rSel)
+ const uno::Reference<text::XTextRange>& rContent, SvxEditSource* pEditSrc, const ESelection& rSel)
{
- if (!pEditSource)
+ if (!mpEditSource)
{
+ mpEditSource = pEditSrc;
aSelection = rSel;
mpContent = rContent;
-
- pEditSource = new ScHeaderFooterEditSource(&rData);
}
}
ScHeaderFieldObj::~ScHeaderFieldObj()
{
- delete pEditSource;
+ delete mpEditSource;
}
// per getImplementation gerufen:
SvxFieldItem ScHeaderFieldObj::CreateFieldItem()
{
- OSL_ENSURE( !pEditSource, "CreateFieldItem mit eingefuegtem Feld" );
+ OSL_ENSURE( !mpEditSource, "CreateFieldItem mit eingefuegtem Feld" );
switch (nType)
{
@@ -1233,11 +1228,11 @@ SvxFieldItem ScHeaderFieldObj::CreateFieldItem()
void ScHeaderFieldObj::DeleteField()
{
- if (pEditSource)
+ if (mpEditSource)
{
- SvxTextForwarder* pForwarder = pEditSource->GetTextForwarder();
+ SvxTextForwarder* pForwarder = mpEditSource->GetTextForwarder();
pForwarder->QuickInsertText( String(), aSelection );
- pEditSource->UpdateData();
+ mpEditSource->UpdateData();
aSelection.nEndPara = aSelection.nStartPara;
aSelection.nEndPos = aSelection.nStartPos;
@@ -1255,11 +1250,11 @@ rtl::OUString SAL_CALL ScHeaderFieldObj::getPresentation( sal_Bool /* bShowComma
SolarMutexGuard aGuard;
String aRet;
- if (pEditSource)
+ if (mpEditSource)
{
// Feld von der EditEngine formatieren lassen, bShowCommand gibt's nicht
- SvxTextForwarder* pForwarder = pEditSource->GetTextForwarder();
+ SvxTextForwarder* pForwarder = mpEditSource->GetTextForwarder();
aRet = pForwarder->GetText( aSelection );
}
@@ -1342,9 +1337,9 @@ void SAL_CALL ScHeaderFieldObj::setPropertyValue(
if ( aValue >>= nIntVal )
{
SvxFileFormat eFormat = lcl_UnoToSvxFileFormat( nIntVal );
- if (pEditSource)
+ if (mpEditSource)
{
- ScEditEngineDefaulter* pEditEngine = ((ScHeaderFooterEditSource*)pEditSource)->GetEditEngine();
+ ScEditEngineDefaulter* pEditEngine = ((ScHeaderFooterEditSource*)mpEditSource)->GetEditEngine();
ScUnoEditEngine aTempEngine(pEditEngine);
SvxFieldData* pField = aTempEngine.FindByPos(
aSelection.nStartPara, aSelection.nStartPos, TYPE(SvxExtFileField) );
@@ -1354,7 +1349,7 @@ void SAL_CALL ScHeaderFieldObj::setPropertyValue(
SvxExtFileField* pExtFile = (SvxExtFileField*)pField; // local to the ScUnoEditEngine
pExtFile->SetFormat( eFormat );
pEditEngine->QuickInsertField( SvxFieldItem(*pField, EE_FEATURE_FIELD), aSelection );
- pEditSource->UpdateData();
+ mpEditSource->UpdateData();
}
}
else
@@ -1388,9 +1383,9 @@ uno::Any SAL_CALL ScHeaderFieldObj::getPropertyValue( const rtl::OUString& aProp
else if ( nType == SC_SERVICE_FILEFIELD && aNameString.EqualsAscii( SC_UNONAME_FILEFORM ) )
{
SvxFileFormat eFormat = SVXFILEFORMAT_NAME_EXT;
- if (pEditSource)
+ if (mpEditSource)
{
- ScEditEngineDefaulter* pEditEngine = ((ScHeaderFooterEditSource*)pEditSource)->GetEditEngine();
+ ScEditEngineDefaulter* pEditEngine = ((ScHeaderFooterEditSource*)mpEditSource)->GetEditEngine();
ScUnoEditEngine aTempEngine(pEditEngine);
SvxFieldData* pField = aTempEngine.FindByPos(
aSelection.nStartPara, aSelection.nStartPos, TYPE(SvxExtFileField) );
diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx
index daa1146b5197..868e7be4c706 100644
--- a/sc/source/ui/unoobj/textuno.cxx
+++ b/sc/source/ui/unoobj/textuno.cxx
@@ -478,7 +478,7 @@ void SAL_CALL ScHeaderFooterTextObj::insertTextContent(
break;
}
- pHeaderField->InitDoc(xTextRange, aTextData, aSelection);
+ pHeaderField->InitDoc(xTextRange, new ScHeaderFooterEditSource(&aTextData), aSelection);
// for bAbsorb=FALSE, the new selection must be behind the inserted content
// (the xml filter relies on this)