diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-01-13 21:34:08 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-01-13 21:50:50 +0100 |
commit | 8dc10235a29e00ae8ebf58b84650aaffd7f0329d (patch) | |
tree | 9683cbb75599ca2c7357503efc498ca98966403b /sw/source/filter/ww8 | |
parent | 8891d8c42df288a4f3c631e9c73b24489c6c83a0 (diff) |
DocxAttributeOutput: factor out writeDMLTextFrame() into DocxSdrExport
Also move the related m_pBodyPrAttrList and m_bDMLTextFrameSyntax
members as well.
Change-Id: I5c9f5b07b472efc930878ee2a26224346f036600
Diffstat (limited to 'sw/source/filter/ww8')
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 168 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxsdrexport.cxx | 154 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxsdrexport.hxx | 8 |
4 files changed, 173 insertions, 163 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 841655439594..20ce7f01d6c3 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -270,137 +270,6 @@ void DocxAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pText m_bParagraphOpened = true; } -void DocxAttributeOutput::WriteDMLTextFrame(sw::Frame* pParentFrame) -{ - const SwFrmFmt& rFrmFmt = pParentFrame->GetFrmFmt( ); - const SwNodeIndex* pNodeIndex = rFrmFmt.GetCntnt().GetCntntIdx(); - - sal_uLong nStt = pNodeIndex ? pNodeIndex->GetIndex()+1 : 0; - sal_uLong nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : 0; - - //Save data here and restore when out of scope - ExportDataSaveRestore aDataGuard(m_rExport, nStt, nEnd, 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_rExport.SdrExporter().startDMLAnchorInline(&rFrmFmt, aSize); - - sax_fastparser::FastAttributeList* pDocPrAttrList = m_pSerializer->createAttrList(); - pDocPrAttrList->add(XML_id, OString::number(m_anchorId++).getStr()); - pDocPrAttrList->add(XML_name, OUStringToOString(rFrmFmt.GetName(), RTL_TEXTENCODING_UTF8).getStr()); - XFastAttributeListRef xDocPrAttrListRef(pDocPrAttrList); - m_pSerializer->singleElementNS(XML_wp, XML_docPr, xDocPrAttrListRef); - - m_pSerializer->startElementNS(XML_a, XML_graphic, - FSNS(XML_xmlns, XML_a), "http://schemas.openxmlformats.org/drawingml/2006/main", - FSEND); - m_pSerializer->startElementNS(XML_a, XML_graphicData, - XML_uri, "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", - FSEND); - m_pSerializer->startElementNS(XML_wps, XML_wsp, FSEND); - m_pSerializer->singleElementNS(XML_wps, XML_cNvSpPr, - XML_txBox, "1", - FSEND); - - uno::Any aRotation ; - const SdrObject* pSdrObj = rFrmFmt.FindRealSdrObject(); - uno::Reference< drawing::XShape > xShape( ((SdrObject*)pSdrObj)->getUnoShape(), uno::UNO_QUERY ); - uno::Reference< beans::XPropertySet > xPropertySet( xShape, uno::UNO_QUERY ); - uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropertySet->getPropertySetInfo(); - sal_Int32 nRotation = 0; - - if ( xPropSetInfo->hasPropertyByName( "FrameInteropGrabBag" ) ) - { - uno::Sequence< beans::PropertyValue > propList; - xPropertySet->getPropertyValue( "FrameInteropGrabBag" ) >>= propList; - for ( sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp ) - { - OUString propName = propList[nProp].Name; - if ( propName == "mso-rotation-angle") - { - aRotation = propList[nProp].Value ; - break; - } - } - } - aRotation >>= nRotation ; - OString sRotation(OString::number(nRotation)); - // Shape properties - m_pSerializer->startElementNS(XML_wps, XML_spPr, FSEND); - if(nRotation) - { - m_pSerializer->startElementNS(XML_a, XML_xfrm, - XML_rot, sRotation.getStr(), - FSEND); - - } - else - { - m_pSerializer->startElementNS(XML_a, XML_xfrm, FSEND); - } - m_pSerializer->singleElementNS(XML_a, XML_off, - XML_x, "0", - XML_y, "0", - FSEND); - OString aWidth(OString::number(TwipsToEMU(aSize.Width()))); - OString aHeight(OString::number(TwipsToEMU(aSize.Height()))); - m_pSerializer->singleElementNS(XML_a, XML_ext, - XML_cx, aWidth.getStr(), - XML_cy, aHeight.getStr(), - FSEND); - m_pSerializer->endElementNS(XML_a, XML_xfrm); - OUString shapeType = "rect"; - if ( xPropSetInfo->hasPropertyByName( "FrameInteropGrabBag" ) ) - { - uno::Sequence< beans::PropertyValue > propList; - xPropertySet->getPropertyValue( "FrameInteropGrabBag" ) >>= propList; - for ( sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp ) - { - OUString propName = propList[nProp].Name; - if ( propName == "mso-orig-shape-type") - { - propList[nProp].Value >>= shapeType; - break; - } - } - } - - m_pSerializer->singleElementNS(XML_a, XML_prstGeom, - XML_prst, OUStringToOString( shapeType, RTL_TEXTENCODING_UTF8 ).getStr(), - FSEND); - m_bDMLTextFrameSyntax = true; - m_pBodyPrAttrList = m_pSerializer->createAttrList(); - m_rExport.OutputFormat( pParentFrame->GetFrmFmt(), false, false, true ); - m_bDMLTextFrameSyntax = false; - m_rExport.SdrExporter().writeDMLEffectLst(rFrmFmt); - m_pSerializer->endElementNS(XML_wps, XML_spPr); - - m_rExport.mpParentFrame = NULL; - m_pSerializer->startElementNS( XML_wps, XML_txbx, FSEND ); - m_pSerializer->startElementNS( XML_w, XML_txbxContent, FSEND ); - - m_rExport.SdrExporter().setFrameBtLr(m_rExport.SdrExporter().checkFrameBtlr(m_rExport.pDoc->GetNodes()[nStt], 0, m_pBodyPrAttrList)); - m_rExport.WriteText( ); - m_rExport.SdrExporter().setFrameBtLr(false); - - m_pSerializer->endElementNS( XML_w, XML_txbxContent ); - m_pSerializer->endElementNS( XML_wps, XML_txbx ); - XFastAttributeListRef xBodyPrAttrList(m_pBodyPrAttrList); - m_pBodyPrAttrList = NULL; - m_pSerializer->startElementNS( XML_wps, XML_bodyPr, xBodyPrAttrList ); - // AutoSize of the Text Frame. - const SwFmtFrmSize& rSize = rFrmFmt.GetFrmSize(); - m_pSerializer->singleElementNS(XML_a, (rSize.GetHeightSizeType() == ATT_VAR_SIZE ? XML_spAutoFit : XML_noAutofit), FSEND); - m_pSerializer->endElementNS( XML_wps, XML_bodyPr ); - - m_pSerializer->endElementNS(XML_wps, XML_wsp); - m_pSerializer->endElementNS(XML_a, XML_graphicData); - m_pSerializer->endElementNS(XML_a, XML_graphic); - m_rExport.SdrExporter().endDMLAnchorInline(&rFrmFmt); -} - void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner ) { // write the paragraph properties + the run, already in the correct order @@ -437,7 +306,7 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT //Reset the table infos after saving. m_rExport.mpTableInfo = ww8::WW8TableInfo::Pointer_t(new ww8::WW8TableInfo()); - WriteDMLTextFrame(pParentFrame); + m_rExport.SdrExporter().writeDMLTextFrame(pParentFrame, m_anchorId++); m_pSerializer->endElementNS(XML_mc, XML_Choice); // Reset table infos, otherwise the depth of the cells will be incorrect, @@ -5335,7 +5204,7 @@ void DocxAttributeOutput::FormatFrameSize( const SwFmtFrmSize& rSize ) m_rExport.SdrExporter().getTextFrameStyle().append(";width:").append(double(pSize->Width()) / 20); m_rExport.SdrExporter().getTextFrameStyle().append("pt;height:").append(double(pSize->Height()) / 20).append("pt"); } - else if (m_bDMLTextFrameSyntax) + else if (m_rExport.SdrExporter().getDMLTextFrameSyntax()) { } else if ( m_rExport.bOutFlyFrmAttrs ) @@ -5384,7 +5253,7 @@ void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace ) m_rExport.SdrExporter().getTextFrameStyle().append(";mso-wrap-distance-left:").append(double(rLRSpace.GetLeft()) / 20).append("pt"); m_rExport.SdrExporter().getTextFrameStyle().append(";mso-wrap-distance-right:").append(double(rLRSpace.GetRight()) / 20).append("pt"); } - else if (m_bDMLTextFrameSyntax) + else if (m_rExport.SdrExporter().getDMLTextFrameSyntax()) { } else if ( m_rExport.bOutFlyFrmAttrs ) @@ -5438,7 +5307,7 @@ void DocxAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace ) m_rExport.SdrExporter().getTextFrameStyle().append(";mso-wrap-distance-top:").append(double(rULSpace.GetUpper()) / 20).append("pt"); m_rExport.SdrExporter().getTextFrameStyle().append(";mso-wrap-distance-bottom:").append(double(rULSpace.GetLower()) / 20).append("pt"); } - else if (m_bDMLTextFrameSyntax) + else if (m_rExport.SdrExporter().getDMLTextFrameSyntax()) { } else if ( m_rExport.bOutFlyFrmAttrs ) @@ -5551,7 +5420,7 @@ void DocxAttributeOutput::FormatSurround( const SwFmtSurround& rSurround ) m_rExport.SdrExporter().getFlyWrapAttrList()->add(XML_side, sSide); } } - else if (m_bDMLTextFrameSyntax) + else if (m_rExport.SdrExporter().getDMLTextFrameSyntax()) { } else if ( m_rExport.bOutFlyFrmAttrs ) @@ -5583,7 +5452,7 @@ void DocxAttributeOutput::FormatVertOrientation( const SwFmtVertOrient& rFlyVert { m_rExport.SdrExporter().getTextFrameStyle().append(";margin-top:").append(double(rFlyVert.GetPos()) / 20).append("pt"); } - else if (m_bDMLTextFrameSyntax) + else if (m_rExport.SdrExporter().getDMLTextFrameSyntax()) { } else if ( m_rExport.bOutFlyFrmAttrs ) @@ -5645,7 +5514,7 @@ void DocxAttributeOutput::FormatHorizOrientation( const SwFmtHoriOrient& rFlyHor { m_rExport.SdrExporter().getTextFrameStyle().append(";margin-left:").append(double(rFlyHori.GetPos()) / 20).append("pt"); } - else if (m_bDMLTextFrameSyntax) + else if (m_rExport.SdrExporter().getDMLTextFrameSyntax()) { } else if ( m_rExport.bOutFlyFrmAttrs ) @@ -5740,7 +5609,7 @@ void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush ) sColor = "#" + sColor; AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), XML_fillcolor, sColor.getStr() ); } - else if (m_bDMLTextFrameSyntax) + else if (m_rExport.SdrExporter().getDMLTextFrameSyntax()) { bool bImageBackground = false; const SfxPoolItem* pItem = GetExport().HasItem(RES_FILL_STYLE); @@ -5799,7 +5668,7 @@ void DocxAttributeOutput::FormatFillStyle( const XFillStyleItem& rFillStyle ) void DocxAttributeOutput::FormatFillGradient( const XFillGradientItem& rFillGradient ) { - if (m_oFillStyle && *m_oFillStyle == XFILL_GRADIENT && !m_bDMLTextFrameSyntax) + if (m_oFillStyle && *m_oFillStyle == XFILL_GRADIENT && !m_rExport.SdrExporter().getDMLTextFrameSyntax()) { AddToAttrList( m_rExport.SdrExporter().getFlyFillAttrList(), XML_type, "gradient" ); @@ -5843,7 +5712,7 @@ void DocxAttributeOutput::FormatFillGradient( const XFillGradientItem& rFillGrad AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), XML_fillcolor, sColor1.getStr() ); AddToAttrList( m_rExport.SdrExporter().getFlyFillAttrList(), XML_color2, sColor2.getStr() ); } - else if (m_oFillStyle && *m_oFillStyle == XFILL_GRADIENT && m_bDMLTextFrameSyntax) + else if (m_oFillStyle && *m_oFillStyle == XFILL_GRADIENT && m_rExport.SdrExporter().getDMLTextFrameSyntax()) { uno::Reference<beans::XPropertySet> xPropertySet = SwXFrames::GetObject(const_cast<SwFrmFmt&>(m_rExport.mpParentFrame->GetFrmFmt()), FLYCNTTYPE_FRM); m_rDrawingML.SetFS(m_pSerializer); @@ -5854,7 +5723,7 @@ void DocxAttributeOutput::FormatFillGradient( const XFillGradientItem& rFillGrad void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox ) { - if (m_bDMLTextFrameSyntax) + if (m_rExport.SdrExporter().getDMLTextFrameSyntax()) { // <a:gradFill> should be before <a:ln>. const SfxPoolItem* pItem = GetExport().HasItem(RES_FILL_STYLE); @@ -5880,7 +5749,7 @@ void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox ) } m_bIgnoreNextFill = true; } - if (m_rExport.SdrExporter().getTextFrameSyntax() || m_bDMLTextFrameSyntax) + if (m_rExport.SdrExporter().getTextFrameSyntax() || m_rExport.SdrExporter().getDMLTextFrameSyntax()) { const SvxBorderLine* pLeft = rBox.GetLeft( ); const SvxBorderLine* pTop = rBox.GetTop( ); @@ -5930,12 +5799,12 @@ void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox ) } } - if (m_bDMLTextFrameSyntax) + if (m_rExport.SdrExporter().getDMLTextFrameSyntax()) { - m_pBodyPrAttrList->add(XML_lIns, OString::number(TwipsToEMU(rBox.GetDistance(BOX_LINE_LEFT)))); - m_pBodyPrAttrList->add(XML_tIns, OString::number(TwipsToEMU(rBox.GetDistance(BOX_LINE_TOP)))); - m_pBodyPrAttrList->add(XML_rIns, OString::number(TwipsToEMU(rBox.GetDistance(BOX_LINE_RIGHT)))); - m_pBodyPrAttrList->add(XML_bIns, OString::number(TwipsToEMU(rBox.GetDistance(BOX_LINE_BOTTOM)))); + m_rExport.SdrExporter().getBodyPrAttrList()->add(XML_lIns, OString::number(TwipsToEMU(rBox.GetDistance(BOX_LINE_LEFT)))); + m_rExport.SdrExporter().getBodyPrAttrList()->add(XML_tIns, OString::number(TwipsToEMU(rBox.GetDistance(BOX_LINE_TOP)))); + m_rExport.SdrExporter().getBodyPrAttrList()->add(XML_rIns, OString::number(TwipsToEMU(rBox.GetDistance(BOX_LINE_RIGHT)))); + m_rExport.SdrExporter().getBodyPrAttrList()->add(XML_bIns, OString::number(TwipsToEMU(rBox.GetDistance(BOX_LINE_BOTTOM)))); return; } @@ -6282,7 +6151,6 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri m_pSectionSpacingAttrList( NULL ), m_pParagraphSpacingAttrList( NULL ), m_pHyperlinkAttrList( NULL ), - m_pBodyPrAttrList( NULL ), m_pColorAttrList( NULL ), m_pBackgroundAttrList( NULL ), m_pFootnotesList( new ::docx::FootnotesList() ), @@ -6300,7 +6168,6 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri m_pTableWrt( NULL ), m_bParagraphOpened( false ), m_nColBreakStatus( COLBRK_NONE ), - m_bDMLTextFrameSyntax( false ), m_closeHyperlinkInThisRun( false ), m_closeHyperlinkInPreviousRun( false ), m_startedHyperlink( false ), @@ -6335,7 +6202,6 @@ DocxAttributeOutput::~DocxAttributeOutput() delete m_pSectionSpacingAttrList, m_pSectionSpacingAttrList = NULL; delete m_pParagraphSpacingAttrList, m_pParagraphSpacingAttrList = NULL; delete m_pHyperlinkAttrList, m_pHyperlinkAttrList = NULL; - delete m_pBodyPrAttrList, m_pBodyPrAttrList = NULL; delete m_pColorAttrList, m_pColorAttrList = NULL; delete m_pBackgroundAttrList, m_pBackgroundAttrList = NULL; diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 87bafdcde4fe..74f76acda3c9 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -393,9 +393,6 @@ private: /// checks whether the current component is a diagram bool IsDiagram (const SdrObject* sdrObject); - /// Writes text frame in DML format. - void WriteDMLTextFrame(sw::Frame* pParentFrame); - void InitTableHelper( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); void StartTable( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); void StartTableRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); @@ -682,8 +679,6 @@ private: ::sax_fastparser::FastAttributeList *m_pSectionSpacingAttrList; ::sax_fastparser::FastAttributeList *m_pParagraphSpacingAttrList; ::sax_fastparser::FastAttributeList *m_pHyperlinkAttrList; - /// Attributes of <wps:bodyPr>, used during DML export of text frames. - ::sax_fastparser::FastAttributeList *m_pBodyPrAttrList; /// Attributes of the run color ::sax_fastparser::FastAttributeList *m_pColorAttrList; /// Attributes of the paragraph background @@ -747,7 +742,6 @@ private: DocxColBreakStatus m_nColBreakStatus; std::vector<sw::Frame> m_aParentFrames; - bool m_bDMLTextFrameSyntax; // close of hyperlink needed bool m_closeHyperlinkInThisRun; bool m_closeHyperlinkInPreviousRun; diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index 2d1d6c7015bb..4c4ab8dd579e 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -35,6 +35,7 @@ #include <ndtxt.hxx> #include <txatbase.hxx> #include <fmtautofmt.hxx> +#include <fmtfsize.hxx> #include <docxsdrexport.hxx> #include <docxexport.hxx> @@ -65,12 +66,14 @@ struct DocxSdrExport::Impl oox::drawingml::DrawingML* m_pDrawingML; const Size* m_pFlyFrameSize; bool m_bTextFrameSyntax; + bool m_bDMLTextFrameSyntax; sax_fastparser::FastAttributeList* m_pFlyAttrList; sax_fastparser::FastAttributeList* m_pTextboxAttrList; OStringBuffer m_aTextFrameStyle; bool m_bFrameBtLr; sax_fastparser::FastAttributeList* m_pFlyFillAttrList; sax_fastparser::FastAttributeList* m_pFlyWrapAttrList; + sax_fastparser::FastAttributeList* m_pBodyPrAttrList; Impl(DocxSdrExport& rSdrExport, DocxExport& rExport, sax_fastparser::FSHelperPtr pSerializer, oox::drawingml::DrawingML* pDrawingML) : m_rSdrExport(rSdrExport), @@ -79,11 +82,13 @@ struct DocxSdrExport::Impl m_pDrawingML(pDrawingML), m_pFlyFrameSize(0), m_bTextFrameSyntax(false), + m_bDMLTextFrameSyntax(false), m_pFlyAttrList(0), m_pTextboxAttrList(0), m_bFrameBtLr(false), m_pFlyFillAttrList(0), - m_pFlyWrapAttrList(0) + m_pFlyWrapAttrList(0), + m_pBodyPrAttrList(0) { } @@ -122,6 +127,11 @@ bool DocxSdrExport::getTextFrameSyntax() return m_pImpl->m_bTextFrameSyntax; } +bool DocxSdrExport::getDMLTextFrameSyntax() +{ + return m_pImpl->m_bDMLTextFrameSyntax; +} + sax_fastparser::FastAttributeList*& DocxSdrExport::getFlyAttrList() { return m_pImpl->m_pFlyAttrList; @@ -162,6 +172,11 @@ sax_fastparser::FastAttributeList* DocxSdrExport::getFlyWrapAttrList() return m_pImpl->m_pFlyWrapAttrList; } +sax_fastparser::FastAttributeList* DocxSdrExport::getBodyPrAttrList() +{ + return m_pImpl->m_pBodyPrAttrList; +} + void DocxSdrExport::setFlyWrapAttrList(sax_fastparser::FastAttributeList* pAttrList) { m_pImpl->m_pFlyWrapAttrList = pAttrList; @@ -757,6 +772,137 @@ void DocxSdrExport::writeDiagram(const SdrObject* sdrObject, const SwFrmFmt& rFr } } +void DocxSdrExport::writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId) +{ + sax_fastparser::FSHelperPtr pFS = m_pImpl->m_pSerializer; + const SwFrmFmt& rFrmFmt = pParentFrame->GetFrmFmt(); + const SwNodeIndex* pNodeIndex = rFrmFmt.GetCntnt().GetCntntIdx(); + + sal_uLong nStt = pNodeIndex ? pNodeIndex->GetIndex()+1 : 0; + sal_uLong nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : 0; + + //Save data here and restore when out of scope + ExportDataSaveRestore aDataGuard(m_pImpl->m_rExport, nStt, nEnd, 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(); + + startDMLAnchorInline(&rFrmFmt, aSize); + + sax_fastparser::FastAttributeList* pDocPrAttrList = pFS->createAttrList(); + pDocPrAttrList->add(XML_id, OString::number(nAnchorId).getStr()); + pDocPrAttrList->add(XML_name, OUStringToOString(rFrmFmt.GetName(), RTL_TEXTENCODING_UTF8).getStr()); + sax_fastparser::XFastAttributeListRef xDocPrAttrListRef(pDocPrAttrList); + pFS->singleElementNS(XML_wp, XML_docPr, xDocPrAttrListRef); + + pFS->startElementNS(XML_a, XML_graphic, + FSNS(XML_xmlns, XML_a), "http://schemas.openxmlformats.org/drawingml/2006/main", + FSEND); + pFS->startElementNS(XML_a, XML_graphicData, + XML_uri, "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", + FSEND); + pFS->startElementNS(XML_wps, XML_wsp, FSEND); + pFS->singleElementNS(XML_wps, XML_cNvSpPr, + XML_txBox, "1", + FSEND); + + uno::Any aRotation ; + const SdrObject* pSdrObj = rFrmFmt.FindRealSdrObject(); + uno::Reference< drawing::XShape > xShape(((SdrObject*)pSdrObj)->getUnoShape(), uno::UNO_QUERY); + uno::Reference< beans::XPropertySet > xPropertySet(xShape, uno::UNO_QUERY); + uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropertySet->getPropertySetInfo(); + sal_Int32 nRotation = 0; + + if (xPropSetInfo->hasPropertyByName("FrameInteropGrabBag")) + { + uno::Sequence< beans::PropertyValue > propList; + xPropertySet->getPropertyValue("FrameInteropGrabBag") >>= propList; + for (sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp) + { + OUString propName = propList[nProp].Name; + if (propName == "mso-rotation-angle") + { + aRotation = propList[nProp].Value ; + break; + } + } + } + aRotation >>= nRotation ; + OString sRotation(OString::number(nRotation)); + // Shape properties + pFS->startElementNS(XML_wps, XML_spPr, FSEND); + if (nRotation) + { + pFS->startElementNS(XML_a, XML_xfrm, + XML_rot, sRotation.getStr(), + FSEND); + } + else + { + pFS->startElementNS(XML_a, XML_xfrm, FSEND); + } + pFS->singleElementNS(XML_a, XML_off, + XML_x, "0", + XML_y, "0", + FSEND); + OString aWidth(OString::number(TwipsToEMU(aSize.Width()))); + OString aHeight(OString::number(TwipsToEMU(aSize.Height()))); + pFS->singleElementNS(XML_a, XML_ext, + XML_cx, aWidth.getStr(), + XML_cy, aHeight.getStr(), + FSEND); + pFS->endElementNS(XML_a, XML_xfrm); + OUString shapeType = "rect"; + if (xPropSetInfo->hasPropertyByName("FrameInteropGrabBag")) + { + uno::Sequence< beans::PropertyValue > propList; + xPropertySet->getPropertyValue("FrameInteropGrabBag") >>= propList; + for (sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp) + { + OUString propName = propList[nProp].Name; + if (propName == "mso-orig-shape-type") + { + propList[nProp].Value >>= shapeType; + break; + } + } + } + + pFS->singleElementNS(XML_a, XML_prstGeom, + XML_prst, OUStringToOString(shapeType, RTL_TEXTENCODING_UTF8).getStr(), + FSEND); + m_pImpl->m_bDMLTextFrameSyntax = true; + m_pImpl->m_pBodyPrAttrList = pFS->createAttrList(); + m_pImpl->m_rExport.OutputFormat(pParentFrame->GetFrmFmt(), false, false, true); + m_pImpl->m_bDMLTextFrameSyntax = false; + writeDMLEffectLst(rFrmFmt); + pFS->endElementNS(XML_wps, XML_spPr); + + m_pImpl->m_rExport.mpParentFrame = NULL; + pFS->startElementNS(XML_wps, XML_txbx, FSEND); + pFS->startElementNS(XML_w, XML_txbxContent, FSEND); + + m_pImpl->m_bFrameBtLr = checkFrameBtlr(m_pImpl->m_rExport.pDoc->GetNodes()[nStt], 0); + m_pImpl->m_rExport.WriteText(); + m_pImpl->m_bFrameBtLr = false; + + pFS->endElementNS(XML_w, XML_txbxContent); + pFS->endElementNS(XML_wps, XML_txbx); + sax_fastparser::XFastAttributeListRef xBodyPrAttrList(m_pImpl->m_pBodyPrAttrList); + m_pImpl->m_pBodyPrAttrList = NULL; + pFS->startElementNS(XML_wps, XML_bodyPr, xBodyPrAttrList); + // AutoSize of the Text Frame. + const SwFmtFrmSize& rSize = rFrmFmt.GetFrmSize(); + pFS->singleElementNS(XML_a, (rSize.GetHeightSizeType() == ATT_VAR_SIZE ? XML_spAutoFit : XML_noAutofit), FSEND); + pFS->endElementNS(XML_wps, XML_bodyPr); + + pFS->endElementNS(XML_wps, XML_wsp); + pFS->endElementNS(XML_a, XML_graphicData); + pFS->endElementNS(XML_a, XML_graphic); + endDMLAnchorInline(&rFrmFmt); +} + void DocxSdrExport::writeVMLTextFrame(sw::Frame* pParentFrame) { sax_fastparser::FSHelperPtr pFS = m_pImpl->m_pSerializer; @@ -816,10 +962,10 @@ void DocxSdrExport::writeVMLTextFrame(sw::Frame* pParentFrame) m_pImpl->m_bFrameBtLr = false; } -bool DocxSdrExport::checkFrameBtlr(SwNode* pStartNode, sax_fastparser::FastAttributeList* pTextboxAttrList, sax_fastparser::FastAttributeList* pBodyPrAttrList) +bool DocxSdrExport::checkFrameBtlr(SwNode* pStartNode, sax_fastparser::FastAttributeList* pTextboxAttrList) { // The intended usage is to pass either a valid VML or DML attribute list. - assert(pTextboxAttrList || pBodyPrAttrList); + assert(pTextboxAttrList || m_pImpl->m_pBodyPrAttrList); if (!pStartNode->IsTxtNode()) return false; @@ -856,7 +1002,7 @@ bool DocxSdrExport::checkFrameBtlr(SwNode* pStartNode, sax_fastparser::FastAttri if (pTextboxAttrList) pTextboxAttrList->add(XML_style, "mso-layout-flow-alt:bottom-to-top"); else - pBodyPrAttrList->add(XML_vert, "vert270"); + m_pImpl->m_pBodyPrAttrList->add(XML_vert, "vert270"); return true; } } diff --git a/sw/source/filter/ww8/docxsdrexport.hxx b/sw/source/filter/ww8/docxsdrexport.hxx index bae4a35c5e6e..0f871ac02917 100644 --- a/sw/source/filter/ww8/docxsdrexport.hxx +++ b/sw/source/filter/ww8/docxsdrexport.hxx @@ -11,7 +11,6 @@ #define INCLUDED_SW_SOURCE_FILTER_WW8_DOCXSDREXPORT_HXX #include <boost/shared_ptr.hpp> -#include <sax/fshelper.hxx> namespace oox { @@ -56,6 +55,7 @@ public: /// When exporting fly frames, this holds the real size of the frame. const Size* getFlyFrameSize(); bool getTextFrameSyntax(); + bool getDMLTextFrameSyntax(); sax_fastparser::FastAttributeList*& getFlyAttrList(); void setFlyAttrList(sax_fastparser::FastAttributeList* pAttrList); /// Attributes of the next v:textbox element. @@ -67,6 +67,8 @@ public: sax_fastparser::FastAttributeList*& getFlyFillAttrList(); sax_fastparser::FastAttributeList* getFlyWrapAttrList(); void setFlyWrapAttrList(sax_fastparser::FastAttributeList* pAttrList); + /// Attributes of <wps:bodyPr>, used during DML export of text frames. + sax_fastparser::FastAttributeList* getBodyPrAttrList(); void startDMLAnchorInline(const SwFrmFmt* pFrmFmt, const Size& rSize); void endDMLAnchorInline(const SwFrmFmt* pFrmFmt); @@ -78,10 +80,12 @@ public: void writeDMLEffectLst(const SwFrmFmt& rFrmFmt); /// Writes a diagram (smartart). void writeDiagram(const SdrObject* sdrObject, const SwFrmFmt& rFrmFmt, int nAnchorId); + /// Writes text frame in DML format. + void writeDMLTextFrame(sw::Frame* pParentFrame, int nAnchorId); /// Writes text frame in VML format. void writeVMLTextFrame(sw::Frame* pParentFrame); /// Undo the text direction mangling done by the frame btLr handler in writerfilter::dmapper::DomainMapper::lcl_startCharacterGroup() - bool checkFrameBtlr(SwNode* pStartNode, sax_fastparser::FastAttributeList* pTextboxAttrList = 0, sax_fastparser::FastAttributeList* pBodyPrAttrList = 0); + bool checkFrameBtlr(SwNode* pStartNode, sax_fastparser::FastAttributeList* pTextboxAttrList = 0); }; #endif // INCLUDED_SW_SOURCE_FILTER_WW8_DOCXSDREXPORT_HXX |