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 /writerfilter | |
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 'writerfilter')
-rw-r--r-- | writerfilter/Library_writerfilter.mk | 1 | ||||
-rw-r--r-- | writerfilter/source/dmapper/BorderHandler.cxx | 4 | ||||
-rw-r--r-- | writerfilter/source/dmapper/ConversionHelper.cxx | 8 | ||||
-rw-r--r-- | writerfilter/source/dmapper/MeasureHandler.cxx | 2 | ||||
-rw-r--r-- | writerfilter/source/dmapper/TDefTableHandler.cxx | 2 |
5 files changed, 11 insertions, 6 deletions
diff --git a/writerfilter/Library_writerfilter.mk b/writerfilter/Library_writerfilter.mk index a405090f9ca3..f768dce6a7ef 100644 --- a/writerfilter/Library_writerfilter.mk +++ b/writerfilter/Library_writerfilter.mk @@ -68,6 +68,7 @@ $(eval $(call gb_Library_use_libraries,writerfilter,\ comphelper \ cppu \ cppuhelper \ + editeng \ i18nisolang1 \ i18nutil \ msfilter \ diff --git a/writerfilter/source/dmapper/BorderHandler.cxx b/writerfilter/source/dmapper/BorderHandler.cxx index 2d0801708fa2..068c21091d7c 100644 --- a/writerfilter/source/dmapper/BorderHandler.cxx +++ b/writerfilter/source/dmapper/BorderHandler.cxx @@ -35,7 +35,7 @@ using namespace ::com::sun::star; BorderHandler::BorderHandler( bool bOOXML ) : LoggedProperties(dmapper_logger, "BorderHandler"), m_nCurrentBorderPosition( BORDER_TOP ), -m_nLineWidth(26), // Word default +m_nLineWidth(15), // Word default, in twips m_nLineType(0), m_nLineColor(0), m_nLineDistance(0), @@ -70,7 +70,7 @@ void BorderHandler::lcl_attribute(Id rName, Value & rVal) break; case NS_rtf::LN_DPTLINEWIDTH: // 0x2871 // width of a single line in 1/8 pt, max of 32 pt -> twip * 5 / 2. - m_nLineWidth = ConversionHelper::convertTwipToMM100( nIntValue * 5 / 2 ); + m_nLineWidth = nIntValue * 5 / 2; break; case NS_rtf::LN_BRCTYPE: // 0x2872 m_nLineType = nIntValue; diff --git a/writerfilter/source/dmapper/ConversionHelper.cxx b/writerfilter/source/dmapper/ConversionHelper.cxx index 8796829b2188..3b896309f313 100644 --- a/writerfilter/source/dmapper/ConversionHelper.cxx +++ b/writerfilter/source/dmapper/ConversionHelper.cxx @@ -22,6 +22,7 @@ #include <com/sun/star/lang/Locale.hpp> #include <com/sun/star/text/HoriOrientation.hpp> #include <com/sun/star/style/NumberingType.hpp> +#include <editeng/borderline.hxx> #include <ooxml/resourceids.hxx> #include <rtl/ustrbuf.hxx> #include <tools/color.hxx> @@ -110,8 +111,7 @@ sal_Int32 MakeBorderLine( sal_Int32 nSprmValue, table::BorderLine2& rToFill ) sal_Int32 nLineType = ((nSprmValue & 0xff00) >> 8); sal_Int32 nLineColor = (nSprmValue & 0xff0000)>>16; sal_Int32 nLineDistance = (((nSprmValue & 0x3f000000)>>24) * 2540 + 36)/72L; - sal_Int32 nLineThickness = TWIP_TO_MM100(nLineThicknessTwip); - MakeBorderLine( nLineThickness, nLineType, nLineColor, rToFill, false); + MakeBorderLine( nLineThicknessTwip, nLineType, nLineColor, rToFill, false); return nLineDistance; } void MakeBorderLine( sal_Int32 nLineThickness, sal_Int32 nLineType, @@ -202,7 +202,9 @@ void MakeBorderLine( sal_Int32 nLineThickness, sal_Int32 nLineType, } rToFill.LineStyle = nLineStyle; - rToFill.LineWidth = sal_uInt32( nLineThickness ); + double const fConverted( (NONE == nLineStyle) ? 0.0 : + ::editeng::ConvertBorderWidthFromWord(nLineStyle, nLineThickness)); + rToFill.LineWidth = convertTwipToMM100(fConverted); rToFill.Color = nLineColor; } diff --git a/writerfilter/source/dmapper/MeasureHandler.cxx b/writerfilter/source/dmapper/MeasureHandler.cxx index 417114350c7d..9eefa2356b80 100644 --- a/writerfilter/source/dmapper/MeasureHandler.cxx +++ b/writerfilter/source/dmapper/MeasureHandler.cxx @@ -95,7 +95,9 @@ sal_Int32 MeasureHandler::getMeasureValue() const { // TODO m_nUnit 3 - twip, other values unknown :-( if( m_nUnit == 3 || sal::static_int_cast<Id>(m_nUnit) == NS_ooxml::LN_Value_ST_TblWidth_dxa) + { nRet = ConversionHelper::convertTwipToMM100( m_nMeasureValue ); + } //todo: handle additional width types: //NS_ooxml::LN_Value_ST_TblWidth_nil, NS_ooxml::LN_Value_ST_TblWidth_pct, //NS_ooxml::LN_Value_ST_TblWidth_dxa, NS_ooxml::LN_Value_ST_TblWidth_auto; diff --git a/writerfilter/source/dmapper/TDefTableHandler.cxx b/writerfilter/source/dmapper/TDefTableHandler.cxx index 822577986b2c..dcd000db9b62 100644 --- a/writerfilter/source/dmapper/TDefTableHandler.cxx +++ b/writerfilter/source/dmapper/TDefTableHandler.cxx @@ -101,7 +101,7 @@ void TDefTableHandler::lcl_attribute(Id rName, Value & rVal) //from LN_BRCXXXX - handled within the BorderHandler case NS_rtf::LN_DPTLINEWIDTH: // 0x2871 // width of a single line in 1/8 pt, max of 32 pt -> twip * 5 / 2. - m_nLineWidth = ConversionHelper::convertTwipToMM100( nIntValue * 5 / 2 ); + m_nLineWidth = nIntValue * 5 / 2; break; case NS_rtf::LN_BRCTYPE: // 0x2872 m_nLineType = nIntValue; |