diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2013-07-14 15:21:18 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-07-16 13:55:41 +0000 |
commit | 263153842741d7ce21cc0bf1c5296a55a1138024 (patch) | |
tree | 6fd3dd47fe08b5caa18e894cd4cb3a55576ff4a6 /sw | |
parent | 6ef38bf1c04de2a0733e5bfd88c483416541d098 (diff) |
String to OUString
Change-Id: I64f31d8a0bb02a2ecd8fcc993c90ca76923b35fb
Reviewed-on: https://gerrit.libreoffice.org/4924
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
37 files changed, 1078 insertions, 1088 deletions
diff --git a/sw/inc/authfld.hxx b/sw/inc/authfld.hxx index 7df89db5f97f..516120b0b4ef 100644 --- a/sw/inc/authfld.hxx +++ b/sw/inc/authfld.hxx @@ -27,16 +27,16 @@ class SwAuthEntry { - String aAuthFields[AUTH_FIELD_END]; + OUString aAuthFields[AUTH_FIELD_END]; sal_uInt16 nRefCount; public: SwAuthEntry() : nRefCount(0){} SwAuthEntry( const SwAuthEntry& rCopy ); sal_Bool operator==(const SwAuthEntry& rComp); - inline const String& GetAuthorField(ToxAuthorityField ePos)const; + inline OUString GetAuthorField(ToxAuthorityField ePos) const; inline void SetAuthorField(ToxAuthorityField ePos, - const String& rField); + const OUString& rField); void AddRef() { ++nRefCount; } void RemoveRef() { --nRefCount; } @@ -67,7 +67,7 @@ class SW_DLLPUBLIC SwAuthorityFieldType : public SwFieldType sal_Bool m_bIsSequence :1; sal_Bool m_bSortByDocument :1; LanguageType m_eLanguage; - String m_sSortAlgorithm; + OUString m_sSortAlgorithm; protected: virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ); @@ -84,7 +84,7 @@ public: inline void SetDoc(SwDoc* pNewDoc) { m_pDoc = pNewDoc; } SwDoc* GetDoc(){ return m_pDoc; } void RemoveField(sal_IntPtr nHandle); - sal_IntPtr AddField(const String& rFieldContents); + sal_IntPtr AddField(const OUString& rFieldContents); sal_Bool AddField(sal_IntPtr nHandle); void DelSequenceArray() { @@ -93,8 +93,8 @@ public: const SwAuthEntry* GetEntryByHandle(sal_IntPtr nHandle) const; - void GetAllEntryIdentifiers( std::vector<String>& rToFill )const; - const SwAuthEntry* GetEntryByIdentifier(const String& rIdentifier)const; + void GetAllEntryIdentifiers( std::vector<OUString>& rToFill ) const; + const SwAuthEntry* GetEntryByIdentifier(const OUString& rIdentifier) const; bool ChangeEntryContent(const SwAuthEntry* pNewEntry); // import interface @@ -130,14 +130,14 @@ public: void SetSortKeys(sal_uInt16 nKeyCount, SwTOXSortKey nKeys[]); //initui.cxx - static const String& GetAuthFieldName(ToxAuthorityField eType); - static const String& GetAuthTypeName(ToxAuthorityType eType); + static OUString GetAuthFieldName(ToxAuthorityField eType); + static OUString GetAuthTypeName(ToxAuthorityType eType); LanguageType GetLanguage() const {return m_eLanguage;} void SetLanguage(LanguageType nLang) {m_eLanguage = nLang;} - const String& GetSortAlgorithm()const {return m_sSortAlgorithm;} - void SetSortAlgorithm(const String& rSet) {m_sSortAlgorithm = rSet;} + OUString GetSortAlgorithm() const {return m_sSortAlgorithm;} + void SetSortAlgorithm(const OUString& rSet) {m_sSortAlgorithm = rSet;} }; @@ -146,15 +146,15 @@ class SwAuthorityField : public SwField sal_IntPtr m_nHandle; mutable sal_IntPtr m_nTempSequencePos; - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; public: - SwAuthorityField(SwAuthorityFieldType* pType, const String& rFieldContents); + SwAuthorityField(SwAuthorityFieldType* pType, const OUString& rFieldContents); SwAuthorityField(SwAuthorityFieldType* pType, sal_IntPtr nHandle); ~SwAuthorityField(); - const String& GetFieldText(ToxAuthorityField eField) const; + OUString GetFieldText(ToxAuthorityField eField) const; virtual void SetPar1(const OUString& rStr); virtual SwFieldType* ChgTyp( SwFieldType* ); @@ -164,16 +164,16 @@ public: sal_IntPtr GetHandle() const { return m_nHandle; } - virtual String GetDescription() const; + virtual OUString GetDescription() const; }; // --- inlines ----------------------------------------------------------- -inline const String& SwAuthEntry::GetAuthorField(ToxAuthorityField ePos)const +inline OUString SwAuthEntry::GetAuthorField(ToxAuthorityField ePos) const { OSL_ENSURE(AUTH_FIELD_END > ePos, "wrong index"); return aAuthFields[ePos]; } -inline void SwAuthEntry::SetAuthorField(ToxAuthorityField ePos, const String& rField) +inline void SwAuthEntry::SetAuthorField(ToxAuthorityField ePos, const OUString& rField) { OSL_ENSURE(AUTH_FIELD_END > ePos, "wrong index"); if(AUTH_FIELD_END > ePos) diff --git a/sw/inc/chpfld.hxx b/sw/inc/chpfld.hxx index 25935787440b..1a87f43e888b 100644 --- a/sw/inc/chpfld.hxx +++ b/sw/inc/chpfld.hxx @@ -51,9 +51,12 @@ class SW_DLLPUBLIC SwChapterField : public SwField { friend class SwChapterFieldType; sal_uInt8 nLevel; - String sTitle, sNumber, sPre, sPost; + OUString sTitle; + OUString sNumber; + OUString sPre; + OUString sPost; - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; public: @@ -68,16 +71,16 @@ public: inline sal_uInt8 GetLevel() const; inline void SetLevel(sal_uInt8); - inline const String& GetNumber() const; - inline const String& GetTitle() const; + inline OUString GetNumber() const; + inline OUString GetTitle() const; virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); }; inline sal_uInt8 SwChapterField::GetLevel() const { return nLevel; } inline void SwChapterField::SetLevel(sal_uInt8 nLev) { nLevel = nLev; } -inline const String& SwChapterField::GetNumber() const { return sNumber; } -inline const String& SwChapterField::GetTitle() const { return sTitle; } +inline OUString SwChapterField::GetNumber() const { return sNumber; } +inline OUString SwChapterField::GetTitle() const { return sTitle; } #endif // SW_CHPFLD_HXX diff --git a/sw/inc/dbfld.hxx b/sw/inc/dbfld.hxx index b4f55a9ee3d7..20d62890c8d2 100644 --- a/sw/inc/dbfld.hxx +++ b/sw/inc/dbfld.hxx @@ -35,21 +35,21 @@ class SW_DLLPUBLIC SwDBFieldType : public SwValueFieldType { SwDBData aDBData; // OUString sName; ///< only used in ::GetName() ! - String sColumn; + OUString sColumn; long nRefCnt; public: - SwDBFieldType(SwDoc* pDocPtr, const String& rColumnName, const SwDBData& rDBData); + SwDBFieldType(SwDoc* pDocPtr, const OUString& rColumnName, const SwDBData& rDBData); ~SwDBFieldType(); - virtual const OUString& GetName() const; + virtual OUString GetName() const; virtual SwFieldType* Copy() const; inline void AddRef() { nRefCnt++; } void ReleaseRef(); - const String& GetColumnName() const {return sColumn;} + OUString GetColumnName() const {return sColumn;} const SwDBData& GetDBData() const {return aDBData;} virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; @@ -70,7 +70,7 @@ class SW_DLLPUBLIC SwDBField : public SwValueField bool bValidValue : 1; bool bInitialized : 1; - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; public: @@ -80,12 +80,12 @@ public: virtual SwFieldType* ChgTyp( SwFieldType* ); /// Current text. - inline void SetExpansion(const String& rStr); + inline void SetExpansion(const OUString& rStr); virtual sal_uInt16 GetSubType() const; virtual void SetSubType(sal_uInt16 nType); - virtual String GetFieldName() const; + virtual OUString GetFieldName() const; /// For calculations in expressions. void ChgValue( double d, bool bVal ); @@ -96,7 +96,7 @@ public: /// Evaluation for header and footer. void ChangeExpansion( const SwFrm*, const SwTxtFld* ); void InitContent(); - void InitContent(const String& rExpansion); + void InitContent(const OUString& rExpansion); inline void ChgBodyTxtFlag( bool bIsInBody ); @@ -105,10 +105,10 @@ public: inline void SetInitialized() { bInitialized = true; } /// Get name. - virtual const OUString& GetPar1() const; + virtual OUString GetPar1() const; /// access to the command string - const OUString& GetFieldCode() const { return sFieldCode;} + OUString GetFieldCode() const { return sFieldCode;} void SetFieldCode(const OUString& rStr) { sFieldCode = rStr; } /// DBName @@ -117,7 +117,7 @@ public: virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); }; -inline void SwDBField::SetExpansion(const String& rStr) +inline void SwDBField::SetExpansion(const OUString& rStr) { aContent = rStr; } /// set from UpdateExpFlds (the Node-Position is known there) @@ -146,7 +146,7 @@ public: SwDBData GetDBData(SwDoc* pDoc); void SetDBData(const SwDBData& rDBData); - virtual String GetFieldName() const; + virtual OUString GetFieldName() const; virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); @@ -177,9 +177,9 @@ class SW_DLLPUBLIC SwDBNextSetField : public SwDBNameInfField public: SwDBNextSetField( SwDBNextSetFieldType*, - const String& rCond, const String& rDummy, const SwDBData& rDBData); + const OUString& rCond, const OUString& rDummy, const SwDBData& rDBData); - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; void Evaluate(SwDoc*); @@ -187,7 +187,7 @@ public: inline bool IsCondValid() const; // Condition - virtual const OUString& GetPar1() const; + virtual OUString GetPar1() const; virtual void SetPar1(const OUString& rStr); virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); @@ -219,13 +219,13 @@ public: class SwDBNumSetField : public SwDBNameInfField { OUString aCond; - String aPar2; + OUString aPar2; bool bCondValid; public: - SwDBNumSetField(SwDBNumSetFieldType*, const String& rCond, const String& rDBNum, const SwDBData& rDBData); + SwDBNumSetField(SwDBNumSetFieldType*, const OUString& rCond, const OUString& rDBNum, const SwDBData& rDBData); - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; inline bool IsCondValid() const; @@ -233,7 +233,7 @@ public: void Evaluate(SwDoc*); // Condition - virtual const OUString& GetPar1() const; + virtual OUString GetPar1() const; virtual void SetPar1(const OUString& rStr); // Number of data record. @@ -261,7 +261,7 @@ class SwDBNameFieldType : public SwFieldType public: SwDBNameFieldType(SwDoc*); - String Expand(sal_uLong) const; + OUString Expand(sal_uLong) const; virtual SwFieldType* Copy() const; }; @@ -274,7 +274,7 @@ class SW_DLLPUBLIC SwDBNameField : public SwDBNameInfField public: SwDBNameField(SwDBNameFieldType*, const SwDBData& rDBData, sal_uLong nFmt = 0); - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); @@ -303,7 +303,7 @@ class SW_DLLPUBLIC SwDBSetNumberField : public SwDBNameInfField public: SwDBSetNumberField(SwDBSetNumberFieldType*, const SwDBData& rDBData, sal_uLong nFmt = 0); - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; void Evaluate(SwDoc*); diff --git a/sw/inc/ddefld.hxx b/sw/inc/ddefld.hxx index 327766077f2b..917d90fbe641 100644 --- a/sw/inc/ddefld.hxx +++ b/sw/inc/ddefld.hxx @@ -32,7 +32,7 @@ class SwDoc; class SW_DLLPUBLIC SwDDEFieldType : public SwFieldType { OUString aName; - String aExpansion; + OUString aExpansion; ::sfx2::SvBaseLinkRef refLink; SwDoc* pDoc; @@ -44,22 +44,22 @@ class SW_DLLPUBLIC SwDDEFieldType : public SwFieldType SW_DLLPRIVATE void _RefCntChgd(); public: - SwDDEFieldType( const String& rName, const String& rCmd, + SwDDEFieldType( const OUString& rName, const OUString& rCmd, sal_uInt16 = sfx2::LINKUPDATE_ONCALL ); ~SwDDEFieldType(); - const String& GetExpansion() const { return aExpansion; } - void SetExpansion( const String& rStr ) { aExpansion = rStr, + OUString GetExpansion() const { return aExpansion; } + void SetExpansion( const OUString& rStr ) { aExpansion = rStr; bCRLFFlag = sal_False; } virtual SwFieldType* Copy() const; - virtual const OUString& GetName() const; + virtual OUString GetName() const; virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); - String GetCmd() const; - void SetCmd( const String& rStr ); + OUString GetCmd() const; + void SetCmd( OUString aStr ); sal_uInt16 GetType() const { return refLink->GetUpdateMode(); } void SetType( sal_uInt16 nType ) { refLink->SetUpdateMode( nType ); } @@ -90,7 +90,7 @@ public: class SwDDEField : public SwField { private: - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; public: @@ -99,7 +99,7 @@ public: /** Get parameter via types. Name cannot be changed. */ - virtual const OUString& GetPar1() const; + virtual OUString GetPar1() const; // Command virtual OUString GetPar2() const; diff --git a/sw/inc/docufld.hxx b/sw/inc/docufld.hxx index 272a6d3bb1c5..529bf14ea8f7 100644 --- a/sw/inc/docufld.hxx +++ b/sw/inc/docufld.hxx @@ -148,8 +148,8 @@ class SwPageNumberFieldType : public SwFieldType public: SwPageNumberFieldType(); - String& Expand( sal_uInt32 nFmt, short nOff, sal_uInt16 const nPageNumber, - sal_uInt16 const nMaxPage, const String&, String& rRet ) const; + OUString Expand( sal_uInt32 nFmt, short nOff, sal_uInt16 const nPageNumber, + sal_uInt16 const nMaxPage, const OUString& ) const; void ChangeExpansion( SwDoc* pDoc, sal_Bool bVirtPageNum, const sal_Int16* pNumFmt = 0 ); virtual SwFieldType* Copy() const; @@ -161,7 +161,7 @@ public: class SW_DLLPUBLIC SwPageNumberField : public SwField { - String sUserStr; + OUString sUserStr; sal_uInt16 nSubType; short nOffset; // fdo#58074 store page number in SwField, not SwFieldType @@ -177,7 +177,7 @@ public: void ChangeExpansion(sal_uInt16 const nPageNumber, sal_uInt16 const nMaxPage); - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; virtual OUString GetPar2() const; @@ -187,8 +187,8 @@ public: virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); - const String& GetUserString() const { return sUserStr; } - void SetUserString( const String& rS ) { sUserStr = rS; } + OUString GetUserString() const { return sUserStr; } + void SetUserString( const OUString& rS ) { sUserStr = rS; } }; /*-------------------------------------------------------------------- @@ -200,7 +200,7 @@ class SwAuthorFieldType : public SwFieldType public: SwAuthorFieldType(); - String Expand(sal_uLong) const; + OUString Expand(sal_uLong) const; virtual SwFieldType* Copy() const; }; @@ -210,16 +210,16 @@ public: class SwAuthorField : public SwField { - String aContent; + OUString aContent; public: SwAuthorField(SwAuthorFieldType*, sal_uInt32 nFmt = 0); - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; - inline void SetExpansion(const String& rStr) { aContent = rStr; } - inline const String& GetContent() const { return aContent; } + inline void SetExpansion(const OUString& rStr) { aContent = rStr; } + inline OUString GetContent() const { return aContent; } virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); @@ -235,7 +235,7 @@ class SwFileNameFieldType : public SwFieldType public: SwFileNameFieldType(SwDoc*); - String Expand(sal_uLong) const; + OUString Expand(sal_uLong) const; virtual SwFieldType* Copy() const; }; @@ -245,16 +245,16 @@ public: class SW_DLLPUBLIC SwFileNameField : public SwField { - String aContent; + OUString aContent; public: SwFileNameField(SwFileNameFieldType*, sal_uInt32 nFmt = 0); - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; - inline void SetExpansion(const String& rStr) { aContent = rStr; } - inline const String& GetContent() const { return aContent; } + inline void SetExpansion(const OUString& rStr) { aContent = rStr; } + inline OUString GetContent() const { return aContent; } virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); @@ -270,7 +270,7 @@ class SwTemplNameFieldType : public SwFieldType public: SwTemplNameFieldType(SwDoc*); - String Expand(sal_uLong) const; + OUString Expand(sal_uLong) const; virtual SwFieldType* Copy() const; }; @@ -283,7 +283,7 @@ class SW_DLLPUBLIC SwTemplNameField : public SwField public: SwTemplNameField(SwTemplNameFieldType*, sal_uInt32 nFmt = 0); - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); @@ -301,7 +301,7 @@ class SwDocStatFieldType : public SwFieldType public: SwDocStatFieldType(SwDoc*); - String Expand(sal_uInt16 nSubType, sal_uInt32 nFmt) const; + OUString Expand(sal_uInt16 nSubType, sal_uInt32 nFmt) const; virtual SwFieldType* Copy() const; inline void SetNumFormat( sal_Int16 eFmt ) { nNumberingType = eFmt; } @@ -321,7 +321,7 @@ public: void ChangeExpansion( const SwFrm* pFrm ); - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; virtual sal_uInt16 GetSubType() const; @@ -363,34 +363,34 @@ class SwHiddenTxtField : public SwField sal_Bool bIsHidden : 1; ///< Is it not visible? sal_Bool bValid : 1; ///< Is DB-field evaluated? - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; public: SwHiddenTxtField( SwHiddenTxtFieldType*, sal_Bool bConditional, - const String& rCond, - const String& rTxt, + const OUString& rCond, + const OUString& rTxt, sal_Bool bHidden = sal_False, sal_uInt16 nSubType = TYP_HIDDENTXTFLD); SwHiddenTxtField( SwHiddenTxtFieldType*, - const String& rCond, - const String& rTrue, - const String& rFalse, + const OUString& rCond, + const OUString& rTrue, + const OUString& rFalse, sal_uInt16 nSubType = TYP_HIDDENTXTFLD); - virtual String GetFieldName() const; + virtual OUString GetFieldName() const; void Evaluate(SwDoc*); inline void SetValue(sal_Bool bHidden) { bIsHidden = bHidden; } - String GetColumnName(const String& rName); - String GetDBName(const String& rName, SwDoc *pDoc); + OUString GetColumnName(const OUString& rName); + OUString GetDBName(const OUString& rName, SwDoc *pDoc); /// Condition virtual void SetPar1(const OUString& rStr); - virtual const OUString& GetPar1() const; + virtual OUString GetPar1() const; /// True/False - String virtual void SetPar2(const OUString& rStr); @@ -425,16 +425,16 @@ class SwHiddenParaField : public SwField sal_Bool bIsHidden:1; public: /// Direct input, delete old value. - SwHiddenParaField(SwHiddenParaFieldType*, const String& rCond); + SwHiddenParaField(SwHiddenParaFieldType*, const OUString& rCond); - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; void SetHidden(sal_Bool bHidden) { bIsHidden = bHidden; } sal_Bool IsHidden() const { return bIsHidden; } /// Query, set condition. - virtual const OUString& GetPar1() const; + virtual OUString GetPar1() const; virtual void SetPar1(const OUString& rStr); virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); @@ -464,24 +464,24 @@ class SW_DLLPUBLIC SwMacroField : public SwField OUString aText; sal_Bool bIsScriptURL; - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; public: /// Direct input, delete old value. - SwMacroField( SwMacroFieldType*, const String& rLibAndName, - const String& rTxt); + SwMacroField( SwMacroFieldType*, const OUString& rLibAndName, + const OUString& rTxt); - inline const OUString& GetMacro() const { return aMacro; } - String GetLibName() const; - String GetMacroName() const; + inline OUString GetMacro() const { return aMacro; } + OUString GetLibName() const; + OUString GetMacroName() const; SvxMacro GetSvxMacro() const; - virtual String GetFieldName() const; + virtual OUString GetFieldName() const; /// Library and FileName - virtual const OUString& GetPar1() const; - virtual void SetPar1(const OUString& rStr); + virtual OUString GetPar1() const; + virtual void SetPar1(const OUString& rStr); /// Macrotext virtual OUString GetPar2() const; @@ -490,10 +490,10 @@ public: virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); static void CreateMacroString( OUString& rMacro, - const String& rMacroName, - const String& rLibraryName ); + const OUString& rMacroName, + const OUString& rLibraryName ); - static sal_Bool isScriptURL( const String& str ); + static sal_Bool isScriptURL( const OUString& str ); }; @@ -528,13 +528,17 @@ class SW_DLLPUBLIC SwPostItField : public SwField public: SwPostItField( SwPostItFieldType*, - const String& rAuthor, const String& rTxt, const String& rInitials, const String& rName, const DateTime& rDate); + const OUString& rAuthor, + const OUString& rTxt, + const OUString& rInitials, + const OUString& rName, + const DateTime& rDate); ~SwPostItField(); /// Looks up a field identified by its unique name (used to get the postit field of a comment fieldmark) static const SwFmtFld* GetByName(SwDoc* pDoc, const OUString& rName); - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; inline const DateTime GetDateTime() const { return aDateTime; } @@ -542,16 +546,16 @@ public: inline const Time GetTime() const { return aDateTime.GetTime(); } /// Author - virtual const OUString& GetPar1() const; + virtual OUString GetPar1() const; virtual void SetPar1(const OUString& rStr); /// Text virtual OUString GetPar2() const; virtual void SetPar2(const OUString& rStr); - const OUString& GetTxt() const { return sTxt; } - const OUString& GetInitials() const; + OUString GetTxt() const { return sTxt; } + OUString GetInitials() const; void SetName(const OUString& rStr); - const OUString& GetName() const; + OUString GetName() const; const OutlinerParaObject* GetTextObject() const; void SetTextObject( OutlinerParaObject* pText ); @@ -560,7 +564,7 @@ public: virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); - virtual String GetDescription() const; + virtual OUString GetDescription() const; }; /*-------------------------------------------------------------------- @@ -572,30 +576,30 @@ class SwDocInfoFieldType : public SwValueFieldType public: SwDocInfoFieldType(SwDoc* pDc); - String Expand(sal_uInt16 nSubType, sal_uInt32 nFormat, sal_uInt16 nLang, const String& rName) const; + OUString Expand(sal_uInt16 nSubType, sal_uInt32 nFormat, sal_uInt16 nLang, const OUString& rName) const; virtual SwFieldType* Copy() const; }; class SW_DLLPUBLIC SwDocInfoField : public SwValueField { sal_uInt16 nSubType; - String aContent; - String aName; + OUString aContent; + OUString aName; - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; public: - SwDocInfoField(SwDocInfoFieldType*, sal_uInt16 nSub, const String& rName, sal_uInt32 nFmt=0); - SwDocInfoField(SwDocInfoFieldType*, sal_uInt16 nSub, const String& rName, const String& rValue, sal_uInt32 nFmt=0); + SwDocInfoField(SwDocInfoFieldType*, sal_uInt16 nSub, const OUString& rName, sal_uInt32 nFmt=0); + SwDocInfoField(SwDocInfoFieldType*, sal_uInt16 nSub, const OUString& rName, const OUString& rValue, sal_uInt32 nFmt=0); virtual void SetSubType(sal_uInt16); virtual sal_uInt16 GetSubType() const; virtual void SetLanguage(sal_uInt16 nLng); - virtual String GetFieldName() const; - String GetName() const { return aName; } - void SetName( const String& rName ) { aName = rName; } - inline void SetExpansion(const String& rStr) { aContent = rStr; } + virtual OUString GetFieldName() const; + OUString GetName() const { return aName; } + void SetName( const OUString& rName ) { aName = rName; } + inline void SetExpansion(const OUString& rStr) { aContent = rStr; } virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); }; @@ -607,31 +611,31 @@ public: class SwExtUserFieldType : public SwFieldType { - String aData; + OUString aData; public: SwExtUserFieldType(); - inline void SetData(const String& rStr) { aData = rStr; } + inline void SetData(const OUString& rStr) { aData = rStr; } - String Expand(sal_uInt16 nSubType, sal_uInt32 nFormat) const; + OUString Expand(sal_uInt16 nSubType, sal_uInt32 nFormat) const; virtual SwFieldType* Copy() const; }; class SwExtUserField : public SwField { - String aContent; + OUString aContent; sal_uInt16 nType; public: SwExtUserField(SwExtUserFieldType*, sal_uInt16 nSub, sal_uInt32 nFmt=0); - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; virtual sal_uInt16 GetSubType() const; virtual void SetSubType(sal_uInt16 nSub); - inline void SetExpansion(const String& rStr) { aContent = rStr; } + inline void SetExpansion(const OUString& rStr) { aContent = rStr; } virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); @@ -667,7 +671,7 @@ public: SwRefPageSetField( SwRefPageSetFieldType*, short nOff = 0, sal_Bool bOn = sal_True ); - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; virtual OUString GetPar2() const; @@ -707,14 +711,14 @@ public: class SwRefPageGetField : public SwField { - String sTxt; + OUString sTxt; public: SwRefPageGetField( SwRefPageGetFieldType*, sal_uInt32 nFmt ); - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; - void SetText( const String& rTxt ) { sTxt = rTxt; } + void SetText( const OUString& rTxt ) { sTxt = rTxt; } void ChangeExpansion( const SwFrm* pFrm, const SwTxtFld* pFld ); virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; @@ -742,13 +746,13 @@ class SwJumpEditField : public SwField OUString sTxt, sHelp; public: SwJumpEditField( SwJumpEditFieldType*, sal_uInt32 nFormat, - const String& sText, const String& sHelp ); + const OUString& sText, const OUString& sHelp ); - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; /// Placeholder-Text - virtual const OUString& GetPar1() const; + virtual OUString GetPar1() const; virtual void SetPar1(const OUString& rStr); /// Hint-Text @@ -787,16 +791,16 @@ class SwScriptField : public SwField sal_Bool bCodeURL; ///< Code contains URL of a script. public: - SwScriptField( SwScriptFieldType*, const String& rType, - const String& rCode, sal_Bool bURL=sal_False ); + SwScriptField( SwScriptFieldType*, const OUString& rType, + const OUString& rCode, sal_Bool bURL=sal_False ); - virtual String GetDescription() const; + virtual OUString GetDescription() const; - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; /// Type - virtual const OUString& GetPar1() const; + virtual OUString GetPar1() const; virtual void SetPar1(const OUString& rStr); /// Text virtual OUString GetPar2() const; @@ -831,13 +835,13 @@ class SW_DLLPUBLIC SwCombinedCharField : public SwField OUString sCharacters; ///< combine these characters public: - SwCombinedCharField( SwCombinedCharFieldType*, const String& rChars ); + SwCombinedCharField( SwCombinedCharFieldType*, const OUString& rChars ); - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; /// Characters - virtual const OUString& GetPar1() const; + virtual OUString GetPar1() const; virtual void SetPar1(const OUString& rStr); virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; diff --git a/sw/inc/expfld.hxx b/sw/inc/expfld.hxx index 8ac6e48fa17c..bca2b0bf19a3 100644 --- a/sw/inc/expfld.hxx +++ b/sw/inc/expfld.hxx @@ -39,14 +39,14 @@ class SwEditShell; const SwTxtNode* GetBodyTxtNode( const SwDoc& pDoc, SwPosition& rPos, const SwFrm& rFrm ); -void ReplacePoint(String& sTmpName, bool bWithCommandType = false); +OUString ReplacePoint(OUString sTmpName, bool bWithCommandType = false); struct _SeqFldLstElem { - String sDlgEntry; + OUString sDlgEntry; sal_uInt16 nSeqNo; - _SeqFldLstElem( const String& rStr, sal_uInt16 nNo ) + _SeqFldLstElem( const OUString& rStr, sal_uInt16 nNo ) : sDlgEntry( rStr ), nSeqNo( nNo ) {} }; @@ -84,24 +84,24 @@ protected: class SW_DLLPUBLIC SwGetExpField : public SwFormulaField { - String sExpand; + OUString sExpand; bool bIsInBodyTxt; sal_uInt16 nSubType; bool bLateInitialization; // #i82544# - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; public: - SwGetExpField( SwGetExpFieldType*, const String& rFormel, + SwGetExpField( SwGetExpFieldType*, const OUString& rFormel, sal_uInt16 nSubType = nsSwGetSetExpType::GSE_EXPR, sal_uLong nFmt = 0); virtual void SetValue( const double& rVal ); virtual void SetLanguage(sal_uInt16 nLng); - inline const String& GetExpStr() const; - inline void ChgExpStr(const String& rExpand); + inline OUString GetExpStr() const; + inline void ChgExpStr(const OUString& rExpand); /// Called by formating. inline bool IsInBodyTxt() const; @@ -113,7 +113,7 @@ public: Only called by formating!! */ void ChangeExpansion( const SwFrm&, const SwTxtFld& ); - virtual String GetFieldName() const; + virtual OUString GetFieldName() const; /// Change formula. virtual OUString GetPar2() const; @@ -129,10 +129,10 @@ public: void SetLateInitialization() { bLateInitialization = true;} }; -inline void SwGetExpField::ChgExpStr(const String& rExpand) +inline void SwGetExpField::ChgExpStr(const OUString& rExpand) { sExpand = rExpand;} -inline const String& SwGetExpField::GetExpStr() const +inline OUString SwGetExpField::GetExpStr() const { return sExpand; } /// Called by formating. @@ -149,7 +149,7 @@ class SW_DLLPUBLIC SwSetExpFieldType : public SwValueFieldType { OUString sName; const SwNode* pOutlChgNd; - String sDelim; + OUString sDelim; sal_uInt16 nType; sal_uInt8 nLevel; sal_Bool bDeleted; @@ -158,10 +158,10 @@ protected: virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ); public: - SwSetExpFieldType( SwDoc* pDoc, const String& rName, + SwSetExpFieldType( SwDoc* pDoc, const OUString& rName, sal_uInt16 nType = nsSwGetSetExpType::GSE_EXPR ); virtual SwFieldType* Copy() const; - virtual const OUString& GetName() const; + virtual OUString GetName() const; inline void SetType(sal_uInt16 nTyp); inline sal_uInt16 GetType() const; @@ -173,16 +173,16 @@ public: void SetDeleted( sal_Bool b ) { bDeleted = b; } /// Overlay, because set-field takes care for its being updated by itself. - inline const OUString& GetSetRefName() const; + inline OUString GetSetRefName() const; sal_uInt16 SetSeqRefNo( SwSetExpField& rFld ); sal_uInt16 GetSeqFldList( SwSeqFldList& rList ); - String MakeSeqName( sal_uInt16 nSeqNo ); + OUString MakeSeqName( sal_uInt16 nSeqNo ); /// Number sequence fields chapterwise if required. - const String& GetDelimiter() const { return sDelim; } - void SetDelimiter( const String& s ) { sDelim = s; } + OUString GetDelimiter() const { return sDelim; } + void SetDelimiter( const OUString& s ) { sDelim = s; } sal_uInt8 GetOutlineLvl() const { return nLevel; } void SetOutlineLvl( sal_uInt8 n ) { nLevel = n; } void SetChapter( SwSetExpField& rFld, const SwNode& rNd ); @@ -205,38 +205,38 @@ inline void SwSetExpFieldType::SetType( sal_uInt16 nTyp ) inline sal_uInt16 SwSetExpFieldType::GetType() const { return nType; } -inline const OUString& SwSetExpFieldType::GetSetRefName() const +inline OUString SwSetExpFieldType::GetSetRefName() const { return sName; } class SW_DLLPUBLIC SwSetExpField : public SwFormulaField { - String sExpand; - String aPText; - String aSeqText; + OUString sExpand; + OUString aPText; + OUString aSeqText; sal_Bool bInput; sal_uInt16 nSeqNo; sal_uInt16 nSubType; - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; public: - SwSetExpField(SwSetExpFieldType*, const String& rFormel, sal_uLong nFmt = 0); + SwSetExpField(SwSetExpFieldType*, const OUString& rFormel, sal_uLong nFmt = 0); virtual void SetValue( const double& rVal ); - inline const String& GetExpStr() const; + inline OUString GetExpStr() const; - inline void ChgExpStr( const String& rExpand ); + inline void ChgExpStr( const OUString& rExpand ); - inline void SetPromptText(const String& rStr); - inline const String& GetPromptText() const; + inline void SetPromptText(const OUString& rStr); + inline OUString GetPromptText() const; inline void SetInputFlag(sal_Bool bInp); inline sal_Bool GetInputFlag() const; - virtual String GetFieldName() const; + virtual OUString GetFieldName() const; virtual sal_uInt16 GetSubType() const; virtual void SetSubType(sal_uInt16 nType); @@ -248,7 +248,7 @@ public: inline sal_uInt16 GetSeqNumber() const { return nSeqNo; } /// Query name only. - virtual const OUString& GetPar1() const; + virtual OUString GetPar1() const; /// Query formula. virtual OUString GetPar2() const; @@ -257,16 +257,16 @@ public: virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); }; -inline const String& SwSetExpField::GetExpStr() const +inline OUString SwSetExpField::GetExpStr() const { return sExpand; } -inline void SwSetExpField::ChgExpStr( const String& rExpand ) +inline void SwSetExpField::ChgExpStr( const OUString& rExpand ) { sExpand = rExpand; } -inline void SwSetExpField::SetPromptText(const String& rStr) +inline void SwSetExpField::SetPromptText(const OUString& rStr) { aPText = rStr; } -inline const String& SwSetExpField::GetPromptText() const +inline OUString SwSetExpField::GetPromptText() const { return aPText; } inline void SwSetExpField::SetInputFlag(sal_Bool bInp) @@ -294,35 +294,35 @@ public: class SW_DLLPUBLIC SwInputField : public SwField { OUString aContent; - String aPText; - String aHelp; - String aToolTip; + OUString aPText; + OUString aHelp; + OUString aToolTip; sal_uInt16 nSubType; - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; public: /// Direct input via dialog; delete old value. - SwInputField(SwInputFieldType*, const String& rContent , - const String& rPrompt, sal_uInt16 nSubType = 0, + SwInputField(SwInputFieldType*, const OUString& rContent, + const OUString& rPrompt, sal_uInt16 nSubType = 0, sal_uLong nFmt = 0); - virtual String GetFieldName() const; + virtual OUString GetFieldName() const; /// Content - virtual const OUString& GetPar1() const; + virtual OUString GetPar1() const; virtual void SetPar1(const OUString& rStr); /// aPromptText virtual OUString GetPar2() const; virtual void SetPar2(const OUString& rStr); - virtual String GetHelp() const; - virtual void SetHelp(const String & rStr); + virtual OUString GetHelp() const; + virtual void SetHelp(const OUString & rStr); - virtual String GetToolTip() const; - virtual void SetToolTip(const String & rStr); + virtual OUString GetToolTip() const; + virtual void SetToolTip(const OUString & rStr); virtual sal_Bool isFormField() const; @@ -373,31 +373,31 @@ public: class SwTblField : public SwValueField, public SwTableFormula { - String sExpand; + OUString sExpand; sal_uInt16 nSubType; - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; /// Search TextNode containing the field. virtual const SwNode* GetNodeOfFormula() const; - String GetCommand(); + OUString GetCommand(); public: - SwTblField( SwTblFieldType*, const String& rFormel, + SwTblField( SwTblFieldType*, const OUString& rFormel, sal_uInt16 nSubType = 0, sal_uLong nFmt = 0); virtual void SetValue( const double& rVal ); virtual sal_uInt16 GetSubType() const; virtual void SetSubType(sal_uInt16 nType); - const String& GetExpStr() const { return sExpand; } - void ChgExpStr(const String& rStr) { sExpand = rStr; } + OUString GetExpStr() const { return sExpand; } + void ChgExpStr(const OUString& rStr) { sExpand = rStr; } void CalcField( SwTblCalcPara& rCalcPara ); - virtual String GetFieldName() const; + virtual OUString GetFieldName() const; /// The formula. virtual OUString GetPar2() const; diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx index 057f9171c87b..e90d81317455 100644 --- a/sw/inc/fldbas.hxx +++ b/sw/inc/fldbas.hxx @@ -20,7 +20,6 @@ #define SW_FLDBAS_HXX #include <i18nlangtag/lang.h> -#include <tools/string.hxx> #include "swdllapi.h" #include <calbck.hxx> #include <com/sun/star/beans/XPropertySet.hpp> @@ -219,9 +218,9 @@ enum SwDateTimeSubType /// General tools. -String GetResult(double nVal, sal_uInt32 nNumFmt, sal_uInt16 nLang = LANGUAGE_SYSTEM); -void SetErrorStr(const String& rStr); -String FormatNumber(sal_uInt32 nNum, sal_uInt32 nFormat); +OUString GetResult(double nVal, sal_uInt32 nNumFmt, sal_uInt16 nLang = LANGUAGE_SYSTEM); +void SetErrorStr(const OUString& rStr); +OUString FormatNumber(sal_uInt32 nNum, sal_uInt32 nFormat); /** Instances of SwFields and those derived from it occur 0 to n times. For each class there is one instance of the associated type class. @@ -235,7 +234,7 @@ class SW_DLLPUBLIC SwFieldType : public SwModify sal_uInt16 nWhich; friend void _FinitUI(); ///< In order to delete pointer! - static std::vector<String>* pFldNames; + static std::vector<OUString>* pFldNames; static void _GetFldName(); ///< Sets up FldNames; fldmgr.cxx! @@ -252,10 +251,10 @@ public: ::com::sun::star::beans::XPropertySet> const& xFieldMaster) { m_wXFieldMaster = xFieldMaster; } - static const String& GetTypeStr( sal_uInt16 nTypeId ); + static OUString GetTypeStr( sal_uInt16 nTypeId ); /// Only in derived classes. - virtual const OUString& GetName() const; + virtual OUString GetName() const; virtual SwFieldType* Copy() const = 0; virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const; virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ); @@ -276,14 +275,14 @@ inline void SwFieldType::UpdateFlds() const class SW_DLLPUBLIC SwField { private: - mutable String m_Cache; ///< Cached expansion (for clipboard). + mutable OUString m_Cache; ///< Cached expansion (for clipboard). sal_uInt16 nLang; ///< Always change via SetLanguage! sal_Bool bIsAutomaticLanguage; sal_uInt32 nFormat; SwFieldType* pType; - virtual String Expand() const = 0; + virtual OUString Expand() const = 0; virtual SwField* Copy() const = 0; protected: @@ -307,10 +306,10 @@ public: SwTxtFormatter::NewFldPortion() sets things up properly. @return the generated text (suitable for display) */ - String ExpandField(bool const bCached) const; + OUString ExpandField(bool const bCached) const; /// @return name or content. - virtual String GetFieldName() const; + virtual OUString GetFieldName() const; SwField * CopyField() const; @@ -333,10 +332,10 @@ public: /// Query parameters for dialog and for BASIC. inline sal_uInt32 GetFormat() const; - virtual const OUString& GetPar1() const; - virtual OUString GetPar2() const; + virtual OUString GetPar1() const; + virtual OUString GetPar2() const; - virtual String GetFormula() const; + virtual OUString GetFormula() const; virtual void ChangeFormat(sal_uInt32 n); virtual void SetPar1(const OUString& rStr); @@ -352,7 +351,7 @@ public: sal_Bool IsAutomaticLanguage() const { return bIsAutomaticLanguage;} void SetAutomaticLanguage(sal_Bool bSet){bIsAutomaticLanguage = bSet;} - virtual String GetDescription() const; + virtual OUString GetDescription() const; /// Is this field clickable? bool IsClickable() const; }; @@ -384,9 +383,9 @@ public: inline sal_Bool UseFormat() const { return bUseFormat; } inline void EnableFormat(sal_Bool bFormat = sal_True) { bUseFormat = bFormat; } - String ExpandValue(const double& rVal, sal_uInt32 nFmt, sal_uInt16 nLng=0) const; - String DoubleToString(const double &rVal, LanguageType eLng) const; - String DoubleToString(const double &rVal, sal_uInt32 nFmt) const; + OUString ExpandValue(const double& rVal, sal_uInt32 nFmt, sal_uInt16 nLng=0) const; + OUString DoubleToString(const double &rVal, LanguageType eLng) const; + OUString DoubleToString(const double &rVal, sal_uInt32 nFmt) const; }; class SW_DLLPUBLIC SwValueField : public SwField @@ -408,7 +407,7 @@ public: virtual double GetValue() const; virtual void SetValue( const double& rVal ); - inline String ExpandValue(const double& rVal, sal_uInt32 nFmt, sal_uInt16 nLng=0) const + inline OUString ExpandValue(const double& rVal, sal_uInt32 nFmt, sal_uInt16 nLng=0) const { return ((SwValueFieldType*)GetTyp())->ExpandValue(rVal, nFmt, nLng); } static sal_uInt32 GetSystemFormat(SvNumberFormatter* pFormatter, sal_uInt32 nFmt); @@ -416,18 +415,18 @@ public: class SW_DLLPUBLIC SwFormulaField : public SwValueField { - String sFormula; + OUString sFormula; protected: SwFormulaField( SwValueFieldType* pFldType, sal_uInt32 nFmt = 0, const double fVal = 0.0 ); SwFormulaField( const SwFormulaField& rFld ); public: - virtual String GetFormula() const; - void SetFormula(const String& rStr); + virtual OUString GetFormula() const; + void SetFormula(const OUString& rStr); - void SetExpandedFormula(const String& rStr); - String GetExpandedFormula() const; + void SetExpandedFormula(const OUString& rStr); + OUString GetExpandedFormula() const; }; #endif // SW_FLDBAS_HXX diff --git a/sw/inc/flddat.hxx b/sw/inc/flddat.hxx index ccf8885a0f00..ea2c2cfaeb63 100644 --- a/sw/inc/flddat.hxx +++ b/sw/inc/flddat.hxx @@ -20,8 +20,6 @@ #ifndef SW_FLDDAT_HXX #define SW_FLDDAT_HXX -#include <tools/string.hxx> - #include "fldbas.hxx" class DateTime; @@ -98,7 +96,7 @@ class SW_DLLPUBLIC SwDateTimeField : public SwValueField sal_uInt16 nSubType; long nOffset; // Offset in minutes. - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; public: diff --git a/sw/inc/flddropdown.hxx b/sw/inc/flddropdown.hxx index 57d4ee25d5e2..bf943a169502 100644 --- a/sw/inc/flddropdown.hxx +++ b/sw/inc/flddropdown.hxx @@ -90,7 +90,7 @@ class SW_DLLPUBLIC SwDropDownField : public SwField @return the expanded value of the field */ - virtual String Expand() const; + virtual OUString Expand() const; /** Creates a copy of this field. @@ -126,7 +126,7 @@ public: @return the selected value */ - virtual const OUString & GetPar1() const; + virtual OUString GetPar1() const; /** Returns the name of the field. @@ -181,28 +181,28 @@ public: @return the selected item */ - const OUString & GetSelectedItem() const; + OUString GetSelectedItem() const; /** Returns the name of the field. @return the name of the field */ - const OUString & GetName() const; + OUString GetName() const; /** Returns the help text of the field. @return the help text of the field */ - const OUString & GetHelp() const; + OUString GetHelp() const; /** Returns the tool tip of the field. @return the tool tip of the field */ - const OUString & GetToolTip() const; + OUString GetToolTip() const; /** Sets the selected item. diff --git a/sw/inc/reffld.hxx b/sw/inc/reffld.hxx index 9550de42539c..620190782307 100644 --- a/sw/inc/reffld.hxx +++ b/sw/inc/reffld.hxx @@ -72,7 +72,7 @@ public: void MergeWithOtherDoc( SwDoc& rDestDoc ); - static SwTxtNode* FindAnchor( SwDoc* pDoc, const String& rRefMark, + static SwTxtNode* FindAnchor( SwDoc* pDoc, const OUString& rRefMark, sal_uInt16 nSubType, sal_uInt16 nSeqNo, sal_uInt16* pStt, sal_uInt16* pEnd = 0 ); }; @@ -82,27 +82,27 @@ class SW_DLLPUBLIC SwGetRefField : public SwField { private: OUString sSetRefName; - String sTxt; + OUString sTxt; sal_uInt16 nSubType; sal_uInt16 nSeqNo; - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; // #i81002# - String MakeRefNumStr( const SwTxtNode& rTxtNodeOfField, + OUString MakeRefNumStr( const SwTxtNode& rTxtNodeOfField, const SwTxtNode& rTxtNodeOfReferencedItem, const sal_uInt32 nRefNumFormat ) const; public: - SwGetRefField( SwGetRefFieldType*, const String& rSetRef, + SwGetRefField( SwGetRefFieldType*, const OUString& rSetRef, sal_uInt16 nSubType, sal_uInt16 nSeqNo, sal_uLong nFmt ); virtual ~SwGetRefField(); - virtual String GetFieldName() const; + virtual OUString GetFieldName() const; - const OUString& GetSetRefName() const { return sSetRefName; } + OUString GetSetRefName() const { return sSetRefName; } // #i81002# /** The <SwTxtFld> instance, which represents the text attribute for the @@ -113,7 +113,7 @@ public: no update for these reference format types. */ void UpdateField( const SwTxtFld* pFldTxtAttr ); - void SetExpand( const String& rStr ) { sTxt = rStr; } + void SetExpand( const OUString& rStr ) { sTxt = rStr; } /// Get/set sub type. virtual sal_uInt16 GetSubType() const; @@ -124,7 +124,7 @@ public: bool IsRefToNumItemCrossRefBookmark() const; const SwTxtNode* GetReferencedTxtNode() const; // #i85090# - String GetExpandedTxtOfReferencedTxtNode() const; + OUString GetExpandedTxtOfReferencedTxtNode() const; /// Get/set SequenceNo (of interest only for REF_SEQUENCEFLD). @@ -132,7 +132,7 @@ public: void SetSeqNo( sal_uInt16 n ) { nSeqNo = n; } // Name of reference. - virtual const OUString& GetPar1() const; + virtual OUString GetPar1() const; virtual void SetPar1(const OUString& rStr); virtual OUString GetPar2() const; @@ -141,7 +141,7 @@ public: void ConvertProgrammaticToUIName(); - virtual String GetDescription() const; + virtual OUString GetDescription() const; }; diff --git a/sw/inc/usrfld.hxx b/sw/inc/usrfld.hxx index 85fe469775a7..f529c32f2b2c 100644 --- a/sw/inc/usrfld.hxx +++ b/sw/inc/usrfld.hxx @@ -33,19 +33,19 @@ class SW_DLLPUBLIC SwUserFieldType : public SwValueFieldType bool bDeleted : 1; double nValue; OUString aName; - String aContent; + OUString aContent; sal_uInt16 nType; public: - SwUserFieldType( SwDoc* pDocPtr, const String& ); + SwUserFieldType( SwDoc* pDocPtr, const OUString& ); - virtual const OUString& GetName() const; + virtual OUString GetName() const; virtual SwFieldType* Copy() const; - String Expand(sal_uInt32 nFmt, sal_uInt16 nSubType, sal_uInt16 nLng); + OUString Expand(sal_uInt32 nFmt, sal_uInt16 nSubType, sal_uInt16 nLng); - String GetContent( sal_uInt32 nFmt = 0 ); - void SetContent( const String& rStr, sal_uInt32 nFmt = 0 ); + OUString GetContent( sal_uInt32 nFmt = 0 ); + void SetContent( const OUString& rStr, sal_uInt32 nFmt = 0 ); inline bool IsValid() const; inline void ChgValid( bool bNew ); @@ -93,7 +93,7 @@ class SW_DLLPUBLIC SwUserField : public SwValueField { sal_uInt16 nSubType; - virtual String Expand() const; + virtual OUString Expand() const; virtual SwField* Copy() const; public: @@ -105,10 +105,10 @@ public: virtual double GetValue() const; virtual void SetValue( const double& rVal ); - virtual String GetFieldName() const; + virtual OUString GetFieldName() const; // Name cannot be changed. - virtual const OUString& GetPar1() const; + virtual OUString GetPar1() const; // Content. virtual OUString GetPar2() const; diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx index 6f56e120f50a..8439cffdc13d 100644 --- a/sw/source/core/crsr/findtxt.cxx +++ b/sw/source/core/crsr/findtxt.cxx @@ -134,8 +134,8 @@ static String& lcl_CleanStr( const SwTxtNode& rNd, xub_StrLen nStart, xub_StrLen // replacement and remove afterwards all at a string's // end (might be normal 0x7f). bool bEmpty = RES_TXTATR_FIELD != pHt->Which() || - !(static_cast<SwTxtFld const*>(pHt) - ->GetFld().GetFld()->ExpandField(true).Len()); + (static_cast<SwTxtFld const*>(pHt) + ->GetFld().GetFld()->ExpandField(true).isEmpty()); if ( bEmpty && nStart == nAkt ) { rArr.push_back( nAkt ); diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index a78a59289742..bb7db008fd34 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -984,15 +984,14 @@ _HashStr::_HashStr( const String& rName, const String& rText, } /// Look up the Name, if it is present, return it's String, otherwise return an empty String -void LookString( SwHash** ppTbl, sal_uInt16 nSize, const String& rName, - String& rRet, sal_uInt16* pPos ) +OUString LookString( SwHash** ppTbl, sal_uInt16 nSize, const OUString& rName, + sal_uInt16* pPos ) { - rRet = comphelper::string::strip(rName, ' '); - SwHash* pFnd = Find( rRet, ppTbl, nSize, pPos ); + SwHash* pFnd = Find( comphelper::string::strip(rName, ' '), ppTbl, nSize, pPos ); if( pFnd ) - rRet = ((_HashStr*)pFnd)->aSetStr; - else - rRet.Erase(); + return ((_HashStr*)pFnd)->aSetStr; + + return OUString(); } static String lcl_GetDBVarName( SwDoc& rDoc, SwDBNameInfField& rDBFld ) @@ -1145,8 +1144,7 @@ void SwDoc::FldsToExpand( SwHash**& ppHashTbl, sal_uInt16& rTblSize, // set the new value in the hash table // is the formula a field? SwSetExpField* pSFld = (SwSetExpField*)pFld; - String aNew; - LookString( ppHashTbl, rTblSize, pSFld->GetFormula(), aNew ); + String aNew = LookString( ppHashTbl, rTblSize, pSFld->GetFormula() ); if( !aNew.Len() ) // nothing found, then the formula is aNew = pSFld->GetFormula(); // the new value @@ -1392,8 +1390,8 @@ void SwDoc::UpdateExpFlds( SwTxtFld* pUpdtFld, bool bUpdRefFlds ) if( (!pUpdtFld || pUpdtFld == pTxtFld ) && pGFld->IsInBodyTxt() ) { - LookString( pHashStrTbl, nStrFmtCnt, - pGFld->GetFormula(), aNew ); + aNew = LookString( pHashStrTbl, nStrFmtCnt, + pGFld->GetFormula() ); pGFld->ChgExpStr( aNew ); } } @@ -1401,8 +1399,8 @@ void SwDoc::UpdateExpFlds( SwTxtFld* pUpdtFld, bool bUpdRefFlds ) { SwSetExpField* pSFld = (SwSetExpField*)pFld; // is the "formula" a field? - LookString( pHashStrTbl, nStrFmtCnt, - pSFld->GetFormula(), aNew ); + aNew = LookString( pHashStrTbl, nStrFmtCnt, + pSFld->GetFormula() ); if( !aNew.Len() ) // nothing found then the formula is the new value aNew = pSFld->GetFormula(); @@ -2261,11 +2259,11 @@ void SwDocUpdtFld::_MakeFldList( SwDoc& rDoc, int eGetMode ) } } - OUString sTrue("TRUE"), sFalse("FALSE"); + const OUString sTrue("TRUE"); + const OUString sFalse("FALSE"); bool bIsDBMgr = 0 != rDoc.GetNewDBMgr(); sal_uInt16 nWhich, n; - const OUString* pFormel = 0; const SfxPoolItem* pItem; sal_uInt32 nMaxItems = rDoc.GetAttrPool().GetItemCount2( RES_TXTATR_FIELD ); for( n = 0; n < nMaxItems; ++n ) @@ -2278,40 +2276,41 @@ void SwDocUpdtFld::_MakeFldList( SwDoc& rDoc, int eGetMode ) if( !pTxtFld || !pTxtFld->GetTxtNode().GetNodes().IsDocNodes() ) continue; + OUString sFormel; const SwField* pFld = pFmtFld->GetFld(); switch( nWhich = pFld->GetTyp()->Which() ) { case RES_DBSETNUMBERFLD: case RES_GETEXPFLD: if( GETFLD_ALL == eGetMode ) - pFormel = &sTrue; + sFormel = sTrue; break; case RES_DBFLD: if( GETFLD_EXPAND & eGetMode ) - pFormel = &sTrue; + sFormel = sTrue; break; case RES_SETEXPFLD: if ( !(eGetMode == GETFLD_EXPAND) || (nsSwGetSetExpType::GSE_STRING & pFld->GetSubType()) ) { - pFormel = &sTrue; + sFormel = sTrue; } break; case RES_HIDDENPARAFLD: if( GETFLD_ALL == eGetMode ) { - pFormel = &pFld->GetPar1(); - if (pFormel->isEmpty() || pFormel->equals(sFalse)) + sFormel = pFld->GetPar1(); + if (sFormel.isEmpty() || sFormel==sFalse) ((SwHiddenParaField*)pFld)->SetHidden( sal_False ); - else if (pFormel->equals(sTrue)) + else if (sFormel==sTrue) ((SwHiddenParaField*)pFld)->SetHidden( sal_True ); else break; - pFormel = 0; + sFormel = OUString(); // trigger formatting ((SwFmtFld*)pFmtFld)->ModifyNotification( 0, 0 ); } @@ -2320,15 +2319,15 @@ void SwDocUpdtFld::_MakeFldList( SwDoc& rDoc, int eGetMode ) case RES_HIDDENTXTFLD: if( GETFLD_ALL == eGetMode ) { - pFormel = &pFld->GetPar1(); - if (pFormel->isEmpty() || pFormel->equals(sFalse)) + sFormel = pFld->GetPar1(); + if (sFormel.isEmpty() || sFormel==sFalse) ((SwHiddenTxtField*)pFld)->SetValue( sal_True ); - else if (pFormel->equals(sTrue)) + else if (sFormel==sTrue) ((SwHiddenTxtField*)pFld)->SetValue( sal_False ); else break; - pFormel = 0; + sFormel = OUString(); // evaluate field ((SwHiddenTxtField*)pFld)->Evaluate(&rDoc); @@ -2346,7 +2345,7 @@ void SwDocUpdtFld::_MakeFldList( SwDoc& rDoc, int eGetMode ) (GETFLD_ALL == eGetMode || (GETFLD_CALC & eGetMode && ((SwDBNumSetField*)pFld)->IsCondValid())) ) { - pFormel = &pFld->GetPar1(); + sFormel = pFld->GetPar1(); } } break; @@ -2359,16 +2358,15 @@ void SwDocUpdtFld::_MakeFldList( SwDoc& rDoc, int eGetMode ) (GETFLD_ALL == eGetMode || (GETFLD_CALC & eGetMode && ((SwDBNextSetField*)pFld)->IsCondValid())) ) { - pFormel = &pFld->GetPar1(); + sFormel = pFld->GetPar1(); } } break; } - if (pFormel && !pFormel->isEmpty()) + if (!sFormel.isEmpty()) { GetBodyNode( *pTxtFld, nWhich ); - pFormel = 0; } } nFldLstGetMode = static_cast<sal_uInt8>( eGetMode ); diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx index 74b58a50c44e..1133863f2364 100644 --- a/sw/source/core/edit/edattr.cxx +++ b/sw/source/core/edit/edattr.cxx @@ -346,15 +346,15 @@ sal_uInt16 SwEditShell::GetSeqFtnList( SwSeqFldList& rList, bool bEndNotes ) if( pTxtNd ) { - String sTxt( rFtn.GetViewNumStr( *mpDoc )); - if( sTxt.Len() ) - sTxt += ' '; + OUString sTxt( rFtn.GetViewNumStr( *mpDoc )); + if( !sTxt.isEmpty() ) + sTxt += " "; sTxt += pTxtNd->GetExpandTxt( 0, USHRT_MAX ); _SeqFldLstElem* pNew = new _SeqFldLstElem( sTxt, pTxtFtn->GetSeqRefNo() ); while( rList.InsertSort( pNew ) ) - pNew->sDlgEntry += ' '; + pNew->sDlgEntry += " "; } } } diff --git a/sw/source/core/fields/authfld.cxx b/sw/source/core/fields/authfld.cxx index d1fbe7965e7e..3d13d603301d 100644 --- a/sw/source/core/fields/authfld.cxx +++ b/sw/source/core/fields/authfld.cxx @@ -110,13 +110,13 @@ void SwAuthorityFieldType::RemoveField(sal_IntPtr nHandle) #endif } -sal_IntPtr SwAuthorityFieldType::AddField(const String& rFieldContents) +sal_IntPtr SwAuthorityFieldType::AddField(const OUString& rFieldContents) { sal_IntPtr nRet = 0; SwAuthEntry* pEntry = new SwAuthEntry; for( sal_uInt16 i = 0; i < AUTH_FIELD_END; ++i ) pEntry->SetAuthorField( (ToxAuthorityField)i, - rFieldContents.GetToken( i, TOX_STYLE_DELIMITER )); + rFieldContents.getToken( i, TOX_STYLE_DELIMITER )); for(sal_uInt16 j = 0; j < m_DataArr.size() && pEntry; j++) { @@ -178,7 +178,7 @@ const SwAuthEntry* SwAuthorityFieldType::GetEntryByHandle(sal_IntPtr nHandle) c } void SwAuthorityFieldType::GetAllEntryIdentifiers( - std::vector<String>& rToFill )const + std::vector<OUString>& rToFill )const { for(sal_uInt16 j = 0; j < m_DataArr.size(); j++) { @@ -188,7 +188,7 @@ void SwAuthorityFieldType::GetAllEntryIdentifiers( } const SwAuthEntry* SwAuthorityFieldType::GetEntryByIdentifier( - const String& rIdentifier)const + const OUString& rIdentifier)const { const SwAuthEntry* pRet = 0; for( sal_uInt16 j = 0; j < m_DataArr.size(); ++j ) @@ -373,7 +373,7 @@ bool SwAuthorityFieldType::QueryValue( Any& rVal, sal_uInt16 nWhichId ) const } break; case FIELD_PROP_PAR3: - rVal <<= OUString(GetSortAlgorithm()); + rVal <<= GetSortAlgorithm(); break; case FIELD_PROP_BOOL1: @@ -416,14 +416,14 @@ bool SwAuthorityFieldType::QueryValue( Any& rVal, sal_uInt16 nWhichId ) const bool SwAuthorityFieldType::PutValue( const Any& rAny, sal_uInt16 nWhichId ) { bool bRet = true; - String sTmp; switch( nWhichId ) { case FIELD_PROP_PAR1: case FIELD_PROP_PAR2: { - ::GetString( rAny, sTmp ); - sal_Unicode uSet = sTmp.GetChar(0); + OUString sTmp; + rAny >>= sTmp; + const sal_Unicode uSet = !sTmp.isEmpty() ? sTmp[0] : 0; if( FIELD_PROP_PAR1 == nWhichId ) m_cPrefix = uSet; else @@ -431,9 +431,12 @@ bool SwAuthorityFieldType::PutValue( const Any& rAny, sal_uInt16 nWhichId ) } break; case FIELD_PROP_PAR3: - SetSortAlgorithm( ::GetString( rAny, sTmp )); + { + OUString sTmp; + rAny >>= sTmp; + SetSortAlgorithm(sTmp); break; - + } case FIELD_PROP_BOOL1: m_bIsSequence = *(sal_Bool*)rAny.getValue(); break; @@ -516,7 +519,7 @@ void SwAuthorityFieldType::SetSortKeys(sal_uInt16 nKeyCount, SwTOXSortKey aKeys[ } SwAuthorityField::SwAuthorityField( SwAuthorityFieldType* pInitType, - const String& rFieldContents ) + const OUString& rFieldContents ) : SwField(pInitType), m_nTempSequencePos( -1 ) { @@ -537,12 +540,12 @@ SwAuthorityField::~SwAuthorityField() ((SwAuthorityFieldType* )GetTyp())->RemoveField(m_nHandle); } -String SwAuthorityField::Expand() const +OUString SwAuthorityField::Expand() const { SwAuthorityFieldType* pAuthType = (SwAuthorityFieldType*)GetTyp(); - String sRet; + OUString sRet; if(pAuthType->GetPrefix()) - sRet.Assign(pAuthType->GetPrefix()); + sRet = OUString(pAuthType->GetPrefix()); if( pAuthType->IsSequence() ) { @@ -559,7 +562,7 @@ String SwAuthorityField::Expand() const sRet += pEntry->GetAuthorField(AUTH_FIELD_IDENTIFIER); } if(pAuthType->GetSuffix()) - sRet += pAuthType->GetSuffix(); + sRet += OUString(pAuthType->GetSuffix()); return sRet; } @@ -569,7 +572,7 @@ SwField* SwAuthorityField::Copy() const return new SwAuthorityField(pAuthType, m_nHandle); } -const String& SwAuthorityField::GetFieldText(ToxAuthorityField eField) const +OUString SwAuthorityField::GetFieldText(ToxAuthorityField eField) const { SwAuthorityFieldType* pAuthType = (SwAuthorityFieldType*)GetTyp(); const SwAuthEntry* pEntry = pAuthType->GetEntryByHandle( m_nHandle ); @@ -583,7 +586,7 @@ void SwAuthorityField::SetPar1(const OUString& rStr) m_nHandle = pInitType->AddField(rStr); } -String SwAuthorityField::GetDescription() const +OUString SwAuthorityField::GetDescription() const { return SW_RES(STR_AUTHORITY_ENTRY); } @@ -635,11 +638,11 @@ bool SwAuthorityField::QueryValue( Any& rAny, sal_uInt16 /*nWhichId*/ ) const for(sal_Int16 i = 0; i < AUTH_FIELD_END; i++) { pValues[i].Name = OUString::createFromAscii(aFieldNames[i]); - const String& rField = pAuthEntry->GetAuthorField((ToxAuthorityField) i); + const OUString sField = pAuthEntry->GetAuthorField((ToxAuthorityField) i); if(i == AUTH_FIELD_AUTHORITY_TYPE) - pValues[i].Value <<= sal_Int16(rField.ToInt32()); + pValues[i].Value <<= sal_Int16(sField.toInt32()); else - pValues[i].Value <<= OUString(rField); + pValues[i].Value <<= sField; } rAny <<= aRet; /* FIXME: it is weird that we always return false here */ diff --git a/sw/source/core/fields/chpfld.cxx b/sw/source/core/fields/chpfld.cxx index e469c574ff72..ddda6c4c1dc7 100644 --- a/sw/source/core/fields/chpfld.cxx +++ b/sw/source/core/fields/chpfld.cxx @@ -29,6 +29,28 @@ using namespace ::com::sun::star; +namespace +{ + +OUString removeControlChars(OUString sIn) +{ + OUStringBuffer aBuf(sIn); + sal_Int32 nLen = aBuf.getLength(); + for (sal_Int32 i = 0; i < nLen; ++i) + { + if (aBuf[i] < ' ') + { + sal_Int32 j = i+1; + while (j<nLen && aBuf[j]<' ') ++j; + aBuf.remove(i, j-i); + nLen = aBuf.getLength(); + } + } + return aBuf.makeStringAndClear(); +} + +} + // SwChapterFieldType SwChapterFieldType::SwChapterFieldType() @@ -47,23 +69,21 @@ SwChapterField::SwChapterField(SwChapterFieldType* pTyp, sal_uInt32 nFmt) : SwField(pTyp, nFmt), nLevel( 0 ) {} -String SwChapterField::Expand() const +OUString SwChapterField::Expand() const { - String sStr( sNumber ); switch( GetFormat() ) { - case CF_TITLE: sStr = sTitle; break; - + case CF_TITLE: + return sTitle; case CF_NUMBER: - case CF_NUM_TITLE: sStr.Insert( sPre, 0 ); - sStr += sPost; - if( CF_NUM_TITLE == GetFormat() ) - sStr += sTitle; - break; - - case CF_NUM_NOPREPST_TITLE: sStr += sTitle; break; + return sPre + sNumber + sPost; + case CF_NUM_TITLE: + return sPre + sNumber + sPost + sTitle; + case CF_NUM_NOPREPST_TITLE: + return sNumber + sTitle; } - return sStr; + // CF_NUMBER_NOPREPST + return sNumber; } SwField* SwChapterField::Copy() const @@ -104,10 +124,10 @@ void SwChapterField::ChangeExpansion(const SwTxtNode &rTxtNd, sal_Bool bSrchNum) { //i120759,this function is for both the reference chapter field and normal chapter field //bSrchNum can distinguish the two types,to the latter type,the outline num rule is must... - sNumber = aEmptyStr; - sTitle = aEmptyStr; - sPost = aEmptyStr; - sPre = aEmptyStr; + sNumber = OUString(); + sTitle = OUString(); + sPost = OUString(); + sPre = OUString(); //The reference chapter field of normal num rule will be handled in this code segment if (bSrchNum && !rTxtNd.IsOutline()) { @@ -121,13 +141,9 @@ void SwChapterField::ChangeExpansion(const SwTxtNode &rTxtNd, sal_Bool bSrchNum) } else { - sNumber = String("??", RTL_TEXTENCODING_ASCII_US); + sNumber = "??"; } - sTitle = rTxtNd.GetExpandTxt(); - - for( xub_StrLen i = 0; i < sTitle.Len(); ++i ) - if( ' ' > sTitle.GetChar( i ) ) - sTitle.Erase( i--, 1 ); + sTitle = removeControlChars(rTxtNd.GetExpandTxt()); } else { @@ -185,14 +201,11 @@ void SwChapterField::ChangeExpansion(const SwTxtNode &rTxtNd, sal_Bool bSrchNum) } else { - sNumber = String("??", RTL_TEXTENCODING_ASCII_US); + sNumber = "??"; } - sTitle = pTxtNd->GetExpandTxt(); + sTitle = removeControlChars(pTxtNd->GetExpandTxt()); - for( xub_StrLen i = 0; i < sTitle.Len(); ++i ) - if( ' ' > sTitle.GetChar( i ) ) - sTitle.Erase( i--, 1 ); } } } diff --git a/sw/source/core/fields/dbfld.cxx b/sw/source/core/fields/dbfld.cxx index f3e81116d302..8b7d7e085326 100644 --- a/sw/source/core/fields/dbfld.cxx +++ b/sw/source/core/fields/dbfld.cxx @@ -43,30 +43,28 @@ using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star; /// replace database separator by dots for display -static String lcl_DBTrennConv(const String& aContent) +static OUString lcl_DBTrennConv(const OUString& aContent) { - String sTmp(aContent); - sal_Unicode* pStr = sTmp.GetBufferAccess(); - for( sal_uInt16 i = sTmp.Len(); i; --i, ++pStr ) - if( DB_DELIM == *pStr ) - *pStr = '.'; - return sTmp; + return aContent.replaceAll(OUString(DB_DELIM), OUString('.')); } // database field type -SwDBFieldType::SwDBFieldType(SwDoc* pDocPtr, const String& rNam, const SwDBData& rDBData ) : +SwDBFieldType::SwDBFieldType(SwDoc* pDocPtr, const OUString& rNam, const SwDBData& rDBData ) : SwValueFieldType( pDocPtr, RES_DBFLD ), aDBData(rDBData), + sName(rNam), sColumn(rNam), nRefCnt(0) { if(!aDBData.sDataSource.isEmpty() || !aDBData.sCommand.isEmpty()) { - sName = OUStringBuffer(aDBData.sDataSource).append(DB_DELIM). - append(aDBData.sCommand).append(DB_DELIM).makeStringAndClear(); + sName = aDBData.sDataSource + + OUString(DB_DELIM) + + aDBData.sCommand + + OUString(DB_DELIM) + + sName; } - sName += GetColumnName(); } SwDBFieldType::~SwDBFieldType() @@ -79,7 +77,7 @@ SwFieldType* SwDBFieldType::Copy() const return pTmp; } -const OUString& SwDBFieldType::GetName() const +OUString SwDBFieldType::GetName() const { return sName; } @@ -111,7 +109,7 @@ bool SwDBFieldType::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const rAny <<= aDBData.sCommand; break; case FIELD_PROP_PAR3: - rAny <<= OUString(sColumn); + rAny <<= sColumn; break; case FIELD_PROP_SHORT1: rAny <<= aDBData.nCommandType; @@ -134,8 +132,8 @@ bool SwDBFieldType::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) break; case FIELD_PROP_PAR3: { - String sTmp; - ::GetString( rAny, sTmp ); + OUString sTmp; + rAny >>= sTmp; if( sTmp != sColumn ) { sColumn = sTmp; @@ -150,7 +148,7 @@ bool SwDBFieldType::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) SwDBField* pDBField = (SwDBField*)pFld->GetFld(); pDBField->ClearInitialized(); pDBField->InitContent(); - } + } pFld = aIter.Next(); } } @@ -189,38 +187,30 @@ void SwDBField::InitContent() { if (!IsInitialized()) { - aContent = OUStringBuffer().append('<') - .append(((const SwDBFieldType*)GetTyp())->GetColumnName()) - .append('>').makeStringAndClear(); + aContent = "<" + ((const SwDBFieldType*)GetTyp())->GetColumnName() + ">"; } } -void SwDBField::InitContent(const String& rExpansion) +void SwDBField::InitContent(const OUString& rExpansion) { - if (rExpansion.Len() > 2) + if (rExpansion.startsWith("<") && rExpansion.endsWith(">")) { - if (rExpansion.GetChar(0) == '<' && - rExpansion.GetChar(rExpansion.Len() - 1) == '>') + const OUString sColumn( rExpansion.copy( 1, rExpansion.getLength() - 2 ) ); + if( ::GetAppCmpStrIgnore().isEqual( sColumn, + ((SwDBFieldType *)GetTyp())->GetColumnName() )) { - String sColumn( rExpansion.Copy( 1, rExpansion.Len() - 2 ) ); - if( ::GetAppCmpStrIgnore().isEqual( sColumn, - ((SwDBFieldType *)GetTyp())->GetColumnName() )) - { - InitContent(); - return; - } + InitContent(); + return; } } SetExpansion( rExpansion ); } -String SwDBField::Expand() const +OUString SwDBField::Expand() const { - String sRet; - if(0 ==(GetSubType() & nsSwExtendedSubType::SUB_INVISIBLE)) - sRet = lcl_DBTrennConv(aContent); - return sRet; + return lcl_DBTrennConv(aContent); + return OUString(); } SwField* SwDBField::Copy() const @@ -237,18 +227,18 @@ SwField* SwDBField::Copy() const return pTmp; } -String SwDBField::GetFieldName() const +OUString SwDBField::GetFieldName() const { - const String& rDBName = static_cast<SwDBFieldType*>(GetTyp())->GetName(); + const OUString rDBName = static_cast<SwDBFieldType*>(GetTyp())->GetName(); - String sContent( rDBName.GetToken(0, DB_DELIM) ); + OUString sContent( rDBName.getToken(0, DB_DELIM) ); - if (sContent.Len() > 1) + if (sContent.getLength() > 1) { - sContent += DB_DELIM; - sContent += rDBName.GetToken(1, DB_DELIM); - sContent += DB_DELIM; - sContent += rDBName.GetToken(2, DB_DELIM); + sContent += OUString(DB_DELIM) + + rDBName.getToken(1, DB_DELIM) + + OUString(DB_DELIM) + + rDBName.getToken(2, DB_DELIM); } return lcl_DBTrennConv(sContent); } @@ -334,7 +324,7 @@ void SwDBField::Evaluate() } /// get name -const OUString& SwDBField::GetPar1() const +OUString SwDBField::GetPar1() const { return ((const SwDBFieldType*)GetTyp())->GetName(); } @@ -369,10 +359,10 @@ bool SwDBField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const rAny <<= (sal_Int32)GetFormat(); break; case FIELD_PROP_PAR1: - rAny <<= OUString(aContent); + rAny <<= aContent; break; case FIELD_PROP_PAR2: - rAny <<= OUString(sFieldCode); + rAny <<= sFieldCode; break; default: OSL_FAIL("illegal property"); @@ -463,15 +453,15 @@ void SwDBNameInfField::SetDBData(const SwDBData & rDBData) aDBData = rDBData; } -String SwDBNameInfField::GetFieldName() const +OUString SwDBNameInfField::GetFieldName() const { - String sStr( SwField::GetFieldName() ); + OUString sStr( SwField::GetFieldName() ); if (!aDBData.sDataSource.isEmpty()) { - sStr += ':'; - sStr += String(aDBData.sDataSource); - sStr += DB_DELIM; - sStr += String(aDBData.sCommand); + sStr += OUString(':') + + aDBData.sDataSource + + OUString(DB_DELIM) + + aDBData.sCommand; } return lcl_DBTrennConv(sStr); } @@ -559,21 +549,21 @@ SwFieldType* SwDBNextSetFieldType::Copy() const // SwDBSetField SwDBNextSetField::SwDBNextSetField(SwDBNextSetFieldType* pTyp, - const String& rCond, - const String& , + const OUString& rCond, + const OUString& , const SwDBData& rDBData) : SwDBNameInfField(pTyp, rDBData), aCond(rCond), bCondValid(true) {} -String SwDBNextSetField::Expand() const +OUString SwDBNextSetField::Expand() const { - return aEmptyStr; + return OUString(); } SwField* SwDBNextSetField::Copy() const { SwDBNextSetField *pTmp = new SwDBNextSetField((SwDBNextSetFieldType*)GetTyp(), - aCond, aEmptyStr, GetDBData()); + aCond, OUString(), GetDBData()); pTmp->SetSubType(GetSubType()); pTmp->bCondValid = bCondValid; return pTmp; @@ -590,7 +580,7 @@ void SwDBNextSetField::Evaluate(SwDoc* pDoc) } /// get condition -const OUString& SwDBNextSetField::GetPar1() const +OUString SwDBNextSetField::GetPar1() const { return aCond; } @@ -607,7 +597,7 @@ bool SwDBNextSetField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const switch( nWhichId ) { case FIELD_PROP_PAR3: - rAny <<= OUString(aCond); + rAny <<= aCond; break; default: bRet = SwDBNameInfField::QueryValue( rAny, nWhichId ); @@ -645,8 +635,8 @@ SwFieldType* SwDBNumSetFieldType::Copy() const // SwDBNumSetField SwDBNumSetField::SwDBNumSetField(SwDBNumSetFieldType* pTyp, - const String& rCond, - const String& rDBNum, + const OUString& rCond, + const OUString& rDBNum, const SwDBData& rDBData) : SwDBNameInfField(pTyp, rDBData), aCond(rCond), @@ -654,9 +644,9 @@ SwDBNumSetField::SwDBNumSetField(SwDBNumSetFieldType* pTyp, bCondValid(true) {} -String SwDBNumSetField::Expand() const +OUString SwDBNumSetField::Expand() const { - return aEmptyStr; + return OUString(); } SwField* SwDBNumSetField::Copy() const @@ -676,12 +666,12 @@ void SwDBNumSetField::Evaluate(SwDoc* pDoc) if( bCondValid && pMgr && pMgr->IsInMerge() && pMgr->IsDataSourceOpen(aTmpData.sDataSource, aTmpData.sCommand, sal_True)) { // Bedingug OK -> aktuellen Set einstellen - pMgr->ToRecordId(std::max((sal_uInt16)aPar2.ToInt32(), sal_uInt16(1))-1); + pMgr->ToRecordId(std::max((sal_uInt16)aPar2.toInt32(), sal_uInt16(1))-1); } } /// get LogDBName -const OUString& SwDBNumSetField::GetPar1() const +OUString SwDBNumSetField::GetPar1() const { return aCond; } @@ -710,10 +700,10 @@ bool SwDBNumSetField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const switch( nWhichId ) { case FIELD_PROP_PAR3: - rAny <<= OUString(aCond); + rAny <<= aCond; break; case FIELD_PROP_FORMAT: - rAny <<= (sal_Int32)aPar2.ToInt32(); + rAny <<= aPar2.toInt32(); break; default: bRet = SwDBNameInfField::QueryValue(rAny, nWhichId ); @@ -750,13 +740,10 @@ SwDBNameFieldType::SwDBNameFieldType(SwDoc* pDocument) pDoc = pDocument; } -String SwDBNameFieldType::Expand(sal_uLong ) const +OUString SwDBNameFieldType::Expand(sal_uLong ) const { const SwDBData aData = pDoc->GetDBData(); - String sRet(aData.sDataSource); - sRet += '.'; - sRet += (String)aData.sCommand; - return sRet; + return aData.sDataSource + "." + aData.sCommand; } SwFieldType* SwDBNameFieldType::Copy() const @@ -771,12 +758,11 @@ SwDBNameField::SwDBNameField(SwDBNameFieldType* pTyp, const SwDBData& rDBData, s : SwDBNameInfField(pTyp, rDBData, nFmt) {} -String SwDBNameField::Expand() const +OUString SwDBNameField::Expand() const { - String sRet; if(0 ==(GetSubType() & nsSwExtendedSubType::SUB_INVISIBLE)) - sRet = ((SwDBNameFieldType*)GetTyp())->Expand(GetFormat()); - return sRet; + return ((SwDBNameFieldType*)GetTyp())->Expand(GetFormat()); + return OUString(); } SwField* SwDBNameField::Copy() const @@ -819,12 +805,11 @@ SwDBSetNumberField::SwDBSetNumberField(SwDBSetNumberFieldType* pTyp, : SwDBNameInfField(pTyp, rDBData, nFmt), nNumber(0) {} -String SwDBSetNumberField::Expand() const +OUString SwDBSetNumberField::Expand() const { if(0 !=(GetSubType() & nsSwExtendedSubType::SUB_INVISIBLE) || nNumber == 0) - return aEmptyStr; - else - return FormatNumber((sal_uInt16)nNumber, GetFormat()); + return OUString(); + return FormatNumber((sal_uInt16)nNumber, GetFormat()); } void SwDBSetNumberField::Evaluate(SwDoc* pDoc) diff --git a/sw/source/core/fields/ddefld.cxx b/sw/source/core/fields/ddefld.cxx index 1ec60355b4d8..6fd3c0824ccf 100644 --- a/sw/source/core/fields/ddefld.cxx +++ b/sw/source/core/fields/ddefld.cxx @@ -17,7 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <comphelper/string.hxx> #include <sfx2/linkmgr.hxx> #include <doc.hxx> #include <editsh.hxx> @@ -228,8 +227,8 @@ sal_Bool SwIntrnlRefLink::IsInRange( sal_uLong nSttNd, sal_uLong nEndNd, return sal_False; } -SwDDEFieldType::SwDDEFieldType(const String& rName, - const String& rCmd, sal_uInt16 nUpdateType ) +SwDDEFieldType::SwDDEFieldType(const OUString& rName, + const OUString& rCmd, sal_uInt16 nUpdateType ) : SwFieldType( RES_DDEFLD ), aName( rName ), pDoc( 0 ), nRefCnt( 0 ) { @@ -255,21 +254,22 @@ SwFieldType* SwDDEFieldType::Copy() const return pType; } -const OUString& SwDDEFieldType::GetName() const +OUString SwDDEFieldType::GetName() const { return aName; } -void SwDDEFieldType::SetCmd( const String& rStr ) +void SwDDEFieldType::SetCmd( OUString aStr ) { - String sCmd( rStr ); - xub_StrLen nPos; - while( STRING_NOTFOUND != (nPos = sCmd.SearchAscii( " " )) ) - sCmd.Erase( nPos, 1 ); - refLink->SetLinkSourceName( sCmd ); + sal_Int32 nIndex = 0; + do + { + aStr = aStr.replaceFirst(" ", " ", &nIndex); + } while (nIndex>=0); + refLink->SetLinkSourceName( aStr ); } -String SwDDEFieldType::GetCmd() const +OUString SwDDEFieldType::GetCmd() const { return refLink->GetLinkSourceName(); } @@ -312,12 +312,12 @@ void SwDDEFieldType::_RefCntChgd() bool SwDDEFieldType::QueryValue( uno::Any& rVal, sal_uInt16 nWhichId ) const { - sal_uInt8 nPart = 0; + sal_Int32 nPart = -1; switch( nWhichId ) { - case FIELD_PROP_PAR2: nPart = 3; break; - case FIELD_PROP_PAR4: nPart = 2; break; - case FIELD_PROP_SUBTYPE: nPart = 1; break; + case FIELD_PROP_PAR2: nPart = 2; break; + case FIELD_PROP_PAR4: nPart = 1; break; + case FIELD_PROP_SUBTYPE: nPart = 0; break; case FIELD_PROP_BOOL1: { sal_Bool bSet = GetType() == sfx2::LINKUPDATE_ALWAYS ? sal_True : sal_False; @@ -325,46 +325,50 @@ bool SwDDEFieldType::QueryValue( uno::Any& rVal, sal_uInt16 nWhichId ) const } break; case FIELD_PROP_PAR5: - rVal <<= OUString(aExpansion); - break; + rVal <<= aExpansion; + break; default: OSL_FAIL("illegal property"); } - if( nPart ) - rVal <<= OUString(GetCmd().GetToken(nPart-1, sfx2::cTokenSeparator)); + if ( nPart>=0 ) + rVal <<= GetCmd().getToken(nPart, sfx2::cTokenSeparator); return true; } bool SwDDEFieldType::PutValue( const uno::Any& rVal, sal_uInt16 nWhichId ) { - sal_uInt8 nPart = 0; + sal_Int32 nPart = -1; switch( nWhichId ) { - case FIELD_PROP_PAR2: nPart = 3; break; - case FIELD_PROP_PAR4: nPart = 2; break; - case FIELD_PROP_SUBTYPE: nPart = 1; break; + case FIELD_PROP_PAR2: nPart = 2; break; + case FIELD_PROP_PAR4: nPart = 1; break; + case FIELD_PROP_SUBTYPE: nPart = 0; break; case FIELD_PROP_BOOL1: SetType( static_cast<sal_uInt16>(*(sal_Bool*)rVal.getValue() ? sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL ) ); break; case FIELD_PROP_PAR5: - { - OUString sTemp; - rVal >>= sTemp; - aExpansion = sTemp; - } - break; + rVal >>= aExpansion; + break; default: OSL_FAIL("illegal property"); } - if( nPart ) + if( nPart>=0 ) { - String sTmp, sCmd( GetCmd() ); - while(3 > comphelper::string::getTokenCount(sCmd, sfx2::cTokenSeparator)) - sCmd += sfx2::cTokenSeparator; - sCmd.SetToken( nPart-1, sfx2::cTokenSeparator, ::GetString( rVal, sTmp ) ); - SetCmd( sCmd ); + const OUString sOldCmd( GetCmd() ); + OUString sNewCmd; + sal_Int32 nIndex = 0; + for (sal_Int32 i=0; i<3; ++i) + { + OUString sToken = sOldCmd.getToken(0, sfx2::cTokenSeparator, nIndex); + if (i==nPart) + { + rVal >>= sToken; + } + sNewCmd += sToken + OUString(sfx2::cTokenSeparator); + } + SetCmd( sNewCmd ); } return true; } @@ -380,17 +384,16 @@ SwDDEField::~SwDDEField() ((SwDDEFieldType*)GetTyp())->Disconnect(); } -String SwDDEField::Expand() const +OUString SwDDEField::Expand() const { - xub_StrLen nPos; - String aStr(comphelper::string::remove(((SwDDEFieldType*)GetTyp())->GetExpansion(), '\r')); - - while( (nPos = aStr.Search( '\t' )) != STRING_NOTFOUND ) - aStr.SetChar( nPos, ' ' ); - while( (nPos = aStr.Search( '\n' )) != STRING_NOTFOUND ) - aStr.SetChar( nPos, '|' ); - if( aStr.Len() && ( aStr.GetChar( aStr.Len()-1 ) == '|') ) - aStr.Erase( aStr.Len()-1, 1 ); + OUString aStr = ((SwDDEFieldType*)GetTyp())->GetExpansion(); + aStr = aStr.replaceAll("\r", OUString()); + aStr = aStr.replaceAll("\t", " "); + aStr = aStr.replaceAll("\n", "|"); + if (aStr.endsWith("|")) + { + return aStr.copy(0, aStr.getLength()-1); + } return aStr; } @@ -400,7 +403,7 @@ SwField* SwDDEField::Copy() const } /// get field type name -const OUString& SwDDEField::GetPar1() const +OUString SwDDEField::GetPar1() const { return ((const SwDDEFieldType*)GetTyp())->GetName(); } diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index 891e72cb384e..c8eb6f468da5 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -108,20 +108,20 @@ SwPageNumberFieldType::SwPageNumberFieldType() { } -String& SwPageNumberFieldType::Expand( sal_uInt32 nFmt, short nOff, +OUString SwPageNumberFieldType::Expand( sal_uInt32 nFmt, short nOff, sal_uInt16 const nPageNumber, sal_uInt16 const nMaxPage, - const String& rUserStr, String& rRet ) const + const OUString& rUserStr ) const { sal_uInt32 nTmpFmt = (SVX_NUM_PAGEDESC == nFmt) ? (sal_uInt32)nNumberingType : nFmt; int const nTmp = nPageNumber + nOff; if (0 >= nTmp || SVX_NUM_NUMBER_NONE == nTmpFmt || (!bVirtuell && nTmp > nMaxPage)) - rRet = aEmptyStr; - else if( SVX_NUM_CHAR_SPECIAL == nTmpFmt ) - rRet = rUserStr; - else - rRet = FormatNumber( (sal_uInt16)nTmp, nTmpFmt ); - return rRet; + return OUString(); + + if( SVX_NUM_CHAR_SPECIAL == nTmpFmt ) + return rUserStr; + + return FormatNumber( (sal_uInt16)nTmp, nTmpFmt ); } SwFieldType* SwPageNumberFieldType::Copy() const @@ -186,32 +186,29 @@ void SwPageNumberField::ChangeExpansion(sal_uInt16 const nPageNumber, m_nMaxPage = nMaxPage; } -String SwPageNumberField::Expand() const +OUString SwPageNumberField::Expand() const { - String sRet; + OUString sRet; SwPageNumberFieldType* pFldType = (SwPageNumberFieldType*)GetTyp(); if( PG_NEXT == nSubType && 1 != nOffset ) { - if (pFldType->Expand(GetFormat(), 1, m_nPageNumber, m_nMaxPage, - sUserStr, sRet).Len()) + sRet = pFldType->Expand(GetFormat(), 1, m_nPageNumber, m_nMaxPage, sUserStr); + if (!sRet.isEmpty()) { - pFldType->Expand(GetFormat(), nOffset, m_nPageNumber, m_nMaxPage, - sUserStr, sRet); + sRet = pFldType->Expand(GetFormat(), nOffset, m_nPageNumber, m_nMaxPage, sUserStr); } } else if( PG_PREV == nSubType && -1 != nOffset ) { - if (pFldType->Expand(GetFormat(), -1, m_nPageNumber, m_nMaxPage, - sUserStr, sRet).Len()) + sRet = pFldType->Expand(GetFormat(), -1, m_nPageNumber, m_nMaxPage, sUserStr); + if (!sRet.isEmpty()) { - pFldType->Expand(GetFormat(), nOffset, m_nPageNumber, m_nMaxPage, - sUserStr, sRet); + sRet = pFldType->Expand(GetFormat(), nOffset, m_nPageNumber, m_nMaxPage, sUserStr); } } else - pFldType->Expand(GetFormat(), nOffset, m_nPageNumber, m_nMaxPage, - sUserStr, sRet); + sRet = pFldType->Expand(GetFormat(), nOffset, m_nPageNumber, m_nMaxPage, sUserStr); return sRet; } @@ -262,7 +259,7 @@ bool SwPageNumberField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const } break; case FIELD_PROP_PAR1: - rAny <<= OUString(sUserStr); + rAny <<= sUserStr; break; default: @@ -307,7 +304,7 @@ bool SwPageNumberField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) } break; case FIELD_PROP_PAR1: - ::GetString( rAny, sUserStr ); + rAny >>= sUserStr; break; default: @@ -322,15 +319,13 @@ SwAuthorFieldType::SwAuthorFieldType() { } -String SwAuthorFieldType::Expand(sal_uLong nFmt) const +OUString SwAuthorFieldType::Expand(sal_uLong nFmt) const { - String sRet; SvtUserOptions& rOpt = SW_MOD()->GetUserOptions(); if((nFmt & 0xff) == AF_NAME) - sRet = rOpt.GetFullName(); - else - sRet = rOpt.GetID(); - return sRet; + return rOpt.GetFullName(); + + return rOpt.GetID(); } SwFieldType* SwAuthorFieldType::Copy() const @@ -346,7 +341,7 @@ SwAuthorField::SwAuthorField(SwAuthorFieldType* pTyp, sal_uInt32 nFmt) aContent = ((SwAuthorFieldType*)GetTyp())->Expand(GetFormat()); } -String SwAuthorField::Expand() const +OUString SwAuthorField::Expand() const { if (!IsFixed()) ((SwAuthorField*)this)->aContent = @@ -379,7 +374,7 @@ bool SwAuthorField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const break; case FIELD_PROP_PAR1: - rAny <<= OUString(GetContent()); + rAny <<= GetContent(); break; default: @@ -404,7 +399,7 @@ bool SwAuthorField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) break; case FIELD_PROP_PAR1: - ::GetString( rAny, aContent ); + rAny >>= aContent; break; default: @@ -421,9 +416,9 @@ SwFileNameFieldType::SwFileNameFieldType(SwDoc *pDocument) pDoc = pDocument; } -String SwFileNameFieldType::Expand(sal_uLong nFmt) const +OUString SwFileNameFieldType::Expand(sal_uLong nFmt) const { - String aRet; + OUString aRet; const SwDocShell* pDShell = pDoc->GetDocShell(); if( pDShell && pDShell->HasName() ) { @@ -444,8 +439,11 @@ String SwFileNameFieldType::Expand(sal_uLong nFmt) const aRet = URIHelper::removePassword( rURLObj.GetMainURL( INetURLObject::NO_DECODE ), INetURLObject::WAS_ENCODED, URL_DECODE ); - aRet.Erase( aRet.Search( String(rURLObj.GetLastName( - URL_DECODE )) ) ); + const sal_Int32 nPos = aRet.indexOf(rURLObj.GetLastName( URL_DECODE )); + if (nPos>=0) + { + aRet = aRet.copy(0, nPos); + } } } break; @@ -484,7 +482,7 @@ SwFileNameField::SwFileNameField(SwFileNameFieldType* pTyp, sal_uInt32 nFmt) aContent = ((SwFileNameFieldType*)GetTyp())->Expand(GetFormat()); } -String SwFileNameField::Expand() const +OUString SwFileNameField::Expand() const { if (!IsFixed()) ((SwFileNameField*)this)->aContent = ((SwFileNameFieldType*)GetTyp())->Expand(GetFormat()); @@ -533,7 +531,7 @@ bool SwFileNameField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const break; case FIELD_PROP_PAR3: - rAny <<= OUString(GetContent()); + rAny <<= GetContent(); break; default: OSL_FAIL("illegal property"); @@ -580,7 +578,7 @@ bool SwFileNameField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) break; case FIELD_PROP_PAR3: - ::GetString( rAny, aContent ); + rAny >>= aContent; break; default: @@ -597,11 +595,11 @@ SwTemplNameFieldType::SwTemplNameFieldType(SwDoc *pDocument) pDoc = pDocument; } -String SwTemplNameFieldType::Expand(sal_uLong nFmt) const +OUString SwTemplNameFieldType::Expand(sal_uLong nFmt) const { OSL_ENSURE( nFmt < FF_END, "Expand: kein guelt. Fmt!" ); - String aRet; + OUString aRet; SwDocShell *pDocShell(pDoc->GetDocShell()); OSL_ENSURE(pDocShell, "no SwDocShell"); if (pDocShell) { @@ -621,7 +619,9 @@ String SwTemplNameFieldType::Expand(sal_uLong nFmt) const SfxDocumentTemplates aFac; aFac.Construct(); String sTmp; - aFac.GetLogicNames( xDocProps->getTemplateURL(), aRet, sTmp ); + String sRegion; + aFac.GetLogicNames( xDocProps->getTemplateURL(), sRegion, sTmp ); + aRet = sRegion; } else { @@ -657,7 +657,7 @@ SwTemplNameField::SwTemplNameField(SwTemplNameFieldType* pTyp, sal_uInt32 nFmt) : SwField(pTyp, nFmt) {} -String SwTemplNameField::Expand() const +OUString SwTemplNameField::Expand() const { return((SwTemplNameFieldType*)GetTyp())->Expand(GetFormat()); } @@ -741,7 +741,7 @@ SwDocStatFieldType::SwDocStatFieldType(SwDoc* pDocument) pDoc = pDocument; } -String SwDocStatFieldType::Expand(sal_uInt16 nSubType, sal_uInt32 nFmt) const +OUString SwDocStatFieldType::Expand(sal_uInt16 nSubType, sal_uInt32 nFmt) const { sal_uInt32 nVal = 0; const SwDocStat& rDStat = pDoc->GetDocStat(); @@ -764,12 +764,10 @@ String SwDocStatFieldType::Expand(sal_uInt16 nSubType, sal_uInt32 nFmt) const OSL_FAIL( "SwDocStatFieldType::Expand: unbekannter SubType" ); } - String sRet; if( nVal <= SHRT_MAX ) - sRet = FormatNumber( (sal_uInt16)nVal, nFmt ); - else - sRet = OUString::number( nVal ); - return sRet; + return FormatNumber( (sal_uInt16)nVal, nFmt ); + + return OUString::number( nVal ); } SwFieldType* SwDocStatFieldType::Copy() const @@ -788,7 +786,7 @@ SwDocStatField::SwDocStatField(SwDocStatFieldType* pTyp, sal_uInt16 nSub, sal_uI nSubType(nSub) {} -String SwDocStatField::Expand() const +OUString SwDocStatField::Expand() const { return((SwDocStatFieldType*)GetTyp())->Expand(nSubType, GetFormat()); } @@ -880,14 +878,13 @@ static void lcl_GetLocalDataWrapper( sal_uLong nLang, LanguageTag( static_cast<LanguageType>(nLang) )); } -String SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, - sal_uInt16 nLang, const String& rName ) const +OUString SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, + sal_uInt16 nLang, const OUString& rName ) const { - String aStr; const LocaleDataWrapper *pAppLocalData = 0, *pLocalData = 0; SwDocShell *pDocShell(GetDoc()->GetDocShell()); OSL_ENSURE(pDocShell, "no SwDocShell"); - if (!pDocShell) { return aStr; } + if (!pDocShell) { return OUString(); } uno::Reference<document::XDocumentPropertiesSupplier> xDPS( pDocShell->GetModel(), uno::UNO_QUERY_THROW); @@ -898,6 +895,7 @@ String SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, sal_uInt16 nExtSub = nSub & 0xff00; nSub &= 0xff; // ExtendedSubTypes nicht beachten + OUString aStr; switch(nSub) { case DI_TITEL: aStr = xDocProps->getTitle(); break; @@ -946,7 +944,7 @@ String SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, default: { - String aName( xDocProps->getAuthor() ); + OUString aName( xDocProps->getAuthor() ); util::DateTime uDT( xDocProps->getCreationDate() ); Date aD(uDT.Day, uDT.Month, uDT.Year); Time aT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.NanoSeconds); @@ -1028,14 +1026,14 @@ String SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, // document info field -SwDocInfoField::SwDocInfoField(SwDocInfoFieldType* pTyp, sal_uInt16 nSub, const String& rName, sal_uInt32 nFmt) : +SwDocInfoField::SwDocInfoField(SwDocInfoFieldType* pTyp, sal_uInt16 nSub, const OUString& rName, sal_uInt32 nFmt) : SwValueField(pTyp, nFmt), nSubType(nSub) { aName = rName; aContent = ((SwDocInfoFieldType*)GetTyp())->Expand(nSubType, nFmt, GetLanguage(), aName); } -SwDocInfoField::SwDocInfoField(SwDocInfoFieldType* pTyp, sal_uInt16 nSub, const String& rName, const String& rValue, sal_uInt32 nFmt) : +SwDocInfoField::SwDocInfoField(SwDocInfoFieldType* pTyp, sal_uInt16 nSub, const OUString& rName, const OUString& rValue, sal_uInt32 nFmt) : SwValueField(pTyp, nFmt), nSubType(nSub) { aName = rName; @@ -1057,7 +1055,7 @@ static double lcl_DateToDouble( const D& rDate, const Date& rNullDate ) return double( nDate - nNullDate ); } -String SwDocInfoField::Expand() const +OUString SwDocInfoField::Expand() const { if ( ( nSubType & 0xFF ) == DI_CUSTOM ) { @@ -1108,15 +1106,14 @@ String SwDocInfoField::Expand() const } else if( aAny >>= aDuration ) { - String sText = aDuration.Negative ? OUString('-') : OUString('+'); - sText += ViewShell::GetShellRes()->sDurationFormat; - sText.SearchAndReplace(OUString("%1"), OUString::number( aDuration.Years ) ); - sText.SearchAndReplace(OUString("%2"), OUString::number( aDuration.Months ) ); - sText.SearchAndReplace(OUString("%3"), OUString::number( aDuration.Days ) ); - sText.SearchAndReplace(OUString("%4"), OUString::number( aDuration.Hours ) ); - sText.SearchAndReplace(OUString("%5"), OUString::number( aDuration.Minutes) ); - sText.SearchAndReplace(OUString("%6"), OUString::number( aDuration.Seconds) ); - sVal = sText; + sVal = OUString(aDuration.Negative ? '-' : '+') + + ViewShell::GetShellRes()->sDurationFormat; + sVal = sVal.replaceFirst("%1", OUString::number( aDuration.Years ) ); + sVal = sVal.replaceFirst("%2", OUString::number( aDuration.Months ) ); + sVal = sVal.replaceFirst("%3", OUString::number( aDuration.Days ) ); + sVal = sVal.replaceFirst("%4", OUString::number( aDuration.Hours ) ); + sVal = sVal.replaceFirst("%5", OUString::number( aDuration.Minutes) ); + sVal = sVal.replaceFirst("%6", OUString::number( aDuration.Seconds) ); } else { @@ -1135,10 +1132,9 @@ String SwDocInfoField::Expand() const return aContent; } -String SwDocInfoField::GetFieldName() const +OUString SwDocInfoField::GetFieldName() const { - String aStr(SwFieldType::GetTypeStr(GetTypeId())); - aStr += ':'; + OUString aStr(SwFieldType::GetTypeStr(GetTypeId()) + ":"); sal_uInt16 const nSub = nSubType & 0xff; @@ -1155,8 +1151,7 @@ String SwDocInfoField::GetFieldName() const } if (IsFixed()) { - aStr += ' '; - aStr += ViewShell::GetShellRes()->aFixedStr; + aStr += " " + OUString(ViewShell::GetShellRes()->aFixedStr); } return aStr; } @@ -1193,15 +1188,15 @@ bool SwDocInfoField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const switch( nWhichId ) { case FIELD_PROP_PAR1: - rAny <<= OUString(aContent); + rAny <<= aContent; break; case FIELD_PROP_PAR4: - rAny <<= OUString(aName); + rAny <<= aName; break; case FIELD_PROP_USHORT1: - rAny <<= (sal_Int16)aContent.ToInt32(); + rAny <<= (sal_Int16)aContent.toInt32(); break; case FIELD_PROP_BOOL1: @@ -1221,7 +1216,7 @@ bool SwDocInfoField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const } break; case FIELD_PROP_PAR3: - rAny <<= OUString(Expand()); + rAny <<= Expand(); break; case FIELD_PROP_BOOL2: { @@ -1243,7 +1238,7 @@ bool SwDocInfoField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) { case FIELD_PROP_PAR1: if( nSubType & DI_SUB_FIXED ) - ::GetString( rAny, aContent ); + rAny >>= aContent; break; case FIELD_PROP_USHORT1: @@ -1269,7 +1264,7 @@ bool SwDocInfoField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) break; case FIELD_PROP_PAR3: - ::GetString( rAny, aContent ); + rAny >>= aContent; break; case FIELD_PROP_BOOL2: nSubType &= 0xf0ff; @@ -1307,8 +1302,8 @@ void SwHiddenTxtFieldType::SetHiddenFlag( sal_Bool bSetHidden ) SwHiddenTxtField::SwHiddenTxtField( SwHiddenTxtFieldType* pFldType, sal_Bool bConditional, - const String& rCond, - const String& rStr, + const OUString& rCond, + const OUString& rStr, sal_Bool bHidden, sal_uInt16 nSub) : SwField( pFldType ), aCond(rCond), nSubType(nSub), @@ -1317,14 +1312,14 @@ SwHiddenTxtField::SwHiddenTxtField( SwHiddenTxtFieldType* pFldType, if(nSubType == TYP_CONDTXTFLD) { sal_Int32 nPos = 0; - aTRUETxt = rStr.GetToken(0, '|', nPos); + aTRUETxt = rStr.getToken(0, '|', nPos); if(nPos != -1) { - aFALSETxt = rStr.GetToken(0, '|', nPos); + aFALSETxt = rStr.getToken(0, '|', nPos); if(nPos != -1) { - aContent = rStr.GetToken(0, '|', nPos); + aContent = rStr.getToken(0, '|', nPos); bValid = sal_True; } } @@ -1334,17 +1329,17 @@ SwHiddenTxtField::SwHiddenTxtField( SwHiddenTxtFieldType* pFldType, } SwHiddenTxtField::SwHiddenTxtField( SwHiddenTxtFieldType* pFldType, - const String& rCond, - const String& rTrue, - const String& rFalse, + const OUString& rCond, + const OUString& rTrue, + const OUString& rFalse, sal_uInt16 nSub) : SwField( pFldType ), aTRUETxt(rTrue), aFALSETxt(rFalse), aCond(rCond), nSubType(nSub), bIsHidden(sal_True), bValid(sal_False) { - bCanToggle = aCond.getLength() > 0; + bCanToggle = !aCond.isEmpty(); } -String SwHiddenTxtField::Expand() const +OUString SwHiddenTxtField::Expand() const { // Type: !Hidden -> show always // Hide -> evaluate condition @@ -1374,38 +1369,33 @@ void SwHiddenTxtField::Evaluate(SwDoc* pDoc) SwNewDBMgr* pMgr = pDoc->GetNewDBMgr(); bValid = sal_False; - String sTmpName; + OUString sTmpName = (bCanToggle && !bIsHidden) ? aTRUETxt : aFALSETxt; - if (bCanToggle && !bIsHidden) - sTmpName = aTRUETxt; - else - sTmpName = aFALSETxt; - - // Database expressions need to be differnt from normal text. Therefore, normal text is set + // Database expressions need to be different from normal text. Therefore, normal text is set // in quotes. If the latter exist they will be removed. If not, check if potential DB name. // Only if there are two or more dots and no quotes, we assume a database. - if(sTmpName.Len() > 1 && sTmpName.GetChar(0) == '\"' && - sTmpName.GetChar((sTmpName.Len() - 1))== '\"') + if (sTmpName.getLength()>1 && + sTmpName.startsWith("\"") && + sTmpName.endsWith("\"")) { - aContent = sTmpName.Copy(1, sTmpName.Len() - 2); + aContent = sTmpName.copy(1, sTmpName.getLength() - 2); bValid = sal_True; } - else if(sTmpName.Search('\"') == STRING_NOTFOUND && + else if(sTmpName.indexOf('\"')<0 && comphelper::string::getTokenCount(sTmpName, '.') > 2) { - ::ReplacePoint(sTmpName); - if(sTmpName.GetChar(0) == '[' && sTmpName.GetChar(sTmpName.Len()-1) == ']') + sTmpName = ::ReplacePoint(sTmpName); + if(sTmpName.startsWith("[") && sTmpName.endsWith("]")) { // remove brackets - sTmpName.Erase(0, 1); - sTmpName.Erase(sTmpName.Len()-1, 1); + sTmpName = sTmpName.copy(1, sTmpName.getLength() - 2); } if( pMgr) { - String sDBName( GetDBName( sTmpName, pDoc )); - String sDataSource(sDBName.GetToken(0, DB_DELIM)); - String sDataTableOrQuery(sDBName.GetToken(1, DB_DELIM)); - if( pMgr->IsInMerge() && sDBName.Len() && + OUString sDBName( GetDBName( sTmpName, pDoc )); + OUString sDataSource(sDBName.getToken(0, DB_DELIM)); + OUString sDataTableOrQuery(sDBName.getToken(1, DB_DELIM)); + if( pMgr->IsInMerge() && !sDBName.isEmpty() && pMgr->IsDataSourceOpen( sDataSource, sDataTableOrQuery, sal_False)) { @@ -1415,26 +1405,22 @@ void SwHiddenTxtField::Evaluate(SwDoc* pDoc) GetLanguage(), aContent, &fNumber, &nTmpFormat ); bValid = sal_True; } - else if( sDBName.Len() && sDataSource.Len() && - sDataTableOrQuery.Len() ) + else if( !sDBName.isEmpty() && !sDataSource.isEmpty() && + !sDataTableOrQuery.isEmpty() ) bValid = sal_True; } } } } -String SwHiddenTxtField::GetFieldName() const +OUString SwHiddenTxtField::GetFieldName() const { - String aStr(SwFieldType::GetTypeStr(nSubType)); - aStr += ' '; - aStr += aCond; - aStr += ' '; - aStr += aTRUETxt; + OUString aStr = SwFieldType::GetTypeStr(nSubType) + + " " + aCond + " " + aTRUETxt; if (nSubType == TYP_CONDTXTFLD) { - aStr.AppendAscii(" : "); - aStr += aFALSETxt; + aStr += " : " + aFALSETxt; } return aStr; } @@ -1456,10 +1442,10 @@ SwField* SwHiddenTxtField::Copy() const void SwHiddenTxtField::SetPar1(const OUString& rStr) { aCond = rStr; - bCanToggle = aCond.getLength() > 0; + bCanToggle = !aCond.isEmpty(); } -const OUString& SwHiddenTxtField::GetPar1() const +OUString SwHiddenTxtField::GetPar1() const { return aCond; } @@ -1485,13 +1471,11 @@ void SwHiddenTxtField::SetPar2(const OUString& rStr) /// get True/False text OUString SwHiddenTxtField::GetPar2() const { - String aRet(aTRUETxt); - if(nSubType == TYP_CONDTXTFLD) + if(nSubType != TYP_CONDTXTFLD) { - aRet += '|'; - aRet += aFALSETxt; + return aTRUETxt; } - return aRet; + return aTRUETxt + "|" + aFALSETxt; } sal_uInt16 SwHiddenTxtField::GetSubType() const @@ -1501,20 +1485,19 @@ sal_uInt16 SwHiddenTxtField::GetSubType() const bool SwHiddenTxtField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const { - const OUString* pOut = 0; switch( nWhichId ) { case FIELD_PROP_PAR1: - pOut = &aCond; + rAny <<= aCond; break; case FIELD_PROP_PAR2: - pOut = &aTRUETxt; + rAny <<= aTRUETxt; break; case FIELD_PROP_PAR3: - pOut = &aFALSETxt; + rAny <<= aFALSETxt; break; case FIELD_PROP_PAR4 : - pOut = &aContent; + rAny <<= aContent; break; case FIELD_PROP_BOOL1: { @@ -1525,8 +1508,6 @@ bool SwHiddenTxtField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const default: OSL_FAIL("illegal property"); } - if( pOut ) - rAny <<= *pOut; return true; } @@ -1560,34 +1541,32 @@ bool SwHiddenTxtField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) return true; } -String SwHiddenTxtField::GetColumnName(const String& rName) +OUString SwHiddenTxtField::GetColumnName(const OUString& rName) { - sal_uInt16 nPos = rName.Search(DB_DELIM); - if( STRING_NOTFOUND != nPos ) + sal_Int32 nPos = rName.indexOf(DB_DELIM); + if( nPos>=0 ) { - nPos = rName.Search(DB_DELIM, nPos + 1); + nPos = rName.indexOf(DB_DELIM, nPos + 1); - if( STRING_NOTFOUND != nPos ) - return rName.Copy(nPos + 1); + if( nPos>=0 ) + return rName.copy(nPos + 1); } return rName; } -String SwHiddenTxtField::GetDBName(const String& rName, SwDoc *pDoc) +OUString SwHiddenTxtField::GetDBName(const OUString& rName, SwDoc *pDoc) { - sal_uInt16 nPos = rName.Search(DB_DELIM); - if( STRING_NOTFOUND != nPos ) + sal_Int32 nPos = rName.indexOf(DB_DELIM); + if( nPos>=0 ) { - nPos = rName.Search(DB_DELIM, nPos + 1); + nPos = rName.indexOf(DB_DELIM, nPos + 1); - if( STRING_NOTFOUND != nPos ) - return rName.Copy( 0, nPos ); + if( nPos>=0 ) + return rName.copy(0, nPos); } + SwDBData aData = pDoc->GetDBData(); - String sRet = aData.sDataSource; - sRet += DB_DELIM; - sRet += String(aData.sCommand); - return sRet; + return aData.sDataSource + OUString(DB_DELIM) + aData.sCommand; } // field type for line height 0 @@ -1605,15 +1584,15 @@ SwFieldType* SwHiddenParaFieldType::Copy() const // field for line height 0 -SwHiddenParaField::SwHiddenParaField(SwHiddenParaFieldType* pTyp, const String& rStr) +SwHiddenParaField::SwHiddenParaField(SwHiddenParaFieldType* pTyp, const OUString& rStr) : SwField(pTyp), aCond(rStr) { bIsHidden = sal_False; } -String SwHiddenParaField::Expand() const +OUString SwHiddenParaField::Expand() const { - return aEmptyStr; + return OUString(); } SwField* SwHiddenParaField::Copy() const @@ -1629,7 +1608,7 @@ bool SwHiddenParaField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const switch ( nWhichId ) { case FIELD_PROP_PAR1: - rAny <<= OUString(aCond); + rAny <<= aCond; break; case FIELD_PROP_BOOL1: { @@ -1667,7 +1646,7 @@ void SwHiddenParaField::SetPar1(const OUString& rStr) aCond = rStr; } -const OUString& SwHiddenParaField::GetPar1() const +OUString SwHiddenParaField::GetPar1() const { return aCond; } @@ -1686,8 +1665,19 @@ SwFieldType* SwPostItFieldType::Copy() const // PostIt field SwPostItField::SwPostItField( SwPostItFieldType* pT, - const String& rAuthor, const String& rTxt, const String& rInitials, const String& rName, const DateTime& rDateTime ) - : SwField( pT ), sTxt( rTxt ), sAuthor( rAuthor ), sInitials( rInitials ), sName( rName ), aDateTime( rDateTime ), mpText(0), m_pTextObject(0) + const OUString& rAuthor, + const OUString& rTxt, + const OUString& rInitials, + const OUString& rName, + const DateTime& rDateTime ) + : SwField( pT ) + , sTxt( rTxt ) + , sAuthor( rAuthor ) + , sInitials( rInitials ) + , sName( rName ) + , aDateTime( rDateTime ) + , mpText(0) + , m_pTextObject(0) { } @@ -1724,13 +1714,13 @@ const SwFmtFld* SwPostItField::GetByName(SwDoc* pDoc, const OUString& rName) return 0; } -String SwPostItField::Expand() const +OUString SwPostItField::Expand() const { - return aEmptyStr; + return OUString(); } -String SwPostItField::GetDescription() const +OUString SwPostItField::GetDescription() const { return SW_RES(STR_NOTE); } @@ -1751,7 +1741,7 @@ void SwPostItField::SetPar1(const OUString& rStr) } /// get author -const OUString& SwPostItField::GetPar1() const +OUString SwPostItField::GetPar1() const { return sAuthor; } @@ -1768,7 +1758,7 @@ OUString SwPostItField::GetPar2() const return sTxt; } -const OUString& SwPostItField::GetInitials() const +OUString SwPostItField::GetInitials() const { return sInitials; } @@ -1778,7 +1768,7 @@ void SwPostItField::SetName(const OUString& rName) sName = rName; } -const OUString& SwPostItField::GetName() const +OUString SwPostItField::GetName() const { return sName; } @@ -1804,18 +1794,18 @@ bool SwPostItField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const switch( nWhichId ) { case FIELD_PROP_PAR1: - rAny <<= OUString(sAuthor); + rAny <<= sAuthor; break; case FIELD_PROP_PAR2: { - rAny <<= OUString(sTxt); + rAny <<= sTxt; break; } case FIELD_PROP_PAR3: - rAny <<= OUString(sInitials); + rAny <<= sInitials; break; case FIELD_PROP_PAR4: - rAny <<= OUString(sName); + rAny <<= sName; break; case FIELD_PROP_TEXT: { @@ -1930,9 +1920,8 @@ SwFieldType* SwExtUserFieldType::Copy() const return pTyp; } -String SwExtUserFieldType::Expand(sal_uInt16 nSub, sal_uInt32 ) const +OUString SwExtUserFieldType::Expand(sal_uInt16 nSub, sal_uInt32 ) const { - String aRet; sal_uInt16 nRet = USHRT_MAX; switch(nSub) { @@ -1959,9 +1948,9 @@ String SwExtUserFieldType::Expand(sal_uInt16 nSub, sal_uInt32 ) const if( USHRT_MAX != nRet ) { SvtUserOptions& rUserOpt = SW_MOD()->GetUserOptions(); - aRet = rUserOpt.GetToken( nRet ); + return rUserOpt.GetToken( nRet ); } - return aRet; + return OUString(); } // extended user information field @@ -1972,7 +1961,7 @@ SwExtUserField::SwExtUserField(SwExtUserFieldType* pTyp, sal_uInt16 nSubTyp, sal aContent = ((SwExtUserFieldType*)GetTyp())->Expand(nType, GetFormat()); } -String SwExtUserField::Expand() const +OUString SwExtUserField::Expand() const { if (!IsFixed()) ((SwExtUserField*)this)->aContent = ((SwExtUserFieldType*)GetTyp())->Expand(nType, GetFormat()); @@ -2003,7 +1992,7 @@ bool SwExtUserField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const switch( nWhichId ) { case FIELD_PROP_PAR1: - rAny <<= OUString(aContent); + rAny <<= aContent; break; case FIELD_PROP_USHORT1: @@ -2029,7 +2018,7 @@ bool SwExtUserField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) switch( nWhichId ) { case FIELD_PROP_PAR1: - ::GetString( rAny, aContent ); + rAny >>= aContent; break; case FIELD_PROP_USHORT1: @@ -2076,9 +2065,9 @@ SwRefPageSetField::SwRefPageSetField( SwRefPageSetFieldType* pTyp, { } -String SwRefPageSetField::Expand() const +OUString SwRefPageSetField::Expand() const { - return aEmptyStr; + return OUString(); } SwField* SwRefPageSetField::Copy() const @@ -2213,7 +2202,7 @@ void SwRefPageGetFieldType::UpdateField( SwTxtFld* pTxtFld, _SetGetExpFlds& rSetList ) { SwRefPageGetField* pGetFld = (SwRefPageGetField*)pTxtFld->GetFld().GetFld(); - pGetFld->SetText( aEmptyStr ); + pGetFld->SetText( OUString() ); // then search the correct RefPageSet field SwTxtNode* pTxtNode = (SwTxtNode*)&pTxtFld->GetTxtNode(); @@ -2265,7 +2254,7 @@ SwRefPageGetField::SwRefPageGetField( SwRefPageGetFieldType* pTyp, { } -String SwRefPageGetField::Expand() const +OUString SwRefPageGetField::Expand() const { return sTxt; } @@ -2289,7 +2278,7 @@ void SwRefPageGetField::ChangeExpansion( const SwFrm* pFrm, pDoc->GetNodes().GetEndOfExtras().GetIndex() ) return; - sTxt.Erase(); + sTxt = OUString(); OSL_ENSURE( !pFrm->IsInDocBody(), "Flag incorrect, frame is in DocBody" ); @@ -2344,7 +2333,7 @@ bool SwRefPageGetField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const rAny <<= (sal_Int16)GetFormat(); break; case FIELD_PROP_PAR1: - rAny <<= OUString(sTxt); + rAny <<= sTxt; break; default: OSL_FAIL("illegal property"); @@ -2367,11 +2356,7 @@ bool SwRefPageGetField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) } break; case FIELD_PROP_PAR1: - { - OUString sTmp; - rAny >>= sTmp; - sTxt = sTmp; - } + rAny >>= sTxt; break; default: OSL_FAIL("illegal property"); @@ -2403,15 +2388,14 @@ SwCharFmt* SwJumpEditFieldType::GetCharFmt() } SwJumpEditField::SwJumpEditField( SwJumpEditFieldType* pTyp, sal_uInt32 nForm, - const String& rTxt, const String& rHelp ) + const OUString& rTxt, const OUString& rHelp ) : SwField( pTyp, nForm ), sTxt( rTxt ), sHelp( rHelp ) { } -String SwJumpEditField::Expand() const +OUString SwJumpEditField::Expand() const { - return OUStringBuffer().append('<'). - append(sTxt).append('>').makeStringAndClear(); + return "<" + sTxt + ">"; } SwField* SwJumpEditField::Copy() const @@ -2421,7 +2405,7 @@ SwField* SwJumpEditField::Copy() const } /// get place holder text -const OUString& SwJumpEditField::GetPar1() const +OUString SwJumpEditField::GetPar1() const { return sTxt; } @@ -2464,10 +2448,10 @@ bool SwJumpEditField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const } break; case FIELD_PROP_PAR1 : - rAny <<= OUString(sHelp); + rAny <<= sHelp; break; case FIELD_PROP_PAR2 : - rAny <<= OUString(sTxt); + rAny <<= sTxt; break; default: OSL_FAIL("illegal property"); @@ -2523,13 +2507,13 @@ SwFieldType* SwCombinedCharFieldType::Copy() const // combined character field SwCombinedCharField::SwCombinedCharField( SwCombinedCharFieldType* pFTyp, - const String& rChars ) + const OUString& rChars ) : SwField( pFTyp, 0 ), - sCharacters( rChars.Copy( 0, MAX_COMBINED_CHARACTERS )) + sCharacters( rChars.copy( 0, MAX_COMBINED_CHARACTERS )) { } -String SwCombinedCharField::Expand() const +OUString SwCombinedCharField::Expand() const { return sCharacters; } @@ -2540,7 +2524,7 @@ SwField* SwCombinedCharField::Copy() const sCharacters ); } -const OUString& SwCombinedCharField::GetPar1() const +OUString SwCombinedCharField::GetPar1() const { return sCharacters; } @@ -2556,7 +2540,7 @@ bool SwCombinedCharField::QueryValue( uno::Any& rAny, switch( nWhichId ) { case FIELD_PROP_PAR1: - rAny <<= OUString( sCharacters ); + rAny <<= sCharacters; break; default: OSL_FAIL("illegal property"); diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx index 65538544b271..388d2feea268 100644 --- a/sw/source/core/fields/expfld.cxx +++ b/sw/source/core/fields/expfld.cxx @@ -96,30 +96,35 @@ static sal_Int32 lcl_APIToSubType(const uno::Any& rAny) return nSet; } -void ReplacePoint( String& rTmpName, bool bWithCommandType ) +OUString ReplacePoint( OUString rTmpName, bool bWithCommandType ) { // replace first and last (if bWithCommandType: last two) dot // since table names may contain dots - xub_StrLen nLen = rTmpName.Len(); - sal_Unicode *pStr = rTmpName.GetBufferAccess(), *pBackStr = pStr + nLen; + sal_Int32 nIndex = rTmpName.lastIndexOf('.'); + if (nIndex<0) + { + return rTmpName; + } - long nBackCount = bWithCommandType ? 2 : 1; - xub_StrLen i; + OUString sRes = rTmpName.replaceAt(nIndex, 1, OUString(DB_DELIM)); - for( i = nLen; i; --i, pBackStr-- ) - if( '.' == *pBackStr ) - { - *pBackStr = DB_DELIM; - if(!--nBackCount) - break; - } - for( i = 0; i < nLen; ++i, ++pStr ) - if( '.' == *pStr ) + if (bWithCommandType) + { + nIndex = sRes.lastIndexOf('.', nIndex); + if (nIndex<0) { - *pStr = DB_DELIM; - break; + return sRes; } + sRes = sRes.replaceAt(nIndex, 1, OUString(DB_DELIM)); + } + + nIndex = sRes.indexOf('.'); + if (nIndex>=0) + { + sRes = sRes.replaceAt(nIndex, 1, OUString(DB_DELIM)); + } + return sRes; } SwTxtNode* GetFirstTxtNode( const SwDoc& rDoc, SwPosition& rPos, @@ -267,7 +272,7 @@ void SwGetExpFieldType::Modify( const SfxPoolItem*, const SfxPoolItem* pNew ) // do not expand anything else } -SwGetExpField::SwGetExpField(SwGetExpFieldType* pTyp, const String& rFormel, +SwGetExpField::SwGetExpField(SwGetExpFieldType* pTyp, const OUString& rFormel, sal_uInt16 nSub, sal_uLong nFmt) : SwFormulaField( pTyp, nFmt, 0.0 ), bIsInBodyTxt( sal_True ), @@ -277,23 +282,22 @@ SwGetExpField::SwGetExpField(SwGetExpFieldType* pTyp, const String& rFormel, SetFormula( rFormel ); } -String SwGetExpField::Expand() const +OUString SwGetExpField::Expand() const { if(nSubType & nsSwExtendedSubType::SUB_CMD) return GetFormula(); - else - return sExpand; + + return sExpand; } -String SwGetExpField::GetFieldName() const +OUString SwGetExpField::GetFieldName() const { - String aStr( SwFieldType::GetTypeStr( - static_cast<sal_uInt16>(((nsSwGetSetExpType::GSE_FORMULA & nSubType) != 0) - ? TYP_FORMELFLD - : TYP_GETFLD ) )); - aStr += ' '; - aStr += GetFormula(); - return aStr; + const sal_uInt16 nType = static_cast<sal_uInt16>( + (nsSwGetSetExpType::GSE_FORMULA & nSubType) + ? TYP_FORMELFLD + : TYP_GETFLD); + + return SwFieldType::GetTypeStr(nType) + " " + GetFormula(); } SwField* SwGetExpField::Copy() const @@ -349,7 +353,7 @@ void SwGetExpField::ChangeExpansion( const SwFrm& rFrm, const SwTxtFld& rFld ) SwHash** ppHashTbl; sal_uInt16 nSize; rDoc.FldsToExpand( ppHashTbl, nSize, aEndFld ); - LookString( ppHashTbl, nSize, GetFormula(), sExpand ); + sExpand = LookString( ppHashTbl, nSize, GetFormula() ); ::DeleteHashTable( ppHashTbl, nSize ); } else @@ -409,7 +413,7 @@ bool SwGetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const rAny <<= (sal_Int16)nSubType; break; case FIELD_PROP_PAR1: - rAny <<= OUString( GetFormula() ); + rAny <<= GetFormula(); break; case FIELD_PROP_SUBTYPE: { @@ -424,7 +428,7 @@ bool SwGetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const } break; case FIELD_PROP_PAR4: - rAny <<= OUString(GetExpStr()); + rAny <<= GetExpStr(); break; default: return SwField::QueryValue(rAny, nWhichId); @@ -435,7 +439,6 @@ bool SwGetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const bool SwGetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) { sal_Int32 nTmp = 0; - String sTmp; switch( nWhichId ) { case FIELD_PROP_DOUBLE: @@ -450,8 +453,12 @@ bool SwGetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) nSubType = static_cast<sal_uInt16>(nTmp); break; case FIELD_PROP_PAR1: - SetFormula( ::GetString( rAny, sTmp )); + { + OUString sTmp; + rAny >>= sTmp; + SetFormula(sTmp); break; + } case FIELD_PROP_SUBTYPE: nTmp = lcl_APIToSubType(rAny); if( nTmp >=0 ) @@ -464,19 +471,23 @@ bool SwGetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) nSubType &= (~nsSwExtendedSubType::SUB_CMD); break; case FIELD_PROP_PAR4: - ChgExpStr(::GetString( rAny, sTmp )); + { + OUString sTmp; + rAny >>= sTmp; + ChgExpStr(sTmp); break; + } default: return SwField::PutValue(rAny, nWhichId); } return true; } -SwSetExpFieldType::SwSetExpFieldType( SwDoc* pDc, const String& rName, sal_uInt16 nTyp ) +SwSetExpFieldType::SwSetExpFieldType( SwDoc* pDc, const OUString& rName, sal_uInt16 nTyp ) : SwValueFieldType( pDc, RES_SETEXPFLD ), sName( rName ), pOutlChgNd( 0 ), - sDelim( OUString(".") ), + sDelim( "." ), nType(nTyp), nLevel( UCHAR_MAX ), bDeleted( sal_False ) { @@ -494,7 +505,7 @@ SwFieldType* SwSetExpFieldType::Copy() const return pNew; } -const OUString& SwSetExpFieldType::GetName() const +OUString SwSetExpFieldType::GetName() const { return sName; } @@ -598,10 +609,10 @@ void SwSetExpFieldType::SetChapter( SwSetExpField& rFld, const SwNode& rNd ) const SwNodeNum & aNum = *(pTxtNd->GetNum()); // nur die Nummer besorgen, ohne Pre-/Post-fixstrings - String sNumber( pRule->MakeNumString(aNum, sal_False )); + OUString sNumber( pRule->MakeNumString(aNum, sal_False )); - if( sNumber.Len() ) - rFld.ChgExpStr( ( sNumber += sDelim ) += rFld.GetExpStr() ); + if( !sNumber.isEmpty() ) + rFld.ChgExpStr( sNumber + sDelim + rFld.GetExpStr() ); } else { @@ -622,7 +633,7 @@ bool SwSetExpFieldType::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const } break; case FIELD_PROP_PAR2: - rAny <<= OUString(GetDelimiter()); + rAny <<= GetDelimiter(); break; case FIELD_PROP_SHORT1: { @@ -649,11 +660,12 @@ bool SwSetExpFieldType::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) break; case FIELD_PROP_PAR2: { - String sTmp; - if( ::GetString( rAny, sTmp ).Len() ) + OUString sTmp; + rAny >>= sTmp; + if( !sTmp.isEmpty() ) SetDelimiter( sTmp ); else - SetDelimiter(OUString(" ")); + SetDelimiter( " " ); } break; case FIELD_PROP_SHORT1: @@ -674,13 +686,16 @@ bool SwSetExpFieldType::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) bool SwSeqFldList::InsertSort( _SeqFldLstElem* pNew ) { - sal_Unicode* p = pNew->sDlgEntry.GetBufferAccess(); - while( *p ) + OUStringBuffer aBuf(pNew->sDlgEntry); + const sal_Int32 nLen = aBuf.getLength(); + for (sal_Int32 i = 0; i < nLen; ++i) { - if( *p < 0x20 ) - *p = 0x20; - ++p; + if (aBuf[i]<' ') + { + aBuf[i]=' '; + } } + pNew->sDlgEntry = aBuf.makeStringAndClear(); sal_uInt16 nPos; bool bRet = SeekEntry( *pNew, &nPos ); @@ -699,11 +714,11 @@ bool SwSeqFldList::SeekEntry( const _SeqFldLstElem& rNew, sal_uInt16* pP ) const const CharClass& rCC = GetAppCharClass(); //#59900# Sorting should sort number correctly (e.g. "10" after "9" not after "1") - const String& rTmp2 = rNew.sDlgEntry; + const OUString rTmp2 = rNew.sDlgEntry; sal_Int32 nFndPos2 = 0; - String sNum2( rTmp2.GetToken( 0, ' ', nFndPos2 )); + const OUString sNum2( rTmp2.getToken( 0, ' ', nFndPos2 )); sal_Bool bIsNum2IsNumeric = rCC.isAsciiNumeric( sNum2 ); - sal_Int32 nNum2 = bIsNum2IsNumeric ? sNum2.ToInt32() : 0; + sal_Int32 nNum2 = bIsNum2IsNumeric ? sNum2.toInt32() : 0; nO--; while( nU <= nO ) @@ -711,18 +726,18 @@ bool SwSeqFldList::SeekEntry( const _SeqFldLstElem& rNew, sal_uInt16* pP ) const nM = nU + ( nO - nU ) / 2; //#59900# Sorting should sort number correctly (e.g. "10" after "9" not after "1") - const String& rTmp1 = maData[nM]->sDlgEntry; + const OUString rTmp1 = maData[nM]->sDlgEntry; sal_Int32 nFndPos1 = 0; - String sNum1( rTmp1.GetToken( 0, ' ', nFndPos1 )); + const OUString sNum1( rTmp1.getToken( 0, ' ', nFndPos1 )); sal_Int32 nCmp; if( bIsNum2IsNumeric && rCC.isNumeric( sNum1 ) ) { - sal_Int32 nNum1 = sNum1.ToInt32(); + sal_Int32 nNum1 = sNum1.toInt32(); nCmp = nNum2 - nNum1; if( 0 == nCmp ) - nCmp = rCaseColl.compareString( rTmp2.Copy( nFndPos2 ), - rTmp1.Copy( nFndPos1 )); + nCmp = rCaseColl.compareString( rTmp2.copy( nFndPos2 ), + rTmp1.copy( nFndPos1 )); } else nCmp = rColl.compareString( rTmp2, rTmp1 ); @@ -744,7 +759,7 @@ bool SwSeqFldList::SeekEntry( const _SeqFldLstElem& rNew, sal_uInt16* pP ) const return false; } -SwSetExpField::SwSetExpField(SwSetExpFieldType* pTyp, const String& rFormel, +SwSetExpField::SwSetExpField(SwSetExpFieldType* pTyp, const OUString& rFormel, sal_uLong nFmt) : SwFormulaField( pTyp, nFmt, 0.0 ), nSeqNo( USHRT_MAX ), nSubType(0) @@ -755,35 +770,28 @@ SwSetExpField::SwSetExpField(SwSetExpFieldType* pTyp, const String& rFormel, if( IsSequenceFld() ) { SwValueField::SetValue(1.0); - if( !rFormel.Len() ) + if( rFormel.isEmpty() ) { - String sFormel(rFormel); - sFormel += pTyp->GetName(); - sFormel += '+'; - sFormel += '1'; - SetFormula(sFormel); + SetFormula(pTyp->GetName() + "+1"); } } } -String SwSetExpField::Expand() const +OUString SwSetExpField::Expand() const { - String aStr; if (nSubType & nsSwExtendedSubType::SUB_CMD) { // we need the CommandString - aStr = GetTyp()->GetName(); - aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " = " )); - aStr += GetFormula(); + return GetTyp()->GetName() + " = " + GetFormula(); } - else if(!(nSubType & nsSwExtendedSubType::SUB_INVISIBLE)) + if(!(nSubType & nsSwExtendedSubType::SUB_INVISIBLE)) { // value is visible - aStr = sExpand; + return sExpand; } - return aStr; + return OUString(); } /// @return the field name -String SwSetExpField::GetFieldName() const +OUString SwSetExpField::GetFieldName() const { SwFldTypesEnum const nStrType( (IsSequenceFld()) ? TYP_SEQFLD @@ -791,15 +799,15 @@ String SwSetExpField::GetFieldName() const ? TYP_SETINPFLD : TYP_SETFLD ); - String aStr( SwFieldType::GetTypeStr( static_cast<sal_uInt16>(nStrType) ) ); - aStr += ' '; - aStr += GetTyp()->GetName(); + OUString aStr( + SwFieldType::GetTypeStr( static_cast<sal_uInt16>(nStrType) ) + + " " + + GetTyp()->GetName() ); // Sequence: without formula if (TYP_SEQFLD != nStrType) { - aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " = " ) ); - aStr += GetFormula(); + aStr += " = " + GetFormula(); } return aStr; } @@ -865,10 +873,12 @@ xub_StrLen SwGetExpField::GetReferenceTextPos( const SwFmtFld& rFmt, SwDoc& rDoc const SwTxtNode& rTxtNode = pTxtFld->GetTxtNode(); // xub_StrLen nRet = nHint ? nHint : *pTxtFld->GetStart() + 1; - String sNodeText = rTxtNode.GetTxt(); - sNodeText.Erase(0, nRet); - if(sNodeText.Len()) + OUString sNodeText = rTxtNode.GetTxt(); + + if(nRet<sNodeText.getLength()) { + sNodeText = sNodeText.copy(nRet); + // now check if sNodeText starts with a non-alphanumeric character plus blanks sal_uInt16 nSrcpt = g_pBreakIt->GetRealScriptOfText( sNodeText, 0 ); @@ -892,26 +902,26 @@ xub_StrLen SwGetExpField::GetReferenceTextPos( const SwFmtFld& rFmt, SwDoc& rDoc GetWhichOfScript( RES_CHRATR_LANGUAGE, nSrcpt )) ).GetLanguage(); LanguageTag aLanguageTag( eLang); CharClass aCC( aLanguageTag); - sal_Unicode c0 = sNodeText.GetChar(0); + sal_Unicode c0 = sNodeText[0]; sal_Bool bIsAlphaNum = aCC.isAlphaNumeric( sNodeText, 0 ); if( !bIsAlphaNum || (c0 == ' ' || c0 == '\t')) { // ignoring blanks nRet++; - unsigned i = 1; - while (i < sNodeText.Len() && - (sNodeText.GetChar(i) == ' ' || - sNodeText.GetChar(i) == '\t') + const sal_Int32 nLen = sNodeText.getLength(); + for (sal_Int32 i = 1; + i<nLen && (sNodeText[i]==' ' || sNodeText[i]=='\t'); + ++i ) - nRet++, i++; + ++nRet; } } } return nRet; } -const OUString& SwSetExpField::GetPar1() const +OUString SwSetExpField::GetPar1() const { return ((const SwSetExpFieldType*)GetTyp())->GetName(); } @@ -949,20 +959,18 @@ SwFieldType* SwInputFieldType::Copy() const return pType; } -SwInputField::SwInputField(SwInputFieldType* pTyp, const String& rContent, - const String& rPrompt, sal_uInt16 nSub, sal_uLong nFmt) : +SwInputField::SwInputField(SwInputFieldType* pTyp, const OUString& rContent, + const OUString& rPrompt, sal_uInt16 nSub, sal_uLong nFmt) : SwField(pTyp, nFmt), aContent(rContent), aPText(rPrompt), nSubType(nSub) { } -String SwInputField::GetFieldName() const +OUString SwInputField::GetFieldName() const { - String aStr(SwField::GetFieldName()); + OUString aStr(SwField::GetFieldName()); if ((nSubType & 0x00ff) == INP_USR) { - aStr += GetTyp()->GetName(); - aStr += ' '; - aStr += aContent; + aStr += GetTyp()->GetName() + " " + aContent; } return aStr; } @@ -979,21 +987,21 @@ SwField* SwInputField::Copy() const return pFld; } -String SwInputField::Expand() const +OUString SwInputField::Expand() const { - String sRet; if((nSubType & 0x00ff) == INP_TXT) - sRet = aContent; + return aContent; - else if( (nSubType & 0x00ff) == INP_USR ) + if( (nSubType & 0x00ff) == INP_USR ) { SwUserFieldType* pUserTyp = (SwUserFieldType*) ((SwInputFieldType*)GetTyp())->GetDoc()-> GetFldType( RES_USERFLD, aContent, false ); if( pUserTyp ) - sRet = pUserTyp->GetContent(); + return pUserTyp->GetContent(); } - return sRet; + + return OUString(); } bool SwInputField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const @@ -1001,16 +1009,16 @@ bool SwInputField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const switch( nWhichId ) { case FIELD_PROP_PAR1: - rAny <<= OUString( aContent ); + rAny <<= aContent; break; case FIELD_PROP_PAR2: - rAny <<= OUString( aPText ); + rAny <<= aPText; break; case FIELD_PROP_PAR3: - rAny <<= OUString( aHelp ); + rAny <<= aHelp; break; case FIELD_PROP_PAR4: - rAny <<= OUString( aToolTip ); + rAny <<= aToolTip; break; default: OSL_FAIL("illegal property"); @@ -1023,16 +1031,16 @@ bool SwInputField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) switch( nWhichId ) { case FIELD_PROP_PAR1: - rAny >>= aContent; + rAny >>= aContent; break; case FIELD_PROP_PAR2: - ::GetString( rAny, aPText ); + rAny >>= aPText; break; case FIELD_PROP_PAR3: - ::GetString( rAny, aHelp ); + rAny >>= aHelp; break; case FIELD_PROP_PAR4: - ::GetString( rAny, aToolTip ); + rAny >>= aToolTip; break; default: OSL_FAIL("illegal property"); @@ -1046,7 +1054,7 @@ void SwInputField::SetPar1(const OUString& rStr) aContent = rStr; } -const OUString& SwInputField::GetPar1() const +OUString SwInputField::GetPar1() const { return aContent; } @@ -1062,29 +1070,29 @@ OUString SwInputField::GetPar2() const return aPText; } -void SwInputField::SetHelp(const String & rStr) +void SwInputField::SetHelp(const OUString & rStr) { aHelp = rStr; } -String SwInputField::GetHelp() const +OUString SwInputField::GetHelp() const { return aHelp; } -void SwInputField::SetToolTip(const String & rStr) +void SwInputField::SetToolTip(const OUString & rStr) { aToolTip = rStr; } -String SwInputField::GetToolTip() const +OUString SwInputField::GetToolTip() const { return aToolTip; } sal_Bool SwInputField::isFormField() const { - return aHelp.Len() > 0 || aToolTip.Len() > 0; + return !aHelp.isEmpty() || !aToolTip.isEmpty(); } sal_uInt16 SwInputField::GetSubType() const @@ -1120,13 +1128,10 @@ bool SwSetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const rAny <<= OUString ( SwStyleNameMapper::GetProgName(GetPar1(), nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ) ); break; case FIELD_PROP_PAR2: - { - //I18N - if the formula contains only "TypeName+1" - //and it's one of the initially created sequence fields - //then the localized names has to be replaced by a programmatic name - OUString sMyFormula = SwXFieldMaster::LocalizeFormula(*this, GetFormula(), sal_True); - rAny <<= OUString( sMyFormula ); - } + //I18N - if the formula contains only "TypeName+1" + //and it's one of the initially created sequence fields + //then the localized names has to be replaced by a programmatic name + rAny <<= SwXFieldMaster::LocalizeFormula(*this, GetFormula(), sal_True); break; case FIELD_PROP_DOUBLE: rAny <<= (double)GetValue(); @@ -1139,7 +1144,7 @@ bool SwSetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const } break; case FIELD_PROP_PAR3: - rAny <<= OUString( aPText ); + rAny <<= aPText; break; case FIELD_PROP_BOOL3: { @@ -1154,7 +1159,7 @@ bool SwSetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const } break; case FIELD_PROP_PAR4: - rAny <<= OUString(GetExpStr()); + rAny <<= GetExpStr(); break; default: return SwField::QueryValue(rAny, nWhichId); @@ -1166,7 +1171,6 @@ bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) { sal_Int32 nTmp32 = 0; sal_Int16 nTmp16 = 0; - String sTmp; switch( nWhichId ) { case FIELD_PROP_BOOL2: @@ -1193,8 +1197,11 @@ bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) nSeqNo = nTmp16; break; case FIELD_PROP_PAR1: - SetPar1( SwStyleNameMapper::GetUIName( - ::GetString( rAny, sTmp ), nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ) ); + { + OUString sTmp; + rAny >>= sTmp; + SetPar1( SwStyleNameMapper::GetUIName( sTmp, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ) ); + } break; case FIELD_PROP_PAR2: { @@ -1203,8 +1210,7 @@ bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) //I18N - if the formula contains only "TypeName+1" //and it's one of the initially created sequence fields //then the localized names has to be replaced by a programmatic name - OUString sMyFormula = SwXFieldMaster::LocalizeFormula(*this, uTmp, sal_False); - SetFormula( sMyFormula ); + SetFormula( SwXFieldMaster::LocalizeFormula(*this, uTmp, sal_False) ); } break; case FIELD_PROP_DOUBLE: @@ -1220,7 +1226,7 @@ bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) SetSubType(static_cast<sal_uInt16>((GetSubType() & 0xff00) | nTmp32)); break; case FIELD_PROP_PAR3: - ::GetString( rAny, aPText ); + rAny >>= aPText; break; case FIELD_PROP_BOOL3: if(*(sal_Bool*) rAny.getValue()) @@ -1232,7 +1238,11 @@ bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) SetInputFlag(*(sal_Bool*) rAny.getValue()); break; case FIELD_PROP_PAR4: - ChgExpStr( ::GetString( rAny, sTmp )); + { + OUString sTmp; + rAny >>= sTmp; + ChgExpStr( sTmp ); + } break; default: return SwField::PutValue(rAny, nWhichId); diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx index 9db180b1c47d..e80657c9c051 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -68,7 +68,7 @@ static sal_uInt16 lcl_GetLanguageOfFormat( sal_uInt16 nLng, sal_uLong nFmt, // Globals /// field names -std::vector<String>* SwFieldType::pFldNames = 0; +std::vector<OUString>* SwFieldType::pFldNames = 0; namespace { @@ -118,15 +118,14 @@ namespace } -const String& SwFieldType::GetTypeStr(sal_uInt16 nTypeId) +OUString SwFieldType::GetTypeStr(sal_uInt16 nTypeId) { if( !pFldNames ) _GetFldName(); if( nTypeId < SwFieldType::pFldNames->size() ) return (*SwFieldType::pFldNames)[nTypeId]; - else - return aEmptyStr; + return OUString(); } // each field refences a field type that is unique for each document @@ -136,9 +135,9 @@ SwFieldType::SwFieldType( sal_uInt16 nWhichId ) { } -const OUString& SwFieldType::GetName() const +OUString SwFieldType::GetName() const { - return aEmptyOUStr; + return OUString(); } bool SwFieldType::QueryValue( uno::Any&, sal_uInt16 ) const @@ -221,7 +220,7 @@ sal_uInt16 SwField::GetTypeId() const } /// get name or content -String SwField::GetFieldName() const +OUString SwField::GetFieldName() const { sal_uInt16 nTypeId = GetTypeId(); if (RES_DATETIMEFLD == GetTyp()->Which()) @@ -229,18 +228,17 @@ String SwField::GetFieldName() const nTypeId = static_cast<sal_uInt16>( ((GetSubType() & DATEFLD) != 0) ? TYP_DATEFLD : TYP_TIMEFLD); } - String sRet = SwFieldType::GetTypeStr( nTypeId ); + OUString sRet = SwFieldType::GetTypeStr( nTypeId ); if (IsFixed()) { - sRet += ' '; - sRet += ViewShell::GetShellRes()->aFixedStr; + sRet += " " + OUString(ViewShell::GetShellRes()->aFixedStr); } return sRet; } -const OUString& SwField::GetPar1() const +OUString SwField::GetPar1() const { - return aEmptyOUStr; + return OUString(); } OUString SwField::GetPar2() const @@ -248,7 +246,7 @@ OUString SwField::GetPar2() const return OUString(); } -String SwField::GetFormula() const +OUString SwField::GetFormula() const { return GetPar2(); } @@ -380,7 +378,7 @@ sal_Bool SwField::IsFixed() const return bRet; } -String SwField::ExpandField(bool const bCached) const +OUString SwField::ExpandField(bool const bCached) const { if (!bCached) // #i85766# do not expand fields in clipboard documents { @@ -399,7 +397,7 @@ SwField * SwField::CopyField() const } /// expand numbering -String FormatNumber(sal_uInt32 nNum, sal_uInt32 nFormat) +OUString FormatNumber(sal_uInt32 nNum, sal_uInt32 nFormat) { if(SVX_NUM_PAGEDESC == nFormat) return OUString::number( nNum ); @@ -426,7 +424,7 @@ SwValueFieldType::SwValueFieldType( const SwValueFieldType& rTyp ) } /// return value formatted as string -String SwValueFieldType::ExpandValue( const double& rVal, +OUString SwValueFieldType::ExpandValue( const double& rVal, sal_uInt32 nFmt, sal_uInt16 nLng) const { if (rVal >= DBL_MAX) // error string for calculator @@ -477,19 +475,19 @@ String SwValueFieldType::ExpandValue( const double& rVal, return sExpand; } -String SwValueFieldType::DoubleToString(const double &rVal, +OUString SwValueFieldType::DoubleToString(const double &rVal, sal_uInt32 nFmt) const { SvNumberFormatter* pFormatter = pDoc->GetNumberFormatter(); const SvNumberformat* pEntry = pFormatter->GetEntry(nFmt); if (!pEntry) - return String(); + return OUString(); return DoubleToString(rVal, pEntry->GetLanguage()); } -String SwValueFieldType::DoubleToString( const double &rVal, +OUString SwValueFieldType::DoubleToString( const double &rVal, sal_uInt16 nLng ) const { SvNumberFormatter* pFormatter = pDoc->GetNumberFormatter(); @@ -639,12 +637,12 @@ SwFormulaField::SwFormulaField( const SwFormulaField& rFld ) { } -String SwFormulaField::GetFormula() const +OUString SwFormulaField::GetFormula() const { return sFormula; } -void SwFormulaField::SetFormula(const String& rStr) +void SwFormulaField::SetFormula(const OUString& rStr) { sFormula = rStr; @@ -659,7 +657,7 @@ void SwFormulaField::SetFormula(const String& rStr) } } -void SwFormulaField::SetExpandedFormula( const String& rStr ) +void SwFormulaField::SetExpandedFormula( const OUString& rStr ) { sal_uInt32 nFmt(GetFormat()); @@ -680,7 +678,7 @@ void SwFormulaField::SetExpandedFormula( const String& rStr ) sFormula = rStr; } -String SwFormulaField::GetExpandedFormula() const +OUString SwFormulaField::GetExpandedFormula() const { sal_uInt32 nFmt(GetFormat()); @@ -694,9 +692,7 @@ String SwFormulaField::GetExpandedFormula() const if (pFormatter->IsTextFormat(nFmt)) { OUString sTempIn(((SwValueFieldType *)GetTyp())->DoubleToString(GetValue(), nFmt)); - OUString sTempOut(sFormattedValue); - pFormatter->GetOutputString(sTempIn, nFmt, sTempOut, &pCol); - sFormattedValue = sTempOut; + pFormatter->GetOutputString(sTempIn, nFmt, sFormattedValue, &pCol); } else { @@ -708,7 +704,7 @@ String SwFormulaField::GetExpandedFormula() const return GetFormula(); } -String SwField::GetDescription() const +OUString SwField::GetDescription() const { return SW_RES(STR_FIELD); } diff --git a/sw/source/core/fields/flddat.cxx b/sw/source/core/fields/flddat.cxx index 4b17cb772b77..04cbcbd7cb41 100644 --- a/sw/source/core/fields/flddat.cxx +++ b/sw/source/core/fields/flddat.cxx @@ -57,7 +57,7 @@ SwDateTimeField::SwDateTimeField(SwDateTimeFieldType* pInitType, sal_uInt16 nSub } } -String SwDateTimeField::Expand() const +OUString SwDateTimeField::Expand() const { double fVal; diff --git a/sw/source/core/fields/flddropdown.cxx b/sw/source/core/fields/flddropdown.cxx index 6f6517a1e358..d81d1d8fd3a0 100644 --- a/sw/source/core/fields/flddropdown.cxx +++ b/sw/source/core/fields/flddropdown.cxx @@ -29,8 +29,6 @@ using namespace com::sun::star; using std::vector; -static String aEmptyString; - SwDropDownFieldType::SwDropDownFieldType() : SwFieldType(RES_DROPDOWN) { @@ -61,18 +59,18 @@ SwDropDownField::~SwDropDownField() { } -String SwDropDownField::Expand() const +OUString SwDropDownField::Expand() const { - String sSelect = GetSelectedItem(); - if(!sSelect.Len()) + OUString sSelect = GetSelectedItem(); + if (sSelect.isEmpty()) { vector<OUString>::const_iterator aIt = aValues.begin(); if ( aIt != aValues.end()) sSelect = *aIt; } // if still no list value is available a default text of 10 spaces is to be set - if(!sSelect.Len()) - sSelect.AppendAscii ( RTL_CONSTASCII_STRINGPARAM (" ")); + if (sSelect.isEmpty()) + sSelect = " "; return sSelect; } @@ -81,7 +79,7 @@ SwField * SwDropDownField::Copy() const return new SwDropDownField(*this); } -const OUString & SwDropDownField::GetPar1() const +OUString SwDropDownField::GetPar1() const { return GetSelectedItem(); } @@ -104,7 +102,7 @@ void SwDropDownField::SetPar2(const OUString & rName) void SwDropDownField::SetItems(const vector<OUString> & rItems) { aValues = rItems; - aSelectedItem = aEmptyString; + aSelectedItem = OUString(); } void SwDropDownField::SetItems(const uno::Sequence<OUString> & rItems) @@ -115,7 +113,7 @@ void SwDropDownField::SetItems(const uno::Sequence<OUString> & rItems) for (int i = 0; i < aCount; i++) aValues.push_back(rItems[i]); - aSelectedItem = aEmptyString; + aSelectedItem = OUString(); } uno::Sequence<OUString> SwDropDownField::GetItemSequence() const @@ -134,22 +132,22 @@ uno::Sequence<OUString> SwDropDownField::GetItemSequence() const return aSeq; } -const OUString & SwDropDownField::GetSelectedItem() const +OUString SwDropDownField::GetSelectedItem() const { return aSelectedItem; } -const OUString & SwDropDownField::GetName() const +OUString SwDropDownField::GetName() const { return aName; } -const OUString & SwDropDownField::GetHelp() const +OUString SwDropDownField::GetHelp() const { return aHelp; } -const OUString & SwDropDownField::GetToolTip() const +OUString SwDropDownField::GetToolTip() const { return aToolTip; } @@ -188,16 +186,16 @@ bool SwDropDownField::QueryValue(::uno::Any &rVal, sal_uInt16 nWhich) const switch( nWhich ) { case FIELD_PROP_PAR1: - rVal <<= GetSelectedItem(); + rVal <<= aSelectedItem; break; case FIELD_PROP_PAR2: - rVal <<= GetName(); + rVal <<= aName; break; case FIELD_PROP_PAR3: - rVal <<= GetHelp(); + rVal <<= aHelp; break; case FIELD_PROP_PAR4: - rVal <<= GetToolTip(); + rVal <<= aToolTip; break; case FIELD_PROP_STRINGS: rVal <<= GetItemSequence(); @@ -225,30 +223,15 @@ bool SwDropDownField::PutValue(const uno::Any &rVal, break; case FIELD_PROP_PAR2: - { - OUString aTmpStr; - rVal >>= aTmpStr; - - SetName(aTmpStr); - } + rVal >>= aName; break; case FIELD_PROP_PAR3: - { - OUString aTmpStr; - rVal >>= aTmpStr; - - SetHelp(aTmpStr); - } + rVal >>= aHelp; break; case FIELD_PROP_PAR4: - { - OUString aTmpStr; - rVal >>= aTmpStr; - - SetToolTip(aTmpStr); - } + rVal >>= aToolTip; break; case FIELD_PROP_STRINGS: diff --git a/sw/source/core/fields/macrofld.cxx b/sw/source/core/fields/macrofld.cxx index a073a842d229..0732979c4564 100644 --- a/sw/source/core/fields/macrofld.cxx +++ b/sw/source/core/fields/macrofld.cxx @@ -42,13 +42,13 @@ SwFieldType* SwMacroFieldType::Copy() const SwMacroField::SwMacroField(SwMacroFieldType* pInitType, - const String& rLibAndName, const String& rTxt) : + const OUString& rLibAndName, const OUString& rTxt) : SwField(pInitType), aMacro(rLibAndName), aText(rTxt), bIsScriptURL(sal_False) { bIsScriptURL = isScriptURL(aMacro); } -String SwMacroField::Expand() const +OUString SwMacroField::Expand() const { return aText ; } @@ -58,20 +58,17 @@ SwField* SwMacroField::Copy() const return new SwMacroField((SwMacroFieldType*)GetTyp(), aMacro, aText); } -String SwMacroField::GetFieldName() const +OUString SwMacroField::GetFieldName() const { - String aStr(GetTyp()->GetName()); - aStr += ' '; - aStr += aMacro; - return aStr; + return GetTyp()->GetName() + " " + aMacro; } -String SwMacroField::GetLibName() const +OUString SwMacroField::GetLibName() const { // if it is a Scripting Framework macro return an empty string if (bIsScriptURL) { - return String(); + return OUString(); } if (!aMacro.isEmpty()) @@ -84,11 +81,11 @@ String SwMacroField::GetLibName() const return aMacro.copy(0, nPos); } - OSL_FAIL("No MacroName"); - return aEmptyStr; + OSL_FAIL("No LibName"); + return OUString(); } -String SwMacroField::GetMacroName() const +OUString SwMacroField::GetMacroName() const { if (!aMacro.isEmpty()) { @@ -108,14 +105,14 @@ String SwMacroField::GetMacroName() const } OSL_FAIL("No MacroName"); - return aEmptyStr; + return OUString(); } SvxMacro SwMacroField::GetSvxMacro() const { - if (bIsScriptURL) + if (bIsScriptURL) { - return SvxMacro(aMacro, String(), EXTENDED_STYPE); + return SvxMacro(aMacro, OUString(), EXTENDED_STYPE); } else { @@ -131,7 +128,7 @@ void SwMacroField::SetPar1(const OUString& rStr) } /// Get macro -const OUString& SwMacroField::GetPar1() const +OUString SwMacroField::GetPar1() const { return aMacro; } @@ -153,16 +150,16 @@ bool SwMacroField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const switch( nWhichId ) { case FIELD_PROP_PAR1: - rAny <<= OUString(GetMacroName()); + rAny <<= GetMacroName(); break; case FIELD_PROP_PAR2: - rAny <<= OUString(aText); + rAny <<= aText; break; case FIELD_PROP_PAR3: - rAny <<= OUString(GetLibName()); + rAny <<= GetLibName(); break; case FIELD_PROP_PAR4: - rAny <<= bIsScriptURL ? OUString(GetMacroName()): OUString(); + rAny <<= bIsScriptURL ? GetMacroName() : OUString(); break; default: OSL_FAIL("illegal property"); @@ -200,17 +197,17 @@ bool SwMacroField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) /// create an internally used macro name from the library and macro name parts void SwMacroField::CreateMacroString( OUString& rMacro, - const String& rMacroName, - const String& rLibraryName ) + const OUString& rMacroName, + const OUString& rLibraryName ) { // concatenate library and name; use dot only if both strings have content rMacro = rLibraryName; - if ( rLibraryName.Len() > 0 && rMacroName.Len() > 0 ) + if ( !rLibraryName.isEmpty() && !rMacroName.isEmpty() ) rMacro += OUString('.'); rMacro += rMacroName; } -sal_Bool SwMacroField::isScriptURL( const String& str ) +sal_Bool SwMacroField::isScriptURL( const OUString& str ) { uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index 19743c5f9514..7bdcc0c1a4e6 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -195,7 +195,7 @@ bool IsFrameBehind( const SwTxtNode& rMyNd, sal_uInt16 nMySttPos, /// get references SwGetRefField::SwGetRefField( SwGetRefFieldType* pFldType, - const String& rSetRef, sal_uInt16 nSubTyp, + const OUString& rSetRef, sal_uInt16 nSubTyp, sal_uInt16 nSeqenceNo, sal_uLong nFmt ) : SwField( pFldType, nFmt ), sSetRefName( rSetRef ), @@ -208,7 +208,7 @@ SwGetRefField::~SwGetRefField() { } -String SwGetRefField::GetDescription() const +OUString SwGetRefField::GetDescription() const { return SW_RES(STR_REFERENCE); } @@ -244,36 +244,33 @@ const SwTxtNode* SwGetRefField::GetReferencedTxtNode() const } // #i85090# -String SwGetRefField::GetExpandedTxtOfReferencedTxtNode() const +OUString SwGetRefField::GetExpandedTxtOfReferencedTxtNode() const { const SwTxtNode* pReferencedTxtNode( GetReferencedTxtNode() ); return pReferencedTxtNode - ? pReferencedTxtNode->GetExpandTxt( 0, STRING_LEN, true, true ) - : aEmptyStr; + ? OUString(pReferencedTxtNode->GetExpandTxt( 0, STRING_LEN, true, true )) + : OUString(); } -String SwGetRefField::Expand() const +OUString SwGetRefField::Expand() const { return sTxt; } -String SwGetRefField::GetFieldName() const +OUString SwGetRefField::GetFieldName() const { - if ( GetTyp()->GetName().getLength() > 0 || sSetRefName.getLength() > 0 ) + const OUString aName = GetTyp()->GetName(); + if ( !aName.isEmpty() || !sSetRefName.isEmpty() ) { - String aStr(GetTyp()->GetName()); - aStr += ' '; - aStr += sSetRefName; - return aStr; + return aName + " " + sSetRefName; } - else - return Expand(); + return Expand(); } // #i81002# - parameter <pFldTxtAttr> added void SwGetRefField::UpdateField( const SwTxtFld* pFldTxtAttr ) { - sTxt.Erase(); + sTxt = OUString(); SwDoc* pDoc = ((SwGetRefFieldType*)GetTyp())->GetDoc(); // finding the reference target (the number) @@ -396,16 +393,23 @@ void SwGetRefField::UpdateField( const SwTxtFld* pFldTxtAttr ) sTxt = pTxtNd->GetExpandTxt( nStart, nEnd - nStart ); // alle Sonderzeichen entfernen (durch Blanks ersetzen): - if( sTxt.Len() ) + if( !sTxt.isEmpty() ) { sTxt = comphelper::string::remove(sTxt, 0xad); - for( sal_Unicode* p = sTxt.GetBufferAccess(); *p; ++p ) + OUStringBuffer aBuf(sTxt); + const sal_Int32 l = aBuf.getLength(); + for (sal_Int32 i=0; i<l; ++i) { - if( *p < 0x20 ) - *p = 0x20; - else if(*p == 0x2011) - *p = '-'; + if (aBuf[i]<' ') + { + aBuf[i]=' '; + } + else if (aBuf[i]==0x2011) + { + aBuf[i]='-'; + } } + sTxt = aBuf.makeStringAndClear(); } } } @@ -491,7 +495,7 @@ void SwGetRefField::UpdateField( const SwTxtFld* pFldTxtAttr ) } // #i81002# -String SwGetRefField::MakeRefNumStr( const SwTxtNode& rTxtNodeOfField, +OUString SwGetRefField::MakeRefNumStr( const SwTxtNode& rTxtNodeOfField, const SwTxtNode& rTxtNodeOfReferencedItem, const sal_uInt32 nRefNumFormat ) const { @@ -562,7 +566,7 @@ String SwGetRefField::MakeRefNumStr( const SwTxtNode& rTxtNodeOfField, nRestrictInclToThisLevel ); } - return String(); + return OUString(); } SwField* SwGetRefField::Copy() const @@ -575,7 +579,7 @@ SwField* SwGetRefField::Copy() const } /// get reference name -const OUString& SwGetRefField::GetPar1() const +OUString SwGetRefField::GetPar1() const { return sSetRefName; } @@ -651,7 +655,7 @@ bool SwGetRefField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const } break; case FIELD_PROP_PAR3: - rAny <<= OUString(Expand()); + rAny <<= Expand(); break; case FIELD_PROP_SHORT1: rAny <<= (sal_Int16)nSeqNo; @@ -720,7 +724,11 @@ bool SwGetRefField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) } break; case FIELD_PROP_PAR3: - SetExpand( ::GetString( rAny, sTmp )); + { + OUString sTmpStr; + rAny >>= sTmpStr; + SetExpand( sTmpStr ); + } break; case FIELD_PROP_SHORT1: { @@ -741,7 +749,7 @@ void SwGetRefField::ConvertProgrammaticToUIName() if(GetTyp() && REF_SEQUENCEFLD == nSubType) { SwDoc* pDoc = ((SwGetRefFieldType*)GetTyp())->GetDoc(); - const String& rPar1 = GetPar1(); + const OUString rPar1 = GetPar1(); // don't convert when the name points to an existing field type if(!pDoc->GetFldType(RES_SETEXPFLD, rPar1, false)) { @@ -805,7 +813,7 @@ void SwGetRefFieldType::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew NotifyClients( pOld, pNew ); } -SwTxtNode* SwGetRefFieldType::FindAnchor( SwDoc* pDoc, const String& rRefMark, +SwTxtNode* SwGetRefFieldType::FindAnchor( SwDoc* pDoc, const OUString& rRefMark, sal_uInt16 nSubType, sal_uInt16 nSeqNo, sal_uInt16* pStt, sal_uInt16* pEnd ) { @@ -916,7 +924,7 @@ SwTxtNode* SwGetRefFieldType::FindAnchor( SwDoc* pDoc, const String& rRefMark, struct _RefIdsMap { private: - String aName; + OUString aName; std::set<sal_uInt16> aIds; std::set<sal_uInt16> aDstIds; std::map<sal_uInt16, sal_uInt16> sequencedIds; /// ID numbers sorted by sequence number. @@ -929,11 +937,11 @@ private: sal_uInt16 GetFirstUnusedId( std::set<sal_uInt16> &rIds ); public: - _RefIdsMap( const String& rName ) : aName( rName ), bInit( false ) {} + _RefIdsMap( const OUString& rName ) : aName( rName ), bInit( false ) {} void Check( SwDoc& rDoc, SwDoc& rDestDoc, SwGetRefField& rFld, bool bField ); - String GetName() { return aName; } + OUString GetName() { return aName; } }; typedef boost::ptr_vector<_RefIdsMap> _RefIdsMaps; @@ -1093,7 +1101,7 @@ void SwGetRefFieldType::MergeWithOtherDoc( SwDoc& rDestDoc ) _RefIdsMap* pMap = 0; for( sal_uInt16 n = aFldMap.size(); n; ) { - if( aFldMap[ --n ].GetName().Equals(rRefFld.GetSetRefName()) ) + if( aFldMap[ --n ].GetName()==rRefFld.GetSetRefName() ) { pMap = &aFldMap[ n ]; break; diff --git a/sw/source/core/fields/scrptfld.cxx b/sw/source/core/fields/scrptfld.cxx index 48b367652c08..22ea9db9400f 100644 --- a/sw/source/core/fields/scrptfld.cxx +++ b/sw/source/core/fields/scrptfld.cxx @@ -34,18 +34,18 @@ SwFieldType* SwScriptFieldType::Copy() const } SwScriptField::SwScriptField( SwScriptFieldType* pInitType, - const String& rType, const String& rCode, + const OUString& rType, const OUString& rCode, sal_Bool bURL ) : SwField( pInitType ), sType( rType ), sCode( rCode ), bCodeURL( bURL ) { } -String SwScriptField::GetDescription() const +OUString SwScriptField::GetDescription() const { return SW_RES(STR_SCRIPT); } -String SwScriptField::Expand() const +OUString SwScriptField::Expand() const { return aEmptyStr; } @@ -61,7 +61,7 @@ void SwScriptField::SetPar1( const OUString& rStr ) sType = rStr; } -const OUString& SwScriptField::GetPar1() const +OUString SwScriptField::GetPar1() const { return sType; } @@ -82,10 +82,10 @@ bool SwScriptField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const switch( nWhichId ) { case FIELD_PROP_PAR1: - rAny <<= OUString( sType ); + rAny <<= sType; break; case FIELD_PROP_PAR2: - rAny <<= OUString( sCode ); + rAny <<= sCode; break; case FIELD_PROP_BOOL1: rAny.setValue(&bCodeURL, ::getBooleanCppuType()); diff --git a/sw/source/core/fields/tblcalc.cxx b/sw/source/core/fields/tblcalc.cxx index 3b18763ffa81..2d310a653db0 100644 --- a/sw/source/core/fields/tblcalc.cxx +++ b/sw/source/core/fields/tblcalc.cxx @@ -51,7 +51,7 @@ void SwTblField::CalcField( SwTblCalcPara& rCalcPara ) ChgValid( !rCalcPara.IsStackOverFlow() ); // is the value again valid? } -SwTblField::SwTblField( SwTblFieldType* pInitType, const String& rFormel, +SwTblField::SwTblField( SwTblFieldType* pInitType, const OUString& rFormel, sal_uInt16 nType, sal_uLong nFmt ) : SwValueField( pInitType, nFmt ), SwTableFormula( rFormel ), nSubType(nType) @@ -70,12 +70,9 @@ SwField* SwTblField::Copy() const return pTmp; } -String SwTblField::GetFieldName() const +OUString SwTblField::GetFieldName() const { - String aStr(GetTyp()->GetName()); - aStr += ' '; - aStr += const_cast<SwTblField *>(this)->GetCommand(); - return aStr; + return GetTyp()->GetName() + " " + const_cast<SwTblField *>(this)->GetCommand(); } /// search TextNode containing this field @@ -91,7 +88,7 @@ const SwNode* SwTblField::GetNodeOfFormula() const return 0; } -String SwTblField::GetCommand() +OUString SwTblField::GetCommand() { if (EXTRNL_NAME != GetNameType()) { @@ -103,29 +100,24 @@ String SwTblField::GetCommand() } } return (EXTRNL_NAME == GetNameType()) - ? SwTableFormula::GetFormula() - : String(); + ? OUString(SwTableFormula::GetFormula()) + : OUString(); } -String SwTblField::Expand() const +OUString SwTblField::Expand() const { - String aStr; if (nSubType & nsSwExtendedSubType::SUB_CMD) { - aStr = const_cast<SwTblField *>(this)->GetCommand(); + return const_cast<SwTblField *>(this)->GetCommand(); } - else + + if(nSubType & nsSwGetSetExpType::GSE_STRING) { - aStr = sExpand; - if(nSubType & nsSwGetSetExpType::GSE_STRING) - { - // es ist ein String - aStr = sExpand; - aStr.Erase( 0,1 ); - aStr.Erase( aStr.Len()-1, 1 ); - } + // es ist ein String + return sExpand.copy(1, sExpand.getLength()-2); } - return aStr; + + return sExpand; } sal_uInt16 SwTblField::GetSubType() const @@ -165,7 +157,7 @@ bool SwTblField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const sal_uInt16 nOldSubType = nSubType; SwTblField* pThis = (SwTblField*)this; pThis->nSubType |= nsSwExtendedSubType::SUB_CMD; - rAny <<= OUString( Expand() ); + rAny <<= Expand(); pThis->nSubType = nOldSubType; } break; @@ -176,7 +168,7 @@ bool SwTblField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const } break; case FIELD_PROP_PAR1: - rAny <<= OUString(GetExpStr()); + rAny <<= GetExpStr(); break; case FIELD_PROP_FORMAT: rAny <<= (sal_Int32)GetFormat(); @@ -190,11 +182,14 @@ bool SwTblField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const bool SwTblField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) { bool bRet = true; - String sTmp; switch ( nWhichId ) { case FIELD_PROP_PAR2: - SetFormula( ::GetString( rAny, sTmp )); + { + OUString sTmp; + rAny >>= sTmp; + SetFormula( sTmp ); + } break; case FIELD_PROP_BOOL1: if(*(sal_Bool*)rAny.getValue()) @@ -203,7 +198,11 @@ bool SwTblField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) nSubType = nsSwGetSetExpType::GSE_FORMULA; break; case FIELD_PROP_PAR1: - ChgExpStr( ::GetString( rAny, sTmp )); + { + OUString sTmp; + rAny >>= sTmp; + ChgExpStr( sTmp ); + } break; case FIELD_PROP_FORMAT: { diff --git a/sw/source/core/fields/usrfld.cxx b/sw/source/core/fields/usrfld.cxx index 21aab3236008..35b726178f9d 100644 --- a/sw/source/core/fields/usrfld.cxx +++ b/sw/source/core/fields/usrfld.cxx @@ -41,13 +41,12 @@ SwUserField::SwUserField(SwUserFieldType* pTyp, sal_uInt16 nSub, sal_uInt32 nFmt { } -String SwUserField::Expand() const +OUString SwUserField::Expand() const { - String sStr; if(!(nSubType & nsSwExtendedSubType::SUB_INVISIBLE)) - sStr = ((SwUserFieldType*)GetTyp())->Expand(GetFormat(), nSubType, GetLanguage()); + return ((SwUserFieldType*)GetTyp())->Expand(GetFormat(), nSubType, GetLanguage()); - return sStr; + return OUString(); } SwField* SwUserField::Copy() const @@ -57,14 +56,11 @@ SwField* SwUserField::Copy() const return pTmp; } -String SwUserField::GetFieldName() const +OUString SwUserField::GetFieldName() const { - String aStr(SwFieldType::GetTypeStr(TYP_USERFLD)); - aStr += ' '; - aStr += GetTyp()->GetName(); - aStr.AppendAscii(" = "); - aStr += static_cast<SwUserFieldType*>(GetTyp())->GetContent(); - return aStr; + return SwFieldType::GetTypeStr(TYP_USERFLD) + + " " + GetTyp()->GetName() + " = " + + static_cast<SwUserFieldType*>(GetTyp())->GetContent(); } double SwUserField::GetValue() const @@ -78,7 +74,7 @@ void SwUserField::SetValue( const double& rVal ) } /// Get name -const OUString& SwUserField::GetPar1() const +OUString SwUserField::GetPar1() const { return ((const SwUserFieldType*)GetTyp())->GetName(); } @@ -159,7 +155,7 @@ bool SwUserField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) return true; } -SwUserFieldType::SwUserFieldType( SwDoc* pDocPtr, const String& aNam ) +SwUserFieldType::SwUserFieldType( SwDoc* pDocPtr, const OUString& aNam ) : SwValueFieldType( pDocPtr, RES_USERFLD ), nValue( 0 ), nType(nsSwGetSetExpType::GSE_STRING) @@ -171,18 +167,16 @@ SwUserFieldType::SwUserFieldType( SwDoc* pDocPtr, const String& aNam ) EnableFormat(sal_False); // Do not use a Numberformatter } -String SwUserFieldType::Expand(sal_uInt32 nFmt, sal_uInt16 nSubType, sal_uInt16 nLng) +OUString SwUserFieldType::Expand(sal_uInt32 nFmt, sal_uInt16 nSubType, sal_uInt16 nLng) { - String aStr(aContent); if((nType & nsSwGetSetExpType::GSE_EXPR) && !(nSubType & nsSwExtendedSubType::SUB_CMD)) { EnableFormat(sal_True); - aStr = ExpandValue(nValue, nFmt, nLng); + return ExpandValue(nValue, nFmt, nLng); } - else - EnableFormat(sal_False); // Do not use a Numberformatter - return aStr; + EnableFormat(sal_False); // Do not use a Numberformatter + return aContent; } SwFieldType* SwUserFieldType::Copy() const @@ -197,7 +191,7 @@ SwFieldType* SwUserFieldType::Copy() const return pTmp; } -const OUString& SwUserFieldType::GetName() const +OUString SwUserFieldType::GetName() const { return aName; } @@ -233,7 +227,7 @@ double SwUserFieldType::GetValue( SwCalc& rCalc ) return nValue; } -String SwUserFieldType::GetContent( sal_uInt32 nFmt ) +OUString SwUserFieldType::GetContent( sal_uInt32 nFmt ) { if (nFmt && nFmt != SAL_MAX_UINT32) { @@ -245,11 +239,11 @@ String SwUserFieldType::GetContent( sal_uInt32 nFmt ) pFormatter->GetOutputString(GetValue(), nFmt, sFormattedValue, &pCol); return sFormattedValue; } - else - return aContent; + + return aContent; } -void SwUserFieldType::SetContent( const String& rStr, sal_uInt32 nFmt ) +void SwUserFieldType::SetContent( const OUString& rStr, sal_uInt32 nFmt ) { if( aContent != rStr ) { @@ -285,7 +279,7 @@ bool SwUserFieldType::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const rAny <<= (double) nValue; break; case FIELD_PROP_PAR2: - rAny <<= OUString(aContent); + rAny <<= aContent; break; case FIELD_PROP_BOOL1: { @@ -316,7 +310,7 @@ bool SwUserFieldType::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) } break; case FIELD_PROP_PAR2: - ::GetString( rAny, aContent ); + rAny >>= aContent; break; case FIELD_PROP_BOOL1: if(*(sal_Bool*)rAny.getValue()) diff --git a/sw/source/core/inc/docfld.hxx b/sw/source/core/inc/docfld.hxx index f30a366a7199..906d21d4d09a 100644 --- a/sw/source/core/inc/docfld.hxx +++ b/sw/source/core/inc/docfld.hxx @@ -133,8 +133,8 @@ struct SwCalcFldType : public SwHash }; // search for the string that was saved under rName in the hash table -void LookString( SwHash** ppTbl, sal_uInt16 nSize, const String& rName, - String& rRet, sal_uInt16* pPos = 0 ); +OUString LookString( SwHash** ppTbl, sal_uInt16 nSize, const OUString& rName, + sal_uInt16* pPos = 0 ); const int GETFLD_ALL = 3; // combine flags via OR const int GETFLD_CALC = 1; diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index fb0f24d2c0d1..62335b3afd08 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -1807,7 +1807,8 @@ void WW8Export::OutputField( const SwField* pFld, ww::eField eFldType, if ( nSubType == REF_SETREFATTR || nSubType == REF_BOOKMARK ) { - aLinkStr = GetBookmarkName( nSubType, &rRFld.GetSetRefName(), 0 ); + const OUString aRefName(rRFld.GetSetRefName()); + aLinkStr = GetBookmarkName( nSubType, &aRefName, 0 ); } else if ( nSubType == REF_FOOTNOTE || nSubType == REF_ENDNOTE ) @@ -2808,9 +2809,11 @@ void AttributeOutputBase::TextField( const SwFmtFld& rField ) eFld = ww::eREF; break; } - sStr = FieldString(eFld); - sStr += GetExport().GetBookmarkName(nSubType, - &rRFld.GetSetRefName(), 0); + { + const OUString aRefName(rRFld.GetSetRefName()); + sStr = FieldString(eFld); + sStr += GetExport().GetBookmarkName(nSubType, &aRefName, 0); + } switch (pFld->GetFormat()) { case REF_NUMBER: diff --git a/sw/source/ui/fldui/fldfunc.cxx b/sw/source/ui/fldui/fldfunc.cxx index f8eec49e6c70..80f5e1e44374 100644 --- a/sw/source/ui/fldui/fldfunc.cxx +++ b/sw/source/ui/fldui/fldfunc.cxx @@ -284,7 +284,7 @@ IMPL_LINK_NOARG(SwFldFuncPage, TypeHdl) { case TYP_MACROFLD: bMacro = sal_True; - if (GetFldMgr().GetMacroPath().Len()) + if (!GetFldMgr().GetMacroPath().isEmpty()) bValue = sal_True; else bInsert = sal_False; @@ -507,7 +507,7 @@ void SwFldFuncPage::UpdateSubType() if (nTypeId == TYP_MACROFLD) { - sal_Bool bHasMacro = GetFldMgr().GetMacroPath().Len() != 0; + const bool bHasMacro = !GetFldMgr().GetMacroPath().isEmpty(); if (bHasMacro) { diff --git a/sw/source/ui/fldui/fldmgr.cxx b/sw/source/ui/fldui/fldmgr.cxx index d9e0d569c386..7c55bd24b63c 100644 --- a/sw/source/ui/fldui/fldmgr.cxx +++ b/sw/source/ui/fldui/fldmgr.cxx @@ -274,7 +274,7 @@ SwFldMgr::~SwFldMgr() Description: organise RefMark by names --------------------------------------------------------------------*/ -bool SwFldMgr::CanInsertRefMark( const String& rStr ) +bool SwFldMgr::CanInsertRefMark( const OUString& rStr ) { bool bRet = false; SwWrtShell *pSh = pWrtShell ? pWrtShell : lcl_GetShell(); @@ -296,7 +296,7 @@ bool SwFldMgr::CanInsertRefMark( const String& rStr ) Description: access over ResIds --------------------------------------------------------------------*/ -void SwFldMgr::RemoveFldType(sal_uInt16 nResId, const String& rName ) +void SwFldMgr::RemoveFldType(sal_uInt16 nResId, const OUString& rName ) { SwWrtShell * pSh = pWrtShell ? pWrtShell : lcl_GetShell(); OSL_ENSURE(pSh, "no SwWrtShell found"); @@ -320,7 +320,7 @@ SwFieldType* SwFldMgr::GetFldType(sal_uInt16 nResId, sal_uInt16 nId) const } -SwFieldType* SwFldMgr::GetFldType(sal_uInt16 nResId, const String& rName) const +SwFieldType* SwFldMgr::GetFldType(sal_uInt16 nResId, const OUString& rName) const { SwWrtShell * pSh = pWrtShell ? pWrtShell : lcl_GetShell(); OSL_ENSURE(pSh, "no SwWrtShell found"); @@ -340,9 +340,9 @@ SwField* SwFldMgr::GetCurFld() pCurFld = NULL; // initialise strings and format - aCurPar1.Erase(); - aCurPar2.Erase(); - sCurFrame.Erase(); + aCurPar1 = OUString(); + aCurPar2 = OUString(); + sCurFrame = OUString(); nCurFmt = 0; if(!pCurFld) @@ -444,7 +444,7 @@ sal_uInt16 SwFldMgr::GetTypeId(sal_uInt16 nPos) } -const String& SwFldMgr::GetTypeStr(sal_uInt16 nPos) +OUString SwFldMgr::GetTypeStr(sal_uInt16 nPos) { OSL_ENSURE(nPos < ::GetPackCount(), "forbidden TypeId"); @@ -453,12 +453,12 @@ const String& SwFldMgr::GetTypeStr(sal_uInt16 nPos) // special treatment for date/time fields (without var/fix) if( TYP_DATEFLD == nFldWh ) { - static String g_aDate( SW_RES( STR_DATEFLD ) ); + static OUString g_aDate( SW_RES( STR_DATEFLD ) ); return g_aDate; } if( TYP_TIMEFLD == nFldWh ) { - static String g_aTime( SW_RES( STR_TIMEFLD ) ); + static OUString g_aTime( SW_RES( STR_TIMEFLD ) ); return g_aTime; } @@ -515,7 +515,7 @@ bool SwFldMgr::GetSubTypes(sal_uInt16 nTypeId, std::vector<OUString>& rToFill) } case TYP_INPUTFLD: { - rToFill.push_back(String(SW_RESSTR(aSwFlds[nPos].nSubTypeStart))); + rToFill.push_back(SW_RES(aSwFlds[nPos].nSubTypeStart)); // move on at generic types } case TYP_DDEFLD: @@ -574,18 +574,18 @@ bool SwFldMgr::GetSubTypes(sal_uInt16 nTypeId, std::vector<OUString>& rToFill) for(sal_uInt16 i = 0; i < nCount; ++i) { - String pNew; + OUString sNew; if (nTypeId == TYP_DOCINFOFLD) { if ( i == DI_CUSTOM ) - pNew = String(SW_RES( STR_CUSTOM )); + sNew = SW_RES( STR_CUSTOM ); else - pNew = ViewShell::GetShellRes()->aDocInfoLst[i]; + sNew = ViewShell::GetShellRes()->aDocInfoLst[i]; } else - pNew = SW_RESSTR(aSwFlds[nPos].nSubTypeStart + i); + sNew = SW_RES(aSwFlds[nPos].nSubTypeStart + i); - rToFill.push_back(pNew); + rToFill.push_back(sNew); } } } @@ -658,15 +658,14 @@ sal_uInt16 SwFldMgr::GetFormatCount(sal_uInt16 nTypeId, bool bIsText, sal_Bool b --------------------------------------------------------------------*/ -String SwFldMgr::GetFormatStr(sal_uInt16 nTypeId, sal_uLong nFormatId) const +OUString SwFldMgr::GetFormatStr(sal_uInt16 nTypeId, sal_uLong nFormatId) const { - String aRet; OSL_ENSURE(nTypeId < TYP_END, "forbidden TypeId"); const sal_uInt16 nPos = GetPos(nTypeId); if(nPos == USHRT_MAX) - return aRet; + return OUString(); sal_uLong nStart; @@ -676,8 +675,10 @@ String SwFldMgr::GetFormatStr(sal_uInt16 nTypeId, sal_uLong nFormatId) const nFormatId &= ~FF_FIXED; // mask out Fixed-Flag if((nStart + nFormatId) < aSwFlds[nPos].nFmtEnd) - aRet = SW_RESSTR((sal_uInt16)(nStart + nFormatId)); - else if( FMT_NUM_BEGIN == nStart) + return SW_RES((sal_uInt16)(nStart + nFormatId)); + + OUString aRet; + if( FMT_NUM_BEGIN == nStart) { if(xNumberingInfo.is()) { @@ -931,7 +932,7 @@ sal_Bool SwFldMgr::InsertFld( const SwInsertFld_Data& rData, SwPaM *pPam ) } case TYP_CHAPTERFLD: { - sal_uInt16 nByte = (sal_uInt16)rData.sPar2.ToInt32(); + sal_uInt16 nByte = (sal_uInt16)rData.sPar2.toInt32(); SwChapterFieldType* pTyp = (SwChapterFieldType*)pCurShell->GetFldType(0, RES_CHAPTERFLD); pFld = new SwChapterField(pTyp, nFormatId); @@ -945,7 +946,7 @@ sal_Bool SwFldMgr::InsertFld( const SwInsertFld_Data& rData, SwPaM *pPam ) case TYP_PREVPAGEFLD: case TYP_PAGENUMBERFLD: { - short nOff = (short)rData.sPar2.ToInt32(); + short nOff = (short)rData.sPar2.toInt32(); if(rData.nTypeId == TYP_NEXTPAGEFLD) { @@ -1006,7 +1007,7 @@ sal_Bool SwFldMgr::InsertFld( const SwInsertFld_Data& rData, SwPaM *pPam ) } case TYP_SETREFFLD: { - if( rData.sPar1.Len() > 0 && CanInsertRefMark( rData.sPar1 ) ) + if( !rData.sPar1.isEmpty() && CanInsertRefMark( rData.sPar1 ) ) { pCurShell->SetAttr( SwFmtRefMark( rData.sPar1 ) ); return sal_True; @@ -1017,7 +1018,7 @@ sal_Bool SwFldMgr::InsertFld( const SwInsertFld_Data& rData, SwPaM *pPam ) { SwGetRefFieldType* pTyp = (SwGetRefFieldType*)pCurShell->GetFldType(0, RES_GETREFFLD); - sal_uInt16 nSeqNo = (sal_uInt16)rData.sPar2.ToInt32(); + sal_uInt16 nSeqNo = (sal_uInt16)rData.sPar2.toInt32(); pFld = new SwGetRefField(pTyp, rData.sPar1, nSubType, nSeqNo, nFormatId); bExp = true; break; @@ -1026,9 +1027,12 @@ sal_Bool SwFldMgr::InsertFld( const SwInsertFld_Data& rData, SwPaM *pPam ) { //JP 28.08.95: DDE-Topics/-Items can have blanks in their names! // That's not yet considered here. - String sCmd( rData.sPar2 ); - sal_uInt16 nTmpPos = sCmd.SearchAndReplace( ' ', sfx2::cTokenSeparator ); - sCmd.SearchAndReplace( ' ', sfx2::cTokenSeparator, nTmpPos ); + sal_Int32 nIndex = 0; + OUString sCmd = rData.sPar2.replaceFirst(OUString(' '), OUString(sfx2::cTokenSeparator), &nIndex); + if (nIndex>=0 && ++nIndex<sCmd.getLength()) + { + sCmd = sCmd.replaceFirst(OUString(' '), OUString(sfx2::cTokenSeparator), &nIndex); + } SwDDEFieldType aType( rData.sPar1, sCmd, (sal_uInt16) nFormatId ); SwDDEFieldType* pTyp = (SwDDEFieldType*) pCurShell->InsertFldType( aType ); @@ -1076,19 +1080,19 @@ sal_Bool SwFldMgr::InsertFld( const SwInsertFld_Data& rData, SwPaM *pPam ) case TYP_DBFLD: { SwDBData aDBData; - String sPar1; + OUString sPar1; - if (rData.sPar1.Search(DB_DELIM) == STRING_NOTFOUND) + if (rData.sPar1.indexOf(DB_DELIM)<0) { aDBData = pCurShell->GetDBData(); sPar1 = rData.sPar1; } else { - aDBData.sDataSource = rData.sPar1.GetToken(0, DB_DELIM); - aDBData.sCommand = rData.sPar1.GetToken(1, DB_DELIM); - aDBData.nCommandType = rData.sPar1.GetToken(2, DB_DELIM).ToInt32(); - sPar1 = rData.sPar1.GetToken(3, DB_DELIM); + aDBData.sDataSource = rData.sPar1.getToken(0, DB_DELIM); + aDBData.sCommand = rData.sPar1.getToken(1, DB_DELIM); + aDBData.nCommandType = rData.sPar1.getToken(2, DB_DELIM).toInt32(); + sPar1 = rData.sPar1.getToken(3, DB_DELIM); } if(!aDBData.sDataSource.isEmpty() && pCurShell->GetDBData() != aDBData) @@ -1127,28 +1131,35 @@ sal_Bool SwFldMgr::InsertFld( const SwInsertFld_Data& rData, SwPaM *pPam ) case TYP_DBNEXTSETFLD: case TYP_DBNAMEFLD: { - sal_uInt16 nPos, nTablePos, nCmdTypePos, nExpPos; - String sPar1; SwDBData aDBData; // excract DBName from rData.sPar1. Format: DBName.TableName.CommandType.ExpStrg - if ((nTablePos = rData.sPar1.Search(DB_DELIM)) != STRING_NOTFOUND) - aDBData.sDataSource = rData.sPar1.Copy(0, nTablePos++); - if ((nCmdTypePos = rData.sPar1.Search(DB_DELIM, nTablePos)) != STRING_NOTFOUND) - { - aDBData.sCommand = rData.sPar1.Copy(nTablePos, nCmdTypePos++ - nTablePos); - } - if ((nExpPos = rData.sPar1.Search(DB_DELIM, nCmdTypePos)) != STRING_NOTFOUND) + sal_Int32 nTablePos = rData.sPar1.indexOf(DB_DELIM); + sal_Int32 nCmdTypePos = -1; + sal_Int32 nExpPos = -1; + + if (nTablePos>=0) { - aDBData.nCommandType = rData.sPar1.Copy(nCmdTypePos, nExpPos++ - nCmdTypePos).ToInt32(); + aDBData.sDataSource = rData.sPar1.copy(0, nTablePos++); + nCmdTypePos = rData.sPar1.indexOf(DB_DELIM, nTablePos); + if (nCmdTypePos>=0) + { + aDBData.sCommand = rData.sPar1.copy(nTablePos, nCmdTypePos++ - nTablePos); + nExpPos = rData.sPar1.indexOf(DB_DELIM, nCmdTypePos); + if (nExpPos>=0) + { + aDBData.nCommandType = rData.sPar1.copy(nCmdTypePos, nExpPos++ - nCmdTypePos).toInt32(); + } + } } - if (nExpPos != STRING_NOTFOUND) + + sal_Int32 nPos = 0; + if (nExpPos>=0) nPos = nExpPos; - else if (nTablePos != STRING_NOTFOUND) + else if (nTablePos>=0) nPos = nTablePos; - else - nPos = 0; - sPar1 = rData.sPar1.Copy(nPos); + + OUString sPar1 = rData.sPar1.copy(nPos); if (!aDBData.sDataSource.isEmpty() && pCurShell->GetDBData() != aDBData) pCurShell->ChgDBData(aDBData); @@ -1250,7 +1261,7 @@ sal_Bool SwFldMgr::InsertFld( const SwInsertFld_Data& rData, SwPaM *pPam ) } case TYP_SETFLD: { - if (!rData.sPar2.Len()) // empty variables are not allowed + if (rData.sPar2.isEmpty()) // empty variables are not allowed return sal_False; SwSetExpFieldType* pTyp = (SwSetExpFieldType*)pCurShell->InsertFldType( @@ -1318,10 +1329,11 @@ sal_Bool SwFldMgr::InsertFld( const SwInsertFld_Data& rData, SwPaM *pPam ) SfxItemSet aBoxSet( pCurShell->GetAttrPool(), RES_BOXATR_FORMULA, RES_BOXATR_FORMULA ); - String sFml(comphelper::string::stripStart(rData.sPar2, ' ')); - if( sFml.Len() && - '=' == sFml.GetChar( 0 ) ) - sFml.Erase( 0, 1 ); + OUString sFml(comphelper::string::stripStart(rData.sPar2, ' ')); + if ( sFml.startsWith("=") ) + { + sFml = sFml.copy(1); + } aBoxSet.Put( SwTblBoxFormula( sFml )); pCurShell->SetTblBoxFormulaAttrs( aBoxSet ); @@ -1344,7 +1356,7 @@ sal_Bool SwFldMgr::InsertFld( const SwInsertFld_Data& rData, SwPaM *pPam ) case TYP_SETREFPAGEFLD: pFld = new SwRefPageSetField( (SwRefPageSetFieldType*) pCurShell->GetFldType( 0, RES_REFPAGESETFLD ), - (short)rData.sPar2.ToInt32(), 0 != nSubType ); + (short)rData.sPar2.toInt32(), 0 != nSubType ); bPageVar = true; break; @@ -1356,11 +1368,11 @@ sal_Bool SwFldMgr::InsertFld( const SwInsertFld_Data& rData, SwPaM *pPam ) case TYP_DROPDOWN : { pFld = new SwDropDownField(pCurShell->GetFldType( 0, RES_DROPDOWN )); - xub_StrLen nTokenCount = comphelper::string::getTokenCount(rData.sPar2, DB_DELIM); + const sal_Int32 nTokenCount = comphelper::string::getTokenCount(rData.sPar2, DB_DELIM); Sequence<OUString> aEntries(nTokenCount); OUString* pArray = aEntries.getArray(); - for(xub_StrLen nToken = 0; nToken < nTokenCount; nToken++) - pArray[nToken] = rData.sPar2.GetToken(nToken, DB_DELIM); + for(sal_Int32 nToken = 0; nToken < nTokenCount; nToken++) + pArray[nToken] = rData.sPar2.getToken(nToken, DB_DELIM); ((SwDropDownField*)pFld)->SetItems(aEntries); ((SwDropDownField*)pFld)->SetName(rData.sPar1); } @@ -1417,8 +1429,8 @@ sal_Bool SwFldMgr::InsertFld( const SwInsertFld_Data& rData, SwPaM *pPam ) void SwFldMgr::UpdateCurFld(sal_uLong nFormat, - const String& rPar1, - const String& rPar2, + const OUString& rPar1, + const OUString& rPar2, SwField * _pTmpFld) // #111840# { // change format @@ -1447,8 +1459,8 @@ void SwFldMgr::UpdateCurFld(sal_uLong nFormat, bool bSetPar2 = true; bool bSetPar1 = true; - String sPar1( rPar1 ); - String sPar2( rPar2 ); + OUString sPar1( rPar1 ); + OUString sPar2( rPar2 ); // Order to Format switch( nTypeId ) @@ -1457,14 +1469,18 @@ void SwFldMgr::UpdateCurFld(sal_uLong nFormat, { // DDE-Topics/-Items can have blanks in their names! // That's not yet considered here! - sal_uInt16 nTmpPos = sPar2.SearchAndReplace( ' ', sfx2::cTokenSeparator ); - sPar2.SearchAndReplace( ' ', sfx2::cTokenSeparator, nTmpPos ); + sal_Int32 nIndex = 0; + sPar2 = sPar2.replaceFirst(OUString(' '), OUString(sfx2::cTokenSeparator), &nIndex ); + if (nIndex>=0 && ++nIndex<sPar2.getLength()) + { + sPar2 = sPar2.replaceFirst(OUString(' '), OUString(sfx2::cTokenSeparator), &nIndex); + } break; } case TYP_CHAPTERFLD: { - sal_uInt16 nByte = (sal_uInt16)rPar2.ToInt32(); + sal_uInt16 nByte = (sal_uInt16)rPar2.toInt32(); nByte = std::max(sal_uInt16(1), nByte); nByte = std::min(nByte, sal_uInt16(MAXLEVEL)); nByte -= 1; @@ -1481,13 +1497,13 @@ void SwFldMgr::UpdateCurFld(sal_uLong nFormat, if( SVX_NUM_CHAR_SPECIAL == nFormat ) { ((SwPageNumberField*)pCurFld)->SetUserString( sPar2 ); - sPar2 = '1'; + sPar2 = OUString('1'); } else { if( nFormat + 2 == SVX_NUM_PAGEDESC ) nFormat = SVX_NUM_PAGEDESC; - short nOff = (short)sPar2.ToInt32(); + short nOff = (short)sPar2.toInt32(); nOff += 1; sPar2 = OUString::number(nOff); } @@ -1503,7 +1519,7 @@ void SwFldMgr::UpdateCurFld(sal_uLong nFormat, { if( nFormat + 2 == SVX_NUM_PAGEDESC ) nFormat = SVX_NUM_PAGEDESC; - short nOff = (short)sPar2.ToInt32(); + short nOff = (short)sPar2.toInt32(); nOff -= 1; sPar2 = OUString::number(nOff); } @@ -1518,10 +1534,10 @@ void SwFldMgr::UpdateCurFld(sal_uLong nFormat, case TYP_GETREFFLD: { bSetPar2 = false; - ((SwGetRefField*)pTmpFld)->SetSubType( (sal_uInt16)rPar2.ToInt32() ); - sal_uInt16 nPos = rPar2.Search( '|' ); - if( STRING_NOTFOUND != nPos ) - ((SwGetRefField*)pTmpFld)->SetSeqNo( (sal_uInt16)rPar2.Copy( nPos + 1 ).ToInt32()); + ((SwGetRefField*)pTmpFld)->SetSubType( (sal_uInt16)rPar2.toInt32() ); + const sal_Int32 nPos = rPar2.indexOf( '|' ); + if( nPos>=0 ) + ((SwGetRefField*)pTmpFld)->SetSeqNo( (sal_uInt16)rPar2.copy( nPos + 1 ).toInt32()); } break; case TYP_DROPDOWN: @@ -1530,7 +1546,7 @@ void SwFldMgr::UpdateCurFld(sal_uLong nFormat, Sequence<OUString> aEntries(nTokenCount); OUString* pArray = aEntries.getArray(); for(xub_StrLen nToken = 0; nToken < nTokenCount; nToken++) - pArray[nToken] = sPar2.GetToken(nToken, DB_DELIM); + pArray[nToken] = sPar2.getToken(nToken, DB_DELIM); ((SwDropDownField*)pTmpFld)->SetItems(aEntries); ((SwDropDownField*)pTmpFld)->SetName(sPar1); bSetPar1 = bSetPar2 = false; @@ -1544,7 +1560,7 @@ void SwFldMgr::UpdateCurFld(sal_uLong nFormat, SwAuthEntry aTempEntry; for( sal_uInt16 i = 0; i < AUTH_FIELD_END; ++i ) aTempEntry.SetAuthorField( (ToxAuthorityField)i, - rPar1.GetToken( i, TOX_STYLE_DELIMITER )); + rPar1.getToken( i, TOX_STYLE_DELIMITER )); if( pAuthorityType->ChangeEntryContent( &aTempEntry ) ) { pType->UpdateFlds(); @@ -1661,17 +1677,16 @@ void SwFieldType::_GetFldName() }; // insert infos for fields - SwFieldType::pFldNames = new std::vector<String>; + SwFieldType::pFldNames = new std::vector<OUString>; SwFieldType::pFldNames->reserve(SAL_N_ELEMENTS(coFldNms)); for( sal_uInt16 nIdx = 0; nIdx < SAL_N_ELEMENTS(coFldNms); ++nIdx ) { - String aTmp(SW_RESSTR( coFldNms[ nIdx ] )); - aTmp.Assign( MnemonicGenerator::EraseAllMnemonicChars( aTmp ) ); - SwFieldType::pFldNames->push_back(aTmp); + const OUString aTmp(SW_RES( coFldNms[ nIdx ] )); + SwFieldType::pFldNames->push_back(MnemonicGenerator::EraseAllMnemonicChars( aTmp )); } } -sal_Bool SwFldMgr::ChooseMacro(const String&) +sal_Bool SwFldMgr::ChooseMacro(const OUString&) { sal_Bool bRet = sal_False; @@ -1688,7 +1703,7 @@ sal_Bool SwFldMgr::ChooseMacro(const String&) return bRet; } -void SwFldMgr::SetMacroPath(const String& rPath) +void SwFldMgr::SetMacroPath(const OUString& rPath) { sMacroPath = rPath; sMacroName = rPath; diff --git a/sw/source/ui/fldui/xfldui.cxx b/sw/source/ui/fldui/xfldui.cxx index c6cf2c4b7f69..de49dd77bfab 100644 --- a/sw/source/ui/fldui/xfldui.cxx +++ b/sw/source/ui/fldui/xfldui.cxx @@ -54,8 +54,8 @@ using namespace ::com::sun::star::beans; remark: in case of error sal_True is returned --------------------------------------------------------------------*/ -sal_Bool SwFldMgr::IsDBNumeric( const String& rDBName, const String& rTblQryName, - sal_Bool bIsTable, const String& rFldName) +sal_Bool SwFldMgr::IsDBNumeric( const OUString& rDBName, const OUString& rTblQryName, + sal_Bool bIsTable, const OUString& rFldName) { sal_Bool bNumeric = sal_True; diff --git a/sw/source/ui/inc/fldmgr.hxx b/sw/source/ui/inc/fldmgr.hxx index d745c41484b5..735abafe35fe 100644 --- a/sw/source/ui/inc/fldmgr.hxx +++ b/sw/source/ui/inc/fldmgr.hxx @@ -19,7 +19,6 @@ #ifndef _FLDMGR_HXX #define _FLDMGR_HXX -#include <tools/string.hxx> #include "swdllapi.h" #include "swtypes.hxx" #include <com/sun/star/uno/Reference.h> @@ -71,8 +70,8 @@ struct SwInsertFld_Data { sal_uInt16 nTypeId; sal_uInt16 nSubType; - const String sPar1; - const String sPar2; + const OUString sPar1; + const OUString sPar2; sal_uLong nFormatId; SwWrtShell* pSh; sal_Unicode cSeparator; @@ -82,7 +81,7 @@ struct SwInsertFld_Data ::com::sun::star::uno::Any aDBColumn; Window* pParent; // parent dialog used for SwWrtShell::StartInputFldDlg() - SwInsertFld_Data(sal_uInt16 nType, sal_uInt16 nSub, const String& rPar1, const String& rPar2, + SwInsertFld_Data(sal_uInt16 nType, sal_uInt16 nSub, const OUString& rPar1, const OUString& rPar2, sal_uLong nFmtId, SwWrtShell* pShell = NULL, sal_Unicode cSep = ' ', sal_Bool bIsAutoLanguage = sal_True) : nTypeId(nType), nSubType(nSub), @@ -108,12 +107,12 @@ private: SbModule* pModule; const SvxMacroItem* pMacroItem; SwWrtShell* pWrtShell; // can be ZERO too! - String aCurPar1; - String aCurPar2; - String sCurFrame; + OUString aCurPar1; + OUString aCurPar2; + OUString sCurFrame; - String sMacroPath; - String sMacroName; + OUString sMacroPath; + OUString sMacroName; sal_uLong nCurFmt; sal_Bool bEvalExp; @@ -136,12 +135,12 @@ public: // change the current field directly void UpdateCurFld(sal_uLong nFormat, - const String& rPar1, - const String& rPar2, + const OUString& rPar1, + const OUString& rPar2, SwField * _pField = 0); // #111840# - inline const String& GetCurFldPar1() const; - inline const String& GetCurFldPar2() const; + OUString GetCurFldPar1() const { return aCurPar1; } + OUString GetCurFldPar2() const { return aCurPar2; } inline sal_uLong GetCurFldFmt() const; // determine a field @@ -149,10 +148,10 @@ public: void InsertFldType(SwFieldType& rType); - sal_Bool ChooseMacro(const String &rSelMacro = aEmptyStr); - void SetMacroPath(const String& rPath); - inline const String& GetMacroPath() const { return (sMacroPath); } - inline const String& GetMacroName() const { return (sMacroName); } + sal_Bool ChooseMacro(const OUString &rSelMacro = OUString()); + void SetMacroPath(const OUString& rPath); + inline OUString GetMacroPath() const { return sMacroPath; } + inline OUString GetMacroName() const { return sMacroName; } inline void SetMacroModule(SbModule* pMod) { pModule = pMod; } // previous and next of the same type @@ -162,19 +161,19 @@ public: // query values from database fields (BASIC ) // String GetDataBaseFieldValue(const String &rDBName, const String &rFieldName, SwWrtShell* pSh); - sal_Bool IsDBNumeric(const String& rDBName, const String& rTblQryName, - sal_Bool bIsTable, const String& rFldName); + sal_Bool IsDBNumeric(const OUString& rDBName, const OUString& rTblQryName, + sal_Bool bIsTable, const OUString& rFldName); // organise RefMark with names - bool CanInsertRefMark( const String& rStr ); + bool CanInsertRefMark( const OUString& rStr ); // access to field types via ResId sal_uInt16 GetFldTypeCount(sal_uInt16 nResId = USHRT_MAX) const; SwFieldType* GetFldType(sal_uInt16 nResId, sal_uInt16 nId = 0) const; - SwFieldType* GetFldType(sal_uInt16 nResId, const String& rName) const; + SwFieldType* GetFldType(sal_uInt16 nResId, const OUString& rName) const; - void RemoveFldType(sal_uInt16 nResId, const String& rName); + void RemoveFldType(sal_uInt16 nResId, const OUString& rName); // access via TypeId from the dialog // Ids for a range of fields @@ -187,7 +186,7 @@ public: // TypeId for a concrete position in the list static sal_uInt16 GetTypeId(sal_uInt16 nPos); // name of the type in the list of fields - static const String& GetTypeStr(sal_uInt16 nPos); + static OUString GetTypeStr(sal_uInt16 nPos); // Pos in the list of fields static sal_uInt16 GetPos(sal_uInt16 nTypeId); @@ -197,7 +196,7 @@ public: // format to a type sal_uInt16 GetFormatCount(sal_uInt16 nTypeId, bool bIsText, sal_Bool bHtmlMode = sal_False) const; - String GetFormatStr(sal_uInt16 nTypeId, sal_uLong nFormatId) const; + OUString GetFormatStr(sal_uInt16 nTypeId, sal_uLong nFormatId) const; sal_uInt16 GetFormatId(sal_uInt16 nTypeId, sal_uLong nFormatId) const; sal_uLong GetDefaultFormat(sal_uInt16 nTypeId, bool bIsText, SvNumberFormatter* pFormatter, double* pVal = 0L); @@ -211,12 +210,6 @@ public: inline void SwFldMgr::SetEvalExpFlds(sal_Bool bEval) { bEvalExp = bEval; } -inline const String& SwFldMgr::GetCurFldPar1() const - { return aCurPar1; } - -inline const String& SwFldMgr::GetCurFldPar2() const - { return aCurPar2; } - inline sal_uLong SwFldMgr::GetCurFldFmt() const { return nCurFmt; } diff --git a/sw/source/ui/inc/initui.hxx b/sw/source/ui/inc/initui.hxx index 31f355b25437..297bb0bf4b78 100644 --- a/sw/source/ui/inc/initui.hxx +++ b/sw/source/ui/inc/initui.hxx @@ -51,9 +51,6 @@ SW_DLLPUBLIC void SetCurrGlosGroup(String* pStr); extern std::vector<String>* pDBNameList; -extern std::vector<String>* pAuthFieldNameList; -extern std::vector<String>* pAuthFieldTypeList; - // provides textblock management class SwGlossaries; SW_DLLPUBLIC SwGlossaries* GetGlossaries(); diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx index cab0acc72c4b..6b8673268ac3 100644 --- a/sw/source/ui/index/swuiidxmrk.cxx +++ b/sw/source/ui/index/swuiidxmrk.cxx @@ -1214,7 +1214,7 @@ IMPL_LINK( SwAuthorMarkPane, CompEntryHdl, ListBox*, pBox) const SwAuthEntry* pEntry = pFType ? pFType->GetEntryByIdentifier(sEntry) : 0; for(sal_uInt16 i = 0; i < AUTH_FIELD_END; i++) m_sFields[i] = pEntry ? - pEntry->GetAuthorField((ToxAuthorityField)i) : aEmptyStr; + pEntry->GetAuthorField((ToxAuthorityField)i) : OUString(); } } if(!pBox->GetSelectEntry().Len()) @@ -1376,7 +1376,7 @@ IMPL_LINK(SwAuthorMarkPane, ChangeSourceHdl, RadioButton*, pButton) pSh->GetFldType(RES_AUTHORITY, aEmptyStr); if(pFType) { - std::vector<String> aIds; + std::vector<OUString> aIds; pFType->GetAllEntryIdentifiers( aIds ); for(size_t n = 0; n < aIds.size(); ++n) m_pEntryLB->InsertEntry(aIds[n]); @@ -1523,7 +1523,7 @@ SwCreateAuthEntryDlg_Impl::SwCreateAuthEntryDlg_Impl(Window* pParent, rSh.GetFldType(RES_AUTHORITY, aEmptyStr); if(pFType) { - std::vector<String> aIds; + std::vector<OUString> aIds; pFType->GetAllEntryIdentifiers( aIds ); for(size_t n = 0; n < aIds.size(); ++n) pIdentifierBox->InsertEntry(aIds[n]); diff --git a/sw/source/ui/utlui/initui.cxx b/sw/source/ui/utlui/initui.cxx index 42ad626e3413..043b650eed63 100644 --- a/sw/source/ui/utlui/initui.cxx +++ b/sw/source/ui/utlui/initui.cxx @@ -75,8 +75,13 @@ void SetCurrGlosGroup(String* pStr) std::vector<String>* pDBNameList = 0; -std::vector<String>* pAuthFieldNameList = 0; -std::vector<String>* pAuthFieldTypeList = 0; +namespace +{ + +std::vector<OUString>* pAuthFieldNameList = 0; +std::vector<OUString>* pAuthFieldTypeList = 0; + +} // Finish UI @@ -253,26 +258,26 @@ ImpAutoFmtNameListLoader::ImpAutoFmtNameListLoader( std::vector<String>& rLst ) FreeResource(); } -const String& SwAuthorityFieldType::GetAuthFieldName(ToxAuthorityField eType) +OUString SwAuthorityFieldType::GetAuthFieldName(ToxAuthorityField eType) { if(!pAuthFieldNameList) { - pAuthFieldNameList = new std::vector<String>; + pAuthFieldNameList = new std::vector<OUString>; pAuthFieldNameList->reserve(AUTH_FIELD_END); for(sal_uInt16 i = 0; i < AUTH_FIELD_END; ++i) - pAuthFieldNameList->push_back(String(SW_RES(STR_AUTH_FIELD_START + i))); + pAuthFieldNameList->push_back(SW_RES(STR_AUTH_FIELD_START + i)); } return (*pAuthFieldNameList)[static_cast< sal_uInt16 >(eType)]; } -const String& SwAuthorityFieldType::GetAuthTypeName(ToxAuthorityType eType) +OUString SwAuthorityFieldType::GetAuthTypeName(ToxAuthorityType eType) { if(!pAuthFieldTypeList) { - pAuthFieldTypeList = new std::vector<String>; + pAuthFieldTypeList = new std::vector<OUString>; pAuthFieldTypeList->reserve(AUTH_TYPE_END); for(sal_uInt16 i = 0; i < AUTH_TYPE_END; ++i) - pAuthFieldTypeList->push_back(String(SW_RES(STR_AUTH_TYPE_START + i))); + pAuthFieldTypeList->push_back(SW_RES(STR_AUTH_TYPE_START + i)); } return (*pAuthFieldTypeList)[static_cast< sal_uInt16 >(eType)]; } |