Kaydet (Commit) 60b7f09e authored tarafından Muthu Subramanian's avatar Muthu Subramanian

n#655408: Importing extLst of drawings in diagrams.

data*.xml contains the list of drawings which can be imported
instead. These are easier to import now that we support better
smartart.
üst 18692cc1
......@@ -266,6 +266,7 @@ $(eval $(call gb_Library_add_exception_objects,oox,\
oox/source/ppt/timenode \
oox/source/ppt/timenodelistcontext \
oox/source/ppt/timetargetelementcontext \
oox/source/ppt/extdrawingfragmenthandler \
oox/source/shape/ShapeContextHandler \
oox/source/shape/ShapeFilterBase \
oox/source/token/namespacemap \
......
......@@ -43,7 +43,7 @@ namespace oox { namespace drawingml {
generate and layout the shapes, and push it as children into the
referenced shape.
*/
void loadDiagram( const ShapePtr& pShape,
void loadDiagram( ShapePtr& pShape,
core::XmlFilterBase& rFilter,
const ::rtl::OUString& rDataModelPath,
const ::rtl::OUString& rLayoutPath,
......
......@@ -107,6 +107,7 @@ public:
void setChildPosition( com::sun::star::awt::Point nPosition ){ maChPosition = nPosition; }
void setChildSize( com::sun::star::awt::Size aSize ){ maChSize = aSize; }
void moveAllToPosition( const com::sun::star::awt::Point &rPoint );
void setPosition( com::sun::star::awt::Point nPosition ){ maPosition = nPosition; }
const com::sun::star::awt::Point& getPosition() const { return maPosition; }
......@@ -173,6 +174,9 @@ public:
getXShape() const { return mxShape; }
virtual void applyShapeReference( const Shape& rReferencedShape );
const ::std::vector<rtl::OUString>&
getExtDrawings() { return maExtDrawings; }
void addExtDrawingRelId( const ::rtl::OUString &rRelId ) { maExtDrawings.push_back( rRelId ); }
protected:
......@@ -233,6 +237,7 @@ protected:
com::sun::star::awt::Size maSize;
com::sun::star::awt::Point maPosition;
::std::vector<rtl::OUString> maExtDrawings;
private:
enum FrameType
......
......@@ -38,6 +38,7 @@ class PPTShapeGroupContext : public ::oox::drawingml::ShapeGroupContext
{
SlidePersistPtr mpSlidePersistPtr;
ShapeLocation meShapeLocation;
oox::drawingml::ShapePtr pGraphicShape;
public:
PPTShapeGroupContext(
......@@ -50,6 +51,8 @@ public:
virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL
createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
protected:
};
......
......@@ -148,7 +148,8 @@ namespace
"http://schemas.microsoft.com/office/excel/2006/main",
"http://schemas.openxmlformats.org/presentationml/2006/main",
"http://schemas.openxmlformats.org/markup-compatibility/2006",
"http://schemas.openxmlformats.org/spreadsheetml/2006/main/v2"
"http://schemas.openxmlformats.org/spreadsheetml/2006/main/v2",
"http://schemas.microsoft.com/office/drawing/2008/diagram"
};
static const sal_Int32 namespaceIds[] = {
......@@ -170,7 +171,8 @@ namespace
NMSP_ax,
NMSP_xm,
NMSP_mce,
NMSP_mceTest
NMSP_mceTest,
NMSP_dsp
};
Sequence< Pair< OUString, sal_Int32 > > aRet(STATIC_ARRAY_SIZE(namespaceIds));
......
......@@ -399,10 +399,9 @@ DataModelContext::~DataModelContext()
mpDataModel->dump();
}
Reference< XFastContextHandler > SAL_CALL
DataModelContext::createFastChildContext( ::sal_Int32 aElement,
const Reference< XFastAttributeList >& /*xAttribs*/ )
const Reference< XFastAttributeList >& xAttribs )
throw ( SAXException, RuntimeException)
{
Reference< XFastContextHandler > xRet;
......@@ -426,7 +425,11 @@ DataModelContext::createFastChildContext( ::sal_Int32 aElement,
// TODO
return xRet;
case DGM_TOKEN( extLst ):
return xRet;
case A_TOKEN( ext ):
break;
case DSP_TOKEN( dataModelExt ):
mpDataModel->getExtDrawings().push_back( xAttribs->getOptionalValue( XML_relId ) );
break;
default:
break;
}
......
......@@ -40,6 +40,8 @@
#include "oox/drawingml/textrun.hxx"
#include "oox/drawingml/diagram/diagram.hxx"
#include "oox/drawingml/fillproperties.hxx"
#include "oox/ppt/pptshapegroupcontext.hxx"
#include "oox/ppt/pptshape.hxx"
#include "diagramlayoutatoms.hxx"
#include "diagramfragmenthandler.hxx"
......@@ -54,7 +56,6 @@ namespace oox { namespace drawingml {
namespace dgm {
void Connection::dump()
{
OSL_TRACE("dgm: cnx modelId %s, srcId %s, dstId %s, parTransId %s, presId %s, sibTransId %s, srcOrd %d, dstOrd %d",
......@@ -374,7 +375,7 @@ void importFragment( core::XmlFilterBase& rFilter,
rFilter.importFragment( rxHandler, xSerializer );
}
void loadDiagram( const ShapePtr& pShape,
void loadDiagram( ShapePtr& pShape,
core::XmlFilterBase& rFilter,
const ::rtl::OUString& rDataModelPath,
const ::rtl::OUString& rLayoutPath,
......@@ -400,6 +401,10 @@ void loadDiagram( const ShapePtr& pShape,
"DiagramData",
pShape,
xRef);
// Pass the info to pShape
for( ::std::vector<OUString>::const_iterator aIt = pData->getExtDrawings().begin(), aEnd = pData->getExtDrawings().end();
aIt != aEnd; ++aIt )
pShape->addExtDrawingRelId( *aIt );
}
// layout
......
......@@ -166,6 +166,7 @@ typedef boost::shared_ptr< LayoutNode > LayoutNodePtr;
class DiagramData
{
public:
::std::vector<rtl::OUString> maExtDrawings;
typedef std::map< rtl::OUString, dgm::Point* > PointNameMap;
typedef std::map< rtl::OUString,
std::vector<dgm::Point*> > PointsNameMap;
......@@ -188,6 +189,8 @@ public:
{ return maPointNameMap; }
PointsNameMap & getPointsPresNameMap()
{ return maPointsPresNameMap; }
::std::vector<rtl::OUString> &getExtDrawings()
{ return maExtDrawings; }
void dump();
private:
FillPropertiesPtr mpFillProperties;
......
......@@ -591,6 +591,13 @@ TextBodyPtr Shape::getTextBody()
return mpTextBody;
}
void Shape::moveAllToPosition( const Point &rPoint )
{
setPosition( Point( rPoint.X + maPosition.X, rPoint.Y + maPosition.Y ) );
for( ::std::vector<ShapePtr>::const_iterator aIt = maChildren.begin(), aEnd = maChildren.end();aIt != aEnd; ++aIt )
(*aIt)->moveAllToPosition( rPoint );
}
void Shape::setMasterTextListStyle( const TextListStylePtr& pMasterTextListStyle )
{
OSL_TRACE("set master text list style to shape id: %s", rtl::OUStringToOString(msId, RTL_TEXTENCODING_UTF8 ).getStr());
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Initial Developer of the Original Code is
* Novell, Inc.
*
* Portions created by the Initial Developer are Copyright (C) 2011 the
* Initial Developer. All Rights Reserved.
*
* Contributor(s): Muthu Subramanian <sumuthu@suse.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
* instead of those above.
*/
#include "extdrawingfragmenthandler.hxx"
using namespace ::oox::core;
using namespace ::com::sun::star::xml::sax;
using namespace ::com::sun::star::uno;
using ::rtl::OUString;
namespace oox { namespace ppt {
ExtDrawingFragmentHandler::ExtDrawingFragmentHandler( XmlFilterBase& rFilter,
const OUString& rFragmentPath,
const oox::ppt::SlidePersistPtr pSlidePersistPtr,
const oox::ppt::ShapeLocation eShapeLocation,
oox::drawingml::ShapePtr pMasterShapePtr,
oox::drawingml::ShapePtr pGroupShapePtr,
oox::drawingml::ShapePtr pShapePtr)
throw( )
: FragmentHandler( rFilter, rFragmentPath ),
mpSlidePersistPtr (pSlidePersistPtr ),
meShapeLocation( eShapeLocation ),
mpMasterShapePtr( pMasterShapePtr ),
mpGroupShapePtr( pGroupShapePtr ),
mpOrgShapePtr( pShapePtr )
{
}
ExtDrawingFragmentHandler::~ExtDrawingFragmentHandler( ) throw ()
{
}
Reference< XFastContextHandler > SAL_CALL
ExtDrawingFragmentHandler::createFastChildContext( ::sal_Int32 aElement,
const Reference< XFastAttributeList >& )
throw ( SAXException, RuntimeException)
{
Reference< XFastContextHandler > xRet;
switch( aElement )
{
case DSP_TOKEN( drawing ):
break;
case DSP_TOKEN( spTree ):
mpShapePtr = oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GroupShape" ) );
xRet.set( new PPTShapeGroupContext(
*this, mpSlidePersistPtr, meShapeLocation, mpSlidePersistPtr->getShapes(),
mpShapePtr ) );
break;
default:
break;
}
if( !xRet.is() )
xRet = getFastContextHandler();
return xRet;
}
void SAL_CALL ExtDrawingFragmentHandler::endDocument() throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException)
{
mpShapePtr->moveAllToPosition( mpOrgShapePtr->getPosition() );
mpShapePtr->setName( mpOrgShapePtr->getName() );
}
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Initial Developer of the Original Code is
* Novell, Inc.
*
* Portions created by the Initial Developer are Copyright (C) 2011 the
* Initial Developer. All Rights Reserved.
*
* Contributor(s): Muthu Subramanian <sumuthu@suse.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
* instead of those above.
*/
#ifndef OOX_PPT_EXTDRAWINGFRAGMENTHANDLER
#define OOX_PPT_EXTDRAWINGFRAGMENTHANDLER
#include "oox/core/fragmenthandler.hxx"
#include "oox/core/fragmenthandler2.hxx"
#include "oox/drawingml/shapegroupcontext.hxx"
#include "oox/ppt/slidepersist.hxx"
#include "oox/ppt/pptshapegroupcontext.hxx"
#include "oox/ppt/pptshape.hxx"
namespace oox { namespace ppt {
class ExtDrawingFragmentHandler : public ::oox::core::FragmentHandler
{
public:
ExtDrawingFragmentHandler( oox::core::XmlFilterBase& rFilter, const ::rtl::OUString& rFragmentPath,
const oox::ppt::SlidePersistPtr pSlidePersistPtr,
const oox::ppt::ShapeLocation eShapeLocation,
oox::drawingml::ShapePtr pMasterShapePtr,
oox::drawingml::ShapePtr pGroupShapePtr,
oox::drawingml::ShapePtr pShapePtr ) throw();
virtual ~ExtDrawingFragmentHandler() throw();
virtual void SAL_CALL endDocument() throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
private:
const oox::ppt::SlidePersistPtr mpSlidePersistPtr;
const oox::ppt::ShapeLocation meShapeLocation;
oox::drawingml::ShapePtr mpMasterShapePtr;
oox::drawingml::ShapePtr mpGroupShapePtr;
oox::drawingml::ShapePtr mpOrgShapePtr; // Original Shape data, if any
oox::drawingml::ShapePtr mpShapePtr;
};
} }
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -96,6 +96,8 @@ oox::drawingml::ShapePtr findPlaceholder( sal_Int32 nFirstPlaceholder, sal_Int32
Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
{
Reference< XFastContextHandler > xRet;
if( getNamespace( aElementToken ) == NMSP_dsp )
aElementToken = NMSP_ppt | getBaseToken( aElementToken );
switch( aElementToken )
{
......
......@@ -41,6 +41,7 @@
#include "oox/drawingml/customshapegeometry.hxx"
#include "oox/drawingml/textbodycontext.hxx"
#include "oox/drawingml/connectorshapecontext.hxx"
#include "extdrawingfragmenthandler.hxx"
using rtl::OUString;
using namespace oox::core;
......@@ -62,12 +63,15 @@ PPTShapeGroupContext::PPTShapeGroupContext(
: ShapeGroupContext( rParent, pMasterShapePtr, pGroupShapePtr )
, mpSlidePersistPtr( pSlidePersistPtr )
, meShapeLocation( eShapeLocation )
, pGraphicShape( (PPTShape *)NULL )
{
}
Reference< XFastContextHandler > PPTShapeGroupContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
{
Reference< XFastContextHandler > xRet;
if( getNamespace( aElementToken ) == NMSP_dsp )
aElementToken = NMSP_ppt | getBaseToken( aElementToken );
switch( aElementToken )
{
......@@ -110,7 +114,10 @@ Reference< XFastContextHandler > PPTShapeGroupContext::createFastChildContext( s
xRet.set( new PPTGraphicShapeContext( *this, mpSlidePersistPtr, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GraphicObjectShape" ) ) ) );
break;
case PPT_TOKEN( graphicFrame ): // CT_GraphicalObjectFrame
xRet.set( new oox::drawingml::GraphicalObjectFrameContext( *this, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.OLE2Shape" ) ), true ) );
{
pGraphicShape = oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.OLE2Shape" ) );
xRet.set( new oox::drawingml::GraphicalObjectFrameContext( *this, mpGroupShapePtr, pGraphicShape, true ) );
}
break;
}
......@@ -121,6 +128,25 @@ Reference< XFastContextHandler > PPTShapeGroupContext::createFastChildContext( s
return xRet;
}
void PPTShapeGroupContext::endFastElement( sal_Int32 nElement ) throw (SAXException, RuntimeException)
{
if( nElement == PPT_TOKEN( spTree ) && pGraphicShape )
{
for( ::std::vector<OUString>::const_iterator aIt = pGraphicShape->getExtDrawings().begin(), aEnd = pGraphicShape->getExtDrawings().end();
aIt != aEnd; ++aIt )
{
getFilter().importFragment( new ExtDrawingFragmentHandler( getFilter(), getFragmentPathFromRelId( *aIt ),
mpSlidePersistPtr,
meShapeLocation,
mpMasterShapePtr,
mpGroupShapePtr,
pGraphicShape ) );
}
pGraphicShape = oox::drawingml::ShapePtr( (PPTShape *)NULL );
}
}
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -32,6 +32,7 @@ inline sal_Int32 getNamespace( sal_Int32 nToken ) { return nToken & NMSP_MASK; }
#define XM_TOKEN( token ) OOX_TOKEN( xm, token )
#define XML_TOKEN( token ) OOX_TOKEN( xml, token )
#define VMLPPT_TOKEN( token ) OOX_TOKEN( vmlPowerpoint, token )
#define DSP_TOKEN( token ) OOX_TOKEN( dsp, token )
// ============================================================================
......
......@@ -28,6 +28,7 @@ ppt http://schemas.openxmlformats.org/presentationml/2006/ma
# drawing ---------------------------------------------------------------------
dml http://schemas.openxmlformats.org/drawingml/2006/main
dsp http://schemas.microsoft.com/office/drawing/2008/diagram
dmlChart http://schemas.openxmlformats.org/drawingml/2006/chart
dmlChartDr http://schemas.openxmlformats.org/drawingml/2006/chartDrawing
dmlDiagram http://schemas.openxmlformats.org/drawingml/2006/diagram
......
......@@ -1592,6 +1592,7 @@ dataExtractLoad
dataField
dataFields
dataModel
dataModelExt
dataOnRows
dataOnly
dataPosition
......@@ -4168,6 +4169,7 @@ regroupid
regrouptable
regular
rel
relId
relIds
relOff
relSizeAnchor
......
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