diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2013-08-21 14:40:34 +0200 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@yahoo.com> | 2013-08-21 19:26:12 +0200 |
commit | fdbb60d2604471fc3aaf7ce4cefbb355952bac0f (patch) | |
tree | 08a06f569a723eedbbcb0893e4442dadf070a758 /sw | |
parent | 8abfe7d06b998ca42a3f22667a7aeadb0826b9b3 (diff) |
SwRewriter: use GetPlaceHolder in Apply
Change-Id: I7b7372e781b445eb2bb7f07d7ccf44ede963ae99
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/undo/SwRewriter.cxx | 34 |
1 files changed, 6 insertions, 28 deletions
diff --git a/sw/source/core/undo/SwRewriter.cxx b/sw/source/core/undo/SwRewriter.cxx index 3d1b584f2f2c..33a05d9c35a9 100644 --- a/sw/source/core/undo/SwRewriter.cxx +++ b/sw/source/core/undo/SwRewriter.cxx @@ -55,35 +55,13 @@ void SwRewriter::AddRule(SwUndoArg eWhat, const OUString & rWith) mRules.push_back(aRule); } -namespace -{ - -const char UNDO_ARG1[] = "$1"; -const char UNDO_ARG2[] = "$2"; -const char UNDO_ARG3[] = "$3"; - -} - OUString SwRewriter::Apply(const OUString & rStr) const { OUString aResult = rStr; - std::vector<SwRewriteRule>::const_iterator aIt; - for (aIt = mRules.begin(); aIt != mRules.end(); ++aIt) + for (std::vector<SwRewriteRule>::const_iterator aIt = mRules.begin(); aIt != mRules.end(); ++aIt) { - switch (aIt->first) - { - case UndoArg1: - default: - aResult = aResult.replaceAll(UNDO_ARG1, aIt->second); - break; - case UndoArg2: - aResult = aResult.replaceAll(UNDO_ARG2, aIt->second); - break; - case UndoArg3: - aResult = aResult.replaceAll(UNDO_ARG3, aIt->second); - break; - } + aResult = aResult.replaceAll(GetPlaceHolder(aIt->first), aIt->second); } return aResult; @@ -94,15 +72,15 @@ OUString SwRewriter::GetPlaceHolder(SwUndoArg eId) switch (eId) { case UndoArg1: - return OUString(UNDO_ARG1); + return OUString("$1"); case UndoArg2: - return OUString(UNDO_ARG2); + return OUString("$2"); case UndoArg3: - return OUString(UNDO_ARG3); + return OUString("$3"); default: break; } - return OUString(UNDO_ARG1); + return OUString("$1"); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |