[Libreoffice-commits] core.git: editeng/source svl/source

Laurent Balland-Poirier laurent.balland-poirier at laposte.net
Mon Sep 23 13:35:06 PDT 2013


 editeng/source/misc/svxacorr.cxx |   17 ++++++++---------
 svl/source/numbers/zforfind.cxx  |    4 +++-
 2 files changed, 11 insertions(+), 10 deletions(-)

New commits:
commit 2f4d7eacabd62db35777682bcca353e142e024bf
Author: Laurent Balland-Poirier <laurent.balland-poirier at laposte.net>
Date:   Sun Sep 22 00:19:12 2013 +0200

    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
    
    Change-Id: I30c2c36778cb53a0238a0829043dad4d709f97d2
    Reviewed-on: https://gerrit.libreoffice.org/6015
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>

diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index 1c65aea..3176db9 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -61,8 +61,6 @@
 #include <xmloff/xmltoken.hxx>
 #include <vcl/help.hxx>
 
-#define CHAR_HARDBLANK      ((sal_Unicode)0x00A0)
-
 using namespace ::com::sun::star::ucb;
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star;
@@ -75,6 +73,7 @@ static const int C_FULL_STOP        = 0x01;
 static const int C_EXCLAMATION_MARK = 0x02;
 static const int C_QUESTION_MARK    = 0x04;
 static const int C_ASTERISK         = 0x2A;
+static const sal_Unicode cNonBreakingSpace = 0xA0;
 
 static const sal_Char pImplAutocorr_ListStr[]      = "DocumentList";
 static const sal_Char pXMLImplWrdStt_ExcptLstStr[] = "WordExceptList.xml";
@@ -99,7 +98,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 )
@@ -662,7 +661,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--;
@@ -675,7 +674,7 @@ sal_Bool SvxAutoCorrect::FnAddNonBrkSpace(
 
                     // Add the non-breaking space at the end pos
                     if ( bHasSpace )
-                        rDoc.Insert( nPos, OUString(CHAR_HARDBLANK) );
+                        rDoc.Insert( nPos, OUString(cNonBreakingSpace) );
                     bRunNext = true;
                     bRet = true;
                 }
@@ -688,7 +687,7 @@ sal_Bool SvxAutoCorrect::FnAddNonBrkSpace(
             // Remove the hardspace right before to avoid formatting URLs
             sal_Unicode cPrevChar = rTxt[ nEndPos - 1 ];
             sal_Unicode cMaybeSpaceChar = rTxt[ nEndPos - 2 ];
-            if ( cPrevChar == ':' && cMaybeSpaceChar == CHAR_HARDBLANK )
+            if ( cPrevChar == ':' && cMaybeSpaceChar == cNonBreakingSpace )
             {
                 rDoc.Delete( nEndPos - 2, nEndPos - 1 );
                 bRet = true;
@@ -1184,7 +1183,7 @@ void SvxAutoCorrect::InsertQuote( SvxAutoCorrDoc& rDoc, xub_StrLen nInsPos,
         case LANGUAGE_FRENCH_SWISS:
         case LANGUAGE_FRENCH_LUXEMBOURG:
             {
-                OUString s( static_cast< sal_Unicode >(0xA0) );
+                OUString s( cNonBreakingSpace );
                     // UNICODE code for no break space
                 if( rDoc.Insert( bSttQuote ? nInsPos+1 : nInsPos, s ))
                 {
@@ -1284,7 +1283,7 @@ SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt,
                 {
                     // Remove the NBSP if it wasn't an autocorrection
                     if ( nInsPos != 0 && NeedsHardspaceAutocorr( rTxt[ nInsPos - 1 ] ) &&
-                            cChar != ' ' && cChar != '\t' && cChar != CHAR_HARDBLANK )
+                            cChar != ' ' && cChar != '\t' && cChar != cNonBreakingSpace )
                     {
                         // Look for the last HARD_SPACE
                         sal_Int32 nPos = nInsPos - 1;
@@ -1292,7 +1291,7 @@ SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt,
                         while ( bContinue )
                         {
                             const sal_Unicode cTmpChar = rTxt[ 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 381a260..3004211 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -65,6 +65,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;
+
 ImpSvNumberInputScan::ImpSvNumberInputScan( SvNumberFormatter* pFormatterP )
         :
         pUpperMonthText( NULL ),
@@ -459,7 +461,7 @@ inline void ImpSvNumberInputScan::SkipBlanks( const OUString& rString,
     if ( nPos < rString.getLength() )
     {
         const sal_Unicode* p = rString.getStr() + nPos;
-        while ( *p == ' ' )
+        while ( *p == ' ' || *p == cNonBreakingSpace )
         {
             nPos++;
             p++;


More information about the Libreoffice-commits mailing list