summaryrefslogtreecommitdiff
path: root/sw/source/core/fields
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core/fields')
-rw-r--r--sw/source/core/fields/cellfml.cxx2
-rw-r--r--sw/source/core/fields/dbfld.cxx47
-rw-r--r--sw/source/core/fields/docufld.cxx71
-rw-r--r--sw/source/core/fields/expfld.cxx78
-rw-r--r--sw/source/core/fields/fldbas.cxx36
-rw-r--r--sw/source/core/fields/macrofld.cxx19
-rw-r--r--sw/source/core/fields/reffld.cxx11
-rw-r--r--sw/source/core/fields/tblcalc.cxx48
-rw-r--r--sw/source/core/fields/usrfld.cxx21
9 files changed, 137 insertions, 196 deletions
diff --git a/sw/source/core/fields/cellfml.cxx b/sw/source/core/fields/cellfml.cxx
index 182ed12d6ddd..36b981b90752 100644
--- a/sw/source/core/fields/cellfml.cxx
+++ b/sw/source/core/fields/cellfml.cxx
@@ -203,7 +203,7 @@ double SwTableBox::GetValue( SwTblCalcPara& rCalcPara ) const
break;
default:
- String const value(pFld->ExpandField(pDoc->IsClipBoard()));
+ String const value(pFld->ExpandField(true));
nRet = rCalcPara.rCalc.Calculate(value).GetDouble();
}
}
diff --git a/sw/source/core/fields/dbfld.cxx b/sw/source/core/fields/dbfld.cxx
index 15c44286921c..ec3f5200ba67 100644
--- a/sw/source/core/fields/dbfld.cxx
+++ b/sw/source/core/fields/dbfld.cxx
@@ -28,7 +28,6 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
-
#include <float.h>
#include <sfx2/app.hxx>
#include <svl/zforlist.hxx>
@@ -44,15 +43,11 @@
#include <pam.hxx>
#include <ndtxt.hxx>
#include <dbfld.hxx>
-#ifndef _DBMGR_HXX
#include <dbmgr.hxx>
-#endif
#include <docfld.hxx>
#include <expfld.hxx>
#include <txtatr.hxx>
-#ifndef _UNOFLDMID_H
#include <unofldmid.h>
-#endif
using namespace ::com::sun::star::sdbc;
@@ -281,27 +276,23 @@ SwField* SwDBField::Copy() const
return pTmp;
}
-String SwDBField::GetCntnt(BOOL bName) const
+String SwDBField::GetFieldName() const
{
- if(bName)
- {
- const String& rDBName = ((SwDBFieldType*)GetTyp())->GetName();
+ const String& rDBName = static_cast<SwDBFieldType*>(GetTyp())->GetName();
//TODO/CLEANUP
//Funktion tut nichts!
//String sContent( SFX_APP()->LocalizeDBName(INI2NATIONAL,
// rDBName.GetToken(0, DB_DELIM)));
- String sContent( rDBName.GetToken(0, DB_DELIM) );
+ String sContent( rDBName.GetToken(0, DB_DELIM) );
- if (sContent.Len() > 1)
- {
- sContent += DB_DELIM;
- sContent += rDBName.GetToken(1, DB_DELIM);
- sContent += DB_DELIM;
- sContent += rDBName.GetToken(2, DB_DELIM);
- }
- return lcl_DBTrennConv(sContent);
+ if (sContent.Len() > 1)
+ {
+ sContent += DB_DELIM;
+ sContent += rDBName.GetToken(1, DB_DELIM);
+ sContent += DB_DELIM;
+ sContent += rDBName.GetToken(2, DB_DELIM);
}
- return Expand();
+ return lcl_DBTrennConv(sContent);
}
//------------------------------------------------------------------------------
@@ -547,19 +538,15 @@ void SwDBNameInfField::SetDBData(const SwDBData & rDBData)
//------------------------------------------------------------------------------
-String SwDBNameInfField::GetCntnt(BOOL bName) const
+String SwDBNameInfField::GetFieldName() const
{
- String sStr(SwField::GetCntnt(bName));
-
- if(bName)
+ String sStr( SwField::GetFieldName() );
+ if (aDBData.sDataSource.getLength())
{
- if (aDBData.sDataSource.getLength())
- {
- sStr += ':';
- sStr += String(aDBData.sDataSource);
- sStr += DB_DELIM;
- sStr += String(aDBData.sCommand);
- }
+ sStr += ':';
+ sStr += String(aDBData.sDataSource);
+ sStr += DB_DELIM;
+ sStr += String(aDBData.sCommand);
}
return lcl_DBTrennConv(sStr);
}
diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx
index fba7115075e8..f6b727987cd3 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -171,9 +171,9 @@ void SwPageNumberFieldType::ChangeExpansion( SwDoc* pDoc, sal_uInt16 nPage,
// es NIE zurueck
const SfxItemPool &rPool = pDoc->GetAttrPool();
const SwFmtPageDesc *pDesc;
- sal_uInt16 nMaxItems = rPool.GetItemCount( RES_PAGEDESC );
- for( sal_uInt16 n = 0; n < nMaxItems; ++n )
- if( 0 != (pDesc = (SwFmtPageDesc*)rPool.GetItem( RES_PAGEDESC, n ) )
+ sal_uInt32 nMaxItems = rPool.GetItemCount2( RES_PAGEDESC );
+ for( sal_uInt32 n = 0; n < nMaxItems; ++n )
+ if( 0 != (pDesc = (SwFmtPageDesc*)rPool.GetItem2( RES_PAGEDESC, n ) )
&& pDesc->GetNumOffset() && pDesc->GetDefinedIn() )
{
if( pDesc->GetDefinedIn()->ISA( SwCntntNode ))
@@ -1198,30 +1198,30 @@ String SwDocInfoField::Expand() const
/* ---------------------------------------------------------------------------
---------------------------------------------------------------------------*/
-String SwDocInfoField::GetCntnt(sal_Bool bName) const
+String SwDocInfoField::GetFieldName() const
{
- if ( bName )
- {
- String aStr(SwFieldType::GetTypeStr(GetTypeId()));
- aStr += ':';
+ String aStr(SwFieldType::GetTypeStr(GetTypeId()));
+ aStr += ':';
- sal_uInt16 nSub = nSubType & 0xff;
+ sal_uInt16 const nSub = nSubType & 0xff;
- switch(nSub)
- {
- case DI_CUSTOM:
- aStr += aName;
- break;
+ switch (nSub)
+ {
+ case DI_CUSTOM:
+ aStr += aName;
+ break;
- default:
- aStr += *ViewShell::GetShellRes()->aDocInfoLst[ nSub - DI_SUBTYPE_BEGIN ];
- break;
- }
- if( IsFixed() )
- ( aStr += ' ' ) += ViewShell::GetShellRes()->aFixedStr;
- return aStr;
+ default:
+ aStr += *ViewShell::GetShellRes()
+ ->aDocInfoLst[ nSub - DI_SUBTYPE_BEGIN ];
+ break;
}
- return Expand();
+ if (IsFixed())
+ {
+ aStr += ' ';
+ aStr += ViewShell::GetShellRes()->aFixedStr;
+ }
+ return aStr;
}
/* ---------------------------------------------------------------------------
@@ -1517,25 +1517,20 @@ void SwHiddenTxtField::Evaluate(SwDoc* pDoc)
/* ---------------------------------------------------------------------------
---------------------------------------------------------------------------*/
-String SwHiddenTxtField::GetCntnt(sal_Bool bName) const
+String SwHiddenTxtField::GetFieldName() const
{
- if ( bName )
- {
- String aStr(SwFieldType::GetTypeStr(nSubType));
- aStr += ' ';
- aStr += aCond;
- aStr += ' ';
- aStr += aTRUETxt;
+ String aStr(SwFieldType::GetTypeStr(nSubType));
+ aStr += ' ';
+ aStr += aCond;
+ aStr += ' ';
+ aStr += aTRUETxt;
- if(nSubType == TYP_CONDTXTFLD)
- {
-static char __READONLY_DATA cTmp[] = " : ";
- aStr.AppendAscii(cTmp);
- aStr += aFALSETxt;
- }
- return aStr;
+ if (nSubType == TYP_CONDTXTFLD)
+ {
+ aStr.AppendAscii(" : ");
+ aStr += aFALSETxt;
}
- return Expand();
+ return aStr;
}
/* ---------------------------------------------------------------------------
diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx
index 25b0cf932e83..e55c8598cf90 100644
--- a/sw/source/core/fields/expfld.cxx
+++ b/sw/source/core/fields/expfld.cxx
@@ -305,18 +305,15 @@ String SwGetExpField::Expand() const
return sExpand;
}
-String SwGetExpField::GetCntnt(BOOL bName) const
-{
- if ( bName )
- {
- String aStr( SwFieldType::GetTypeStr( static_cast<USHORT>(nsSwGetSetExpType::GSE_FORMULA & nSubType
- ? TYP_FORMELFLD
- : TYP_GETFLD ) ));
- aStr += ' ';
- aStr += GetFormula();
- return aStr;
- }
- return Expand();
+String SwGetExpField::GetFieldName() const
+{
+ String aStr( SwFieldType::GetTypeStr(
+ static_cast<USHORT>(((nsSwGetSetExpType::GSE_FORMULA & nSubType) != 0)
+ ? TYP_FORMELFLD
+ : TYP_GETFLD ) ));
+ aStr += ' ';
+ aStr += GetFormula();
+ return aStr;
}
SwField* SwGetExpField::Copy() const
@@ -834,35 +831,28 @@ String SwSetExpField::Expand() const
}
/*--------------------------------------------------------------------
- Beschreibung: liefert den Namen oder den Inhalt
+ @return the field name
--------------------------------------------------------------------*/
-String SwSetExpField::GetCntnt(BOOL bName) const
+String SwSetExpField::GetFieldName() const
{
- if( bName )
- {
- USHORT nStrType;
-
- if( IsSequenceFld() )
- nStrType = TYP_SEQFLD;
- else if( bInput )
- nStrType = TYP_SETINPFLD;
- else
- nStrType = TYP_SETFLD;
+ SwFldTypesEnum const nStrType( (IsSequenceFld())
+ ? TYP_SEQFLD
+ : (bInput)
+ ? TYP_SETINPFLD
+ : TYP_SETFLD );
- String aStr( SwFieldType::GetTypeStr( nStrType ) );
- aStr += ' ';
- aStr += GetTyp()->GetName();
+ String aStr( SwFieldType::GetTypeStr( static_cast<USHORT>(nStrType) ) );
+ aStr += ' ';
+ aStr += GetTyp()->GetName();
- if( TYP_SEQFLD != nStrType )
- {
- // Sequence nicht die Formel ausgeben
- aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " = " ));
- aStr += GetFormula();
- }
- return aStr;
+ // Sequence: without formula
+ if (TYP_SEQFLD != nStrType)
+ {
+ aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " = " ) );
+ aStr += GetFormula();
}
- return Expand();
+ return aStr;
}
SwField* SwSetExpField::Copy() const
@@ -1021,20 +1011,16 @@ SwInputField::SwInputField(SwInputFieldType* pTyp, const String& rContent,
{
}
-String SwInputField::GetCntnt(BOOL bName) const
+String SwInputField::GetFieldName() const
{
- if ( bName )
+ String aStr(SwField::GetFieldName());
+ if ((nSubType & 0x00ff) == INP_USR)
{
- String aStr(SwField::GetCntnt(bName));
- if ((nSubType & 0x00ff) == INP_USR)
- {
- aStr += GetTyp()->GetName();
- aStr += ' ';
- aStr += aContent;
- }
- return aStr;
+ aStr += GetTyp()->GetName();
+ aStr += ' ';
+ aStr += aContent;
}
- return Expand();
+ return aStr;
}
SwField* SwInputField::Copy() const
diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx
index e35c27d0464b..6ffe675c760a 100644
--- a/sw/source/core/fields/fldbas.cxx
+++ b/sw/source/core/fields/fldbas.cxx
@@ -28,16 +28,12 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
-
-// #include <math.h>
#include <float.h>
#include <rtl/math.hxx>
#include <svl/zforlist.hxx>
#include <svl/zformat.hxx>
#include <editeng/unolingu.hxx>
-#ifndef _UNOFLDMID_H
#include <unofldmid.h>
-#endif
#include <doc.hxx>
#include <editsh.hxx>
#include <frame.hxx>
@@ -53,9 +49,7 @@
#include <expfld.hxx>
#include <shellres.hxx>
#include <calc.hxx>
-#ifndef _COMCORE_HRC
#include <comcore.hrc>
-#endif
#include <math.h>
#include <float.h>
@@ -269,21 +263,20 @@ USHORT SwField::GetTypeId() const
Beschreibung: liefert den Namen oder den Inhalt
--------------------------------------------------------------------*/
-String SwField::GetCntnt( BOOL bName ) const
+String SwField::GetFieldName() const
{
- String sRet;
- if( bName )
+ USHORT nTypeId = GetTypeId();
+ if (RES_DATETIMEFLD == GetTyp()->Which())
{
- USHORT nTypeId = GetTypeId();
- if( RES_DATETIMEFLD == GetTyp()->Which() )
- nTypeId = static_cast<USHORT>(GetSubType() & DATEFLD ? TYP_DATEFLD : TYP_TIMEFLD);
-
- sRet = SwFieldType::GetTypeStr( nTypeId );
- if( IsFixed() )
- ( sRet += ' ' ) += ViewShell::GetShellRes()->aFixedStr;
+ nTypeId = static_cast<USHORT>(
+ ((GetSubType() & DATEFLD) != 0) ? TYP_DATEFLD : TYP_TIMEFLD);
+ }
+ String sRet = SwFieldType::GetTypeStr( nTypeId );
+ if (IsFixed())
+ {
+ sRet += ' ';
+ sRet += ViewShell::GetShellRes()->aFixedStr;
}
- else
- sRet = Expand();
return sRet;
}
@@ -434,9 +427,9 @@ BOOL SwField::IsFixed() const
return bRet;
}
-String SwField::ExpandField(bool const bInClipboard) const
+String SwField::ExpandField(bool const bCached) const
{
- if (!bInClipboard) // #i85766# do not expand fields in clipboard documents
+ if (!bCached) // #i85766# do not expand fields in clipboard documents
{
m_Cache = Expand();
}
@@ -447,7 +440,8 @@ SwField * SwField::CopyField() const
{
SwField *const pNew = Copy();
// #i85766# cache expansion of source (for clipboard)
- pNew->m_Cache = Expand();
+ // use this->cache, not this->Expand(): only text formatting calls Expand()
+ pNew->m_Cache = m_Cache;
return pNew;
}
diff --git a/sw/source/core/fields/macrofld.cxx b/sw/source/core/fields/macrofld.cxx
index 70a0d2dcf689..f77bcf1fd457 100644
--- a/sw/source/core/fields/macrofld.cxx
+++ b/sw/source/core/fields/macrofld.cxx
@@ -28,20 +28,19 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
-
#include <hintids.hxx>
#include <doc.hxx>
#include <docufld.hxx>
-#ifndef _UNOFLDMID_H
#include <unofldmid.h>
-#endif
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/uri/XUriReferenceFactory.hpp>
#include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
#include <comphelper/processfactory.hxx>
+
using namespace ::com::sun::star;
using ::rtl::OUString;
+
/*--------------------------------------------------------------------
Beschreibung: MacroFeldtypen
--------------------------------------------------------------------*/
@@ -79,16 +78,12 @@ SwField* SwMacroField::Copy() const
return new SwMacroField((SwMacroFieldType*)GetTyp(), aMacro, aText);
}
-String SwMacroField::GetCntnt(BOOL bName) const
+String SwMacroField::GetFieldName() const
{
- if(bName)
- {
- String aStr(GetTyp()->GetName());
- aStr += ' ';
- aStr += aMacro;
- return aStr;
- }
- return Expand();
+ String aStr(GetTyp()->GetName());
+ aStr += ' ';
+ aStr += aMacro;
+ return aStr;
}
String SwMacroField::GetLibName() const
diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx
index 8b03b7e54664..1af598eb4e46 100644
--- a/sw/source/core/fields/reffld.cxx
+++ b/sw/source/core/fields/reffld.cxx
@@ -62,18 +62,12 @@
// <--
#include <ftnidx.hxx>
#include <viewsh.hxx>
-#ifndef _UNOFLDMID_H
#include <unofldmid.h>
-#endif
#include <SwStyleNameMapper.hxx>
#include <shellres.hxx>
#include <poolfmt.hxx>
-#ifndef _POOLFMT_HRC
#include <poolfmt.hrc>
-#endif
-#ifndef _COMCORE_HRC
#include <comcore.hrc>
-#endif
#include <numrule.hxx>
#include <SwNodeNum.hxx>
@@ -280,11 +274,8 @@ String SwGetRefField::Expand() const
}
-String SwGetRefField::GetCntnt(BOOL bName) const
+String SwGetRefField::GetFieldName() const
{
- if( !bName )
- return Expand();
-
String aStr(GetTyp()->GetName());
aStr += ' ';
aStr += sSetRefName;
diff --git a/sw/source/core/fields/tblcalc.cxx b/sw/source/core/fields/tblcalc.cxx
index ae340b9a7ba5..abaacf8abc9e 100644
--- a/sw/source/core/fields/tblcalc.cxx
+++ b/sw/source/core/fields/tblcalc.cxx
@@ -37,9 +37,8 @@
#include <txtfld.hxx>
#include <expfld.hxx>
#include <docfld.hxx> // fuer _SetGetExpFld
-#ifndef _UNOFLDMID_H
#include <unofldmid.h>
-#endif
+
using namespace ::com::sun::star;
using ::rtl::OUString;
@@ -91,22 +90,12 @@ SwField* SwTblField::Copy() const
}
-String SwTblField::GetCntnt(BOOL bName) const
+String SwTblField::GetFieldName() const
{
- if( bName )
- {
- String aStr(GetTyp()->GetName());
- aStr += ' ';
-
- USHORT nOldSubType = nSubType;
- SwTblField* pThis = (SwTblField*)this;
- pThis->nSubType |= nsSwExtendedSubType::SUB_CMD;
- aStr += Expand();
- pThis->nSubType = nOldSubType;
-
- return aStr;
- }
- return Expand();
+ String aStr(GetTyp()->GetName());
+ aStr += ' ';
+ aStr += const_cast<SwTblField *>(this)->GetCommand();
+ return aStr;
}
// suche den TextNode, in dem das Feld steht
@@ -127,21 +116,28 @@ const SwNode* SwTblField::GetNodeOfFormula() const
return 0;
}
+String SwTblField::GetCommand()
+{
+ if (EXTRNL_NAME != GetNameType())
+ {
+ SwNode const*const pNd = GetNodeOfFormula();
+ SwTableNode const*const pTblNd = (pNd) ? pNd->FindTableNode() : 0;
+ if (pTblNd)
+ {
+ PtrToBoxNm( &pTblNd->GetTable() );
+ }
+ }
+ return (EXTRNL_NAME == GetNameType())
+ ? SwTableFormula::GetFormula()
+ : String();
+}
String SwTblField::Expand() const
{
String aStr;
if (nSubType & nsSwExtendedSubType::SUB_CMD)
{
- if( EXTRNL_NAME != GetNameType() )
- {
- const SwNode* pNd = GetNodeOfFormula();
- const SwTableNode* pTblNd = pNd ? pNd->FindTableNode() : 0;
- if( pTblNd )
- ((SwTblField*)this)->PtrToBoxNm( &pTblNd->GetTable() );
- }
- if( EXTRNL_NAME == GetNameType() )
- aStr = SwTableFormula::GetFormula();
+ aStr = const_cast<SwTblField *>(this)->GetCommand();
}
else
{
diff --git a/sw/source/core/fields/usrfld.cxx b/sw/source/core/fields/usrfld.cxx
index f9437cd0fbd5..ccb10ca03ee1 100644
--- a/sw/source/core/fields/usrfld.cxx
+++ b/sw/source/core/fields/usrfld.cxx
@@ -40,12 +40,12 @@
#include <doc.hxx>
#include <editsh.hxx>
#include <dpage.hxx>
-#ifndef _UNOFLDMID_H
#include <unofldmid.h>
-#endif
+
using namespace ::com::sun::star;
using ::rtl::OUString;
+
/*--------------------------------------------------------------------
Beschreibung: Benutzerfelder
--------------------------------------------------------------------*/
@@ -72,17 +72,14 @@ SwField* SwUserField::Copy() const
return pTmp;
}
-String SwUserField::GetCntnt(sal_Bool bName) const
+String SwUserField::GetFieldName() const
{
- if ( bName )
- { String aStr(SwFieldType::GetTypeStr(TYP_USERFLD));
- aStr += ' ';
- aStr += GetTyp()->GetName();
- aStr.AppendAscii(" = ");
- aStr += ((SwUserFieldType*)GetTyp())->GetContent();
- return aStr;
- }
- return Expand();
+ String aStr(SwFieldType::GetTypeStr(TYP_USERFLD));
+ aStr += ' ';
+ aStr += GetTyp()->GetName();
+ aStr.AppendAscii(" = ");
+ aStr += static_cast<SwUserFieldType*>(GetTyp())->GetContent();
+ return aStr;
}
double SwUserField::GetValue() const