diff options
author | Katarina Machalkova <kmachalkova@suse.cz> | 2010-10-21 17:43:47 +0200 |
---|---|---|
committer | Katarina Machalkova <kmachalkova@suse.cz> | 2010-10-27 15:08:58 +0200 |
commit | fef5d1414bb9238626962cb64d98b924a595c9da (patch) | |
tree | 4eed7590145112443c69d6c0f45b4789a4c24d81 | |
parent | 5e13f5238dc5d4534eabdf2dd95c39f97bab98d2 (diff) |
Merged xlsx-shared-oox-chart-export-part1.diff from ooo-build
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 88 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxexport.cxx | 29 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxexport.hxx | 17 |
4 files changed, 131 insertions, 5 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 7219ad1751..40c31e79bd 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -125,6 +125,11 @@ #include <tools/color.hxx> #include <com/sun/star/i18n/ScriptType.hdl> +#include <com/sun/star/drawing/XShape.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XNamed.hpp> #if OSL_DEBUG_LEVEL > 0 #include <stdio.h> @@ -141,6 +146,7 @@ using namespace sax_fastparser; using namespace nsSwDocInfoSubType; using namespace nsFieldFlags; using namespace sw::util; +using namespace ::com::sun::star; void DocxAttributeOutput::RTLAndCJKState( bool bIsRTL, sal_uInt16 /*nScript*/ ) { @@ -1742,6 +1748,81 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size m_pSerializer->endElementNS( XML_w, XML_drawing ); } +void DocxAttributeOutput::WriteOLE2Obj( const SdrObject* pSdrObj, const Size& rSize ) +{ + uno::Reference< chart2::XChartDocument > xChartDoc; + uno::Reference< drawing::XShape > xShape( ((SdrObject*)pSdrObj)->getUnoShape(), uno::UNO_QUERY ); + if( xShape.is() ) + { + uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY ); + if( xPropSet.is() ) + xChartDoc.set( xPropSet->getPropertyValue( rtl::OUString::createFromAscii("Model") ), uno::UNO_QUERY ); + } + + if( xChartDoc.is() ) + { + OSL_TRACE("DocxAttributeOutput::WriteOLE2Obj: export chart "); + m_pSerializer->startElementNS( XML_w, XML_drawing, + FSEND ); + m_pSerializer->startElementNS( XML_wp, XML_inline, + XML_distT, "0", XML_distB, "0", XML_distL, "0", XML_distR, "0", + FSEND ); + + OString aWidth( OString::valueOf( TwipsToEMU( rSize.Width() ) ) ); + OString aHeight( OString::valueOf( TwipsToEMU( rSize.Height() ) ) ); + m_pSerializer->singleElementNS( XML_wp, XML_extent, + XML_cx, aWidth.getStr(), + XML_cy, aHeight.getStr(), + FSEND ); + // TODO - the right effectExtent, extent including the effect + m_pSerializer->singleElementNS( XML_wp, XML_effectExtent, + XML_l, "0", XML_t, "0", XML_r, "0", XML_b, "0", + FSEND ); + + // should get the unique id + sal_Int32 nID = 1; + OUString sName = rtl::OUString::createFromAscii("Object 1"); + uno::Reference< container::XNamed > xNamed( xShape, uno::UNO_QUERY ); + if( xNamed.is() ) + sName = xNamed->getName(); + + m_pSerializer->singleElementNS( XML_wp, XML_docPr, + XML_id, I32S( nID ), + XML_name, USS( sName ), + FSEND ); + + m_pSerializer->singleElementNS( XML_wp, XML_cNvGraphicFramePr, + FSEND ); + + 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.openxmlformats.org/drawingml/2006/chart", + FSEND ); + + + + OString aRelId; + static sal_Int32 nChartCount = 0; + nChartCount++; + uno::Reference< frame::XModel > xModel( xChartDoc, uno::UNO_QUERY ); + aRelId = m_rExport.OutputChart( xModel, nChartCount ); + + m_pSerializer->singleElementNS( XML_c, XML_chart, + FSNS( XML_xmlns, XML_c ), "http://schemas.openxmlformats.org/drawingml/2006/chart", + FSNS( XML_xmlns, XML_r ), "http://schemas.openxmlformats.org/officeDocument/2006/relationships", + FSNS( XML_r, XML_id ), aRelId.getStr(), + FSEND ); + + m_pSerializer->endElementNS( XML_a, XML_graphicData ); + m_pSerializer->endElementNS( XML_a, XML_graphic ); + m_pSerializer->endElementNS( XML_wp, XML_inline ); + m_pSerializer->endElementNS( XML_w, XML_drawing ); + } +} + void DocxAttributeOutput::OutputFlyFrame_Impl( const sw::Frame &rFrame, const Point& /*rNdTopLeft*/ ) { m_pSerializer->mark(); @@ -1792,6 +1873,13 @@ void DocxAttributeOutput::OutputFlyFrame_Impl( const sw::Frame &rFrame, const Po m_pParentFrame = &rFrame; } break; + case sw::Frame::eOle: + { + const SdrObject* pSdrObj = rFrame.GetFrmFmt().FindRealSdrObject(); + if ( pSdrObj ) + WriteOLE2Obj( pSdrObj, rFrame.GetLayoutSize() ); + } + break; default: #if OSL_DEBUG_LEVEL > 0 OSL_TRACE( "TODO DocxAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Point& rNdTopLeft ) - frame type '%s'\n", diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 5b5a741238..3048269a39 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -43,6 +43,7 @@ class DocxExport; class SwGrfNode; +class SdrObject; namespace docx { class FootnotesList; } namespace oox { namespace drawingml { class DrawingML; } } @@ -302,6 +303,7 @@ private: /// Output graphic fly frames. void FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size& rSize ); + void WriteOLE2Obj( const SdrObject* pSdrObj, const Size& rSize ); void InitTableHelper( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 3dfb000a79..4ccf208eb2 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -32,10 +32,12 @@ #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <com/sun/star/document/XDocumentProperties.hpp> #include <com/sun/star/i18n/ScriptType.hdl> +#include <com/sun/star/frame/XModel.hpp> #include <oox/core/tokens.hxx> #include <oox/export/drawingml.hxx> #include <oox/export/vmlexport.hxx> +#include <oox/export/chartexport.hxx> #include <map> #include <algorithm> @@ -292,6 +294,33 @@ void DocxExport::DoFormText(const SwInputField* /*pFld*/) OSL_TRACE( "TODO DocxExport::ForFormText()\n" ); } +rtl::OString DocxExport::OutputChart( uno::Reference< frame::XModel >& xModel, sal_Int32 nCount ) +{ + rtl::OUString aFileName = rtl::OUStringBuffer() + .appendAscii("charts/chart") + .append(nCount) + .appendAscii( ".xml" ) + .makeStringAndClear(); + + OUString sId = m_pFilter->addRelation( m_pDocumentFS->getOutputStream(), + S( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart" ), + aFileName ); + + aFileName = rtl::OUStringBuffer() + .appendAscii("word/charts/chart") + .append(nCount) + .appendAscii( ".xml" ) + .makeStringAndClear(); + + ::sax_fastparser::FSHelperPtr pChartFS = + m_pFilter->openFragmentStreamWithSerializer( aFileName, + S( "application/vnd.openxmlformats-officedocument.drawingml.chart" ) ); + + oox::drawingml::ChartExport aChartExport( XML_w, pChartFS, xModel, m_pFilter, oox::drawingml::DrawingML::DOCUMENT_DOCX ); + aChartExport.ExportContent(); + return ::rtl::OUStringToOString( sId, RTL_TEXTENCODING_UTF8 ); +} + void DocxExport::ExportDocument_Impl() { InitStyles(); diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx index b4bcba0baf..c42b23c87e 100644 --- a/sw/source/filter/ww8/docxexport.hxx +++ b/sw/source/filter/ww8/docxexport.hxx @@ -2,7 +2,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -53,6 +53,10 @@ namespace oox { namespace vml { class VMLExport; } } +namespace com { namespace sun { namespace star { + namespace frame { class XModel; } +} } } + /// The class that does all the actual DOCX export-related work. class DocxExport : public MSWordExportBase { @@ -118,7 +122,7 @@ public: /// Write the data of the form field virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ); virtual void WriteHyperlinkData( const ::sw::mark::IFieldmark& rFieldmark ); - + virtual void DoComboBox(const rtl::OUString &rName, const rtl::OUString &rHelp, const rtl::OUString &ToolTip, @@ -126,16 +130,19 @@ public: com::sun::star::uno::Sequence<rtl::OUString> &rListItems); virtual void DoFormText(const SwInputField * pFld); - + virtual ULONG ReplaceCr( BYTE nChar ); + /// Returns the relationd id + rtl::OString OutputChart( com::sun::star::uno::Reference< com::sun::star::frame::XModel >& xModel, sal_Int32 nCount ); + protected: /// Format-dependant part of the actual export. virtual void ExportDocument_Impl(); /// Output page/section breaks virtual void OutputPageSectionBreaks( const SwTxtNode& ); - + /// Output SwEndNode virtual void OutputEndNode( const SwEndNode& ); @@ -163,7 +170,7 @@ protected: const SwPageDesc* pNewPgDesc = 0 ); private: - /// Setup pStyles and write styles.xml + /// Setup pStyles and write styles.xml void InitStyles(); /// Write footnotes.xml and endnotes.xml. |