From 77df2ac92687496a3ae027451364ff833df47e68 Mon Sep 17 00:00:00 2001 From: Zolnai Tamás Date: Thu, 29 Aug 2013 10:37:44 +0200 Subject: Generalize SwHTMLWriter::ToPixel method Change-Id: Iba4c292a3130f33792ef39b97d774a48c181359a --- sw/source/filter/html/css1atr.cxx | 11 +---------- sw/source/filter/html/htmlatr.cxx | 11 ++++++----- sw/source/filter/html/htmltabw.cxx | 6 +++--- sw/source/filter/html/wrthtml.hxx | 2 +- 4 files changed, 11 insertions(+), 19 deletions(-) (limited to 'sw') diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx index 03fde66e46ba..98ef8d42fa1d 100644 --- a/sw/source/filter/html/css1atr.cxx +++ b/sw/source/filter/html/css1atr.cxx @@ -454,16 +454,7 @@ void SwHTMLWriter::OutCSS1_UnitProperty( const sal_Char *pProp, long nVal ) void SwHTMLWriter::OutCSS1_PixelProperty( const sal_Char *pProp, long nVal, sal_Bool bVert ) { - if( nVal && Application::GetDefaultDevice() ) - { - Size aSz( bVert ? 0 : nVal, bVert ? nVal : 0 ); - aSz = Application::GetDefaultDevice()->LogicToPixel( aSz, MapMode( MAP_TWIP) ); - nVal = bVert ? aSz.Height() : aSz.Width(); - if( !nVal ) - nVal = 1; - } - - OString sOut(OString::number(nVal) + sCSS1_UNIT_px); + OString sOut(OString::number(ToPixel(nVal,bVert)) + sCSS1_UNIT_px); OutCSS1_PropertyAscii(pProp, sOut); } diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx index c107939e8a96..1f141bc4d8b3 100644 --- a/sw/source/filter/html/htmlatr.cxx +++ b/sw/source/filter/html/htmlatr.cxx @@ -2092,7 +2092,7 @@ Writer& OutHTML_SwTxtNode( Writer& rWrt, const SwCntntNode& rNode ) sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_width) .append('='); rWrt.Strm() << sOut.makeStringAndClear().getStr(); - rWrt.OutULong( rHTMLWrt.ToPixel(nPageWidth-nLeft-nRight) ); + rWrt.OutULong( rHTMLWrt.ToPixel(nPageWidth-nLeft-nRight,false) ); sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_align) .append('='); @@ -2115,7 +2115,7 @@ Writer& OutHTML_SwTxtNode( Writer& rWrt, const SwCntntNode& rNode ) sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_size) .append('='); rWrt.Strm() << sOut.makeStringAndClear().getStr(); - rWrt.OutULong( rHTMLWrt.ToPixel(nWidth) ); + rWrt.OutULong( rHTMLWrt.ToPixel(nWidth,false) ); const Color& rBorderColor = pBorderLine->GetColor(); if( !rBorderColor.IsRGBEqual( Color(COL_GRAY) ) ) @@ -2613,12 +2613,13 @@ Writer& OutHTML_SwTxtNode( Writer& rWrt, const SwCntntNode& rNode ) } -sal_uInt32 SwHTMLWriter::ToPixel( sal_uInt32 nVal ) const +sal_uInt32 SwHTMLWriter::ToPixel( sal_uInt32 nVal, const bool bVert ) const { if( Application::GetDefaultDevice() && nVal ) { - nVal = Application::GetDefaultDevice()->LogicToPixel( - Size( nVal, nVal ), MapMode( MAP_TWIP ) ).Width(); + Size aSz( bVert ? 0 : nVal, bVert ? nVal : 0 ); + aSz = Application::GetDefaultDevice()->LogicToPixel(aSz, MapMode( MAP_TWIP )); + nVal = bVert ? aSz.Height() : aSz.Width(); if( !nVal ) // wo ein Twip ist sollte auch ein Pixel sein nVal = 1; } diff --git a/sw/source/filter/html/htmltabw.cxx b/sw/source/filter/html/htmltabw.cxx index bc016c6cf12a..e55e7e66cece 100644 --- a/sw/source/filter/html/htmltabw.cxx +++ b/sw/source/filter/html/htmltabw.cxx @@ -716,11 +716,11 @@ void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, sal_Int16 eAlign, // CELLPADDING ausgeben: Stammt aus Layout oder ist berechnet sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_cellpadding). - append('=').append(static_cast(rWrt.ToPixel(nCellPadding))); + append('=').append(static_cast(rWrt.ToPixel(nCellPadding,false))); // CELLSPACING ausgeben: Stammt aus Layout oder ist berechnet sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_cellspacing). - append('=').append(static_cast(rWrt.ToPixel(nCellSpacing))); + append('=').append(static_cast(rWrt.ToPixel(nCellSpacing,false))); rWrt.Strm() << sOut.makeStringAndClear().getStr(); @@ -792,7 +792,7 @@ void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, sal_Int16 eAlign, if( bRel ) sOutStr.append(static_cast(nWidth)).append('*'); else - sOutStr.append(static_cast(rWrt.ToPixel(nWidth))); + sOutStr.append(static_cast(rWrt.ToPixel(nWidth,false))); sOutStr.append('>'); rWrt.Strm() << sOutStr.makeStringAndClear().getStr(); diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx index a7aa3b7c1bde..66f368de7d41 100644 --- a/sw/source/filter/html/wrthtml.hxx +++ b/sw/source/filter/html/wrthtml.hxx @@ -490,7 +490,7 @@ public: SwPaM* GetEndPaM() { return pOrigPam; } void SetEndPaM( SwPaM* pPam ) { pOrigPam = pPam; } - sal_uInt32 ToPixel( sal_uInt32 nVal ) const; + sal_uInt32 ToPixel( sal_uInt32 nVal, const bool bVert ) const; sal_uInt16 GuessFrmType( const SwFrmFmt& rFrmFmt, const SdrObject*& rpStrObj ); -- cgit v1.2.3