diff options
author | Laurent Balland-Poirier <laurent.balland-poirier@laposte.net> | 2013-09-22 00:19:12 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-09-23 22:54:25 +0200 |
commit | d6f90b9ec323b1871ff5a23e30bd090b124cf006 (patch) | |
tree | 741d88f03b725296e98bc594cc27bfbdcb2cfac2 | |
parent | 9471b1704f64a0c08f76ad8d88eff58be7ed414a (diff) |
fdo#54686 Treat hard blank as soft blank in number
AutoCorrect option "Add non-breaking space in French..." insert
non-breaking space (hard blank) and avoid recognition of percent
number and time number. This patch treats hard blanks as soft blank
in number format recognition
Rev.#1: change #define to const variable. Same change in svxaccor
Rev.#2: improvements
Reviewed-on: https://gerrit.libreoffice.org/6015
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
(cherry picked from commit 2f4d7eacabd62db35777682bcca353e142e024bf)
Conflicts:
editeng/source/misc/svxacorr.cxx
svl/source/numbers/zforfind.cxx
(cherry picked from commit 1ca4b1bae11704a1119a9c680c6ae5b85ea1b31e)
Signed-off-by: Eike Rathke <erack@redhat.com>
Conflicts:
editeng/source/misc/svxacorr.cxx
Change-Id: I30c2c36778cb53a0238a0829043dad4d709f97d2
-rw-r--r-- | editeng/source/misc/svxacorr.cxx | 17 | ||||
-rw-r--r-- | svl/source/numbers/zforfind.cxx | 4 |
2 files changed, 11 insertions, 10 deletions
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index 046c4b392772..9887540bdfd7 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -63,8 +63,6 @@ #include <vcl/help.hxx> #include <rtl/logfile.hxx> -#define CHAR_HARDBLANK ((sal_Unicode)0x00A0) - using namespace ::com::sun::star::ucb; using namespace ::com::sun::star::uno; using namespace ::com::sun::star; @@ -76,6 +74,7 @@ static const int C_NONE = 0x00; static const int C_FULL_STOP = 0x01; static const int C_EXCLAMATION_MARK = 0x02; static const int C_QUESTION_MARK = 0x04; +static const sal_Unicode cNonBreakingSpace = 0xA0; static const sal_Char pImplWrdStt_ExcptLstStr[] = "WordExceptList"; static const sal_Char pImplCplStt_ExcptLstStr[] = "SentenceExceptList"; @@ -102,7 +101,7 @@ typedef SvxAutoCorrectLanguageLists* SvxAutoCorrectLanguageListsPtr; static inline int IsWordDelim( const sal_Unicode c ) { return ' ' == c || '\t' == c || 0x0a == c || - 0xA0 == c || 0x2011 == c || 0x1 == c; + cNonBreakingSpace == c || 0x2011 == c || 0x1 == c; } static inline int IsLowerLetter( sal_Int32 nCharType ) @@ -628,7 +627,7 @@ sal_Bool SvxAutoCorrect::FnAddNonBrkSpace( { // Remove any previous normal space xub_StrLen nPos = nEndPos - 1; - while ( cPrevChar == ' ' || cPrevChar == CHAR_HARDBLANK ) + while ( cPrevChar == ' ' || cPrevChar == cNonBreakingSpace ) { if ( nPos == 0 ) break; nPos--; @@ -641,7 +640,7 @@ sal_Bool SvxAutoCorrect::FnAddNonBrkSpace( // Add the non-breaking space at the end pos if ( bHasSpace ) - rDoc.Insert( nPos, rtl::OUString(CHAR_HARDBLANK) ); + rDoc.Insert( nPos, rtl::OUString(cNonBreakingSpace) ); bRunNext = true; bRet = true; } @@ -654,7 +653,7 @@ sal_Bool SvxAutoCorrect::FnAddNonBrkSpace( // Remove the hardspace right before to avoid formatting URLs sal_Unicode cPrevChar = rTxt.GetChar( nEndPos - 1 ); sal_Unicode cMaybeSpaceChar = rTxt.GetChar( nEndPos - 2 ); - if ( cPrevChar == ':' && cMaybeSpaceChar == CHAR_HARDBLANK ) + if ( cPrevChar == ':' && cMaybeSpaceChar == cNonBreakingSpace ) { rDoc.Delete( nEndPos - 2, nEndPos - 1 ); bRet = true; @@ -1126,7 +1125,7 @@ void SvxAutoCorrect::InsertQuote( SvxAutoCorrDoc& rDoc, xub_StrLen nInsPos, case LANGUAGE_FRENCH_SWISS: case LANGUAGE_FRENCH_LUXEMBOURG: { - rtl::OUString s( static_cast< sal_Unicode >(0xA0) ); + rtl::OUString s( cNonBreakingSpace ); // UNICODE code for no break space if( rDoc.Insert( bSttQuote ? nInsPos+1 : nInsPos, s )) { @@ -1225,7 +1224,7 @@ sal_uLong SvxAutoCorrect::AutoCorrect( SvxAutoCorrDoc& rDoc, const String& rTxt, { // Remove the NBSP if it wasn't an autocorrection if ( nInsPos != 0 && NeedsHardspaceAutocorr( rTxt.GetChar( nInsPos - 1 ) ) && - cChar != ' ' && cChar != '\t' && cChar != CHAR_HARDBLANK ) + cChar != ' ' && cChar != '\t' && cChar != cNonBreakingSpace ) { // Look for the last HARD_SPACE xub_StrLen nPos = nInsPos - 1; @@ -1233,7 +1232,7 @@ sal_uLong SvxAutoCorrect::AutoCorrect( SvxAutoCorrDoc& rDoc, const String& rTxt, while ( bContinue ) { const sal_Unicode cTmpChar = rTxt.GetChar( nPos ); - if ( cTmpChar == CHAR_HARDBLANK ) + if ( cTmpChar == cNonBreakingSpace ) { rDoc.Delete( nPos, nPos + 1 ); nRet = AddNonBrkSpace; diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx index d5adf88b7555..27baf010b9a1 100644 --- a/svl/source/numbers/zforfind.cxx +++ b/svl/source/numbers/zforfind.cxx @@ -68,6 +68,8 @@ const sal_uInt8 ImpSvNumberInputScan::nMatchedUsedAsReturn = 0x10; * would work, together with the nTimezonePos handling in GetTimeRef(). */ #define NF_RECOGNIZE_ISO8601_TIMEZONES 0 +static const sal_Unicode cNonBreakingSpace = 0xA0; + //--------------------------------------------------------------------------- // Konstruktor @@ -483,7 +485,7 @@ inline void ImpSvNumberInputScan::SkipBlanks( const OUString& rString, if ( nPos < rString.getLength() ) { register const sal_Unicode* p = rString.getStr() + nPos; - while ( *p == ' ' ) + while ( *p == ' ' || *p == cNonBreakingSpace ) { nPos++; p++; |