summaryrefslogtreecommitdiffstats
path: root/writerfilter
diff options
context:
space:
mode:
authorVinaya Mandke <vinaya.mandke@synerzip.com>2013-09-17 18:54:21 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-09-20 10:06:05 +0200
commit13e8e9e2fe32bc77058b5869c39948b683fb81ec (patch)
tree9489788b389b3d76761ad194e214bcaf7b797f96 /writerfilter
parentconfigure.ac: use ${INPATH} instead of wildcard (diff)
downloadcore-13e8e9e2fe32bc77058b5869c39948b683fb81ec.tar.gz
core-13e8e9e2fe32bc77058b5869c39948b683fb81ec.zip
fdo#40594 Fix for chart missing issue in Writer (for docx)
1. Enabled parsing of chart in writer module. 2. While parsing chart is read as ole2shape. Then converted into TextEmbedded object for chart. 3. While exporting postponed chart writing after rpr tag. 4. Generated unique id for each chart. 5. Corrected content type of chart in export. Change-Id: I6a1ca0c34e03e17cc3dd8a183580132ea7af5c48 Reviewed-on: https://gerrit.libreoffice.org/5976 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx35
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx2
-rw-r--r--writerfilter/source/dmapper/GraphicImport.cxx4
-rw-r--r--writerfilter/source/dmapper/GraphicImport.hxx1
-rw-r--r--writerfilter/source/ooxml/model.xml20
5 files changed, 61 insertions, 1 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index c89fdf2d1f58..308a7b283ec8 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1723,6 +1723,25 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape
uno::Reference<text::XTextContent> xTxtContent(xShape, uno::UNO_QUERY);
m_aAnchoredStack.push(xTxtContent);
}
+ else if (xSInfo->supportsService("com.sun.star.drawing.OLE2Shape"))
+ {
+ // OLE2Shape from oox should be converted to a TextEmbeddedObject for sw.
+ m_aTextAppendStack.push(TextAppendContext(uno::Reference<text::XTextAppend>(xShape, uno::UNO_QUERY), uno::Reference<text::XTextCursor>()));
+ uno::Reference<text::XTextContent> xTextContent(xShape, uno::UNO_QUERY);
+ m_aAnchoredStack.push(xTextContent);
+ uno::Reference<beans::XPropertySet> xShapePropertySet(xShape, uno::UNO_QUERY);
+
+ PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
+
+ m_xEmbedded.set(m_xTextFactory->createInstance("com.sun.star.text.TextEmbeddedObject"), uno::UNO_QUERY_THROW);
+ uno::Reference<beans::XPropertySet> xEmbeddedProperties(m_xEmbedded, uno::UNO_QUERY_THROW);
+ xEmbeddedProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_EMBEDDED_OBJECT), xShapePropertySet->getPropertyValue(rPropNameSupplier.GetName(PROP_EMBEDDED_OBJECT)));
+ xEmbeddedProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_ANCHOR_TYPE), uno::makeAny(text::TextContentAnchorType_AS_CHARACTER));
+ // So that the original bitmap-only shape will be replaced by the embedded object.
+ m_aAnchoredStack.top().bToRemove = true;
+ m_aTextAppendStack.pop();
+ appendTextContent(m_xEmbedded, uno::Sequence<beans::PropertyValue>());
+ }
else
{
uno::Reference< text::XTextRange > xShapeText( xShape, uno::UNO_QUERY_THROW);
@@ -1783,7 +1802,17 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape
SAL_WARN("writerfilter", "Exception when adding shape: " << e.Message);
}
}
-
+/*
+ * Updating chart height and width after reading the actual values from wp:extent
+*/
+void DomainMapper_Impl::UpdateEmbeddedShapeProps(const uno::Reference< drawing::XShape > xShape)
+{
+ PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
+ uno::Reference<beans::XPropertySet> xEmbeddedProperties(m_xEmbedded, uno::UNO_QUERY_THROW);
+ awt::Size aSize = xShape->getSize( );
+ xEmbeddedProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_WIDTH), uno::makeAny(sal_Int32(aSize.Width)));
+ xEmbeddedProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_HEIGHT), uno::makeAny(sal_Int32(aSize.Height)));
+}
void DomainMapper_Impl::PopShapeContext()
@@ -3668,6 +3697,10 @@ void DomainMapper_Impl::ImportGraphic(writerfilter::Reference< Properties >::Po
uno::Reference<text::XTextContent> xTextContent
(m_pGraphicImport->GetGraphicObject());
+ // Update the shape properties if it is embedded object.
+ if(m_xEmbedded.is()){
+ UpdateEmbeddedShapeProps(m_pGraphicImport->GetXShapeObject());
+ }
//insert it into the document at the current cursor position
OSL_ENSURE( xTextContent.is(), "DomainMapper_Impl::ImportGraphic");
if( xTextContent.is())
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 0da21a0878c7..f61c9ad0c838 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -299,6 +299,7 @@ private:
::com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext > m_xComponentContext;
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xPageStyles;
::com::sun::star::uno::Reference< ::com::sun::star::text::XText > m_xBodyText;
+ ::com::sun::star::uno::Reference<text::XTextContent> m_xEmbedded;
TextAppendStack m_aTextAppendStack;
@@ -523,6 +524,7 @@ public:
void PushShapeContext( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
void PopShapeContext();
+ void UpdateEmbeddedShapeProps( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
/// Add a pending shape: it's currently inserted into the document, but it should be removed before the import finishes.
void PushPendingShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
/// Get the first pending shape, if there are any.
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index af55e261842f..c4b9b43f4f76 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -1028,6 +1028,9 @@ uno::Reference<text::XTextContent> GraphicImport::GetGraphicObject()
return xResult;
}
+uno::Reference< ::com::sun::star::drawing::XShape> GraphicImport::GetXShapeObject(){
+ return m_xShape;
+}
void GraphicImport::ProcessShapeOptions(Value& val)
@@ -1206,6 +1209,7 @@ void GraphicImport::lcl_sprm(Sprm & rSprm)
case NS_ooxml::LN_pic_pic:
case NS_ooxml::LN_dgm_relIds:
case NS_ooxml::LN_lc_lockedCanvas:
+ case NS_ooxml::LN_c_chart:
{
writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
if( pProperties.get())
diff --git a/writerfilter/source/dmapper/GraphicImport.hxx b/writerfilter/source/dmapper/GraphicImport.hxx
index 6dba57c30acd..a9795125b85b 100644
--- a/writerfilter/source/dmapper/GraphicImport.hxx
+++ b/writerfilter/source/dmapper/GraphicImport.hxx
@@ -84,6 +84,7 @@ public:
virtual void data(const sal_uInt8* buf, size_t len, writerfilter::Reference<Properties>::Pointer_t ref);
::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > GetGraphicObject();
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape> GetXShapeObject();
bool IsGraphic() const;
private:
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index 3f0ed5aa7c45..f6a155c3fea5 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -27,6 +27,7 @@
<namespace-alias name="http://schemas.openxmlformats.org/drawingml/2006/picture" alias="picture" id="dmlPicture"/>
<namespace-alias name="http://schemas.openxmlformats.org/drawingml/2006/diagram" alias="diagram" id="dmlDiagram"/>
<namespace-alias name="http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas" alias="lockedCanvas" id="dmlLockedCanvas"/>
+ <namespace-alias name="http://schemas.openxmlformats.org/drawingml/2006/chart" alias="chart" id="dmlChart"/>
<namespace-alias name="urn:schemas-microsoft-com:office:word" alias="vml_wordprocessingDrawing" id="vmlWord"/>
<namespace-alias name="http://schemas.openxmlformats.org/wordprocessingml/2006/main" alias="wordprocessingml" id="doc"/>
<namespace-alias name="http://schemas.openxmlformats.org/officeDocument/2006/math" alias="math" id="officeMath"/>
@@ -5169,6 +5170,7 @@
<ref name="pic"/>
<ref name="relIds"/>
<ref name="lockedCanvas"/>
+ <ref name="chart"/>
<element>
<anyName/>
<ref name="BUILT_IN_ANY_TYPE"/>
@@ -5196,6 +5198,7 @@
<element name="pic" tokenid="ooxml:CT_GraphicalObjectData_pic"/>
<element name="relIds" tokenid="ooxml:CT_GraphicalObjectData_relIds"/>
<element name="lockedCanvas" tokenid="ooxml:CT_GraphicalObjectData_lockedCanvas"/>
+ <element name="chart" tokenid="ooxml:CT_GraphicalObjectData_chart"/>
<attribute name="uri" tokenid="ooxml:CT_GraphicalObjectData_uri"/>
</resource>
<resource name="CT_GraphicalObject" resource="Properties" tag="shape">
@@ -8472,6 +8475,16 @@
<ref name="CT_GvmlGroupShape"/>
</element>
</define>
+ <define xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" name="CT_Chart">
+ <attribute name="r:id">
+ <text/>
+ </attribute>
+ </define>
+ <define name="chart">
+ <element xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" name="c:chart">
+ <ref name="CT_Chart"/>
+ </element>
+ </define>
</grammar>
<resource name="CT_PictureNonVisual" resource="Properties" tag="shape">
<element name="cNvPr" tokenid="ooxml:CT_PictureNonVisual_cNvPr"/>
@@ -8501,6 +8514,13 @@
<resource name="lockedCanvas" resource="Shape" tag="shape">
<element xmlns:lc="http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas" name="lc:lockedCanvas" tokenid="ooxml:lc_lockedCanvas"/>
</resource>
+ <resource xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" name="CT_Chart" resource="Shape" tag="shape">
+ <attribute name="r:id" tokenid="ooxml:CT_RelId_chart"/>
+ </resource>
+ <resource name="chart" resource="Shape" tag="shape">
+ <element xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" name="c:chart" tokenid="ooxml:c_chart"/>
+ </resource>
+
</namespace>
<namespace name="vml-main" file="vml-main.rng" todo="ignore">
<start name="shape"/>