diff options
author | Michael Stahl <mstahl@redhat.com> | 2012-07-04 17:47:22 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-07-04 17:55:45 +0200 |
commit | 2d045cdb69176b280812dda0b813371cf1ac72e2 (patch) | |
tree | c427cd49c3782d509199d4e4590ff42e7862bf93 /sw | |
parent | 6146c5d1557f4813c9793c1b00567885382c00e7 (diff) |
refactor handling of double border widths:
Word uses a completely different definition of "width" of a double border
than OOo and ODF: for Word the width is apparently the largest of the 3
component widths, while OOo and ODF define the width as the total with of
all 3 components. The new border implementation in LO 3.4 was apparently
inspired by Word's double border definition, which resulted in
various import filter regressions, see the previous fixes:
36e43b52992735c622833e923faa63774b9e2f76
e2ffb71305c5f085eec6d396651c76d6daee3406
70a6a4d425558340bb49507975343a3e0a1bdde8
These fixes set the ScaleMetrics, which actually seems sub-optimal as
there is a ScaleItemSet function somewhere that apparently re-scales
all items in an itemset, which could undo the fixes.
Also, one of the fixes actually managed to break RTF/DOCX import
of double borders, as that ended up in the same code via the API.
This commit now reverses the change, so that the width of a border is
now always the total with of all components, which is (imho) much more
intutitive, and also leads to a consistent UI where selecting say 3pt
width has predictable results, no matter what the border style.
The border widths are now converted in the Word format import/export
filters (writerfilter and sw/source/filter/ww8), and various tests
were adapted to the new handling.
Change-Id: I50456c49b1a298569607e6c88f19f18441348ac3
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmltok/ooxmltok.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfattributeoutput.cxx | 10 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 3 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8graf.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par6.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlithlp.cxx | 4 |
7 files changed, 18 insertions, 15 deletions
diff --git a/sw/qa/extras/ooxmltok/ooxmltok.cxx b/sw/qa/extras/ooxmltok/ooxmltok.cxx index 790194d7b55b..a3fd38a59913 100644 --- a/sw/qa/extras/ooxmltok/ooxmltok.cxx +++ b/sw/qa/extras/ooxmltok/ooxmltok.cxx @@ -581,7 +581,7 @@ void Test::testN758883() uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName("Default"), uno::UNO_QUERY); sal_Int32 nValue = 0; xPropertySet->getPropertyValue("LeftMargin") >>= nValue; - CPPUNIT_ASSERT_EQUAL(sal_Int32(820), nValue); + CPPUNIT_ASSERT_EQUAL(sal_Int32(794), nValue); // No assert for the 3rd problem: see the comment in the test doc. diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index eea8da3fe373..e5b35c5df5ba 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -1410,8 +1410,10 @@ static void impl_borderLine( FSHelperPtr pSerializer, sal_Int32 elementToken, co { // Compute the sz attribute + double const fConverted( ::editeng::ConvertBorderWidthToWord( + pBorderLine->GetBorderLineStyle(), pBorderLine->GetWidth())); // The unit is the 8th of point - sal_Int32 nWidth = sal_Int32( pBorderLine->GetWidth() / 2.5 ); + sal_Int32 nWidth = sal_Int32( fConverted / 2.5 ); sal_uInt16 nMinWidth = 2; sal_uInt16 nMaxWidth = 96; diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index e22f7cfccc4f..59576062f989 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -179,12 +179,18 @@ static OString OutTBLBorderLine(RtfExport &rExport, const SvxBorderLine* pLine, break; } + double const fConverted( ::editeng::ConvertBorderWidthToWord( + pLine->GetBorderLineStyle(), pLine->GetWidth()) ); if ( 255 >= pLine->GetWidth() ) // That value comes from RTF specs { - aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRW).append((sal_Int32)pLine->GetWidth()); + aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRW).append( + static_cast<sal_Int32>(fConverted)); } else - aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRTH OOO_STRING_SVTOOLS_RTF_BRDRW).append((sal_Int32)pLine->GetWidth() / 2); + { // use \brdrth to double the value range... + aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRTH OOO_STRING_SVTOOLS_RTF_BRDRW); + aRet.append(static_cast<sal_Int32>(fConverted) / 2); + } aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRCF); aRet.append((sal_Int32)rExport.GetColor(pLine->GetColor())); diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index acf2dbff2b5d..78ff6bef1c0c 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -4061,7 +4061,8 @@ WW8_BRC WW8Export::TranslateBorderLine(const SvxBorderLine& rLine, // what SwRTFWriter::OutRTFBorder does in the RTF filter Eventually it // would be nice if all this functionality was in the one place WW8_BRC aBrc; - sal_uInt16 nWidth = rLine.GetWidth(); + sal_uInt16 nWidth = ::editeng::ConvertBorderWidthToWord( + rLine.GetBorderLineStyle(), rLine.GetWidth()); sal_uInt8 brcType = 0, nColCode = 0; if( nWidth ) // Linie ? diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index c5c663148d8d..1c350b22490f 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -1570,10 +1570,6 @@ sal_Int32 SwWW8ImplReader::MatchSdrBoxIntoFlyBoxItem(const Color& rLineColor, aLine.SetWidth( nLineThick ); // No conversion here, nLineThick is already in twips aLine.SetBorderLineStyle(nIdx); - if (table::BorderLineStyle::DOUBLE == nIdx) - { // fdo#43249: divide width by 3 for outer line, gap, inner line - aLine.ScaleMetrics(1, 3); - } for(sal_uInt16 nLine = 0; nLine < 4; ++nLine) rBox.SetLine(new SvxBorderLine( aLine ), nLine); diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 7582a2be1d90..c86300a18990 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -1355,7 +1355,9 @@ void GetLineIndex(SvxBoxItem &rBox, short nLineThickness, short nSpace, sal_uInt ::editeng::SvxBorderLine aLine; aLine.SetBorderLineStyle( eStyle ); - aLine.SetWidth( nLineThickness ); + double const fConverted( (table::BorderLineStyle::NONE == eStyle) ? 0.0 : + ::editeng::ConvertBorderWidthFromWord(eStyle, nLineThickness)); + aLine.SetWidth(fConverted); //No AUTO for borders as yet, so if AUTO, use BLACK if (nCol == 0) @@ -1364,7 +1366,7 @@ void GetLineIndex(SvxBoxItem &rBox, short nLineThickness, short nSpace, sal_uInt aLine.SetColor(SwWW8ImplReader::GetCol(nCol)); if (pSize) - pSize[nWWIndex] = nLineThickness+nSpace; + pSize[nWWIndex] = fConverted + nSpace; rBox.SetLine(&aLine, nOOIndex); rBox.SetDistance(nSpace, nOOIndex); diff --git a/sw/source/filter/xml/xmlithlp.cxx b/sw/source/filter/xml/xmlithlp.cxx index 0902899899e6..d29853e2af17 100644 --- a/sw/source/filter/xml/xmlithlp.cxx +++ b/sw/source/filter/xml/xmlithlp.cxx @@ -218,10 +218,6 @@ 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 ); |