summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorTor Lillqvist <tml@openoffice.org>2010-03-23 14:27:33 +0200
committerTor Lillqvist <tml@openoffice.org>2010-03-23 14:27:33 +0200
commit805c67052e0f6f09fc6270b89e3ec275ee57a4e3 (patch)
treeda0cf15499c2bb63e33e1781b245b97242fca3bb /oox
parent5223f5f223f28c3795a443de6bb12c60b654f4ad (diff)
ooxml10: oox-custom-shape-polygons.diff from ooo-build
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/oox/drawingml/customshapegeometry.hxx4
-rw-r--r--oox/inc/oox/drawingml/customshapeproperties.hxx4
-rw-r--r--oox/inc/oox/drawingml/shape.hxx5
-rw-r--r--oox/source/drawingml/chart/plotareaconverter.cxx1
-rw-r--r--oox/source/drawingml/customshapegeometry.cxx92
-rw-r--r--oox/source/drawingml/diagram/diagramdefinitioncontext.cxx1
-rw-r--r--oox/source/drawingml/diagram/diagramfragmenthandler.cxx2
-rw-r--r--oox/source/drawingml/graphicshapecontext.cxx1
-rw-r--r--oox/source/drawingml/shape.cxx34
-rw-r--r--oox/source/drawingml/shapepropertiescontext.cxx2
-rw-r--r--oox/source/drawingml/table/tablerowcontext.cxx1
-rw-r--r--oox/source/drawingml/theme.cxx1
-rw-r--r--oox/source/shape/ShapeContextHandler.cxx1
-rw-r--r--oox/source/xls/themebuffer.cxx1
14 files changed, 139 insertions, 11 deletions
diff --git a/oox/inc/oox/drawingml/customshapegeometry.hxx b/oox/inc/oox/drawingml/customshapegeometry.hxx
index 4fec38cf09eb..75a788acb609 100644
--- a/oox/inc/oox/drawingml/customshapegeometry.hxx
+++ b/oox/inc/oox/drawingml/customshapegeometry.hxx
@@ -41,11 +41,11 @@ namespace oox { namespace drawingml {
class CustomShapeGeometryContext : public ::oox::core::ContextHandler
{
public:
- CustomShapeGeometryContext( ::oox::core::ContextHandler& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, CustomShapeProperties& rCustomShapeProperties );
+ CustomShapeGeometryContext( ::oox::core::ContextHandler& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, Shape& rShape );
virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
private:
- CustomShapeProperties& mrCustomShapeProperties;
+ Shape& mrShape;
};
// ---------------------------------------------------------------------
diff --git a/oox/inc/oox/drawingml/customshapeproperties.hxx b/oox/inc/oox/drawingml/customshapeproperties.hxx
index 4e4b82cd5acd..02eb75cee31b 100644
--- a/oox/inc/oox/drawingml/customshapeproperties.hxx
+++ b/oox/inc/oox/drawingml/customshapeproperties.hxx
@@ -32,6 +32,7 @@
#include "oox/drawingml/color.hxx"
#include <com/sun/star/graphic/XGraphic.hpp>
#include <boost/shared_ptr.hpp>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
#include "tokens.hxx"
#include <vector>
#include <map>
@@ -77,11 +78,12 @@ public:
std::vector< CustomShapeGuide >& getAdjustmentValues(){ return maAdjustmentValues; };
double getValue( const std::vector< CustomShapeGuide >&, sal_uInt32 nIndex ) const;
-
+ ::basegfx::B2DPolyPolygon& getPolygon() { return maPolygon; }
private:
rtl::OUString maShapePresetType;
std::vector< CustomShapeGuide > maAdjustmentValues;
+ ::basegfx::B2DPolyPolygon maPolygon;
};
} }
diff --git a/oox/inc/oox/drawingml/shape.hxx b/oox/inc/oox/drawingml/shape.hxx
index dccc9319a84f..89bdab7b59d2 100644
--- a/oox/inc/oox/drawingml/shape.hxx
+++ b/oox/inc/oox/drawingml/shape.hxx
@@ -30,7 +30,7 @@
#include "oox/helper/propertymap.hxx"
#include "oox/drawingml/drawingmltypes.hxx"
-#include "oox/drawingml/customshapeproperties.hxx"
+//#include "oox/drawingml/customshapeproperties.hxx"
#include "oox/drawingml/textliststyle.hxx"
#include <com/sun/star/frame/XModel.hpp>
@@ -42,6 +42,9 @@
namespace oox { namespace drawingml {
+class CustomShapeProperties;
+typedef boost::shared_ptr< CustomShapeProperties > CustomShapePropertiesPtr;
+
typedef ::std::map< ::rtl::OUString, ShapePtr > ShapeIdMap;
struct ShapeStyleRef
diff --git a/oox/source/drawingml/chart/plotareaconverter.cxx b/oox/source/drawingml/chart/plotareaconverter.cxx
index 82a22213b713..f69fde409c0e 100644
--- a/oox/source/drawingml/chart/plotareaconverter.cxx
+++ b/oox/source/drawingml/chart/plotareaconverter.cxx
@@ -27,6 +27,7 @@
#include "oox/drawingml/chart/plotareaconverter.hxx"
#include <com/sun/star/drawing/Direction3D.hpp>
+#include <com/sun/star/drawing/ProjectionMode.hpp>
#include <com/sun/star/drawing/ShadeMode.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
diff --git a/oox/source/drawingml/customshapegeometry.cxx b/oox/source/drawingml/customshapegeometry.cxx
index decb759579f3..79c0c2e28d99 100644
--- a/oox/source/drawingml/customshapegeometry.cxx
+++ b/oox/source/drawingml/customshapegeometry.cxx
@@ -26,10 +26,12 @@
************************************************************************/
#include "oox/drawingml/customshapegeometry.hxx"
+#include "oox/drawingml/customshapeproperties.hxx"
#include <com/sun/star/xml/sax/FastToken.hpp>
#include <comphelper/stl_types.hxx>
#include <hash_map>
+#include <basegfx/polygon/b2dpolygon.hxx>
#include "oox/helper/helper.hxx"
#include "oox/helper/propertymap.hxx"
@@ -37,6 +39,7 @@
#include "tokens.hxx"
using ::rtl::OUString;
+using namespace ::basegfx;
using namespace ::oox::core;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::xml::sax;
@@ -180,6 +183,88 @@ Reference< XFastContextHandler > AdjustmentValueContext::createFastChildContext(
// ---------------------------------------------------------------------
+class PathListContext : public ContextHandler
+{
+public:
+ PathListContext( ContextHandler& rParent, Shape& rShape );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL endFastElement( sal_Int32 aElementToken ) throw (SAXException, RuntimeException);
+
+protected:
+ Shape& mrShape;
+ sal_Int32 maPointToken;
+ ::basegfx::B2DPolygon maPolygon;
+};
+
+PathListContext::PathListContext( ContextHandler& rParent, Shape& rShape )
+: ContextHandler( rParent )
+, mrShape( rShape )
+{
+}
+
+Reference< XFastContextHandler > PathListContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
+{
+ switch( aElementToken ) {
+ case NMSP_DRAWINGML | XML_path:
+ maPolygon.clear();
+ break;
+ case NMSP_DRAWINGML | XML_close:
+ maPolygon.setClosed( true );
+ break;
+ case NMSP_DRAWINGML | XML_pt:
+ {
+ OUString sX, sY;
+
+ sX = xAttribs->getOptionalValue( XML_x );
+ sY = xAttribs->getOptionalValue( XML_y );
+
+ double dX, dY;
+
+ dX = sX.toDouble();
+ dY = sY.toDouble();
+
+ maPolygon.append( B2DPoint ( dX, dY ) );
+ break;
+ }
+ case NMSP_DRAWINGML | XML_lnTo:
+ case NMSP_DRAWINGML | XML_moveTo:
+ maPointToken = aElementToken;
+ break;
+ }
+
+ return this;
+}
+
+void PathListContext::endFastElement( sal_Int32 aElementToken ) throw (SAXException, RuntimeException)
+{
+ switch( aElementToken ) {
+ case NMSP_DRAWINGML|XML_pathLst:
+ {
+ B2DPolyPolygon& rPoly = mrShape.getCustomShapeProperties()->getPolygon();
+ if( rPoly.count() ) {
+ if( rPoly.areControlPointsUsed() ) {
+ if( rPoly.isClosed() )
+ mrShape.setServiceName( "com.sun.star.drawing.ClosedBezierShape" );
+ else
+ mrShape.setServiceName( "com.sun.star.drawing.OpenBezierShape" );
+ } else {
+ if( rPoly.isClosed() )
+ mrShape.setServiceName( "com.sun.star.drawing.PolyPolygonPathShape" );
+ else
+ mrShape.setServiceName( "com.sun.star.drawing.PolyLinePathShape" );
+ }
+ }
+ break;
+ }
+ case NMSP_DRAWINGML|XML_path:
+ if( maPolygon.count() > 0 )
+ mrShape.getCustomShapeProperties()->getPolygon().append( maPolygon );
+ break;
+ }
+}
+
+// ---------------------------------------------------------------------
+
OUString GetShapeType( sal_Int32 nType )
{
OUString sType;
@@ -981,9 +1066,9 @@ static OUString GetTextShapeType( sal_Int32 nType )
// ---------------------------------------------------------------------
// CT_CustomGeometry2D
-CustomShapeGeometryContext::CustomShapeGeometryContext( ContextHandler& rParent, const Reference< XFastAttributeList >& /* xAttribs */, CustomShapeProperties& rCustomShapeProperties )
+CustomShapeGeometryContext::CustomShapeGeometryContext( ContextHandler& rParent, const Reference< XFastAttributeList >& /* xAttribs */, Shape& rShape )
: ContextHandler( rParent )
-, mrCustomShapeProperties( rCustomShapeProperties )
+, mrShape( rShape )
{
}
@@ -997,8 +1082,9 @@ Reference< XFastContextHandler > CustomShapeGeometryContext::createFastChildCont
case NMSP_DRAWINGML|XML_ahLst: // CT_AdjustHandleList adjust handle list
case NMSP_DRAWINGML|XML_cxnLst: // CT_ConnectionSiteList connection site list
case NMSP_DRAWINGML|XML_rect: // CT_GeomRectList geometry rect list
+ break;
case NMSP_DRAWINGML|XML_pathLst: // CT_Path2DList 2d path list
- break;
+ return new PathListContext( *this, mrShape );
}
Reference< XFastContextHandler > xEmpty;
diff --git a/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx b/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx
index 81c0d597afe2..53477211848e 100644
--- a/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx
+++ b/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx
@@ -30,6 +30,7 @@
#include "oox/helper/helper.hxx"
#include "layoutnodecontext.hxx"
#include "oox/drawingml/diagram/datamodelcontext.hxx"
+#include "tokens.hxx"
using namespace ::oox::core;
using namespace ::com::sun::star::uno;
diff --git a/oox/source/drawingml/diagram/diagramfragmenthandler.cxx b/oox/source/drawingml/diagram/diagramfragmenthandler.cxx
index 0cad22660ab6..ac2e755bee40 100644
--- a/oox/source/drawingml/diagram/diagramfragmenthandler.cxx
+++ b/oox/source/drawingml/diagram/diagramfragmenthandler.cxx
@@ -31,7 +31,7 @@
#include "oox/drawingml/diagram/datamodelcontext.hxx"
#include "oox/core/namespaces.hxx"
#include "diagramdefinitioncontext.hxx"
-
+#include "tokens.hxx"
using namespace ::oox::core;
using namespace ::com::sun::star::xml::sax;
diff --git a/oox/source/drawingml/graphicshapecontext.cxx b/oox/source/drawingml/graphicshapecontext.cxx
index a0335fe68ee2..8537017c2118 100644
--- a/oox/source/drawingml/graphicshapecontext.cxx
+++ b/oox/source/drawingml/graphicshapecontext.cxx
@@ -30,6 +30,7 @@
#include <com/sun/star/chart2/XChartDocument.hpp>
#include "oox/drawingml/fillpropertiesgroupcontext.hxx"
+#include "oox/drawingml/customshapeproperties.hxx"
#include "oox/drawingml/diagram/diagramfragmenthandler.hxx"
#include "oox/drawingml/table/tablecontext.hxx"
#include "oox/core/namespaces.hxx"
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index cab64f11c166..fedbee275b93 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -26,6 +26,7 @@
************************************************************************/
#include "oox/drawingml/shape.hxx"
+#include "oox/drawingml/customshapeproperties.hxx"
#include "oox/drawingml/theme.hxx"
#include "oox/drawingml/fillproperties.hxx"
#include "oox/drawingml/lineproperties.hxx"
@@ -214,8 +215,8 @@ void Shape::addChildren(
aIter = rMaster.maChildren.begin();
while( aIter != rMaster.maChildren.end() )
{
- Rectangle aShapeRect;
- Rectangle* pShapeRect = 0;
+ awt::Rectangle aShapeRect;
+ awt::Rectangle* pShapeRect = 0;
if ( ( nGlobalLeft != SAL_MAX_INT32 ) && ( nGlobalRight != SAL_MIN_INT32 ) && ( nGlobalTop != SAL_MAX_INT32 ) && ( nGlobalBottom != SAL_MIN_INT32 ) )
{
sal_Int32 nGlobalWidth = nGlobalRight - nGlobalLeft;
@@ -294,6 +295,35 @@ Reference< XShape > Shape::createAndInsert(
aTransformation.translate( aPosition.X / 360.0, aPosition.Y / 360.0 );
}
+ if ( mpCustomShapePropertiesPtr && mpCustomShapePropertiesPtr->getPolygon().count() )
+ {
+ ::basegfx::B2DPolyPolygon& rPolyPoly = mpCustomShapePropertiesPtr->getPolygon();
+
+ if( rPolyPoly.count() > 0 ) {
+ if( rPolyPoly.areControlPointsUsed() ) {
+ // TODO Beziers
+ } else {
+ uno::Sequence< uno::Sequence< awt::Point > > aPolyPolySequence( rPolyPoly.count() );
+
+ for (sal_uInt32 j = 0; j < rPolyPoly.count(); j++ ) {
+ ::basegfx::B2DPolygon aPoly = rPolyPoly.getB2DPolygon( j );
+
+ // now creating the corresponding PolyPolygon
+ sal_Int32 i, nNumPoints = aPoly.count();
+ uno::Sequence< awt::Point > aPointSequence( nNumPoints );
+ awt::Point* pPoints = aPointSequence.getArray();
+ for( i = 0; i < nNumPoints; ++i )
+ {
+ const ::basegfx::B2DPoint aPoint( aPoly.getB2DPoint( i ) );
+ pPoints[ i ] = awt::Point( static_cast< sal_Int32 >( aPoint.getX() ), static_cast< sal_Int32 >( aPoint.getY() ) );
+ }
+ aPolyPolySequence.getArray()[ j ] = aPointSequence;
+ }
+ maShapeProperties[ PROP_PolyPolygon ] <<= aPolyPolySequence;
+ }
+ }
+ }
+
// special for lineshape
if ( aServiceName == OUString::createFromAscii( "com.sun.star.drawing.LineShape" ) )
{
diff --git a/oox/source/drawingml/shapepropertiescontext.cxx b/oox/source/drawingml/shapepropertiescontext.cxx
index 68c8ed967159..7724ba9b44b2 100644
--- a/oox/source/drawingml/shapepropertiescontext.cxx
+++ b/oox/source/drawingml/shapepropertiescontext.cxx
@@ -74,7 +74,7 @@ Reference< XFastContextHandler > ShapePropertiesContext::createFastChildContext(
// GeometryGroup
case NMSP_DRAWINGML|XML_custGeom: // custom geometry "CT_CustomGeometry2D"
- xRet.set( new CustomShapeGeometryContext( *this, xAttribs, *(mrShape.getCustomShapeProperties()) ) );
+ xRet.set( new CustomShapeGeometryContext( *this, xAttribs, mrShape ) );
break;
diff --git a/oox/source/drawingml/table/tablerowcontext.cxx b/oox/source/drawingml/table/tablerowcontext.cxx
index 17881d89639b..7e0ff052bb4e 100644
--- a/oox/source/drawingml/table/tablerowcontext.cxx
+++ b/oox/source/drawingml/table/tablerowcontext.cxx
@@ -31,6 +31,7 @@
#include "oox/drawingml/table/tablecellcontext.hxx"
#include "oox/drawingml/table/tablerow.hxx"
#include "oox/core/namespaces.hxx"
+#include "tokens.hxx"
using namespace ::oox::core;
using namespace ::com::sun::star;
diff --git a/oox/source/drawingml/theme.cxx b/oox/source/drawingml/theme.cxx
index b37ccdbaf13c..59245201eb61 100644
--- a/oox/source/drawingml/theme.cxx
+++ b/oox/source/drawingml/theme.cxx
@@ -26,6 +26,7 @@
************************************************************************/
#include "oox/drawingml/theme.hxx"
+#include "tokens.hxx"
using ::rtl::OUString;
diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx
index 42efee474d90..05734b65e2a7 100644
--- a/oox/source/shape/ShapeContextHandler.cxx
+++ b/oox/source/shape/ShapeContextHandler.cxx
@@ -29,6 +29,7 @@
#include "oox/vml/vmldrawingfragment.hxx"
#include "oox/vml/vmlshape.hxx"
#include "oox/vml/vmlshapecontainer.hxx"
+#include "tokens.hxx"
#if DEBUG
#include <iostream>
diff --git a/oox/source/xls/themebuffer.cxx b/oox/source/xls/themebuffer.cxx
index 3aabd471742d..23617287dc57 100644
--- a/oox/source/xls/themebuffer.cxx
+++ b/oox/source/xls/themebuffer.cxx
@@ -27,6 +27,7 @@
#include "oox/xls/themebuffer.hxx"
#include "oox/xls/stylesbuffer.hxx"
+#include "tokens.hxx"
using ::oox::drawingml::ClrScheme;