Kaydet (Commit) 486fa0ba authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Have the caller pass the content instance directly.

This is to reduce dependency on ScHeaderFooterContentObj from
ScHeaderFieldObj.  Eventually that member should be removed and
ScHeaderFieldObj be replaced with ScEditFieldObj.
üst e04892db
...@@ -340,6 +340,7 @@ class ScHeaderFieldObj : public ScMutexHelper, ...@@ -340,6 +340,7 @@ class ScHeaderFieldObj : public ScMutexHelper,
{ {
private: private:
const SfxItemPropertySet* pPropSet; const SfxItemPropertySet* pPropSet;
com::sun::star::uno::Reference<com::sun::star::text::XTextRange> mpContent;
ScHeaderFooterContentObj* pContentObj; ScHeaderFooterContentObj* pContentObj;
sal_uInt16 nPart; sal_uInt16 nPart;
sal_uInt16 nType; sal_uInt16 nType;
...@@ -349,16 +350,18 @@ private: ...@@ -349,16 +350,18 @@ private:
ScHeaderFieldObj(); // disabled ScHeaderFieldObj(); // disabled
public: public:
ScHeaderFieldObj(ScHeaderFooterContentObj* pContent, sal_uInt16 nP, ScHeaderFieldObj(
sal_uInt16 nT, const ESelection& rSel); const com::sun::star::uno::Reference<com::sun::star::text::XTextRange>& rContent,
virtual ~ScHeaderFieldObj(); ScHeaderFooterContentObj* pContent, sal_uInt16 nP, sal_uInt16 nT, const ESelection& rSel);
virtual ~ScHeaderFieldObj();
// called by getImplementation: // called by getImplementation:
void DeleteField(); void DeleteField();
sal_Bool IsInserted() const { return pEditSource != NULL; } sal_Bool IsInserted() const { return pEditSource != NULL; }
SvxFieldItem CreateFieldItem(); SvxFieldItem CreateFieldItem();
void InitDoc( ScHeaderFooterContentObj* pContent, sal_uInt16 nP, void InitDoc(
const ESelection& rSel ); const com::sun::star::uno::Reference<com::sun::star::text::XTextRange>& rContent,
ScHeaderFooterContentObj* pContent, sal_uInt16 nP, const ESelection& rSel);
virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation(
const ::com::sun::star::uno::Type & rType ) const ::com::sun::star::uno::Type & rType )
......
...@@ -926,7 +926,21 @@ ScHeaderFieldObj* ScHeaderFieldsObj::GetObjectByIndex_Impl(sal_Int32 Index) cons ...@@ -926,7 +926,21 @@ ScHeaderFieldObj* ScHeaderFieldsObj::GetObjectByIndex_Impl(sal_Int32 Index) cons
} }
ESelection aSelection( nPar, nPos, nPar, nPos+1 ); // Field is 1 character ESelection aSelection( nPar, nPos, nPar, nPos+1 ); // Field is 1 character
return new ScHeaderFieldObj( pContentObj, nPart, nFieldType, aSelection ); 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();
uno::Reference<text::XTextRange> xTemp(xText, uno::UNO_QUERY);
xTextRange = xTemp;
}
return new ScHeaderFieldObj(xTextRange, pContentObj, nPart, nFieldType, aSelection);
} }
return NULL; return NULL;
} }
...@@ -1086,10 +1100,13 @@ sal_Int16 lcl_SvxToUnoFileFormat( SvxFileFormat nSvxValue ) ...@@ -1086,10 +1100,13 @@ sal_Int16 lcl_SvxToUnoFileFormat( SvxFileFormat nSvxValue )
} }
} }
ScHeaderFieldObj::ScHeaderFieldObj(ScHeaderFooterContentObj* pContent, sal_uInt16 nP, ScHeaderFieldObj::ScHeaderFieldObj(
sal_uInt16 nT, const ESelection& rSel) : const uno::Reference<text::XTextRange>& rContent,
ScHeaderFooterContentObj* pContent, sal_uInt16 nP,
sal_uInt16 nT, const ESelection& rSel) :
OComponentHelper( getMutex() ), OComponentHelper( getMutex() ),
pPropSet( (nT == SC_SERVICE_FILEFIELD) ? lcl_GetFileFieldPropertySet() : lcl_GetHeaderFieldPropertySet() ), pPropSet( (nT == SC_SERVICE_FILEFIELD) ? lcl_GetFileFieldPropertySet() : lcl_GetHeaderFieldPropertySet() ),
mpContent(rContent),
pContentObj( pContent ), pContentObj( pContent ),
nPart( nP ), nPart( nP ),
nType( nT ), nType( nT ),
...@@ -1168,8 +1185,9 @@ void SAL_CALL ScHeaderFieldObj::release() throw() ...@@ -1168,8 +1185,9 @@ void SAL_CALL ScHeaderFieldObj::release() throw()
OComponentHelper::release(); OComponentHelper::release();
} }
void ScHeaderFieldObj::InitDoc( ScHeaderFooterContentObj* pContent, sal_uInt16 nP, void ScHeaderFieldObj::InitDoc(
const ESelection& rSel ) const uno::Reference<text::XTextRange>& rContent,
ScHeaderFooterContentObj* pContent, sal_uInt16 nP, const ESelection& rSel)
{ {
if ( pContent && !pEditSource ) if ( pContent && !pEditSource )
{ {
...@@ -1178,6 +1196,7 @@ void ScHeaderFieldObj::InitDoc( ScHeaderFooterContentObj* pContent, sal_uInt16 n ...@@ -1178,6 +1196,7 @@ void ScHeaderFieldObj::InitDoc( ScHeaderFooterContentObj* pContent, sal_uInt16 n
aSelection = rSel; aSelection = rSel;
nPart = nP; nPart = nP;
pContentObj = pContent; pContentObj = pContent;
mpContent = rContent;
pContentObj->acquire(); // darf nicht wegkommen pContentObj->acquire(); // darf nicht wegkommen
pEditSource = new ScHeaderFooterEditSource( pContentObj, nPart ); pEditSource = new ScHeaderFooterEditSource( pContentObj, nPart );
...@@ -1295,18 +1314,7 @@ void SAL_CALL ScHeaderFieldObj::attach( const uno::Reference<text::XTextRange>& ...@@ -1295,18 +1314,7 @@ void SAL_CALL ScHeaderFieldObj::attach( const uno::Reference<text::XTextRange>&
uno::Reference<text::XTextRange> SAL_CALL ScHeaderFieldObj::getAnchor() throw(uno::RuntimeException) uno::Reference<text::XTextRange> SAL_CALL ScHeaderFieldObj::getAnchor() throw(uno::RuntimeException)
{ {
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
if (pContentObj) return mpContent;
{
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();
return uno::Reference<text::XTextRange>( xText, uno::UNO_QUERY );
}
return NULL;
} }
// XComponent // XComponent
......
...@@ -442,8 +442,12 @@ uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance( ...@@ -442,8 +442,12 @@ uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance(
case SC_SERVICE_TITLEFIELD: case SC_SERVICE_TITLEFIELD:
case SC_SERVICE_FILEFIELD: case SC_SERVICE_FILEFIELD:
case SC_SERVICE_SHEETFIELD: case SC_SERVICE_SHEETFIELD:
xRet.set((text::XTextField*)new ScHeaderFieldObj( NULL, 0, nType, ESelection() )); {
break; uno::Reference<text::XTextRange> xNullContent;
xRet.set(static_cast<text::XTextField*>(
new ScHeaderFieldObj(xNullContent, NULL, 0, nType, ESelection())));
}
break;
case SC_SERVICE_CELLSTYLE: case SC_SERVICE_CELLSTYLE:
xRet.set((style::XStyle*)new ScStyleObj( NULL, SFX_STYLE_FAMILY_PARA, String() )); xRet.set((style::XStyle*)new ScStyleObj( NULL, SFX_STYLE_FAMILY_PARA, String() ));
break; break;
......
...@@ -485,7 +485,35 @@ void SAL_CALL ScHeaderFooterTextObj::insertTextContent( ...@@ -485,7 +485,35 @@ void SAL_CALL ScHeaderFooterTextObj::insertTextContent(
aSelection.Adjust(); aSelection.Adjust();
aSelection.nEndPara = aSelection.nStartPara; aSelection.nEndPara = aSelection.nStartPara;
aSelection.nEndPos = aSelection.nStartPos + 1; aSelection.nEndPos = aSelection.nStartPos + 1;
pHeaderField->InitDoc( &aTextData.GetContentObj(), aTextData.GetPart(), aSelection );
uno::Reference<text::XTextRange> xTextRange;
switch (aTextData.GetPart())
{
case SC_HDFT_LEFT:
{
uno::Reference<text::XTextRange> xTemp(
aTextData.GetContentObj().getLeftText(), uno::UNO_QUERY);
xTextRange = xTemp;
}
break;
case SC_HDFT_CENTER:
{
uno::Reference<text::XTextRange> xTemp(
aTextData.GetContentObj().getCenterText(), uno::UNO_QUERY);
xTextRange = xTemp;
}
break;
case SC_HDFT_RIGHT:
{
uno::Reference<text::XTextRange> xTemp(
aTextData.GetContentObj().getRightText(), uno::UNO_QUERY);
xTextRange = xTemp;
}
break;
}
pHeaderField->InitDoc(
xTextRange, &aTextData.GetContentObj(), aTextData.GetPart(), aSelection);
// for bAbsorb=FALSE, the new selection must be behind the inserted content // for bAbsorb=FALSE, the new selection must be behind the inserted content
// (the xml filter relies on this) // (the xml filter relies on this)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment