From a96abfcabba97e69d3ad91511bd0e9e38350d6f3 Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Wed, 16 Aug 2017 21:05:12 -0400 Subject: [PATCH] tdf#109308 docx export: support export of Drop Caps LO handles Drop Caps much better than MSO. MSO needs a lot of extra size settings specified instead of calculating the appropriate value. I don't understand marks/mergeTopMarks at all, so this is a mess. I also get really frustrated trying to do something simple like figure out the current font size - which is only needed to sync the MSO-required properties with the proper size. Change-Id: Ibd260aed2eef00ed196df63cb79df737dca7632a --- sw/source/filter/ww8/docxattributeoutput.cxx | 40 +++++++++++++++++++++++++++- sw/source/filter/ww8/docxattributeoutput.hxx | 2 ++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index e09bdaa..87cdfa3 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -904,6 +904,14 @@ void DocxAttributeOutput::WriteCollectedParagraphProperties() m_pSerializer->singleElementNS( XML_w, XML_spacing, xAttrList ); } + if ( m_pDropCapSpacingAttrList.is() ) + { + XFastAttributeListRef xAttrList( m_pDropCapSpacingAttrList.get() ); + m_pDropCapSpacingAttrList.clear(); + + m_pSerializer->singleElementNS( XML_w, XML_spacing, xAttrList ); + } + if ( m_pBackgroundAttrList.is() ) { XFastAttributeListRef xAttrList( m_pBackgroundAttrList.get() ); @@ -1981,6 +1989,13 @@ void DocxAttributeOutput::WriteCollectedRunProperties() m_pSerializer->singleElementNS( XML_w, XML_rFonts, xAttrList ); } + if ( m_pDropCapSizeAttrList.is() ) + { + XFastAttributeListRef xAttrList( m_pDropCapSizeAttrList.get() ); + m_pDropCapSizeAttrList.clear(); + m_pSerializer->singleElementNS( XML_w, XML_sz, xAttrList ); + } + if ( m_pColorAttrList.is() ) { XFastAttributeListRef xAttrList( m_pColorAttrList.get() ); @@ -2589,9 +2604,32 @@ void DocxAttributeOutput::EndRedline( const SwRedlineData * pRedlineData ) } } -void DocxAttributeOutput::FormatDrop( const SwTextNode& /*rNode*/, const SwFormatDrop& /*rSwFormatDrop*/, sal_uInt16 /*nStyle*/, ww8::WW8TableNodeInfo::Pointer_t /*pTextNodeInfo*/, ww8::WW8TableNodeInfoInner::Pointer_t ) +void DocxAttributeOutput::FormatDrop( const SwTextNode& rNode, const SwFormatDrop& rSwFormatDrop, sal_uInt16 /*nStyle*/, ww8::WW8TableNodeInfo::Pointer_t /*pTextNodeInfo*/, ww8::WW8TableNodeInfoInner::Pointer_t ) { SAL_INFO("sw.ww8", "TODO DocxAttributeOutput::FormatDrop( const SwTextNode& rNode, const SwFormatDrop& rSwFormatDrop, sal_uInt16 nStyle )" ); + +SAL_WARN("DEBUG","::FormatDrop Drop.Lines["<<(int)rSwFormatDrop.GetLines()<<"] Count["<<(int)rSwFormatDrop.GetChars()<<"] Distance["<(m_rExport.GetItem(RES_CHRATR_FONTSIZE)); + // 240 is roughly the height of a normal font. MSO needs this to set the frame height approxmiately correct on import. How do you get the current height? + AddToAttrList( m_pDropCapSpacingAttrList, FSNS( XML_w, XML_line ), OString::number( rSwFormatDrop.GetLines() * rItem.GetHeight() ).getStr() ); + AddToAttrList( m_pDropCapSpacingAttrList, FSNS( XML_w, XML_lineRule ), "exact" ); + + // 28 is roughly the pt size of a normal font. MSO needs this to set the text size approxmately correct on import. How do you get the current size? + AddToAttrList( m_pDropCapSizeAttrList, FSNS( XML_w, XML_val ), OString::number( rSwFormatDrop.GetLines() * 28 ).getStr() ); + +SAL_WARN("DEBUG","::FormatDop finished, ParaOpened?["<endElementNS( XML_w, XML_r ); + m_pSerializer->endElementNS( XML_w, XML_p ); + m_pSerializer->startElementNS( XML_w, XML_p, FSEND ); + m_pSerializer->startElementNS( XML_w, XML_r, FSEND ); } void DocxAttributeOutput::ParagraphStyle( sal_uInt16 nStyle ) diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 49efe1d..47044eb 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -724,8 +724,10 @@ private: rtl::Reference m_pFontsAttrList; rtl::Reference m_pEastAsianLayoutAttrList; rtl::Reference m_pCharLangAttrList; + rtl::Reference m_pDropCapSizeAttrList; rtl::Reference m_pSectionSpacingAttrList; rtl::Reference m_pParagraphSpacingAttrList; + rtl::Reference m_pDropCapSpacingAttrList; rtl::Reference m_pHyperlinkAttrList; /// If the current SDT around runs should be ended before the current run. bool m_bEndCharSdt; -- 2.7.4