summaryrefslogtreecommitdiff
path: root/oox/source/drawingml
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2008-01-17 07:06:10 +0000
committerRüdiger Timm <rt@openoffice.org>2008-01-17 07:06:10 +0000
commit3381981e76873304b171f7df900561dac681d2af (patch)
treef496d5a2006e8719b5783d5a8966a05858ed3014 /oox/source/drawingml
parent90e7bde2a1f3dd8c81e947578f14f40059961740 (diff)
#i10000# Bring module to HEAD.
Diffstat (limited to 'oox/source/drawingml')
-rw-r--r--oox/source/drawingml/clrscheme.cxx104
-rw-r--r--oox/source/drawingml/clrschemecontext.cxx137
-rw-r--r--oox/source/drawingml/color.cxx64
-rw-r--r--oox/source/drawingml/colorchoicecontext.cxx146
-rw-r--r--oox/source/drawingml/connectorshapecontext.cxx89
-rw-r--r--oox/source/drawingml/customshapegeometry.cxx1071
-rw-r--r--oox/source/drawingml/customshapeproperties.cxx156
-rw-r--r--oox/source/drawingml/diagram/datamodelcontext.cxx336
-rw-r--r--oox/source/drawingml/diagram/diagram.cxx130
-rw-r--r--oox/source/drawingml/diagram/diagramdefinitioncontext.cxx124
-rw-r--r--oox/source/drawingml/diagram/diagramdefinitioncontext.hxx60
-rw-r--r--oox/source/drawingml/diagram/diagramfragmenthandler.cxx233
-rw-r--r--oox/source/drawingml/diagram/diagramlayoutatoms.cxx149
-rw-r--r--oox/source/drawingml/diagram/layoutnodecontext.cxx368
-rw-r--r--oox/source/drawingml/diagram/layoutnodecontext.hxx61
-rw-r--r--oox/source/drawingml/diagram/makefile.mk61
-rw-r--r--oox/source/drawingml/drawingmltypes.cxx433
-rw-r--r--oox/source/drawingml/embeddedwavaudiofile.cxx64
-rw-r--r--oox/source/drawingml/fillproperties.cxx117
-rw-r--r--oox/source/drawingml/fillpropertiesgroupcontext.cxx457
-rw-r--r--oox/source/drawingml/graphicshapecontext.cxx335
-rw-r--r--oox/source/drawingml/hyperlinkcontext.cxx121
-rw-r--r--oox/source/drawingml/hyperlinkcontext.hxx67
-rw-r--r--oox/source/drawingml/lineproperties.cxx349
-rw-r--r--oox/source/drawingml/linepropertiescontext.cxx157
-rw-r--r--oox/source/drawingml/makefile.mk96
-rw-r--r--oox/source/drawingml/objectdefaultcontext.cxx81
-rw-r--r--oox/source/drawingml/shape.cxx489
-rw-r--r--oox/source/drawingml/shapecontext.cxx130
-rw-r--r--oox/source/drawingml/shapegroupcontext.cxx125
-rw-r--r--oox/source/drawingml/shapepropertiescontext.cxx140
-rw-r--r--oox/source/drawingml/shapestylecontext.cxx148
-rw-r--r--oox/source/drawingml/spdefcontext.cxx83
-rw-r--r--oox/source/drawingml/textbody.cxx86
-rw-r--r--oox/source/drawingml/textbodycontext.cxx224
-rw-r--r--oox/source/drawingml/textbodypropertiescontext.cxx161
-rw-r--r--oox/source/drawingml/textcharacterproperties.cxx135
-rw-r--r--oox/source/drawingml/textcharacterpropertiescontext.cxx282
-rw-r--r--oox/source/drawingml/textfield.cxx196
-rw-r--r--oox/source/drawingml/textfieldcontext.cxx107
-rw-r--r--oox/source/drawingml/textliststyle.cxx78
-rw-r--r--oox/source/drawingml/textliststylecontext.cxx120
-rw-r--r--oox/source/drawingml/textparagraph.cxx127
-rw-r--r--oox/source/drawingml/textparagraphproperties.cxx419
-rw-r--r--oox/source/drawingml/textparagraphpropertiescontext.cxx306
-rw-r--r--oox/source/drawingml/textrun.cxx120
-rw-r--r--oox/source/drawingml/textspacingcontext.cxx87
-rw-r--r--oox/source/drawingml/textspacingcontext.hxx69
-rw-r--r--oox/source/drawingml/texttabstoplistcontext.cxx106
-rw-r--r--oox/source/drawingml/texttabstoplistcontext.hxx69
-rw-r--r--oox/source/drawingml/theme.cxx55
-rw-r--r--oox/source/drawingml/themeelementscontext.cxx234
-rw-r--r--oox/source/drawingml/themefragmenthandler.cxx108
53 files changed, 9770 insertions, 0 deletions
diff --git a/oox/source/drawingml/clrscheme.cxx b/oox/source/drawingml/clrscheme.cxx
new file mode 100644
index 000000000000..50c0ea07d417
--- /dev/null
+++ b/oox/source/drawingml/clrscheme.cxx
@@ -0,0 +1,104 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: clrscheme.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/clrscheme.hxx"
+#include "tokens.hxx"
+
+namespace oox { namespace drawingml {
+
+sal_Bool ClrMap::getColorMap( sal_Int32& nClrToken )
+{
+ sal_Int32 nMapped = 0;
+ std::map < sal_Int32, sal_Int32 >::const_iterator aIter( maClrMap.find( nClrToken ) );
+ if ( aIter != maClrMap.end() )
+ nMapped = (*aIter).second;
+ if ( nMapped )
+ {
+ nClrToken = nMapped;
+ return sal_True;
+ }
+ else
+ return sal_False;
+}
+
+void ClrMap::setColorMap( sal_Int32 nClrToken, sal_Int32 nMappedClrToken )
+{
+ maClrMap[ nClrToken ] = nMappedClrToken;
+}
+
+//-----------------------------------------------------------------------------------------
+
+ClrScheme::ClrScheme()
+{
+}
+ClrScheme::~ClrScheme()
+{
+}
+
+sal_Bool ClrScheme::getColor( sal_Int32 nSchemeClrToken, sal_Int32& rColor ) const
+{
+ switch( nSchemeClrToken )
+ {
+ case XML_bg1 : nSchemeClrToken = XML_dk1; break;
+ case XML_bg2 : nSchemeClrToken = XML_dk2; break;
+ case XML_tx1 : nSchemeClrToken = XML_lt1; break;
+ case XML_tx2 : nSchemeClrToken = XML_lt2; break;
+ }
+ std::map < sal_Int32, sal_Int32 >::const_iterator aIter( maClrScheme.find( nSchemeClrToken ) );
+ if ( aIter != maClrScheme.end() )
+ rColor = (*aIter).second;
+ return aIter != maClrScheme.end();
+}
+
+void ClrScheme::setColor( sal_Int32 nSchemeClrToken, sal_Int32 nColor )
+{
+ maClrScheme[ nSchemeClrToken ] = nColor;
+}
+
+// static
+bool ClrScheme::getSystemColor( const sal_Int32 nSysClrToken, sal_Int32& rColor )
+{
+ //! TODO: get colors from system
+ switch( nSysClrToken )
+ {
+ case XML_window: rColor = 0xFFFFFF; break;
+ case XML_windowText: rColor = 0x000000; break;
+ //! TODO: more colors to follow... (chapter 5.1.12.58)
+ default: return false;
+ }
+ return true;
+}
+
+} }
diff --git a/oox/source/drawingml/clrschemecontext.cxx b/oox/source/drawingml/clrschemecontext.cxx
new file mode 100644
index 000000000000..a6a5373d772a
--- /dev/null
+++ b/oox/source/drawingml/clrschemecontext.cxx
@@ -0,0 +1,137 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: clrschemecontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/clrschemecontext.hxx"
+#include "oox/drawingml/colorchoicecontext.hxx"
+#include "oox/core/namespaces.hxx"
+#include "tokens.hxx"
+
+using namespace ::oox::core;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+
+namespace oox { namespace drawingml {
+
+static void setClrMap( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes,
+ oox::drawingml::ClrMap& rClrMap, sal_Int32 nToken )
+{
+ if ( xAttributes->hasAttribute( nToken ) )
+ {
+ sal_Int32 nMappedToken = xAttributes->getOptionalValueToken( nToken, 0 );
+ rClrMap.setColorMap( nToken, nMappedToken );
+ }
+}
+
+clrMapContext::clrMapContext( const FragmentHandlerRef& xHandler,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, oox::drawingml::ClrMap& rClrMap )
+: Context( xHandler )
+{
+ setClrMap( xAttributes, rClrMap, XML_bg1 );
+ setClrMap( xAttributes, rClrMap, XML_tx1 );
+ setClrMap( xAttributes, rClrMap, XML_bg2 );
+ setClrMap( xAttributes, rClrMap, XML_tx2 );
+ setClrMap( xAttributes, rClrMap, XML_accent1 );
+ setClrMap( xAttributes, rClrMap, XML_accent2 );
+ setClrMap( xAttributes, rClrMap, XML_accent3 );
+ setClrMap( xAttributes, rClrMap, XML_accent4 );
+ setClrMap( xAttributes, rClrMap, XML_accent5 );
+ setClrMap( xAttributes, rClrMap, XML_accent6 );
+ setClrMap( xAttributes, rClrMap, XML_hlink );
+ setClrMap( xAttributes, rClrMap, XML_folHlink );
+}
+
+Reference< XFastContextHandler > clrMapContext::createFastChildContext( sal_Int32 /* aElementToken */, const Reference< XFastAttributeList >& /* xAttribs */ )
+ throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+ return xRet;
+}
+
+clrSchemeContext::clrSchemeContext( const ::oox::core::FragmentHandlerRef& xHandler, const oox::drawingml::ClrSchemePtr pClrSchemePtr )
+: Context( xHandler )
+, mpClrSchemePtr( pClrSchemePtr )
+{
+}
+
+void clrSchemeContext::startFastElement( sal_Int32 /* aElementToken */, const Reference< XFastAttributeList >& /* xAttribs */ ) throw (SAXException, RuntimeException)
+{
+}
+
+void clrSchemeContext::endFastElement( sal_Int32 aElementToken ) throw (SAXException, RuntimeException)
+{
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_dk1:
+ case NMSP_DRAWINGML|XML_lt1:
+ case NMSP_DRAWINGML|XML_dk2:
+ case NMSP_DRAWINGML|XML_lt2:
+ case NMSP_DRAWINGML|XML_accent1:
+ case NMSP_DRAWINGML|XML_accent2:
+ case NMSP_DRAWINGML|XML_accent3:
+ case NMSP_DRAWINGML|XML_accent4:
+ case NMSP_DRAWINGML|XML_accent5:
+ case NMSP_DRAWINGML|XML_accent6:
+ case NMSP_DRAWINGML|XML_hlink:
+ case NMSP_DRAWINGML|XML_folHlink:
+ {
+ mpClrSchemePtr->setColor( aElementToken & 0xffff, maColor.getColor( *getHandler()->getFilter().get() ) );
+ break;
+ }
+ }
+}
+
+Reference< XFastContextHandler > clrSchemeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& /* xAttribs */ ) throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_scrgbClr: // CT_ScRgbColor
+ case NMSP_DRAWINGML|XML_srgbClr: // CT_SRgbColor
+ case NMSP_DRAWINGML|XML_hslClr: // CT_HslColor
+ case NMSP_DRAWINGML|XML_sysClr: // CT_SystemColor
+// case NMSP_DRAWINGML|XML_schemeClr: // CT_SchemeColor
+ case NMSP_DRAWINGML|XML_prstClr: // CT_PresetColor
+ {
+ xRet.set( new colorChoiceContext( getHandler(), maColor ) );
+ break;
+ }
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+
+ return xRet;
+}
+
+} }
diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx
new file mode 100644
index 000000000000..9b27916d83ca
--- /dev/null
+++ b/oox/source/drawingml/color.cxx
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: color.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/color.hxx"
+#include "oox/core/namespaces.hxx"
+#include "tokens.hxx"
+
+using namespace ::oox::core;
+
+namespace oox { namespace drawingml {
+
+Color::Color()
+: mnColor( 0 )
+, mnAlpha( 0 )
+, mbUsed( sal_False )
+, mbSchemeColor( sal_False )
+, mbAlphaColor( sal_False )
+{
+}
+Color::~Color()
+{
+}
+sal_Int32 Color::getColor( const oox::core::XmlFilterBase& rFilterBase ) const
+{
+ return mbSchemeColor ? rFilterBase.getSchemeClr( mnColor ) : mnColor;
+}
+sal_Int32 Color::getAlpha() const
+{
+ return mnAlpha;
+}
+
+} }
diff --git a/oox/source/drawingml/colorchoicecontext.cxx b/oox/source/drawingml/colorchoicecontext.cxx
new file mode 100644
index 000000000000..6f5572fcaefa
--- /dev/null
+++ b/oox/source/drawingml/colorchoicecontext.cxx
@@ -0,0 +1,146 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: colorchoicecontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/colorchoicecontext.hxx"
+#include "oox/drawingml/clrscheme.hxx"
+#include "oox/drawingml/drawingmltypes.hxx"
+#include "oox/core/namespaces.hxx"
+#include "tokens.hxx"
+
+using namespace ::oox::core;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+
+namespace oox { namespace drawingml {
+
+colorChoiceContext::colorChoiceContext( const ::oox::core::FragmentHandlerRef& xHandler, ::oox::drawingml::Color& rColor )
+: Context( xHandler )
+, mrColor( rColor )
+{
+}
+
+void colorChoiceContext::startFastElement( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
+{
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_scrgbClr: // CT_ScRgbColor
+ {
+ sal_Int32 r = ((xAttribs->getOptionalValue( XML_r ).toInt32() * 256) / 1000) & 0xff;
+ sal_Int32 g = ((xAttribs->getOptionalValue( XML_g ).toInt32() * 256) / 1000) & 0xff;
+ sal_Int32 b = ((xAttribs->getOptionalValue( XML_b ).toInt32() * 256) / 1000) & 0xff;
+ mrColor.mnColor = (r << 16) | (g << 8) | b;
+ mrColor.mbUsed = sal_True;
+ break;
+ }
+ case NMSP_DRAWINGML|XML_srgbClr: // CT_SRgbColor
+ {
+ mrColor.mnColor = xAttribs->getOptionalValue( XML_val ).toInt32( 16 );
+ mrColor.mbUsed = sal_True;
+ break;
+ }
+ case NMSP_DRAWINGML|XML_hslClr: // CT_HslColor
+ // todo
+ break;
+ case NMSP_DRAWINGML|XML_sysClr: // CT_SystemColor
+ sal_Int32 nColor;
+ if( !ClrScheme::getSystemColor( xAttribs->getOptionalValueToken( XML_val, XML_TOKEN_INVALID ), nColor ) )
+ nColor = xAttribs->getOptionalValue( XML_lastClr ).toInt32( 16 );
+ mrColor.mnColor = nColor;
+ mrColor.mbUsed = sal_True;
+ break;
+ case NMSP_DRAWINGML|XML_schemeClr: // CT_SchemeColor
+ {
+ mrColor.mnColor = xAttribs->getOptionalValueToken( XML_val, XML_nothing );
+ mrColor.mbUsed = sal_True;
+ mrColor.mbSchemeColor = sal_True;
+ break;
+ }
+ case NMSP_DRAWINGML|XML_prstClr: // CT_PresetColor
+ // todo
+ break;
+
+ }
+}
+
+Reference< XFastContextHandler > colorChoiceContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& rxAttribs ) throw (SAXException, RuntimeException)
+{
+ // colorTransformGroup
+
+ // color should be available as rgb in member mnColor already, now modify it depending on
+ // the transformation elements
+
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_tint: // CT_PositiveFixedPercentage
+ case NMSP_DRAWINGML|XML_shade: // CT_PositiveFixedPercentage
+ case NMSP_DRAWINGML|XML_comp: // CT_ComplementTransform
+ case NMSP_DRAWINGML|XML_inv: // CT_InverseTransform
+ case NMSP_DRAWINGML|XML_gray: // CT_GrayscaleTransform
+ break;
+ case NMSP_DRAWINGML|XML_alpha: // CT_PositiveFixedPercentage
+ {
+ mrColor.mbUsed = sal_True;
+ mrColor.mbAlphaColor = sal_True;
+ mrColor.mnAlpha = GetPercent( rxAttribs->getOptionalValue( XML_val ) );
+ }
+ break;
+ case NMSP_DRAWINGML|XML_alphaOff: // CT_FixedPercentage
+ case NMSP_DRAWINGML|XML_alphaMod: // CT_PositivePercentage
+ case NMSP_DRAWINGML|XML_hue: // CT_PositiveFixedAngle
+ case NMSP_DRAWINGML|XML_hueOff: // CT_Angle
+ case NMSP_DRAWINGML|XML_hueMod: // CT_PositivePercentage
+ case NMSP_DRAWINGML|XML_sat: // CT_Percentage
+ case NMSP_DRAWINGML|XML_satOff: // CT_Percentage
+ case NMSP_DRAWINGML|XML_satMod: // CT_Percentage
+ case NMSP_DRAWINGML|XML_lum: // CT_Percentage
+ case NMSP_DRAWINGML|XML_lumOff: // CT_Percentage
+ case NMSP_DRAWINGML|XML_lumMod: // CT_Percentage
+ case NMSP_DRAWINGML|XML_red: // CT_Percentage
+ case NMSP_DRAWINGML|XML_redOff: // CT_Percentage
+ case NMSP_DRAWINGML|XML_redMod: // CT_Percentage
+ case NMSP_DRAWINGML|XML_green: // CT_Percentage
+ case NMSP_DRAWINGML|XML_greenOff: // CT_Percentage
+ case NMSP_DRAWINGML|XML_greenMod: // CT_Percentage
+ case NMSP_DRAWINGML|XML_blue: // CT_Percentage
+ case NMSP_DRAWINGML|XML_blueOff: // CT_Percentage
+ case NMSP_DRAWINGML|XML_blueMod: // CT_Percentage
+ break;
+ }
+ return this;
+}
+
+
+} }
diff --git a/oox/source/drawingml/connectorshapecontext.cxx b/oox/source/drawingml/connectorshapecontext.cxx
new file mode 100644
index 000000000000..447065f56cd9
--- /dev/null
+++ b/oox/source/drawingml/connectorshapecontext.cxx
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: connectorshapecontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include <com/sun/star/xml/sax/FastToken.hpp>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+
+#include "oox/drawingml/connectorshapecontext.hxx"
+#include "oox/drawingml/graphicshapecontext.hxx"
+#include "oox/drawingml/lineproperties.hxx"
+#include "oox/drawingml/drawingmltypes.hxx"
+#include "oox/drawingml/customshapegeometry.hxx"
+#include "oox/drawingml/textbodycontext.hxx"
+#include "oox/core/namespaces.hxx"
+#include "tokens.hxx"
+
+using rtl::OUString;
+using namespace oox::core;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::drawing;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::xml::sax;
+
+namespace oox { namespace drawingml {
+
+ConnectorShapeContext::ConnectorShapeContext( const FragmentHandlerRef& xHandler,
+ sal_Int32 /* aElementToken */, ShapePtr pMasterShapePtr, ShapePtr pGroupShapePtr )
+: ShapeContext( xHandler, pMasterShapePtr, pGroupShapePtr )
+{
+}
+
+ConnectorShapeContext::~ConnectorShapeContext()
+{
+}
+
+Reference< XFastContextHandler > ConnectorShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElementToken &(~NMSP_MASK) )
+ {
+ case XML_nvCxnSpPr :
+ break;
+
+ default:
+ xRet = ShapeContext::createFastChildContext( aElementToken, xAttribs );
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+
+
+ return xRet;
+}
+
+} }
diff --git a/oox/source/drawingml/customshapegeometry.cxx b/oox/source/drawingml/customshapegeometry.cxx
new file mode 100644
index 000000000000..3eeeabd77e0e
--- /dev/null
+++ b/oox/source/drawingml/customshapegeometry.cxx
@@ -0,0 +1,1071 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: customshapegeometry.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include <com/sun/star/xml/sax/FastToken.hpp>
+
+#include "oox/helper/propertymap.hxx"
+#include "oox/core/namespaces.hxx"
+#include "oox/drawingml/customshapegeometry.hxx"
+#include "tokens.hxx"
+#ifndef _UTL_STLTYPES_HXX_
+#include <comphelper/stl_types.hxx>
+#endif
+#include <hash_map>
+
+using ::rtl::OUString;
+using ::com::sun::star::beans::NamedValue;
+using namespace ::oox::core;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+
+namespace oox { namespace drawingml {
+
+enum FormularCommand
+{
+ FC_MULDIV = 0,
+ FC_PLUSMINUS,
+ FC_PLUSDIV,
+ FC_IFELSE,
+ FC_ABS,
+ FC_AT2,
+ FC_CAT2,
+ FC_COS,
+ FC_MAX,
+ FC_MIN,
+ FC_MOD,
+ FC_PIN,
+ FC_SAT2,
+ FC_SIN,
+ FC_SQRT,
+ FC_TAN,
+ FC_VAL,
+ FC_LAST
+};
+struct FormularCommandNameTable
+{
+ const char* pS;
+ FormularCommand pE;
+};
+static FormularCommandNameTable pFormularCommandNameTable[] =
+{
+ { "*/", FC_MULDIV },
+ { "+-", FC_PLUSMINUS },
+ { "+/", FC_PLUSDIV },
+ { "ifelse", FC_IFELSE },
+ { "abs", FC_ABS },
+ { "at2", FC_AT2 },
+ { "cat2", FC_CAT2 },
+ { "cos", FC_COS },
+ { "max", FC_MAX },
+ { "min", FC_MIN },
+ { "mod", FC_MOD },
+ { "pin", FC_PIN },
+ { "sat2", FC_SAT2 },
+ { "sin", FC_SIN },
+ { "sqrt", FC_SQRT },
+ { "tan", FC_TAN },
+ { "val", FC_VAL }
+
+};
+typedef std::hash_map< rtl::OUString, FormularCommand, comphelper::UStringHash, comphelper::UStringEqual > FormulaCommandHMap;
+
+static const FormulaCommandHMap* pCommandHashMap;
+
+// ---------------------------------------------------------------------
+// CT_GeomGuideList
+class AdjustmentValueContext : public ::oox::core::Context
+{
+public:
+ AdjustmentValueContext( const ::oox::core::FragmentHandlerRef& xHandler, CustomShapeProperties& rCustomShapeProperties );
+ 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);
+
+protected:
+ ::oox::drawingml::CustomShapeProperties& mrCustomShapeProperties;
+};
+
+AdjustmentValueContext::AdjustmentValueContext( const FragmentHandlerRef& xHandler, CustomShapeProperties& rCustomShapeProperties )
+: Context( xHandler )
+, mrCustomShapeProperties( rCustomShapeProperties )
+{
+}
+
+static rtl::OUString convertToOOEquation( const rtl::OUString& rSource )
+{
+ if ( !pCommandHashMap )
+ {
+ FormulaCommandHMap* pHM = new FormulaCommandHMap();
+ for( sal_Int32 i = 0; i < FC_LAST; i++ )
+ (*pHM)[ OUString::createFromAscii( pFormularCommandNameTable[ i ].pS ) ] = pFormularCommandNameTable[ i ].pE;
+ pCommandHashMap = pHM;
+ }
+
+ std::vector< rtl::OUString > aTokens;
+ sal_Int32 nIndex = 0;
+ do
+ {
+ rtl::OUString aToken( rSource.getToken( 0, ' ', nIndex ) );
+ if ( aToken.getLength() )
+ aTokens.push_back( aToken );
+ }
+ while ( nIndex >= 0 );
+
+ rtl::OUString aEquation;
+ if ( aTokens.size() )
+ {
+ const FormulaCommandHMap::const_iterator aIter( pCommandHashMap->find( aTokens[ 0 ] ) );
+ if ( aIter != pCommandHashMap->end() )
+ {
+ switch( aIter->second )
+ {
+ case FC_MULDIV :
+ case FC_PLUSMINUS :
+ case FC_PLUSDIV :
+ case FC_IFELSE :
+ case FC_ABS :
+ case FC_AT2 :
+ case FC_CAT2 :
+ case FC_COS :
+ case FC_MAX :
+ case FC_MIN :
+ case FC_MOD :
+ case FC_PIN :
+ case FC_SAT2 :
+ case FC_SIN :
+ case FC_SQRT :
+ case FC_TAN :
+ case FC_VAL :
+ default :
+ break;
+ }
+ }
+ }
+ return aEquation;
+}
+
+Reference< XFastContextHandler > AdjustmentValueContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
+{
+ if ( aElementToken == ( NMSP_DRAWINGML | XML_gd ) ) // CT_GeomGuide
+ {
+ CustomShapeGuide aGuide;
+ aGuide.maName = xAttribs->getOptionalValue( XML_name );
+ aGuide.maFormula = convertToOOEquation( xAttribs->getOptionalValue( XML_fmla ) );
+ std::vector< CustomShapeGuide >& rAdjustmentValues( mrCustomShapeProperties.getAdjustmentValues() );
+ rAdjustmentValues.push_back( aGuide );
+ }
+ return this;
+}
+
+// ---------------------------------------------------------------------
+
+static OUString GetShapeType( sal_Int32 nType )
+{
+ OUString sType;
+ switch( nType )
+ {
+ case XML_lineInv: // TODO
+ case XML_line: {
+ static const OUString sLine = CREATE_OUSTRING( "mso-spt20" );
+ sType = sLine;
+ } break;
+ case XML_triangle: {
+ static const OUString sTriangle = CREATE_OUSTRING( "isosceles-triangle" );
+ sType = sTriangle;
+ } break;
+ case XML_rtTriangle: {
+ static const OUString sRtTriangle = CREATE_OUSTRING( "right-triangle" );
+ sType = sRtTriangle;
+ } break;
+ case XML_rect: {
+ static const OUString sRectangle = CREATE_OUSTRING( "rectangle" );
+ sType = sRectangle;
+ } break;
+ case XML_diamond: {
+ static const OUString sDiamond = CREATE_OUSTRING( "diamond" );
+ sType = sDiamond;
+ } break;
+ case XML_parallelogram: {
+ static const OUString sParallelogram = CREATE_OUSTRING( "parallelogram" );
+ sType = sParallelogram;
+ } break;
+ case XML_nonIsoscelesTrapezoid: // TODO
+ case XML_trapezoid: {
+ static const OUString sTrapezoid = CREATE_OUSTRING( "trapezoid" );
+ sType = sTrapezoid;
+ } break;
+ case XML_pentagon: {
+ static const OUString sPentagon = CREATE_OUSTRING( "pentagon" );
+ sType = sPentagon;
+ } break;
+ case XML_heptagon: // TODO
+ case XML_hexagon: {
+ static const OUString sHexagon = CREATE_OUSTRING( "hexagon" );
+ sType = sHexagon;
+ } break;
+ case XML_decagon: // TODO
+ case XML_dodecagon: // TODO
+ case XML_octagon: {
+ static const OUString sOctagon = CREATE_OUSTRING( "octagon" );
+ sType = sOctagon;
+ } break;
+ case XML_star4: {
+ static const OUString sStar4 = CREATE_OUSTRING( "star4" );
+ sType = sStar4;
+ } break;
+ case XML_star6: // TODO
+ case XML_star7: // TODO
+ case XML_star5: {
+ static const OUString sStar5 = CREATE_OUSTRING( "star5" );
+ sType = sStar5;
+ } break;
+ case XML_star10: // TODO
+ case XML_star12: // TODO
+ case XML_star16: // TODO
+ case XML_star8: {
+ static const OUString sStar8 = CREATE_OUSTRING( "star8" );
+ sType = sStar8;
+ } break;
+ case XML_star32: // TODO
+ case XML_star24: {
+ static const OUString sStar24 = CREATE_OUSTRING( "star24" );
+ sType = sStar24;
+ } break;
+ case XML_round1Rect: // TODO
+ case XML_round2SameRect: // TODO
+ case XML_round2DiagRect: // TODO
+ case XML_snipRoundRect: // TODO
+ case XML_snip1Rect: // TODO
+ case XML_snip2SameRect: // TODO
+ case XML_snip2DiagRect: // TODO
+ case XML_roundRect: {
+ static const OUString sRoundRect = CREATE_OUSTRING( "round-rectangle" );
+ sType = sRoundRect;
+ } break;
+ case XML_plaque: {
+ static const OUString sPlaque = CREATE_OUSTRING( "mso-spt21" );
+ sType = sPlaque;
+ } break;
+ case XML_teardrop: // TODO
+ case XML_ellipse: {
+ static const OUString sEllipse = CREATE_OUSTRING( "ellipse" );
+ sType = sEllipse;
+ } break;
+ case XML_homePlate: {
+ static const OUString sHomePlate = CREATE_OUSTRING( "pentagon-right" );
+ sType = sHomePlate;
+ } break;
+ case XML_chevron: {
+ static const OUString sChevron = CREATE_OUSTRING( "chevron" );
+ sType = sChevron;
+ } break;
+ case XML_pieWedge: // TODO
+ case XML_pie: // TODO
+ case XML_blockArc: {
+ static const OUString sBlockArc = CREATE_OUSTRING( "block-arc" );
+ sType = sBlockArc;
+ } break;
+ case XML_donut: {
+ static const OUString sDonut = CREATE_OUSTRING( "ring" );
+ sType = sDonut;
+ } break;
+ case XML_noSmoking: {
+ static const OUString sNoSmoking = CREATE_OUSTRING( "forbidden" );
+ sType = sNoSmoking;
+ } break;
+ case XML_rightArrow: {
+ static const OUString sRightArrow = CREATE_OUSTRING( "right-arrow" );
+ sType = sRightArrow;
+ } break;
+ case XML_leftArrow: {
+ static const OUString sLeftArrow = CREATE_OUSTRING( "left-arrow" );
+ sType = sLeftArrow;
+ } break;
+ case XML_upArrow: {
+ static const OUString sUpArrow = CREATE_OUSTRING( "up-arrow" );
+ sType = sUpArrow;
+ } break;
+ case XML_downArrow: {
+ static const OUString sDownArrow = CREATE_OUSTRING( "down-arrow" );
+ sType = sDownArrow;
+ } break;
+ case XML_stripedRightArrow: {
+ static const OUString sStripedRightArrow = CREATE_OUSTRING( "striped-right-arrow" );
+ sType = sStripedRightArrow;
+ } break;
+ case XML_notchedRightArrow: {
+ static const OUString sNotchedRightArrow = CREATE_OUSTRING( "notched-right-arrow" );
+ sType = sNotchedRightArrow;
+ } break;
+ case XML_bentUpArrow: {
+ static const OUString sBentUpArrow = CREATE_OUSTRING( "mso-spt90" );
+ sType = sBentUpArrow;
+ } break;
+ case XML_leftRightArrow: {
+ static const OUString sLeftRightArrow = CREATE_OUSTRING( "left-right-arrow" );
+ sType = sLeftRightArrow;
+ } break;
+ case XML_upDownArrow: {
+ static const OUString sUpDownArrow = CREATE_OUSTRING( "up-down-arrow" );
+ sType = sUpDownArrow;
+ } break;
+ case XML_leftUpArrow: {
+ static const OUString sLeftUpArrow = CREATE_OUSTRING( "mso-spt89" );
+ sType = sLeftUpArrow;
+ } break;
+ case XML_leftRightUpArrow: {
+ static const OUString sLeftRightUpArrow = CREATE_OUSTRING( "mso-spt182" );
+ sType = sLeftRightUpArrow;
+ } break;
+ case XML_quadArrow: {
+ static const OUString sQuadArrow = CREATE_OUSTRING( "quad-arrow" );
+ sType = sQuadArrow;
+ } break;
+ case XML_leftArrowCallout: {
+ static const OUString sLeftArrowCallout = CREATE_OUSTRING( "left-arrow-callout" );
+ sType = sLeftArrowCallout;
+ } break;
+ case XML_rightArrowCallout: {
+ static const OUString sRightArrowCallout = CREATE_OUSTRING( "right-arrow-callout" );
+ sType = sRightArrowCallout;
+ } break;
+ case XML_upArrowCallout: {
+ static const OUString sUpArrowCallout = CREATE_OUSTRING( "up-arrow-callout" );
+ sType = sUpArrowCallout;
+ } break;
+ case XML_downArrowCallout: {
+ static const OUString sDownArrowCallout = CREATE_OUSTRING( "down-arrow-callout" );
+ sType = sDownArrowCallout;
+ } break;
+ case XML_leftRightArrowCallout: {
+ static const OUString sLeftRightArrowCallout = CREATE_OUSTRING( "left-right-arrow-callout" );
+ sType = sLeftRightArrowCallout;
+ } break;
+ case XML_upDownArrowCallout: {
+ static const OUString sUpDownArrowCallout = CREATE_OUSTRING( "up-down-arrow-callout" );
+ sType = sUpDownArrowCallout;
+ } break;
+ case XML_quadArrowCallout: {
+ static const OUString sQuadArrowCallout = CREATE_OUSTRING( "quad-arrow-callout" );
+ sType = sQuadArrowCallout;
+ } break;
+ case XML_bentArrow: {
+ static const OUString sBentArrow = CREATE_OUSTRING( "mso-spt91" );
+ sType = sBentArrow;
+ } break;
+ case XML_uturnArrow: {
+ static const OUString sUTurnArrow = CREATE_OUSTRING( "mso-spt101" );
+ sType = sUTurnArrow;
+ } break;
+ case XML_leftCircularArrow: // TODO
+ case XML_leftRightCircularArrow: // TODO
+ case XML_circularArrow: {
+ static const OUString sCircularArrow = CREATE_OUSTRING( "circular-arrow" );
+ sType = sCircularArrow;
+ } break;
+ case XML_curvedRightArrow: {
+ static const OUString sCurvedRightArrow = CREATE_OUSTRING( "mso-spt102" );
+ sType = sCurvedRightArrow;
+ } break;
+ case XML_curvedLeftArrow: {
+ static const OUString sCurvedLeftArrow = CREATE_OUSTRING( "mso-spt103" );
+ sType = sCurvedLeftArrow;
+ } break;
+ case XML_curvedUpArrow: {
+ static const OUString sCurvedUpArrow = CREATE_OUSTRING( "mso-spt104" );
+ sType = sCurvedUpArrow;
+ } break;
+ case XML_swooshArrow: // TODO
+ case XML_curvedDownArrow: {
+ static const OUString sCurvedDownArrow = CREATE_OUSTRING( "mso-spt105" );
+ sType = sCurvedDownArrow;
+ } break;
+ case XML_cube: {
+ static const OUString sCube = CREATE_OUSTRING( "cube" );
+ sType = sCube;
+ } break;
+ case XML_can: {
+ static const OUString sCan = CREATE_OUSTRING( "can" );
+ sType = sCan;
+ } break;
+ case XML_lightningBolt: {
+ static const OUString sLightningBolt = CREATE_OUSTRING( "lightning" );
+ sType = sLightningBolt;
+ } break;
+ case XML_heart: {
+ static const OUString sHeart = CREATE_OUSTRING( "heart" );
+ sType = sHeart;
+ } break;
+ case XML_sun: {
+ static const OUString sSun = CREATE_OUSTRING( "sun" );
+ sType = sSun;
+ } break;
+ case XML_moon: {
+ static const OUString sMoon = CREATE_OUSTRING( "moon" );
+ sType = sMoon;
+ } break;
+ case XML_smileyFace: {
+ static const OUString sSmileyFace = CREATE_OUSTRING( "smiley" );
+ sType = sSmileyFace;
+ } break;
+ case XML_irregularSeal1: {
+ static const OUString sIrregularSeal1 = CREATE_OUSTRING( "mso-spt71" );
+ sType = sIrregularSeal1;
+ } break;
+ case XML_irregularSeal2: {
+ static const OUString sIrregularSeal2 = CREATE_OUSTRING( "bang" );
+ sType = sIrregularSeal2;
+ } break;
+ case XML_foldedCorner: {
+ static const OUString sFoldedCorner = CREATE_OUSTRING( "paper" );
+ sType = sFoldedCorner;
+ } break;
+ case XML_bevel: {
+ static const OUString sBevel = CREATE_OUSTRING( "quad-bevel" );
+ sType = sBevel;
+ } break;
+ case XML_halfFrame: // TODO
+ case XML_corner: // TODO
+ case XML_diagStripe: // TODO
+ case XML_chord: // TODO
+ case XML_frame: {
+ static const OUString sFrame = CREATE_OUSTRING( "mso-spt75" );
+ sType = sFrame;
+ } break;
+ case XML_arc: {
+ static const OUString sArc = CREATE_OUSTRING( "mso-spt19" );
+ sType = sArc;
+ } break;
+ case XML_leftBracket: {
+ static const OUString sLeftBracket = CREATE_OUSTRING( "left-bracket" );
+ sType = sLeftBracket;
+ } break;
+ case XML_rightBracket: {
+ static const OUString sRightBracket = CREATE_OUSTRING( "right-bracket" );
+ sType = sRightBracket;
+ } break;
+ case XML_leftBrace: {
+ static const OUString sLeftBrace = CREATE_OUSTRING( "left-brace" );
+ sType = sLeftBrace;
+ } break;
+ case XML_rightBrace: {
+ static const OUString sRightBrace = CREATE_OUSTRING( "right-brace" );
+ sType = sRightBrace;
+ } break;
+ case XML_bracketPair: {
+ static const OUString sBracketPair = CREATE_OUSTRING( "bracket-pair" );
+ sType = sBracketPair;
+ } break;
+ case XML_bracePair: {
+ static const OUString sBracePair = CREATE_OUSTRING( "brace-pair" );
+ sType = sBracePair;
+ } break;
+ case XML_straightConnector1: {
+ static const OUString sStraightConnector1 = CREATE_OUSTRING( "mso-spt32" );
+ sType = sStraightConnector1;
+ } break;
+ case XML_bentConnector2: {
+ static const OUString sBentConnector2 = CREATE_OUSTRING( "mso-spt33" );
+ sType = sBentConnector2;
+ } break;
+ case XML_bentConnector3: {
+ static const OUString sBentConnector3 = CREATE_OUSTRING( "mso-spt34" );
+ sType = sBentConnector3;
+ } break;
+ case XML_bentConnector4: {
+ static const OUString sBentConnector4 = CREATE_OUSTRING( "mso-spt35" );
+ sType = sBentConnector4;
+ } break;
+ case XML_bentConnector5: {
+ static const OUString sBentConnector5 = CREATE_OUSTRING( "mso-spt36" );
+ sType = sBentConnector5;
+ } break;
+ case XML_curvedConnector2: {
+ static const OUString sCurvedConnector2 = CREATE_OUSTRING( "mso-spt37" );
+ sType = sCurvedConnector2;
+ } break;
+ case XML_curvedConnector3: {
+ static const OUString sCurvedConnector3 = CREATE_OUSTRING( "mso-spt38" );
+ sType = sCurvedConnector3;
+ } break;
+ case XML_curvedConnector4: {
+ static const OUString sCurvedConnector4 = CREATE_OUSTRING( "mso-spt39" );
+ sType = sCurvedConnector4;
+ } break;
+ case XML_curvedConnector5: {
+ static const OUString sCurvedConnector5 = CREATE_OUSTRING( "mso-spt40" );
+ sType = sCurvedConnector5;
+ } break;
+ case XML_callout1: {
+ static const OUString sCallout1 = CREATE_OUSTRING( "mso-spt41" );
+ sType = sCallout1;
+ } break;
+ case XML_callout2: {
+ static const OUString sCallout2 = CREATE_OUSTRING( "mso-spt42" );
+ sType = sCallout2;
+ } break;
+ case XML_callout3: {
+ static const OUString sCallout3 = CREATE_OUSTRING( "mso-spt43" );
+ sType = sCallout3;
+ } break;
+ case XML_accentCallout1: {
+ static const OUString sAccentCallout1 = CREATE_OUSTRING( "mso-spt44" );
+ sType = sAccentCallout1;
+ } break;
+ case XML_accentCallout2: {
+ static const OUString sAccentCallout2 = CREATE_OUSTRING( "mso-spt45" );
+ sType = sAccentCallout2;
+ } break;
+ case XML_accentCallout3: {
+ static const OUString sAccentCallout3 = CREATE_OUSTRING( "mso-spt46" );
+ sType = sAccentCallout3;
+ } break;
+ case XML_borderCallout1: {
+ static const OUString sBorderCallout1 = CREATE_OUSTRING( "line-callout-1" );
+ sType = sBorderCallout1;
+ } break;
+ case XML_borderCallout2: {
+ static const OUString sBorderCallout2 = CREATE_OUSTRING( "line-callout-2" );
+ sType = sBorderCallout2;
+ } break;
+ case XML_borderCallout3: {
+ static const OUString sBorderCallout3 = CREATE_OUSTRING( "mso-spt49" );
+ sType = sBorderCallout3;
+ } break;
+ case XML_accentBorderCallout1: {
+ static const OUString sAccentBorderCallout1 = CREATE_OUSTRING( "mso-spt50" );
+ sType = sAccentBorderCallout1;
+ } break;
+ case XML_accentBorderCallout2: {
+ static const OUString sAccentBorderCallout2 = CREATE_OUSTRING( "mso-spt51" );
+ sType = sAccentBorderCallout2;
+ } break;
+ case XML_accentBorderCallout3: {
+ static const OUString sAccentBorderCallout3 = CREATE_OUSTRING( "mso-spt52" );
+ sType = sAccentBorderCallout3;
+ } break;
+ case XML_wedgeRectCallout: {
+ static const OUString sWedgeRectCallout = CREATE_OUSTRING( "rectangular-callout" );
+ sType = sWedgeRectCallout;
+ } break;
+ case XML_wedgeRoundRectCallout: {
+ static const OUString sWedgeRoundRectCallout = CREATE_OUSTRING( "round-rectangular-callout" );
+ sType = sWedgeRoundRectCallout;
+ } break;
+ case XML_wedgeEllipseCallout: {
+ static const OUString sWedgeEllipseCallout = CREATE_OUSTRING( "round-callout" );
+ sType = sWedgeEllipseCallout;
+ } break;
+ case XML_cloud: // TODO
+ case XML_cloudCallout: {
+ static const OUString sCloudCallout = CREATE_OUSTRING( "cloud-callout" );
+ sType = sCloudCallout;
+ } break;
+ case XML_ribbon: {
+ static const OUString sRibbon = CREATE_OUSTRING( "mso-spt53" );
+ sType = sRibbon;
+ } break;
+ case XML_ribbon2: {
+ static const OUString sRibbon2 = CREATE_OUSTRING( "mso-spt54" );
+ sType = sRibbon2;
+ } break;
+ case XML_ellipseRibbon: {
+ static const OUString sEllipseRibbon = CREATE_OUSTRING( "mso-spt107" );
+ sType = sEllipseRibbon;
+ } break;
+ case XML_leftRightRibbon: // TODO
+ case XML_ellipseRibbon2: {
+ static const OUString sEllipseRibbon2 = CREATE_OUSTRING( "mso-spt108" );
+ sType = sEllipseRibbon2;
+ } break;
+ case XML_verticalScroll: {
+ static const OUString sVerticalScroll = CREATE_OUSTRING( "vertical-scroll" );
+ sType = sVerticalScroll;
+ } break;
+ case XML_horizontalScroll: {
+ static const OUString sHorizontalScroll = CREATE_OUSTRING( "horizontal-scroll" );
+ sType = sHorizontalScroll;
+ } break;
+ case XML_wave: {
+ static const OUString sWave = CREATE_OUSTRING( "mso-spt64" );
+ sType = sWave;
+ } break;
+ case XML_doubleWave: {
+ static const OUString sDoubleWave = CREATE_OUSTRING( "mso-spt188" );
+ sType = sDoubleWave;
+ } break;
+ case XML_plus: {
+ static const OUString sPlus = CREATE_OUSTRING( "cross" );
+ sType = sPlus;
+ } break;
+ case XML_flowChartProcess: {
+ static const OUString sFlowChartProcess = CREATE_OUSTRING( "flowchart-process" );
+ sType = sFlowChartProcess;
+ } break;
+ case XML_flowChartDecision: {
+ static const OUString sFlowChartDecision = CREATE_OUSTRING( "flowchart-decision" );
+ sType = sFlowChartDecision;
+ } break;
+ case XML_flowChartInputOutput: {
+ static const OUString sFlowChartInputOutput = CREATE_OUSTRING( "flowchart-data" );
+ sType = sFlowChartInputOutput;
+ } break;
+ case XML_flowChartPredefinedProcess: {
+ static const OUString sFlowChartPredefinedProcess = CREATE_OUSTRING( "flowchart-predefined-process" );
+ sType = sFlowChartPredefinedProcess;
+ } break;
+ case XML_flowChartInternalStorage: {
+ static const OUString sFlowChartInternalStorage = CREATE_OUSTRING( "flowchart-internal-storage" );
+ sType = sFlowChartInternalStorage;
+ } break;
+ case XML_flowChartDocument: {
+ static const OUString sFlowChartDocument = CREATE_OUSTRING( "flowchart-document" );
+ sType = sFlowChartDocument;
+ } break;
+ case XML_flowChartMultidocument: {
+ static const OUString sFlowChartMultidocument = CREATE_OUSTRING( "flowchart-multidocument" );
+ sType = sFlowChartMultidocument;
+ } break;
+ case XML_flowChartTerminator: {
+ static const OUString sFlowChartTerminator = CREATE_OUSTRING( "flowchart-terminator" );
+ sType = sFlowChartTerminator;
+ } break;
+ case XML_flowChartPreparation : {
+ static const OUString sFlowChartPreparation = CREATE_OUSTRING( "flowchart-preparation" );
+ sType = sFlowChartPreparation;
+ } break;
+ case XML_flowChartManualInput: {
+ static const OUString sFlowChartManualInput = CREATE_OUSTRING( "flowchart-manual-input" );
+ sType = sFlowChartManualInput;
+ } break;
+ case XML_flowChartManualOperation: {
+ static const OUString sFlowChartManualOperation = CREATE_OUSTRING( "flowchart-manual-operation" );
+ sType = sFlowChartManualOperation;
+ } break;
+ case XML_flowChartConnector: {
+ static const OUString sFlowChartConnector = CREATE_OUSTRING( "flowchart-connector" );
+ sType = sFlowChartConnector;
+ } break;
+ case XML_flowChartPunchedCard: {
+ static const OUString sFlowChartPunchedCard = CREATE_OUSTRING( "flowchart-card" );
+ sType = sFlowChartPunchedCard;
+ } break;
+ case XML_flowChartPunchedTape: {
+ static const OUString sFlowChartPunchedTape = CREATE_OUSTRING( "flowchart-punched-tape" );
+ sType = sFlowChartPunchedTape;
+ } break;
+ case XML_flowChartSummingJunction: {
+ static const OUString sFlowChartSummingJunction = CREATE_OUSTRING( "flowchart-summing-junction" );
+ sType = sFlowChartSummingJunction;
+ } break;
+ case XML_flowChartOr: {
+ static const OUString sFlowChartOr = CREATE_OUSTRING( "flowchart-or" );
+ sType = sFlowChartOr;
+ } break;
+ case XML_flowChartCollate: {
+ static const OUString sFlowChartCollate = CREATE_OUSTRING( "flowchart-collate" );
+ sType = sFlowChartCollate;
+ } break;
+ case XML_flowChartSort: {
+ static const OUString sFlowChartSort = CREATE_OUSTRING( "flowchart-sort" );
+ sType = sFlowChartSort;
+ } break;
+ case XML_flowChartExtract: {
+ static const OUString sFlowChartExtract = CREATE_OUSTRING( "flowchart-extract" );
+ sType = sFlowChartExtract;
+ } break;
+ case XML_flowChartMerge: {
+ static const OUString sFlowChartMerge = CREATE_OUSTRING( "flowchart-merge" );
+ sType = sFlowChartMerge;
+ } break;
+ case XML_flowChartOfflineStorage: {
+ static const OUString sFlowChartOfflineStorage = CREATE_OUSTRING( "mso-spt129" );
+ sType = sFlowChartOfflineStorage;
+ } break;
+ case XML_flowChartOnlineStorage: {
+ static const OUString sFlowChartOnlineStorage = CREATE_OUSTRING( "flowchart-stored-data" );
+ sType = sFlowChartOnlineStorage;
+ } break;
+ case XML_flowChartMagneticTape: {
+ static const OUString sFlowChartMagneticTape = CREATE_OUSTRING( "flowchart-sequential-access" );
+ sType = sFlowChartMagneticTape;
+ } break;
+ case XML_flowChartMagneticDisk: {
+ static const OUString sFlowChartMagneticDisk = CREATE_OUSTRING( "flowchart-magnetic-disk" );
+ sType = sFlowChartMagneticDisk;
+ } break;
+ case XML_flowChartMagneticDrum: {
+ static const OUString sFlowChartMagneticDrum = CREATE_OUSTRING( "flowchart-direct-access-storage" );
+ sType = sFlowChartMagneticDrum;
+ } break;
+ case XML_flowChartDisplay: {
+ static const OUString sFlowChartDisplay = CREATE_OUSTRING( "flowchart-display" );
+ sType = sFlowChartDisplay;
+ } break;
+ case XML_flowChartDelay: {
+ static const OUString sFlowChartDelay = CREATE_OUSTRING( "flowchart-delay" );
+ sType = sFlowChartDelay;
+ } break;
+ case XML_flowChartAlternateProcess: {
+ static const OUString sFlowChartAlternateProcess = CREATE_OUSTRING( "flowchart-alternate-process" );
+ sType = sFlowChartAlternateProcess;
+ } break;
+ case XML_flowChartOffpageConnector: {
+ static const OUString sFlowChartOffpageConnector = CREATE_OUSTRING( "flowchart-off-page-connector" );
+ sType = sFlowChartOffpageConnector;
+ } break;
+ case XML_actionButtonBlank: {
+ static const OUString sActionButtonBlank = CREATE_OUSTRING( "mso-spt189" );
+ sType = sActionButtonBlank;
+ } break;
+ case XML_actionButtonHome: {
+ static const OUString sActionButtonHome = CREATE_OUSTRING( "mso-spt190" );
+ sType = sActionButtonHome;
+ } break;
+ case XML_actionButtonHelp: {
+ static const OUString sActionButtonHelp = CREATE_OUSTRING( "mso-spt191" );
+ sType = sActionButtonHelp;
+ } break;
+ case XML_actionButtonInformation: {
+ static const OUString sActionButtonInformation = CREATE_OUSTRING( "mso-spt192" );
+ sType = sActionButtonInformation;
+ } break;
+ case XML_actionButtonForwardNext: {
+ static const OUString sActionButtonForwardNext = CREATE_OUSTRING( "mso-spt193" );
+ sType = sActionButtonForwardNext;
+ } break;
+ case XML_actionButtonBackPrevious: {
+ static const OUString sActionButtonBackPrevious = CREATE_OUSTRING( "mso-spt194" );
+ sType = sActionButtonBackPrevious;
+ } break;
+ case XML_actionButtonEnd: {
+ static const OUString sActionButtonEnd = CREATE_OUSTRING( "mso-spt195" );
+ sType = sActionButtonEnd;
+ } break;
+ case XML_actionButtonBeginning: {
+ static const OUString sActionButtonBeginning = CREATE_OUSTRING( "mso-spt196" );
+ sType = sActionButtonBeginning;
+ } break;
+ case XML_actionButtonReturn: {
+ static const OUString sActionButtonReturn = CREATE_OUSTRING( "mso-spt197" );
+ sType = sActionButtonReturn;
+ } break;
+ case XML_actionButtonDocument: {
+ static const OUString sActionButtonDocument = CREATE_OUSTRING( "mso-spt198" );
+ sType = sActionButtonDocument;
+ } break;
+ case XML_actionButtonSound: {
+ static const OUString sActionButtonSound = CREATE_OUSTRING( "mso-spt199" );
+ sType = sActionButtonSound;
+ } break;
+ case XML_actionButtonMovie: {
+ static const OUString sActionButtonMovie = CREATE_OUSTRING( "mso-spt200" );
+ sType = sActionButtonMovie;
+ } break;
+ case XML_gear6: // TODO
+ case XML_gear9: // TODO
+ case XML_funnel: // TODO
+ case XML_mathPlus: // TODO
+ case XML_mathMinus: // TODO
+ case XML_mathMultiply: // TODO
+ case XML_mathDivide: // TODO
+ case XML_mathEqual: // TODO
+ case XML_mathNotEqual: // TODO
+ case XML_cornerTabs: // TODO
+ case XML_squareTabs: // TODO
+ case XML_plaqueTabs: // TODO
+ case XML_chartX: // TODO
+ case XML_chartStar: // TODO
+ case XML_chartPlus: { // TODO
+ static const OUString sRectangle = CREATE_OUSTRING( "rectangle" );
+ sType = sRectangle;
+ } break;
+ default:
+ break;
+ }
+ return sType;
+}
+
+static OUString GetTextShapeType( sal_Int32 nType )
+{
+ OUString sType;
+ switch( nType )
+ {
+ case XML_textNoShape: // TODO
+ case XML_textPlain: {
+ static const OUString sTextPlain = CREATE_OUSTRING( "fontwork-plain-text" );
+ sType = sTextPlain;
+ } break;
+ case XML_textStop: {
+ static const OUString sTextStop = CREATE_OUSTRING( "fontwork-stop" );
+ sType = sTextStop;
+ } break;
+ case XML_textTriangle: {
+ static const OUString sTextTriangle = CREATE_OUSTRING( "fontwork-triangle-up" );
+ sType = sTextTriangle;
+ } break;
+ case XML_textTriangleInverted: {
+ static const OUString sTextTriangleInverted = CREATE_OUSTRING( "fontwork-triangle-down" );
+ sType = sTextTriangleInverted;
+ } break;
+ case XML_textChevron: {
+ static const OUString sTextChevron = CREATE_OUSTRING( "fontwork-chevron-up" );
+ sType = sTextChevron;
+ } break;
+ case XML_textChevronInverted: {
+ static const OUString sTextChevronInverted = CREATE_OUSTRING( "fontwork-chevron-down" );
+ sType = sTextChevronInverted;
+ } break;
+ case XML_textRingInside: {
+ static const OUString sTextRingInside = CREATE_OUSTRING( "mso-spt142" );
+ sType = sTextRingInside;
+ } break;
+ case XML_textRingOutside: {
+ static const OUString sTextRingOutside = CREATE_OUSTRING( "mso-spt143" );
+ sType = sTextRingOutside;
+ } break;
+ case XML_textArchUp: {
+ static const OUString sTextArchUp = CREATE_OUSTRING( "fontwork-arch-up-curve" );
+ sType = sTextArchUp;
+ } break;
+ case XML_textArchDown: {
+ static const OUString sTextArchDown = CREATE_OUSTRING( "fontwork-arch-down-curve" );
+ sType = sTextArchDown;
+ } break;
+ case XML_textCircle: {
+ static const OUString sTextCircle = CREATE_OUSTRING( "fontwork-circle-curve" );
+ sType = sTextCircle;
+ } break;
+ case XML_textButton: {
+ static const OUString sTextButton = CREATE_OUSTRING( "fontwork-open-circle-curve" );
+ sType = sTextButton;
+ } break;
+ case XML_textArchUpPour: {
+ static const OUString sTextArchUpPour = CREATE_OUSTRING( "fontwork-arch-up-pour" );
+ sType = sTextArchUpPour;
+ } break;
+ case XML_textArchDownPour: {
+ static const OUString sTextArchDownPour = CREATE_OUSTRING( "fontwork-arch-down-pour" );
+ sType = sTextArchDownPour;
+ } break;
+ case XML_textCirclePour: {
+ static const OUString sTextCirclePour = CREATE_OUSTRING( "fontwork-circle-pour" );
+ sType = sTextCirclePour;
+ } break;
+ case XML_textButtonPour: {
+ static const OUString sTextButtonPour = CREATE_OUSTRING( "fontwork-open-circle-pour" );
+ sType = sTextButtonPour;
+ } break;
+ case XML_textCurveUp: {
+ static const OUString sTextCurveUp = CREATE_OUSTRING( "fontwork-curve-up" );
+ sType = sTextCurveUp;
+ } break;
+ case XML_textCurveDown: {
+ static const OUString sTextCurveDown = CREATE_OUSTRING( "fontwork-curve-down" );
+ sType = sTextCurveDown;
+ } break;
+ case XML_textCanUp: {
+ static const OUString sTextCanUp = CREATE_OUSTRING( "mso-spt174" );
+ sType = sTextCanUp;
+ } break;
+ case XML_textCanDown: {
+ static const OUString sTextCanDown = CREATE_OUSTRING( "mso-spt175" );
+ sType = sTextCanDown;
+ } break;
+ case XML_textWave1: {
+ static const OUString sTextWave1 = CREATE_OUSTRING( "fontwork-wave" );
+ sType = sTextWave1;
+ } break;
+ case XML_textWave2: {
+ static const OUString sTextWave2 = CREATE_OUSTRING( "mso-spt157" );
+ sType = sTextWave2;
+ } break;
+ case XML_textDoubleWave1: {
+ static const OUString sTextDoubleWave1 = CREATE_OUSTRING( "mso-spt158" );
+ sType = sTextDoubleWave1;
+ } break;
+ case XML_textWave4: {
+ static const OUString sTextWave4 = CREATE_OUSTRING( "mso-spt159" );
+ sType = sTextWave4;
+ } break;
+ case XML_textInflate: {
+ static const OUString sTextInflate = CREATE_OUSTRING( "fontwork-inflate" );
+ sType = sTextInflate;
+ } break;
+ case XML_textDeflate: {
+ static const OUString sTextDeflate = CREATE_OUSTRING( "mso-spt161" );
+ sType = sTextDeflate;
+ } break;
+ case XML_textInflateBottom: {
+ static const OUString sTextInflateBottom = CREATE_OUSTRING( "mso-spt162" );
+ sType = sTextInflateBottom;
+ } break;
+ case XML_textDeflateBottom: {
+ static const OUString sTextDeflateBottom = CREATE_OUSTRING( "mso-spt163" );
+ sType = sTextDeflateBottom;
+ } break;
+ case XML_textInflateTop: {
+ static const OUString sTextInflateTop = CREATE_OUSTRING( "mso-spt164" );
+ sType = sTextInflateTop;
+ } break;
+ case XML_textDeflateTop: {
+ static const OUString sTextDeflateTop = CREATE_OUSTRING( "mso-spt165" );
+ sType = sTextDeflateTop;
+ } break;
+ case XML_textDeflateInflate: {
+ static const OUString sTextDeflateInflate = CREATE_OUSTRING( "mso-spt166" );
+ sType = sTextDeflateInflate;
+ } break;
+ case XML_textDeflateInflateDeflate: {
+ static const OUString sTextDeflateInflateDeflate = CREATE_OUSTRING( "mso-spt167" );
+ sType = sTextDeflateInflateDeflate;
+ } break;
+ case XML_textFadeRight: {
+ static const OUString sTextFadeRight = CREATE_OUSTRING( "fontwork-fade-right" );
+ sType = sTextFadeRight;
+ } break;
+ case XML_textFadeLeft: {
+ static const OUString sTextFadeLeft = CREATE_OUSTRING( "fontwork-fade-left" );
+ sType = sTextFadeLeft;
+ } break;
+ case XML_textFadeUp: {
+ static const OUString sTextFadeUp = CREATE_OUSTRING( "fontwork-fade-up" );
+ sType = sTextFadeUp;
+ } break;
+ case XML_textFadeDown: {
+ static const OUString sTextFadeDown = CREATE_OUSTRING( "fontwork-fade-down" );
+ sType = sTextFadeDown;
+ } break;
+ case XML_textSlantUp: {
+ static const OUString sTextSlantUp = CREATE_OUSTRING( "fontwork-slant-up" );
+ sType = sTextSlantUp;
+ } break;
+ case XML_textSlantDown: {
+ static const OUString sTextSlantDown = CREATE_OUSTRING( "fontwork-slant-down" );
+ sType = sTextSlantDown;
+ } break;
+ case XML_textCascadeUp: {
+ static const OUString sTextCascadeUp = CREATE_OUSTRING( "fontwork-fade-up-and-right" );
+ sType = sTextCascadeUp;
+ } break;
+ case XML_textCascadeDown: {
+ static const OUString sTextCascadeDown = CREATE_OUSTRING( "fontwork-fade-up-and-left" );
+ sType = sTextCascadeDown;
+ } break;
+ default:
+ break;
+ }
+ return sType;
+}
+
+// ---------------------------------------------------------------------
+// CT_CustomGeometry2D
+CustomShapeGeometryContext::CustomShapeGeometryContext( const FragmentHandlerRef& xHandler, const Reference< XFastAttributeList >& /* xAttribs */, CustomShapeProperties& rCustomShapeProperties )
+: Context( xHandler )
+, mrCustomShapeProperties( rCustomShapeProperties )
+{
+}
+
+Reference< XFastContextHandler > CustomShapeGeometryContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& ) throw (SAXException, RuntimeException)
+{
+ switch( aElementToken )
+ {
+ // todo
+ case NMSP_DRAWINGML|XML_avLst: // CT_GeomGuideList adjust value list
+ case NMSP_DRAWINGML|XML_gdLst: // CT_GeomGuideList guide list
+ 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
+ case NMSP_DRAWINGML|XML_pathLst: // CT_Path2DList 2d path list
+ break;
+ }
+
+ Reference< XFastContextHandler > xEmpty;
+ return xEmpty;
+}
+
+// ---------------------------------------------------------------------
+// CT_PresetGeometry2D
+PresetShapeGeometryContext::PresetShapeGeometryContext( const FragmentHandlerRef& xHandler, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties )
+: Context( xHandler )
+, mrCustomShapeProperties( rCustomShapeProperties )
+{
+ OUString sShapeType;
+ sal_Int32 nShapeType = xAttribs->getOptionalValueToken( XML_prst, FastToken::DONTKNOW );
+ if ( nShapeType != FastToken::DONTKNOW )
+ sShapeType = GetShapeType( nShapeType );
+ OSL_ENSURE( sShapeType.getLength(), "oox::drawingml::CustomShapeCustomGeometryContext::CustomShapeCustomGeometryContext(), unknown shape type" );
+ mrCustomShapeProperties.setShapePresetType( sShapeType );
+}
+
+Reference< XFastContextHandler > PresetShapeGeometryContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& ) throw (SAXException, RuntimeException)
+{
+ if ( aElementToken == ( NMSP_DRAWINGML | XML_avLst ) )
+ return new AdjustmentValueContext( getHandler(), mrCustomShapeProperties );
+ else
+ return this;
+}
+
+// ---------------------------------------------------------------------
+// CT_PresetTextShape
+PresetTextShapeContext::PresetTextShapeContext( const FragmentHandlerRef& xHandler, const Reference< XFastAttributeList >& xAttribs, CustomShapeProperties& rCustomShapeProperties )
+: Context( xHandler )
+, mrCustomShapeProperties( rCustomShapeProperties )
+{
+ OUString sShapeType;
+ sal_Int32 nShapeType = xAttribs->getOptionalValueToken( XML_prst, FastToken::DONTKNOW );
+ if ( nShapeType != FastToken::DONTKNOW )
+ sShapeType = GetTextShapeType( nShapeType );
+ OSL_ENSURE( sShapeType.getLength(), "oox::drawingml::CustomShapeCustomGeometryContext::CustomShapeCustomGeometryContext(), unknown shape type" );
+ mrCustomShapeProperties.setShapePresetType( sShapeType );
+}
+
+Reference< XFastContextHandler > PresetTextShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& ) throw (SAXException, RuntimeException)
+{
+ switch( aElementToken )
+ {
+ // todo
+ case NMSP_DRAWINGML|XML_avLst: // CT_GeomGuideList adjust value list
+ case NMSP_DRAWINGML|XML_gdLst: // CT_GeomGuideList guide list
+ 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
+ case NMSP_DRAWINGML|XML_pathLst: // CT_Path2DList 2d path list
+ break;
+ }
+
+ Reference< XFastContextHandler > xEmpty;
+ return xEmpty;
+}
+
+} }
diff --git a/oox/source/drawingml/customshapeproperties.cxx b/oox/source/drawingml/customshapeproperties.cxx
new file mode 100644
index 000000000000..255a986e7336
--- /dev/null
+++ b/oox/source/drawingml/customshapeproperties.cxx
@@ -0,0 +1,156 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: customshapeproperties.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include <comphelper/processfactory.hxx>
+#include "oox/drawingml/customshapeproperties.hxx"
+#include "oox/helper/propertyset.hxx"
+#include "oox/core/namespaces.hxx"
+#include "tokens.hxx"
+#ifndef _SOLAR_H
+#include <tools/solar.h>
+#endif
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/graphic/XGraphicTransformer.hpp>
+
+using rtl::OUString;
+using namespace ::oox::core;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::graphic;
+
+namespace oox { namespace drawingml {
+
+CustomShapeProperties::CustomShapeProperties()
+{
+}
+CustomShapeProperties::~CustomShapeProperties()
+{
+}
+
+void CustomShapeProperties::apply( const CustomShapePropertiesPtr& /* rSourceCustomShapeProperties */ )
+{
+ // not sure if this needs to be implemented
+}
+
+void CustomShapeProperties::pushToPropSet( const ::oox::core::XmlFilterBase& /* rFilterBase */,
+ const Reference < XPropertySet >& xPropSet ) const
+{
+ const OUString sType = CREATE_OUSTRING( "Type" );
+ if ( maShapePresetType.getLength() )
+ {
+
+ // XEnhancedCustomShapeDefaulter TODO
+// const uno::Reference < drawing::XShape > xShape( xPropSet, UNO_QUERY ) ; // REMOVE THIS
+// SdrObjCustomShape* pCustoObj = const_cast< SdrObjCustomShape* >( dynamic_cast< SdrObjCustomShape* >( GetSdrObjectFromXShape( xShape ) ) ) ; // REMOVE THIS
+// if ( pCustoObj ) // REMOVE THIS
+// pCustoObj->MergeDefaultAttributes( &sType ); // REMOVE THIS
+
+ const rtl::OUString sCustomShapeGeometry( RTL_CONSTASCII_USTRINGPARAM( "CustomShapeGeometry" ) );
+ uno::Any aGeoPropSet = xPropSet->getPropertyValue( sCustomShapeGeometry );
+ uno::Sequence< beans::PropertyValue > aGeoPropSeq;
+ if ( aGeoPropSet >>= aGeoPropSeq )
+ {
+ sal_Int32 i, nCount = aGeoPropSeq.getLength();
+ for ( i = 0; i < nCount; i++ )
+ {
+ const rtl::OUString sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM( "AdjustmentValues" ) );
+ if ( aGeoPropSeq[ i ].Name.equals( sAdjustmentValues ) )
+ {
+ uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentSeq;
+ if ( aGeoPropSeq[ i ].Value >>= aAdjustmentSeq )
+ {
+ sal_uInt32 j, nHighest = 0;
+ for( j = 0; j < maAdjustmentValues.size(); j++ )
+ {
+ const rtl::OUString& rS( maAdjustmentValues[ j ].maName );
+ if ( rS.getLength() > 3 )
+ {
+ sal_uInt32 nVal = rS.copy( 3 ).toInt32();
+ if ( ( nVal < 10 ) && ( nVal > nHighest ) )
+ nHighest = nVal;
+ }
+ }
+ if ( nHighest > static_cast< sal_uInt32 >( aAdjustmentSeq.getLength() ) )
+ aAdjustmentSeq.realloc( nHighest );
+
+ for ( j = 0; j < maAdjustmentValues.size(); j++ )
+ {
+ sal_uInt32 nVal = maAdjustmentValues[ j ].maName.copy( 3 ).toInt32();
+ if ( nVal-- )
+ {
+ double fNewAdj = getValue( maAdjustmentValues, nVal );
+ aAdjustmentSeq[ nVal ].State = beans::PropertyState_DIRECT_VALUE;
+ aAdjustmentSeq[ nVal ].Value <<= fNewAdj;
+ }
+ }
+ aGeoPropSeq[ i ].Value <<= aAdjustmentSeq;
+ xPropSet->setPropertyValue( sCustomShapeGeometry, Any( aGeoPropSeq ) );
+ }
+ }
+ else if ( aGeoPropSeq[ i ].Name.equals( sType ) )
+ {
+ aGeoPropSeq[ i ].Value <<= maShapePresetType;
+ }
+ }
+ }
+ }
+ else
+ {
+ PropertyMap aPropertyMap;
+ OUString sShapeType( CREATE_OUSTRING( "non-primitive" ) );
+ aPropertyMap[ sType ] <<= sShapeType;
+
+
+ // converting the vector to a sequence
+ Sequence< PropertyValue > aSeq;
+ aPropertyMap.makeSequence( aSeq );
+ static const rtl::OUString sCustomShapeGeometry( RTL_CONSTASCII_USTRINGPARAM( "CustomShapeGeometry" ) );
+ xPropSet->setPropertyValue( sCustomShapeGeometry, Any( aSeq ) );
+ }
+}
+
+double CustomShapeProperties::getValue( const std::vector< CustomShapeGuide >& rGuideList, sal_uInt32 nIndex ) const
+{
+ double fRet = 0.0;
+ if ( nIndex < rGuideList.size() )
+ {
+
+ }
+ return fRet;
+}
+
+} }
diff --git a/oox/source/drawingml/diagram/datamodelcontext.cxx b/oox/source/drawingml/diagram/datamodelcontext.cxx
new file mode 100644
index 000000000000..d7502ea4781a
--- /dev/null
+++ b/oox/source/drawingml/diagram/datamodelcontext.cxx
@@ -0,0 +1,336 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: datamodelcontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:57 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/diagram/datamodelcontext.hxx"
+#include "oox/helper/attributelist.hxx"
+#include "oox/core/skipcontext.hxx"
+#include "oox/drawingml/fillpropertiesgroupcontext.hxx"
+#include "oox/drawingml/shapepropertiescontext.hxx"
+#include "oox/drawingml/textbodycontext.hxx"
+
+using namespace ::oox::core;
+using namespace ::com::sun::star::xml::sax;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+
+namespace oox { namespace drawingml {
+
+
+
+// CL_Cxn
+class CxnContext
+ : public Context
+{
+public:
+ CxnContext( const FragmentHandlerRef& xParent,
+ const Reference< XFastAttributeList >& xAttribs,
+ const dgm::ConnectionPtr & pConnection )
+ : Context( xParent )
+ , mpConnection( pConnection )
+ {
+ pConnection->msModelId = xAttribs->getOptionalValue( XML_modelId );
+ pConnection->msSourceId = xAttribs->getOptionalValue( XML_srcId );
+ pConnection->msDestId = xAttribs->getOptionalValue( XML_destId );
+ pConnection->msPresId = xAttribs->getOptionalValue( XML_presId );
+ pConnection->msSibTransId = xAttribs->getOptionalValue( XML_sibTransId );
+ AttributeList attribs( xAttribs );
+ pConnection->mnSourceOrder = attribs.getInteger( XML_srcOrd, 0 );
+ pConnection->mnDestOrder = attribs.getInteger( XML_destOrd, 0 );
+ }
+
+ virtual Reference< XFastContextHandler > SAL_CALL
+ createFastChildContext( sal_Int32 aElementToken,
+ const Reference< XFastAttributeList >& /*xAttribs*/ )
+ throw (SAXException, RuntimeException)
+ {
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElementToken )
+ {
+ case NMSP_DIAGRAM|XML_extLst:
+ xRet.set( new SkipContext( getHandler() ) );
+ break;
+ default:
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+ }
+private:
+ dgm::ConnectionPtr mpConnection;
+};
+
+
+// CT_CxnList
+class CxnListContext
+ : public Context
+{
+public:
+ CxnListContext( const FragmentHandlerRef& xParent, dgm::Connections & aConnections )
+ : Context( xParent )
+ , maConnections( aConnections )
+ {
+ }
+ virtual Reference< XFastContextHandler > SAL_CALL
+ createFastChildContext( sal_Int32 aElementToken,
+ const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
+ {
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElementToken )
+ {
+ case NMSP_DIAGRAM|XML_cxn:
+ {
+ dgm::ConnectionPtr pConnection( new dgm::Connection() );
+ maConnections.push_back( pConnection );
+ xRet.set( new CxnContext( getHandler( ), xAttribs, pConnection ) );
+ break;
+ }
+ default:
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+ }
+
+private:
+ dgm::Connections & maConnections;
+};
+
+
+
+// CL_Pt
+class PtContext
+ : public Context
+{
+public:
+ PtContext( const FragmentHandlerRef& xParent,
+ const Reference< XFastAttributeList >& xAttribs,
+ const dgm::PointPtr & pPoint)
+ : Context( xParent )
+ , mpPoint( pPoint )
+ {
+ // both can be either an int or a uuid
+ mpPoint->setCnxId( xAttribs->getOptionalValue( XML_cxnId ) );
+ mpPoint->setModelId( xAttribs->getOptionalValue( XML_modelId ) );
+ //
+ mpPoint->setType( xAttribs->getOptionalValueToken( XML_type, 0 ) );
+ }
+
+ virtual Reference< XFastContextHandler > SAL_CALL
+ createFastChildContext( sal_Int32 aElementToken,
+ const Reference< XFastAttributeList >& /*xAttribs*/ )
+ throw (SAXException, RuntimeException)
+ {
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElementToken )
+ {
+ case NMSP_DIAGRAM|XML_extLst:
+ xRet.set( new SkipContext( getHandler() ) );
+ break;
+ case NMSP_DIAGRAM|XML_prSet:
+ // TODO
+ // CT_ElemPropSet
+ break;
+ case NMSP_DIAGRAM|XML_spPr:
+ xRet = new ShapePropertiesContext( this, *(mpPoint->getShape().get()) );
+ break;
+ case NMSP_DIAGRAM|XML_t:
+ xRet = new TextBodyContext( getHandler(), *(mpPoint->getShape().get()) );
+ break;
+ default:
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+ }
+
+private:
+ dgm::PointPtr mpPoint;
+};
+
+
+
+// CT_PtList
+class PtListContext
+ : public Context
+{
+public:
+ PtListContext( const FragmentHandlerRef& xParent, dgm::Points & aPoints)
+ : Context( xParent )
+ , maPoints( aPoints )
+ {
+ }
+ virtual Reference< XFastContextHandler > SAL_CALL
+ createFastChildContext( sal_Int32 aElementToken,
+ const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
+ {
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElementToken )
+ {
+ case NMSP_DIAGRAM|XML_pt:
+ {
+ // CT_Pt
+ dgm::PointPtr pPoint( new dgm::Point() );
+ maPoints.push_back( pPoint );
+ xRet.set( new PtContext( getHandler( ), xAttribs, pPoint ) );
+ break;
+ }
+ default:
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+ }
+
+private:
+ dgm::Points & maPoints;
+};
+
+// CT_BackgroundFormatting
+class BackgroundFormattingContext
+ : public Context
+{
+public:
+ BackgroundFormattingContext( const FragmentHandlerRef& xParent, DiagramDataPtr & pModel )
+ : Context( xParent )
+ , mpDataModel( pModel )
+ {
+ OSL_ENSURE( pModel, "the data model MUST NOT be NULL" );
+ }
+
+ virtual Reference< XFastContextHandler > SAL_CALL
+ createFastChildContext( sal_Int32 aElementToken,
+ const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
+ {
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_blipFill:
+ case NMSP_DRAWINGML|XML_gradFill:
+ case NMSP_DRAWINGML|XML_grpFill:
+ case NMSP_DRAWINGML|XML_noFill:
+ case NMSP_DRAWINGML|XML_pattFill:
+ case NMSP_DRAWINGML|XML_solidFill:
+ // EG_FillProperties
+ xRet.set( FillPropertiesGroupContext::StaticCreateContext( getHandler( ),
+ aElementToken,
+ xAttribs,
+ *(mpDataModel->getFillProperties().get()) ) );
+ break;
+ case NMSP_DRAWINGML|XML_effectDag:
+ case NMSP_DRAWINGML|XML_effectLst:
+ // TODO
+ // EG_EffectProperties
+ break;
+ default:
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+ }
+private:
+ DiagramDataPtr mpDataModel;
+};
+
+
+
+DataModelContext::DataModelContext( const FragmentHandlerRef& xHandler,
+ const DiagramDataPtr & pDataModel )
+ : Context( xHandler )
+ , mpDataModel( pDataModel )
+{
+ OSL_ENSURE( pDataModel, "Data Model must not be NULL" );
+}
+
+
+DataModelContext::~DataModelContext()
+{
+ // some debug
+ mpDataModel->dump();
+}
+
+
+Reference< XFastContextHandler > SAL_CALL
+DataModelContext::createFastChildContext( ::sal_Int32 aElement,
+ const Reference< XFastAttributeList >& /*xAttribs*/ )
+ throw ( SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElement )
+ {
+ case NMSP_DIAGRAM|XML_cxnLst:
+ // CT_CxnList
+ xRet.set( new CxnListContext( getHandler( ), mpDataModel->getConnections() ) );
+ break;
+ case NMSP_DIAGRAM|XML_ptLst:
+ // CT_PtList
+ xRet.set( new PtListContext( getHandler( ), mpDataModel->getPoints() ) );
+ break;
+ case NMSP_DIAGRAM|XML_bg:
+ // CT_BackgroundFormatting
+ xRet.set( new BackgroundFormattingContext( getHandler(), mpDataModel ) );
+ break;
+ case NMSP_DIAGRAM|XML_whole:
+ // CT_WholeE2oFormatting
+ // TODO
+ xRet.set( new SkipContext( getHandler() ) );
+ break;
+ case NMSP_DIAGRAM|XML_extLst:
+ xRet.set( new SkipContext( getHandler() ) );
+ break;
+ default:
+ break;
+ }
+
+ if( !xRet.is() )
+ xRet.set( this );
+
+ return xRet;
+}
+
+} }
diff --git a/oox/source/drawingml/diagram/diagram.cxx b/oox/source/drawingml/diagram/diagram.cxx
new file mode 100644
index 000000000000..04394b331f4b
--- /dev/null
+++ b/oox/source/drawingml/diagram/diagram.cxx
@@ -0,0 +1,130 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: diagram.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:57 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+
+#include <functional>
+#include <boost/bind.hpp>
+
+#include "oox/drawingml/diagram/diagram.hxx"
+#include "oox/core/namespaces.hxx"
+#include "tokens.hxx"
+
+
+namespace oox { namespace drawingml {
+
+namespace dgm {
+
+
+void Connection::dump()
+{
+ OSL_TRACE("dgm: cnx modelId %s, srcId %s, dstId %s",
+ OUSTRING_TO_CSTR( msModelId ),
+ OUSTRING_TO_CSTR( msSourceId ),
+ OUSTRING_TO_CSTR( msDestId ) );
+}
+
+Point::Point()
+ : mpShape( new Shape( "com.sun.star.drawing.GroupShape" ) )
+ , mnType( 0 )
+{
+}
+
+void Point::dump()
+{
+ OSL_TRACE( "dgm: pt cnxId %s, modelId %s",
+ OUSTRING_TO_CSTR( msCnxId ),
+ OUSTRING_TO_CSTR( msModelId ) );
+}
+
+
+}
+
+
+DiagramData::DiagramData()
+ : mpFillProperties( new FillProperties( ) )
+{
+}
+
+void DiagramData::dump()
+{
+ OSL_TRACE("Dgm: DiagramData # of cnx: %d", maConnections.size() );
+ std::for_each( maConnections.begin(), maConnections.end(),
+ boost::bind( &dgm::Connection::dump, _1 ) );
+ OSL_TRACE("Dgm: DiagramData # of pt: %d", maPoints.size() );
+ std::for_each( maPoints.begin(), maPoints.end(),
+ boost::bind( &dgm::Point::dump, _1 ) );
+}
+
+
+void Diagram::setData( const DiagramDataPtr & pData)
+{
+ mpData = pData;
+}
+
+
+void Diagram::setLayout( const DiagramLayoutPtr & pLayout)
+{
+ mpLayout = pLayout;
+}
+
+void Diagram::setQStyles( const DiagramQStylesPtr & pStyles)
+{
+ mpQStyles = pStyles;
+}
+
+
+void Diagram::setColors( const DiagramColorsPtr & pColors)
+{
+ mpColors = pColors;
+}
+
+
+void Diagram::addTo( const ShapePtr & pShape )
+{
+ dgm::Points & aPoints( mpData->getPoints( ) );
+ std::for_each( aPoints.begin(), aPoints.end(),
+ boost::bind( &Shape::addChild, boost::ref( pShape ),
+ boost::bind( &dgm::Point::getShape, _1 ) ) );
+
+ OSL_TRACE( "Dgm: addTo() # of childs %d", pShape->getChilds().size() );
+ for( std::vector< ShapePtr >::iterator iter = pShape->getChilds().begin();
+ iter != pShape->getChilds().end(); ++iter)
+ {
+ OSL_TRACE( "Dgm: shape name %s", OUSTRING_TO_CSTR( (*iter)->getName() ) );
+ }
+}
+
+
+} }
diff --git a/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx b/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx
new file mode 100644
index 000000000000..d8d246efa3c2
--- /dev/null
+++ b/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx
@@ -0,0 +1,124 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: diagramdefinitioncontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:57 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2007 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/core/skipcontext.hxx"
+#include "layoutnodecontext.hxx"
+#include "diagramdefinitioncontext.hxx"
+#include "oox/drawingml/diagram/datamodelcontext.hxx"
+
+using namespace ::oox::core;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+using ::rtl::OUString;
+
+namespace oox { namespace drawingml {
+
+
+// CT_DiagramDefinition
+DiagramDefinitionContext::DiagramDefinitionContext( const FragmentHandlerRef& xHandler,
+ const Reference< XFastAttributeList >& xAttributes,
+ const DiagramLayoutPtr &pLayout )
+ : Context( xHandler )
+ , mpLayout( pLayout )
+{
+ OSL_TRACE( "OOX: DiagramDefinitionContext::DiagramDefinitionContext()" );
+ mpLayout->setDefStyle( xAttributes->getOptionalValue( XML_defStyle ) );
+ OUString sValue = xAttributes->getOptionalValue( XML_minVer );
+ if( sValue.getLength() == 0 )
+ {
+ sValue = CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/diagram" );
+ }
+ mpLayout->setMinVer( sValue );
+ mpLayout->setUniqueId( xAttributes->getOptionalValue( XML_uniqueId ) );
+}
+
+
+DiagramDefinitionContext::~DiagramDefinitionContext()
+{
+ mpLayout->getNode()->dump(0);
+}
+
+void SAL_CALL DiagramDefinitionContext::endFastElement( ::sal_Int32 )
+ throw (SAXException, RuntimeException)
+{
+
+}
+
+
+Reference< XFastContextHandler > SAL_CALL
+DiagramDefinitionContext::createFastChildContext( ::sal_Int32 aElement,
+ const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElement )
+ {
+ case NMSP_DIAGRAM|XML_title:
+ mpLayout->setTitle( xAttribs->getOptionalValue( XML_val ) );
+ break;
+ case NMSP_DIAGRAM|XML_desc:
+ mpLayout->setDesc( xAttribs->getOptionalValue( XML_val ) );
+ break;
+ case NMSP_DIAGRAM|XML_layoutNode:
+ mpLayout->getNode().reset( new LayoutNode() );
+ xRet.set( new LayoutNodeContext( getHandler(), xAttribs, mpLayout->getNode() ) );
+ break;
+ case NMSP_DIAGRAM|XML_clrData:
+ // TODO, does not matter for the UI. skip.
+ xRet.set( new SkipContext( getHandler() ) );
+ break;
+ case NMSP_DIAGRAM|XML_sampData:
+ mpLayout->getSampData().reset( new DiagramData );
+ xRet.set( new DataModelContext( getHandler(), mpLayout->getSampData() ) );
+ break;
+ case NMSP_DIAGRAM|XML_styleData:
+ mpLayout->getStyleData().reset( new DiagramData );
+ xRet.set( new DataModelContext( getHandler(), mpLayout->getStyleData() ) );
+ break;
+ case NMSP_DIAGRAM|XML_cat:
+ case NMSP_DIAGRAM|XML_catLst:
+ // TODO, does not matter for the UI
+ default:
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set(this);
+
+ return xRet;
+}
+
+
+} }
diff --git a/oox/source/drawingml/diagram/diagramdefinitioncontext.hxx b/oox/source/drawingml/diagram/diagramdefinitioncontext.hxx
new file mode 100644
index 000000000000..7931f5357e45
--- /dev/null
+++ b/oox/source/drawingml/diagram/diagramdefinitioncontext.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: diagramdefinitioncontext.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:57 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2007 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#ifndef OOX_DRAWINGML_DIAGRAMDEFINITIONCONTEXT_HXX
+#define OOX_DRAWINGML_DIAGRAMDEFINITIONCONTEXT_HXX
+
+#include "oox/core/fragmenthandler.hxx"
+#include "oox/core/context.hxx"
+#include "oox/drawingml/diagram/diagram.hxx"
+
+namespace oox { namespace drawingml {
+
+class DiagramDefinitionContext : public ::oox::core::Context
+{
+public:
+ DiagramDefinitionContext( const ::oox::core::FragmentHandlerRef& xHandler, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, const DiagramLayoutPtr &pLayout );
+ virtual ~DiagramDefinitionContext();
+
+ virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) 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:
+ DiagramLayoutPtr mpLayout;
+};
+
+} }
+
+#endif
diff --git a/oox/source/drawingml/diagram/diagramfragmenthandler.cxx b/oox/source/drawingml/diagram/diagramfragmenthandler.cxx
new file mode 100644
index 000000000000..1a9646323794
--- /dev/null
+++ b/oox/source/drawingml/diagram/diagramfragmenthandler.cxx
@@ -0,0 +1,233 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: diagramfragmenthandler.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:58 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include <osl/diagnose.h>
+
+#include "oox/drawingml/diagram/diagramfragmenthandler.hxx"
+#include "oox/drawingml/diagram/datamodelcontext.hxx"
+#include "oox/core/namespaces.hxx"
+#include "diagramdefinitioncontext.hxx"
+
+
+using namespace ::oox::core;
+using namespace ::com::sun::star::xml::sax;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+
+namespace oox { namespace drawingml {
+
+DiagramDataFragmentHandler::DiagramDataFragmentHandler( const XmlFilterRef& xFilter,
+ const OUString& rFragmentPath,
+ const DiagramDataPtr pDataPtr )
+ throw( )
+ : FragmentHandler( xFilter, rFragmentPath )
+ , mpDataPtr( pDataPtr )
+{
+}
+
+DiagramDataFragmentHandler::~DiagramDataFragmentHandler( ) throw ()
+{
+
+}
+
+void SAL_CALL DiagramDataFragmentHandler::endDocument()
+ throw (SAXException, RuntimeException)
+{
+
+}
+
+
+Reference< XFastContextHandler > SAL_CALL
+DiagramDataFragmentHandler::createFastChildContext( ::sal_Int32 aElement,
+ const Reference< XFastAttributeList >& )
+ throw ( SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElement )
+ {
+ case NMSP_DIAGRAM|XML_dataModel:
+ xRet.set( new DataModelContext( this, mpDataPtr ) );
+ break;
+ default:
+ break;
+ }
+
+ if( !xRet.is() )
+ xRet.set( this );
+
+ return xRet;
+}
+
+///////////////////
+
+DiagramLayoutFragmentHandler::DiagramLayoutFragmentHandler( const XmlFilterRef& xFilter,
+ const OUString& rFragmentPath,
+ const DiagramLayoutPtr pDataPtr )
+ throw( )
+ : FragmentHandler( xFilter, rFragmentPath )
+ , mpDataPtr( pDataPtr )
+{
+}
+
+DiagramLayoutFragmentHandler::~DiagramLayoutFragmentHandler( ) throw ()
+{
+
+}
+
+void SAL_CALL DiagramLayoutFragmentHandler::endDocument()
+ throw (SAXException, RuntimeException)
+{
+
+}
+
+
+Reference< XFastContextHandler > SAL_CALL
+DiagramLayoutFragmentHandler::createFastChildContext( ::sal_Int32 aElement,
+ const Reference< XFastAttributeList >& xAttribs )
+ throw ( SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElement )
+ {
+ case NMSP_DIAGRAM|XML_layoutDef:
+ xRet.set( new DiagramDefinitionContext( this, xAttribs,
+ mpDataPtr ) );
+ break;
+ default:
+ break;
+ }
+
+ if( !xRet.is() )
+ xRet.set( this );
+
+ return xRet;
+}
+
+///////////////////////
+
+DiagramQStylesFragmentHandler::DiagramQStylesFragmentHandler( const XmlFilterRef& xFilter,
+ const OUString& rFragmentPath,
+ const DiagramQStylesPtr pDataPtr )
+ throw( )
+ : FragmentHandler( xFilter, rFragmentPath )
+ , mpDataPtr( pDataPtr )
+{
+}
+
+DiagramQStylesFragmentHandler::~DiagramQStylesFragmentHandler( ) throw ()
+{
+
+}
+
+void SAL_CALL DiagramQStylesFragmentHandler::endDocument()
+ throw (SAXException, RuntimeException)
+{
+
+}
+
+
+Reference< XFastContextHandler > SAL_CALL
+DiagramQStylesFragmentHandler::createFastChildContext( ::sal_Int32 aElement,
+ const Reference< XFastAttributeList >& )
+ throw ( SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElement )
+ {
+ case NMSP_DIAGRAM|XML_styleDef:
+ // TODO
+ break;
+ default:
+ break;
+ }
+
+ if( !xRet.is() )
+ xRet.set( this );
+
+ return xRet;
+}
+
+/////////////////////
+
+DiagramColorsFragmentHandler::DiagramColorsFragmentHandler( const XmlFilterRef& xFilter,
+ const OUString& rFragmentPath,
+ const DiagramColorsPtr pDataPtr )
+ throw( )
+ : FragmentHandler( xFilter, rFragmentPath )
+ , mpDataPtr( pDataPtr )
+{
+}
+
+DiagramColorsFragmentHandler::~DiagramColorsFragmentHandler( ) throw ()
+{
+
+}
+
+void SAL_CALL DiagramColorsFragmentHandler::endDocument()
+ throw (SAXException, RuntimeException)
+{
+
+}
+
+
+Reference< XFastContextHandler > SAL_CALL
+DiagramColorsFragmentHandler::createFastChildContext( ::sal_Int32 aElement,
+ const Reference< XFastAttributeList >& )
+ throw ( SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElement )
+ {
+ case NMSP_DIAGRAM|XML_colorsDef:
+ // TODO
+ break;
+ default:
+ break;
+ }
+
+ if( !xRet.is() )
+ xRet.set( this );
+
+ return xRet;
+}
+
+
+
+
+} }
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
new file mode 100644
index 000000000000..81d7631befc2
--- /dev/null
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -0,0 +1,149 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: diagramlayoutatoms.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:58 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/diagram/diagramlayoutatoms.hxx"
+
+#include <functional>
+#include <boost/bind.hpp>
+
+#include "oox/helper/attributelist.hxx"
+#include "layoutnodecontext.hxx"
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+using namespace ::oox::core;
+
+namespace oox { namespace drawingml {
+
+
+IteratorAttr::IteratorAttr( )
+ : mnAxis( 0 )
+ , mnCnt( 0 )
+ , mbHideLastTrans( false )
+ , mnPtType( 0 )
+ , mnSt( 0 )
+ , mnStep( 1 )
+{
+}
+
+void IteratorAttr::loadFromXAttr( const Reference< XFastAttributeList >& xAttr )
+{
+ AttributeList attr( xAttr );
+ mnAxis = xAttr->getOptionalValueToken( XML_axis, 0 );
+ mnCnt = attr.getInteger( XML_cnt, 0 );
+ mbHideLastTrans = attr.getBool( XML_hideLastTrans, false );
+ mnPtType = xAttr->getOptionalValueToken( XML_ptType, 0 );
+ mnSt = attr.getInteger( XML_st, 0 );
+ mnStep = attr.getInteger( XML_step, 1 );
+}
+
+
+
+ConditionAttr::ConditionAttr()
+ : mnFunc( 0 )
+ , mnArg( 0 )
+ , mnOp( 0 )
+{
+
+}
+
+
+void ConditionAttr::loadFromXAttr( const Reference< XFastAttributeList >& xAttr )
+{
+ mnFunc = xAttr->getOptionalValueToken( XML_func, 0 );
+ // mnArg will be -1 for "none" or any other unknown value
+ mnArg = LayoutNodeContext::tagToVarIdx( xAttr->getOptionalValueToken( XML_arg, XML_none ) );
+ mnOp = xAttr->getOptionalValueToken( XML_op, 0 );
+ msVal = xAttr->getOptionalValue( XML_val );
+}
+
+
+void LayoutAtom::dump(int level)
+{
+ OSL_TRACE( "level = %d - %s of type %s", level,
+ OUSTRING_TO_CSTR( msName ),
+ typeid(*this).name() );
+ std::for_each( mpChildNodes.begin(), mpChildNodes.end(),
+ boost::bind( &LayoutAtom::dump, _1, level + 1 ) );
+}
+
+
+void ForEachAtom::processAtom()
+{
+ // TODO there is likely some conditions
+ std::for_each( mpChildNodes.begin(), mpChildNodes.end(),
+ boost::bind( &LayoutAtom::processAtom, _1 ) );
+}
+
+/** call ConditionAtom::test() if pAtom is one
+ * if it is not a ConditionAtom, then return false.
+ */
+static bool _test_atom( const LayoutAtomPtr & pAtom)
+{
+ try {
+ bool bResult = false;
+ const ConditionAtomPtr pCond = boost::dynamic_pointer_cast< ConditionAtom >(pAtom);
+ if( pCond )
+ {
+ bResult = pCond->test();
+ }
+ return bResult;
+ }
+ catch(...)
+ {
+ }
+ return false;
+}
+
+void ChooseAtom::processAtom()
+{
+ std::vector< LayoutAtomPtr >::iterator
+ iter = std::find_if( mpChildNodes.begin(), mpChildNodes.end(),
+ boost::bind( &_test_atom, _1 ) );
+ if( iter != mpChildNodes.end() )
+ {
+ // TODO do something
+ (*iter)->processAtom();
+ }
+}
+
+bool ConditionAtom::test()
+{
+ // TODO
+ return false;
+}
+
+
+} }
diff --git a/oox/source/drawingml/diagram/layoutnodecontext.cxx b/oox/source/drawingml/diagram/layoutnodecontext.cxx
new file mode 100644
index 000000000000..eb070fba70f3
--- /dev/null
+++ b/oox/source/drawingml/diagram/layoutnodecontext.cxx
@@ -0,0 +1,368 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: layoutnodecontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:58 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2007 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "layoutnodecontext.hxx"
+
+#include "oox/helper/attributelist.hxx"
+#include "oox/core/skipcontext.hxx"
+#include "oox/drawingml/diagram/diagram.hxx"
+#include "oox/drawingml/shapecontext.hxx"
+#include "diagramdefinitioncontext.hxx"
+
+using namespace ::oox::core;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+using ::rtl::OUString;
+
+namespace oox { namespace drawingml {
+
+class IfContext
+ : public LayoutNodeContext
+{
+public:
+ IfContext( const FragmentHandlerRef& xHandler,
+ const Reference< XFastAttributeList >& xAttribs,
+ const LayoutAtomPtr & pNode )
+ : LayoutNodeContext( xHandler, xAttribs, pNode )
+ {
+ ConditionAtomPtr pAtom( boost::dynamic_pointer_cast< ConditionAtom >(pNode) );
+ OSL_ENSURE( pAtom, "Must pass a ConditionAtom" );
+
+ pAtom->iterator().loadFromXAttr( xAttribs );
+ pAtom->cond().loadFromXAttr( xAttribs );
+ }
+};
+
+
+
+class AlgorithmContext
+ : public Context
+{
+public:
+ AlgorithmContext( const FragmentHandlerRef& xHandler, const Reference< XFastAttributeList >& xAttribs, const LayoutAtomPtr & pNode )
+ : Context( xHandler )
+ , mnRevision( 0 )
+ , mnType( 0 )
+ , mpNode( pNode )
+ {
+ AttributeList aAttribs( xAttribs );
+ mnRevision = aAttribs.getInteger( XML_rev, 0 );
+ mnType = xAttribs->getOptionalValueToken( XML_type, 0 );
+ }
+
+private:
+ sal_Int32 mnRevision;
+ sal_Int32 mnType;
+ LayoutAtomPtr mpNode;
+};
+
+
+class ChooseContext
+ : public Context
+{
+public:
+ ChooseContext( const FragmentHandlerRef& xHandler, const Reference< XFastAttributeList >& xAttribs, const LayoutAtomPtr & pNode )
+ : Context( xHandler )
+ , mbHasElse( false )
+ , mpNode( pNode )
+ {
+ msName = xAttribs->getOptionalValue( XML_name );
+ }
+
+ virtual Reference< XFastContextHandler > SAL_CALL
+ createFastChildContext( ::sal_Int32 aElement,
+ const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
+ {
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElement )
+ {
+ case XML_if:
+ {
+ // CT_When
+ LayoutAtomPtr pAtom( new ConditionAtom( false ) );
+ mpNode->addChild( pAtom );
+ xRet.set( new IfContext( getHandler(), xAttribs, pAtom ) );
+ break;
+ }
+ case XML_else:
+ // CT_Otherwise
+ if( !mbHasElse )
+ {
+ LayoutAtomPtr pAtom( new ConditionAtom( true ) );
+ mpNode->addChild( pAtom );
+ xRet.set( new IfContext( getHandler(), xAttribs, pAtom ) );
+ mbHasElse = true;
+ }
+ else
+ {
+ OSL_TRACE( "ignoring second else clause" );
+ }
+ break;
+ default:
+ break;
+ }
+
+ if( !xRet.is() )
+ xRet.set(this);
+
+ return xRet;
+ }
+private:
+ bool mbHasElse;
+ OUString msName;
+ LayoutAtomPtr mpNode;
+};
+
+
+
+
+class ForEachContext
+ : public LayoutNodeContext
+{
+public:
+ ForEachContext( const FragmentHandlerRef& xHandler, const Reference< XFastAttributeList >& xAttribs, const LayoutAtomPtr & pNode )
+ : LayoutNodeContext( xHandler, xAttribs, pNode )
+ {
+ ForEachAtomPtr pAtom( boost::dynamic_pointer_cast< ForEachAtom >(pNode) );
+ OSL_ENSURE( pAtom, "Must pass a ForEachAtom" );
+ xAttribs->getOptionalValue( XML_ref );
+
+ pAtom->iterator().loadFromXAttr( xAttribs );
+ }
+};
+
+
+// CT_LayoutVariablePropertySet
+class LayoutVariablePropertySetContext
+ : public Context
+{
+public:
+ LayoutVariablePropertySetContext( const FragmentHandlerRef& xHandler,
+ LayoutNode::VarMap & aVar )
+ : Context( xHandler )
+ , mVariables( aVar )
+ {
+ }
+
+ virtual ~LayoutVariablePropertySetContext()
+ {
+ }
+
+ virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
+ {
+ Reference< XFastContextHandler > xRet;
+
+ sal_Int32 nIdx = LayoutNodeContext::tagToVarIdx( aElement & ( ~NMSP_MASK ) );
+ if( nIdx != -1 )
+ {
+ mVariables[ nIdx ] = makeAny( xAttribs->getOptionalValue( XML_val ) );
+ }
+ if( !xRet.is() )
+ xRet.set(this);
+
+ return xRet;
+ }
+private:
+ LayoutNode::VarMap & mVariables;
+};
+
+
+// CT_LayoutNode
+LayoutNodeContext::LayoutNodeContext( const FragmentHandlerRef& xHandler,
+ const Reference< XFastAttributeList >& xAttribs,
+ const LayoutAtomPtr &pNode )
+ : Context( xHandler )
+ , mpNode( pNode )
+{
+ OSL_ENSURE( pNode, "Node must NOT be NULL" );
+ mpNode->setName( xAttribs->getOptionalValue( XML_name ) );
+ // TODO shall we even bother?
+ // b or t
+// sal_Int32 nChOrder = xAttributes->getOptionalValueToken( XML_chOrder, XML_b );
+// OUString sMoveWith = xAttributes->getOptionalValue( XML_moveWith );
+// OUString sStyleLbl = xAttributes->getOptionalValue( XML_styleLbl );
+}
+
+
+LayoutNodeContext::~LayoutNodeContext()
+{
+}
+
+void SAL_CALL LayoutNodeContext::endFastElement( ::sal_Int32 )
+ throw (SAXException, RuntimeException)
+{
+
+}
+
+/** convert the XML tag to a variable index in the array
+ * @param aTag the tag, wihout namespace
+ * @return the variable index. -1 is an error
+ */
+sal_Int32 LayoutNodeContext::tagToVarIdx( sal_Int32 aTag )
+{
+ sal_Int32 nIdx = -1;
+ switch( aTag )
+ {
+ case NMSP_DIAGRAM|XML_animLvl:
+ nIdx = LayoutNode::VAR_animLvl;
+ break;
+ case NMSP_DIAGRAM|XML_animOne:
+ nIdx = LayoutNode::VAR_animOne;
+ break;
+ case NMSP_DIAGRAM|XML_bulletEnabled:
+ nIdx = LayoutNode::VAR_bulletEnabled;
+ break;
+ case NMSP_DIAGRAM|XML_chMax:
+ nIdx = LayoutNode::VAR_chMax;
+ break;
+ case NMSP_DIAGRAM|XML_chPref:
+ nIdx = LayoutNode::VAR_chPref;
+ break;
+ case NMSP_DIAGRAM|XML_dir:
+ nIdx = LayoutNode::VAR_dir;
+ break;
+ case NMSP_DIAGRAM|XML_hierBranch:
+ nIdx = LayoutNode::VAR_hierBranch;
+ break;
+ case NMSP_DIAGRAM|XML_orgChart:
+ nIdx = LayoutNode::VAR_orgChart;
+ break;
+ case NMSP_DIAGRAM|XML_resizeHandles:
+ nIdx = LayoutNode::VAR_resizeHandles;
+ break;
+ default:
+ break;
+ }
+ return nIdx;
+}
+
+
+Reference< XFastContextHandler > SAL_CALL
+LayoutNodeContext::createFastChildContext( ::sal_Int32 aElement,
+ const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElement )
+ {
+ case NMSP_DIAGRAM|XML_layoutNode:
+ {
+ LayoutNodePtr pNode( new LayoutNode() );
+ mpNode->addChild( pNode );
+ xRet.set( new LayoutNodeContext( getHandler(), xAttribs, pNode ) );
+ break;
+ }
+ case NMSP_DIAGRAM|XML_shape:
+ {
+ ShapePtr pShape( new Shape() );
+ xRet.set( new ShapeContext( getHandler(), ShapePtr( ( Shape* )NULL ), pShape ) );
+ break;
+ }
+ case NMSP_DIAGRAM|XML_extLst:
+ xRet.set( new SkipContext( getHandler() ) );
+ break;
+ case NMSP_DIAGRAM|XML_alg:
+ {
+ // CT_Algorithm
+ LayoutAtomPtr pAtom( new AlgAtom );
+ mpNode->addChild( pAtom );
+ xRet.set( new AlgorithmContext( getHandler(), xAttribs, pAtom ) );
+ break;
+ }
+ case NMSP_DIAGRAM|XML_choose:
+ {
+ // CT_Choose
+ LayoutAtomPtr pAtom( new ChooseAtom );
+ mpNode->addChild( pAtom );
+ xRet.set( new ChooseContext( getHandler(), xAttribs, pAtom ) );
+ break;
+ }
+ case NMSP_DIAGRAM|XML_forEach:
+ {
+ // CT_ForEach
+ LayoutAtomPtr pAtom( new ForEachAtom );
+ mpNode->addChild( pAtom );
+ xRet.set( new ForEachContext( getHandler(), xAttribs, pAtom ) );
+ break;
+ }
+ case NMSP_DIAGRAM|XML_constrLst:
+ // CT_Constraints
+ // TODO
+ break;
+ case NMSP_DIAGRAM|XML_presOf:
+ {
+ // CT_PresentationOf
+ // TODO
+ xAttribs->getOptionalValue( XML_axis );
+ xAttribs->getOptionalValue( XML_cnt );
+ xAttribs->getOptionalValue( XML_hideLastTrans );
+ xAttribs->getOptionalValue( XML_ptType );
+ xAttribs->getOptionalValue( XML_st );
+ xAttribs->getOptionalValue( XML_step );
+ break;
+ }
+ case NMSP_DIAGRAM|XML_ruleLst:
+ // CT_Rules
+ // TODO
+ break;
+ case NMSP_DIAGRAM|XML_varLst:
+ {
+ LayoutNodePtr pNode( boost::dynamic_pointer_cast< LayoutNode >( mpNode ) );
+ if( pNode )
+ {
+ xRet.set( new LayoutVariablePropertySetContext( getHandler(),
+ pNode->variables() ) );
+ }
+ else
+ {
+ OSL_TRACE( "OOX: encountered a varLst in a non layoutNode context" );
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set(this);
+
+ return xRet;
+}
+
+
+} }
diff --git a/oox/source/drawingml/diagram/layoutnodecontext.hxx b/oox/source/drawingml/diagram/layoutnodecontext.hxx
new file mode 100644
index 000000000000..90ad860a98f5
--- /dev/null
+++ b/oox/source/drawingml/diagram/layoutnodecontext.hxx
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: layoutnodecontext.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:58 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2007 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#ifndef OOX_DRAWINGML_LAYOUTNODECONTEXT_HXX
+#define OOX_DRAWINGML_LAYOUTNODECONTEXT_HXX
+
+#include "oox/core/fragmenthandler.hxx"
+#include "oox/core/context.hxx"
+#include "oox/drawingml/diagram/diagram.hxx"
+
+namespace oox { namespace drawingml {
+
+class LayoutNodeContext : public ::oox::core::Context
+{
+public:
+ LayoutNodeContext( const ::oox::core::FragmentHandlerRef& xHandler, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, const LayoutAtomPtr &pNode );
+ virtual ~LayoutNodeContext();
+
+ virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) 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);
+
+ static ::sal_Int32 tagToVarIdx( ::sal_Int32 aTag );
+private:
+ LayoutAtomPtr mpNode;
+};
+
+} }
+
+#endif
diff --git a/oox/source/drawingml/diagram/makefile.mk b/oox/source/drawingml/diagram/makefile.mk
new file mode 100644
index 000000000000..d2a1bf63d5d8
--- /dev/null
+++ b/oox/source/drawingml/diagram/makefile.mk
@@ -0,0 +1,61 @@
+#*************************************************************************
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.2 $
+#
+# last change: $Author: rt $ $Date: 2008-01-17 08:05:58 $
+#
+# The Contents of this file are made available subject to
+# the terms of GNU Lesser General Public License Version 2.1.
+#
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2005 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=oox
+TARGET=diagram
+AUTOSEG=true
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/diagram.obj \
+ $(SLO)$/diagramfragmenthandler.obj \
+ $(SLO)$/diagramdefinitioncontext.obj \
+ $(SLO)$/diagramlayoutatoms.obj \
+ $(SLO)$/datamodelcontext.obj \
+ $(SLO)$/layoutnodecontext.obj
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/oox/source/drawingml/drawingmltypes.cxx b/oox/source/drawingml/drawingmltypes.cxx
new file mode 100644
index 000000000000..7d5f15c899ec
--- /dev/null
+++ b/oox/source/drawingml/drawingmltypes.cxx
@@ -0,0 +1,433 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: drawingmltypes.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/drawingmltypes.hxx"
+
+#include <com/sun/star/awt/FontPitch.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
+#include <com/sun/star/awt/FontFamily.hpp>
+#include <com/sun/star/awt/FontStrikeout.hpp>
+#include <com/sun/star/style/TabAlign.hpp>
+#include <com/sun/star/style/CaseMap.hpp>
+#include <com/sun/star/style/ParagraphAdjust.hpp>
+
+#include <sax/tools/converter.hxx>
+#include "oox/helper/attributelist.hxx"
+#include "oox/core/namespaces.hxx"
+#include "oox/drawingml/shape.hxx"
+#include "tokens.hxx"
+
+using ::rtl::OUString;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::style;
+using namespace ::oox::core;
+using namespace ::com::sun::star::drawing;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+
+namespace oox { namespace drawingml {
+
+// --------------------------------------------------------------------
+
+/** converts an emu string into 1/100th mmm but constrain as per ST_TextMargin
+ * see 5.1.12.73
+ */
+sal_Int32 GetTextMargin( const ::rtl::OUString& sValue )
+{
+ sal_Int32 nRet = 0;
+ if( !::sax::Converter::convertNumber( nRet, sValue ) )
+ nRet = 0;
+ else if( nRet < 0 )
+ nRet = 0;
+ else if( nRet > 51206400 )
+ nRet = 51206400;
+
+ nRet /= 360;
+ return nRet;
+}
+
+/** converts an emu string into 1/100th mmm */
+sal_Int32 GetCoordinate( const ::rtl::OUString& sValue )
+{
+ sal_Int32 nRet = 0;
+ if( !::sax::Converter::convertNumber( nRet, sValue ) )
+ nRet = 0;
+
+ nRet /= 360;
+ return nRet;
+}
+
+/** converts a ST_Percentage % string into 1/1000th of % */
+sal_Int32 GetPercent( const ::rtl::OUString& sValue )
+{
+ sal_Int32 nRet = 0;
+ if( !::sax::Converter::convertNumber( nRet, sValue ) )
+ nRet = 0;
+
+ return nRet;
+}
+
+double GetPositiveFixedPercentage( const ::rtl::OUString& sValue )
+{
+ double fPercent = sValue.toFloat() / 100000.;
+ return fPercent;
+}
+
+// --------------------------------------------------------------------
+
+/** converts the attributes from an CT_Point2D into an awt Point with 1/100thmm */
+::com::sun::star::awt::Point GetPoint2D( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs )
+{
+ return ::com::sun::star::awt::Point( GetCoordinate( xAttribs->getOptionalValue( XML_x ) ), GetCoordinate( xAttribs->getOptionalValue( XML_y ) ) );
+}
+
+/** converts the attributes from an CT_TLPoint into an awt Point with 1/1000% */
+::com::sun::star::awt::Point GetPointPercent( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs )
+{
+ return ::com::sun::star::awt::Point( GetPercent( xAttribs->getOptionalValue( XML_x ) ), GetCoordinate( xAttribs->getOptionalValue( XML_y ) ) );
+}
+
+// --------------------------------------------------------------------
+
+/** converts the ST_TextFontSize to point */
+float GetTextSize( const ::rtl::OUString& sValue )
+{
+ float fRet = 0;
+ sal_Int32 nRet;
+ if( ::sax::Converter::convertNumber( nRet, sValue ) )
+ fRet = static_cast< float >( static_cast< double >( nRet ) / 100.0 );
+ return fRet;
+}
+
+
+/** converts the ST_TextSpacingPoint to 1/100mm */
+sal_Int32 GetTextSpacingPoint( const ::rtl::OUString& sValue )
+{
+ sal_Int32 nRet;
+ if( ::sax::Converter::convertNumber( nRet, sValue ) )
+ nRet = ( nRet * 254 + 360 ) / 720;
+ return nRet;
+}
+
+
+sal_Int16 GetFontUnderline( ::sal_Int32 nToken )
+{
+ sal_Int16 nEnum;
+ switch( nToken )
+ {
+ case XML_none:
+ nEnum = FontUnderline::NONE;
+ break;
+ case XML_dash:
+ nEnum = FontUnderline::DASH;
+ break;
+ case XML_dashHeavy:
+ nEnum = FontUnderline::BOLDDASH;
+ break;
+ case XML_dashLong:
+ nEnum = FontUnderline::LONGDASH;
+ break;
+ case XML_dashLongHeavy:
+ nEnum = FontUnderline::BOLDLONGDASH;
+ break;
+ case XML_dbl:
+ nEnum = FontUnderline::DOUBLE;
+ break;
+ case XML_dotDash:
+ nEnum = FontUnderline::DASHDOT;
+ break;
+ case XML_dotDashHeavy:
+ nEnum = FontUnderline::BOLDDASHDOT;
+ break;
+ case XML_dotDotDash:
+ nEnum = FontUnderline::DASHDOTDOT;
+ break;
+ case XML_dotDotDashHeavy:
+ nEnum = FontUnderline::BOLDDASHDOTDOT;
+ break;
+ case XML_dotted:
+ nEnum = FontUnderline::DOTTED;
+ break;
+ case XML_dottedHeavy:
+ nEnum = FontUnderline::BOLDDOTTED;
+ break;
+ case XML_heavy:
+ nEnum = FontUnderline::BOLD;
+ break;
+ case XML_sng:
+ nEnum = FontUnderline::SINGLE;
+ break;
+ case XML_wavy:
+ nEnum = FontUnderline::WAVE;
+ break;
+ case XML_wavyDbl:
+ nEnum = FontUnderline::DOUBLEWAVE;
+ break;
+ case XML_wavyHeavy:
+ nEnum = FontUnderline::BOLDWAVE;
+ break;
+ case XML_words:
+ // TODO
+ default:
+ nEnum = FontUnderline::DONTKNOW;
+ break;
+ }
+ return nEnum;
+}
+
+sal_Int16 GetFontStrikeout( sal_Int32 nToken )
+{
+ sal_Int16 nEnum;
+ switch( nToken )
+ {
+ case XML_dblStrike:
+ nEnum = FontStrikeout::DOUBLE;
+ break;
+ case XML_noStrike:
+ nEnum = FontStrikeout::NONE;
+ break;
+ case XML_sngStrike:
+ nEnum = FontStrikeout::SINGLE;
+ break;
+ default:
+ nEnum = FontStrikeout::DONTKNOW;
+ break;
+ }
+ return nEnum;
+}
+
+sal_Int16 GetCaseMap( sal_Int32 nToken )
+{
+ sal_Int16 nEnum;
+ switch( nToken )
+ {
+ case XML_all:
+ nEnum = CaseMap::UPPERCASE;
+ break;
+ case XML_small:
+ nEnum = CaseMap::SMALLCAPS;
+ break;
+ case XML_none:
+ // fall through
+ default:
+ nEnum = CaseMap::NONE;
+ break;
+ }
+ return nEnum;
+}
+
+// BEGIN stolen from sd/source/filter/eppt/epptso.cxx
+/* Font Families */
+#define FF_DONTCARE 0x00
+#define FF_ROMAN 0x10
+#define FF_SWISS 0x20
+#define FF_MODERN 0x30
+#define FF_SCRIPT 0x40
+#define FF_DECORATIVE 0x50
+
+/* Font pitches */
+#define DEFAULT_PITCH 0x00
+#define FIXED_PITCH 0x01
+#define VARIABLE_PITCH 0x02
+
+// END
+
+void GetFontPitch( sal_Int32 nOoxValue, sal_Int16 & nPitch, sal_Int16 & nFamily )
+{
+ sal_Int32 oFamily = ( nOoxValue & 0xf0 );
+ sal_Int32 oPitch = ( nOoxValue & 0x0f );
+ switch( oFamily )
+ {
+ case FF_ROMAN:
+ nFamily = FontFamily::ROMAN;
+ break;
+ case FF_SWISS:
+ nFamily = FontFamily::SWISS;
+ break;
+ case FF_MODERN:
+ nFamily = FontFamily::MODERN;
+ break;
+ case FF_SCRIPT:
+ nFamily = FontFamily::SCRIPT;
+ break;
+ case FF_DECORATIVE:
+ nFamily = FontFamily::DECORATIVE;
+ break;
+ default:
+ nFamily = FontFamily::DONTKNOW;
+ break;
+ }
+ switch( oPitch )
+ {
+ case FIXED_PITCH:
+ nPitch = FontPitch::FIXED;
+ break;
+ case VARIABLE_PITCH:
+ nPitch = FontPitch::VARIABLE;
+ break;
+ case DEFAULT_PITCH:
+ default:
+ nPitch = FontPitch::DONTKNOW;
+ break;
+ }
+}
+
+/** converts a paragraph align to a ParaAdjust */
+sal_Int16 GetParaAdjust( sal_Int32 nAlign )
+{
+ sal_Int16 nEnum;
+ switch( nAlign )
+ {
+ case XML_ctr:
+ nEnum = ParagraphAdjust_CENTER;
+ break;
+ case XML_just:
+ case XML_justLow:
+ nEnum = ParagraphAdjust_BLOCK;
+ break;
+ case XML_r:
+ nEnum = ParagraphAdjust_RIGHT;
+ break;
+ case XML_thaiDist:
+ case XML_dist:
+ nEnum = ParagraphAdjust_STRETCH;
+ break;
+ case XML_l:
+ default:
+ nEnum = ParagraphAdjust_LEFT;
+ break;
+ }
+ return nEnum;
+}
+
+
+TabAlign GetTabAlign( sal_Int32 aToken )
+{
+ TabAlign nEnum;
+ switch( aToken )
+ {
+ case XML_ctr:
+ nEnum = TabAlign_CENTER;
+ break;
+ case XML_dec:
+ nEnum = TabAlign_DECIMAL;
+ break;
+ case XML_l:
+ nEnum = TabAlign_LEFT;
+ break;
+ case XML_r:
+ nEnum = TabAlign_RIGHT;
+ break;
+ default:
+ nEnum = TabAlign_DEFAULT;
+ break;
+ }
+ return nEnum;
+}
+
+// --------------------------------------------------------------------
+
+/** converts the attributes from a CT_RelativeRect to an IntegerRectangle2D */
+com::sun::star::geometry::IntegerRectangle2D GetRelativeRect( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs )
+{
+ com::sun::star::geometry::IntegerRectangle2D r;
+
+ r.X1 = xAttribs->getOptionalValue( XML_l ).toInt32();
+ r.Y1 = xAttribs->getOptionalValue( XML_t ).toInt32();
+ r.X2 = xAttribs->getOptionalValue( XML_r ).toInt32();
+ r.Y2 = xAttribs->getOptionalValue( XML_b ).toInt32();
+
+ return r;
+}
+
+// --------------------------------------------------------------------
+
+/** converts the attributes from an CT_Size2D into an awt Size with 1/100thmm */
+::com::sun::star::awt::Size GetSize2D( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs )
+{
+ return ::com::sun::star::awt::Size( GetCoordinate( xAttribs->getOptionalValue( XML_cx ) ), GetCoordinate( xAttribs->getOptionalValue( XML_cy ) ) );
+}
+
+
+
+
+IndexRange GetIndexRange( const Reference< XFastAttributeList >& xAttributes )
+{
+ IndexRange range;
+ range.start = xAttributes->getOptionalValue( XML_st ).toInt32();
+ range.end = xAttributes->getOptionalValue( XML_end ).toInt32();
+ return range;
+}
+
+
+// --------------------------------------------------------------------
+
+/** context to import a CT_Transform2D */
+Transform2DContext::Transform2DContext( const FragmentHandlerRef& xHandler, const Reference< XFastAttributeList >& xAttribs, ::oox::drawingml::Shape& rShape ) throw()
+: Context( xHandler )
+, mrShape( rShape )
+{
+ AttributeList aAttributeList( xAttribs );
+ mrShape.setRotation( aAttributeList.getInteger( XML_rot, 0 ) ); // 60000ths of a degree Positive angles are clockwise; negative angles are counter-clockwise
+ mrShape.setFlip( aAttributeList.getBool( XML_flipH, sal_False ), aAttributeList.getBool( XML_flipV, sal_False ) );
+}
+
+void Transform2DContext::endFastElement( sal_Int32 ) throw (SAXException, RuntimeException)
+{
+}
+
+Reference< XFastContextHandler > Transform2DContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
+{
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_off: // horz/vert translation
+ mrShape.setPosition( Point( xAttribs->getOptionalValue( XML_x ).toInt32(), xAttribs->getOptionalValue( XML_y ).toInt32() ) );
+ break;
+ case NMSP_DRAWINGML|XML_ext: // horz/vert size
+ mrShape.setSize( Size( xAttribs->getOptionalValue( XML_cx ).toInt32(), xAttribs->getOptionalValue( XML_cy ).toInt32() ) );
+ break;
+/* todo: what to do?
+ case NMSP_DRAWINGML|XML_chOff: // horz/vert translation of children
+ case NMSP_DRAWINGML|XML_chExt: // horz/vert size of children
+ break;
+*/
+ }
+
+ Reference< XFastContextHandler > xEmpty;
+ return xEmpty;
+}
+
+
+} }
diff --git a/oox/source/drawingml/embeddedwavaudiofile.cxx b/oox/source/drawingml/embeddedwavaudiofile.cxx
new file mode 100644
index 000000000000..e9631b91c0dd
--- /dev/null
+++ b/oox/source/drawingml/embeddedwavaudiofile.cxx
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: embeddedwavaudiofile.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2007 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/embeddedwavaudiofile.hxx"
+#include "oox/helper/attributelist.hxx"
+#include "oox/core/namespaces.hxx"
+
+#include "tokens.hxx"
+
+using ::rtl::OUString;
+using namespace ::oox::core;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+
+
+namespace oox { namespace drawingml {
+
+
+ // CT_EmbeddedWAVAudioFile
+ void getEmbeddedWAVAudioFile( const FragmentHandlerRef &xHandler, const Reference< XFastAttributeList >& xAttribs,
+ EmbeddedWAVAudioFile & aAudio )
+ {
+ AttributeList attribs(xAttribs);
+
+ OUString sId = xAttribs->getOptionalValue( NMSP_RELATIONSHIPS|XML_embed );
+ aAudio.msLink = xHandler->getRelations().getTargetFromRelId( sId );
+ aAudio.mbBuiltIn = attribs.getBool( XML_builtIn, false );
+ aAudio.msName = xAttribs->getOptionalValue( XML_name );
+ }
+
+
+} }
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
new file mode 100644
index 000000000000..562eb35f22aa
--- /dev/null
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -0,0 +1,117 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: fillproperties.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include <comphelper/processfactory.hxx>
+#include "oox/drawingml/fillproperties.hxx"
+#include "oox/helper/propertyset.hxx"
+#include "oox/core/namespaces.hxx"
+#include "tokens.hxx"
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/graphic/XGraphicTransformer.hpp>
+
+using rtl::OUString;
+using namespace ::oox::core;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::graphic;
+
+namespace oox { namespace drawingml {
+
+FillProperties::FillProperties( sal_Int32 nContext )
+: mnContext( nContext )
+, maFillColor( new Color() )
+{
+}
+FillProperties::~FillProperties()
+{
+}
+
+void FillProperties::apply( const FillPropertiesPtr& rSourceFillProperties )
+{
+ maFillProperties.insert( rSourceFillProperties->maFillProperties.begin(), rSourceFillProperties->maFillProperties.end() );
+ if ( rSourceFillProperties->maFillColor->isUsed() )
+ maFillColor = rSourceFillProperties->maFillColor;
+}
+
+void FillProperties::pushToPropSet( const ::oox::core::XmlFilterBase& rFilterBase,
+ const Reference < XPropertySet >& xPropSet ) const
+{
+ PropertySet aPropSet( xPropSet );
+ Sequence< OUString > aNames;
+ Sequence< Any > aValues;
+
+ maFillProperties.makeSequence( aNames, aValues );
+ aPropSet.setProperties( aNames, aValues );
+ if ( maFillColor->isUsed() )
+ {
+ const rtl::OUString sFillColor( OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "FillColor" ) ) );
+ xPropSet->setPropertyValue( sFillColor, Any( maFillColor->getColor( rFilterBase ) ) );
+ }
+ createTransformedGraphic( rFilterBase, xPropSet );
+}
+
+void FillProperties::createTransformedGraphic( const oox::core::XmlFilterBase& rFilterBase, const Reference < XPropertySet >& xPropSet ) const
+{
+ if( mxGraphic.is() )
+ {
+ if ( mnContext == XML_pic )
+ {
+ Reference< XGraphic > xGraphic( mxGraphic );
+ if ( maColorChangeFrom.get() && maColorChangeTo.get() )
+ {
+ sal_Int32 nClrChangeFrom = maColorChangeFrom->getColor( rFilterBase );
+ sal_Int32 nClrChangeTo = maColorChangeTo->getColor( rFilterBase );
+ sal_Int32 nAlphaTo = maColorChangeTo->getAlpha();
+ if ( ( nClrChangeFrom != nClrChangeTo ) || ( maColorChangeTo->hasAlpha() && ( nAlphaTo != 1000000 ) ) )
+ {
+ Reference< XGraphicTransformer > xTransformer( xGraphic, UNO_QUERY );
+ if ( xTransformer.is() )
+ xGraphic = xTransformer->colorChange( xGraphic, nClrChangeFrom, 9, nClrChangeTo, static_cast< sal_Int8 >( ( nAlphaTo / 39062 ) ) );
+ }
+ }
+ static const OUString sGraphic( CREATE_OUSTRING( "Graphic" ) );
+ xPropSet->setPropertyValue( sGraphic, Any( xGraphic ) );
+ }
+ else if ( mnContext == XML_spPr )
+ {
+ static const OUString sFillBitmap( CREATE_OUSTRING( "FillBitmap" ) );
+ xPropSet->setPropertyValue( sFillBitmap, Any( mxGraphic ) );
+ }
+ }
+}
+
+} }
diff --git a/oox/source/drawingml/fillpropertiesgroupcontext.cxx b/oox/source/drawingml/fillpropertiesgroupcontext.cxx
new file mode 100644
index 000000000000..351391c7aca7
--- /dev/null
+++ b/oox/source/drawingml/fillpropertiesgroupcontext.cxx
@@ -0,0 +1,457 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: fillpropertiesgroupcontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/fillpropertiesgroupcontext.hxx"
+
+#include "comphelper/anytostring.hxx"
+#include "cppuhelper/exc_hlp.hxx"
+#include "oox/drawingml/colorchoicecontext.hxx"
+#include <com/sun/star/graphic/XGraphicProvider.hpp>
+#include "oox/helper/propertymap.hxx"
+#include "oox/core/namespaces.hxx"
+#include "tokens.hxx"
+
+using ::rtl::OUString;
+using ::com::sun::star::beans::NamedValue;
+using namespace ::oox::core;
+using namespace ::com::sun::star::drawing;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::graphic;
+using namespace ::com::sun::star::xml::sax;
+
+namespace oox { namespace drawingml {
+
+// ---------------------------------------------------------------------
+
+class NoFillContext : public FillPropertiesGroupContext
+{
+public:
+ NoFillContext( const oox::core::FragmentHandlerRef& xHandler, ::oox::drawingml::FillProperties& rFillProperties ) throw();
+};
+
+// ---------------------------------------------------------------------
+
+class SolidColorFillPropertiesContext : public FillPropertiesGroupContext
+{
+public:
+ SolidColorFillPropertiesContext( const oox::core::FragmentHandlerRef& xHandler, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, ::oox::drawingml::FillProperties& rFillProperties ) throw();
+ virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException);
+};
+
+// ---------------------------------------------------------------------
+
+class GradFillPropertiesContext : public FillPropertiesGroupContext
+{
+public:
+ GradFillPropertiesContext( const oox::core::FragmentHandlerRef& xHandler, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, ::oox::drawingml::FillProperties& rFillProperties ) throw();
+
+ virtual void SAL_CALL endFastElement( sal_Int32 aElementToken ) throw (SAXException, RuntimeException);
+ virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException);
+};
+
+// ---------------------------------------------------------------------
+
+class PattFillPropertiesContext : public FillPropertiesGroupContext
+{
+public:
+ PattFillPropertiesContext( const oox::core::FragmentHandlerRef& xHandler, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, ::oox::drawingml::FillProperties& rFillProperties ) throw();
+
+ virtual void SAL_CALL startFastElement( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException);
+ virtual void SAL_CALL endFastElement( sal_Int32 aElementToken ) throw (SAXException, RuntimeException);
+ virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException);
+};
+
+// ---------------------------------------------------------------------
+
+class GrpFillPropertiesContext : public FillPropertiesGroupContext
+{
+public:
+ GrpFillPropertiesContext( const oox::core::FragmentHandlerRef& xHandler, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, ::oox::drawingml::FillProperties& rFillProperties ) throw();
+
+ virtual void SAL_CALL startFastElement( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException);
+ virtual void SAL_CALL endFastElement( sal_Int32 aElementToken ) throw (SAXException, RuntimeException);
+ virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException);
+};
+
+// ---------------------------------------------------------------------
+
+class clrChangeContext : public ::oox::core::Context
+{
+ oox::drawingml::ColorPtr& mraClrFrom;
+ oox::drawingml::ColorPtr& mraClrTo;
+ sal_Bool mbUseAlpha;
+public:
+ clrChangeContext( const oox::core::FragmentHandlerRef& xHandler, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes,
+ oox::drawingml::ColorPtr& raClrFrom, oox::drawingml::ColorPtr& raClrTo ) throw();
+ ~clrChangeContext();
+ virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException);
+};
+
+// ---------------------------------------------------------------------
+
+FillPropertiesGroupContext::FillPropertiesGroupContext( const FragmentHandlerRef& xHandler, ::com::sun::star::drawing::FillStyle eFillStyle, oox::drawingml::FillProperties& rFillProperties ) throw()
+: ::oox::core::Context( xHandler )
+, mrFillProperties( rFillProperties )
+{
+ static const OUString sFillStyle = CREATE_OUSTRING( "FillStyle" );
+ mrFillProperties.getFillPropertyMap()[ sFillStyle ] <<= eFillStyle;
+}
+
+// ---------------------------------------------------------------------
+
+Reference< XFastContextHandler > FillPropertiesGroupContext::StaticCreateContext( const FragmentHandlerRef& xHandler, sal_Int32 aElementToken,
+ const Reference< XFastAttributeList >& xAttribs, ::oox::drawingml::FillProperties& rFillProperties )
+ throw ( SAXException, RuntimeException )
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_noFill:
+ xRet.set( new NoFillContext( xHandler, rFillProperties ) );
+ break;
+ case NMSP_DRAWINGML|XML_solidFill:
+ xRet.set( new SolidColorFillPropertiesContext( xHandler, xAttribs, rFillProperties ) );
+ break;
+ case NMSP_DRAWINGML|XML_gradFill:
+ xRet.set( new GradFillPropertiesContext( xHandler, xAttribs, rFillProperties ) );
+ break;
+ case NMSP_DRAWINGML|XML_blipFill:
+ xRet.set( new BlipFillPropertiesContext( xHandler, xAttribs, rFillProperties ) );
+ break;
+ case NMSP_DRAWINGML|XML_pattFill:
+ xRet.set( new PattFillPropertiesContext( xHandler, xAttribs, rFillProperties ) );
+ break;
+ case NMSP_DRAWINGML|XML_grpFill:
+ xRet.set( new GrpFillPropertiesContext( xHandler, xAttribs, rFillProperties ) );
+ break;
+ }
+ return xRet;
+}
+
+// ---------------------------------------------------------------------
+
+NoFillContext::NoFillContext( const FragmentHandlerRef& xHandler, oox::drawingml::FillProperties& rFillProperties ) throw()
+: FillPropertiesGroupContext( xHandler, FillStyle_NONE, rFillProperties )
+{
+}
+
+// ---------------------------------------------------------------------
+
+SolidColorFillPropertiesContext::SolidColorFillPropertiesContext( const FragmentHandlerRef& xHandler, const Reference< XFastAttributeList >&, ::oox::drawingml::FillProperties& rFillProperties ) throw()
+: FillPropertiesGroupContext( xHandler, FillStyle_SOLID, rFillProperties )
+{
+}
+Reference< XFastContextHandler > SolidColorFillPropertiesContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& ) throw (SAXException, RuntimeException)
+{
+ // colorTransformGroup
+
+ // color should be available as rgb in member mnColor already, now modify it depending on
+ // the transformation elements
+
+ Reference< XFastContextHandler > xRet;
+ switch( aElementToken )
+ {
+
+ case NMSP_DRAWINGML|XML_scrgbClr: // CT_ScRgbColor
+ case NMSP_DRAWINGML|XML_srgbClr: // CT_SRgbColor
+ case NMSP_DRAWINGML|XML_hslClr: // CT_HslColor
+ case NMSP_DRAWINGML|XML_sysClr: // CT_SystemColor
+ case NMSP_DRAWINGML|XML_schemeClr: // CT_SchemeColor
+ case NMSP_DRAWINGML|XML_prstClr: // CT_PresetColor
+ {
+ xRet.set( new colorChoiceContext( getHandler(), *(mrFillProperties.getFillColor().get()) ) );
+ break;
+ }
+ case NMSP_DRAWINGML|XML_tint: // CT_PositiveFixedPercentage
+ case NMSP_DRAWINGML|XML_shade: // CT_PositiveFixedPercentage
+ case NMSP_DRAWINGML|XML_comp: // CT_ComplementTransform
+ case NMSP_DRAWINGML|XML_inv: // CT_InverseTransform
+ case NMSP_DRAWINGML|XML_gray: // CT_GrayscaleTransform
+ case NMSP_DRAWINGML|XML_alpha: // CT_PositiveFixedPercentage
+ case NMSP_DRAWINGML|XML_alphaOff: // CT_FixedPercentage
+ case NMSP_DRAWINGML|XML_alphaMod: // CT_PositivePercentage
+ case NMSP_DRAWINGML|XML_hue: // CT_PositiveFixedAngle
+ case NMSP_DRAWINGML|XML_hueOff: // CT_Angle
+ case NMSP_DRAWINGML|XML_hueMod: // CT_PositivePercentage
+ case NMSP_DRAWINGML|XML_sat: // CT_Percentage
+ case NMSP_DRAWINGML|XML_satOff: // CT_Percentage
+ case NMSP_DRAWINGML|XML_satMod: // CT_Percentage
+ case NMSP_DRAWINGML|XML_lum: // CT_Percentage
+ case NMSP_DRAWINGML|XML_lumOff: // CT_Percentage
+ case NMSP_DRAWINGML|XML_lumMod: // CT_Percentage
+ case NMSP_DRAWINGML|XML_red: // CT_Percentage
+ case NMSP_DRAWINGML|XML_redOff: // CT_Percentage
+ case NMSP_DRAWINGML|XML_redMod: // CT_Percentage
+ case NMSP_DRAWINGML|XML_green: // CT_Percentage
+ case NMSP_DRAWINGML|XML_greenOff: // CT_Percentage
+ case NMSP_DRAWINGML|XML_greenMod: // CT_Percentage
+ case NMSP_DRAWINGML|XML_blue: // CT_Percentage
+ case NMSP_DRAWINGML|XML_blueOff: // CT_Percentage
+ case NMSP_DRAWINGML|XML_blueMod: // CT_Percentage
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+}
+
+// ---------------------------------------------------------------------
+
+GradFillPropertiesContext::GradFillPropertiesContext( const FragmentHandlerRef& xHandler, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >&, ::oox::drawingml::FillProperties& rFillProperties ) throw()
+: FillPropertiesGroupContext( xHandler, FillStyle_GRADIENT, rFillProperties )
+{
+}
+
+void GradFillPropertiesContext::endFastElement( sal_Int32 ) throw (SAXException, RuntimeException)
+{
+}
+
+Reference< XFastContextHandler > GradFillPropertiesContext::createFastChildContext( sal_Int32, const Reference< XFastAttributeList >& ) throw (SAXException, RuntimeException)
+{
+ return this;
+}
+
+// ---------------------------------------------------------------------
+// CT_BlipFill
+// ---------------------------------------------------------------------
+
+BlipFillPropertiesContext::BlipFillPropertiesContext( const FragmentHandlerRef& xHandler, const Reference< XFastAttributeList >&,
+ ::oox::drawingml::FillProperties& rFillProperties )
+ throw()
+: FillPropertiesGroupContext( xHandler, FillStyle_BITMAP, rFillProperties )
+, meBitmapMode( BitmapMode_REPEAT )
+, mnWidth( 0 )
+, mnHeight( 0 )
+{
+ /* todo
+ if( xAttribs->hasAttribute( XML_dpi ) )
+ {
+ xsd:unsignedInt
+ DPI (dots per inch) used to calculate the size of the blip. If not present or zero,
+ the DPI in the blip is used.
+
+ }
+ if( xAttribs->hasAttribute( XML_rotWithShape ) )
+ {
+ xsd:boolean
+ fill should rotate with the shape
+ }
+ */
+}
+
+void BlipFillPropertiesContext::endFastElement( sal_Int32 ) throw (SAXException, RuntimeException)
+{
+ if( msEmbed.getLength() )
+ {
+ const OUString aFragmentPath = getHandler()->getFragmentPathFromRelId( msEmbed );
+ if( aFragmentPath.getLength() > 0 ) try
+ {
+ // get the input stream for the fill bitmap
+ XmlFilterRef xFilter = getHandler()->getFilter();
+ Reference< XInputStream > xInputStream( xFilter->openInputStream( aFragmentPath ), UNO_QUERY_THROW );
+
+ // load the fill bitmap into an XGraphic with the GraphicProvider
+ static const OUString sGraphicProvider = CREATE_OUSTRING( "com.sun.star.graphic.GraphicProvider" );
+ Reference< XMultiServiceFactory > xMSFT( xFilter->getServiceFactory(), UNO_QUERY_THROW );
+ Reference< XGraphicProvider > xGraphicProvider( xMSFT->createInstance( sGraphicProvider ), UNO_QUERY_THROW );
+
+ static const OUString sInputStream = CREATE_OUSTRING( "InputStream" );
+ PropertyValues aMediaProperties(1);
+ aMediaProperties[0].Name = sInputStream;
+ aMediaProperties[0].Value <<= xInputStream;
+
+ Reference< XGraphic > xGraphic( xGraphicProvider->queryGraphic(aMediaProperties ) );
+ mrFillProperties.mxGraphic = xGraphic;
+ }
+ catch( Exception& )
+ {
+ OSL_ENSURE( false,
+ (rtl::OString("oox::drawingml::BlipFillPropertiesContext::EndElement(), "
+ "exception caught: ") +
+ rtl::OUStringToOString(
+ comphelper::anyToString( cppu::getCaughtException() ),
+ RTL_TEXTENCODING_UTF8 )).getStr() );
+
+ }
+
+ static const OUString sFillBitmapMode = CREATE_OUSTRING( "FillBitmapMode" );
+ mrFillProperties.getFillPropertyMap()[ sFillBitmapMode ] <<= meBitmapMode;
+ }
+}
+
+Reference< XFastContextHandler > BlipFillPropertiesContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_blip: // CT_Blip
+// mnWidth = xAttribs.getInt32( XML_w );
+// mnHeight = xAttribs.getInt32( XML_h );
+ msEmbed = xAttribs->getOptionalValue(NMSP_RELATIONSHIPS|XML_embed); // relationship identifer for embedded blobs
+ msLink = xAttribs->getOptionalValue(NMSP_RELATIONSHIPS|XML_link); // relationship identifer for linked blobs
+ break;
+ case NMSP_DRAWINGML|XML_alphaBiLevel:
+ case NMSP_DRAWINGML|XML_alphaCeiling:
+ case NMSP_DRAWINGML|XML_alphaFloor:
+ case NMSP_DRAWINGML|XML_alphaInv:
+ case NMSP_DRAWINGML|XML_alphaMod:
+ case NMSP_DRAWINGML|XML_alphaModFix:
+ case NMSP_DRAWINGML|XML_alphaRepl:
+ case NMSP_DRAWINGML|XML_biLevel:
+ case NMSP_DRAWINGML|XML_blur:
+ break;
+ case NMSP_DRAWINGML|XML_clrChange:
+ {
+ xRet = new clrChangeContext( getHandler(), xAttribs, mrFillProperties.getColorChangeFrom(), mrFillProperties.getColorChangeTo() );
+ }
+ break;
+ case NMSP_DRAWINGML|XML_clrRepl:
+ case NMSP_DRAWINGML|XML_duotone:
+ case NMSP_DRAWINGML|XML_extLst:
+ case NMSP_DRAWINGML|XML_fillOverlay:
+ case NMSP_DRAWINGML|XML_grayscl:
+ case NMSP_DRAWINGML|XML_hsl:
+ case NMSP_DRAWINGML|XML_lum:
+ case NMSP_DRAWINGML|XML_tint:
+ break;
+
+ case NMSP_DRAWINGML|XML_srcRect: // CT_RelativeRect
+// todo maSrcRect = GetRelativeRect( xAttribs );
+ break;
+ case NMSP_DRAWINGML|XML_tile: // CT_TileInfo
+ meBitmapMode = BitmapMode_REPEAT;
+/* todo
+ mnTileX = GetCoordinate( xAttribs[ XML_tx ] ); // additional horizontal offset after alignment
+ mnTileY = GetCoordinate( xAttribs[ XML_ty ] ); // additional vertical offset after alignment
+ mnSX = xAttribs.getInt32( XML_sx, 100000 ); // amount to horizontally scale the srcRect
+ mnSX = xAttribs.getInt32( XML_sy, 100000 ); // amount to vertically scale the srcRect
+ mnFlip = xAttribs->getOptionalValueToken( XML_flip ); // ST_TileFlipMode how to flip the tile when it repeats
+ mnAlign = xAttribs->getOptionalValueToken( XML_algn ); // ST_RectAlignment where to align the first tile with respect to the shape; alignment happens after the scaling, but before the additional offset.
+*/
+ break;
+ case NMSP_DRAWINGML|XML_stretch: // CT_StretchInfo
+ meBitmapMode = BitmapMode_STRETCH;
+ break;
+ case NMSP_DRAWINGML|XML_fillRect:
+// todo maFillRect = GetRelativeRect( xAttribs );
+ break;
+ }
+ if ( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+}
+
+// ---------------------------------------------------------------------
+
+PattFillPropertiesContext::PattFillPropertiesContext( const FragmentHandlerRef& xHandler, const Reference< XFastAttributeList >&, ::oox::drawingml::FillProperties& rFillProperties ) throw()
+: FillPropertiesGroupContext( xHandler, FillStyle_HATCH, rFillProperties )
+{
+}
+
+void PattFillPropertiesContext::startFastElement( sal_Int32, const Reference< XFastAttributeList >& ) throw (SAXException, RuntimeException)
+{
+}
+
+void PattFillPropertiesContext::endFastElement( sal_Int32 ) throw (SAXException, RuntimeException)
+{
+}
+
+Reference< XFastContextHandler > PattFillPropertiesContext::createFastChildContext( sal_Int32, const Reference< XFastAttributeList >& ) throw (SAXException, RuntimeException)
+{
+ return this;
+}
+
+// ---------------------------------------------------------------------
+
+GrpFillPropertiesContext::GrpFillPropertiesContext( const FragmentHandlerRef& xHandler,const Reference< XFastAttributeList >&, ::oox::drawingml::FillProperties& rFillProperties ) throw()
+: FillPropertiesGroupContext( xHandler, FillStyle_NONE, rFillProperties )
+{
+}
+
+void GrpFillPropertiesContext::startFastElement( sal_Int32, const Reference< XFastAttributeList >& ) throw (SAXException, RuntimeException)
+{
+}
+
+void GrpFillPropertiesContext::endFastElement( sal_Int32 ) throw (SAXException, RuntimeException)
+{
+}
+
+Reference< XFastContextHandler > GrpFillPropertiesContext::createFastChildContext( sal_Int32, const Reference< XFastAttributeList >& )
+ throw (SAXException, RuntimeException)
+{
+ return this;
+}
+
+
+// ---------------------------------------------------------------------
+
+clrChangeContext::clrChangeContext( const FragmentHandlerRef& xHandler,const Reference< XFastAttributeList >& xAttributes,
+ ColorPtr& raClrFrom, ColorPtr& raClrTo ) throw()
+: Context( xHandler )
+, mraClrFrom( raClrFrom )
+, mraClrTo( raClrTo )
+, mbUseAlpha( xAttributes->getOptionalValueToken( XML_useA, XML_true ) == XML_true ? sal_True : sal_False )
+{
+ mraClrFrom = ColorPtr( new Color() );
+ mraClrTo = ColorPtr( new Color() );
+}
+clrChangeContext::~clrChangeContext()
+{
+ if ( !mbUseAlpha )
+ mraClrTo->mbAlphaColor = sal_False;
+}
+Reference< XFastContextHandler > clrChangeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& )
+ throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_clrFrom: // CT_Color
+ xRet.set( new colorChoiceContext( getHandler(), *mraClrFrom.get() ) );
+ break;
+ case NMSP_DRAWINGML|XML_clrTo: // CT_Color
+ xRet.set( new colorChoiceContext( getHandler(), *mraClrTo.get() ) );
+ break;
+ default:
+ break;
+ }
+ return xRet;
+}
+
+} }
diff --git a/oox/source/drawingml/graphicshapecontext.cxx b/oox/source/drawingml/graphicshapecontext.cxx
new file mode 100644
index 000000000000..c9e9de409d88
--- /dev/null
+++ b/oox/source/drawingml/graphicshapecontext.cxx
@@ -0,0 +1,335 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: graphicshapecontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include <osl/diagnose.h>
+
+#include "oox/drawingml/fillpropertiesgroupcontext.hxx"
+#include "oox/drawingml/graphicshapecontext.hxx"
+#include "oox/drawingml/diagram/diagramfragmenthandler.hxx"
+#include "oox/core/namespaces.hxx"
+#include "oox/drawingml/drawingmltypes.hxx"
+#include "tokens.hxx"
+#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
+#include <comphelper/processfactory.hxx>
+#endif
+#include "com/sun/star/container/XNameAccess.hpp"
+#include "com/sun/star/io/XStream.hpp"
+#include "com/sun/star/beans/XPropertySet.hpp"
+#include "com/sun/star/document/XEmbeddedObjectResolver.hpp"
+#include <com/sun/star/graphic/XGraphicProvider.hpp>
+
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::oox::core;
+using namespace ::com::sun::star::xml::sax;
+
+namespace oox { namespace drawingml {
+
+// ====================================================================
+// CT_Picture
+GraphicShapeContext::GraphicShapeContext( const FragmentHandlerRef& xHandler, ShapePtr pMasterShapePtr, ShapePtr pShapePtr )
+: ShapeContext( xHandler, pMasterShapePtr, pShapePtr )
+{
+}
+
+Reference< XFastContextHandler > GraphicShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElementToken &(~NMSP_MASK) )
+ {
+ // CT_ShapeProperties
+ case XML_xfrm:
+ xRet.set( new Transform2DContext( getHandler(), xAttribs, *(mpShapePtr.get()) ) );
+ break;
+ case XML_blipFill:
+ xRet.set( new BlipFillPropertiesContext( getHandler(), xAttribs, *(mpShapePtr->getGraphicProperties().get()) ) );
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set( ShapeContext::createFastChildContext( aElementToken, xAttribs ) );
+
+ return xRet;
+}
+
+// ====================================================================
+// CT_GraphicalObjectFrameContext
+GraphicalObjectFrameContext::GraphicalObjectFrameContext( const FragmentHandlerRef& xHandler, ShapePtr pMasterShapePtr, ShapePtr pShapePtr )
+: ShapeContext( xHandler, pMasterShapePtr, pShapePtr )
+{
+}
+
+Reference< XFastContextHandler > GraphicalObjectFrameContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElementToken &(~NMSP_MASK) )
+ {
+ // CT_ShapeProperties
+ case XML_nvGraphicFramePr: // CT_GraphicalObjectFrameNonVisual
+ break;
+ case XML_xfrm: // CT_Transform2D
+ xRet.set( new Transform2DContext( getHandler(), xAttribs, *(mpShapePtr.get()) ) );
+ break;
+ case XML_graphic: // CT_GraphicalObject
+ xRet.set( this );
+ break;
+
+ case XML_graphicData : // CT_GraphicalObjectData
+ {
+ rtl::OUString sUri( xAttribs->getOptionalValue( XML_uri ) );
+ if ( sUri.compareToAscii( "http://schemas.openxmlformats.org/presentationml/2006/ole" ) == 0 )
+ xRet.set( new PresentationOle2006Context( mxHandler, mpShapePtr ) );
+ else if ( sUri.compareToAscii( "http://schemas.openxmlformats.org/drawingml/2006/diagram" ) == 0 )
+ xRet.set( new DiagramGraphicDataContext( mxHandler, mpShapePtr ) );
+ else if ( sUri.compareToAscii( "http://schemas.openxmlformats.org/drawingml/2006/table" ) == 0 )
+ // TODO deal with tables too.
+ xRet.set( this );
+ else
+ {
+ OSL_TRACE( "OOX: Ignore graphicsData of %s", OUSTRING_TO_CSTR( sUri ) );
+ return xRet;
+ }
+ }
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set( ShapeContext::createFastChildContext( aElementToken, xAttribs ) );
+
+ return xRet;
+}
+
+// ====================================================================
+
+PresentationOle2006Context::PresentationOle2006Context( const FragmentHandlerRef& xHandler, ShapePtr pShapePtr )
+: ShapeContext( xHandler, ShapePtr(), pShapePtr )
+{
+}
+
+PresentationOle2006Context::~PresentationOle2006Context()
+{
+ XmlFilterRef xFilter = getHandler()->getFilter();
+ const OUString aFragmentPath = getHandler()->getFragmentPathFromRelId( msId );
+ if( aFragmentPath.getLength() > 0 )
+ {
+ Reference< ::com::sun::star::io::XInputStream > xInputStream( xFilter->openInputStream( aFragmentPath ), UNO_QUERY_THROW );
+
+ Sequence< sal_Int8 > aData;
+ xInputStream->readBytes( aData, 0x7fffffff );
+ uno::Reference< lang::XMultiServiceFactory > xMSF( xFilter->getModel(), UNO_QUERY );
+ Reference< com::sun::star::document::XEmbeddedObjectResolver > xEmbeddedResolver( xMSF->createInstance( OUString::createFromAscii( "com.sun.star.document.ImportEmbeddedObjectResolver" ) ), UNO_QUERY );
+
+ if ( xEmbeddedResolver.is() )
+ {
+ Reference< com::sun::star::container::XNameAccess > xNA( xEmbeddedResolver, UNO_QUERY );
+ if( xNA.is() )
+ {
+ Reference < XOutputStream > xOLEStream;
+ OUString aURL = CREATE_OUSTRING( "Obj12345678" );
+ Any aAny( xNA->getByName( aURL ) );
+ aAny >>= xOLEStream;
+ if ( xOLEStream.is() )
+ {
+ xOLEStream->writeBytes( aData );
+ xOLEStream->closeOutput();
+
+ const OUString sProtocol = CREATE_OUSTRING( "vnd.sun.star.EmbeddedObject:" );
+ rtl::OUString aPersistName( xEmbeddedResolver->resolveEmbeddedObjectURL( aURL ) );
+ aPersistName = aPersistName.copy( sProtocol.getLength() );
+
+ static const OUString sPersistName = CREATE_OUSTRING( "PersistName" );
+ mpShapePtr->getShapeProperties()[ sPersistName ] <<= aPersistName;
+ }
+ }
+ Reference< XComponent > xComp( xEmbeddedResolver, UNO_QUERY );
+ xComp->dispose();
+ }
+ }
+
+ // taking care of the representation graphic
+ if ( msSpid.getLength() )
+ {
+ oox::vml::DrawingPtr pDrawingPtr = xFilter->getDrawings();
+ if ( pDrawingPtr.get() )
+ {
+ rtl::OUString aGraphicURL( pDrawingPtr->getGraphicUrlById( msSpid ) );
+ if ( aGraphicURL.getLength() )
+ {
+ try
+ {
+ uno::Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
+ Reference< io::XInputStream > xInputStream( xFilter->openInputStream( aGraphicURL ), UNO_QUERY_THROW );
+ Reference< graphic::XGraphicProvider > xGraphicProvider( xMSF->createInstance( OUString::createFromAscii( "com.sun.star.graphic.GraphicProvider" ) ), UNO_QUERY_THROW );
+ if ( xInputStream.is() && xGraphicProvider.is() )
+ {
+ Sequence< PropertyValue > aArgs( 1 );
+ const OUString sInputStream = CREATE_OUSTRING( "InputStream" );
+ aArgs[ 0 ].Name = sInputStream;
+ aArgs[ 0 ].Value <<= xInputStream;
+ Reference< graphic::XGraphic > xGraphic = xGraphicProvider->queryGraphic( aArgs );
+ if ( xGraphic.is() )
+ {
+ static const OUString sEmptyGraphicURL;
+ static const OUString sGraphicURL = CREATE_OUSTRING( "GraphicURL" );
+ mpShapePtr->getShapeProperties()[ sGraphicURL ] <<= sEmptyGraphicURL;
+
+ static const OUString sThumbnailGraphic = CREATE_OUSTRING( "Graphic" );
+ mpShapePtr->getShapeProperties()[ sThumbnailGraphic ] <<= xGraphic;
+ }
+ }
+ }
+ catch( Exception& )
+ {
+ }
+ }
+ }
+ }
+}
+
+Reference< XFastContextHandler > PresentationOle2006Context::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElementToken &(~NMSP_MASK) )
+ {
+ case XML_oleObj:
+ {
+ msSpid = xAttribs->getOptionalValue( XML_spid );
+ msName = xAttribs->getOptionalValue( XML_name );
+ msId = xAttribs->getOptionalValue( NMSP_RELATIONSHIPS|XML_id );
+ mnWidth = GetCoordinate( xAttribs->getOptionalValue( XML_imgW ) );
+ mnHeight = GetCoordinate( xAttribs->getOptionalValue( XML_imgH ) );
+ msProgId = xAttribs->getOptionalValue( XML_progId );
+ }
+ break;
+
+ case XML_embed:
+ {
+ mnFollowColorSchemeToken = xAttribs->getOptionalValueToken( XML_followColorScheme, XML_full );
+ }
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set( ShapeContext::createFastChildContext( aElementToken, xAttribs ) );
+
+ return xRet;
+}
+
+DiagramGraphicDataContext::DiagramGraphicDataContext( const ::oox::core::FragmentHandlerRef& xHandler, ShapePtr pShapePtr )
+: ShapeContext( xHandler, ShapePtr(), pShapePtr )
+{
+}
+
+
+
+DiagramGraphicDataContext::~DiagramGraphicDataContext()
+{
+
+}
+
+DiagramPtr DiagramGraphicDataContext::loadDiagram()
+{
+ DiagramPtr pDiagram( new Diagram() );
+ const oox::core::XmlFilterRef& xFilter( getHandler()->getFilter() );
+
+ // data
+ OUString sDmPath = getHandler()->getFragmentPathFromRelId( msDm );
+ if( sDmPath.getLength() > 0 )
+ {
+ DiagramDataPtr pData( new DiagramData() );
+ pDiagram->setData( pData );
+ xFilter->importFragment( new DiagramDataFragmentHandler( xFilter, sDmPath, pData ) );
+ }
+ // layout
+ OUString sLoPath = getHandler()->getFragmentPathFromRelId( msLo );
+ if( sLoPath.getLength() > 0 )
+ {
+ DiagramLayoutPtr pLayout( new DiagramLayout() );
+ pDiagram->setLayout( pLayout );
+ xFilter->importFragment( new DiagramLayoutFragmentHandler( xFilter, sLoPath, pLayout ) );
+ }
+ // style
+ OUString sQsPath = getHandler()->getFragmentPathFromRelId( msQs );
+ if( sQsPath.getLength() > 0 )
+ {
+ DiagramQStylesPtr pStyles( new DiagramQStyles() );
+ pDiagram->setQStyles( pStyles );
+ xFilter->importFragment( new DiagramQStylesFragmentHandler( xFilter, sQsPath, pStyles ) );
+ }
+ // colors
+ OUString sCsPath = getHandler()->getFragmentPathFromRelId( msCs );
+ if( sCsPath.getLength() > 0 )
+ {
+ DiagramColorsPtr pColors( new DiagramColors() );
+ pDiagram->setColors( pColors );
+ xFilter->importFragment( new DiagramColorsFragmentHandler( xFilter, sCsPath, pColors ) ) ;
+ }
+
+ return pDiagram;
+}
+
+
+Reference< XFastContextHandler > DiagramGraphicDataContext::createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElementToken )
+ {
+ case NMSP_DIAGRAM|XML_relIds:
+ {
+ msDm = xAttribs->getOptionalValue( NMSP_RELATIONSHIPS|XML_dm );
+ msLo = xAttribs->getOptionalValue( NMSP_RELATIONSHIPS|XML_lo );
+ msQs = xAttribs->getOptionalValue( NMSP_RELATIONSHIPS|XML_qs );
+ msCs = xAttribs->getOptionalValue( NMSP_RELATIONSHIPS|XML_cs );
+ DiagramPtr pDiagram = loadDiagram();
+ pDiagram->addTo( mpShapePtr );
+ break;
+ }
+ default:
+ break;
+ }
+
+ if( !xRet.is() )
+ xRet.set( ShapeContext::createFastChildContext( aElementToken, xAttribs ) );
+
+ return xRet;
+}
+
+} }
diff --git a/oox/source/drawingml/hyperlinkcontext.cxx b/oox/source/drawingml/hyperlinkcontext.cxx
new file mode 100644
index 000000000000..d4c75b83663f
--- /dev/null
+++ b/oox/source/drawingml/hyperlinkcontext.cxx
@@ -0,0 +1,121 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: hyperlinkcontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2007 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "hyperlinkcontext.hxx"
+
+#include <rtl/ustring.hxx>
+
+#include <com/sun/star/xml/sax/XFastContextHandler.hpp>
+
+#include "oox/helper/propertymap.hxx"
+#include "oox/core/relations.hxx"
+#include "oox/core/namespaces.hxx"
+#include "oox/core/skipcontext.hxx"
+#include "oox/drawingml/embeddedwavaudiofile.hxx"
+#include "tokens.hxx"
+
+using ::rtl::OUString;
+using namespace ::oox::core;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+
+namespace oox { namespace drawingml {
+
+
+ HyperLinkContext::HyperLinkContext( const FragmentHandlerRef& xParent,
+ const Reference< XFastAttributeList >& xAttributes,
+ PropertyMap& aProperties)
+ : Context( xParent )
+ , maProperties(aProperties)
+ {
+ OUString aRelId = xAttributes->getOptionalValue( NMSP_RELATIONSHIPS|XML_id );
+ OSL_TRACE("OOX: URI rId %s", ::rtl::OUStringToOString (aRelId, RTL_TEXTENCODING_UTF8).pData->buffer);
+ const OUString& sHref = getHandler()->getRelations().getTargetFromRelId( aRelId );
+ if( sHref.getLength() > 0 )
+ {
+ OSL_TRACE("OOX: URI href %s", ::rtl::OUStringToOString (sHref, RTL_TEXTENCODING_UTF8).pData->buffer);
+ const OUString sURL( CREATE_OUSTRING( "URL" ) );
+ maProperties[ sURL ] <<= getHandler()->getFilter()->getAbsoluteUrl( sHref );
+ OUString sTooltip = xAttributes->getOptionalValue( NMSP_RELATIONSHIPS|XML_tooltip );
+ const OUString sRepresentation( CREATE_OUSTRING( "Representation" ) );
+ maProperties[ sRepresentation ] <<= sTooltip;
+
+ OUString sFrame = xAttributes->getOptionalValue( NMSP_RELATIONSHIPS|XML_tgtFrame );
+ if( sFrame.getLength() )
+ {
+ const OUString sTargetFrame( CREATE_OUSTRING( "TargetFrame" ) );
+ maProperties[ sTargetFrame ] <<= sFrame;
+ }
+
+// sValue = OUString( RTL_CONSTASCII_USTRINGPARAM( "" ) );
+// const rtl::OUString sUnvisitedCharStyleName( CREATE_OUSTRING( "UnvisitedCharStyleName" ) );
+// maProperties[ sUnvisitedCharStyleName ] <<= sValue;
+// const rtl::OUString sVisitedCharStyleName( CREATE_OUSTRING( "VisitedCharStyleName" ) );
+// maProperties[ sVisitedCharStyleName ] <<= sValue;
+
+ }
+ // TODO unhandled
+ // XML_invalidUrl
+ // XML_history
+ // XML_highlightClick
+ // XML_endSnd
+ // XML_action
+ }
+
+ HyperLinkContext::~HyperLinkContext()
+ {
+ }
+
+ Reference< XFastContextHandler > HyperLinkContext::createFastChildContext( ::sal_Int32 aElement,
+ const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
+ {
+ Reference< XFastContextHandler > xRet;
+ switch( aElement )
+ {
+ case NMSP_DRAWINGML|XML_extLst:
+ xRet.set( new SkipContext( getHandler() ) );
+ break;
+ case NMSP_DRAWINGML|XML_snd:
+ EmbeddedWAVAudioFile aAudio;
+ getEmbeddedWAVAudioFile( getHandler(), xAttribs, aAudio );
+ break;
+ }
+ if ( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+ }
+
+} }
diff --git a/oox/source/drawingml/hyperlinkcontext.hxx b/oox/source/drawingml/hyperlinkcontext.hxx
new file mode 100644
index 000000000000..f35261aaad54
--- /dev/null
+++ b/oox/source/drawingml/hyperlinkcontext.hxx
@@ -0,0 +1,67 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: hyperlinkcontext.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2007 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#ifndef OOX_DRAWINGML_HYPERLINKCONTEXT_HXX
+#define OOX_DRAWINGML_HYPERLINKCONTEXT_HXX
+
+#include <com/sun/star/xml/sax/XFastAttributeList.hpp>
+
+#include "oox/core/context.hxx"
+#include "oox/core/fragmenthandler.hxx"
+
+namespace oox { class PropertyMap; }
+
+namespace oox { namespace drawingml {
+
+ class HyperLinkContext : public ::oox::core::Context
+ {
+ public:
+ HyperLinkContext( const ::oox::core::FragmentHandlerRef& xParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs,
+ PropertyMap& aProperties);
+ ~HyperLinkContext();
+
+// virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) 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);
+
+ protected:
+ PropertyMap& maProperties;
+ };
+
+
+} }
+
+
+#endif
diff --git a/oox/source/drawingml/lineproperties.cxx b/oox/source/drawingml/lineproperties.cxx
new file mode 100644
index 000000000000..ed4261f7154b
--- /dev/null
+++ b/oox/source/drawingml/lineproperties.cxx
@@ -0,0 +1,349 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: lineproperties.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/lineproperties.hxx"
+#include "oox/drawingml/drawingmltypes.hxx"
+#include "oox/core/namespaces.hxx"
+#include "tokens.hxx"
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include "oox/helper/propertyset.hxx"
+#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
+#include <com/sun/star/drawing/PointSequence.hpp>
+#include <com/sun/star/drawing/FlagSequence.hpp>
+#include <com/sun/star/drawing/LineDash.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
+
+using rtl::OUString;
+using namespace ::oox::core;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+
+namespace oox { namespace drawingml {
+
+LineProperties::LineProperties()
+: maLineColor( new Color() )
+{
+}
+LineProperties::~LineProperties()
+{
+}
+
+void LineProperties::apply( const LinePropertiesPtr& rSourceLineProperties )
+{
+ maLineProperties.insert( rSourceLineProperties->maLineProperties.begin(), rSourceLineProperties->maLineProperties.end() );
+ if ( rSourceLineProperties->maLineColor->isUsed() )
+ maLineColor = rSourceLineProperties->maLineColor;
+ if ( rSourceLineProperties->moLineWidth )
+ moLineWidth = rSourceLineProperties->moLineWidth;
+ if ( rSourceLineProperties->moStartArrow )
+ moStartArrow = rSourceLineProperties->moStartArrow;
+ if ( rSourceLineProperties->moStartArrowWidth )
+ moStartArrowWidth = rSourceLineProperties->moStartArrowWidth;
+ if ( rSourceLineProperties->moStartArrowLength )
+ moStartArrowLength = rSourceLineProperties->moStartArrowLength;
+ if ( rSourceLineProperties->moEndArrow )
+ moEndArrow = rSourceLineProperties->moEndArrow;
+ if ( rSourceLineProperties->moEndArrowWidth )
+ moEndArrowWidth = rSourceLineProperties->moEndArrowWidth;
+ if ( rSourceLineProperties->moEndArrowLength )
+ moEndArrowLength = rSourceLineProperties->moEndArrowLength;
+ if ( rSourceLineProperties->moPresetDash )
+ moPresetDash = rSourceLineProperties->moPresetDash;
+ if ( rSourceLineProperties->moLineCap )
+ moLineCap = rSourceLineProperties->moLineCap;
+}
+
+static com::sun::star::drawing::PolyPolygonBezierCoords GetLineArrow( const sal_Int32 nLineWidth, const sal_Int32 nLineEndToken,
+ const sal_Int32 nArrowWidthToken, const sal_Int32 nArrowLengthToken, sal_Int32& rnArrowWidth, sal_Bool& rbArrowCenter, rtl::OUString& rsArrowName )
+{
+ uno::Sequence< awt::Point > aPoly;
+
+ double fLineWidth = nLineWidth < 70 ? 70.0 : nLineWidth;
+ double fLenghtMul, fWidthMul;
+ sal_Int32 nLineNumber;
+ switch( nArrowLengthToken )
+ {
+ default :
+ case XML_med: fLenghtMul = 3.0; nLineNumber = 2; break;
+ case XML_sm : fLenghtMul = 2.0; nLineNumber = 1; break;
+ case XML_lg : fLenghtMul = 5.0; nLineNumber = 3; break;
+ }
+ switch( nArrowWidthToken )
+ {
+ default :
+ case XML_med: fWidthMul = 3.0; nLineNumber += 3; break;
+ case XML_sm : fWidthMul = 2.0; break;
+ case XML_lg : fWidthMul = 5.0; nLineNumber += 6; break;
+ }
+ rbArrowCenter = sal_False;
+ switch ( nLineEndToken )
+ {
+ case XML_triangle :
+ {
+ aPoly.realloc( 4 );
+ aPoly[ 0 ] = awt::Point( static_cast< sal_Int32 >( fWidthMul * fLineWidth * 0.50 ), 0 );
+ aPoly[ 1 ] = awt::Point( static_cast< sal_Int32 >( fWidthMul * fLineWidth ), static_cast< sal_Int32 >( fLenghtMul * fLineWidth ) );
+ aPoly[ 2 ] = awt::Point( 0, static_cast< sal_Int32 >( fLenghtMul * fLineWidth ) );
+ aPoly[ 3 ] = awt::Point( static_cast< sal_Int32 >( fWidthMul * fLineWidth * 0.50 ), 0 );
+ static const OUString sArrowEnd( RTL_CONSTASCII_USTRINGPARAM( "msArrowEnd " ) );
+ rsArrowName = sArrowEnd;
+ }
+ break;
+
+ case XML_arrow :
+ {
+ switch( nArrowLengthToken )
+ {
+ default :
+ case XML_med: fLenghtMul = 4.5; break;
+ case XML_sm : fLenghtMul = 3.5; break;
+ case XML_lg : fLenghtMul = 6.0; break;
+ }
+ switch( nArrowWidthToken )
+ {
+ default :
+ case XML_med: fWidthMul = 4.5; break;
+ case XML_sm : fWidthMul = 3.5; break;
+ case XML_lg : fWidthMul = 6.0; break;
+ }
+ aPoly.realloc( 7 );
+ aPoly[ 0 ] = awt::Point( static_cast< sal_Int32 >( fWidthMul * fLineWidth * 0.50 ), 0 );
+ aPoly[ 1 ] = awt::Point( static_cast< sal_Int32 >( fWidthMul * fLineWidth ), static_cast< sal_Int32 >( fLenghtMul * fLineWidth * 0.91 ) );
+ aPoly[ 2 ] = awt::Point( static_cast< sal_Int32 >( fWidthMul * fLineWidth * 0.85 ), static_cast< sal_Int32 >( fLenghtMul * fLineWidth ) );
+ aPoly[ 3 ] = awt::Point( static_cast< sal_Int32 >( fWidthMul * fLineWidth * 0.50 ), static_cast< sal_Int32 >( fLenghtMul * fLineWidth * 0.36 ) );
+ aPoly[ 4 ] = awt::Point( static_cast< sal_Int32 >( fWidthMul * fLineWidth * 0.15 ), static_cast< sal_Int32 >( fLenghtMul * fLineWidth ) );
+ aPoly[ 5 ] = awt::Point( 0, static_cast< sal_Int32 >( fLenghtMul * fLineWidth * 0.91 ) );
+ aPoly[ 6 ] = awt::Point( static_cast< sal_Int32 >( fWidthMul * fLineWidth * 0.50 ), 0 );
+ static const OUString sArrowOpenEnd( RTL_CONSTASCII_USTRINGPARAM( "msArrowOpenEnd " ) );
+ rsArrowName = sArrowOpenEnd;
+ }
+ break;
+ case XML_stealth :
+ {
+ aPoly.realloc( 5 );
+ aPoly[ 0 ] = awt::Point( static_cast< sal_Int32 >( fWidthMul * fLineWidth * 0.50 ), 0 );
+ aPoly[ 1 ] = awt::Point( static_cast< sal_Int32 >( fWidthMul * fLineWidth ), static_cast< sal_Int32 >( fLenghtMul * fLineWidth ) );
+ aPoly[ 2 ] = awt::Point( static_cast< sal_Int32 >( fWidthMul * fLineWidth * 0.50 ), static_cast< sal_Int32 >( fLenghtMul * fLineWidth * 0.60 ) );
+ aPoly[ 3 ] = awt::Point( 0, static_cast< sal_Int32 >( fLenghtMul * fLineWidth ) );
+ aPoly[ 4 ] = awt::Point( static_cast< sal_Int32 >( fWidthMul * fLineWidth * 0.50 ), 0 );
+ static const OUString sArrowStealthEnd( RTL_CONSTASCII_USTRINGPARAM( "msArrowStealthEnd " ) );
+ rsArrowName = sArrowStealthEnd;
+ }
+ break;
+ case XML_diamond :
+ {
+ aPoly.realloc( 5 );
+ aPoly[ 0 ] = awt::Point( static_cast< sal_Int32 >( fWidthMul * fLineWidth * 0.50 ), 0 );
+ aPoly[ 1 ] = awt::Point( static_cast< sal_Int32 >( fWidthMul * fLineWidth ), static_cast< sal_Int32 >( fLenghtMul * fLineWidth * 0.50 ) );
+ aPoly[ 2 ] = awt::Point( static_cast< sal_Int32 >( fWidthMul * fLineWidth * 0.50 ), static_cast< sal_Int32 >( fLenghtMul * fLineWidth ) );
+ aPoly[ 3 ] = awt::Point( 0, static_cast< sal_Int32 >( fLenghtMul * fLineWidth * 0.50 ) );
+ aPoly[ 4 ] = awt::Point( static_cast< sal_Int32 >( fWidthMul * fLineWidth * 0.50 ), 0 );
+ static const OUString sArrowDiamondEnd( RTL_CONSTASCII_USTRINGPARAM( "msArrowDiamondEnd " ) );
+ rsArrowName = sArrowDiamondEnd;
+ rbArrowCenter = sal_True;
+ }
+ break;
+ case XML_oval :
+ {
+ aPoly.realloc( 5 );
+ aPoly[ 0 ] = awt::Point( static_cast< sal_Int32 >( fWidthMul * fLineWidth * 0.50 ), 0 );
+ aPoly[ 1 ] = awt::Point( static_cast< sal_Int32 >( fWidthMul * fLineWidth ), static_cast< sal_Int32 >( fLenghtMul * fLineWidth * 0.50 ) );
+ aPoly[ 2 ] = awt::Point( static_cast< sal_Int32 >( fWidthMul * fLineWidth * 0.50 ), static_cast< sal_Int32 >( fLenghtMul * fLineWidth ) );
+ aPoly[ 3 ] = awt::Point( 0, static_cast< sal_Int32 >( fLenghtMul * fLineWidth * 0.50 ) );
+ aPoly[ 4 ] = awt::Point( static_cast< sal_Int32 >( fWidthMul * fLineWidth * 0.50 ), 0 );
+ static const OUString sArrowOvalEnd( RTL_CONSTASCII_USTRINGPARAM( "msArrowOvalEnd " ) );
+ rsArrowName = sArrowOvalEnd;
+ rbArrowCenter = sal_True;
+ }
+ break;
+ default: break;
+ }
+ rsArrowName += rtl::OUString::valueOf( nLineNumber );
+ rnArrowWidth = static_cast< sal_Int32 >( fLineWidth * fWidthMul );
+
+ com::sun::star::drawing::PolyPolygonBezierCoords aPolyPolyBezier;
+ aPolyPolyBezier.Coordinates.realloc( 1 );
+ aPolyPolyBezier.Flags.realloc( 1 );
+ ::com::sun::star::drawing::PointSequence* pOuterSequence = aPolyPolyBezier.Coordinates.getArray();
+ ::com::sun::star::drawing::FlagSequence* pOuterFlags = aPolyPolyBezier.Flags.getArray();
+ pOuterSequence[ 0 ] = aPoly;
+ pOuterFlags[ 0 ] = ::com::sun::star::drawing::PolygonFlags( aPoly.getLength() );
+ return aPolyPolyBezier;
+}
+
+void setArrow( const ::oox::core::XmlFilterBase& rFilterBase, rtl::OUString& rName, com::sun::star::drawing::PolyPolygonBezierCoords& rPoly )
+{
+ uno::Reference< container::XNameContainer >& xMarker( rFilterBase.getMarkerTable() );
+ try
+ {
+ if( xMarker.is() )
+ {
+ if( xMarker->hasByName( rName ) )
+ xMarker->replaceByName( rName, Any( rPoly ) );
+ else
+ xMarker->insertByName( rName, Any( rPoly ) );
+ }
+ }
+ catch( container::ElementExistException& )
+ {}
+}
+
+void LineProperties::pushToPropSet( const ::oox::core::XmlFilterBase& rFilterBase,
+ const Reference < XPropertySet >& xPropSet ) const
+{
+ PropertySet aPropSet( xPropSet );
+ Sequence< OUString > aNames;
+ Sequence< Any > aValues;
+
+ maLineProperties.makeSequence( aNames, aValues );
+ aPropSet.setProperties( aNames, aValues );
+ if ( maLineColor->isUsed() )
+ {
+ const rtl::OUString sLineColor( OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "LineColor" ) ) );
+ xPropSet->setPropertyValue( sLineColor, Any( maLineColor->getColor( rFilterBase ) ) );
+ }
+ if ( moLineWidth )
+ {
+ const rtl::OUString sLineWidth( OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "LineWidth" ) ) );
+ xPropSet->setPropertyValue( sLineWidth, Any( *moLineWidth ) );
+ }
+ if ( moStartArrow && ( *moStartArrow != XML_none ) )
+ {
+ sal_Int32 nArrowWidth;
+ sal_Bool bArrowCenter;
+ rtl::OUString aArrowName;
+ com::sun::star::drawing::PolyPolygonBezierCoords aPoly( GetLineArrow( moLineWidth ? *moLineWidth : 70, *moStartArrow,
+ moStartArrowWidth ? *moStartArrowWidth : XML_med, moStartArrowLength ? *moStartArrowLength : XML_med, nArrowWidth, bArrowCenter, aArrowName ) );
+ const rtl::OUString sLineStart( OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "LineStart" ) ) );
+ const rtl::OUString sLineStartName( OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "LineStartName" ) ) );
+ const rtl::OUString sLineStartCenter( OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "LineStartCenter" ) ) );
+ const rtl::OUString sLineStartWidth( OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "LineStartWidth" ) ) );
+// xPropSet->setPropertyValue( sLineStart, Any( aPoly ) );
+ setArrow( rFilterBase, aArrowName, aPoly );
+ xPropSet->setPropertyValue( sLineStartName, Any( aArrowName ) );
+ xPropSet->setPropertyValue( sLineStartCenter, Any( bArrowCenter ) );
+ xPropSet->setPropertyValue( sLineStartWidth, Any( nArrowWidth ) );
+ }
+ if ( moEndArrow && ( *moEndArrow != XML_none ) )
+ {
+ sal_Int32 nArrowWidth;
+ sal_Bool bArrowCenter;
+ rtl::OUString aArrowName;
+ com::sun::star::drawing::PolyPolygonBezierCoords aPoly( GetLineArrow( moLineWidth ? *moLineWidth : 70, *moEndArrow,
+ moEndArrowWidth ? *moEndArrowWidth : XML_med, moEndArrowLength ? *moEndArrowLength : XML_med, nArrowWidth, bArrowCenter, aArrowName ) );
+ const rtl::OUString sLineEnd( OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "LineEnd" ) ) );
+ const rtl::OUString sLineEndName( OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "LineEndName" ) ) );
+ const rtl::OUString sLineEndCenter( OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "LineEndCenter" ) ) );
+ const rtl::OUString sLineEndWidth( OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "LineEndWidth" ) ) );
+// xPropSet->setPropertyValue( sLineEnd, Any( aPoly ) );
+ setArrow( rFilterBase, aArrowName, aPoly );
+ xPropSet->setPropertyValue( sLineEndName, Any( aArrowName ) );
+ xPropSet->setPropertyValue( sLineEndCenter, Any( bArrowCenter ) );
+ xPropSet->setPropertyValue( sLineEndWidth, Any( nArrowWidth ) );
+ }
+ if ( moPresetDash ) // ST_PresetLineDashVal
+ {
+ const rtl::OUString sLineStyle( OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "LineStyle" ) ) );
+ if ( *moPresetDash == XML_solid )
+ xPropSet->setPropertyValue( sLineStyle, Any( drawing::LineStyle_SOLID ) );
+ else
+ {
+ sal_Int32 nLineWidth = moLineWidth ? *moLineWidth : 288;
+ drawing::LineDash aLineDash;
+ aLineDash.Style = drawing::DashStyle_ROUNDRELATIVE;
+ if ( moLineCap )
+ {
+ switch( *moLineCap )
+ {
+ default:
+ case XML_rnd: // Rounded ends. Semi-circle protrudes by half line width.
+ aLineDash.Style = drawing::DashStyle_ROUNDRELATIVE;
+ break;
+ case XML_sq: // Square protrudes by half line width.
+ aLineDash.Style = drawing::DashStyle_RECTRELATIVE;
+ break;
+ case XML_flat: // Line ends at end point.
+ aLineDash.Style = drawing::DashStyle_RECT;
+ break;
+ }
+ }
+ aLineDash.Dots = 1;
+ aLineDash.DotLen = nLineWidth;
+ aLineDash.Dashes = 0;
+ aLineDash.DashLen = ( 8 * nLineWidth );
+ aLineDash.Distance = ( 3 * nLineWidth );
+
+ switch( *moPresetDash )
+ {
+ default :
+ case XML_dash :
+ case XML_sysDash :
+ aLineDash.DashLen = ( 4 * nLineWidth ); // !!PASSTHROUGH INTENDED
+ case XML_lgDash :
+ {
+ aLineDash.Dots = 0;
+ aLineDash.Dashes = 1;
+ }
+ break;
+ case XML_dashDot :
+ case XML_sysDashDot :
+ aLineDash.DashLen = ( 4 * nLineWidth ); // !!PASSTHROUGH INTENDED
+ case XML_lgDashDot :
+ aLineDash.Dashes = 1;
+ break;
+ case XML_sysDashDotDot :
+ aLineDash.DashLen = ( 4 * nLineWidth ); // !!PASSTHROUGH INTENDED
+ case XML_lgDashDotDot :
+ {
+ aLineDash.Dots = 2;
+ aLineDash.Dashes = 1;
+ }
+ break;
+ case XML_dot :
+ case XML_sysDot :
+ aLineDash.Distance = aLineDash.DotLen;
+ break;
+ }
+ const rtl::OUString sLineDash( OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "LineDash" ) ) );
+ xPropSet->setPropertyValue( sLineStyle, Any( drawing::LineStyle_DASH ) );
+ xPropSet->setPropertyValue( sLineDash, Any( aLineDash ) );
+ }
+ }
+}
+
+} }
diff --git a/oox/source/drawingml/linepropertiescontext.cxx b/oox/source/drawingml/linepropertiescontext.cxx
new file mode 100644
index 000000000000..5f21b0aa7109
--- /dev/null
+++ b/oox/source/drawingml/linepropertiescontext.cxx
@@ -0,0 +1,157 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: linepropertiescontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/linepropertiescontext.hxx"
+
+#include <com/sun/star/drawing/LineJoint.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
+#include "oox/helper/propertymap.hxx"
+#include "oox/core/namespaces.hxx"
+#include "oox/drawingml/colorchoicecontext.hxx"
+#include "oox/drawingml/drawingmltypes.hxx"
+
+#include "tokens.hxx"
+
+using ::rtl::OUString;
+using ::com::sun::star::beans::NamedValue;
+using namespace ::oox::core;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::drawing;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+
+// CT_LineProperties
+
+namespace oox { namespace drawingml {
+// ---------------------------------------------------------------------
+
+LinePropertiesContext::LinePropertiesContext( const FragmentHandlerRef& xHandler, const Reference< XFastAttributeList >& xAttribs,
+ oox::drawingml::LineProperties& rLineProperties ) throw()
+: Context( xHandler )
+, mrLineProperties( rLineProperties )
+{
+ // ST_LineWidth
+ if( xAttribs->hasAttribute( XML_w ) )
+ mrLineProperties.getLineWidth() = boost::optional< sal_Int32 >( GetCoordinate( xAttribs->getOptionalValue( XML_w ) ) );
+
+ // "ST_LineCap"
+ if( xAttribs->hasAttribute( XML_cap ) )
+ mrLineProperties.getLineCap() = boost::optional< sal_Int32 >( xAttribs->getOptionalValueToken( XML_cap, 0 ) );
+
+ // if ( xAttribs->hasAttribute( XML_cmpd ) ) ST_CompoundLine
+ // if ( xAttribs->hasAttribute( XML_algn ) ) ST_PenAlignment
+}
+
+LinePropertiesContext::~LinePropertiesContext()
+{
+}
+
+Reference< XFastContextHandler > LinePropertiesContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+ const rtl::OUString sLineStyle( RTL_CONSTASCII_USTRINGPARAM( "LineStyle" ) );
+ switch( aElementToken )
+ {
+ // LineFillPropertiesGroup, line fillings currently unsuported
+ case NMSP_DRAWINGML|XML_noFill:
+ mrLineProperties.getLinePropertyMap()[ sLineStyle ] <<= LineStyle_NONE;
+ break;
+ case NMSP_DRAWINGML|XML_solidFill:
+ {
+ mrLineProperties.getLinePropertyMap()[ sLineStyle ] <<= LineStyle_SOLID;
+ xRet = new colorChoiceContext( getHandler(), *mrLineProperties.getLineColor().get() );
+ }
+ break;
+ case NMSP_DRAWINGML|XML_gradFill:
+ case NMSP_DRAWINGML|XML_pattFill:
+ mrLineProperties.getLinePropertyMap()[ sLineStyle ] <<= LineStyle_SOLID;
+ break;
+
+ // LineDashPropertiesGroup
+ case NMSP_DRAWINGML|XML_prstDash: // CT_PresetLineDashProperties
+ mrLineProperties.getPresetDash() = boost::optional< sal_Int32 >( xAttribs->getOptionalValueToken( XML_val, XML_solid ) );
+ break;
+ case NMSP_DRAWINGML|XML_custDash: // CT_DashStopList
+ break;
+
+ // LineJoinPropertiesGroup
+ case NMSP_DRAWINGML|XML_round:
+ case NMSP_DRAWINGML|XML_bevel:
+ case NMSP_DRAWINGML|XML_miter:
+ {
+ LineJoint eJoint = (aElementToken == (NMSP_DRAWINGML|XML_round)) ? LineJoint_ROUND :
+ (aElementToken == (NMSP_DRAWINGML|XML_bevel)) ? LineJoint_BEVEL :
+ LineJoint_MITER;
+ static const OUString sLineJoint( RTL_CONSTASCII_USTRINGPARAM( "LineJoint" ) );
+ mrLineProperties.getLinePropertyMap()[ sLineJoint ] <<= eJoint;
+ }
+ break;
+
+ case NMSP_DRAWINGML|XML_headEnd: // CT_LineEndProperties
+ case NMSP_DRAWINGML|XML_tailEnd: // CT_LineEndProperties
+ { // ST_LineEndType
+ if( xAttribs->hasAttribute( XML_type ) )
+ {
+ sal_Int32 nType = xAttribs->getOptionalValueToken( XML_type, 0 );
+ if ( aElementToken == ( NMSP_DRAWINGML|XML_tailEnd ) )
+ mrLineProperties.getStartArrow() = boost::optional< sal_Int32 >( nType );
+ else
+ mrLineProperties.getEndArrow() = boost::optional< sal_Int32 >( nType );
+ }
+ if ( xAttribs->hasAttribute( XML_w ) )
+ {
+ sal_Int32 nW = xAttribs->getOptionalValueToken( XML_w, 0 );
+ if ( aElementToken == ( NMSP_DRAWINGML|XML_tailEnd ) )
+ mrLineProperties.getStartArrowWidth() = boost::optional< sal_Int32 >( nW );
+ else
+ mrLineProperties.getEndArrowWidth() = boost::optional< sal_Int32 >( nW );
+ }
+ if ( xAttribs->hasAttribute( XML_len ) )
+ {
+ sal_Int32 nLen = xAttribs->getOptionalValueToken( XML_len, 0 );
+ if ( aElementToken == ( NMSP_DRAWINGML|XML_tailEnd ) )
+ mrLineProperties.getStartArrowLength() = boost::optional< sal_Int32 >( nLen );
+ else
+ mrLineProperties.getEndArrowLength() = boost::optional< sal_Int32 >( nLen );
+ }
+ }
+ break;
+ }
+ if ( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+}
+
+} }
diff --git a/oox/source/drawingml/makefile.mk b/oox/source/drawingml/makefile.mk
new file mode 100644
index 000000000000..4df20df79252
--- /dev/null
+++ b/oox/source/drawingml/makefile.mk
@@ -0,0 +1,96 @@
+#*************************************************************************
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.2 $
+#
+# last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+#
+# The Contents of this file are made available subject to
+# the terms of GNU Lesser General Public License Version 2.1.
+#
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2005 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=oox
+TARGET=drawingml
+AUTOSEG=true
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/shapecontext.obj\
+ $(SLO)$/shapegroupcontext.obj\
+ $(SLO)$/fillproperties.obj\
+ $(SLO)$/fillpropertiesgroupcontext.obj\
+ $(SLO)$/lineproperties.obj\
+ $(SLO)$/linepropertiescontext.obj\
+ $(SLO)$/drawingmltypes.obj\
+ $(SLO)$/customshapegeometry.obj\
+ $(SLO)$/connectorshapecontext.obj\
+ $(SLO)$/graphicshapecontext.obj\
+ $(SLO)$/textbodycontext.obj\
+ $(SLO)$/textbodypropertiescontext.obj\
+ $(SLO)$/themefragmenthandler.obj\
+ $(SLO)$/objectdefaultcontext.obj\
+ $(SLO)$/themeelementscontext.obj\
+ $(SLO)$/spdefcontext.obj\
+ $(SLO)$/colorchoicecontext.obj\
+ $(SLO)$/clrschemecontext.obj\
+ $(SLO)$/clrscheme.obj\
+ $(SLO)$/color.obj\
+ $(SLO)$/shape.obj\
+ $(SLO)$/shapestylecontext.obj\
+ $(SLO)$/shapepropertiescontext.obj\
+ $(SLO)$/textparagraphproperties.obj\
+ $(SLO)$/textparagraphpropertiescontext.obj\
+ $(SLO)$/textcharacterproperties.obj\
+ $(SLO)$/textcharacterpropertiescontext.obj\
+ $(SLO)$/theme.obj\
+ $(SLO)$/textliststylecontext.obj\
+ $(SLO)$/textrun.obj\
+ $(SLO)$/textbody.obj\
+ $(SLO)$/textparagraph.obj\
+ $(SLO)$/textfontcontext.obj\
+ $(SLO)$/textspacingcontext.obj\
+ $(SLO)$/texttabstoplistcontext.obj\
+ $(SLO)$/textliststyle.obj \
+ $(SLO)$/textfieldcontext.obj\
+ $(SLO)$/textfield.obj\
+ $(SLO)$/hyperlinkcontext.obj\
+ $(SLO)$/embeddedwavaudiofile.obj\
+ $(SLO)$/customshapeproperties.obj
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/oox/source/drawingml/objectdefaultcontext.cxx b/oox/source/drawingml/objectdefaultcontext.cxx
new file mode 100644
index 000000000000..4e76cf1fb633
--- /dev/null
+++ b/oox/source/drawingml/objectdefaultcontext.cxx
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: objectdefaultcontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/objectdefaultcontext.hxx"
+#include "oox/drawingml/spdefcontext.hxx"
+#include "oox/core/namespaces.hxx"
+#include "tokens.hxx"
+
+using rtl::OUString;
+using namespace ::oox::core;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+
+namespace oox { namespace drawingml {
+
+objectDefaultContext::objectDefaultContext( const ::oox::core::FragmentHandlerRef& xHandler, Theme& rTheme )
+: Context( xHandler )
+, mrTheme( rTheme )
+{
+}
+
+Reference< XFastContextHandler > objectDefaultContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& /* xAttribs */ ) throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_spDef:
+ {
+ xRet.set( new spDefContext( getHandler(), *(mrTheme.getspDef().get()) ) );
+ break;
+ }
+ case NMSP_DRAWINGML|XML_lnDef:
+ {
+ xRet.set( new spDefContext( getHandler(), *(mrTheme.getlnDef().get()) ) );
+ break;
+ }
+ case NMSP_DRAWINGML|XML_txDef:
+ {
+ xRet.set( new spDefContext( getHandler(), *(mrTheme.gettxDef().get()) ) );
+ break;
+ }
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+
+ return xRet;
+}
+
+} }
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
new file mode 100644
index 000000000000..dabd5a359e7e
--- /dev/null
+++ b/oox/source/drawingml/shape.cxx
@@ -0,0 +1,489 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: shape.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/shape.hxx"
+#include "oox/core/namespaces.hxx"
+#include "tokens.hxx"
+
+#include <tools/solar.h> // for the F_PI180 define
+#include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/drawing/HomogenMatrix3.hpp>
+#include <com/sun/star/text/XText.hpp>
+#include <basegfx/point/b2dpoint.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+
+using rtl::OUString;
+using namespace ::oox::core;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::drawing;
+
+namespace oox { namespace drawingml {
+
+Shape::Shape( const sal_Char* pServiceName )
+: mpLinePropertiesPtr( new LineProperties() )
+, mpFillPropertiesPtr( new FillProperties( XML_spPr ) )
+, mpGraphicPropertiesPtr( new FillProperties( XML_pic ) )
+, mpCustomShapePropertiesPtr( new CustomShapeProperties() )
+, mpMasterTextListStyle( new TextListStyle() )
+, mnSubType( 0 )
+, mnIndex( 0 )
+, mnRotation( 0 )
+, mbFlipH( false )
+, mbFlipV( false )
+{
+ if ( pServiceName )
+ msServiceName = OUString::createFromAscii( pServiceName );
+ setDefaults();
+}
+Shape::~Shape()
+{
+}
+
+void Shape::setDefaults()
+{
+ const OUString sTextAutoGrowHeight( RTL_CONSTASCII_USTRINGPARAM( "TextAutoGrowHeight" ) );
+ const OUString sTextWordWrap( RTL_CONSTASCII_USTRINGPARAM( "TextWordWrap" ) );
+ const OUString sTextLeftDistance( RTL_CONSTASCII_USTRINGPARAM( "TextLeftDistance" ) );
+ const OUString sTextUpperDistance( RTL_CONSTASCII_USTRINGPARAM( "TextUpperDistance" ) );
+ const OUString sTextRightDistance( RTL_CONSTASCII_USTRINGPARAM( "TextRightDistance" ) );
+ const OUString sTextLowerDistance( RTL_CONSTASCII_USTRINGPARAM( "TextLowerDistance" ) );
+ maShapeProperties[ sTextAutoGrowHeight ] <<= sal_False;
+ maShapeProperties[ sTextWordWrap ] <<= sal_True;
+ maShapeProperties[ sTextLeftDistance ] <<= static_cast< sal_Int32 >( 250 );
+ maShapeProperties[ sTextUpperDistance ] <<= static_cast< sal_Int32 >( 125 );
+ maShapeProperties[ sTextRightDistance ] <<= static_cast< sal_Int32 >( 250 );
+ maShapeProperties[ sTextLowerDistance ] <<= static_cast< sal_Int32 >( 125 );
+}
+
+void Shape::setServiceName( const sal_Char* pServiceName )
+{
+ if ( pServiceName )
+ msServiceName = OUString::createFromAscii( pServiceName );
+}
+
+
+void Shape::addShape( const oox::core::XmlFilterBase& rFilterBase, const Reference< XModel > &rxModel, const oox::drawingml::ThemePtr pThemePtr,
+ std::map< ::rtl::OUString, ShapePtr > & aShapeMap, const Reference< XShapes >& rxShapes, const awt::Rectangle* pShapeRect )
+{
+ try
+ {
+ rtl::OUString sServiceName( msServiceName );
+ if( sServiceName.getLength() )
+ {
+ Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, rxModel, pThemePtr, rxShapes, pShapeRect ) );
+
+ if( msId.getLength() )
+ {
+ aShapeMap[ msId ] = shared_from_this();
+ }
+
+ // if this is a group shape, we have to add also each child shape
+ Reference< XShapes > xShapes( xShape, UNO_QUERY );
+ if ( xShapes.is() )
+ addChilds( rFilterBase, *this, rxModel, pThemePtr, aShapeMap, xShapes, pShapeRect ? *pShapeRect : awt::Rectangle( maPosition.X, maPosition.Y, maSize.Width, maSize.Height ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ }
+}
+
+void Shape::applyShapeReference( const oox::drawingml::Shape& rReferencedShape )
+{
+ mpTextBody = TextBodyPtr( new TextBody( *rReferencedShape.mpTextBody.get() ) );
+ maShapeProperties = rReferencedShape.maShapeProperties;
+ mpLinePropertiesPtr = LinePropertiesPtr( new LineProperties( *rReferencedShape.mpLinePropertiesPtr.get() ) );
+ mpFillPropertiesPtr = FillPropertiesPtr( new FillProperties( *rReferencedShape.mpFillPropertiesPtr.get() ) );
+ mpCustomShapePropertiesPtr = CustomShapePropertiesPtr( new CustomShapeProperties( *rReferencedShape.mpCustomShapePropertiesPtr.get() ) );
+ mpMasterTextListStyle = TextListStylePtr( new TextListStyle( *rReferencedShape.mpMasterTextListStyle.get() ) );
+ maShapeStylesColorMap = rReferencedShape.maShapeStylesColorMap;
+ maShapeStylesIndexMap = rReferencedShape.maShapeStylesIndexMap;
+ maSize = rReferencedShape.maSize;
+ maPosition = rReferencedShape.maPosition;
+ mnRotation = rReferencedShape.mnRotation;
+ mbFlipH = rReferencedShape.mbFlipH;
+ mbFlipV = rReferencedShape.mbFlipV;
+}
+
+// for group shapes, the following method is also adding each child
+void Shape::addChilds( const oox::core::XmlFilterBase& rFilterBase, Shape& rMaster, const Reference< XModel > &rxModel, const oox::drawingml::ThemePtr pThemePtr,
+ std::map< ::rtl::OUString, ShapePtr > & aShapeMap, const Reference< XShapes >& rxShapes, const awt::Rectangle& rClientRect )
+{
+ // first the global child union needs to be calculated
+ sal_Int32 nGlobalLeft = SAL_MAX_INT32;
+ sal_Int32 nGlobalRight = SAL_MIN_INT32;
+ sal_Int32 nGlobalTop = SAL_MAX_INT32;
+ sal_Int32 nGlobalBottom= SAL_MIN_INT32;
+ std::vector< ShapePtr >::iterator aIter( rMaster.maChilds.begin() );
+ while( aIter != rMaster.maChilds.end() )
+ {
+ sal_Int32 l = (*aIter)->maPosition.X;
+ sal_Int32 t = (*aIter)->maPosition.Y;
+ sal_Int32 r = l + (*aIter)->maSize.Width;
+ sal_Int32 b = t + (*aIter)->maSize.Height;
+ if ( nGlobalLeft > l )
+ nGlobalLeft = l;
+ if ( nGlobalRight < r )
+ nGlobalRight = r;
+ if ( nGlobalTop > t )
+ nGlobalTop = t;
+ if ( nGlobalBottom < b )
+ nGlobalBottom = b;
+ aIter++;
+ }
+ aIter = rMaster.maChilds.begin();
+ while( aIter != rMaster.maChilds.end() )
+ {
+ Rectangle aShapeRect;
+ 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;
+ sal_Int32 nGlobalHeight = nGlobalBottom - nGlobalTop;
+ if ( nGlobalWidth && nGlobalHeight )
+ {
+ double fWidth = (*aIter)->maSize.Width;
+ double fHeight= (*aIter)->maSize.Height;
+ double fXScale = (double)rClientRect.Width / (double)nGlobalWidth;
+ double fYScale = (double)rClientRect.Height / (double)nGlobalHeight;
+ aShapeRect.X = static_cast< sal_Int32 >( ( ( (*aIter)->maPosition.X - nGlobalLeft ) * fXScale ) + rClientRect.X );
+ aShapeRect.Y = static_cast< sal_Int32 >( ( ( (*aIter)->maPosition.Y - nGlobalTop ) * fYScale ) + rClientRect.Y );
+ fWidth *= fXScale;
+ fHeight *= fYScale;
+ aShapeRect.Width = static_cast< sal_Int32 >( fWidth );
+ aShapeRect.Height = static_cast< sal_Int32 >( fHeight );
+ pShapeRect = &aShapeRect;
+ }
+ }
+ (*aIter++)->addShape( rFilterBase, rxModel, pThemePtr, aShapeMap, rxShapes, pShapeRect );
+ }
+}
+
+void applyPropertyMap( uno::Reference< drawing::XShape >& rxShape, PropertyMap& rPropertyMap )
+{
+ if( !rPropertyMap.empty() )
+ {
+ Reference< XMultiPropertySet > xMSet( rxShape, UNO_QUERY );
+ if( xMSet.is() )
+ {
+ try
+ {
+ Sequence< OUString > aNames;
+ Sequence< Any > aValues;
+ rPropertyMap.makeSequence( aNames, aValues );
+ xMSet->setPropertyValues( aNames, aValues);
+ }
+ catch( Exception& )
+ {
+ }
+ }
+ else
+ {
+ uno::Reference< beans::XPropertySet > xSet( rxShape, uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySetInfo > xInfo( xSet->getPropertySetInfo() );
+
+ for( PropertyMap::const_iterator aIter( rPropertyMap.begin() ); aIter != rPropertyMap.end(); aIter++ )
+ {
+ if ( xInfo->hasPropertyByName( (*aIter).first ) )
+ xSet->setPropertyValue( (*aIter).first, (*aIter).second );
+ }
+ }
+ }
+}
+
+
+
+Reference< XShape > Shape::createAndInsert( const oox::core::XmlFilterBase& rFilterBase, const rtl::OUString& rServiceName, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > &rxModel,
+ const oox::drawingml::ThemePtr pThemePtr, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
+ const awt::Rectangle* pShapeRect )
+{
+ basegfx::B2DHomMatrix aTransformation;
+
+ awt::Size aSize( pShapeRect ? awt::Size( pShapeRect->Width, pShapeRect->Height ) : maSize );
+ awt::Point aPosition( pShapeRect ? awt::Point( pShapeRect->X, pShapeRect->Y ) : maPosition );
+ if( aSize.Width != 1 || aSize.Height != 1)
+ {
+ // take care there are no zeros used by error
+ aTransformation.scale(
+ aSize.Width ? aSize.Width / 360.0 : 1.0,
+ aSize.Height ? aSize.Height / 360.0 : 1.0 );
+ }
+
+ if( mbFlipH || mbFlipV || mnRotation != 0)
+ {
+ // calculate object's center
+ basegfx::B2DPoint aCenter(0.5, 0.5);
+ aCenter *= aTransformation;
+
+ // center object at origin
+ aTransformation.translate( -aCenter.getX(), -aCenter.getY() );
+
+ if( mbFlipH || mbFlipV)
+ {
+ // mirror around object's center
+ aTransformation.scale( mbFlipH ? -1.0 : 1.0, mbFlipV ? -1.0 : 1.0 );
+ }
+
+ if( mnRotation != 0 )
+ {
+ // rotate around object's center
+ aTransformation.rotate( -F_PI180 * ( (double)mnRotation / 60000.0 ) );
+ }
+
+ // move object back from center
+ aTransformation.translate( aCenter.getX(), aCenter.getY() );
+ }
+
+ if( aPosition.X != 0 || aPosition.Y != 0)
+ {
+ // if global position is used, add it to transformation
+ aTransformation.translate( aPosition.X / 360.0, aPosition.Y / 360.0 );
+ }
+
+ // special for lineshape
+ if ( rServiceName == OUString::createFromAscii( "com.sun.star.drawing.LineShape" ) )
+ {
+ ::basegfx::B2DPolygon aPoly;
+ aPoly.insert( 0, ::basegfx::B2DPoint( 0, 0 ) );
+ aPoly.insert( 1, ::basegfx::B2DPoint( maSize.Width ? 1 : 0, maSize.Height ? 1 : 0 ) );
+ aPoly.transform( aTransformation );
+
+ // 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() ) );
+ }
+ uno::Sequence< uno::Sequence< awt::Point > > aPolyPolySequence( 1 );
+ aPolyPolySequence.getArray()[ 0 ] = aPointSequence;
+
+ static const OUString sPolyPolygon(RTL_CONSTASCII_USTRINGPARAM("PolyPolygon"));
+ maShapeProperties[ sPolyPolygon ] <<= aPolyPolySequence;
+ }
+ else if ( rServiceName == OUString::createFromAscii( "com.sun.star.drawing.ConnectorShape" ) )
+ {
+ ::basegfx::B2DPolygon aPoly;
+ aPoly.insert( 0, ::basegfx::B2DPoint( 0, 0 ) );
+ aPoly.insert( 1, ::basegfx::B2DPoint( maSize.Width ? 1 : 0, maSize.Height ? 1 : 0 ) );
+ aPoly.transform( aTransformation );
+
+ basegfx::B2DPoint aStartPosition( aPoly.getB2DPoint( 0 ) );
+ basegfx::B2DPoint aEndPosition( aPoly.getB2DPoint( 1 ) );
+ awt::Point aAWTStartPosition( static_cast< sal_Int32 >( aStartPosition.getX() ), static_cast< sal_Int32 >( aStartPosition.getY() ) );
+ awt::Point aAWTEndPosition( static_cast< sal_Int32 >( aEndPosition.getX() ), static_cast< sal_Int32 >( aEndPosition.getY() ) );
+
+ static const OUString sStartPosition(RTL_CONSTASCII_USTRINGPARAM("StartPosition"));
+ maShapeProperties[ sStartPosition ] <<= aAWTStartPosition;
+ static const OUString sEndPosition(RTL_CONSTASCII_USTRINGPARAM("EndPosition"));
+ maShapeProperties[ sEndPosition ] <<= aAWTEndPosition;
+ }
+ else
+ {
+ // now set transformation for this object
+ HomogenMatrix3 aMatrix;
+
+ aMatrix.Line1.Column1 = aTransformation.get(0,0);
+ aMatrix.Line1.Column2 = aTransformation.get(0,1);
+ aMatrix.Line1.Column3 = aTransformation.get(0,2);
+
+ aMatrix.Line2.Column1 = aTransformation.get(1,0);
+ aMatrix.Line2.Column2 = aTransformation.get(1,1);
+ aMatrix.Line2.Column3 = aTransformation.get(1,2);
+
+ aMatrix.Line3.Column1 = aTransformation.get(2,0);
+ aMatrix.Line3.Column2 = aTransformation.get(2,1);
+ aMatrix.Line3.Column3 = aTransformation.get(2,2);
+
+ static const OUString sTransformation(RTL_CONSTASCII_USTRINGPARAM("Transformation"));
+ maShapeProperties[ sTransformation ] <<= aMatrix;
+ }
+ Reference< lang::XMultiServiceFactory > xServiceFact( rxModel, UNO_QUERY_THROW );
+ Reference< drawing::XShape > xShape( xServiceFact->createInstance( rServiceName ), UNO_QUERY_THROW );
+ Reference< XPropertySet > xSet( xShape, UNO_QUERY_THROW );
+ if( xShape.is() && xSet.is() )
+ {
+ if( msName.getLength() )
+ {
+ Reference< container::XNamed > xNamed( xShape, UNO_QUERY );
+ if( xNamed.is() )
+ xNamed->setName( msName );
+ }
+ rxShapes->add( xShape );
+ mxShape = xShape;
+
+ setShapeStyles( pThemePtr, rFilterBase );
+
+ // applying properties
+ if ( rServiceName == OUString::createFromAscii( "com.sun.star.drawing.GraphicObjectShape" ) )
+ mpGraphicPropertiesPtr->pushToPropSet( rFilterBase, xSet );
+ mpFillPropertiesPtr->pushToPropSet( rFilterBase, xSet );
+ mpLinePropertiesPtr->pushToPropSet( rFilterBase, xSet );
+
+ // applying autogrowheight property before setting shape size, because
+ // the shape size might be changed if currently autogrowheight is true
+ // we must also check that the PropertySet supports the property.
+ Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
+ static const rtl::OUString sTextAutoGrowHeight( RTL_CONSTASCII_USTRINGPARAM( "TextAutoGrowHeight" ) );
+ if( xSetInfo->hasPropertyByName( sTextAutoGrowHeight ) )
+ {
+ const Any* pAutoGrowHeight = maShapeProperties.getPropertyValue( sTextAutoGrowHeight );
+ if ( pAutoGrowHeight )
+ xSet->setPropertyValue( sTextAutoGrowHeight, Any( sal_False ) );
+ }
+
+ applyPropertyMap( xShape, maShapeProperties );
+
+ if( rServiceName == OUString::createFromAscii( "com.sun.star.drawing.CustomShape" ) )
+ mpCustomShapePropertiesPtr->pushToPropSet( rFilterBase, xSet );
+
+ // in some cases, we don't have any text body.
+ if( getTextBody() )
+ {
+ Reference < XText > xText( xShape, UNO_QUERY );
+ if ( xText.is() ) // not every shape is supporting an XText interface (e.g. GroupShape)
+ {
+ Reference < XTextCursor > xAt = xText->createTextCursor();
+ getTextBody()->insertAt( rFilterBase, xText, xAt, rxModel, mpMasterTextListStyle );
+ }
+ }
+ }
+ return xShape;
+}
+
+// the properties of rSource which are not part of rDest are being put into rDest
+void addMissingProperties( const PropertyMap& rSource, PropertyMap& rDest )
+{
+ PropertyMap::const_iterator aSourceIter( rSource.begin() );
+ while( aSourceIter != rSource.end() )
+ {
+ if ( rDest.find( (*aSourceIter ).first ) == rDest.end() )
+ rDest[ (*aSourceIter).first ] <<= (*aSourceIter).second;
+ aSourceIter++;
+ }
+}
+
+// merging styles, if a shape property is not set, we have to set the shape style property
+void Shape::setShapeStyles( const oox::drawingml::ThemePtr pThemePtr, const oox::core::XmlFilterBase& rFilterBase )
+{
+ std::map< ShapeStyle, ColorPtr >::const_iterator aShapeStylesColorIter( getShapeStylesColor().begin() );
+ std::map< ShapeStyle, rtl::OUString >::const_iterator aShapeStylesIndexIter( getShapeStylesIndex().begin() );
+ while( aShapeStylesColorIter != getShapeStylesColor().end() )
+ {
+ switch( (*aShapeStylesColorIter).first )
+ {
+ case oox::drawingml::SHAPESTYLE_ln :
+ {
+ if ( !mpLinePropertiesPtr->getLineColor()->isUsed() )
+ mpLinePropertiesPtr->getLineColor() = (*aShapeStylesColorIter).second;
+ }
+ break;
+ case oox::drawingml::SHAPESTYLE_fill :
+ {
+ if ( !mpFillPropertiesPtr->getFillColor()->isUsed() )
+ mpFillPropertiesPtr->getFillColor() = (*aShapeStylesColorIter).second;
+ }
+ case oox::drawingml::SHAPESTYLE_effect :
+ break;
+ case oox::drawingml::SHAPESTYLE_font :
+ {
+ const rtl::OUString sCharColor( OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "CharColor" ) ) );
+ if ( maShapeProperties.find( sCharColor ) == maShapeProperties.end() )
+ maShapeProperties[ sCharColor ] <<= ((*aShapeStylesColorIter).second)->getColor( rFilterBase );
+ }
+ break;
+ }
+ aShapeStylesColorIter++;
+ }
+ while( aShapeStylesIndexIter != getShapeStylesIndex().end() )
+ {
+ const rtl::OUString sIndex( (*aShapeStylesIndexIter).second );
+ sal_uInt32 nIndex( sIndex.toInt32() );
+ if ( nIndex-- )
+ {
+ switch( (*aShapeStylesIndexIter).first )
+ {
+ case oox::drawingml::SHAPESTYLE_ln :
+ {
+ const std::vector< oox::drawingml::LinePropertiesPtr >& rThemeLineStyleList( pThemePtr->getLineStyleList() );
+ if ( rThemeLineStyleList.size() > nIndex )
+ mpLinePropertiesPtr->apply( rThemeLineStyleList[ nIndex ] );
+ }
+ break;
+ case oox::drawingml::SHAPESTYLE_fill :
+ {
+ const std::vector< oox::drawingml::FillPropertiesPtr >& rThemeFillStyleList( pThemePtr->getFillStyleList() );
+ if ( rThemeFillStyleList.size() > nIndex )
+ mpFillPropertiesPtr->apply( rThemeFillStyleList[ nIndex ] );
+ }
+ break;
+ case oox::drawingml::SHAPESTYLE_effect :
+ case oox::drawingml::SHAPESTYLE_font :
+ break;
+ }
+ }
+ aShapeStylesIndexIter++;
+ }
+}
+
+void Shape::setTextBody(const TextBodyPtr & pTextBody)
+{
+ mpTextBody = pTextBody;
+}
+
+
+TextBodyPtr Shape::getTextBody()
+{
+ return mpTextBody;
+}
+
+void Shape::setMasterTextListStyle( const TextListStylePtr& pMasterTextListStyle )
+{
+ mpMasterTextListStyle = pMasterTextListStyle;
+}
+
+
+} }
diff --git a/oox/source/drawingml/shapecontext.cxx b/oox/source/drawingml/shapecontext.cxx
new file mode 100644
index 000000000000..5ac0ffc255bf
--- /dev/null
+++ b/oox/source/drawingml/shapecontext.cxx
@@ -0,0 +1,130 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: shapecontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include <com/sun/star/xml/sax/FastToken.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+
+#include "oox/drawingml/shapecontext.hxx"
+#include "oox/drawingml/shapestylecontext.hxx"
+#include "oox/core/namespaces.hxx"
+#include "oox/drawingml/fillpropertiesgroupcontext.hxx"
+#include "oox/drawingml/lineproperties.hxx"
+#include "oox/drawingml/drawingmltypes.hxx"
+#include "oox/drawingml/customshapegeometry.hxx"
+#include "oox/drawingml/textbodycontext.hxx"
+#include "tokens.hxx"
+
+using rtl::OUString;
+using namespace oox::core;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::drawing;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::xml::sax;
+
+namespace oox { namespace drawingml {
+
+// CT_Shape
+ShapeContext::ShapeContext( const FragmentHandlerRef& xHandler, ShapePtr pMasterShapePtr, ShapePtr pShapePtr )
+: Context( xHandler )
+, mpMasterShapePtr( pMasterShapePtr )
+, mpShapePtr( pShapePtr )
+{
+}
+
+ShapeContext::~ShapeContext()
+{
+ if ( mpMasterShapePtr.get() && mpShapePtr.get() )
+ mpMasterShapePtr->addChild( mpShapePtr );
+}
+
+ShapePtr ShapeContext::getShape()
+{
+ return mpShapePtr;
+}
+
+void ShapeContext::endFastElement( sal_Int32 /* aElementToken */ ) throw( SAXException, RuntimeException )
+{
+}
+
+Reference< XFastContextHandler > ShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElementToken &(~NMSP_MASK) )
+ {
+ // nvSpPr CT_ShapeNonVisual begin
+// case XML_drElemPr:
+// break;
+ case XML_cNvPr:
+ mpShapePtr->setId( xAttribs->getOptionalValue( XML_id ) );
+ mpShapePtr->setName( xAttribs->getOptionalValue( XML_name ) );
+ break;
+ case XML_ph:
+ mpShapePtr->setSubType( xAttribs->getOptionalValueToken( XML_type, XML_obj ) );
+ mpShapePtr->setIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() );
+ break;
+ // nvSpPr CT_ShapeNonVisual end
+
+ case XML_spPr:
+ xRet = new ShapePropertiesContext( this, *(mpShapePtr.get()) );
+ break;
+
+ case XML_style:
+ xRet = new ShapeStyleContext( this, *(mpShapePtr.get()) );
+ break;
+
+ case XML_txBody:
+ {
+ xRet = new TextBodyContext( getHandler(), *(mpShapePtr.get()) );
+ break;
+ }
+ }
+
+ if( !xRet.is() )
+ {
+ uno::Reference<XFastContextHandler> xTmp(this);
+ xRet.set( xTmp );
+ }
+
+ return xRet;
+}
+
+
+} }
diff --git a/oox/source/drawingml/shapegroupcontext.cxx b/oox/source/drawingml/shapegroupcontext.cxx
new file mode 100644
index 000000000000..7e6c7dd0c6ee
--- /dev/null
+++ b/oox/source/drawingml/shapegroupcontext.cxx
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: shapegroupcontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include <com/sun/star/xml/sax/FastToken.hpp>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+
+#include "oox/drawingml/shapegroupcontext.hxx"
+#include "oox/drawingml/connectorshapecontext.hxx"
+#include "oox/drawingml/graphicshapecontext.hxx"
+#include "oox/drawingml/lineproperties.hxx"
+#include "oox/drawingml/drawingmltypes.hxx"
+#include "oox/drawingml/customshapegeometry.hxx"
+#include "oox/drawingml/textbodycontext.hxx"
+#include "oox/core/namespaces.hxx"
+#include "tokens.hxx"
+
+using rtl::OUString;
+using namespace oox::core;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::drawing;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::xml::sax;
+
+namespace oox { namespace drawingml {
+
+ShapeGroupContext::ShapeGroupContext( const FragmentHandlerRef& xHandler,
+ sal_Int32 /* aElementToken */, ShapePtr pMasterShapePtr, ShapePtr pGroupShapePtr )
+: Context( xHandler )
+, mpGroupShapePtr( pGroupShapePtr )
+, mpMasterShapePtr( pMasterShapePtr )
+{
+}
+
+ShapeGroupContext::~ShapeGroupContext()
+{
+ if ( mpMasterShapePtr.get() && mpGroupShapePtr.get() )
+ mpMasterShapePtr->addChild( mpGroupShapePtr );
+}
+
+Reference< XFastContextHandler > ShapeGroupContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElementToken &(~NMSP_MASK) )
+ {
+ case XML_cNvPr:
+ mpGroupShapePtr->setId( xAttribs->getOptionalValue( XML_id ) );
+ mpGroupShapePtr->setName( xAttribs->getOptionalValue( XML_name ) );
+ break;
+ case XML_ph:
+ mpGroupShapePtr->setSubType( xAttribs->getOptionalValueToken( XML_type, FastToken::DONTKNOW ) );
+ mpGroupShapePtr->setIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() );
+ break;
+ // nvSpPr CT_ShapeNonVisual end
+
+ case XML_grpSpPr:
+ xRet = new ShapePropertiesContext( this, *(mpGroupShapePtr.get()) );
+ break;
+ case XML_spPr:
+ xRet = new ShapePropertiesContext( this, *(mpGroupShapePtr.get()) );
+ break;
+/*
+ case XML_style:
+ xRet = new ShapeStyleContext( getParser() );
+ break;
+*/
+ case XML_cxnSp: // connector shape
+ xRet.set( new ConnectorShapeContext( getHandler(), aElementToken, mpGroupShapePtr, ShapePtr( new Shape( "com.sun.star.drawing.ConnectorShape" ) ) ) );
+ break;
+ case XML_grpSp: // group shape
+ xRet.set( new ShapeGroupContext( getHandler(), aElementToken, mpGroupShapePtr, ShapePtr( new Shape( "com.sun.star.drawing.GroupShape" ) ) ) );
+ break;
+ case XML_sp: // shape
+ xRet.set( new ShapeContext( getHandler(), mpGroupShapePtr, ShapePtr( new Shape( "com.sun.star.drawing.CustomShape" ) ) ) );
+ break;
+ case XML_pic: // CT_Picture
+ xRet.set( new GraphicShapeContext( getHandler(), mpGroupShapePtr, ShapePtr( new Shape( "com.sun.star.drawing.GraphicObjectShape" ) ) ) );
+ break;
+ case XML_graphicFrame: // CT_GraphicalObjectFrame
+ xRet.set( new GraphicalObjectFrameContext( getHandler(), mpGroupShapePtr, ShapePtr( new Shape( "com.sun.star.drawing.OLE2Shape" ) ) ) );
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+
+
+ return xRet;
+}
+
+} }
diff --git a/oox/source/drawingml/shapepropertiescontext.cxx b/oox/source/drawingml/shapepropertiescontext.cxx
new file mode 100644
index 000000000000..a4c6ad5c98c8
--- /dev/null
+++ b/oox/source/drawingml/shapepropertiescontext.cxx
@@ -0,0 +1,140 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: shapepropertiescontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#include <com/sun/star/xml/sax/FastToken.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+
+#include "oox/drawingml/shapepropertiescontext.hxx"
+#include "oox/core/namespaces.hxx"
+#include "oox/drawingml/linepropertiescontext.hxx"
+#include "oox/drawingml/fillpropertiesgroupcontext.hxx"
+#include "oox/drawingml/drawingmltypes.hxx"
+#include "oox/drawingml/customshapegeometry.hxx"
+#include "tokens.hxx"
+
+using rtl::OUString;
+using namespace oox::core;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::drawing;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::xml::sax;
+
+namespace oox { namespace drawingml {
+
+// ====================================================================
+
+// CT_ShapeProperties
+ShapePropertiesContext::ShapePropertiesContext( const ContextRef& xParent, ::oox::drawingml::Shape& rShape )
+: Context( xParent->getHandler() )
+, mxParent( xParent )
+, mrShape( rShape )
+{
+}
+
+// --------------------------------------------------------------------
+
+void ShapePropertiesContext::endFastElement( sal_Int32 aElementToken ) throw( SAXException, RuntimeException )
+{
+ mxParent->endFastElement( aElementToken );
+}
+
+// --------------------------------------------------------------------
+
+Reference< XFastContextHandler > ShapePropertiesContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElementToken )
+ {
+ // CT_Transform2D
+ case NMSP_DRAWINGML|XML_xfrm:
+ xRet.set( new Transform2DContext( getHandler(), xAttribs, mrShape ) );
+ break;
+
+ // GeometryGroup
+ case NMSP_DRAWINGML|XML_custGeom: // custom geometry "CT_CustomGeometry2D"
+ xRet.set( new CustomShapeGeometryContext( getHandler(), xAttribs, *(mrShape.getCustomShapeProperties()) ) );
+ break;
+
+
+ case NMSP_DRAWINGML|XML_prstGeom: // preset geometry "CT_PresetGeometry2D"
+ {
+ sal_Int32 nToken = xAttribs->getOptionalValueToken( XML_prst, 0 );
+ if ( nToken == XML_line )
+ {
+ static const OUString sLineShape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.LineShape" ) );
+ mrShape.getServiceName() = sLineShape;
+ }
+ xRet.set( new PresetShapeGeometryContext( getHandler(), xAttribs, *(mrShape.getCustomShapeProperties()) ) );
+ }
+ break;
+
+ case NMSP_DRAWINGML|XML_prstTxWarp:
+ xRet.set( new PresetTextShapeContext( getHandler(), xAttribs, *(mrShape.getCustomShapeProperties()) ) );
+ break;
+
+ // CT_LineProperties
+ case NMSP_DRAWINGML|XML_ln:
+ xRet.set( new LinePropertiesContext( getHandler(), xAttribs, *(mrShape.getLineProperties().get()) ) );
+ break;
+
+ // EffectPropertiesGroup
+ // todo not supported by core
+ case NMSP_DRAWINGML|XML_effectLst: // CT_EffectList
+ case NMSP_DRAWINGML|XML_effectDag: // CT_EffectContainer
+ break;
+
+ // todo
+ case NMSP_DRAWINGML|XML_scene3d: // CT_Scene3D
+ case NMSP_DRAWINGML|XML_sp3d: // CT_Shape3D
+ break;
+ }
+
+ // FillPropertiesGroupContext
+ if( !xRet.is() )
+ xRet.set( FillPropertiesGroupContext::StaticCreateContext( getHandler(), aElementToken, xAttribs, *(mrShape.getFillProperties().get()) ) );
+
+ return xRet;
+}
+
+} }
diff --git a/oox/source/drawingml/shapestylecontext.cxx b/oox/source/drawingml/shapestylecontext.cxx
new file mode 100644
index 000000000000..bf58ecde8f4a
--- /dev/null
+++ b/oox/source/drawingml/shapestylecontext.cxx
@@ -0,0 +1,148 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: shapestylecontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/shapestylecontext.hxx"
+
+#include "oox/helper/attributelist.hxx"
+#include "oox/core/namespaces.hxx"
+#include "oox/drawingml/colorchoicecontext.hxx"
+#include "tokens.hxx"
+
+using ::rtl::OUString;
+using namespace ::oox::core;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+
+namespace oox { namespace drawingml {
+
+// -------------------------
+// CT_StyleMatrixReference
+// -------------------------
+class StyleMatrixReferenceContext : public ::oox::core::Context
+{
+public:
+ StyleMatrixReferenceContext( const ::oox::core::ContextRef& rxParent, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs,
+ const oox::drawingml::ShapeStyle eShapeStyle, oox::drawingml::Shape& rShape );
+ ~StyleMatrixReferenceContext();
+
+ virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) 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);
+
+protected:
+ ::oox::drawingml::Shape& mrShape;
+ ::oox::drawingml::ShapeStyle meShapeStyle;
+ ::oox::drawingml::ColorPtr maColor;
+};
+
+StyleMatrixReferenceContext::StyleMatrixReferenceContext( const ::oox::core::ContextRef& rxParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs,
+ const oox::drawingml::ShapeStyle eShapeStyle, oox::drawingml::Shape& rShape )
+: Context( rxParent->getHandler() )
+, mrShape( rShape )
+, meShapeStyle( eShapeStyle )
+, maColor( new Color() )
+{
+ mrShape.getShapeStylesIndex()[ meShapeStyle ] = rxAttribs->getOptionalValue( XML_idx );
+}
+
+StyleMatrixReferenceContext::~StyleMatrixReferenceContext()
+{
+
+}
+
+// --------------------------------------------------------------------
+
+void StyleMatrixReferenceContext::endFastElement( sal_Int32 ) throw (SAXException, RuntimeException)
+{
+ mrShape.getShapeStylesColor()[ meShapeStyle ] = maColor;
+}
+
+// --------------------------------------------------------------------
+
+Reference< XFastContextHandler > StyleMatrixReferenceContext::createFastChildContext( sal_Int32 /* aElementToken */, const Reference< XFastAttributeList >& /* rxAttributes */ ) throw (SAXException, RuntimeException)
+{
+ return new colorChoiceContext( getHandler(), *maColor.get() );
+}
+
+// ---------------
+// CT_ShapeStyle
+// ---------------
+ShapeStyleContext::ShapeStyleContext( const ::oox::core::ContextRef& rxParent, oox::drawingml::Shape& rShape )
+: Context( rxParent->getHandler() )
+, mrShape( rShape )
+{
+}
+
+ShapeStyleContext::~ShapeStyleContext()
+{
+}
+
+// --------------------------------------------------------------------
+
+void ShapeStyleContext::endFastElement( sal_Int32 ) throw (SAXException, RuntimeException)
+{
+}
+
+// --------------------------------------------------------------------
+
+Reference< XFastContextHandler > ShapeStyleContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& rxAttributes )
+ throw ( SAXException, RuntimeException )
+{
+ Reference< XFastContextHandler > xRet;
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_lnRef : // CT_StyleMatrixReference
+ xRet.set( new StyleMatrixReferenceContext( this, rxAttributes, oox::drawingml::SHAPESTYLE_ln, mrShape ) );
+ break;
+ case NMSP_DRAWINGML|XML_fillRef : // CT_StyleMatrixReference
+ xRet.set( new StyleMatrixReferenceContext( this, rxAttributes, oox::drawingml::SHAPESTYLE_fill, mrShape ) );
+ break;
+ case NMSP_DRAWINGML|XML_effectRef : // CT_StyleMatrixReference
+ xRet.set( new StyleMatrixReferenceContext( this, rxAttributes, oox::drawingml::SHAPESTYLE_effect, mrShape ) );
+ break;
+ case NMSP_DRAWINGML|XML_fontRef : // CT_FontReference
+ xRet.set( new StyleMatrixReferenceContext( this, rxAttributes, oox::drawingml::SHAPESTYLE_font, mrShape ) );
+ break;
+ }
+ if ( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+}
+
+// --------------------------------------------------------------------
+
+} }
+
diff --git a/oox/source/drawingml/spdefcontext.cxx b/oox/source/drawingml/spdefcontext.cxx
new file mode 100644
index 000000000000..55530b3ffefb
--- /dev/null
+++ b/oox/source/drawingml/spdefcontext.cxx
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: spdefcontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/spdefcontext.hxx"
+#include "oox/drawingml/shapepropertiescontext.hxx"
+#include "oox/drawingml/textbodypropertiescontext.hxx"
+#include "oox/drawingml/textliststylecontext.hxx"
+#include "oox/core/namespaces.hxx"
+#include "tokens.hxx"
+
+using rtl::OUString;
+using namespace ::oox::core;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+
+namespace oox { namespace drawingml {
+
+spDefContext::spDefContext( const ::oox::core::FragmentHandlerRef& xHandler, oox::drawingml::Shape& rDefaultObject )
+: Context( xHandler )
+, mrDefaultObject( rDefaultObject )
+{
+}
+
+Reference< XFastContextHandler > spDefContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_spPr:
+ {
+ xRet = new ShapePropertiesContext( this, mrDefaultObject );
+ break;
+ }
+ case NMSP_DRAWINGML|XML_bodyPr:
+ {
+ xRet = new TextBodyPropertiesContext( this, xAttribs, mrDefaultObject );
+ break;
+ }
+ case NMSP_DRAWINGML|XML_lstStyle:
+ xRet.set( new TextListStyleContext( getHandler(), *(mrDefaultObject.getMasterTextListStyle().get()) ) );
+ break;
+ case NMSP_DRAWINGML|XML_style:
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+
+ return xRet;
+}
+
+} }
diff --git a/oox/source/drawingml/textbody.cxx b/oox/source/drawingml/textbody.cxx
new file mode 100644
index 000000000000..13afccddac2f
--- /dev/null
+++ b/oox/source/drawingml/textbody.cxx
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: textbody.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:52 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2007 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include <algorithm>
+#include <boost/bind.hpp>
+
+#include "oox/drawingml/textbody.hxx"
+
+using ::rtl::OUString;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::frame;
+
+namespace oox { namespace drawingml {
+
+
+ TextBody::TextBody()
+ : mpTextListStyle( new TextListStyle() )
+ {
+ }
+
+ TextBody::~TextBody()
+ {
+ }
+
+
+
+ void TextBody::insertAt( const ::oox::core::XmlFilterBase& rFilterBase, const Reference < XText > & xText, const Reference < XTextCursor > & xAt,
+ const Reference < XModel > &xModel, const TextListStylePtr& pMasterTextListStylePtr )
+ {
+ TextListStylePtr aCombinedTextStyle( new TextListStyle( *(pMasterTextListStylePtr.get()) ) );
+ aCombinedTextStyle->apply( mpTextListStyle );
+
+ std::vector< TextParagraphPtr >::iterator begin( maParagraphs.begin() );
+ std::vector< TextParagraphPtr >::iterator end( maParagraphs.end() );
+ // apparently if there is no paragraph, it crashes. this is sort of the
+ // expected behavior.
+ while( begin != end )
+ {
+ (*begin)->insertAt( rFilterBase, xText, xAt, xModel, aCombinedTextStyle, begin == maParagraphs.begin() );
+ begin++;
+/*
+ std::for_each( begin, end,
+ boost::bind( &TextParagraph::insertAt, _1,
+ rFilterBase, xText, xAt, xModel, aCombinedTextStyle,
+ // determine whether it is the first paragraph of not
+ boost::bind( std::equal_to<TextParagraphPtr>(), _1,
+ *maParagraphs.begin() ) ) );
+*/
+ }
+ }
+
+
+} }
diff --git a/oox/source/drawingml/textbodycontext.cxx b/oox/source/drawingml/textbodycontext.cxx
new file mode 100644
index 000000000000..0636ece28713
--- /dev/null
+++ b/oox/source/drawingml/textbodycontext.cxx
@@ -0,0 +1,224 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: textbodycontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:52 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/textbodypropertiescontext.hxx"
+#include "oox/drawingml/textbodycontext.hxx"
+#include "oox/drawingml/textparagraphpropertiescontext.hxx"
+#include "oox/drawingml/textcharacterpropertiescontext.hxx"
+#include "oox/drawingml/textliststylecontext.hxx"
+#include "oox/drawingml/textfieldcontext.hxx"
+#include "oox/core/namespaces.hxx"
+#include "tokens.hxx"
+
+using ::rtl::OUString;
+using namespace ::oox::core;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::xml::sax;
+
+namespace oox { namespace drawingml {
+
+// --------------------------------------------------------------------
+
+// CT_TextParagraph
+class TextParagraphContext : public Context
+{
+public:
+ TextParagraphContext( const FragmentHandlerRef& xHandler, TextParagraph& rPara );
+
+ virtual void SAL_CALL endFastElement( sal_Int32 aElementToken ) throw (SAXException, RuntimeException);
+ virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException);
+
+protected:
+ TextParagraph& mrParagraph;
+};
+
+// --------------------------------------------------------------------
+TextParagraphContext::TextParagraphContext( const FragmentHandlerRef& xHandler, TextParagraph& rPara )
+: Context( xHandler )
+, mrParagraph( rPara )
+{
+}
+
+// --------------------------------------------------------------------
+void TextParagraphContext::endFastElement( sal_Int32 aElementToken ) throw (SAXException, RuntimeException)
+{
+ if( aElementToken == (NMSP_DRAWINGML|XML_p) )
+ {
+ }
+}
+
+// --------------------------------------------------------------------
+
+Reference< XFastContextHandler > TextParagraphContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ // EG_TextRun
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_r: // "CT_RegularTextRun" Regular Text Run.
+ {
+ TextRunPtr pRun( new TextRun() );
+ mrParagraph.addRun( pRun );
+ xRet.set( new RegularTextRunContext( getHandler(), pRun ) );
+ break;
+ }
+ case NMSP_DRAWINGML|XML_br: // "CT_TextLineBreak" Soft return line break (vertical tab).
+ {
+ TextRunPtr pRun( new TextRun() );
+ pRun->setLineBreak();
+ mrParagraph.addRun( pRun );
+ xRet.set( new RegularTextRunContext( getHandler(), pRun ) );
+ break;
+ }
+ case NMSP_DRAWINGML|XML_fld: // "CT_TextField" Text Field.
+ {
+ TextFieldPtr pField( new TextField() );
+ mrParagraph.addRun( pField );
+ xRet.set( new TextFieldContext( this, xAttribs, pField ) );
+ break;
+ }
+ case NMSP_DRAWINGML|XML_pPr:
+ xRet.set( new TextParagraphPropertiesContext( this, xAttribs, *(mrParagraph.getProperties().get()) ) );
+ break;
+ case NMSP_DRAWINGML|XML_endParaRPr:
+ xRet.set( new TextParagraphPropertiesContext( this, xAttribs, *(mrParagraph.getEndProperties().get()) ) );
+ break;
+ }
+
+ return xRet;
+}
+// --------------------------------------------------------------------
+
+RegularTextRunContext::RegularTextRunContext( const FragmentHandlerRef& xHandler, oox::drawingml::TextRunPtr pRunPtr )
+: Context( xHandler )
+, mpRunPtr( pRunPtr )
+, mbIsInText( false )
+{
+}
+
+// --------------------------------------------------------------------
+
+void RegularTextRunContext::endFastElement( sal_Int32 aElementToken ) throw (SAXException, RuntimeException)
+{
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_t:
+ {
+ mbIsInText = false;
+ break;
+ }
+ case NMSP_DRAWINGML|XML_r:
+ {
+ break;
+ }
+
+ }
+}
+
+// --------------------------------------------------------------------
+
+void RegularTextRunContext::characters( const OUString& aChars ) throw (SAXException, RuntimeException)
+{
+ if( mbIsInText )
+ {
+ mpRunPtr->text() += aChars;
+ }
+}
+
+// --------------------------------------------------------------------
+
+Reference< XFastContextHandler > RegularTextRunContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs) throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet( this );
+
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_rPr: // "CT_TextCharPropertyBag" The text char properties of this text run.
+ xRet.set( new TextCharacterPropertiesContext( this, xAttribs, *(mpRunPtr->getTextCharacterProperties().get()) ) );
+ break;
+ case NMSP_DRAWINGML|XML_t: // "xsd:string" minOccurs="1" The actual text string.
+ mbIsInText = true;
+ break;
+ }
+
+ return xRet;
+}
+
+// --------------------------------------------------------------------
+
+TextBodyContext::TextBodyContext( const ::oox::core::FragmentHandlerRef& xHandler, oox::drawingml::Shape& rShape )
+: Context( xHandler )
+, mrShape( rShape )
+, mpBodyPtr( new TextBody() )
+{
+ rShape.setTextBody( mpBodyPtr );
+}
+
+// --------------------------------------------------------------------
+
+void TextBodyContext::endFastElement( sal_Int32 ) throw (SAXException, RuntimeException)
+{
+}
+
+// --------------------------------------------------------------------
+
+Reference< XFastContextHandler > TextBodyContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_bodyPr: // CT_TextBodyPropertyBag
+ xRet.set( new TextBodyPropertiesContext( this, xAttribs, mrShape ) );
+ break;
+ case NMSP_DRAWINGML|XML_lstStyle: // CT_TextListStyle
+ xRet.set( new TextListStyleContext( getHandler(), *(mpBodyPtr->getTextListStyle().get()) ) );
+ break;
+ case NMSP_DRAWINGML|XML_p: // CT_TextParagraph
+ TextParagraphPtr pPara( new TextParagraph() );
+ mpBodyPtr->addParagraph( pPara );
+ xRet.set( new TextParagraphContext( getHandler(), *(pPara.get()) ) );
+ break;
+ }
+
+ return xRet;
+}
+
+// --------------------------------------------------------------------
+
+} }
+
diff --git a/oox/source/drawingml/textbodypropertiescontext.cxx b/oox/source/drawingml/textbodypropertiescontext.cxx
new file mode 100644
index 000000000000..31b0aca30f7c
--- /dev/null
+++ b/oox/source/drawingml/textbodypropertiescontext.cxx
@@ -0,0 +1,161 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: textbodypropertiescontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:52 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/textbodypropertiescontext.hxx"
+
+#include <com/sun/star/text/ControlCharacter.hpp>
+#include "oox/drawingml/drawingmltypes.hxx"
+#include "oox/helper/attributelist.hxx"
+#include "oox/core/namespaces.hxx"
+#include "tokens.hxx"
+
+using ::rtl::OUString;
+using namespace ::oox::core;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::xml::sax;
+
+namespace oox { namespace drawingml {
+
+// --------------------------------------------------------------------
+
+// CT_TextBodyProperties
+TextBodyPropertiesContext::TextBodyPropertiesContext( const ::oox::core::ContextRef& xParent,
+ const Reference< XFastAttributeList >& xAttributes, Shape& rShape )
+: Context( xParent->getHandler() )
+, mrShape( rShape )
+{
+ AttributeList attribs(xAttributes);
+
+ // ST_TextWrappingType
+ sal_Int32 nWrappingType = xAttributes->getOptionalValueToken( XML_wrap, XML_square );
+ const OUString sTextWordWrap( RTL_CONSTASCII_USTRINGPARAM( "TextWordWrap" ) );
+ mrShape.getShapeProperties()[ sTextWordWrap ] <<= (nWrappingType == XML_square);
+
+ // ST_Coordinate
+ const OUString sTextLeftDistance( RTL_CONSTASCII_USTRINGPARAM( "TextLeftDistance" ) );
+ const OUString sTextUpperDistance( RTL_CONSTASCII_USTRINGPARAM( "TextUpperDistance" ) );
+ const OUString sTextRightDistance( RTL_CONSTASCII_USTRINGPARAM( "TextRightDistance" ) );
+ const OUString sTextLowerDistance( RTL_CONSTASCII_USTRINGPARAM( "TextLowerDistance" ) );
+ OUString sValue;
+ sValue = xAttributes->getOptionalValue( XML_lIns );
+ sal_Int32 nLeftInset = ( sValue.getLength() != 0 ? GetCoordinate( sValue ) : 91440 / 360 );
+ mrShape.getShapeProperties()[ sTextLeftDistance ] <<= static_cast< sal_Int32 >( nLeftInset );
+
+ sValue = xAttributes->getOptionalValue( XML_tIns );
+ sal_Int32 nTopInset = ( sValue.getLength() != 0 ? GetCoordinate( sValue ) : 91440 / 360 );
+ mrShape.getShapeProperties()[ sTextUpperDistance ] <<= static_cast< sal_Int32 >( nTopInset );
+
+ sValue = xAttributes->getOptionalValue( XML_rIns );
+ sal_Int32 nRightInset = ( sValue.getLength() != 0 ? GetCoordinate( sValue ) : 91440 / 360 );
+ mrShape.getShapeProperties()[ sTextRightDistance ] <<= static_cast< sal_Int32 >( nRightInset );
+
+ sValue = xAttributes->getOptionalValue( XML_bIns );
+ sal_Int32 nBottonInset = ( sValue.getLength() != 0 ? GetCoordinate( sValue ) : 45720 / 360 );;
+ mrShape.getShapeProperties()[ sTextLowerDistance ] <<= static_cast< sal_Int32 >( nBottonInset );
+
+
+ // ST_TextAnchoringType
+// sal_Int32 nAnchoringType = xAttributes->getOptionalValueToken( XML_anchor, XML_t );
+
+// bool bAnchorCenter = attribs.getBool( XML_anchorCtr, false );
+
+// bool bCompatLineSpacing = attribs.getBool( XML_compatLnSpc, false );
+// bool bForceAA = attribs.getBool( XML_forceAA, false );
+// bool bFromWordArt = attribs.getBool( XML_fromWordArt, false );
+
+ // ST_TextHorzOverflowType
+// sal_Int32 nHorzOverflow = xAttributes->getOptionalValueToken( XML_horzOverflow, XML_overflow );
+ // ST_TextVertOverflowType
+// sal_Int32 nVertOverflow = xAttributes->getOptionalValueToken( XML_vertOverflow, XML_overflow );
+
+ // ST_TextColumnCount
+// sal_Int32 nNumCol = attribs.getInteger( XML_numCol, 1 );
+
+ // ST_Angle
+// sal_Int32 nRot = attribs.getInteger( XML_rot, 0 );
+// bool bRtlCol = attribs.getBool( XML_rtlCol, false );
+ // ST_PositiveCoordinate
+// sal_Int32 nSpcCol = attribs.getInteger( XML_spcCol, 0 );
+// bool bSpcFirstLastPara = attribs.getBool( XML_spcFirstLastPara, 0 );
+// bool bUpRight = attribs.getBool( XML_upright, 0 );
+ // ST_TextVerticalType
+// sal_Int32 nVert = xAttributes->getOptionalValueToken( XML_vert, XML_horz );
+}
+
+// --------------------------------------------------------------------
+
+void TextBodyPropertiesContext::endFastElement( sal_Int32 ) throw (SAXException, RuntimeException)
+{
+}
+
+// --------------------------------------------------------------------
+
+Reference< XFastContextHandler > TextBodyPropertiesContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& /*xAttributes*/) throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+ const OUString sTextAutoGrowHeight( RTL_CONSTASCII_USTRINGPARAM( "TextAutoGrowHeight" ) );
+ switch( aElementToken )
+ {
+ // Sequence
+ case NMSP_DRAWINGML|XML_prstTxWarp: // CT_PresetTextShape
+ case NMSP_DRAWINGML|XML_prot: // CT_TextProtectionProperty
+ break;
+
+ // EG_TextAutofit
+ case NMSP_DRAWINGML|XML_noAutofit:
+ mrShape.getShapeProperties()[ sTextAutoGrowHeight ] <<= sal_False; // CT_TextNoAutofit
+ break;
+ case NMSP_DRAWINGML|XML_normAutofit: // CT_TextNormalAutofit
+ case NMSP_DRAWINGML|XML_spAutoFit:
+ mrShape.getShapeProperties()[ sTextAutoGrowHeight ] <<= sal_True;
+ break;
+
+ case NMSP_DRAWINGML|XML_scene3d: // CT_Scene3D
+
+ // EG_Text3D
+ case NMSP_DRAWINGML|XML_sp3d: // CT_Shape3D
+ case NMSP_DRAWINGML|XML_flatTx: // CT_FlatText
+
+ break;
+ }
+
+ return xRet;
+}
+
+// --------------------------------------------------------------------
+
+} }
+
diff --git a/oox/source/drawingml/textcharacterproperties.cxx b/oox/source/drawingml/textcharacterproperties.cxx
new file mode 100644
index 000000000000..999f1e6dccb4
--- /dev/null
+++ b/oox/source/drawingml/textcharacterproperties.cxx
@@ -0,0 +1,135 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: textcharacterproperties.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:52 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/textcharacterproperties.hxx"
+
+#include "oox/helper/propertyset.hxx"
+#include "oox/core/namespaces.hxx"
+#include "tokens.hxx"
+
+using rtl::OUString;
+using namespace ::oox::core;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+
+namespace oox { namespace drawingml {
+
+TextCharacterProperties::TextCharacterProperties()
+: maCharColorPtr( new Color() )
+, maUnderlineColorPtr( new Color() )
+, maHighlightColorPtr( new Color() )
+{
+}
+TextCharacterProperties::~TextCharacterProperties()
+{
+}
+void TextCharacterProperties::apply( const TextCharacterPropertiesPtr& rSourceTextCharacterPropertiesPtr )
+{
+ maTextCharacterPropertyMap.insert( rSourceTextCharacterPropertiesPtr->maTextCharacterPropertyMap.begin(), rSourceTextCharacterPropertiesPtr->maTextCharacterPropertyMap.end() );
+ maHyperlinkPropertyMap.insert( rSourceTextCharacterPropertiesPtr->maHyperlinkPropertyMap.begin(), rSourceTextCharacterPropertiesPtr->maHyperlinkPropertyMap.end() );
+ ColorPtr rSourceCharColor( rSourceTextCharacterPropertiesPtr->getCharColor() );
+ if ( rSourceCharColor->isUsed() )
+ maCharColorPtr = rSourceCharColor;
+ ColorPtr rSourceHighlightColor( rSourceTextCharacterPropertiesPtr->getHighlightColor() );
+ if ( rSourceHighlightColor->isUsed() )
+ maHighlightColorPtr = rSourceHighlightColor;
+ ColorPtr rSourceUnderlineColor( rSourceTextCharacterPropertiesPtr->getUnderlineColor() );
+ if ( rSourceUnderlineColor->isUsed() )
+ maUnderlineColorPtr = rSourceUnderlineColor;
+ Any& rHasUnderline = rSourceTextCharacterPropertiesPtr->getHasUnderline();
+ if ( rHasUnderline.hasValue() )
+ maHasUnderline = rHasUnderline;
+ Any& rUnderlineLineFollowText = rSourceTextCharacterPropertiesPtr->getUnderlineLineFollowText();
+ if ( rUnderlineLineFollowText.hasValue() )
+ maUnderlineLineFollowText = rUnderlineLineFollowText;
+ Any& rUnderlineFillFollowText = rSourceTextCharacterPropertiesPtr->getUnderlineFillFollowText();
+ if ( rUnderlineFillFollowText.hasValue() )
+ maUnderlineFillFollowText = rUnderlineFillFollowText;
+}
+void TextCharacterProperties::pushToPropSet( const ::oox::core::XmlFilterBase& rFilterBase, const Reference < XPropertySet > & xPropSet ) const
+{
+ PropertySet aPropSet( xPropSet );
+ Sequence< OUString > aNames;
+ Sequence< Any > aValues;
+
+// maTextCharacterPropertyMap.dump_debug("TextCharacter props");
+ maTextCharacterPropertyMap.makeSequence( aNames, aValues );
+ aPropSet.setProperties( aNames, aValues );
+ if ( maCharColorPtr->isUsed() )
+ {
+ const rtl::OUString sCharColor( CREATE_OUSTRING( "CharColor" ) );
+ aPropSet.setProperty( sCharColor, maCharColorPtr->getColor( rFilterBase ) );
+
+ }
+
+ sal_Bool bHasUnderline = sal_False;
+ sal_Bool bUnderlineFillFollowText = sal_False;
+ maHasUnderline >>= bHasUnderline;
+ maUnderlineFillFollowText >>= bUnderlineFillFollowText;
+ if( bHasUnderline )
+ {
+ if( maUnderlineColorPtr.get() && !bUnderlineFillFollowText )
+ {
+ const rtl::OUString sCharUnderlineColor( CREATE_OUSTRING( "CharUnderlineColor" ) );
+ aPropSet.setProperty( sCharUnderlineColor, maUnderlineColorPtr->getColor( rFilterBase ) );
+ const rtl::OUString sCharUnderlineHasColor( CREATE_OUSTRING( "CharUnderlineHasColor" ) );
+ aPropSet.setProperty( sCharUnderlineHasColor, Any( sal_True ) );
+ }
+ }
+}
+
+void TextCharacterProperties::pushToUrlFieldPropSet( const Reference < XPropertySet > & xPropSet ) const
+{
+ PropertySet aPropSet( xPropSet );
+ Sequence< OUString > aNames;
+ Sequence< Any > aValues;
+
+ maHyperlinkPropertyMap.makeSequence( aNames, aValues );
+ aPropSet.setProperties( aNames, aValues );
+}
+
+float TextCharacterProperties::getCharacterSize( float fDefault ) const
+{
+ const rtl::OUString sCharHeight( CREATE_OUSTRING( "CharHeight" ) );
+ float fCharHeight;
+ const Any* pAny = maTextCharacterPropertyMap.getPropertyValue( sCharHeight );
+ if ( pAny && ( *pAny >>= fCharHeight ) )
+ return fCharHeight;
+ else
+ return fDefault;
+}
+
+} }
diff --git a/oox/source/drawingml/textcharacterpropertiescontext.cxx b/oox/source/drawingml/textcharacterpropertiescontext.cxx
new file mode 100644
index 000000000000..21ef91063726
--- /dev/null
+++ b/oox/source/drawingml/textcharacterpropertiescontext.cxx
@@ -0,0 +1,282 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: textcharacterpropertiescontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:52 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/textcharacterpropertiescontext.hxx"
+
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/awt/FontStrikeout.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+
+#include "oox/helper/attributelist.hxx"
+#include "oox/drawingml/drawingmltypes.hxx"
+#include "oox/drawingml/colorchoicecontext.hxx"
+#include "oox/drawingml/lineproperties.hxx"
+#include "oox/core/namespaces.hxx"
+#include "oox/core/relations.hxx"
+#include "textfontcontext.hxx"
+#include "hyperlinkcontext.hxx"
+#include "tokens.hxx"
+
+using ::rtl::OUString;
+using namespace ::oox::core;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+using namespace ::com::sun::star::awt;
+
+namespace oox { namespace drawingml {
+
+// --------------------------------------------------------------------
+
+// CT_TextCharacterProperties
+TextCharacterPropertiesContext::TextCharacterPropertiesContext( const ::oox::core::ContextRef& xParent,
+ const Reference< XFastAttributeList >& rXAttributes,
+ oox::drawingml::TextCharacterProperties& rTextCharacterProperties )
+: Context( xParent->getHandler() )
+, mrTextCharacterProperties( rTextCharacterProperties )
+{
+ AttributeList attribs( rXAttributes );
+ PropertyMap& rPropertyMap( mrTextCharacterProperties.getTextCharacterPropertyMap() );
+
+ rtl::OUString aVal( rXAttributes->getOptionalValue( XML_sz ) );
+ if ( aVal.getLength() )
+ {
+ float fTextSize = GetTextSize( aVal );
+ const rtl::OUString sCharHeight( CREATE_OUSTRING( "CharHeight" ) );
+ const rtl::OUString sCharHeightAsian( CREATE_OUSTRING( "CharHeightAsian" ) );
+ const rtl::OUString sCharHeightComplex( CREATE_OUSTRING( "CharHeightComplex" ) );
+ rPropertyMap[ sCharHeight ] <<= fTextSize;
+ rPropertyMap[ sCharHeightAsian ] <<= fTextSize;
+ rPropertyMap[ sCharHeightComplex ] <<= fTextSize;
+ }
+
+ bool bIsBold = attribs.getBool( XML_b, false );
+ const rtl::OUString sCharWeight( CREATE_OUSTRING( "CharWeight" ) );
+ const rtl::OUString sCharWeightAsian( CREATE_OUSTRING( "CharWeightAsian" ) );
+ const rtl::OUString sCharWeightComplex( CREATE_OUSTRING( "CharWeightComplex" ) );
+ rPropertyMap[ sCharWeight ] <<= ( bIsBold ? FontWeight::BOLD : FontWeight::NORMAL );
+ rPropertyMap[ sCharWeightAsian ] <<= ( bIsBold ? FontWeight::BOLD : FontWeight::NORMAL );
+ rPropertyMap[ sCharWeightComplex ] <<= ( bIsBold ? FontWeight::BOLD : FontWeight::NORMAL );
+
+ bool bIsItalic = attribs.getBool( XML_i, false );
+ const rtl::OUString sCharFontPosture( CREATE_OUSTRING( "CharPosture" ) );
+ const rtl::OUString sCharFontPostureAsian( CREATE_OUSTRING( "CharPostureAsian" ) );
+ const rtl::OUString sCharFontPostureComplex( CREATE_OUSTRING( "CharPostureComplex" ) );
+ rPropertyMap[ sCharFontPosture ] <<= ( bIsItalic ? FontSlant_ITALIC : FontSlant_NONE );
+ rPropertyMap[ sCharFontPostureAsian ] <<= ( bIsItalic ? FontSlant_ITALIC : FontSlant_NONE );
+ rPropertyMap[ sCharFontPostureComplex ] <<= ( bIsItalic ? FontSlant_ITALIC : FontSlant_NONE );
+
+ sal_Int32 nFontUnderline( rXAttributes->getOptionalValueToken( XML_u, 0 ) );
+ if ( nFontUnderline )
+ {
+ const rtl::OUString sCharUnderline( CREATE_OUSTRING( "CharUnderline" ) );
+ rPropertyMap[ sCharUnderline ] <<= GetFontUnderline( nFontUnderline );
+ mrTextCharacterProperties.getHasUnderline() <<= sal_True;
+ }
+
+ const rtl::OUString sCharStrikeout( CREATE_OUSTRING( "CharStrikeout" ) );
+ rPropertyMap[ sCharStrikeout ] <<= GetFontStrikeout( rXAttributes->getOptionalValueToken( XML_strike, XML_noStrike ) );
+
+ // ST_TextCapsType
+ const rtl::OUString sCharCaseMap( CREATE_OUSTRING( "CharCaseMap" ) );
+ rPropertyMap[ sCharCaseMap ] <<= GetCaseMap( rXAttributes->getOptionalValueToken( XML_cap, XML_none ) );
+
+
+ OUString sLang = rXAttributes->getOptionalValue( XML_lang );
+ if( sLang.getLength( ) )
+ {
+ const rtl::OUString sCharLocale( CREATE_OUSTRING( "CharLocale" ) );
+ const rtl::OUString sCharLocaleAsian( CREATE_OUSTRING( "CharLocaleAsian" ) );
+ const rtl::OUString sCharLocaleComplex( CREATE_OUSTRING( "CharLocaleComplex" ) );
+
+ com::sun::star::lang::Locale aLocale;
+ OUString aString( sLang );
+ sal_Int32 nSepPos = aString.indexOf( (sal_Unicode)'-', 0 );
+ if ( nSepPos != -1 )
+ {
+ aLocale.Language = aString.copy( 0, nSepPos );
+ aLocale.Country = aString.copy( nSepPos+1 );
+ }
+ else
+ {
+ aLocale.Language = aString;
+ }
+
+ rPropertyMap[ sCharLocale ] <<= aLocale;
+ rPropertyMap[ sCharLocaleAsian ] <<= aLocale;
+ rPropertyMap[ sCharLocaleComplex ] <<= aLocale;
+ }
+
+
+// TODO
+/* todo: we need to be able to iterate over the XFastAttributes
+
+ // ST_TextNonNegativePoint
+ const rtl::OUString sCharKerning( CREATE_OUSTRING( "CharKerning" ) );
+ //case NMSP_DRAWINGML|XML_kern:
+
+ // ST_TextLanguageID
+ OUString sAltLang = rXAttributes->getOptionalValue( XML_altLang );
+
+ case NMSP_DRAWINGML|XML_kumimoji: // xsd:boolean
+ break;
+ case NMSP_DRAWINGML|XML_spc: // ST_TextPoint
+ case NMSP_DRAWINGML|XML_normalizeH: // xsd:boolean
+ case NMSP_DRAWINGML|XML_baseline: // ST_Percentage
+ case NMSP_DRAWINGML|XML_noProof: // xsd:boolean
+ case NMSP_DRAWINGML|XML_dirty: // xsd:boolean
+ case NMSP_DRAWINGML|XML_err: // xsd:boolean
+ case NMSP_DRAWINGML|XML_smtClean: // xsd:boolean
+ case NMSP_DRAWINGML|XML_smtId: // xsd:unsignedInt
+ break;
+*/
+
+}
+
+TextCharacterPropertiesContext::~TextCharacterPropertiesContext()
+{
+ PropertyMap& rPropertyMap( mrTextCharacterProperties.getTextCharacterPropertyMap() );
+
+ sal_Int16 nPitch, nFamily;
+
+ if( maLatinFont.is() )
+ {
+ const rtl::OUString sCharFontName( CREATE_OUSTRING( "CharFontName" ) );
+ const rtl::OUString sCharFontPitch( CREATE_OUSTRING( "CharFontPitch" ) );
+ const rtl::OUString sCharFontFamily( CREATE_OUSTRING( "CharFontFamily" ) );
+ GetFontPitch( maLatinFont.mnPitch, nPitch, nFamily);
+ rPropertyMap[ sCharFontName ] <<= maLatinFont.msTypeface;
+ rPropertyMap[ sCharFontPitch ] <<= nPitch;
+ rPropertyMap[ sCharFontFamily ] <<= nFamily;
+ }
+ if( maAsianFont.is() )
+ {
+ const rtl::OUString sCharFontNameAsian( CREATE_OUSTRING( "CharFontNameAsian" ) );
+ const rtl::OUString sCharFontPitchAsian( CREATE_OUSTRING( "CharFontPitchAsian" ) );
+ const rtl::OUString sCharFontFamilyAsian( CREATE_OUSTRING( "CharFontFamilyAsian" ) );
+ GetFontPitch( maAsianFont.mnPitch, nPitch, nFamily);
+ rPropertyMap[ sCharFontNameAsian ] <<= maAsianFont.msTypeface;
+ rPropertyMap[ sCharFontPitchAsian ] <<= nFamily;
+ rPropertyMap[ sCharFontFamilyAsian ] <<= nPitch;
+ }
+ if( maComplexFont.is() )
+ {
+ const rtl::OUString sCharFontNameComplex( CREATE_OUSTRING( "CharFontNameComplex" ) );
+ const rtl::OUString sCharFontPitchComplex( CREATE_OUSTRING( "CharFontPitchComplex" ) );
+ const rtl::OUString sCharFontFamilyComplex( CREATE_OUSTRING( "CharFontFamilyComplex" ) );
+ GetFontPitch( maComplexFont.mnPitch, nPitch, nFamily );
+ rPropertyMap[ sCharFontNameComplex ] <<= maComplexFont.msTypeface;
+ rPropertyMap[ sCharFontPitchComplex ] <<= nPitch;
+ rPropertyMap[ sCharFontFamilyComplex ] <<= nFamily;
+ }
+}
+
+// --------------------------------------------------------------------
+
+void TextCharacterPropertiesContext::endFastElement( sal_Int32 ) throw (SAXException, RuntimeException)
+{
+}
+
+// --------------------------------------------------------------------
+
+Reference< XFastContextHandler > TextCharacterPropertiesContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttributes ) throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+ switch( aElementToken )
+ {
+ // not supported.....
+ case NMSP_DRAWINGML|XML_ln: // CT_LineProperties
+// TODO unsupported yet
+// xRet.set( new LinePropertiesContext( getHandler(), xAttributes, maTextOutlineProperties ) );
+ break;
+ // EG_FillProperties
+ case NMSP_DRAWINGML|XML_solidFill:
+ xRet.set( new colorChoiceContext( getHandler(), *(mrTextCharacterProperties.getCharColor().get()) ) );
+ break;
+ // EG_EffectProperties
+ case NMSP_DRAWINGML|XML_effectDag:
+ // CT_EffectContainer 5.1.10.25
+ case NMSP_DRAWINGML|XML_effectLst:
+ // CT_EffectList 5.1.10.26
+ break;
+
+ case NMSP_DRAWINGML|XML_highlight: //CT_Color
+ xRet.set( new colorChoiceContext( getHandler(), *(mrTextCharacterProperties.getHighlightColor().get()) ) );
+ break;
+
+ // EG_TextUnderlineLine
+ case NMSP_DRAWINGML|XML_uLnTx: // CT_TextUnderlineLineFollowText
+ mrTextCharacterProperties.getUnderlineLineFollowText() <<= sal_True;
+ break;
+ case NMSP_DRAWINGML|XML_uLn: // CT_LineProperties
+// TODO unsupported yet
+// xRet.set( new LinePropertiesContext( getHandler(), xAttributes, maUnderlineProperties ) );
+ break;
+
+ // EG_TextUnderlineFill
+ case NMSP_DRAWINGML|XML_uFillTx: // CT_TextUnderlineFillFollowText
+ mrTextCharacterProperties.getUnderlineFillFollowText() <<= sal_True;
+ break;
+ case NMSP_DRAWINGML|XML_uFill: // CT_TextUnderlineFillGroupWrapper->EG_FillProperties (not supported)
+ xRet.set( new colorChoiceContext( getHandler(), *(mrTextCharacterProperties.getUnderlineColor().get()) ) );
+ break;
+
+ case NMSP_DRAWINGML|XML_ea: // CT_TextFont
+ xRet.set( new TextFontContext( getHandler(), aElementToken, xAttributes, maAsianFont ) );
+ break;
+ case NMSP_DRAWINGML|XML_cs: // CT_TextFont
+ xRet.set( new TextFontContext( getHandler(), aElementToken, xAttributes, maComplexFont ) );
+ break;
+ case NMSP_DRAWINGML|XML_sym: // CT_TextFont
+ xRet.set( new TextFontContext( getHandler(), aElementToken, xAttributes, maSymbolFont ) );
+ break;
+ case NMSP_DRAWINGML|XML_latin: // CT_TextFont
+ xRet.set( new TextFontContext( getHandler(), aElementToken, xAttributes, maLatinFont ) );
+ break;
+ case NMSP_DRAWINGML|XML_hlinkClick: // CT_Hyperlink
+ case NMSP_DRAWINGML|XML_hlinkMouseOver: // CT_Hyperlink
+ xRet.set( new HyperLinkContext( getHandler(), xAttributes, mrTextCharacterProperties.getHyperlinkPropertyMap() ) );
+ break;
+ }
+ if ( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+}
+
+// --------------------------------------------------------------------
+
+} }
+
diff --git a/oox/source/drawingml/textfield.cxx b/oox/source/drawingml/textfield.cxx
new file mode 100644
index 000000000000..7ae2ba947dd7
--- /dev/null
+++ b/oox/source/drawingml/textfield.cxx
@@ -0,0 +1,196 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: textfield.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:52 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2007 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/textfield.hxx"
+
+#include <list>
+
+#include <rtl/ustring.hxx>
+#include <rtl/string.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/text/XTextField.hpp>
+
+#include "oox/helper/helper.hxx"
+#include "oox/drawingml/textparagraphproperties.hxx"
+
+using ::rtl::OString;
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::lang;
+
+namespace oox { namespace drawingml {
+
+ TextField::TextField()
+ : mpTextParagraphPropertiesPtr( new TextParagraphProperties())
+ {
+ }
+
+
+ /** intsanciate the textfields. Because of semantics difference between
+ * OpenXML and OpenOffice, some OpenXML field might cause two fields to be created.
+ * @param aFields the created fields. The list is empty if no field has been created.
+ * @param xModel the model
+ * @param sType the OpenXML field type.
+ */
+ static void createTextFields( std::list< Reference< XTextField > > & aFields,
+ const Reference< XModel > & xModel, const OUString & sType )
+ {
+ Reference< XInterface > xIface;
+ Reference< XMultiServiceFactory > xFactory( xModel, UNO_QUERY_THROW );
+
+ if( sType.compareToAscii( "datetime", 8 ) == 0)
+ {
+ OString s = ::rtl::OUStringToOString( sType, RTL_TEXTENCODING_UTF8);
+ OString p( s.pData->buffer + 8 );
+ try
+ {
+ bool bIsDate = true;
+ int idx = p.toInt32();
+// OSL_TRACE( "OOX: p = %s, %d", p.pData->buffer, idx );
+ xIface = xFactory->createInstance( CREATE_OUSTRING( "com.sun.star.text.TextField.DateTime" ) );
+ aFields.push_back( Reference< XTextField > ( xIface, UNO_QUERY ) );
+ Reference< XPropertySet > xProps( xIface, UNO_QUERY_THROW );
+
+ // here we should format the field properly. waiting after #i81091.
+ switch( idx )
+ {
+ case 1: // Date dd/mm/yyyy
+ // this is the default format...
+ break;
+ case 2: // Date Day, Month dd, yyyy
+ break;
+ case 3: // Date dd Month yyyy
+ break;
+ case 4: // Date Month dd, yyyy
+ break;
+ case 5: // Date dd-Mon-yy
+ break;
+ case 6: // Date Month yy
+ break;
+ case 7: // Date Mon-yy
+ break;
+ case 8: // DateTime dd/mm/yyyy H:MM PM
+ createTextFields( aFields, xModel, CREATE_OUSTRING( "datetime12" ) );
+ break;
+ case 9: // DateTime dd/mm/yy H:MM:SS PM
+ createTextFields( aFields, xModel, CREATE_OUSTRING( "datetime13" ) );
+ break;
+ case 10: // Time H:MM
+ bIsDate = false;
+ break;
+ case 11: // Time H:MM:SS
+ bIsDate = false;
+ // this is the default format
+ break;
+ case 12: // Time H:MM PM
+ bIsDate = false;
+ break;
+ case 13: // Time H:MM:SS PM
+ bIsDate = false;
+ break;
+ }
+ xProps->setPropertyValue( CREATE_OUSTRING( "IsDate" ), makeAny( bIsDate ) );
+ xProps->setPropertyValue( CREATE_OUSTRING( "IsFixed" ), makeAny( false ) );
+ }
+ catch(Exception & e)
+ {
+ OSL_TRACE( "Exception %s", OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ }
+ }
+ else if ( sType.compareToAscii( "slidenum" ) == 0 )
+ {
+ xIface = xFactory->createInstance( CREATE_OUSTRING( "com.sun.star.text.TextField.PageNumber" ) );
+ aFields.push_back( Reference< XTextField > ( xIface, UNO_QUERY ) );
+ }
+ }
+
+ void TextField::insertAt( const ::oox::core::XmlFilterBase& rFilterBase, const Reference < XText > & xText,
+ const Reference < XTextCursor > &xAt,
+ const Reference< XModel > &xModel,
+ const TextCharacterPropertiesPtr& rTextCharacterStyle )
+ {
+ try {
+
+ PropertyMap aioBulletList;
+ Reference< XTextRange > xStart( xAt, UNO_QUERY );
+ Reference< XPropertySet > xProps( xStart, UNO_QUERY);
+ mpTextParagraphPropertiesPtr->pushToPropSet( rFilterBase, xProps, aioBulletList, sal_True );
+
+ if ( rTextCharacterStyle.get() )
+ rTextCharacterStyle->pushToPropSet( rFilterBase, xProps );
+
+ maTextCharacterPropertiesPtr->pushToPropSet( rFilterBase, xProps );
+
+ std::list< Reference< XTextField > > fields;
+ createTextFields( fields, xModel, msType );
+ if( !fields.empty() )
+ {
+ bool bFirst = true;
+ for( std::list< Reference< XTextField > >::iterator iter = fields.begin();
+ iter != fields.end(); ++iter )
+ {
+ if( iter->is() )
+ {
+ Reference< XTextContent > xContent( *iter, UNO_QUERY);
+ if( bFirst)
+ {
+ bFirst = false;
+ }
+ else
+ {
+ xText->insertString( xStart, CREATE_OUSTRING( " " ), sal_False );
+ }
+ xText->insertTextContent( xStart, xContent, sal_False );
+ }
+ }
+ }
+ else
+ {
+ xText->insertString( xStart, text(), sal_False );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_TRACE("OOX: TextField::insertAt() exception");
+ }
+ }
+
+
+} }
diff --git a/oox/source/drawingml/textfieldcontext.cxx b/oox/source/drawingml/textfieldcontext.cxx
new file mode 100644
index 000000000000..00845ee76862
--- /dev/null
+++ b/oox/source/drawingml/textfieldcontext.cxx
@@ -0,0 +1,107 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: textfieldcontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:52 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include <rtl/ustring.hxx>
+
+#include "oox/drawingml/textparagraphpropertiescontext.hxx"
+#include "oox/drawingml/textcharacterpropertiescontext.hxx"
+#include "oox/drawingml/textfieldcontext.hxx"
+#include "oox/core/namespaces.hxx"
+#include "tokens.hxx"
+
+using ::rtl::OUString;
+using namespace ::oox::core;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+
+namespace oox { namespace drawingml {
+
+ TextFieldContext::TextFieldContext( const ContextRef& xParent,
+ const Reference< XFastAttributeList >& rXAttributes,
+ const TextFieldPtr & pTextField)
+ : Context( xParent->getHandler() )
+ , mpTextField( pTextField )
+ , mbIsInText( false )
+ {
+ try {
+ pTextField->setUuid( rXAttributes->getValue( XML_id ) );
+ }
+ catch(...)
+ {
+
+ }
+ pTextField->setType( rXAttributes->getOptionalValue( XML_type ) );
+ }
+
+ void TextFieldContext::endFastElement( sal_Int32 aElementToken ) throw (SAXException, RuntimeException)
+ {
+ if( aElementToken == (NMSP_DRAWINGML|XML_t) )
+ {
+ mbIsInText = false;
+ }
+ }
+
+ void TextFieldContext::characters( const OUString& aChars ) throw (SAXException, RuntimeException)
+ {
+ if( mbIsInText )
+ {
+ mpTextField->text() += aChars;
+ }
+ }
+
+ Reference< XFastContextHandler > TextFieldContext::createFastChildContext( sal_Int32 aElementToken,
+ const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
+ {
+ Reference< XFastContextHandler > xRet;
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_rPr:
+ xRet.set( new TextCharacterPropertiesContext( this, xAttribs, *(mpTextField->getTextCharacterProperties().get()) ) );
+ break;
+ case NMSP_DRAWINGML|XML_pPr:
+ xRet.set( new TextParagraphPropertiesContext( this, xAttribs, *(mpTextField->getTextParagraphProperties().get()) ) );
+ break;
+ case NMSP_DRAWINGML|XML_t:
+ mbIsInText = true;
+ break;
+ }
+ if ( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+ }
+
+
+} }
diff --git a/oox/source/drawingml/textliststyle.cxx b/oox/source/drawingml/textliststyle.cxx
new file mode 100644
index 000000000000..fec174159497
--- /dev/null
+++ b/oox/source/drawingml/textliststyle.cxx
@@ -0,0 +1,78 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: textliststyle.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:52 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/textliststyle.hxx"
+
+namespace oox { namespace drawingml {
+
+TextListStyle::TextListStyle()
+ : maListStyle()
+ , maAggregationListStyle()
+{
+ int i;
+ for ( i = 0; i < 9; i++ )
+ maListStyle.push_back( TextParagraphPropertiesPtr( new TextParagraphProperties() ) );
+ for ( i = 0; i < 9; i++ )
+ maAggregationListStyle.push_back( TextParagraphPropertiesPtr( new TextParagraphProperties() ) );
+}
+TextListStyle::~TextListStyle()
+{
+}
+
+void applyStyleList( const std::vector< ::oox::drawingml::TextParagraphPropertiesPtr >& rSourceListStyle,
+ std::vector< ::oox::drawingml::TextParagraphPropertiesPtr >& rDestListStyle )
+{
+ std::vector< ::oox::drawingml::TextParagraphPropertiesPtr >::const_iterator aSourceListStyleIter( rSourceListStyle.begin() );
+ std::vector< ::oox::drawingml::TextParagraphPropertiesPtr >::iterator aDestListStyleIter( rDestListStyle.begin() );
+ while( aSourceListStyleIter != rSourceListStyle.end() )
+ {
+ if ( aDestListStyleIter != rDestListStyle.end() )
+ {
+ (*aDestListStyleIter)->apply( *aSourceListStyleIter );
+ aDestListStyleIter++;
+ }
+ else
+ rDestListStyle.push_back( TextParagraphPropertiesPtr( new oox::drawingml::TextParagraphProperties( *(*aSourceListStyleIter).get() ) ) );
+ aSourceListStyleIter++;
+ }
+}
+
+void TextListStyle::apply( const TextListStylePtr& rTextListStylePtr )
+{
+ applyStyleList( rTextListStylePtr->getAggregationListStyle(), getAggregationListStyle() );
+ applyStyleList( rTextListStylePtr->getListStyle(), getListStyle() );
+}
+
+} }
diff --git a/oox/source/drawingml/textliststylecontext.cxx b/oox/source/drawingml/textliststylecontext.cxx
new file mode 100644
index 000000000000..1e8b33b0fbd1
--- /dev/null
+++ b/oox/source/drawingml/textliststylecontext.cxx
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: textliststylecontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:52 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/textliststylecontext.hxx"
+#include "oox/drawingml/textparagraphpropertiescontext.hxx"
+#include "oox/core/namespaces.hxx"
+#include "oox/helper/attributelist.hxx"
+#include "tokens.hxx"
+
+using ::rtl::OUString;
+using namespace ::oox::core;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+
+namespace oox { namespace drawingml {
+
+// --------------------------------------------------------------------
+
+// CT_TextListStyle
+TextListStyleContext::TextListStyleContext( const ::oox::core::FragmentHandlerRef& xHandler, oox::drawingml::TextListStyle& rTextListStyle )
+: Context( xHandler )
+, mrTextListStyle( rTextListStyle )
+{
+}
+
+TextListStyleContext::~TextListStyleContext()
+{
+}
+
+// --------------------------------------------------------------------
+
+void TextListStyleContext::endFastElement( sal_Int32 ) throw (SAXException, RuntimeException)
+{
+}
+
+// --------------------------------------------------------------------
+
+Reference< XFastContextHandler > TextListStyleContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& rxAttributes ) throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_defPPr: // CT_TextParagraphProperties
+ xRet.set( new TextParagraphPropertiesContext( this, rxAttributes, *(mrTextListStyle.getListStyle()[ 0 ].get()) ) );
+ break;
+ case NMSP_DRAWINGML|XML_outline1pPr:
+ xRet.set( new TextParagraphPropertiesContext( this, rxAttributes, *(mrTextListStyle.getAggregationListStyle()[ 0 ].get()) ) );
+ break;
+ case NMSP_DRAWINGML|XML_outline2pPr:
+ xRet.set( new TextParagraphPropertiesContext( this, rxAttributes, *(mrTextListStyle.getAggregationListStyle()[ 1 ].get()) ) );
+ break;
+ case NMSP_DRAWINGML|XML_lvl1pPr:
+ xRet.set( new TextParagraphPropertiesContext( this, rxAttributes, *(mrTextListStyle.getListStyle()[ 0 ].get()) ) );
+ break;
+ case NMSP_DRAWINGML|XML_lvl2pPr:
+ xRet.set( new TextParagraphPropertiesContext( this, rxAttributes, *(mrTextListStyle.getListStyle()[ 1 ].get()) ) );
+ break;
+ case NMSP_DRAWINGML|XML_lvl3pPr:
+ xRet.set( new TextParagraphPropertiesContext( this, rxAttributes, *(mrTextListStyle.getListStyle()[ 2 ].get()) ) );
+ break;
+ case NMSP_DRAWINGML|XML_lvl4pPr:
+ xRet.set( new TextParagraphPropertiesContext( this, rxAttributes, *(mrTextListStyle.getListStyle()[ 3 ].get()) ) );
+ break;
+ case NMSP_DRAWINGML|XML_lvl5pPr:
+ xRet.set( new TextParagraphPropertiesContext( this, rxAttributes, *(mrTextListStyle.getListStyle()[ 4 ].get()) ) );
+ break;
+ case NMSP_DRAWINGML|XML_lvl6pPr:
+ xRet.set( new TextParagraphPropertiesContext( this, rxAttributes, *(mrTextListStyle.getListStyle()[ 5 ].get()) ) );
+ break;
+ case NMSP_DRAWINGML|XML_lvl7pPr:
+ xRet.set( new TextParagraphPropertiesContext( this, rxAttributes, *(mrTextListStyle.getListStyle()[ 6 ].get()) ) );
+ break;
+ case NMSP_DRAWINGML|XML_lvl8pPr:
+ xRet.set( new TextParagraphPropertiesContext( this, rxAttributes, *(mrTextListStyle.getListStyle()[ 7 ].get()) ) );
+ break;
+ case NMSP_DRAWINGML|XML_lvl9pPr:
+ xRet.set( new TextParagraphPropertiesContext( this, rxAttributes, *(mrTextListStyle.getListStyle()[ 8 ].get()) ) );
+ break;
+ }
+ if ( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+}
+
+// --------------------------------------------------------------------
+
+} }
+
diff --git a/oox/source/drawingml/textparagraph.cxx b/oox/source/drawingml/textparagraph.cxx
new file mode 100644
index 000000000000..e078e899282d
--- /dev/null
+++ b/oox/source/drawingml/textparagraph.cxx
@@ -0,0 +1,127 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: textparagraph.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:52 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2007 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+
+#include <algorithm>
+#include <boost/bind.hpp>
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/text/XText.hpp>
+#include <com/sun/star/text/XTextCursor.hpp>
+#include <com/sun/star/text/ControlCharacter.hpp>
+#include <comphelper/processfactory.hxx>
+
+#include "oox/drawingml/textparagraph.hxx"
+
+using ::rtl::OUString;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::frame;
+
+namespace oox { namespace drawingml {
+
+ TextParagraph::TextParagraph()
+ : mpProperties( new TextParagraphProperties( ) )
+ , mpEndProperties( new TextParagraphProperties( ) )
+ {
+ }
+
+
+ TextParagraph::~TextParagraph()
+ {
+ }
+
+
+ void TextParagraph::insertAt( const ::oox::core::XmlFilterBase& rFilterBase, const Reference < XText > &xText, const Reference < XTextCursor > &xAt, const Reference < XModel > &xModel,
+ const TextListStylePtr& rTextStyleList, bool bFirst)
+ {
+ try {
+ sal_Int32 nParagraphSize = 0;
+ Reference< XTextRange > xStart( xAt, UNO_QUERY );
+
+ sal_Int16 nLevel = mpProperties->getLevel();
+ std::vector< ::oox::drawingml::TextParagraphPropertiesPtr >& rListStyle = rTextStyleList->getListStyle();
+ if ( nLevel >= static_cast< sal_Int16 >( rListStyle.size() ) )
+ nLevel = 0;
+ TextParagraphPropertiesPtr pTextParagraphStyle;
+ TextCharacterPropertiesPtr pTextCharacterStyle;
+ if ( rListStyle.size() )
+ pTextParagraphStyle = rListStyle[ nLevel ];
+ if ( pTextParagraphStyle.get() )
+ pTextCharacterStyle = pTextParagraphStyle->getTextCharacterProperties();
+
+ if( !bFirst )
+ {
+ xText->insertControlCharacter( xStart, ControlCharacter::APPEND_PARAGRAPH, sal_False );
+ xAt->gotoEnd(true);
+ }
+
+ std::vector< TextRunPtr >::iterator begin( maRuns.begin() );
+ while( begin != maRuns.end() )
+ {
+ (*begin)->insertAt( rFilterBase, xText, xAt, xModel, pTextCharacterStyle );
+ nParagraphSize += (*begin++)->text().getLength();
+ }
+ xAt->gotoEnd(true);
+
+ PropertyMap aioBulletList;
+ Reference< XPropertySet > xProps( xStart, UNO_QUERY);
+ if ( pTextParagraphStyle.get() )
+ pTextParagraphStyle->pushToPropSet( rFilterBase, xProps, aioBulletList, sal_False );
+
+ mpProperties->pushToPropSet( rFilterBase, xProps, aioBulletList, sal_True );
+
+ // empty paragraphs do not have bullets in ppt
+ if ( !nParagraphSize )
+ {
+ const rtl::OUString sIsNumbering( CREATE_OUSTRING( "IsNumbering" ) );
+ xProps->setPropertyValue( sIsNumbering, Any( sal_False ) );
+ }
+
+// FIXME this is causing a lot of dispruption (ie does not work). I wonder what to do -- Hub
+// Reference< XTextRange > xEnd( xAt, UNO_QUERY );
+// Reference< XPropertySet > xProps2( xEnd, UNO_QUERY );
+// mpEndProperties->pushToPropSet( xProps2 );
+ }
+ catch( Exception & )
+ {
+ OSL_TRACE("OOX: exception in TextParagraph::insertAt");
+ }
+ }
+
+
+} }
+
diff --git a/oox/source/drawingml/textparagraphproperties.cxx b/oox/source/drawingml/textparagraphproperties.cxx
new file mode 100644
index 000000000000..e29cbf823aa2
--- /dev/null
+++ b/oox/source/drawingml/textparagraphproperties.cxx
@@ -0,0 +1,419 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: textparagraphproperties.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:52 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/textparagraphproperties.hxx"
+
+#include <com/sun/star/text/XNumberingRulesSupplier.hpp>
+#include <com/sun/star/container/XIndexReplace.hpp>
+#include <com/sun/star/text/HoriOrientation.hpp>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+
+#include "oox/helper/propertyset.hxx"
+#include "oox/core/namespaces.hxx"
+#include "oox/drawingml/drawingmltypes.hxx"
+#include "tokens.hxx"
+
+using rtl::OUString;
+using namespace ::oox::core;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::style;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::container;
+using ::com::sun::star::awt::FontDescriptor;
+
+namespace oox { namespace drawingml {
+
+BulletList::BulletList( )
+: maBulletColorPtr( new Color() )
+{
+}
+
+bool BulletList::is() const
+{
+ return mnNumberingType.hasValue();
+}
+
+void BulletList::setBulletChar( const ::rtl::OUString & sChar )
+{
+ mnNumberingType <<= NumberingType::CHAR_SPECIAL;
+ msBulletChar <<= sChar;
+}
+
+void BulletList::setNone( )
+{
+ mnNumberingType <<= NumberingType::NUMBER_NONE;
+}
+
+void BulletList::setSuffixParenBoth()
+{
+ msNumberingSuffix <<= CREATE_OUSTRING( ")" );
+ msNumberingPrefix <<= CREATE_OUSTRING( "(" );
+}
+
+void BulletList::setSuffixParenRight()
+{
+ msNumberingSuffix <<= CREATE_OUSTRING( ")" );
+ msNumberingPrefix <<= OUString();
+}
+
+void BulletList::setSuffixPeriod()
+{
+ msNumberingSuffix <<= CREATE_OUSTRING( "." );
+ msNumberingPrefix <<= OUString();
+}
+
+void BulletList::setSuffixNone()
+{
+ msNumberingSuffix <<= OUString();
+ msNumberingPrefix <<= OUString();
+}
+
+void BulletList::setSuffixMinusRight()
+{
+ msNumberingSuffix <<= CREATE_OUSTRING( "-" );
+ msNumberingPrefix <<= OUString();
+}
+
+void BulletList::setType( sal_Int32 nType )
+{
+// OSL_TRACE( "OOX: set list numbering type %d", nType);
+ switch( nType )
+ {
+ case XML_alphaLcParenBoth:
+ mnNumberingType <<= NumberingType::CHARS_LOWER_LETTER;
+ setSuffixParenBoth();
+ break;
+ case XML_alphaLcParenR:
+ mnNumberingType <<= NumberingType::CHARS_LOWER_LETTER;
+ setSuffixParenRight();
+ break;
+ case XML_alphaLcPeriod:
+ mnNumberingType <<= NumberingType::CHARS_LOWER_LETTER;
+ setSuffixPeriod();
+ break;
+ case XML_alphaUcParenBoth:
+ mnNumberingType <<= NumberingType::CHARS_UPPER_LETTER;
+ setSuffixParenBoth();
+ break;
+ case XML_alphaUcParenR:
+ mnNumberingType <<= NumberingType::CHARS_UPPER_LETTER;
+ setSuffixParenRight();
+ break;
+ case XML_alphaUcPeriod:
+ mnNumberingType <<= NumberingType::CHARS_UPPER_LETTER;
+ setSuffixPeriod();
+ break;
+ case XML_arabic1Minus:
+ case XML_arabic2Minus:
+ case XML_arabicDbPeriod:
+ case XML_arabicDbPlain:
+ // TODO
+ break;
+ case XML_arabicParenBoth:
+ mnNumberingType <<= NumberingType::ARABIC;
+ setSuffixParenBoth();
+ break;
+ case XML_arabicParenR:
+ mnNumberingType <<= NumberingType::ARABIC;
+ setSuffixParenRight();
+ break;
+ case XML_arabicPeriod:
+ mnNumberingType <<= NumberingType::ARABIC;
+ setSuffixPeriod();
+ break;
+ case XML_arabicPlain:
+ mnNumberingType <<= NumberingType::ARABIC;
+ setSuffixNone();
+ break;
+ case XML_circleNumDbPlain:
+ case XML_circleNumWdBlackPlain:
+ case XML_circleNumWdWhitePlain:
+ mnNumberingType <<= NumberingType::CIRCLE_NUMBER;
+ break;
+ case XML_ea1ChsPeriod:
+ mnNumberingType <<= NumberingType::NUMBER_UPPER_ZH;
+ setSuffixPeriod();
+ break;
+ case XML_ea1ChsPlain:
+ mnNumberingType <<= NumberingType::NUMBER_UPPER_ZH;
+ setSuffixNone();
+ break;
+ case XML_ea1ChtPeriod:
+ mnNumberingType <<= NumberingType::NUMBER_UPPER_ZH_TW;
+ setSuffixPeriod();
+ break;
+ case XML_ea1ChtPlain:
+ mnNumberingType <<= NumberingType::NUMBER_UPPER_ZH_TW;
+ setSuffixNone();
+ break;
+ case XML_ea1JpnChsDbPeriod:
+ case XML_ea1JpnKorPeriod:
+ case XML_ea1JpnKorPlain:
+ break;
+ case XML_hebrew2Minus:
+ mnNumberingType <<= NumberingType::CHARS_HEBREW;
+ setSuffixMinusRight();
+ break;
+ case XML_hindiAlpha1Period:
+ case XML_hindiAlphaPeriod:
+ case XML_hindiNumParenR:
+ case XML_hindiNumPeriod:
+ // TODO
+ break;
+ case XML_romanLcParenBoth:
+ mnNumberingType <<= NumberingType::ROMAN_LOWER;
+ setSuffixParenBoth();
+ break;
+ case XML_romanLcParenR:
+ mnNumberingType <<= NumberingType::ROMAN_LOWER;
+ setSuffixParenRight();
+ break;
+ case XML_romanLcPeriod:
+ mnNumberingType <<= NumberingType::ROMAN_LOWER;
+ setSuffixPeriod();
+ break;
+ case XML_romanUcParenBoth:
+ mnNumberingType <<= NumberingType::ROMAN_UPPER;
+ setSuffixParenBoth();
+ break;
+ case XML_romanUcParenR:
+ mnNumberingType <<= NumberingType::ROMAN_UPPER;
+ setSuffixParenRight();
+ break;
+ case XML_romanUcPeriod:
+ mnNumberingType <<= NumberingType::ROMAN_UPPER;
+ setSuffixPeriod();
+ break;
+ case XML_thaiAlphaParenBoth:
+ case XML_thaiNumParenBoth:
+ mnNumberingType <<= NumberingType::CHARS_THAI;
+ setSuffixParenBoth();
+ break;
+ case XML_thaiAlphaParenR:
+ case XML_thaiNumParenR:
+ mnNumberingType <<= NumberingType::CHARS_THAI;
+ setSuffixParenRight();
+ break;
+ case XML_thaiAlphaPeriod:
+ case XML_thaiNumPeriod:
+ mnNumberingType <<= NumberingType::CHARS_THAI;
+ setSuffixPeriod();
+ break;
+ }
+}
+
+void BulletList::setBulletSize(sal_Int16 nSize)
+{
+ mnSize <<= nSize;
+}
+
+
+void BulletList::setFontSize(sal_Int16 nSize)
+{
+ mnFontSize <<= nSize;
+}
+
+void BulletList::apply( const BulletList& rSource )
+{
+ if ( rSource.maBulletColorPtr->isUsed() )
+ maBulletColorPtr = rSource.maBulletColorPtr;
+ if ( rSource.mbBulletColorFollowText.hasValue() )
+ mbBulletColorFollowText = rSource.mbBulletColorFollowText;
+ if ( rSource.mbBulletFontFollowText.hasValue() )
+ mbBulletFontFollowText = rSource.mbBulletFontFollowText;
+ if ( rSource.maBulletFont.is() )
+ maBulletFont = rSource.maBulletFont;
+ if ( rSource.msBulletChar.hasValue() )
+ msBulletChar = rSource.msBulletChar;
+ if ( rSource.mnStartAt.hasValue() )
+ mnStartAt = rSource.mnStartAt;
+ if ( rSource.mnNumberingType.hasValue() )
+ mnNumberingType = rSource.mnNumberingType;
+ if ( rSource.msNumberingPrefix.hasValue() )
+ msNumberingPrefix = rSource.msNumberingPrefix;
+ if ( rSource.msNumberingSuffix.hasValue() )
+ msNumberingSuffix = rSource.msNumberingSuffix;
+ if ( rSource.mnSize.hasValue() )
+ mnSize = rSource.mnSize;
+ if ( rSource.mnFontSize.hasValue() )
+ mnFontSize = rSource.mnFontSize;
+ if ( rSource.maStyleName.hasValue() )
+ maStyleName = rSource.maStyleName;
+}
+
+void BulletList::pushToPropMap( const ::oox::core::XmlFilterBase& rFilterBase, PropertyMap& rPropMap ) const
+{
+ if( msNumberingPrefix.hasValue() )
+ {
+// OSL_TRACE( "OOX: numb prefix found");
+ const rtl::OUString sPrefix( CREATE_OUSTRING( "Prefix" ) );
+ rPropMap[ sPrefix ] = msNumberingPrefix;
+ }
+ if( msNumberingSuffix.hasValue() )
+ {
+// OSL_TRACE( "OOX: numb suffix found");
+ const rtl::OUString sSuffix( CREATE_OUSTRING( "Suffix" ) );
+ rPropMap[ sSuffix ] = msNumberingSuffix;
+ }
+ if( mnStartAt.hasValue() )
+ {
+ const rtl::OUString sStartWith( CREATE_OUSTRING( "StartWith" ) );
+ rPropMap[ sStartWith ] = mnStartAt;
+ }
+ const rtl::OUString sAdjust( CREATE_OUSTRING( "Adjust" ) );
+ rPropMap[ sAdjust ] <<= HoriOrientation::LEFT;
+
+ if( mnNumberingType.hasValue() )
+ {
+ const rtl::OUString sNumberingType( CREATE_OUSTRING( "NumberingType" ) );
+ rPropMap[ sNumberingType ] = mnNumberingType;
+ }
+ if( maBulletFont.is() )
+ {
+ FontDescriptor aFontDesc;
+ sal_Int16 nFontSize = 0;
+ if( mnFontSize >>= nFontSize )
+ aFontDesc.Height = nFontSize;
+
+ // TODO move the to the TextFont struct.
+ sal_Int16 nPitch, nFamily;
+ aFontDesc.Name = maBulletFont.msTypeface;
+ GetFontPitch( maBulletFont.mnPitch, nPitch, nFamily);
+ aFontDesc.Pitch = nPitch;
+ aFontDesc.Family = nFamily;
+ const rtl::OUString sBulletFont( CREATE_OUSTRING( "BulletFont" ) );
+ rPropMap[ sBulletFont ] <<= aFontDesc;
+ const rtl::OUString sBulletFontName( CREATE_OUSTRING( "BulletFontName" ) );
+ rPropMap[ sBulletFontName ] <<= maBulletFont.msTypeface;
+ }
+ if ( msBulletChar.hasValue() )
+ {
+ const rtl::OUString sBulletChar( CREATE_OUSTRING( "BulletChar" ) );
+ rPropMap[ sBulletChar ] = msBulletChar;
+ }
+ if( mnSize.hasValue() )
+ {
+ const rtl::OUString sBulletRelSize( CREATE_OUSTRING( "BulletRelSize" ) );
+ rPropMap[ sBulletRelSize ] = mnSize;
+ }
+ if ( maStyleName.hasValue() )
+ {
+ const OUString sCharStyleName( CREATE_OUSTRING( "CharStyleName" ) );
+ rPropMap[ sCharStyleName ] <<= maStyleName;
+ }
+ if ( maBulletColorPtr->isUsed() )
+ {
+ const rtl::OUString sBulletColor( CREATE_OUSTRING( "BulletColor" ) );
+ rPropMap[ sBulletColor ] <<= maBulletColorPtr->getColor( rFilterBase );
+ }
+}
+
+TextParagraphProperties::TextParagraphProperties()
+: maTextCharacterPropertiesPtr( new TextCharacterProperties() )
+, mnLevel( 0 )
+{
+}
+TextParagraphProperties::~TextParagraphProperties()
+{
+}
+void TextParagraphProperties::apply( const TextParagraphPropertiesPtr& rSourceTextParagraphProperties )
+{
+ maTextParagraphPropertyMap.insert( rSourceTextParagraphProperties->maTextParagraphPropertyMap.begin(), rSourceTextParagraphProperties->maTextParagraphPropertyMap.end() );
+ maBulletList.apply( rSourceTextParagraphProperties->maBulletList );
+ maTextCharacterPropertiesPtr->apply( rSourceTextParagraphProperties->maTextCharacterPropertiesPtr );
+ if ( rSourceTextParagraphProperties->maParaTopMargin.bHasValue )
+ maParaTopMargin = rSourceTextParagraphProperties->maParaTopMargin;
+ if ( rSourceTextParagraphProperties->maParaBottomMargin.bHasValue )
+ maParaBottomMargin = rSourceTextParagraphProperties->maParaBottomMargin;
+}
+void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase& rFilterBase,
+ const Reference < XPropertySet >& xPropSet, PropertyMap& rioBulletMap, sal_Bool bApplyBulletMap ) const
+{
+ PropertySet aPropSet( xPropSet );
+ Sequence< OUString > aNames;
+ Sequence< Any > aValues;
+
+// maTextParagraphPropertyMap.dump_debug("TextParagraph paragraph props");
+ maTextParagraphPropertyMap.makeSequence( aNames, aValues );
+ aPropSet.setProperties( aNames, aValues );
+
+ maTextCharacterPropertiesPtr->pushToPropSet( rFilterBase, aPropSet.getXPropertySet() );
+ maBulletList.pushToPropMap( rFilterBase, rioBulletMap );
+
+ if ( maParaTopMargin.bHasValue )
+ {
+ const OUString sParaTopMargin( CREATE_OUSTRING( "ParaTopMargin" ) );
+ //OSL_TRACE( "OOX: ParaTopMargin unit = %d, value = %d", maParaTopMargin.nUnit, maParaTopMargin.nValue );
+ xPropSet->setPropertyValue( sParaTopMargin, Any( maParaTopMargin.toMargin( getCharacterSize( 18 ) ) ) );
+ }
+ if ( maParaBottomMargin.bHasValue )
+ {
+ const OUString sParaBottomMargin( CREATE_OUSTRING( "ParaBottomMargin" ) );
+ //OSL_TRACE( "OOX: ParaBottomMargin unit = %d, value = %d", maParaBottomMargin.nUnit, maParaBottomMargin.nValue );
+ xPropSet->setPropertyValue( sParaBottomMargin, Any( maParaBottomMargin.toMargin( getCharacterSize( 18 ) ) ) );
+ }
+ if ( bApplyBulletMap )
+ {
+ Any aValue;
+ Reference< XIndexReplace > xNumRule;
+ const rtl::OUString sNumberingRules( OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "NumberingRules" ) ) );
+ aValue = xPropSet->getPropertyValue( sNumberingRules );
+ aValue >>= xNumRule;
+
+ OSL_ENSURE( xNumRule.is(), "can't get Numbering rules");
+ if( xNumRule.is() )
+ {
+// OSL_TRACE("OOX: BulletList for level %d", getLevel());
+// pProps->getBulletListPropertyMap().dump_debug();
+ Sequence< PropertyValue > aBulletPropSeq;
+ rioBulletMap.makeSequence( aBulletPropSeq );
+ if( aBulletPropSeq.hasElements() )
+ {
+// OSL_TRACE("OOX: bullet props inserted at level %d", getLevel());
+ xNumRule->replaceByIndex( getLevel(), makeAny( aBulletPropSeq ) );
+ }
+ xPropSet->setPropertyValue( sNumberingRules, makeAny( xNumRule ) );
+ }
+ }
+}
+float TextParagraphProperties::getCharacterSize( float fValue ) const
+{
+ if ( maTextCharacterPropertiesPtr.get() )
+ fValue = maTextCharacterPropertiesPtr->getCharacterSize( fValue );
+ return fValue;
+}
+
+} }
diff --git a/oox/source/drawingml/textparagraphpropertiescontext.cxx b/oox/source/drawingml/textparagraphpropertiescontext.cxx
new file mode 100644
index 000000000000..65bd19d22ea7
--- /dev/null
+++ b/oox/source/drawingml/textparagraphpropertiescontext.cxx
@@ -0,0 +1,306 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: textparagraphpropertiescontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:52 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/textparagraphpropertiescontext.hxx"
+
+#include <com/sun/star/text/WritingMode.hpp>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+
+#include "oox/drawingml/colorchoicecontext.hxx"
+#include "oox/drawingml/textcharacterpropertiescontext.hxx"
+#include "oox/drawingml/drawingmltypes.hxx"
+#include "oox/helper/attributelist.hxx"
+#include "oox/core/namespaces.hxx"
+#include "textspacingcontext.hxx"
+#include "textfontcontext.hxx"
+#include "texttabstoplistcontext.hxx"
+#include "tokens.hxx"
+
+using ::rtl::OUString;
+using namespace ::oox::core;
+using ::com::sun::star::awt::FontDescriptor;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+using namespace ::com::sun::star::style;
+using namespace ::com::sun::star::text;
+
+namespace oox { namespace drawingml {
+
+// CT_TextParagraphProperties
+TextParagraphPropertiesContext::TextParagraphPropertiesContext( const ::oox::core::ContextRef& xParent,
+ const Reference< XFastAttributeList >& xAttribs,
+ oox::drawingml::TextParagraphProperties& rTextParagraphProperties )
+: Context( xParent->getHandler() )
+, mrTextParagraphProperties( rTextParagraphProperties )
+, mrSpaceBefore( rTextParagraphProperties.getParaTopMargin() )
+, mrSpaceAfter( rTextParagraphProperties.getParaBottomMargin() )
+, mrBulletList( rTextParagraphProperties.getBulletList() )
+{
+ OUString sValue;
+ AttributeList attribs( xAttribs );
+
+ PropertyMap& rPropertyMap( mrTextParagraphProperties.getTextParagraphPropertyMap() );
+
+ // ST_TextAlignType
+ if ( xAttribs->hasAttribute( XML_algn ) )
+ {
+ sal_Int32 nAlign = xAttribs->getOptionalValueToken( XML_algn, XML_l );
+ const OUString sParaAdjust( CREATE_OUSTRING( "ParaAdjust" ) );
+ rPropertyMap[ sParaAdjust ] <<= GetParaAdjust( nAlign );
+ }
+// OSL_TRACE( "OOX: para adjust %d", GetParaAdjust( nAlign ));
+ // TODO see to do the same with RubyAdjust
+
+ // ST_Coordinate32
+// sValue = xAttribs->getOptionalValue( XML_defTabSz ); SJ: we need to be able to set the default tab size for each text object,
+// this is possible at the moment only for the whole document.
+// sal_Int32 nDefTabSize = ( sValue.getLength() == 0 ? 0 : GetCoordinate( sValue ) );
+ // TODO
+
+// bool bEaLineBrk = attribs.getBool( XML_eaLnBrk, true );
+ if ( xAttribs->hasAttribute( XML_latinLnBrk ) )
+ {
+ bool bLatinLineBrk = attribs.getBool( XML_latinLnBrk, true );
+ const OUString sParaIsHyphenation( CREATE_OUSTRING( "ParaIsHyphenation" ) );
+ rPropertyMap[ sParaIsHyphenation ] <<= bLatinLineBrk;
+ }
+ // TODO see what to do with Asian hyphenation
+
+ // ST_TextFontAlignType
+ // TODO
+// sal_Int32 nFontAlign = xAttribs->getOptionalValueToken( XML_fontAlgn, XML_base );
+
+ if ( xAttribs->hasAttribute( XML_hangingPunct ) )
+ {
+ bool bHangingPunct = attribs.getBool( XML_hangingPunct, false );
+ const OUString sParaIsHangingPunctuation( CREATE_OUSTRING( "ParaIsHangingPunctuation" ) );
+ rPropertyMap[ sParaIsHangingPunctuation ] <<= bHangingPunct;
+ }
+
+ // ST_Coordinate
+ if ( xAttribs->hasAttribute( XML_indent ) )
+ {
+ sValue = xAttribs->getOptionalValue( XML_indent );
+ const OUString sParaFirstLineIndent( CREATE_OUSTRING( "ParaFirstLineIndent" ) );
+ rPropertyMap[ sParaFirstLineIndent ] <<= ( sValue.getLength() == 0 ? 0 : GetCoordinate( sValue ) );
+ }
+
+ // ST_TextIndentLevelType
+ // -1 is an invalid value and denote the lack of level
+ sal_Int32 nLevel = attribs.getInteger( XML_lvl, 0 );
+ if( nLevel > 8 || nLevel < 0 )
+ {
+ nLevel = 0;
+ }
+
+ mrTextParagraphProperties.setLevel( static_cast< sal_Int16 >( nLevel ) );
+
+ char name[] = "Outline X";
+ name[8] = static_cast<char>( '1' + nLevel );
+ const OUString sStyleNameValue( rtl::OUString::createFromAscii( name ) );
+ mrBulletList.setStyleName( sStyleNameValue );
+
+ // ST_TextMargin
+ // ParaLeftMargin
+ if ( xAttribs->hasAttribute( XML_marL ) )
+ {
+ sValue = xAttribs->getOptionalValue( XML_marL );
+ sal_Int32 nMarL = ( sValue.getLength() == 0 ? 0 : GetCoordinate( sValue ) );
+ const OUString sParaLeftMargin( CREATE_OUSTRING( "ParaLeftMargin" ) );
+ rPropertyMap[ sParaLeftMargin ] <<= nMarL;
+ }
+
+ // ParaRightMargin
+ if ( xAttribs->hasAttribute( XML_marR ) )
+ {
+ sValue = xAttribs->getOptionalValue( XML_marR );
+ sal_Int32 nMarR = ( sValue.getLength() == 0 ? 0 : GetCoordinate( sValue ) );
+ const OUString sParaRightMargin( CREATE_OUSTRING( "ParaRightMargin" ) );
+ rPropertyMap[ sParaRightMargin ] <<= nMarR;
+ }
+
+ if ( xAttribs->hasAttribute( XML_rtl ) )
+ {
+ bool bRtl = attribs.getBool( XML_rtl, false );
+ const OUString sTextWritingMode( CREATE_OUSTRING( "TextWritingMode" ) );
+ rPropertyMap[ sTextWritingMode ] <<= ( bRtl ? WritingMode_RL_TB : WritingMode_LR_TB );
+ }
+}
+
+
+
+TextParagraphPropertiesContext::~TextParagraphPropertiesContext()
+{
+ PropertyMap& rPropertyMap( mrTextParagraphProperties.getTextParagraphPropertyMap() );
+ if ( maLineSpacing.bHasValue )
+ {
+ const OUString sParaLineSpacing( CREATE_OUSTRING( "ParaLineSpacing" ) );
+ //OSL_TRACE( "OOX: ParaLineSpacing unit = %d, value = %d", maLineSpacing.nUnit, maLineSpacing.nValue );
+ rPropertyMap[ sParaLineSpacing ] <<= maLineSpacing.toLineSpacing();
+ }
+ ::std::list< TabStop >::size_type nTabCount = maTabList.size();
+ if( nTabCount != 0 )
+ {
+ Sequence< TabStop > aSeq( nTabCount );
+ TabStop * aArray = aSeq.getArray();
+ OSL_ENSURE( aArray != NULL, "sequence array is NULL" );
+ ::std::copy( maTabList.begin(), maTabList.end(), aArray );
+ const OUString sParaTabStops( CREATE_OUSTRING( "ParaTabStops" ) );
+ rPropertyMap[ sParaTabStops ] <<= aSeq;
+ }
+ if( mrBulletList.is() )
+ {
+ const rtl::OUString sIsNumbering( CREATE_OUSTRING( "IsNumbering" ) );
+ rPropertyMap[ sIsNumbering ] <<= sal_True;
+ }
+ sal_Int16 nLevel = mrTextParagraphProperties.getLevel();
+// OSL_TRACE("OOX: numbering level = %d", nLevel );
+ const OUString sNumberingLevel( CREATE_OUSTRING( "NumberingLevel" ) );
+ rPropertyMap[ sNumberingLevel ] <<= (sal_Int16)nLevel;
+ sal_Bool bTmp = sal_True;
+ const OUString sNumberingIsNumber( CREATE_OUSTRING( "NumberingIsNumber" ) );
+ rPropertyMap[ sNumberingIsNumber ] <<= bTmp;
+}
+
+// --------------------------------------------------------------------
+
+void TextParagraphPropertiesContext::endFastElement( sal_Int32 ) throw (SAXException, RuntimeException)
+{
+}
+
+
+
+// --------------------------------------------------------------------
+
+Reference< XFastContextHandler > TextParagraphPropertiesContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& rXAttributes ) throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_lnSpc: // CT_TextSpacing
+ xRet.set( new TextSpacingContext( getHandler(), maLineSpacing ) );
+ break;
+ case NMSP_DRAWINGML|XML_spcBef: // CT_TextSpacing
+ xRet.set( new TextSpacingContext( getHandler(), mrSpaceBefore ) );
+ break;
+ case NMSP_DRAWINGML|XML_spcAft: // CT_TextSpacing
+ xRet.set( new TextSpacingContext( getHandler(), mrSpaceAfter ) );
+ break;
+
+ // EG_TextBulletColor
+ case NMSP_DRAWINGML|XML_buClrTx: // CT_TextBulletColorFollowText ???
+ mrBulletList.mbBulletColorFollowText <<= sal_True;
+ break;
+ case NMSP_DRAWINGML|XML_buClr: // CT_Color
+ xRet.set( new colorChoiceContext( getHandler(), *mrBulletList.maBulletColorPtr.get() ) );
+ break;
+
+ // EG_TextBulletSize
+ case NMSP_DRAWINGML|XML_buSzTx: // CT_TextBulletSizeFollowText
+ mrBulletList.setBulletSize(100);
+ break;
+ case NMSP_DRAWINGML|XML_buSzPct: // CT_TextBulletSizePercent
+ mrBulletList.setBulletSize( static_cast<sal_Int16>( GetPercent( rXAttributes->getOptionalValue( XML_val ) ) / 1000 ) );
+ break;
+ case NMSP_DRAWINGML|XML_buSzPts: // CT_TextBulletSizePoint
+ mrBulletList.setBulletSize(0);
+ mrBulletList.setFontSize( static_cast<sal_Int16>(GetTextSize( rXAttributes->getOptionalValue( XML_val ) ) ) );
+ break;
+
+ // EG_TextBulletTypeface
+ case NMSP_DRAWINGML|XML_buFontTx: // CT_TextBulletTypefaceFollowText
+ mrBulletList.mbBulletFontFollowText <<= sal_True;
+ break;
+ case NMSP_DRAWINGML|XML_buFont: // CT_TextFont
+ xRet.set( new TextFontContext( getHandler(), aElementToken, rXAttributes,
+ mrBulletList.maBulletFont ) );
+ break;
+
+ // EG_TextBullet
+ case NMSP_DRAWINGML|XML_buNone: // CT_TextNoBullet
+ mrBulletList.setNone();
+ break;
+ case NMSP_DRAWINGML|XML_buAutoNum: // CT_TextAutonumberBullet
+ {
+ AttributeList attribs( rXAttributes );
+ try {
+ sal_Int32 nType = rXAttributes->getValueToken( XML_type );
+ sal_Int32 nStartAt = attribs.getInteger( XML_startAt, 1 );
+ if( nStartAt > 32767 )
+ {
+ nStartAt = 32767;
+ }
+ else if( nStartAt < 1 )
+ {
+ nStartAt = 1;
+ }
+ mrBulletList.setStartAt( nStartAt );
+ mrBulletList.setType( nType );
+ }
+ catch(SAXException& /* e */ )
+ {
+ OSL_TRACE("OOX: SAXException in XML_buAutoNum");
+ }
+ break;
+ }
+ case NMSP_DRAWINGML|XML_buChar: // CT_TextCharBullet
+ try {
+ mrBulletList.setBulletChar( rXAttributes->getValue( XML_char ) );
+ }
+ catch(SAXException& /* e */)
+ {
+ OSL_TRACE("OOX: SAXException in XML_buChar");
+ }
+ break;
+ case NMSP_DRAWINGML|XML_buBlip: // CT_TextBlipBullet
+ // TODO
+ break;
+
+ case NMSP_DRAWINGML|XML_tabLst: // CT_TextTabStopList
+ xRet.set( new TextTabStopListContext( this, maTabList ) );
+ break;
+ case NMSP_DRAWINGML|XML_defRPr: // CT_TextCharacterProperties
+ xRet.set( new TextCharacterPropertiesContext( this, rXAttributes, *(mrTextParagraphProperties.getTextCharacterProperties().get()) ) );
+ break;
+ }
+ if ( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+}
+
+// --------------------------------------------------------------------
+
+} }
+
diff --git a/oox/source/drawingml/textrun.cxx b/oox/source/drawingml/textrun.cxx
new file mode 100644
index 000000000000..ed3b362014b7
--- /dev/null
+++ b/oox/source/drawingml/textrun.cxx
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: textrun.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:52 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/textrun.hxx"
+
+#include <rtl/ustring.hxx>
+
+#include <com/sun/star/text/ControlCharacter.hpp>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/text/XTextField.hpp>
+
+#include "oox/helper/helper.hxx"
+
+using ::rtl::OUString;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::lang;
+
+namespace oox { namespace drawingml {
+
+ TextRun::TextRun()
+ : mbIsLineBreak( false )
+ , maTextCharacterPropertiesPtr( new TextCharacterProperties() )
+ {
+ }
+
+
+ TextRun::~TextRun()
+ {
+ }
+
+ void TextRun::insertAt( const ::oox::core::XmlFilterBase& rFilterBase, const Reference < XText > & xText, const Reference < XTextCursor > &xAt,
+ const Reference < XModel > & xModel, const TextCharacterPropertiesPtr& rTextCharacterStyle )
+ {
+ try {
+ Reference< XTextRange > xStart( xAt, UNO_QUERY );
+
+ Reference< XPropertySet > xProps( xStart, UNO_QUERY);
+ if ( rTextCharacterStyle.get() )
+ rTextCharacterStyle->pushToPropSet( rFilterBase, xProps );
+
+ maTextCharacterPropertiesPtr->pushToPropSet( rFilterBase, xProps );
+
+ if( maTextCharacterPropertiesPtr->getHyperlinkPropertyMap().empty() )
+ {
+ if( mbIsLineBreak )
+ {
+ OSL_TRACE( "OOX: TextRun::insertAt() insert line break" );
+ xText->insertControlCharacter( xStart, ControlCharacter::LINE_BREAK, sal_False );
+ }
+ else
+ {
+ xText->insertString( xStart, text(), sal_False );
+ }
+ }
+ else
+ {
+ OSL_TRACE( "OOX: URL field" );
+ Reference< XMultiServiceFactory > xFactory( xModel, UNO_QUERY );
+ Reference< XTextField > xField( xFactory->createInstance( CREATE_OUSTRING( "com.sun.star.text.TextField.URL" ) ), UNO_QUERY );
+ if( xField.is() )
+ {
+ const rtl::OUString sRepresentation( OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "Representation" ) ) );
+ maTextCharacterPropertiesPtr->getHyperlinkPropertyMap()[ sRepresentation ] <<= text();
+
+ Reference< XPropertySet > xFieldProps( xField, UNO_QUERY);
+ maTextCharacterPropertiesPtr->pushToUrlFieldPropSet( xFieldProps );
+ Reference< XTextContent > xContent( xField, UNO_QUERY);
+ xText->insertTextContent( xStart, xContent, sal_False );
+ }
+ else
+ {
+ OSL_TRACE( "OOX: URL field couldn't be created" );
+ xText->insertString( xStart, text(), sal_False );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_TRACE("OOX: TextRun::insertAt() exception");
+ }
+ }
+
+
+} }
diff --git a/oox/source/drawingml/textspacingcontext.cxx b/oox/source/drawingml/textspacingcontext.cxx
new file mode 100644
index 000000000000..e222a8d27a8d
--- /dev/null
+++ b/oox/source/drawingml/textspacingcontext.cxx
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: textspacingcontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:52 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2007 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/drawingmltypes.hxx"
+#include "oox/drawingml/textspacing.hxx"
+#include "oox/core/namespaces.hxx"
+#include "textspacingcontext.hxx"
+#include "tokens.hxx"
+
+
+using namespace ::oox::core;
+using namespace ::com::sun::star::xml::sax;
+using namespace ::com::sun::star::uno;
+
+
+namespace oox { namespace drawingml {
+
+ TextSpacingContext::TextSpacingContext( const FragmentHandlerRef& xHandler,
+ TextSpacing & aSpacing )
+ : Context( xHandler )
+ , maSpacing( aSpacing )
+ {
+ maSpacing.bHasValue = sal_True;
+ }
+
+ void TextSpacingContext::endFastElement( sal_Int32 /*nElement*/ )
+ throw ( SAXException, RuntimeException )
+ {
+ }
+
+ Reference< XFastContextHandler > TextSpacingContext::createFastChildContext( ::sal_Int32 aElement,
+ const Reference< XFastAttributeList >& xAttribs )
+ throw ( SAXException, RuntimeException )
+ {
+ Reference< XFastContextHandler > xRet;
+ switch( aElement )
+ {
+ case NMSP_DRAWINGML|XML_spcPct:
+ maSpacing.nUnit = TextSpacing::PERCENT;
+ maSpacing.nValue = GetPercent( xAttribs->getValue( XML_val ) );
+ break;
+ case NMSP_DRAWINGML|XML_spcPts:
+ maSpacing.nUnit = TextSpacing::POINTS;
+ maSpacing.nValue = GetTextSpacingPoint( xAttribs->getValue( XML_val ) );
+ break;
+ default:
+ break;
+ }
+ if ( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+ }
+
+
+} }
diff --git a/oox/source/drawingml/textspacingcontext.hxx b/oox/source/drawingml/textspacingcontext.hxx
new file mode 100644
index 000000000000..615e0541dbdb
--- /dev/null
+++ b/oox/source/drawingml/textspacingcontext.hxx
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: textspacingcontext.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:52 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2007 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+
+
+#ifndef OOX_DRAWINGML_TEXTSPACINGCONTEXT_HXX
+#define OOX_DRAWINGML_TEXTSPACINGCONTEXT_HXX
+
+#include <rtl/ustring.hxx>
+
+#include "oox/core/context.hxx"
+
+namespace oox { namespace drawingml {
+
+class TextSpacing;
+
+class TextSpacingContext : public ::oox::core::Context
+{
+public:
+ TextSpacingContext( const ::oox::core::FragmentHandlerRef& xHandler, TextSpacing & aSpacing );
+
+ virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) 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:
+ TextSpacing& maSpacing;
+};
+
+
+} }
+
+
+
+
+#endif
+
+
diff --git a/oox/source/drawingml/texttabstoplistcontext.cxx b/oox/source/drawingml/texttabstoplistcontext.cxx
new file mode 100644
index 000000000000..54f6bed012b8
--- /dev/null
+++ b/oox/source/drawingml/texttabstoplistcontext.cxx
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: texttabstoplistcontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:52 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include <list>
+#include <algorithm>
+
+#include <rtl/ustring.hxx>
+
+#include "oox/core/namespaces.hxx"
+#include "oox/drawingml/drawingmltypes.hxx"
+#include "texttabstoplistcontext.hxx"
+#include "tokens.hxx"
+
+using ::rtl::OUString;
+using namespace ::oox::core;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::style;
+using namespace ::com::sun::star::xml::sax;
+
+namespace oox { namespace drawingml {
+
+ TextTabStopListContext::TextTabStopListContext( const ContextRef& xParent,
+ std::list< TabStop > & aTabList )
+ : Context( *xParent )
+ , maTabList( aTabList )
+ {
+ }
+
+ TextTabStopListContext::~TextTabStopListContext()
+ {
+ }
+
+ void SAL_CALL TextTabStopListContext::endFastElement( ::sal_Int32 /*Element*/ )
+ throw ( SAXException, RuntimeException)
+ {
+ }
+
+
+ Reference< ::XFastContextHandler > TextTabStopListContext::createFastChildContext( ::sal_Int32 aElement,
+ const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
+ {
+ Reference< XFastContextHandler > xRet;
+ switch( aElement )
+ {
+ case NMSP_DRAWINGML|XML_tab:
+ {
+ OUString sValue;
+ TabStop aTabStop;
+ sValue = xAttribs->getOptionalValue( XML_pos );
+ if( sValue.getLength() )
+ {
+ aTabStop.Position = GetCoordinate( sValue );
+ }
+ sal_Int32 aToken = xAttribs->getOptionalValueToken( XML_algn, 0 );
+ if( aToken != 0 )
+ {
+ aTabStop.Alignment = GetTabAlign( aToken );
+ }
+ maTabList.push_back(aTabStop);
+ break;
+ }
+ default:
+ break;
+ }
+ if ( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+ }
+
+
+} }
+
+
diff --git a/oox/source/drawingml/texttabstoplistcontext.hxx b/oox/source/drawingml/texttabstoplistcontext.hxx
new file mode 100644
index 000000000000..e0faed8f0f88
--- /dev/null
+++ b/oox/source/drawingml/texttabstoplistcontext.hxx
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: texttabstoplistcontext.hxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:52 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2007 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#ifndef OOX_DRAWINGML_TEXTTABSTOPLISTCONTEXT_HXX
+#define OOX_DRAWINGML_TEXTTABSTOPLISTCONTEXT_HXX
+
+#include <list>
+
+#include <com/sun/star/style/TabStop.hpp>
+
+
+#ifndef OOX_CORE_CONTEXT_HXX
+#include "oox/core/context.hxx"
+#endif
+
+namespace oox { namespace drawingml {
+
+ class TextTabStopListContext : public ::oox::core::Context
+ {
+ public:
+ TextTabStopListContext( const ::oox::core::ContextRef& xParent,
+ ::std::list< ::com::sun::star::style::TabStop > & aTabList );
+ ~TextTabStopListContext();
+
+ virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) 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);
+
+protected:
+ ::std::list< ::com::sun::star::style::TabStop > & maTabList;
+ };
+
+
+} }
+
+
+#endif
+
diff --git a/oox/source/drawingml/theme.cxx b/oox/source/drawingml/theme.cxx
new file mode 100644
index 000000000000..c9b776b941c6
--- /dev/null
+++ b/oox/source/drawingml/theme.cxx
@@ -0,0 +1,55 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: theme.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:52 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/shape.hxx"
+#include "oox/core/namespaces.hxx"
+#include "tokens.hxx"
+
+using namespace ::oox::core;
+
+namespace oox { namespace drawingml {
+
+Theme::Theme()
+: mpClrSchemePtr( new ClrScheme )
+, mpspDefPtr( new Shape )
+, mplnDefPtr( new Shape )
+, mptxDefPtr( new Shape )
+{
+}
+Theme::~Theme()
+{
+}
+
+} }
diff --git a/oox/source/drawingml/themeelementscontext.cxx b/oox/source/drawingml/themeelementscontext.cxx
new file mode 100644
index 000000000000..503e6d4e9514
--- /dev/null
+++ b/oox/source/drawingml/themeelementscontext.cxx
@@ -0,0 +1,234 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: themeelementscontext.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:52 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "oox/drawingml/themeelementscontext.hxx"
+#include "oox/drawingml/clrschemecontext.hxx"
+#include "oox/drawingml/linepropertiescontext.hxx"
+#include "oox/drawingml/fillpropertiesgroupcontext.hxx"
+#include "oox/core/namespaces.hxx"
+#include "tokens.hxx"
+
+using rtl::OUString;
+using namespace ::oox::core;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+
+namespace oox { namespace drawingml {
+
+class fillStyleListContext : public ::oox::core::Context
+{
+ std::vector< oox::drawingml::FillPropertiesPtr >& mrFillStyleList;
+public:
+ fillStyleListContext( const ::oox::core::FragmentHandlerRef& xHandler, std::vector< oox::drawingml::FillPropertiesPtr >& rFillStyleList );
+ 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);
+};
+fillStyleListContext::fillStyleListContext( const FragmentHandlerRef& xHandler, std::vector< oox::drawingml::FillPropertiesPtr >& rFillStyleList )
+: oox::core::Context( xHandler )
+, mrFillStyleList( rFillStyleList )
+{
+}
+Reference< XFastContextHandler > fillStyleListContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_noFill:
+ case NMSP_DRAWINGML|XML_solidFill:
+ case NMSP_DRAWINGML|XML_gradFill:
+ case NMSP_DRAWINGML|XML_blipFill:
+ case NMSP_DRAWINGML|XML_pattFill:
+ case NMSP_DRAWINGML|XML_grpFill:
+ {
+ mrFillStyleList.push_back( FillPropertiesPtr( new oox::drawingml::FillProperties ) );
+ FillPropertiesGroupContext::StaticCreateContext( getHandler(), aElementToken, xAttribs, *(mrFillStyleList.back().get()) );
+ }
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+}
+
+// ---------------------------------------------------------------------
+
+class lineStyleListContext : public ::oox::core::Context
+{
+ std::vector< oox::drawingml::LinePropertiesPtr >& mrLineStyleList;
+public:
+ lineStyleListContext( const ::oox::core::FragmentHandlerRef& xHandler, std::vector< oox::drawingml::LinePropertiesPtr >& rLineStyleList );
+ 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);
+};
+lineStyleListContext::lineStyleListContext( const FragmentHandlerRef& xHandler, std::vector< oox::drawingml::LinePropertiesPtr >& rLineStyleList )
+: oox::core::Context( xHandler )
+, mrLineStyleList( rLineStyleList )
+{
+}
+Reference< XFastContextHandler > lineStyleListContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs )
+ throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_ln:
+ {
+ mrLineStyleList.push_back( LinePropertiesPtr( new oox::drawingml::LineProperties ) );
+ xRet.set( new LinePropertiesContext( getHandler(), xAttribs, *(mrLineStyleList.back().get()) ) );
+ }
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+}
+
+// ---------------------------------------------------------------------
+
+class effectStyleListContext : public ::oox::core::Context
+{
+ std::vector< PropertyMap >& mrEffectStyleList;
+public:
+ effectStyleListContext( const ::oox::core::FragmentHandlerRef& xHandler, std::vector< PropertyMap >& rEffectStyleList );
+ 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);
+};
+effectStyleListContext::effectStyleListContext( const FragmentHandlerRef& xHandler, std::vector< PropertyMap >& rEffectStyleList )
+: oox::core::Context( xHandler )
+, mrEffectStyleList( rEffectStyleList )
+{
+}
+Reference< XFastContextHandler > effectStyleListContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& /* xAttribs */ ) throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_effectStyle:
+ {
+ mrEffectStyleList.push_back( PropertyMap() );
+ // todo: last effect list entry needs to be filled/
+ break;
+ }
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+}
+
+// ---------------------------------------------------------------------
+
+class bgFillStyleListContext : public ::oox::core::Context
+{
+ std::vector< oox::drawingml::FillPropertiesPtr >& mrBgFillStyleList;
+public:
+ bgFillStyleListContext( const ::oox::core::FragmentHandlerRef& xHandler, std::vector< oox::drawingml::FillPropertiesPtr >& rBgFillStyleList );
+ 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);
+};
+bgFillStyleListContext::bgFillStyleListContext( const FragmentHandlerRef& xHandler, std::vector< oox::drawingml::FillPropertiesPtr >& rBgFillStyleList )
+: oox::core::Context( xHandler )
+, mrBgFillStyleList( rBgFillStyleList )
+{
+}
+Reference< XFastContextHandler > bgFillStyleListContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
+{
+ Reference< XFastContextHandler > xRet;
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_noFill:
+ case NMSP_DRAWINGML|XML_solidFill:
+ case NMSP_DRAWINGML|XML_gradFill:
+ case NMSP_DRAWINGML|XML_blipFill:
+ case NMSP_DRAWINGML|XML_pattFill:
+ case NMSP_DRAWINGML|XML_grpFill:
+ {
+ mrBgFillStyleList.push_back( FillPropertiesPtr( new oox::drawingml::FillProperties ) );
+ FillPropertiesGroupContext::StaticCreateContext( getHandler(), aElementToken, xAttribs, *(mrBgFillStyleList.back().get()) );
+ }
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+}
+
+// ---------------------------------------------------------------------
+
+themeElementsContext::themeElementsContext( const ::oox::core::FragmentHandlerRef& xHandler, ::oox::drawingml::Theme& rTheme )
+: Context( xHandler )
+, mrTheme( rTheme )
+{
+}
+
+Reference< XFastContextHandler > themeElementsContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
+{
+ // CT_BaseStyles
+ Reference< XFastContextHandler > xRet;
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_clrScheme: // CT_ColorScheme
+ {
+ xRet.set( new clrSchemeContext( getHandler(), mrTheme.getClrScheme() ) );
+ break;
+ }
+
+ case NMSP_DRAWINGML|XML_fontScheme: // CT_FontScheme
+ break;
+
+ case NMSP_DRAWINGML|XML_fmtScheme: // CT_StyleMatrix
+ mrTheme.getStyleName() = xAttribs->getOptionalValue( XML_name );
+ break;
+
+ case NMSP_DRAWINGML|XML_fillStyleLst: // CT_FillStyleList
+ xRet.set( new fillStyleListContext( getHandler(), mrTheme.getFillStyleList() ) );
+ break;
+ case NMSP_DRAWINGML|XML_lineStyleLst: // CT_LineStyleList
+ xRet.set( new lineStyleListContext( getHandler(), mrTheme.getLineStyleList() ) );
+ break;
+ case NMSP_DRAWINGML|XML_effectStyleLst: // CT_EffectStyleList
+ xRet.set( new effectStyleListContext( getHandler(), mrTheme.getEffectStyleList() ) );
+ break;
+ case NMSP_DRAWINGML|XML_bgFillStyleLst: // CT_BackgroundFillStyleList
+ xRet.set( new bgFillStyleListContext( getHandler(), mrTheme.getBgFillStyleList() ) );
+ break;
+
+ case NMSP_DRAWINGML|XML_extLst: // CT_OfficeArtExtensionList
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+}
+
+} }
diff --git a/oox/source/drawingml/themefragmenthandler.cxx b/oox/source/drawingml/themefragmenthandler.cxx
new file mode 100644
index 000000000000..bebda788d729
--- /dev/null
+++ b/oox/source/drawingml/themefragmenthandler.cxx
@@ -0,0 +1,108 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: themefragmenthandler.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: rt $ $Date: 2008-01-17 08:05:52 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "comphelper/anytostring.hxx"
+#include "cppuhelper/exc_hlp.hxx"
+
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+
+#include "oox/drawingml/themefragmenthandler.hxx"
+#include "oox/drawingml/objectdefaultcontext.hxx"
+#include "oox/drawingml/themeelementscontext.hxx"
+#include "oox/core/namespaces.hxx"
+#include "tokens.hxx"
+
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+using namespace ::oox::core;
+using namespace ::oox::drawingml;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::sax;
+using namespace ::com::sun::star::container;
+
+namespace oox { namespace drawingml {
+
+ThemeFragmentHandler::ThemeFragmentHandler( const XmlFilterRef& xFilter, const OUString& rFragmentPath, Theme& rTheme )
+ throw()
+: FragmentHandler( xFilter, rFragmentPath )
+, mrTheme( rTheme )
+{
+}
+ThemeFragmentHandler::~ThemeFragmentHandler()
+ throw()
+{
+
+}
+Reference< XFastContextHandler > ThemeFragmentHandler::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& /*xAttribs */ )
+ throw (SAXException, RuntimeException)
+{
+ // CT_OfficeStyleSheet
+ Reference< XFastContextHandler > xRet;
+
+ switch( aElementToken )
+ {
+ case NMSP_DRAWINGML|XML_themeElements: // CT_BaseStyles
+ {
+ xRet.set( new themeElementsContext( this, mrTheme ) );
+ break;
+ }
+ case NMSP_DRAWINGML|XML_objectDefaults: // CT_ObjectStyleDefaults
+ {
+ xRet.set( new objectDefaultContext( this, mrTheme ) );
+ break;
+ }
+ case NMSP_DRAWINGML|XML_extraClrSchemeLst: // CT_ColorSchemeList
+ break;
+ case NMSP_DRAWINGML|XML_custClrLst: // CustomColorList
+ break;
+ case NMSP_DRAWINGML|XML_ext: // CT_OfficeArtExtension
+ break;
+ }
+ if( !xRet.is() )
+ xRet.set( this );
+ return xRet;
+}
+void SAL_CALL ThemeFragmentHandler::endDocument()
+ throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException)
+{
+}
+
+//--------------------------------------------------------------------------------------------------------------
+
+
+
+} }
+