diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2013-04-13 13:34:20 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-04-13 13:40:14 +0200 |
commit | 42e57f463ed46c64560e6b27a75cc1e9ad519743 (patch) | |
tree | b65ae6b83bf106fde3a9a2e7628aeb50d0d0bd02 | |
parent | 41807e779f93cc3dc7cb338a13b19195a77d11af (diff) |
sw: fix frame size of textboxes in DOCX/RTF export
In case the frame is AutoSize and the nominal height is less than the
real height, we used to end up with textboxes having height small enough
that some of the content was unreadable.
Instead, do what the WW8 export does and relay on sw::Frame to provide
the layout size.
Change-Id: I2a6cf4373c8565eef780273745a6ef27ddc65753
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 13 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfattributeoutput.cxx | 23 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfattributeoutput.hxx | 4 |
4 files changed, 26 insertions, 16 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 86058dd68883..c988b39fab7f 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -304,6 +304,11 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT m_rExport.mpParentFrame = pParentFrame; + // When a frame has some low height, but automatically expanded due + // to lots of contents, this size contains the real size. + const Size aSize = pParentFrame->GetSize(); + m_pFlyFrameSize = &aSize; + m_bTextFrameSyntax = true; m_pFlyAttrList = m_pSerializer->createAttrList( ); m_pTextboxAttrList = m_pSerializer->createAttrList(); @@ -315,6 +320,7 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT XFastAttributeListRef xTextboxAttrList(m_pTextboxAttrList); m_pTextboxAttrList = NULL; m_bTextFrameSyntax = false; + m_pFlyFrameSize = 0; m_pSerializer->startElementNS( XML_w, XML_r, FSEND ); m_pSerializer->startElementNS( XML_w, XML_pict, FSEND ); @@ -4282,10 +4288,10 @@ void DocxAttributeOutput::ParaSnapToGrid( const SvxParaGridItem& rGrid ) void DocxAttributeOutput::FormatFrameSize( const SwFmtFrmSize& rSize ) { - if (m_bTextFrameSyntax) + if (m_bTextFrameSyntax && m_pFlyFrameSize) { - m_aTextFrameStyle.append(";width:").append(double(rSize.GetWidth()) / 20); - m_aTextFrameStyle.append("pt;height:").append(double(rSize.GetHeight()) / 20).append("pt"); + m_aTextFrameStyle.append(";width:").append(double(m_pFlyFrameSize->Width()) / 20); + m_aTextFrameStyle.append("pt;height:").append(double(m_pFlyFrameSize->Height()) / 20).append("pt"); } else if ( m_rExport.bOutFlyFrmAttrs ) { @@ -4845,6 +4851,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri m_pFlyAttrList( NULL ), m_pFlyFillAttrList( NULL ), m_pTextboxAttrList( NULL ), + m_pFlyFrameSize(0), m_pFootnotesList( new ::docx::FootnotesList() ), m_pEndnotesList( new ::docx::FootnotesList() ), m_footnoteEndnoteRefTag( 0 ), diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index c044ad899ab9..32d0a848d1ae 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -567,6 +567,8 @@ private: ::sax_fastparser::FastAttributeList *m_pFlyFillAttrList; /// Attributes of the next v:textbox element. ::sax_fastparser::FastAttributeList *m_pTextboxAttrList; + /// When exporting fly frames, this holds the real size of the frame. + const Size* m_pFlyFrameSize; ::docx::FootnotesList *m_pFootnotesList; ::docx::FootnotesList *m_pEndnotesList; diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 2a463b0dcfd1..2918e5d428e9 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -1507,12 +1507,17 @@ void RtfAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Poi // Shape properties. m_aFlyProperties.push_back(std::make_pair<OString, OString>("shapeType", OString::number(ESCHER_ShpInst_TextBox))); + // When a frame has some low height, but automatically expanded due + // to lots of contents, this size contains the real size. + const Size aSize = rFrame.GetSize(); + m_pFlyFrameSize = &aSize; + m_rExport.bOutFlyFrmAttrs = m_rExport.bRTFFlySyntax = true; m_rExport.OutputFormat( rFrame.GetFrmFmt(), false, false, true ); m_rExport.Strm() << m_aRunText.makeStringAndClear().getStr(); m_rExport.Strm() << m_aStyles.makeStringAndClear().getStr(); m_rExport.bOutFlyFrmAttrs = m_rExport.bRTFFlySyntax = false; - m_pFmtFrmSize = 0; + m_pFlyFrameSize = 0; for (size_t i = 0; i < m_aFlyProperties.size(); ++i) { @@ -2650,11 +2655,7 @@ void RtfAttributeOutput::FormatFrameSize( const SwFmtFrmSize& rSize ) { SAL_INFO("sw.rtf", OSL_THIS_FUNC); - if ( m_rExport.bOutFlyFrmAttrs && m_rExport.bRTFFlySyntax ) - { - m_pFmtFrmSize = &rSize; - } - else if (m_rExport.bOutPageDescs) + if (m_rExport.bOutPageDescs) { m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_PGWSXN); m_aSectionBreaks.append((sal_Int32)rSize.GetWidth()); @@ -2824,10 +2825,10 @@ void RtfAttributeOutput::FormatVertOrientation( const SwFmtVertOrient& rFlyVert m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_SHPTOP; m_rExport.OutLong(rFlyVert.GetPos()); - if (m_pFmtFrmSize) + if (m_pFlyFrameSize) { m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_SHPBOTTOM; - m_rExport.OutLong(rFlyVert.GetPos() + m_pFmtFrmSize->GetHeight()); + m_rExport.OutLong(rFlyVert.GetPos() + m_pFlyFrameSize->Height()); } } else if ( !m_rExport.bRTFFlySyntax ) @@ -2872,10 +2873,10 @@ void RtfAttributeOutput::FormatHorizOrientation( const SwFmtHoriOrient& rFlyHori m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_SHPLEFT; m_rExport.OutLong(rFlyHori.GetPos()); - if (m_pFmtFrmSize) + if (m_pFlyFrameSize) { m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_SHPRIGHT; - m_rExport.OutLong(rFlyHori.GetPos() + m_pFmtFrmSize->GetWidth()); + m_rExport.OutLong(rFlyHori.GetPos() + m_pFlyFrameSize->Width()); } } else if ( !m_rExport.bRTFFlySyntax ) @@ -3138,7 +3139,7 @@ RtfAttributeOutput::RtfAttributeOutput( RtfExport &rExport ) m_bSingleEmptyRun(false), m_bInRun(false), m_nPostitFieldsMaxId(0), - m_pFmtFrmSize(0), + m_pFlyFrameSize(0), m_pPrevPageDesc(0) { SAL_INFO("sw.rtf", OSL_THIS_FUNC); diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx index b3f0ee3f54f4..9035b554fc4a 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.hxx +++ b/sw/source/filter/ww8/rtfattributeoutput.hxx @@ -552,8 +552,8 @@ private: unsigned int m_nPostitFieldsMaxId; - /// Set by FormatFrameSize(), read by Format*Orientation(). - const SwFmtFrmSize* m_pFmtFrmSize; + /// When exporting fly frames, this holds the real size of the frame. + const Size* m_pFlyFrameSize; std::vector< std::pair<OString, OString> > m_aFlyProperties; |