sw/inc/doc.hxx | 10 +-- sw/inc/editsh.hxx | 2 sw/source/core/doc/docfld.cxx | 113 ++++++++++++++++++-------------------- sw/source/core/doc/docnum.cxx | 8 +- sw/source/core/docnode/ndcopy.cxx | 2 sw/source/core/edit/ednumber.cxx | 2 sw/source/ui/dbui/dbtree.cxx | 40 ++++++------- sw/source/ui/fldui/changedb.cxx | 16 +++-- sw/source/ui/fldui/flddb.cxx | 61 ++++++++++---------- sw/source/ui/fldui/flddb.hxx | 12 ++-- sw/source/ui/inc/dbtree.hxx | 2 sw/source/ui/shells/textsh1.cxx | 4 - sw/source/ui/wrtsh/wrtsh1.cxx | 2 13 files changed, 137 insertions(+), 137 deletions(-)
New commits: commit 1b0f6be2d06154f6ecab2f6ee930fa3c5a62f01d Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Sun Sep 29 10:45:36 2013 +0200 There are no users of this optional argument Change-Id: I74b4988a3c93e0964580bdd35210b3495365d5b6 diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index dff3385..8d6ea4d 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1527,7 +1527,7 @@ public: OUString GetUniqueNumRuleName( const OUString* pChkStr = 0, bool bAutoNum = true ) const; void UpdateNumRule(); /// Update all invalids. - void ChgNumRuleFmts( const SwNumRule& rRule, const String * pOldName = 0 ); + void ChgNumRuleFmts( const SwNumRule& rRule ); bool ReplaceNumRule( const SwPosition& rPos, const String& rOldRule, const String& rNewRule ); diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index 2a3105f..52f3b1d 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -1061,9 +1061,9 @@ bool SwDoc::DelNumRule( const String& rName, bool bBroadcast ) return false; } -void SwDoc::ChgNumRuleFmts( const SwNumRule& rRule, const String * pName ) +void SwDoc::ChgNumRuleFmts( const SwNumRule& rRule ) { - SwNumRule* pRule = FindNumRulePtr( pName ? *pName : String(rRule.GetName()) ); + SwNumRule* pRule = FindNumRulePtr( rRule.GetName() ); if( pRule ) { SwUndoInsNum* pUndo = 0; commit 8b7bc95275b19affebf50b3ecba6c763f63bc1c5 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Sun Sep 29 01:38:27 2013 +0200 String to OUString Change-Id: I6cff1659b0bacef0bed90fb9767513018a7eeba7 diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index a71b21a..dff3385 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1565,7 +1565,7 @@ public: const bool bNum, const bool bOutline, int nNonEmptyAllowed, - String& sListId, + OUString& sListId, const bool bInvestigateStartNode = false ); /// Paragraphs without numbering but with indents. diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx index a8d0d72..d1eb77b 100644 --- a/sw/inc/editsh.hxx +++ b/sw/inc/editsh.hxx @@ -545,7 +545,7 @@ public: const bool bNum, const bool bOutline, int nNonEmptyAllowed, - String& sListId ); + OUString& sListId ); /** Undo. Maintain UndoHistory in Document. diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index 4903d25..2a3105f 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -1205,7 +1205,7 @@ namespace { SwNumRule* pReplaceNumRule; bool bCreateNewList; - String sListId; + OUString sListId; ListStyleData() : pReplaceNumRule( 0 ), @@ -1539,7 +1539,7 @@ const SwNumRule * SwDoc::SearchNumRule(const SwPosition & rPos, const bool bNum, const bool bOutline, int nNonEmptyAllowed, - String& sListId, + OUString& sListId, const bool bInvestigateStartNode) { const SwNumRule * pResult = NULL; diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index e0b0d7a..5b69592 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -920,7 +920,7 @@ bool SwDoc::CopyImpl( SwPaM& rPam, SwPosition& rPos, // First search for non-outline numbering list. Then search for non-outline // bullet list. // Keep also the <ListId> value for possible propagation. - String aListIdToPropagate; + OUString aListIdToPropagate; const SwNumRule* pNumRuleToPropagate = pDoc->SearchNumRule( rPos, false, true, false, 0, aListIdToPropagate, true ); if ( !pNumRuleToPropagate ) diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx index 282ed26..cd0e142 100644 --- a/sw/source/core/edit/ednumber.cxx +++ b/sw/source/core/edit/ednumber.cxx @@ -830,7 +830,7 @@ const SwNumRule * SwEditShell::SearchNumRule( const bool bForward, const bool bNum, const bool bOutline, int nNonEmptyAllowed, - String& sListId ) + OUString& sListId ) { return GetDoc()->SearchNumRule( *(bForward ? GetCrsr()->End() : GetCrsr()->Start()), bForward, bNum, bOutline, nNonEmptyAllowed, diff --git a/sw/source/ui/shells/textsh1.cxx b/sw/source/ui/shells/textsh1.cxx index 902a885..c018b5f 100644 --- a/sw/source/ui/shells/textsh1.cxx +++ b/sw/source/ui/shells/textsh1.cxx @@ -1066,7 +1066,7 @@ void SwTextShell::Execute(SfxRequest &rReq) break; case FN_NUM_CONTINUE: { - String sContinuedListId; + OUString sContinuedListId; const SwNumRule* pRule = rWrtSh.SearchNumRule( false, true, false, -1, sContinuedListId ); // #i86492# @@ -1680,7 +1680,7 @@ void SwTextShell::GetState( SfxItemSet &rSet ) { // #i86492# // Search also for bullet list - String aDummy; + OUString aDummy; const SwNumRule* pRule = rSh.SearchNumRule( false, true, false, -1, aDummy ); if ( !pRule ) diff --git a/sw/source/ui/wrtsh/wrtsh1.cxx b/sw/source/ui/wrtsh/wrtsh1.cxx index 0cda8cf..c87aaa1 100644 --- a/sw/source/ui/wrtsh/wrtsh1.cxx +++ b/sw/source/ui/wrtsh/wrtsh1.cxx @@ -1139,7 +1139,7 @@ void SwWrtShell::NumOrBulletOn(sal_Bool bNum) } // Search for a previous numbering/bullet rule to continue it. - String sContinuedListId; + OUString sContinuedListId; if ( !pNumRule ) { pNumRule = GetDoc()->SearchNumRule( *GetCrsr()->GetPoint(), commit 9811d927766ec54c0ca7e163df3bd762caab0355 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Sat Sep 28 13:47:03 2013 +0200 Formel to Formula Change-Id: I757bcfb1f425190a9fb62d1e0428f724230fe194 diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index d98ede9..a71b21a 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -656,9 +656,9 @@ private: bool IsNameInArray( const std::vector<String>& rOldNames, const String& rName ); void GetAllDBNames( std::vector<String>& rAllDBNames ); OUString ReplaceUsedDBs( const std::vector<String>& rUsedDBNames, - const OUString& rNewName, const OUString& rFormel ); + const OUString& rNewName, const OUString& rFormula ); std::vector<String>& FindUsedDBs( const std::vector<String>& rAllDBNames, - const String& rFormel, + const String& rFormula, std::vector<String>& rUsedDBNames ); void InitDrawModel(); diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index b459705..6b83111 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -1755,13 +1755,13 @@ void SwDoc::GetAllDBNames( std::vector<String>& rAllDBNames ) } std::vector<String>& SwDoc::FindUsedDBs( const std::vector<String>& rAllDBNames, - const String& rFormel, + const String& rFormula, std::vector<String>& rUsedDBNames ) { const CharClass& rCC = GetAppCharClass(); - String sFormel( rFormel); + String sFormula(rFormula); #ifndef UNX - sFormel = rCC.uppercase( sFormel ); + sFormula = rCC.uppercase( sFormula ); #endif xub_StrLen nPos; @@ -1769,17 +1769,17 @@ std::vector<String>& SwDoc::FindUsedDBs( const std::vector<String>& rAllDBNames, { String pStr(rAllDBNames[i]); - if( STRING_NOTFOUND != (nPos = sFormel.Search( pStr )) && - sFormel.GetChar( nPos + pStr.Len() ) == '.' && - (!nPos || !rCC.isLetterNumeric( sFormel, nPos - 1 ))) + if( STRING_NOTFOUND != (nPos = sFormula.Search( pStr )) && + sFormula.GetChar( nPos + pStr.Len() ) == '.' && + (!nPos || !rCC.isLetterNumeric( sFormula, nPos - 1 ))) { // Look up table name xub_StrLen nEndPos; nPos += pStr.Len() + 1; - if( STRING_NOTFOUND != (nEndPos = sFormel.Search('.', nPos)) ) + if( STRING_NOTFOUND != (nEndPos = sFormula.Search('.', nPos)) ) { pStr.Append( DB_DELIM ); - pStr.Append( sFormel.Copy( nPos, nEndPos - nPos )); + pStr.Append( sFormula.Copy( nPos, nEndPos - nPos )); rUsedDBNames.push_back(pStr); } } @@ -1923,11 +1923,11 @@ inline OUString lcl_CutOffDBCommandType(const OUString& rName) } OUString SwDoc::ReplaceUsedDBs( const std::vector<String>& rUsedDBNames, - const OUString& rNewName, const OUString& rFormel ) + const OUString& rNewName, const OUString& rFormula ) { const CharClass& rCC = GetAppCharClass(); const OUString sNewName( lcl_CutOffDBCommandType(rNewName) ); - OUString sFormula(rFormel); + OUString sFormula(rFormula); for( size_t i = 0; i < rUsedDBNames.size(); ++i ) { @@ -2274,41 +2274,41 @@ void SwDocUpdtFld::_MakeFldList( SwDoc& rDoc, int eGetMode ) if( !pTxtFld || !pTxtFld->GetTxtNode().GetNodes().IsDocNodes() ) continue; - OUString sFormel; + OUString sFormula; const SwField* pFld = pFmtFld->GetFld(); switch( nWhich = pFld->GetTyp()->Which() ) { case RES_DBSETNUMBERFLD: case RES_GETEXPFLD: if( GETFLD_ALL == eGetMode ) - sFormel = sTrue; + sFormula = sTrue; break; case RES_DBFLD: if( GETFLD_EXPAND & eGetMode ) - sFormel = sTrue; + sFormula = sTrue; break; case RES_SETEXPFLD: if ( !(eGetMode == GETFLD_EXPAND) || (nsSwGetSetExpType::GSE_STRING & pFld->GetSubType()) ) { - sFormel = sTrue; + sFormula = sTrue; } break; case RES_HIDDENPARAFLD: if( GETFLD_ALL == eGetMode ) { - sFormel = pFld->GetPar1(); - if (sFormel.isEmpty() || sFormel==sFalse) + sFormula = pFld->GetPar1(); + if (sFormula.isEmpty() || sFormula==sFalse) ((SwHiddenParaField*)pFld)->SetHidden( sal_False ); - else if (sFormel==sTrue) + else if (sFormula==sTrue) ((SwHiddenParaField*)pFld)->SetHidden( sal_True ); else break; - sFormel = OUString(); + sFormula = OUString(); // trigger formatting ((SwFmtFld*)pFmtFld)->ModifyNotification( 0, 0 ); } @@ -2317,15 +2317,15 @@ void SwDocUpdtFld::_MakeFldList( SwDoc& rDoc, int eGetMode ) case RES_HIDDENTXTFLD: if( GETFLD_ALL == eGetMode ) { - sFormel = pFld->GetPar1(); - if (sFormel.isEmpty() || sFormel==sFalse) + sFormula = pFld->GetPar1(); + if (sFormula.isEmpty() || sFormula==sFalse) ((SwHiddenTxtField*)pFld)->SetValue( sal_True ); - else if (sFormel==sTrue) + else if (sFormula==sTrue) ((SwHiddenTxtField*)pFld)->SetValue( sal_False ); else break; - sFormel = OUString(); + sFormula = OUString(); // evaluate field ((SwHiddenTxtField*)pFld)->Evaluate(&rDoc); @@ -2343,7 +2343,7 @@ void SwDocUpdtFld::_MakeFldList( SwDoc& rDoc, int eGetMode ) (GETFLD_ALL == eGetMode || (GETFLD_CALC & eGetMode && ((SwDBNumSetField*)pFld)->IsCondValid())) ) { - sFormel = pFld->GetPar1(); + sFormula = pFld->GetPar1(); } } break; @@ -2356,13 +2356,13 @@ void SwDocUpdtFld::_MakeFldList( SwDoc& rDoc, int eGetMode ) (GETFLD_ALL == eGetMode || (GETFLD_CALC & eGetMode && ((SwDBNextSetField*)pFld)->IsCondValid())) ) { - sFormel = pFld->GetPar1(); + sFormula = pFld->GetPar1(); } } break; } - if (!sFormel.isEmpty()) + if (!sFormula.isEmpty()) { GetBodyNode( *pTxtFld, nWhich ); } commit 609e1af93fbfd1a835e657f9ad8e7d70e26b7be4 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Sat Sep 28 13:39:25 2013 +0200 Minor cleanup Change-Id: I097a9f2a553f163d7af33b7d3e0bac6b79177b7b diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index ef38437..b459705 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -1929,15 +1929,21 @@ OUString SwDoc::ReplaceUsedDBs( const std::vector<String>& rUsedDBNames, const OUString sNewName( lcl_CutOffDBCommandType(rNewName) ); OUString sFormula(rFormel); - for( sal_uInt16 i = 0; i < rUsedDBNames.size(); ++i ) + for( size_t i = 0; i < rUsedDBNames.size(); ++i ) { const OUString sDBName( lcl_CutOffDBCommandType(rUsedDBNames[i]) ); if (sDBName!=sNewName) { sal_Int32 nPos = 0; - while ((nPos = sFormula.indexOf(sDBName, nPos))>=0) + for (;;) { + nPos = sFormula.indexOf(sDBName, nPos); + if (nPos<0) + { + break; + } + if( sFormula[nPos + sDBName.getLength()] == '.' && (!nPos || !rCC.isLetterNumeric( sFormula, nPos - 1 ))) { @@ -1945,7 +1951,7 @@ OUString SwDoc::ReplaceUsedDBs( const std::vector<String>& rUsedDBNames, //prevent re-searching - this is useless and provokes //endless loops when names containing each other and numbers are exchanged //e.g.: old ?12345.12345 new: i12345.12345 - nPos = nPos + sNewName.getLength(); + nPos += sNewName.getLength(); } } } commit d614742057077236e3c12e7b0c26f689a81c1ee9 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Sat Sep 28 12:26:23 2013 +0200 Prefer return value to reference argument Change-Id: I1ba2f9abfad6c8a8e48f62e6cf69c7c36b6e1ace diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index daefef0..d98ede9 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -655,8 +655,8 @@ private: void AddUsedDBToList( std::vector<String>& rDBNameList, const String& rDBName ); bool IsNameInArray( const std::vector<String>& rOldNames, const String& rName ); void GetAllDBNames( std::vector<String>& rAllDBNames ); - void ReplaceUsedDBs( const std::vector<String>& rUsedDBNames, - const String& rNewName, OUString& rFormel ); + OUString ReplaceUsedDBs( const std::vector<String>& rUsedDBNames, + const OUString& rNewName, const OUString& rFormel ); std::vector<String>& FindUsedDBs( const std::vector<String>& rAllDBNames, const String& rFormel, std::vector<String>& rUsedDBNames ); diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index 636b68e..ef38437 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -1833,9 +1833,7 @@ void SwDoc::ChangeDBFields( const std::vector<String>& rOldNames, if( pSect ) { - OUString sFormel = pSect->GetCondition(); - ReplaceUsedDBs( rOldNames, rNewName, sFormel); - pSect->SetCondition(sFormel); + pSect->SetCondition(ReplaceUsedDBs(rOldNames, rNewName, pSect->GetCondition())); } } @@ -1896,24 +1894,16 @@ void SwDoc::ChangeDBFields( const std::vector<String>& rOldNames, // no break; case RES_HIDDENTXTFLD: case RES_HIDDENPARAFLD: - { - OUString sFormel = pFld->GetPar1(); - ReplaceUsedDBs( rOldNames, rNewName, sFormel); - pFld->SetPar1( sFormel ); + pFld->SetPar1( ReplaceUsedDBs(rOldNames, rNewName, pFld->GetPar1()) ); bExpand = true; break; - } case RES_SETEXPFLD: case RES_GETEXPFLD: case RES_TABLEFLD: - { - OUString sFormel = pFld->GetFormula(); - ReplaceUsedDBs( rOldNames, rNewName, sFormel); - pFld->SetPar2( sFormel ); + pFld->SetPar2( ReplaceUsedDBs(rOldNames, rNewName, pFld->GetFormula()) ); bExpand = true; break; - } } if (bExpand) @@ -1932,11 +1922,12 @@ inline OUString lcl_CutOffDBCommandType(const OUString& rName) } -void SwDoc::ReplaceUsedDBs( const std::vector<String>& rUsedDBNames, - const String& rNewName, OUString& rFormel ) +OUString SwDoc::ReplaceUsedDBs( const std::vector<String>& rUsedDBNames, + const OUString& rNewName, const OUString& rFormel ) { const CharClass& rCC = GetAppCharClass(); const OUString sNewName( lcl_CutOffDBCommandType(rNewName) ); + OUString sFormula(rFormel); for( sal_uInt16 i = 0; i < rUsedDBNames.size(); ++i ) { @@ -1945,12 +1936,12 @@ void SwDoc::ReplaceUsedDBs( const std::vector<String>& rUsedDBNames, if (sDBName!=sNewName) { sal_Int32 nPos = 0; - while ((nPos = rFormel.indexOf(sDBName, nPos))>=0) + while ((nPos = sFormula.indexOf(sDBName, nPos))>=0) { - if( rFormel[nPos + sDBName.getLength()] == '.' && - (!nPos || !rCC.isLetterNumeric( rFormel, nPos - 1 ))) + if( sFormula[nPos + sDBName.getLength()] == '.' && + (!nPos || !rCC.isLetterNumeric( sFormula, nPos - 1 ))) { - rFormel = rFormel.replaceAt(nPos, sDBName.getLength(), sNewName); + sFormula = sFormula.replaceAt(nPos, sDBName.getLength(), sNewName); //prevent re-searching - this is useless and provokes //endless loops when names containing each other and numbers are exchanged //e.g.: old ?12345.12345 new: i12345.12345 @@ -1959,6 +1950,7 @@ void SwDoc::ReplaceUsedDBs( const std::vector<String>& rUsedDBNames, } } } + return sFormula; } bool SwDoc::IsNameInArray( const std::vector<String>& rArr, const String& rName ) commit 571e8eba65808336870faf593148f42ea2f9571c Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Sat Sep 28 11:30:13 2013 +0200 String to OUString + helper function Change-Id: I9a318c50bc2427f55f58a13f96cbcb68fbc66f21 diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index efd82c3..636b68e 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -1922,35 +1922,39 @@ void SwDoc::ChangeDBFields( const std::vector<String>& rOldNames, SetModified(); } +namespace +{ + +inline OUString lcl_CutOffDBCommandType(const OUString& rName) +{ + return rName.replaceFirst(OUString(DB_DELIM), ".").getToken(0, DB_DELIM); +} + +} + void SwDoc::ReplaceUsedDBs( const std::vector<String>& rUsedDBNames, const String& rNewName, OUString& rFormel ) { const CharClass& rCC = GetAppCharClass(); - String sNewName( rNewName ); - sNewName.SearchAndReplace( DB_DELIM, '.'); - //the command type is not part of the condition - sNewName = sNewName.GetToken(0, DB_DELIM); + const OUString sNewName( lcl_CutOffDBCommandType(rNewName) ); for( sal_uInt16 i = 0; i < rUsedDBNames.size(); ++i ) { - String sDBName( rUsedDBNames[i] ); + const OUString sDBName( lcl_CutOffDBCommandType(rUsedDBNames[i]) ); - sDBName.SearchAndReplace( DB_DELIM, '.'); - //cut off command type - sDBName = sDBName.GetToken(0, DB_DELIM); - if( !sDBName.Equals( sNewName )) + if (sDBName!=sNewName) { sal_Int32 nPos = 0; while ((nPos = rFormel.indexOf(sDBName, nPos))>=0) { - if( rFormel[nPos + sDBName.Len()] == '.' && + if( rFormel[nPos + sDBName.getLength()] == '.' && (!nPos || !rCC.isLetterNumeric( rFormel, nPos - 1 ))) { - rFormel = rFormel.replaceAt(nPos, sDBName.Len(), sNewName); + rFormel = rFormel.replaceAt(nPos, sDBName.getLength(), sNewName); //prevent re-searching - this is useless and provokes //endless loops when names containing each other and numbers are exchanged //e.g.: old ?12345.12345 new: i12345.12345 - nPos = nPos + sNewName.Len(); + nPos = nPos + sNewName.getLength(); } } } commit 92caee2ea04c47aa09190bd498fba434a1641838 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Sat Sep 28 10:18:18 2013 +0200 sUpperNewNm is a duplicate(?) of sNewName Change-Id: I8c45a3d19dd5c54bd35ad1320b8ed4f811f22bff diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index a2a4ddd..efd82c3 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -1930,7 +1930,6 @@ void SwDoc::ReplaceUsedDBs( const std::vector<String>& rUsedDBNames, sNewName.SearchAndReplace( DB_DELIM, '.'); //the command type is not part of the condition sNewName = sNewName.GetToken(0, DB_DELIM); - String sUpperNewNm( sNewName ); for( sal_uInt16 i = 0; i < rUsedDBNames.size(); ++i ) { @@ -1939,7 +1938,7 @@ void SwDoc::ReplaceUsedDBs( const std::vector<String>& rUsedDBNames, sDBName.SearchAndReplace( DB_DELIM, '.'); //cut off command type sDBName = sDBName.GetToken(0, DB_DELIM); - if( !sDBName.Equals( sUpperNewNm )) + if( !sDBName.Equals( sNewName )) { sal_Int32 nPos = 0; while ((nPos = rFormel.indexOf(sDBName, nPos))>=0) commit 5f3ec872c2a53586b6ab29d836a89c50882f8a0c Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Sat Sep 28 01:18:44 2013 +0200 sFormel is just a duplicate of rFormel Change-Id: Ib3eb3f517845776ba3ed51f63692f18d51c3f1cc diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index d9b255a..a2a4ddd 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -1926,7 +1926,6 @@ void SwDoc::ReplaceUsedDBs( const std::vector<String>& rUsedDBNames, const String& rNewName, OUString& rFormel ) { const CharClass& rCC = GetAppCharClass(); - String sFormel(rFormel); String sNewName( rNewName ); sNewName.SearchAndReplace( DB_DELIM, '.'); //the command type is not part of the condition @@ -1942,19 +1941,17 @@ void SwDoc::ReplaceUsedDBs( const std::vector<String>& rUsedDBNames, sDBName = sDBName.GetToken(0, DB_DELIM); if( !sDBName.Equals( sUpperNewNm )) { - xub_StrLen nPos = 0; - - while ((nPos = sFormel.Search(sDBName, nPos)) != STRING_NOTFOUND) + sal_Int32 nPos = 0; + while ((nPos = rFormel.indexOf(sDBName, nPos))>=0) { - if( sFormel.GetChar( nPos + sDBName.Len() ) == '.' && - (!nPos || !rCC.isLetterNumeric( sFormel, nPos - 1 ))) + if( rFormel[nPos + sDBName.Len()] == '.' && + (!nPos || !rCC.isLetterNumeric( rFormel, nPos - 1 ))) { rFormel = rFormel.replaceAt(nPos, sDBName.Len(), sNewName); //prevent re-searching - this is useless and provokes //endless loops when names containing each other and numbers are exchanged //e.g.: old ?12345.12345 new: i12345.12345 nPos = nPos + sNewName.Len(); - sFormel = rFormel; } } } commit 27a236601b3be2a625a64bf07bfdf50f462f6e43 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Fri Sep 27 20:03:25 2013 +0200 String to OUString and minor scope reduction Change-Id: Ic12bb1b51a9b256614876fdfde0056558fa663e9 diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index bff7868..daefef0 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -656,7 +656,7 @@ private: bool IsNameInArray( const std::vector<String>& rOldNames, const String& rName ); void GetAllDBNames( std::vector<String>& rAllDBNames ); void ReplaceUsedDBs( const std::vector<String>& rUsedDBNames, - const String& rNewName, String& rFormel ); + const String& rNewName, OUString& rFormel ); std::vector<String>& FindUsedDBs( const std::vector<String>& rAllDBNames, const String& rFormel, std::vector<String>& rUsedDBNames ); diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index d917a71..d9b255a 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -1826,8 +1826,6 @@ void SwDoc::ChangeDBFields( const std::vector<String>& rOldNames, aNewDBData.sCommand = rNewName.GetToken(1, DB_DELIM); aNewDBData.nCommandType = (short)rNewName.GetToken(2, DB_DELIM).ToInt32(); - String sFormel; - SwSectionFmts& rArr = GetSections(); for (sal_uInt16 n = rArr.size(); n; ) { @@ -1835,7 +1833,7 @@ void SwDoc::ChangeDBFields( const std::vector<String>& rOldNames, if( pSect ) { - sFormel = pSect->GetCondition(); + OUString sFormel = pSect->GetCondition(); ReplaceUsedDBs( rOldNames, rNewName, sFormel); pSect->SetCondition(sFormel); } @@ -1898,20 +1896,24 @@ void SwDoc::ChangeDBFields( const std::vector<String>& rOldNames, // no break; case RES_HIDDENTXTFLD: case RES_HIDDENPARAFLD: - sFormel = pFld->GetPar1(); + { + OUString sFormel = pFld->GetPar1(); ReplaceUsedDBs( rOldNames, rNewName, sFormel); pFld->SetPar1( sFormel ); bExpand = true; break; + } case RES_SETEXPFLD: case RES_GETEXPFLD: case RES_TABLEFLD: - sFormel = pFld->GetFormula(); + { + OUString sFormel = pFld->GetFormula(); ReplaceUsedDBs( rOldNames, rNewName, sFormel); pFld->SetPar2( sFormel ); bExpand = true; break; + } } if (bExpand) @@ -1921,7 +1923,7 @@ void SwDoc::ChangeDBFields( const std::vector<String>& rOldNames, } void SwDoc::ReplaceUsedDBs( const std::vector<String>& rUsedDBNames, - const String& rNewName, String& rFormel ) + const String& rNewName, OUString& rFormel ) { const CharClass& rCC = GetAppCharClass(); String sFormel(rFormel); @@ -1947,8 +1949,7 @@ void SwDoc::ReplaceUsedDBs( const std::vector<String>& rUsedDBNames, if( sFormel.GetChar( nPos + sDBName.Len() ) == '.' && (!nPos || !rCC.isLetterNumeric( sFormel, nPos - 1 ))) { - rFormel.Erase( nPos, sDBName.Len() ); - rFormel.Insert( sNewName, nPos ); + rFormel = rFormel.replaceAt(nPos, sDBName.Len(), sNewName); //prevent re-searching - this is useless and provokes //endless loops when names containing each other and numbers are exchanged //e.g.: old ?12345.12345 new: i12345.12345 commit 19d0c85116922c962705af054b7a9169af1cf627 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Fri Sep 27 14:35:38 2013 +0200 Reuse already retrieved value Change-Id: Ifcc6506523182b7fe1d321851ad0fac845a808d3 diff --git a/sw/source/ui/fldui/flddb.cxx b/sw/source/ui/fldui/flddb.cxx index 866a3ab..8417b19 100644 --- a/sw/source/ui/fldui/flddb.cxx +++ b/sw/source/ui/fldui/flddb.cxx @@ -237,7 +237,7 @@ sal_Bool SwFldDBPage::FillItemSet(SfxItemSet& ) m_sOldTableName != sTempTableName || m_sOldColumnName != sTempColumnName; if (!IsFldEdit() || m_pConditionED->GetSavedValue() != m_pConditionED->GetText() || - m_pValueED->GetSavedValue() != m_pValueED->GetText() || + m_pValueED->GetSavedValue() != aVal || bDBListBoxChanged || m_nOldFormat != nFormat || m_nOldSubType != nSubType) { commit 644c69ccc99a2a02ec20dfb6f6bfe77857f142f5 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Fri Sep 27 14:31:23 2013 +0200 Use consistent naming for data members Change-Id: I01b5695d33ef96b1771b3c8a62f2964dc0295da8 diff --git a/sw/source/ui/fldui/flddb.cxx b/sw/source/ui/fldui/flddb.cxx index 96973b2..866a3ab 100644 --- a/sw/source/ui/fldui/flddb.cxx +++ b/sw/source/ui/fldui/flddb.cxx @@ -60,7 +60,7 @@ SwFldDBPage::SwFldDBPage(Window* pParent, const SfxItemSet& rCoreSet) m_pTypeLB->set_width_request(nWidth); m_pDatabaseTLB->set_width_request(nWidth*2); - aOldNumSelectHdl = m_pNumFormatLB->GetSelectHdl(); + m_aOldNumSelectHdl = m_pNumFormatLB->GetSelectHdl(); m_pNumFormatLB->SetSelectHdl(LINK(this, SwFldDBPage, NumSelectHdl)); m_pDatabaseTLB->SetSelectHdl(LINK(this, SwFldDBPage, TreeSelectHdl)); @@ -83,7 +83,7 @@ void SwFldDBPage::Reset(const SfxItemSet&) m_pTypeLB->SetUpdateMode(sal_False); sal_uInt16 nOldPos = m_pTypeLB->GetSelectEntryPos(); - sOldDBName = m_pDatabaseTLB->GetDBName(sOldTableName, sOldColumnName); + m_sOldDBName = m_pDatabaseTLB->GetDBName(m_sOldTableName, m_sOldColumnName); m_pTypeLB->Clear(); @@ -129,9 +129,9 @@ void SwFldDBPage::Reset(const SfxItemSet&) if (nOldPos != LISTBOX_ENTRY_NOTFOUND) m_pTypeLB->SelectEntryPos(nOldPos); - if (!sOldDBName.isEmpty()) + if (!m_sOldDBName.isEmpty()) { - m_pDatabaseTLB->Select(sOldDBName, sOldTableName, sOldColumnName); + m_pDatabaseTLB->Select(m_sOldDBName, m_sOldTableName, m_sOldColumnName); } else { @@ -174,9 +174,9 @@ void SwFldDBPage::Reset(const SfxItemSet&) { m_pConditionED->SaveValue(); m_pValueED->SaveValue(); - sOldDBName = m_pDatabaseTLB->GetDBName(sOldTableName, sOldColumnName); - nOldFormat = GetCurField()->GetFormat(); - nOldSubType = GetCurField()->GetSubType(); + m_sOldDBName = m_pDatabaseTLB->GetDBName(m_sOldTableName, m_sOldColumnName); + m_nOldFormat = GetCurField()->GetFormat(); + m_nOldSubType = GetCurField()->GetSubType(); } } @@ -233,13 +233,13 @@ sal_Bool SwFldDBPage::FillItemSet(SfxItemSet& ) OUString sTempTableName; OUString sTempColumnName; OUString sTempDBName = m_pDatabaseTLB->GetDBName(sTempTableName, sTempColumnName); - sal_Bool bDBListBoxChanged = sOldDBName != sTempDBName || - sOldTableName != sTempTableName || sOldColumnName != sTempColumnName; + sal_Bool bDBListBoxChanged = m_sOldDBName != sTempDBName || + m_sOldTableName != sTempTableName || m_sOldColumnName != sTempColumnName; if (!IsFldEdit() || m_pConditionED->GetSavedValue() != m_pConditionED->GetText() || m_pValueED->GetSavedValue() != m_pValueED->GetText() || bDBListBoxChanged || - nOldFormat != nFormat || nOldSubType != nSubType) + m_nOldFormat != nFormat || m_nOldSubType != nSubType) { InsertFld( nTypeId, nSubType, aName, aVal, nFormat); } @@ -384,7 +384,7 @@ IMPL_LINK( SwFldDBPage, TypeHdl, ListBox *, pBox ) IMPL_LINK( SwFldDBPage, NumSelectHdl, NumFormatListBox *, pLB ) { m_pNewFormatRB->Check(); - aOldNumSelectHdl.Call(pLB); + m_aOldNumSelectHdl.Call(pLB); return 0; } diff --git a/sw/source/ui/fldui/flddb.hxx b/sw/source/ui/fldui/flddb.hxx index eb6fdac..5655f62 100644 --- a/sw/source/ui/fldui/flddb.hxx +++ b/sw/source/ui/fldui/flddb.hxx @@ -47,12 +47,12 @@ class SwFldDBPage : public SwFldPage ListBox* m_pFormatLB; VclContainer* m_pFormat; - OUString sOldDBName; - OUString sOldTableName; - OUString sOldColumnName; - sal_uLong nOldFormat; - sal_uInt16 nOldSubType; - Link aOldNumSelectHdl; + OUString m_sOldDBName; + OUString m_sOldTableName; + OUString m_sOldColumnName; + sal_uLong m_nOldFormat; + sal_uInt16 m_nOldSubType; + Link m_aOldNumSelectHdl; DECL_LINK( TypeHdl, ListBox* ); DECL_LINK( NumSelectHdl, NumFormatListBox* pLB = 0); commit 3b6f16d24af54fa236a910de2fc49051a1a1fb3e Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Fri Sep 27 14:10:51 2013 +0200 Minor formatting Change-Id: I050d3d516f3cface312fd5c8f8f88d46667a3054 diff --git a/sw/source/ui/dbui/dbtree.cxx b/sw/source/ui/dbui/dbtree.cxx index c361faf..011c0c4 100644 --- a/sw/source/ui/dbui/dbtree.cxx +++ b/sw/source/ui/dbui/dbtree.cxx @@ -489,12 +489,12 @@ void SwDBTreeList::StartDrag( sal_Int8 /*nAction*/, const Point& /*rPosPixel*/ ) { // drag database field svx::OColumnTransferable aColTransfer( - sDBName - ,OUString() - , sdb::CommandType::TABLE - ,sTableName - , sColumnName - ,(CTF_FIELD_DESCRIPTOR |CTF_COLUMN_DESCRIPTOR )); + sDBName, + OUString(), + sdb::CommandType::TABLE, + sTableName, + sColumnName, + (CTF_FIELD_DESCRIPTOR|CTF_COLUMN_DESCRIPTOR) ); aColTransfer.addDataToContainer( pContainer ); } commit 8a7a9992906ba59d575ca9e4441b3e84fea5fae0 Author: Matteo Casalin <matteo.casa...@yahoo.com> Date: Fri Sep 27 14:05:07 2013 +0200 String to OUString Change-Id: I8ff61895eac1dc9714de5ded6e80c06e4ce5357b diff --git a/sw/source/ui/dbui/dbtree.cxx b/sw/source/ui/dbui/dbtree.cxx index 720ecf6..c361faf 100644 --- a/sw/source/ui/dbui/dbtree.cxx +++ b/sw/source/ui/dbui/dbtree.cxx @@ -245,8 +245,9 @@ void SwDBTreeList::ShowColumns(sal_Bool bShowCol) if (bShowCol != bShowColumns) { bShowColumns = bShowCol; - String sTableName, sColumnName; - String sDBName(GetDBName(sTableName, sColumnName)); + OUString sTableName; + OUString sColumnName; + const OUString sDBName(GetDBName(sTableName, sColumnName)); SetUpdateMode(sal_False); @@ -264,7 +265,7 @@ void SwDBTreeList::ShowColumns(sal_Bool bShowCol) pEntry = Next(pEntry); } - if (sDBName.Len()) + if (!sDBName.isEmpty()) { Select(sDBName, sTableName, sColumnName); // force RequestingChildren } @@ -408,9 +409,9 @@ IMPL_LINK( SwDBTreeList, DBCompare, SvSortData*, pData ) return DefaultCompare(pData); // otherwise call base class } -String SwDBTreeList::GetDBName(String& rTableName, String& rColumnName, sal_Bool* pbIsTable) +OUString SwDBTreeList::GetDBName(OUString& rTableName, OUString& rColumnName, sal_Bool* pbIsTable) { - String sDBName; + OUString sDBName; SvTreeListEntry* pEntry = FirstSelected(); if (pEntry && GetParent(pEntry)) @@ -477,13 +478,14 @@ void SwDBTreeList::Select(const String& rDBName, const String& rTableName, const void SwDBTreeList::StartDrag( sal_Int8 /*nAction*/, const Point& /*rPosPixel*/ ) { - String sTableName, sColumnName; - String sDBName( GetDBName( sTableName, sColumnName )); - if( sDBName.Len() ) + OUString sTableName; + OUString sColumnName; + OUString sDBName( GetDBName( sTableName, sColumnName )); + if (!sDBName.isEmpty()) { TransferDataContainer* pContainer = new TransferDataContainer; ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > xRef( pContainer ); - if( sColumnName.Len() ) + if( !sColumnName.isEmpty() ) { // drag database field svx::OColumnTransferable aColTransfer( @@ -496,12 +498,10 @@ void SwDBTreeList::StartDrag( sal_Int8 /*nAction*/, const Point& /*rPosPixel*/ ) aColTransfer.addDataToContainer( pContainer ); } - sDBName += '.'; - sDBName += sTableName; - if( sColumnName.Len() ) + sDBName += "." + sTableName; + if (!sColumnName.isEmpty()) { - sDBName += '.'; - sDBName += sColumnName; + sDBName += "." + sColumnName; } pContainer->CopyString( FORMAT_STRING, sDBName ); diff --git a/sw/source/ui/fldui/changedb.cxx b/sw/source/ui/fldui/changedb.cxx index bed40d1..aba46b3 100644 --- a/sw/source/ui/fldui/changedb.cxx +++ b/sw/source/ui/fldui/changedb.cxx @@ -205,20 +205,22 @@ void SwChangeDBDlg::UpdateFlds() } pSh->StartAllAction(); - String sTableName, sColumnName; + OUString sTableName; + OUString sColumnName; sal_Bool bIsTable = sal_False; - String sTemp(m_pAvailDBTLB->GetDBName(sTableName, sColumnName, &bIsTable)); - sTemp += DB_DELIM; - sTemp += sTableName; - sTemp += DB_DELIM; - sTemp += bIsTable ? '0' : '1'; + const OUString sTemp = m_pAvailDBTLB->GetDBName(sTableName, sColumnName, &bIsTable) + + OUString(DB_DELIM) + + sTableName + + OUString(DB_DELIM) + + OUString(static_cast<sal_Unicode>(bIsTable ? '0' : '1')); pSh->ChangeDBFields( aDBNames, sTemp); pSh->EndAllAction(); } IMPL_LINK_NOARG(SwChangeDBDlg, ButtonHdl) { - String sTableName, sColumnName; + OUString sTableName; + OUString sColumnName; SwDBData aData; sal_Bool bIsTable = sal_False; aData.sDataSource = m_pAvailDBTLB->GetDBName(sTableName, sColumnName, &bIsTable); diff --git a/sw/source/ui/fldui/flddb.cxx b/sw/source/ui/fldui/flddb.cxx index efd8ab2..96973b2 100644 --- a/sw/source/ui/fldui/flddb.cxx +++ b/sw/source/ui/fldui/flddb.cxx @@ -129,7 +129,7 @@ void SwFldDBPage::Reset(const SfxItemSet&) if (nOldPos != LISTBOX_ENTRY_NOTFOUND) m_pTypeLB->SelectEntryPos(nOldPos); - if (sOldDBName.Len()) + if (!sOldDBName.isEmpty()) { m_pDatabaseTLB->Select(sOldDBName, sOldTableName, sOldColumnName); } @@ -182,7 +182,8 @@ void SwFldDBPage::Reset(const SfxItemSet&) sal_Bool SwFldDBPage::FillItemSet(SfxItemSet& ) { - String sTableName, sColumnName; + OUString sTableName; + OUString sColumnName; SwDBData aData; sal_Bool bIsTable; aData.sDataSource = m_pDatabaseTLB->GetDBName(sTableName, sColumnName, &bIsTable); @@ -198,23 +199,20 @@ sal_Bool SwFldDBPage::FillItemSet(SfxItemSet& ) if(!aData.sDataSource.isEmpty()) // without database no new field command { sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)m_pTypeLB->GetEntryData(GetTypeSel()); - String aVal(m_pValueED->GetText()); - String aName(m_pConditionED->GetText()); sal_uLong nFormat = 0; sal_uInt16 nSubType = 0; - String sDBName = aData.sDataSource; - sDBName += DB_DELIM; - sDBName += (String)aData.sCommand; - sDBName += DB_DELIM; - sDBName += OUString::number(aData.nCommandType); - sDBName += DB_DELIM; - if(sColumnName.Len()) + OUString sDBName = aData.sDataSource + + OUString(DB_DELIM) + + aData.sCommand + + OUString(DB_DELIM) + + OUString::number(aData.nCommandType) + + OUString(DB_DELIM); + if (!sColumnName.isEmpty()) { - sDBName += sColumnName; - sDBName += DB_DELIM; + sDBName += sColumnName + OUString(DB_DELIM); } - aName.Insert(sDBName, 0); + OUString aName = sDBName + m_pConditionED->GetText(); switch (nTypeId) { @@ -231,9 +229,10 @@ sal_Bool SwFldDBPage::FillItemSet(SfxItemSet& ) break; } - - String sTempDBName, sTempTableName, sTempColumnName; - sTempDBName = m_pDatabaseTLB->GetDBName(sTempTableName, sTempColumnName); + const OUString aVal(m_pValueED->GetText()); + OUString sTempTableName; + OUString sTempColumnName; + OUString sTempDBName = m_pDatabaseTLB->GetDBName(sTempTableName, sTempColumnName); sal_Bool bDBListBoxChanged = sOldDBName != sTempDBName || sOldTableName != sTempTableName || sOldColumnName != sTempColumnName; if (!IsFldEdit() || @@ -440,10 +439,10 @@ IMPL_LINK( SwFldDBPage, TreeSelectHdl, SvTreeListBox *, pBox ) if (pEntry != 0) { - String sTableName; - String sColumnName; + OUString sTableName; + OUString sColumnName; sal_Bool bIsTable; - String sDBName = m_pDatabaseTLB->GetDBName(sTableName, sColumnName, &bIsTable); + OUString sDBName = m_pDatabaseTLB->GetDBName(sTableName, sColumnName, &bIsTable); bNumFormat = GetFldMgr().IsDBNumeric(sDBName, sTableName, bIsTable, diff --git a/sw/source/ui/fldui/flddb.hxx b/sw/source/ui/fldui/flddb.hxx index 26b4f68..eb6fdac 100644 --- a/sw/source/ui/fldui/flddb.hxx +++ b/sw/source/ui/fldui/flddb.hxx @@ -47,9 +47,9 @@ class SwFldDBPage : public SwFldPage ListBox* m_pFormatLB; VclContainer* m_pFormat; - String sOldDBName; - String sOldTableName; - String sOldColumnName; + OUString sOldDBName; + OUString sOldTableName; + OUString sOldColumnName; sal_uLong nOldFormat; sal_uInt16 nOldSubType; Link aOldNumSelectHdl; diff --git a/sw/source/ui/inc/dbtree.hxx b/sw/source/ui/inc/dbtree.hxx index ad744e4..0409156 100644 --- a/sw/source/ui/inc/dbtree.hxx +++ b/sw/source/ui/inc/dbtree.hxx @@ -56,7 +56,7 @@ public: virtual ~SwDBTreeList(); virtual Size GetOptimalSize() const; - String GetDBName( String& rTableName, String& rColumnName, sal_Bool* pbIsTable = 0); + OUString GetDBName( OUString& rTableName, OUString& rColumnName, sal_Bool* pbIsTable = 0); void Select( const String& rDBName, const String& rTableName, const String& rColumnName ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits