summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2011-07-01 10:04:37 +0200
committerCédric Bosdonnat <cedric.bosdonnat.ooo@free.fr>2011-07-01 16:59:18 +0200
commit71bf87b04a3b3774c523a397eaf751467d1df386 (patch)
tree62cff0aef252e54f302489b38a25ed6413c1698e /sw
parent68628b81e17d8ab694de29283502db9d748ca0b7 (diff)
Fix the computation of grid character pitch, fdo#37516.
Diffstat (limited to 'sw')
-rw-r--r--sw/source/filter/ww8/attributeoutputbase.hxx3
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx17
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx47
3 files changed, 36 insertions, 31 deletions
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx
index 25fc96566def..84e58f7ad0cf 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -539,6 +539,9 @@ protected:
/// Sfx item RES_KEEP
virtual void FormatKeep( const SvxFmtKeepItem& ) = 0;
+ /// Compute the grid character pitch
+ sal_uInt32 GridCharacterPitch( const SwTextGridItem& rGrid ) const;
+
/// Sfx item RES_TEXTGRID
virtual void FormatTextGrid( const SwTextGridItem& ) = 0;
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 497f8bc4f07b..1e257b16b819 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -4041,23 +4041,8 @@ void DocxAttributeOutput::FormatTextGrid( const SwTextGridItem& rGrid )
pGridAttrList->add( FSNS( XML_w, XML_linePitch ),
OString::valueOf( sal_Int32( nHeight ) ).getStr( ) );
- MSWordStyles * pStyles = m_rExport.pStyles;
- SwFmt * pSwFmt = pStyles->GetSwFmt();
-
- sal_uInt32 nPageCharSize = 0;
-
- if (pSwFmt != NULL)
- {
- nPageCharSize = ItemGet<SvxFontHeightItem>
- (*pSwFmt, RES_CHRATR_FONTSIZE).GetHeight();
- }
-
- sal_uInt16 nPitch = rGrid.IsSquaredMode() ? rGrid.GetBaseHeight() :
- rGrid.GetBaseWidth( );
- sal_Int32 nCharSpace = ( nPitch - nPageCharSize ) * 4096 / 20;
-
pGridAttrList->add( FSNS( XML_w, XML_charSpace ),
- OString::valueOf( sal_Int32( nCharSpace ) ).getStr( ) );
+ OString::valueOf( sal_Int32( GridCharacterPitch( rGrid ) ) ).getStr( ) );
m_pSerializer->singleElementNS( XML_w, XML_docGrid, pGridAttrList );
}
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 63ee393bb83a..6e6164172110 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -3641,6 +3641,37 @@ void WW8AttributeOutput::SectionBreak( sal_uInt8 nC, const WW8_SepInfo* /*pSecti
m_rWW8Export.ReplaceCr( nC );
}
+sal_uInt32 AttributeOutputBase::GridCharacterPitch( const SwTextGridItem& rGrid ) const
+{
+ MSWordStyles * pStyles = GetExport().pStyles;
+ SwFmt * pSwFmt = pStyles->GetSwFmt();
+
+ sal_uInt32 nPageCharSize = 0;
+
+ if (pSwFmt != NULL)
+ {
+ nPageCharSize = ItemGet<SvxFontHeightItem>
+ (*pSwFmt, RES_CHRATR_FONTSIZE).GetHeight();
+ }
+ sal_uInt16 nPitch = rGrid.IsSquaredMode() ? rGrid.GetBaseHeight() :
+ rGrid.GetBaseWidth( );
+
+ sal_Int32 nCharWidth = nPitch - nPageCharSize;
+ sal_Int32 nFraction = nCharWidth % 20;
+ if ( nCharWidth < 0 )
+ nFraction = 20 + nFraction;
+ nFraction = ( nFraction * 0xFFF ) / 20;
+ nFraction = ( nFraction & 0x00000FFF );
+
+ sal_Int32 nMain = nCharWidth / 20;
+ if ( nCharWidth < 0 )
+ nMain -= 1;
+ nMain = nMain * 0x1000;
+ nMain = ( nMain & 0xFFFFF000 );
+
+ return sal_uInt32( nFraction + nMain );
+}
+
void WW8AttributeOutput::FormatTextGrid( const SwTextGridItem& rGrid )
{
if ( m_rWW8Export.bOutPageDescs && m_rWW8Export.bWrtWW8 )
@@ -3670,22 +3701,8 @@ void WW8AttributeOutput::FormatTextGrid( const SwTextGridItem& rGrid )
m_rWW8Export.InsUInt16( NS_sprm::LN_SDyaLinePitch );
m_rWW8Export.InsUInt16( nHeight );
- MSWordStyles * pStyles = m_rWW8Export.pStyles;
- SwFmt * pSwFmt = pStyles->GetSwFmt();
-
- sal_uInt32 nPageCharSize = 0;
-
- if (pSwFmt != NULL)
- {
- nPageCharSize = ItemGet<SvxFontHeightItem>
- (*pSwFmt, RES_CHRATR_FONTSIZE).GetHeight();
- }
- sal_uInt16 nPitch = rGrid.IsSquaredMode() ? rGrid.GetBaseHeight() :
- rGrid.GetBaseWidth( );
- sal_Int32 nCharSpace = ( nPitch - nPageCharSize ) * 4096 / 20;
-
m_rWW8Export.InsUInt16( NS_sprm::LN_SDxtCharSpace );
- m_rWW8Export.InsUInt32( nCharSpace );
+ m_rWW8Export.InsUInt32( GridCharacterPitch( rGrid ) );
}
}