[Libreoffice-commits] .: sw/inc sw/source

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Mon May 2 06:09:10 PDT 2011


 sw/inc/paratr.hxx             |    1 
 sw/source/core/text/guess.cxx |   55 ++++++++++++++++++++++++++----------------
 2 files changed, 36 insertions(+), 20 deletions(-)

New commits:
commit 4ee4892968d3e42efc03c1158bebfcdd7bb3249e
Author: Bartosz Kosiorek <gang65 at o2.pl>
Date:   Mon May 2 14:59:26 2011 +0200

    fdo#33167, i#20878: Show spaces at the end of line
    
    The spaces weren't shown at the end of lines when viewing the document
    with the non-printing characters. This helps editing the spaces after a
    line in left aligned paragraphs.

diff --git a/sw/inc/paratr.hxx b/sw/inc/paratr.hxx
index cfbbf06..87f931d 100644
--- a/sw/inc/paratr.hxx
+++ b/sw/inc/paratr.hxx
@@ -35,6 +35,7 @@
 #include <swatrset.hxx>
 #include <format.hxx>
 #include <swtypes.hxx>
+#include <editeng/adjitem.hxx>
 
 class SwCharFmt;
 class IntlWrapper;
diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx
index a4ef47c..7ebeafc 100644
--- a/sw/source/core/text/guess.cxx
+++ b/sw/source/core/text/guess.cxx
@@ -29,7 +29,6 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_sw.hxx"
 
-
 #include <ctype.h>
 #include <editeng/unolingu.hxx>
 #include <tools/shl.hxx>    // needed for SW_MOD() macro
@@ -45,6 +44,7 @@
 #include <com/sun/star/i18n/WordType.hpp>
 #include <unotools/charclass.hxx>
 #include <porfld.hxx>
+#include <paratr.hxx>
 
 using ::rtl::OUString;
 using namespace ::com::sun::star;
@@ -68,7 +68,7 @@ sal_Bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf,
 {
     nCutPos = rInf.GetIdx();
 
-    // Leere Strings sind immer 0
+    // Empty strings are always 0
     if( !rInf.GetLen() || !rInf.GetTxt().Len() )
         return sal_False;
 
@@ -189,8 +189,8 @@ sal_Bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf,
 
         nBreakWidth = nMinSize;
 
-        // Der folgende Vergleich sollte eigenlich immer sal_True ergeben, sonst
-        // hat es wohl bei GetTxtBreak einen Pixel-Rundungsfehler gegeben...
+        // The following comparison should always give sal_True, otherwise
+        // a pixel rounding error in GetTxtBreak will appear
         if ( nBreakWidth <= nLineWidth )
         {
             if( nItalic && ( nBreakPos + 1 ) >= rInf.GetTxt().Len() )
@@ -221,12 +221,23 @@ sal_Bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf,
         nBreakPos = nCutPos;
         xub_StrLen nX = nBreakPos;
 
-        // we step back until a non blank character has been found
-        // or there is only one more character left
-        while( nX && nBreakPos > rInf.GetLineStart() + 1 &&
-               ( CH_BLANK == ( cCutChar = rInf.GetChar( --nX ) ) ||
-                 CH_FULL_BLANK == cCutChar ) )
-            --nBreakPos;
+        const SvxAdjust& rAdjust = rInf.GetTxtFrm()->GetTxtNode()->GetSwAttrSet().GetAdjust().GetAdjust();
+        if ( rAdjust == SVX_ADJUST_LEFT )
+        {
+            // we step back until a non blank character has been found
+            // or there is only one more character left
+            while( nX && nBreakPos > rInf.GetTxt().Len() &&
+                   ( CH_BLANK == ( cCutChar = rInf.GetChar( --nX ) ) ||
+                     CH_FULL_BLANK == cCutChar ) )
+                --nBreakPos;
+        }
+        else
+        {
+            while( nX && nBreakPos > rInf.GetLineStart() + 1 &&
+                   ( CH_BLANK == ( cCutChar = rInf.GetChar( --nX ) ) ||
+                     CH_FULL_BLANK == cCutChar ) )
+                --nBreakPos;
+        }
 
         if( nBreakPos > rInf.GetIdx() )
             nPorLen = nBreakPos - rInf.GetIdx();
@@ -430,16 +441,20 @@ sal_Bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf,
                 CHAR_SOFTHYPHEN == rInf.GetTxt().GetChar( nBreakPos - 1 ) )
                 nBreakPos = rInf.GetIdx() - 1;
 
-            // Delete any blanks at the end of a line, but be careful:
-            // If a field has been expanded, we do not want to delete any
-            // blanks inside the field portion. This would cause an unwanted
-            // underflow
-            xub_StrLen nX = nBreakPos;
-            while( nX > rInf.GetLineStart() &&
-                   ( CH_TXTATR_BREAKWORD != cFldChr || nX > rInf.GetIdx() ) &&
-                   ( CH_BLANK == rInf.GetChar( --nX ) ||
-                     CH_FULL_BLANK == rInf.GetChar( nX ) ) )
-                nBreakPos = nX;
+            const SvxAdjust& rAdjust = rInf.GetTxtFrm()->GetTxtNode()->GetSwAttrSet().GetAdjust().GetAdjust();
+            if( rAdjust != SVX_ADJUST_LEFT )
+            {
+                // Delete any blanks at the end of a line, but be careful:
+                // If a field has been expanded, we do not want to delete any
+                // blanks inside the field portion. This would cause an unwanted
+                // underflow
+                xub_StrLen nX = nBreakPos;
+                while( nX > rInf.GetLineStart() &&
+                       ( CH_TXTATR_BREAKWORD != cFldChr || nX > rInf.GetIdx() ) &&
+                       ( CH_BLANK == rInf.GetChar( --nX ) ||
+                         CH_FULL_BLANK == rInf.GetChar( nX ) ) )
+                    nBreakPos = nX;
+            }
             if( nBreakPos > rInf.GetIdx() )
                 nPorLen = nBreakPos - rInf.GetIdx();
         }


More information about the Libreoffice-commits mailing list