[Libreoffice-commits] .: Branch 'libreoffice-3-5' - 3 commits - editeng/qa editeng/source sw/source

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Fri Jan 27 00:41:23 PST 2012


 editeng/qa/items/borderline_test.cxx |    2 +-
 editeng/source/items/borderline.cxx  |   21 ++++++++++++++++++---
 sw/source/filter/xml/xmlithlp.cxx    |   35 ++++++++++++++++++++++-------------
 3 files changed, 41 insertions(+), 17 deletions(-)

New commits:
commit f05b865607a832cdc1b9b4bfdfd07bcfdc7431cc
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Jan 25 22:43:39 2012 +0100

    fdo#38542: SvxBorderLine::GuessLinesWidths:
    
    Importing style:border-line-width="0.002cm 0.088cm 0.141cm" (which older
    OOo/LO apparently could write) fails, because GuessLinesWidths can't find
    a matching style (result: standard "double" border, 3 equal width parts).
    Try to create a custom BorderWidthImpl of type DOUBLE instead, that
    preserves the individual widths.
    
    Signed-off-by: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>

diff --git a/editeng/qa/items/borderline_test.cxx b/editeng/qa/items/borderline_test.cxx
index 80a840c..4b32ec6 100644
--- a/editeng/qa/items/borderline_test.cxx
+++ b/editeng/qa/items/borderline_test.cxx
@@ -106,7 +106,7 @@ void BorderLineTest::testGuessWidthNoMatch()
     line.GuessLinesWidths( DOUBLE,
             TEST_WIDTH + 1, TEST_WIDTH + 2, TEST_WIDTH + 3 );
     CPPUNIT_ASSERT_EQUAL( DOUBLE, line.GetStyle() );
-    CPPUNIT_ASSERT_EQUAL( long( 0 ), line.GetWidth() );
+    CPPUNIT_ASSERT_EQUAL( long( (3 * TEST_WIDTH) + 6 ), line.GetWidth() );
 }
 
 void BorderLineTest::testGuessWidthThinthickSmallgap()
diff --git a/editeng/source/items/borderline.cxx b/editeng/source/items/borderline.cxx
index e729343..61cecce 100644
--- a/editeng/source/items/borderline.cxx
+++ b/editeng/source/items/borderline.cxx
@@ -277,10 +277,25 @@ void SvxBorderLine::GuessLinesWidths( SvxBorderStyle nStyle, sal_uInt16 nOut, sa
 
         // If anything matched, then set it
         if ( nWidth > 0 )
+        {
             nStyle = nTestStyle;
-
-        SetStyle( nStyle );
-        m_nWidth = nWidth;
+            SetStyle( nStyle );
+            m_nWidth = nWidth;
+        }
+        else
+        {
+            // fdo#38542: not a known double, default to something custom...
+            SetStyle( nStyle );
+            m_nWidth = nOut + nIn + nDist;
+            if (nOut + nIn + nDist)
+            {
+                m_aWidthImpl = BorderWidthImpl(
+                    CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST,
+                    static_cast<double>(nOut ) / static_cast<double>(m_nWidth),
+                    static_cast<double>(nIn  ) / static_cast<double>(m_nWidth),
+                    static_cast<double>(nDist) / static_cast<double>(m_nWidth));
+            }
+        }
     }
     else
     {
commit 858d8a4a2312139545e910cc0854c45f5d65a296
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Jan 25 17:56:08 2012 +0100

    fdo#38542: sw: ODF import: prevent border width overriding:
    
    If there is a width in fo:border{,-left,-right,-top,-bottom}, then
    it should not override the values from
    style:border-line-width{,-left,-right,-top,-bottom}, which are more
    specific in case of "double" borders.
    
    Signed-off-by: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>

diff --git a/sw/source/filter/xml/xmlithlp.cxx b/sw/source/filter/xml/xmlithlp.cxx
index f1bfca6..c6c762c 100644
--- a/sw/source/filter/xml/xmlithlp.cxx
+++ b/sw/source/filter/xml/xmlithlp.cxx
@@ -198,23 +198,28 @@ sal_Bool lcl_frmitems_setXMLBorder( SvxBorderLine*& rpLine,
        sal_Bool bDouble = (bHasWidth && API_LINE_DOUBLE == nStyle ) ||
            rpLine->GetDistance();
 
-       // The width has to be changed
-       if( bHasWidth && USHRT_MAX != nNamedWidth )
+       // fdo#38542: for double borders, do not override the width
+       // set via style:border-line-width{,-left,-right,-top,-bottom}
+       if (!bDouble || !rpLine->GetWidth())
        {
-           if ( bDouble )
-               rpLine->SetStyle( ::editeng::DOUBLE );
-           rpLine->SetWidth( aBorderWidths[nNamedWidth] );
-       }
-       else
-       {
-           if( !bHasWidth )
-               nWidth = rpLine->GetInWidth() + rpLine->GetDistance() +
-                   rpLine->GetOutWidth();
-
-           rpLine->SetWidth( nWidth );
-           if (bDouble)
-           {   // fdo#38542: divide width by 3 for outer line, gap, inner line
-               rpLine->ScaleMetrics(1, 3);
+           // The width has to be changed
+           if (bHasWidth && USHRT_MAX != nNamedWidth)
+           {
+               if (bDouble)
+                   rpLine->SetStyle( ::editeng::DOUBLE );
+               rpLine->SetWidth( aBorderWidths[nNamedWidth] );
+           }
+           else
+           {
+               if (!bHasWidth)
+                   nWidth = rpLine->GetInWidth() + rpLine->GetDistance() +
+                       rpLine->GetOutWidth();
+
+               rpLine->SetWidth( nWidth );
+               if (bDouble)
+               { // fdo#38542: divide width by 3 for outer line, gap, inner line
+                   rpLine->ScaleMetrics(1, 3);
+               }
            }
        }
        lcl_frmitems_setXMLBorderStyle( *rpLine, nStyle );
commit 7cda0a56bf3f9d09740871d85f0557cf0b4a7a76
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Jan 25 17:44:36 2012 +0100

    fdo#38542: sw: ODF import: divide width by 3 for "double" borders
    
    The problem is that the width from the fo:border{,-left,-right,-top,-bottom}
    attributes is effectively tripled for "double" borders.
    
    Signed-off-by: Cédric Bosdonnat <cedric.bosdonnat.ooo at free.fr>

diff --git a/sw/source/filter/xml/xmlithlp.cxx b/sw/source/filter/xml/xmlithlp.cxx
index 4db411c..f1bfca6 100644
--- a/sw/source/filter/xml/xmlithlp.cxx
+++ b/sw/source/filter/xml/xmlithlp.cxx
@@ -212,6 +212,10 @@ sal_Bool lcl_frmitems_setXMLBorder( SvxBorderLine*& rpLine,
                    rpLine->GetOutWidth();
 
            rpLine->SetWidth( nWidth );
+           if (bDouble)
+           {   // fdo#38542: divide width by 3 for outer line, gap, inner line
+               rpLine->ScaleMetrics(1, 3);
+           }
        }
        lcl_frmitems_setXMLBorderStyle( *rpLine, nStyle );
    }


More information about the Libreoffice-commits mailing list