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 e549f52f16c4a519ed3eddb9c66c19bacc247590 Author: Michael Stahl <mst...@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. 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 7add8abf8e88dcae0591e21f525f3f2fa4baee56 Author: Michael Stahl <mst...@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. diff --git a/sw/source/filter/xml/xmlithlp.cxx b/sw/source/filter/xml/xmlithlp.cxx index cd383b5..8de48ab 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 e2ffb71305c5f085eec6d396651c76d6daee3406 Author: Michael Stahl <mst...@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. diff --git a/sw/source/filter/xml/xmlithlp.cxx b/sw/source/filter/xml/xmlithlp.cxx index 18a1b6b..cd383b5 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 ); } _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits