Kaydet (Commit) 6436c8fd authored tarafından Markus Mohrhard's avatar Markus Mohrhard

tdf#108022, don't overwrite chart export information

Change-Id: I47d8a817022829c8cada614469303e440f377299
Reviewed-on: https://gerrit.libreoffice.org/63536
Tested-by: Jenkins
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
(cherry picked from commit 9ccdf4d8)
Reviewed-on: https://gerrit.libreoffice.org/63539
üst c81e6d24
...@@ -4835,8 +4835,7 @@ bool DocxAttributeOutput::WriteOLEChart( const SdrObject* pSdrObj, const Size& r ...@@ -4835,8 +4835,7 @@ bool DocxAttributeOutput::WriteOLEChart( const SdrObject* pSdrObj, const Size& r
if (!SotExchange::IsChart(aClassID)) if (!SotExchange::IsChart(aClassID))
return false; return false;
m_postponedChart = pSdrObj; m_aPostponedCharts.push_back(std::pair<const SdrObject*, Size>(pSdrObj, rSize));
m_postponedChartSize = rSize;
return true; return true;
} }
...@@ -4845,81 +4844,86 @@ bool DocxAttributeOutput::WriteOLEChart( const SdrObject* pSdrObj, const Size& r ...@@ -4845,81 +4844,86 @@ bool DocxAttributeOutput::WriteOLEChart( const SdrObject* pSdrObj, const Size& r
*/ */
void DocxAttributeOutput::WritePostponedChart() void DocxAttributeOutput::WritePostponedChart()
{ {
if(m_postponedChart == nullptr) if (m_aPostponedCharts.empty())
return; return;
uno::Reference< chart2::XChartDocument > xChartDoc;
uno::Reference< drawing::XShape > xShape( const_cast<SdrObject*>(m_postponedChart)->getUnoShape(), uno::UNO_QUERY );
if( xShape.is() )
{
uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
if( xPropSet.is() )
xChartDoc.set( xPropSet->getPropertyValue( "Model" ), uno::UNO_QUERY );
}
if( xChartDoc.is() ) for (const auto& itr : m_aPostponedCharts)
{ {
SAL_INFO("sw.ww8", "DocxAttributeOutput::WriteOLE2Obj: export chart "); uno::Reference< chart2::XChartDocument > xChartDoc;
m_pSerializer->startElementNS( XML_w, XML_drawing, uno::Reference< drawing::XShape > xShape( const_cast<SdrObject*>(itr.first)->getUnoShape(), uno::UNO_QUERY );
FSEND ); if( xShape.is() )
m_pSerializer->startElementNS( XML_wp, XML_inline, {
XML_distT, "0", XML_distB, "0", XML_distL, "0", XML_distR, "0", uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
FSEND ); if( xPropSet.is() )
xChartDoc.set( xPropSet->getPropertyValue( "Model" ), uno::UNO_QUERY );
}
OString aWidth( OString::number( TwipsToEMU( m_postponedChartSize.Width() ) ) ); if( xChartDoc.is() )
OString aHeight( OString::number( TwipsToEMU( m_postponedChartSize.Height() ) ) ); {
m_pSerializer->singleElementNS( XML_wp, XML_extent, SAL_INFO("sw.ww8", "DocxAttributeOutput::WriteOLE2Obj: export chart ");
XML_cx, aWidth.getStr(), m_pSerializer->startElementNS( XML_w, XML_drawing,
XML_cy, aHeight.getStr(), FSEND );
FSEND ); m_pSerializer->startElementNS( XML_wp, XML_inline,
// TODO - the right effectExtent, extent including the effect XML_distT, "0", XML_distB, "0", XML_distL, "0", XML_distR, "0",
m_pSerializer->singleElementNS( XML_wp, XML_effectExtent, FSEND );
XML_l, "0", XML_t, "0", XML_r, "0", XML_b, "0",
FSEND );
OUString sName("Object 1"); OString aWidth( OString::number( TwipsToEMU( itr.second.Width() ) ) );
uno::Reference< container::XNamed > xNamed( xShape, uno::UNO_QUERY ); OString aHeight( OString::number( TwipsToEMU( itr.second.Height() ) ) );
if( xNamed.is() ) m_pSerializer->singleElementNS( XML_wp, XML_extent,
sName = xNamed->getName(); 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 );
/* If there is a scenario where a chart is followed by a shape OUString sName("Object 1");
which is being exported as an alternate content then, the uno::Reference< container::XNamed > xNamed( xShape, uno::UNO_QUERY );
docPr Id is being repeated, ECMA 20.4.2.5 says that the if( xNamed.is() )
docPr Id should be unique, ensuring the same here. sName = xNamed->getName();
*/
m_pSerializer->singleElementNS( XML_wp, XML_docPr, /* If there is a scenario where a chart is followed by a shape
XML_id, I32S( m_anchorId++ ), which is being exported as an alternate content then, the
XML_name, USS( sName ), docPr Id is being repeated, ECMA 20.4.2.5 says that the
FSEND ); docPr Id should be unique, ensuring the same here.
*/
m_pSerializer->singleElementNS( XML_wp, XML_docPr,
XML_id, I32S( m_anchorId++ ),
XML_name, USS( sName ),
FSEND );
m_pSerializer->singleElementNS( XML_wp, XML_cNvGraphicFramePr, m_pSerializer->singleElementNS( XML_wp, XML_cNvGraphicFramePr,
FSEND ); FSEND );
m_pSerializer->startElementNS( XML_a, XML_graphic, m_pSerializer->startElementNS( XML_a, XML_graphic,
FSNS( XML_xmlns, XML_a ), OUStringToOString(GetExport().GetFilter().getNamespaceURL(OOX_NS(dml)), RTL_TEXTENCODING_UTF8).getStr(), FSNS( XML_xmlns, XML_a ), OUStringToOString(GetExport().GetFilter().getNamespaceURL(OOX_NS(dml)), RTL_TEXTENCODING_UTF8).getStr(),
FSEND ); FSEND );
m_pSerializer->startElementNS( XML_a, XML_graphicData, m_pSerializer->startElementNS( XML_a, XML_graphicData,
XML_uri, "http://schemas.openxmlformats.org/drawingml/2006/chart", XML_uri, "http://schemas.openxmlformats.org/drawingml/2006/chart",
FSEND ); FSEND );
OString aRelId; OString aRelId;
m_nChartCount++; m_nChartCount++;
uno::Reference< frame::XModel > xModel( xChartDoc, uno::UNO_QUERY ); uno::Reference< frame::XModel > xModel( xChartDoc, uno::UNO_QUERY );
aRelId = m_rExport.OutputChart( xModel, m_nChartCount, m_pSerializer ); aRelId = m_rExport.OutputChart( xModel, m_nChartCount, m_pSerializer );
m_pSerializer->singleElementNS( XML_c, XML_chart, m_pSerializer->singleElementNS( XML_c, XML_chart,
FSNS( XML_xmlns, XML_c ), OUStringToOString(GetExport().GetFilter().getNamespaceURL(OOX_NS(dmlChart)), RTL_TEXTENCODING_UTF8).getStr(), FSNS( XML_xmlns, XML_c ), OUStringToOString(GetExport().GetFilter().getNamespaceURL(OOX_NS(dmlChart)), RTL_TEXTENCODING_UTF8).getStr(),
FSNS( XML_xmlns, XML_r ), OUStringToOString(GetExport().GetFilter().getNamespaceURL(OOX_NS(officeRel)), RTL_TEXTENCODING_UTF8).getStr(), FSNS( XML_xmlns, XML_r ), OUStringToOString(GetExport().GetFilter().getNamespaceURL(OOX_NS(officeRel)), RTL_TEXTENCODING_UTF8).getStr(),
FSNS( XML_r, XML_id ), aRelId.getStr(), FSNS( XML_r, XML_id ), aRelId.getStr(),
FSEND ); FSEND );
m_pSerializer->endElementNS( XML_a, XML_graphicData ); m_pSerializer->endElementNS( XML_a, XML_graphicData );
m_pSerializer->endElementNS( XML_a, XML_graphic ); m_pSerializer->endElementNS( XML_a, XML_graphic );
m_pSerializer->endElementNS( XML_wp, XML_inline ); m_pSerializer->endElementNS( XML_wp, XML_inline );
m_pSerializer->endElementNS( XML_w, XML_drawing ); m_pSerializer->endElementNS( XML_w, XML_drawing );
}
} }
m_postponedChart = nullptr;
m_aPostponedCharts.clear();
} }
bool DocxAttributeOutput::WriteOLEMath( const SwOLENode& rOLENode ) bool DocxAttributeOutput::WriteOLEMath( const SwOLENode& rOLENode )
...@@ -9150,7 +9154,6 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, const FSHelperPtr ...@@ -9150,7 +9154,6 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, const FSHelperPtr
m_nFieldsInHyperlink( 0 ), m_nFieldsInHyperlink( 0 ),
m_bExportingOutline(false), m_bExportingOutline(false),
m_nChartCount(0), m_nChartCount(0),
m_postponedChart( nullptr ),
pendingPlaceholder( nullptr ), pendingPlaceholder( nullptr ),
m_postitFieldsMaxId( 0 ), m_postitFieldsMaxId( 0 ),
m_anchorId( 1 ), m_anchorId( 1 ),
......
...@@ -877,8 +877,7 @@ private: ...@@ -877,8 +877,7 @@ private:
std::vector<const SwOLENode*> m_aPostponedMaths; std::vector<const SwOLENode*> m_aPostponedMaths;
/// count charts consistently for unit tests /// count charts consistently for unit tests
unsigned int m_nChartCount; unsigned int m_nChartCount;
const SdrObject* m_postponedChart; std::vector<std::pair<const SdrObject*, Size>> m_aPostponedCharts;
Size m_postponedChartSize;
std::vector<const SdrObject*> m_aPostponedFormControls; std::vector<const SdrObject*> m_aPostponedFormControls;
std::vector<PostponedDrawing> m_aPostponedActiveXControls; std::vector<PostponedDrawing> m_aPostponedActiveXControls;
const SwField* pendingPlaceholder; const SwField* pendingPlaceholder;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment