summaryrefslogtreecommitdiff
path: root/oox/source/drawingml
diff options
context:
space:
mode:
authorVinaya Mandke <vinaya.mandke@synerzip.com>2014-02-25 13:13:11 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-03-05 10:13:40 +0100
commit6536826f2f4c747582d60ed40b0418c6a67a9829 (patch)
tree24cd3f23906b7c86dea42f62cf44bbea65113d60 /oox/source/drawingml
parentd043c9e3be791993348afaba6effdc3731f7c33d (diff)
fdo#74792 [DOCX] Grab-bag rels and images for SmartArt
Added support to grab-bag rels and associated Images for data[i].xml, and drawing[i].xml. Added UT for the same Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Reviewed on: https://gerrit.libreoffice.org/8362 Change-Id: I545825f67214f14037ab72b77764a07d575b8b5b
Diffstat (limited to 'oox/source/drawingml')
-rw-r--r--oox/source/drawingml/diagram/diagram.cxx15
-rw-r--r--oox/source/drawingml/diagram/diagram.hxx4
-rw-r--r--oox/source/drawingml/shape.cxx40
3 files changed, 58 insertions, 1 deletions
diff --git a/oox/source/drawingml/diagram/diagram.cxx b/oox/source/drawingml/diagram/diagram.cxx
index da439ea4f6f5..4672a2818cc3 100644
--- a/oox/source/drawingml/diagram/diagram.cxx
+++ b/oox/source/drawingml/diagram/diagram.cxx
@@ -338,6 +338,9 @@ uno::Sequence<beans::PropertyValue> Diagram::getDomsAsPropertyValues() const
{
sal_Int32 length = maMainDomMap.size();
+ if ( 0 < maDataRelsMap.getLength() )
+ ++length;
+
uno::Sequence<beans::PropertyValue> aValue(length);
beans::PropertyValue* pValue = aValue.getArray();
for (DiagramDomMap::const_iterator i = maMainDomMap.begin();
@@ -349,6 +352,13 @@ uno::Sequence<beans::PropertyValue> Diagram::getDomsAsPropertyValues() const
++pValue;
}
+ if ( 0 < maDataRelsMap.getLength() )
+ {
+ pValue[0].Name = OUString("OOXDiagramDataRels");
+ pValue[0].Value = uno::makeAny ( maDataRelsMap );
+ ++pValue;
+ }
+
return aValue;
}
@@ -410,6 +420,11 @@ void loadDiagram( ShapePtr& pShape,
"OOXData",
pDiagram,
xRefDataModel);
+
+ pDiagram->getDataRelsMap() = pShape->resolveRelationshipsOfType( rFilter, xRefDataModel->getFragmentPath(),
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" );
+
+
// Pass the info to pShape
for( ::std::vector<OUString>::const_iterator aIt = pData->getExtDrawings().begin(), aEnd = pData->getExtDrawings().end();
aIt != aEnd; ++aIt )
diff --git a/oox/source/drawingml/diagram/diagram.hxx b/oox/source/drawingml/diagram/diagram.hxx
index 031c66b1cbf6..ae611c9d81f9 100644
--- a/oox/source/drawingml/diagram/diagram.hxx
+++ b/oox/source/drawingml/diagram/diagram.hxx
@@ -157,6 +157,7 @@ typedef boost::shared_ptr< LayoutNode > LayoutNodePtr;
typedef std::map< OUString, uno::Reference<xml::dom::XDocument> > DiagramDomMap;
+typedef uno::Sequence< uno::Sequence< uno::Any > > DiagramRelsMap;
@@ -296,7 +297,7 @@ public:
DiagramColorMap& getColors() { return maColors; }
const DiagramColorMap& getColors() const { return maColors; }
DiagramDomMap & getDomMap() { return maMainDomMap; }
-
+ DiagramRelsMap & getDataRelsMap() { return maDataRelsMap; }
void addTo( const ShapePtr & pShape );
uno::Sequence<beans::PropertyValue> getDomsAsPropertyValues() const;
@@ -308,6 +309,7 @@ private:
DiagramColorMap maColors;
std::map< OUString, ShapePtr > maShapeMap;
DiagramDomMap maMainDomMap;
+ DiagramRelsMap maDataRelsMap;
};
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index ce1d3b6596fd..3a2ebae8ddb1 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1200,6 +1200,46 @@ void Shape::putPropertiesToGrabBag( const Sequence< PropertyValue >& aProperties
}
}
+uno::Sequence< uno::Sequence< uno::Any > > Shape::resolveRelationshipsOfType(core::XmlFilterBase& rFilter, OUString sFragment, OUString sType )
+{
+ uno::Sequence< uno::Sequence< uno::Any > > xRelListTemp;
+ sal_Int32 counter = 0;
+
+ core::RelationsRef xRels = rFilter.importRelations( sFragment );
+ if ( xRels )
+ {
+ core::RelationsRef xImageRels = xRels->getRelationsFromType( sType );
+ if ( xImageRels )
+ {
+ xRelListTemp.realloc( xImageRels->size() );
+ for( ::std::map< OUString, core::Relation >::const_iterator aIt = xImageRels->begin(), aEnd = xImageRels->end(); aIt != aEnd; ++aIt )
+ {
+ uno::Sequence< uno::Any > diagramRelTuple (3);
+ // [0] => RID, [1] => InputStream [2] => extension
+ OUString sRelId = aIt->second.maId;
+
+ diagramRelTuple[0] = uno::makeAny ( sRelId );
+ OUString sTarget = xImageRels->getFragmentPathFromRelId( sRelId );
+
+ uno::Reference< io::XInputStream > xImageInputStrm( rFilter.openInputStream( sTarget ), uno::UNO_SET_THROW );
+ StreamDataSequence dataSeq;
+ if ( rFilter.importBinaryData( dataSeq, sTarget ) )
+ {
+ diagramRelTuple[1] = uno::makeAny( dataSeq );
+ }
+
+ diagramRelTuple[2] = uno::makeAny( sTarget.copy( sTarget.lastIndexOf(".") ) );
+
+ xRelListTemp[counter] = diagramRelTuple;
+ ++counter;
+ }
+ xRelListTemp.realloc(counter);
+
+ }
+ }
+ return xRelListTemp;
+}
+
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */