Kaydet (Commit) 0cce823d authored tarafından Matteo Casalin's avatar Matteo Casalin Kaydeden (comit) Caolán McNamara

String to OUString + drop reference args for struct return

Change-Id: I985edaffb24ba3ec7265761c857a791e34d4f417
Reviewed-on: https://gerrit.libreoffice.org/6096Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst df700770
...@@ -1033,10 +1033,7 @@ void SwTOXBaseSection::InsertAlphaDelimitter( const SwTOXInternational& rIntl ) ...@@ -1033,10 +1033,7 @@ void SwTOXBaseSection::InsertAlphaDelimitter( const SwTOXInternational& rIntl )
if( nLevel == FORM_ALPHA_DELIMITTER ) if( nLevel == FORM_ALPHA_DELIMITTER )
continue; continue;
String sMyString, sMyStringReading; sDeli = rIntl.GetIndexKey( aSortArr[i]->GetTxt(),
aSortArr[i]->GetTxt( sMyString, sMyStringReading );
sDeli = rIntl.GetIndexKey( sMyString, sMyStringReading,
aSortArr[i]->GetLocale() ); aSortArr[i]->GetLocale() );
// Do we already have a Delimitter? // Do we already have a Delimitter?
...@@ -1045,7 +1042,8 @@ void SwTOXBaseSection::InsertAlphaDelimitter( const SwTOXInternational& rIntl ) ...@@ -1045,7 +1042,8 @@ void SwTOXBaseSection::InsertAlphaDelimitter( const SwTOXInternational& rIntl )
// We skip all that are less than a small Blank (these are special characters) // We skip all that are less than a small Blank (these are special characters)
if( ' ' <= sDeli.GetChar( 0 ) ) if( ' ' <= sDeli.GetChar( 0 ) )
{ {
SwTOXCustom* pCst = new SwTOXCustom( sDeli, aEmptyStr, FORM_ALPHA_DELIMITTER, SwTOXCustom* pCst = new SwTOXCustom( TextAndReading(sDeli, OUString()),
FORM_ALPHA_DELIMITTER,
rIntl, aSortArr[i]->GetLocale() ); rIntl, aSortArr[i]->GetLocale() );
aSortArr.insert( aSortArr.begin() + i, pCst); aSortArr.insert( aSortArr.begin() + i, pCst);
i++; i++;
...@@ -2235,13 +2233,12 @@ Range SwTOXBaseSection::GetKeyRange(const String& rStr, const String& rStrReadin ...@@ -2235,13 +2233,12 @@ Range SwTOXBaseSection::GetKeyRange(const String& rStr, const String& rStrReadin
sal_uInt16 nLevel, const Range& rRange ) sal_uInt16 nLevel, const Range& rRange )
{ {
const SwTOXInternational& rIntl = *rNew.pTOXIntl; const SwTOXInternational& rIntl = *rNew.pTOXIntl;
String sToCompare(rStr); TextAndReading aToCompare(rStr, rStrReading);
String sToCompareReading(rStrReading);
if( 0 != (nsSwTOIOptions::TOI_INITIAL_CAPS & GetOptions()) ) if( 0 != (nsSwTOIOptions::TOI_INITIAL_CAPS & GetOptions()) )
{ {
String sUpper( rIntl.ToUpper( sToCompare, 0 )); aToCompare.sText = rIntl.ToUpper( aToCompare.sText, 0 )
sToCompare.Erase( 0, 1 ).Insert( sUpper, 0 ); + aToCompare.sText.copy(1);
} }
OSL_ENSURE(rRange.Min() >= 0 && rRange.Max() >= 0, "Min Max < 0"); OSL_ENSURE(rRange.Min() >= 0 && rRange.Max() >= 0, "Min Max < 0");
...@@ -2255,17 +2252,14 @@ Range SwTOXBaseSection::GetKeyRange(const String& rStr, const String& rStrReadin ...@@ -2255,17 +2252,14 @@ Range SwTOXBaseSection::GetKeyRange(const String& rStr, const String& rStrReadin
{ {
SwTOXSortTabBase* pBase = aSortArr[i]; SwTOXSortTabBase* pBase = aSortArr[i];
String sMyString, sMyStringReading; if( rIntl.IsEqual( pBase->GetTxt(), pBase->GetLocale(),
pBase->GetTxt( sMyString, sMyStringReading ); aToCompare, rNew.GetLocale() ) &&
if( rIntl.IsEqual( sMyString, sMyStringReading, pBase->GetLocale(),
sToCompare, sToCompareReading, rNew.GetLocale() ) &&
pBase->GetLevel() == nLevel ) pBase->GetLevel() == nLevel )
break; break;
} }
if(i == nMax) if(i == nMax)
{ // If not already present, create and insert { // If not already present, create and insert
SwTOXCustom* pKey = new SwTOXCustom( sToCompare, sToCompareReading, nLevel, rIntl, SwTOXCustom* pKey = new SwTOXCustom( aToCompare, nLevel, rIntl,
rNew.GetLocale() ); rNew.GetLocale() );
for(i = nMin; i < nMax; ++i) for(i = nMin; i < nMax; ++i)
{ {
......
...@@ -57,6 +57,21 @@ struct SwTOXSource ...@@ -57,6 +57,21 @@ struct SwTOXSource
typedef std::vector<SwTOXSource> SwTOXSources; typedef std::vector<SwTOXSource> SwTOXSources;
struct TextAndReading
{
OUString sText;
OUString sReading;
TextAndReading() {}
TextAndReading(OUString sTxt, OUString sRdng)
: sText(sTxt)
, sReading(sRdng)
{}
};
class SwTOXInternational class SwTOXInternational
{ {
IndexEntrySupplierWrapper* pIndexWrapper; IndexEntrySupplierWrapper* pIndexWrapper;
...@@ -73,30 +88,28 @@ public: ...@@ -73,30 +88,28 @@ public:
SwTOXInternational( const SwTOXInternational& ); SwTOXInternational( const SwTOXInternational& );
~SwTOXInternational(); ~SwTOXInternational();
sal_Int32 Compare( const String& rTxt1, const String& rTxtReading1, sal_Int32 Compare( const TextAndReading& rTaR1,
const ::com::sun::star::lang::Locale& rLocale1, const ::com::sun::star::lang::Locale& rLocale1,
const String& rTxt2, const String& rTxtReading2, const TextAndReading& rTaR2,
const ::com::sun::star::lang::Locale& rLocale2 ) const; const ::com::sun::star::lang::Locale& rLocale2 ) const;
inline bool IsEqual( const String& rTxt1, const String& rTxtReading1, inline bool IsEqual( const TextAndReading& rTaR1,
const ::com::sun::star::lang::Locale& rLocale1, const ::com::sun::star::lang::Locale& rLocale1,
const String& rTxt2, const String& rTxtReading2, const TextAndReading& rTaR2,
const ::com::sun::star::lang::Locale& rLocale2 ) const const ::com::sun::star::lang::Locale& rLocale2 ) const
{ {
return 0 == Compare( rTxt1, rTxtReading1, rLocale1, return 0 == Compare( rTaR1, rLocale1, rTaR2, rLocale2 );
rTxt2, rTxtReading2, rLocale2 );
} }
inline bool IsLess( const String& rTxt1, const String& rTxtReading1, inline bool IsLess( const TextAndReading& rTaR1,
const ::com::sun::star::lang::Locale& rLocale1, const ::com::sun::star::lang::Locale& rLocale1,
const String& rTxt2, const String& rTxtReading2, const TextAndReading& rTaR2,
const ::com::sun::star::lang::Locale& rLocale2 ) const const ::com::sun::star::lang::Locale& rLocale2 ) const
{ {
return -1 == Compare( rTxt1, rTxtReading1, rLocale1, return -1 == Compare( rTaR1, rLocale1, rTaR2, rLocale2 );
rTxt2, rTxtReading2, rLocale2 );
} }
String GetIndexKey( const String& rTxt, const String& rTxtReading, String GetIndexKey( const TextAndReading& rTaR,
const ::com::sun::star::lang::Locale& rLcl ) const; const ::com::sun::star::lang::Locale& rLcl ) const;
String GetFollowingText( sal_Bool bMorePages ) const; String GetFollowingText( sal_Bool bMorePages ) const;
...@@ -138,29 +151,25 @@ struct SwTOXSortTabBase ...@@ -138,29 +151,25 @@ struct SwTOXSortTabBase
virtual String GetURL() const; virtual String GetURL() const;
inline void GetTxt( String&, String& ) const; inline TextAndReading GetTxt() const;
inline const ::com::sun::star::lang::Locale& GetLocale() const; inline const ::com::sun::star::lang::Locale& GetLocale() const;
private: private:
sal_Bool bValidTxt; sal_Bool bValidTxt;
String sSortTxt; TextAndReading m_aSort;
String sSortTxtReading;
virtual void GetText_Impl( String&, String& ) const = 0; virtual TextAndReading GetText_Impl() const = 0;
}; };
inline void SwTOXSortTabBase::GetTxt( String& rSortTxt, inline TextAndReading SwTOXSortTabBase::GetTxt() const
String& rSortTxtReading ) const
{ {
if( !bValidTxt ) if( !bValidTxt )
{ {
SwTOXSortTabBase* pThis = (SwTOXSortTabBase*)this; SwTOXSortTabBase* pThis = (SwTOXSortTabBase*)this;
pThis->GetText_Impl( pThis->sSortTxt, pThis->sSortTxtReading ); pThis->m_aSort = pThis->GetText_Impl();
pThis->bValidTxt = sal_True; pThis->bValidTxt = sal_True;
} }
return m_aSort;
rSortTxt = sSortTxt;
rSortTxtReading = sSortTxtReading;
} }
inline const ::com::sun::star::lang::Locale& SwTOXSortTabBase::GetLocale() const inline const ::com::sun::star::lang::Locale& SwTOXSortTabBase::GetLocale() const
...@@ -186,14 +195,14 @@ struct SwTOXIndex : public SwTOXSortTabBase ...@@ -186,14 +195,14 @@ struct SwTOXIndex : public SwTOXSortTabBase
virtual bool operator<( const SwTOXSortTabBase& ); virtual bool operator<( const SwTOXSortTabBase& );
private: private:
virtual void GetText_Impl( String&, String& ) const; virtual TextAndReading GetText_Impl() const;
sal_uInt8 nKeyLevel; sal_uInt8 nKeyLevel;
}; };
struct SwTOXCustom : public SwTOXSortTabBase struct SwTOXCustom : public SwTOXSortTabBase
{ {
SwTOXCustom( const String& rKey, const String& rReading, sal_uInt16 nLevel, SwTOXCustom( const TextAndReading& rKey, sal_uInt16 nLevel,
const SwTOXInternational& rIntl, const SwTOXInternational& rIntl,
const ::com::sun::star::lang::Locale& rLocale ); const ::com::sun::star::lang::Locale& rLocale );
virtual ~SwTOXCustom() {} virtual ~SwTOXCustom() {}
...@@ -203,10 +212,9 @@ struct SwTOXCustom : public SwTOXSortTabBase ...@@ -203,10 +212,9 @@ struct SwTOXCustom : public SwTOXSortTabBase
virtual bool operator<( const SwTOXSortTabBase& ); virtual bool operator<( const SwTOXSortTabBase& );
private: private:
virtual void GetText_Impl( String&, String& ) const; virtual TextAndReading GetText_Impl() const;
String aKey; TextAndReading m_aKey;
String sReading;
sal_uInt16 nLev; sal_uInt16 nLev;
}; };
...@@ -223,7 +231,7 @@ struct SwTOXContent : public SwTOXSortTabBase ...@@ -223,7 +231,7 @@ struct SwTOXContent : public SwTOXSortTabBase
virtual void FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0 ) const; virtual void FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0 ) const;
virtual sal_uInt16 GetLevel() const; virtual sal_uInt16 GetLevel() const;
private: private:
virtual void GetText_Impl( String&, String& ) const; virtual TextAndReading GetText_Impl() const;
}; };
...@@ -240,7 +248,7 @@ struct SwTOXPara : public SwTOXSortTabBase ...@@ -240,7 +248,7 @@ struct SwTOXPara : public SwTOXSortTabBase
virtual String GetURL() const; virtual String GetURL() const;
private: private:
virtual void GetText_Impl( String&, String& ) const; virtual TextAndReading GetText_Impl() const;
SwTOXElement eType; SwTOXElement eType;
sal_uInt16 m_nLevel; sal_uInt16 m_nLevel;
...@@ -260,7 +268,7 @@ struct SwTOXTable : public SwTOXSortTabBase ...@@ -260,7 +268,7 @@ struct SwTOXTable : public SwTOXSortTabBase
virtual String GetURL() const; virtual String GetURL() const;
private: private:
virtual void GetText_Impl( String&, String& ) const; virtual TextAndReading GetText_Impl() const;
sal_uInt16 nLevel; sal_uInt16 nLevel;
}; };
...@@ -270,7 +278,7 @@ struct SwTOXAuthority : public SwTOXSortTabBase ...@@ -270,7 +278,7 @@ struct SwTOXAuthority : public SwTOXSortTabBase
private: private:
SwFmtFld& m_rField; SwFmtFld& m_rField;
virtual void FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0 ) const; virtual void FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField = 0 ) const;
virtual void GetText_Impl( String&, String& ) const; virtual TextAndReading GetText_Impl() const;
public: public:
SwTOXAuthority( const SwCntntNode& rNd, SwFmtFld& rField, const SwTOXInternational& rIntl ); SwTOXAuthority( const SwCntntNode& rNd, SwFmtFld& rField, const SwTOXInternational& rIntl );
......
...@@ -109,19 +109,19 @@ inline sal_Bool SwTOXInternational::IsNumeric( const String& rStr ) const ...@@ -109,19 +109,19 @@ inline sal_Bool SwTOXInternational::IsNumeric( const String& rStr ) const
return pCharClass->isNumeric( rStr ); return pCharClass->isNumeric( rStr );
} }
sal_Int32 SwTOXInternational::Compare( const String& rTxt1, const String& rTxtReading1, sal_Int32 SwTOXInternational::Compare( const TextAndReading& rTaR1,
const lang::Locale& rLocale1, const lang::Locale& rLocale1,
const String& rTxt2, const String& rTxtReading2, const TextAndReading& rTaR2,
const lang::Locale& rLocale2 ) const const lang::Locale& rLocale2 ) const
{ {
return pIndexWrapper->CompareIndexEntry( rTxt1, rTxtReading1, rLocale1, return pIndexWrapper->CompareIndexEntry( rTaR1.sText, rTaR1.sReading, rLocale1,
rTxt2, rTxtReading2, rLocale2 ); rTaR2.sText, rTaR2.sReading, rLocale2 );
} }
String SwTOXInternational::GetIndexKey( const String& rTxt, const String& rTxtReading, String SwTOXInternational::GetIndexKey( const TextAndReading& rTaR,
const lang::Locale& rLocale ) const const lang::Locale& rLocale ) const
{ {
return pIndexWrapper->GetIndexKey( rTxt, rTxtReading, rLocale ); return pIndexWrapper->GetIndexKey( rTaR.sText, rTaR.sReading, rLocale );
} }
String SwTOXInternational::GetFollowingText( sal_Bool bMorePages ) const String SwTOXInternational::GetFollowingText( sal_Bool bMorePages ) const
...@@ -195,12 +195,7 @@ String SwTOXSortTabBase::GetURL() const ...@@ -195,12 +195,7 @@ String SwTOXSortTabBase::GetURL() const
void SwTOXSortTabBase::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, void SwTOXSortTabBase::FillText( SwTxtNode& rNd, const SwIndex& rInsPos,
sal_uInt16 ) const sal_uInt16 ) const
{ {
String sMyTxt; rNd.InsertText( GetTxt().sText, rInsPos );
String sMyTxtReading;
GetTxt( sMyTxt, sMyTxtReading );
rNd.InsertText( sMyTxt, rInsPos );
} }
bool SwTOXSortTabBase::operator==( const SwTOXSortTabBase& rCmp ) bool SwTOXSortTabBase::operator==( const SwTOXSortTabBase& rCmp )
...@@ -221,17 +216,9 @@ bool SwTOXSortTabBase::operator==( const SwTOXSortTabBase& rCmp ) ...@@ -221,17 +216,9 @@ bool SwTOXSortTabBase::operator==( const SwTOXSortTabBase& rCmp )
const xub_StrLen *pEnd = pTxtMark->GetEnd(), const xub_StrLen *pEnd = pTxtMark->GetEnd(),
*pEndCmp = rCmp.pTxtMark->GetEnd(); *pEndCmp = rCmp.pTxtMark->GetEnd();
String sMyTxt;
String sMyTxtReading;
GetTxt( sMyTxt, sMyTxtReading );
String sOtherTxt;
String sOtherTxtReading;
rCmp.GetTxt( sOtherTxt, sOtherTxtReading );
bRet = ( ( pEnd && pEndCmp ) || ( !pEnd && !pEndCmp ) ) && bRet = ( ( pEnd && pEndCmp ) || ( !pEnd && !pEndCmp ) ) &&
pTOXIntl->IsEqual( sMyTxt, sMyTxtReading, GetLocale(), pTOXIntl->IsEqual( GetTxt(), GetLocale(),
sOtherTxt, sOtherTxtReading, rCmp.GetLocale() ); rCmp.GetTxt(), rCmp.GetLocale() );
} }
} }
return bRet; return bRet;
...@@ -264,19 +251,11 @@ bool SwTOXSortTabBase::operator<( const SwTOXSortTabBase& rCmp ) ...@@ -264,19 +251,11 @@ bool SwTOXSortTabBase::operator<( const SwTOXSortTabBase& rCmp )
const xub_StrLen *pEnd = pTxtMark->GetEnd(), const xub_StrLen *pEnd = pTxtMark->GetEnd(),
*pEndCmp = rCmp.pTxtMark->GetEnd(); *pEndCmp = rCmp.pTxtMark->GetEnd();
String sMyTxt;
String sMyTxtReading;
GetTxt( sMyTxt, sMyTxtReading );
String sOtherTxt;
String sOtherTxtReading;
rCmp.GetTxt( sOtherTxt, sOtherTxtReading );
// Both pointers exist -> compare text // Both pointers exist -> compare text
// else -> compare AlternativeText // else -> compare AlternativeText
if( ( pEnd && pEndCmp ) || ( !pEnd && !pEndCmp ) ) if( ( pEnd && pEndCmp ) || ( !pEnd && !pEndCmp ) )
pTOXIntl->IsEqual( sMyTxt, sMyTxtReading, GetLocale(), pTOXIntl->IsEqual( GetTxt(), GetLocale(),
sOtherTxt, sOtherTxtReading, rCmp.GetLocale() ); rCmp.GetTxt(), rCmp.GetLocale() );
if( pEnd && !pEndCmp ) if( pEnd && !pEndCmp )
return true; return true;
...@@ -324,16 +303,8 @@ bool SwTOXIndex::operator==( const SwTOXSortTabBase& rCmpBase ) ...@@ -324,16 +303,8 @@ bool SwTOXIndex::operator==( const SwTOXSortTabBase& rCmpBase )
OSL_ENSURE(pTxtMark, "pTxtMark == 0, No keyword"); OSL_ENSURE(pTxtMark, "pTxtMark == 0, No keyword");
String sMyTxt; bool bRet = pTOXIntl->IsEqual( GetTxt(), GetLocale(),
String sMyTxtReading; rCmp.GetTxt(), rCmp.GetLocale() );
GetTxt( sMyTxt, sMyTxtReading );
String sOtherTxt;
String sOtherTxtReading;
rCmp.GetTxt( sOtherTxt, sOtherTxtReading );
bool bRet = pTOXIntl->IsEqual( sMyTxt, sMyTxtReading, GetLocale(),
sOtherTxt, sOtherTxtReading, rCmp.GetLocale() );
// If we don't summarize we need to evaluate the Pos // If we don't summarize we need to evaluate the Pos
if(bRet && !(GetOptions() & nsSwTOIOptions::TOI_SAME_ENTRY)) if(bRet && !(GetOptions() & nsSwTOIOptions::TOI_SAME_ENTRY))
...@@ -351,23 +322,18 @@ bool SwTOXIndex::operator<( const SwTOXSortTabBase& rCmpBase ) ...@@ -351,23 +322,18 @@ bool SwTOXIndex::operator<( const SwTOXSortTabBase& rCmpBase )
OSL_ENSURE(pTxtMark, "pTxtMark == 0, No keyword"); OSL_ENSURE(pTxtMark, "pTxtMark == 0, No keyword");
String sMyTxt; const TextAndReading aMyTaR(GetTxt());
String sMyTxtReading; const TextAndReading aOtherTaR(rCmp.GetTxt());
GetTxt( sMyTxt, sMyTxtReading );
String sOtherTxt;
String sOtherTxtReading;
rCmp.GetTxt( sOtherTxt, sOtherTxtReading );
bool bRet = GetLevel() == rCmp.GetLevel() && bool bRet = GetLevel() == rCmp.GetLevel() &&
pTOXIntl->IsLess( sMyTxt, sMyTxtReading, GetLocale(), pTOXIntl->IsLess( aMyTaR, GetLocale(),
sOtherTxt, sOtherTxtReading, rCmp.GetLocale() ); aOtherTaR, rCmp.GetLocale() );
// If we don't summarize we need to evaluate the Pos // If we don't summarize we need to evaluate the Pos
if( !bRet && !(GetOptions() & nsSwTOIOptions::TOI_SAME_ENTRY) ) if( !bRet && !(GetOptions() & nsSwTOIOptions::TOI_SAME_ENTRY) )
{ {
bRet = pTOXIntl->IsEqual( sMyTxt, sMyTxtReading, GetLocale(), bRet = pTOXIntl->IsEqual( aMyTaR, GetLocale(),
sOtherTxt, sOtherTxtReading, rCmp.GetLocale() ) && aOtherTaR, rCmp.GetLocale() ) &&
nPos < rCmp.nPos; nPos < rCmp.nPos;
} }
...@@ -377,60 +343,62 @@ bool SwTOXIndex::operator<( const SwTOXSortTabBase& rCmpBase ) ...@@ -377,60 +343,62 @@ bool SwTOXIndex::operator<( const SwTOXSortTabBase& rCmpBase )
// //
// The keyword itself // The keyword itself
void SwTOXIndex::GetText_Impl( String& rTxt, String& rTxtReading ) const TextAndReading SwTOXIndex::GetText_Impl() const
{ {
OSL_ENSURE(pTxtMark, "pTxtMark == 0, No keyword"); OSL_ENSURE(pTxtMark, "pTxtMark == 0, No keyword");
const SwTOXMark& rTOXMark = pTxtMark->GetTOXMark(); const SwTOXMark& rTOXMark = pTxtMark->GetTOXMark();
TextAndReading aRet;
switch(nKeyLevel) switch(nKeyLevel)
{ {
case FORM_PRIMARY_KEY : case FORM_PRIMARY_KEY :
{ {
rTxt = rTOXMark.GetPrimaryKey(); aRet.sText = rTOXMark.GetPrimaryKey();
rTxtReading = rTOXMark.GetPrimaryKeyReading(); aRet.sReading = rTOXMark.GetPrimaryKeyReading();
} }
break; break;
case FORM_SECONDARY_KEY : case FORM_SECONDARY_KEY :
{ {
rTxt = rTOXMark.GetSecondaryKey(); aRet.sText = rTOXMark.GetSecondaryKey();
rTxtReading = rTOXMark.GetSecondaryKeyReading(); aRet.sReading = rTOXMark.GetSecondaryKeyReading();
} }
break; break;
case FORM_ENTRY : case FORM_ENTRY :
{ {
rTxt = rTOXMark.GetText(); aRet.sText = rTOXMark.GetText();
rTxtReading = rTOXMark.GetTextReading(); aRet.sReading = rTOXMark.GetTextReading();
} }
break; break;
} }
// if TOI_INITIAL_CAPS is set, first character is to be capitalized // if TOI_INITIAL_CAPS is set, first character is to be capitalized
if( nsSwTOIOptions::TOI_INITIAL_CAPS & nOpt && pTOXIntl ) if( nsSwTOIOptions::TOI_INITIAL_CAPS & nOpt && pTOXIntl && !aRet.sText.isEmpty())
{ {
String sUpper( pTOXIntl->ToUpper( rTxt, 0 )); aRet.sText = pTOXIntl->ToUpper( aRet.sText, 0 ) + aRet.sText.copy(1);
rTxt.Erase( 0, 1 ).Insert( sUpper, 0 );
} }
return aRet;
} }
void SwTOXIndex::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 ) const void SwTOXIndex::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 ) const
{ {
const xub_StrLen* pEnd = pTxtMark->GetEnd(); const xub_StrLen* pEnd = pTxtMark->GetEnd();
String sTmp;
String sTmpReading; TextAndReading aRet;
if( pEnd && !pTxtMark->GetTOXMark().IsAlternativeText() && if( pEnd && !pTxtMark->GetTOXMark().IsAlternativeText() &&
0 == (GetOptions() & nsSwTOIOptions::TOI_KEY_AS_ENTRY)) 0 == (GetOptions() & nsSwTOIOptions::TOI_KEY_AS_ENTRY))
{ {
sTmp = ((SwTxtNode*)aTOXSources[0].pNd)->GetExpandTxt( aRet.sText = ((SwTxtNode*)aTOXSources[0].pNd)->GetExpandTxt(
*pTxtMark->GetStart(), *pTxtMark->GetStart(),
*pEnd - *pTxtMark->GetStart()); *pEnd - *pTxtMark->GetStart());
if(nsSwTOIOptions::TOI_INITIAL_CAPS&nOpt && pTOXIntl) if(nsSwTOIOptions::TOI_INITIAL_CAPS & nOpt && pTOXIntl && !aRet.sText.isEmpty())
{ {
String sUpper( pTOXIntl->ToUpper( sTmp, 0 )); aRet.sText = pTOXIntl->ToUpper( aRet.sText, 0 ) + aRet.sText.copy(1);
sTmp.Erase( 0, 1 ).Insert( sUpper, 0 );
} }
} }
else else
GetTxt( sTmp, sTmpReading ); aRet = GetTxt();
rNd.InsertText( sTmp, rInsPos ); rNd.InsertText( aRet.sText, rInsPos );
} }
...@@ -456,45 +424,29 @@ sal_uInt16 SwTOXIndex::GetLevel() const ...@@ -456,45 +424,29 @@ sal_uInt16 SwTOXIndex::GetLevel() const
--------------------------------------------------------------------*/ --------------------------------------------------------------------*/
SwTOXCustom::SwTOXCustom(const String& rStr, const String& rReading, SwTOXCustom::SwTOXCustom(const TextAndReading& rKey,
sal_uInt16 nLevel, sal_uInt16 nLevel,
const SwTOXInternational& rIntl, const SwTOXInternational& rIntl,
const lang::Locale& rLocale ) const lang::Locale& rLocale )
: SwTOXSortTabBase( TOX_SORT_CUSTOM, 0, 0, &rIntl, &rLocale ), : SwTOXSortTabBase( TOX_SORT_CUSTOM, 0, 0, &rIntl, &rLocale ),
aKey(rStr), sReading(rReading), nLev(nLevel) m_aKey(rKey), nLev(nLevel)
{ {
} }
bool SwTOXCustom::operator==(const SwTOXSortTabBase& rCmpBase) bool SwTOXCustom::operator==(const SwTOXSortTabBase& rCmpBase)
{ {
String sMyTxt;
String sMyTxtReading;
GetTxt( sMyTxt, sMyTxtReading );
String sOtherTxt;
String sOtherTxtReading;
rCmpBase.GetTxt( sOtherTxt, sOtherTxtReading );
return GetLevel() == rCmpBase.GetLevel() && return GetLevel() == rCmpBase.GetLevel() &&
pTOXIntl->IsEqual( sMyTxt, sMyTxtReading, GetLocale(), pTOXIntl->IsEqual( GetTxt(), GetLocale(),
sOtherTxt, sOtherTxtReading, rCmpBase.GetLocale() ); rCmpBase.GetTxt(), rCmpBase.GetLocale() );
} }
bool SwTOXCustom::operator < (const SwTOXSortTabBase& rCmpBase) bool SwTOXCustom::operator < (const SwTOXSortTabBase& rCmpBase)
{ {
String sMyTxt;
String sMyTxtReading;
GetTxt( sMyTxt, sMyTxtReading );
String sOtherTxt;
String sOtherTxtReading;
rCmpBase.GetTxt( sOtherTxt, sOtherTxtReading );
return GetLevel() <= rCmpBase.GetLevel() && return GetLevel() <= rCmpBase.GetLevel() &&
pTOXIntl->IsLess( sMyTxt, sMyTxtReading, GetLocale(), pTOXIntl->IsLess( GetTxt(), GetLocale(),
sOtherTxt, sOtherTxtReading, rCmpBase.GetLocale() ); rCmpBase.GetTxt(), rCmpBase.GetLocale() );
} }
...@@ -504,10 +456,9 @@ sal_uInt16 SwTOXCustom::GetLevel() const ...@@ -504,10 +456,9 @@ sal_uInt16 SwTOXCustom::GetLevel() const
} }
void SwTOXCustom::GetText_Impl( String& rTxt, String &rTxtReading ) const TextAndReading SwTOXCustom::GetText_Impl() const
{ {
rTxt = aKey; return m_aKey;
rTxtReading = sReading;
} }
...@@ -525,19 +476,19 @@ SwTOXContent::SwTOXContent( const SwTxtNode& rNd, const SwTxtTOXMark* pMark, ...@@ -525,19 +476,19 @@ SwTOXContent::SwTOXContent( const SwTxtNode& rNd, const SwTxtTOXMark* pMark,
// The content's text // The content's text
void SwTOXContent::GetText_Impl( String& rTxt, String& rTxtReading ) const TextAndReading SwTOXContent::GetText_Impl() const
{ {
const xub_StrLen* pEnd = pTxtMark->GetEnd(); const xub_StrLen* pEnd = pTxtMark->GetEnd();
if( pEnd && !pTxtMark->GetTOXMark().IsAlternativeText() ) if( pEnd && !pTxtMark->GetTOXMark().IsAlternativeText() )
{ {
rTxt = ((SwTxtNode*)aTOXSources[0].pNd)->GetExpandTxt( return TextAndReading(
((SwTxtNode*)aTOXSources[0].pNd)->GetExpandTxt(
*pTxtMark->GetStart(), *pTxtMark->GetStart(),
*pEnd - *pTxtMark->GetStart() ); *pEnd - *pTxtMark->GetStart() ),
pTxtMark->GetTOXMark().GetTextReading());
rTxtReading = pTxtMark->GetTOXMark().GetTextReading();
} }
else
rTxt = pTxtMark->GetTOXMark().GetAlternativeText(); return TextAndReading(pTxtMark->GetTOXMark().GetAlternativeText(), OUString());
} }
void SwTOXContent::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 ) const void SwTOXContent::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 ) const
...@@ -549,9 +500,7 @@ void SwTOXContent::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 ...@@ -549,9 +500,7 @@ void SwTOXContent::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16
*pEnd - *pTxtMark->GetStart() ); *pEnd - *pTxtMark->GetStart() );
else else
{ {
String sTmp, sTmpReading; rNd.InsertText( GetTxt().sText, rInsPos );
GetTxt( sTmp, sTmpReading );
rNd.InsertText( sTmp, rInsPos );
} }
} }
...@@ -582,7 +531,7 @@ SwTOXPara::SwTOXPara( const SwCntntNode& rNd, SwTOXElement eT, sal_uInt16 nLevel ...@@ -582,7 +531,7 @@ SwTOXPara::SwTOXPara( const SwCntntNode& rNd, SwTOXElement eT, sal_uInt16 nLevel
} }
void SwTOXPara::GetText_Impl( String& rTxt, String& ) const TextAndReading SwTOXPara::GetText_Impl() const
{ {
const SwCntntNode* pNd = aTOXSources[0].pNd; const SwCntntNode* pNd = aTOXSources[0].pNd;
switch( eType ) switch( eType )
...@@ -592,9 +541,10 @@ void SwTOXPara::GetText_Impl( String& rTxt, String& ) const ...@@ -592,9 +541,10 @@ void SwTOXPara::GetText_Impl( String& rTxt, String& ) const
case nsSwTOXElement::TOX_OUTLINELEVEL: case nsSwTOXElement::TOX_OUTLINELEVEL:
{ {
xub_StrLen nStt = nStartIndex; xub_StrLen nStt = nStartIndex;
rTxt = ((SwTxtNode*)pNd)->GetExpandTxt( return TextAndReading(((SwTxtNode*)pNd)->GetExpandTxt(
nStt, nStt,
STRING_NOTFOUND == nEndIndex ? STRING_LEN : nEndIndex - nStt); STRING_NOTFOUND == nEndIndex ? STRING_LEN : nEndIndex - nStt),
OUString());
} }
break; break;
...@@ -605,21 +555,20 @@ void SwTOXPara::GetText_Impl( String& rTxt, String& ) const ...@@ -605,21 +555,20 @@ void SwTOXPara::GetText_Impl( String& rTxt, String& ) const
// Find the FlyFormat; the object/graphic name is there // Find the FlyFormat; the object/graphic name is there
SwFrmFmt* pFly = pNd->GetFlyFmt(); SwFrmFmt* pFly = pNd->GetFlyFmt();
if( pFly ) if( pFly )
rTxt = pFly->GetName(); return TextAndReading(pFly->GetName(), OUString());
else
{ OSL_ENSURE( !this, "Graphic/object without name" );
OSL_ENSURE( !this, "Graphic/object without name" ); sal_uInt16 nId = nsSwTOXElement::TOX_OLE == eType
sal_uInt16 nId = nsSwTOXElement::TOX_OLE == eType ? STR_OBJECT_DEFNAME
? STR_OBJECT_DEFNAME : nsSwTOXElement::TOX_GRAPHIC == eType
: nsSwTOXElement::TOX_GRAPHIC == eType ? STR_GRAPHIC_DEFNAME
? STR_GRAPHIC_DEFNAME : STR_FRAME_DEFNAME;
: STR_FRAME_DEFNAME; return TextAndReading(SW_RESSTR( nId ), OUString());
rTxt = SW_RESSTR( nId );
}
} }
break; break;
default: break; default: break;
} }
return TextAndReading();
} }
void SwTOXPara::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 ) const void SwTOXPara::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 ) const
...@@ -634,10 +583,7 @@ void SwTOXPara::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 ) c ...@@ -634,10 +583,7 @@ void SwTOXPara::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, sal_uInt16 ) c
} }
else else
{ {
String sTmp, sTmpReading; rNd.InsertText( GetTxt().sText.replace('\t', ' '), rInsPos );
GetTxt( sTmp, sTmpReading );
sTmp.SearchAndReplaceAll('\t', ' ');
rNd.InsertText( sTmp, rInsPos );
} }
} }
...@@ -722,18 +668,21 @@ SwTOXTable::SwTOXTable( const SwCntntNode& rNd ) ...@@ -722,18 +668,21 @@ SwTOXTable::SwTOXTable( const SwCntntNode& rNd )
} }
void SwTOXTable::GetText_Impl( String& rTxt, String& ) const TextAndReading SwTOXTable::GetText_Impl() const
{ {
const SwNode* pNd = aTOXSources[0].pNd; const SwNode* pNd = aTOXSources[0].pNd;
if( pNd && 0 != ( pNd = pNd->FindTableNode() ) ) if( pNd )
{
rTxt = ((SwTableNode*)pNd)->GetTable().GetFrmFmt()->GetName();
}
else
{ {
OSL_ENSURE( !this, "Where's my table?" ); const SwTableNode* pTableNd =
rTxt = SW_RESSTR( STR_TABLE_DEFNAME ); reinterpret_cast<const SwTableNode*>(pNd->FindTableNode());
if (pTableNd)
{
return TextAndReading(pTableNd->GetTable().GetFrmFmt()->GetName(), OUString());
}
} }
OSL_ENSURE( !this, "Where's my table?" );
return TextAndReading(SW_RESSTR( STR_TABLE_DEFNAME ), OUString());
} }
sal_uInt16 SwTOXTable::GetLevel() const sal_uInt16 SwTOXTable::GetLevel() const
...@@ -790,9 +739,9 @@ static String lcl_GetText(SwFmtFld const& rField) ...@@ -790,9 +739,9 @@ static String lcl_GetText(SwFmtFld const& rField)
return rField.GetFld()->ExpandField(true); return rField.GetFld()->ExpandField(true);
} }
void SwTOXAuthority::GetText_Impl( String& rTxt, String& ) const TextAndReading SwTOXAuthority::GetText_Impl() const
{ {
rTxt = lcl_GetText(m_rField); return TextAndReading(lcl_GetText(m_rField), OUString());
} }
void SwTOXAuthority::FillText( SwTxtNode& rNd, void SwTOXAuthority::FillText( SwTxtNode& rNd,
...@@ -846,13 +795,11 @@ bool SwTOXAuthority::operator<( const SwTOXSortTabBase& rBase) ...@@ -846,13 +795,11 @@ bool SwTOXAuthority::operator<( const SwTOXSortTabBase& rBase)
for(sal_uInt16 i = 0; i < pType->GetSortKeyCount(); i++) for(sal_uInt16 i = 0; i < pType->GetSortKeyCount(); i++)
{ {
const SwTOXSortKey* pKey = pType->GetSortKey(i); const SwTOXSortKey* pKey = pType->GetSortKey(i);
String sMyTxt = pField->GetFieldText(pKey->eField); const TextAndReading aMy(pField->GetFieldText(pKey->eField), OUString());
String sMyTxtReading; const TextAndReading aOther(pCmpField->GetFieldText(pKey->eField), OUString());
String sOtherTxt = pCmpField->GetFieldText(pKey->eField);
String sOtherTxtReading;
sal_Int32 nComp = pTOXIntl->Compare( sMyTxt, sMyTxtReading, GetLocale(), sal_Int32 nComp = pTOXIntl->Compare( aMy, GetLocale(),
sOtherTxt, sOtherTxtReading, rBase.GetLocale() ); aOther, rBase.GetLocale() );
if( nComp ) if( nComp )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment