summaryrefslogtreecommitdiff
path: root/oox/inc/oox/vml
diff options
context:
space:
mode:
Diffstat (limited to 'oox/inc/oox/vml')
-rw-r--r--oox/inc/oox/vml/vmldrawing.hxx179
-rw-r--r--oox/inc/oox/vml/vmldrawingfragment.hxx66
-rw-r--r--oox/inc/oox/vml/vmlformatting.hxx190
-rw-r--r--oox/inc/oox/vml/vmlinputstream.hxx69
-rw-r--r--oox/inc/oox/vml/vmlshape.hxx330
-rw-r--r--oox/inc/oox/vml/vmlshapecontainer.hxx139
-rw-r--r--oox/inc/oox/vml/vmlshapecontext.hxx148
7 files changed, 1121 insertions, 0 deletions
diff --git a/oox/inc/oox/vml/vmldrawing.hxx b/oox/inc/oox/vml/vmldrawing.hxx
new file mode 100644
index 000000000000..c2f8432dca6f
--- /dev/null
+++ b/oox/inc/oox/vml/vmldrawing.hxx
@@ -0,0 +1,179 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_VML_VMLDRAWING_HXX
+#define OOX_VML_VMLDRAWING_HXX
+
+#include <map>
+#include <memory>
+#include "oox/ole/oleobjecthelper.hxx"
+
+namespace com { namespace sun { namespace star {
+ namespace awt { struct Rectangle; }
+ namespace awt { class XControlModel; }
+ namespace drawing { class XDrawPage; }
+ namespace drawing { class XShape; }
+} } }
+
+namespace oox { namespace core { class XmlFilterBase; } }
+namespace oox { namespace ole { class EmbeddedForm; } }
+
+namespace oox {
+namespace vml {
+
+class ShapeBase;
+class ShapeContainer;
+struct ShapeClientData;
+
+// ============================================================================
+
+/** Enumerates different types of VML drawings. */
+enum DrawingType
+{
+ VMLDRAWING_WORD, /// Word: One shape per drawing.
+ VMLDRAWING_EXCEL, /// Excel: OLE objects are part of VML.
+ VMLDRAWING_POWERPOINT /// PowerPoint: OLE objects are part of DrawingML.
+};
+
+// ============================================================================
+
+/** Contains information about an OLE object embedded in a draw page. */
+struct OleObjectInfo : public ::oox::ole::OleObjectInfo
+{
+ ::rtl::OUString maShapeId; /// Shape identifier for shape lookup.
+ ::rtl::OUString maName; /// Programmatical name of the OLE object.
+ bool mbAutoLoad;
+ const bool mbDmlShape; /// True = DrawingML shape (PowerPoint), false = VML shape (Excel/Word).
+
+ explicit OleObjectInfo( bool bDmlShape = false );
+
+ /** Sets the string representation of the passed numeric shape identifier. */
+ void setShapeId( sal_Int32 nShapeId );
+};
+
+// ============================================================================
+
+/** Contains information about a form control embedded in a draw page. */
+struct ControlInfo
+{
+ ::rtl::OUString maShapeId; /// Shape identifier for shape lookup.
+ ::rtl::OUString maFragmentPath; /// Path to the fragment describing the form control properties.
+ ::rtl::OUString maName; /// Programmatical name of the form control.
+
+ explicit ControlInfo();
+
+ /** Sets the string representation of the passed numeric shape identifier. */
+ void setShapeId( sal_Int32 nShapeId );
+};
+
+// ============================================================================
+
+/** Represents the collection of VML shapes for a complete draw page. */
+class Drawing
+{
+public:
+ explicit Drawing(
+ ::oox::core::XmlFilterBase& rFilter,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& rxDrawPage,
+ DrawingType eType );
+
+ virtual ~Drawing();
+
+ /** Returns the filter object that imports/exports this VML drawing. */
+ inline ::oox::core::XmlFilterBase& getFilter() const { return mrFilter; }
+ /** Returns the application type containing the drawing. */
+ inline DrawingType getType() const { return meType; }
+ /** Returns read/write access to the container of shapes and templates. */
+ inline ShapeContainer& getShapes() { return *mxShapes; }
+ /** Returns read access to the container of shapes and templates. */
+ inline const ShapeContainer& getShapes() const { return *mxShapes; }
+ /** Returns the form object used to process ActiveX form controls. */
+ ::oox::ole::EmbeddedForm& getControlForm() const;
+
+ /** Registers the passed embedded OLE object. The related shape will then
+ load the OLE object data from the specified fragment. */
+ void registerOleObject( const OleObjectInfo& rOleObject );
+ /** Registers the passed embedded form control. The related shape will then
+ load the control properties from the specified fragment. */
+ void registerControl( const ControlInfo& rControl );
+
+ /** Final processing after import of the fragment. */
+ void finalizeFragmentImport();
+
+ /** Creates and inserts all UNO shapes into the passed container. The virtual
+ function notifyShapeInserted() will be called for each new shape. */
+ void convertAndInsert() const;
+
+ /** Returns the registered info structure for an OLE object, if extant. */
+ const OleObjectInfo* getOleObjectInfo( const ::rtl::OUString& rShapeId ) const;
+ /** Returns the registered info structure for a form control, if extant. */
+ const ControlInfo* getControlInfo( const ::rtl::OUString& rShapeId ) const;
+
+ /** Derived classes may disable conversion of specific shapes. */
+ virtual bool isShapeSupported( const ShapeBase& rShape ) const;
+
+ /** Derived classes may calculate the shape rectangle from a non-standard
+ anchor information string. */
+ virtual bool convertShapeClientAnchor(
+ ::com::sun::star::awt::Rectangle& orShapeRect,
+ const ::rtl::OUString& rShapeAnchor ) const;
+
+ /** Derived classes may convert additional form control properties from the
+ passed VML shape client data. */
+ virtual void convertControlClientData(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel,
+ const ShapeClientData& rClientData ) const;
+
+ /** Derived classes may want to know that a shape has been inserted. Will
+ be called from the convertAndInsert() implementation. */
+ virtual void notifyShapeInserted(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape,
+ const ::com::sun::star::awt::Rectangle& rShapeRect );
+
+private:
+ typedef ::std::auto_ptr< ::oox::ole::EmbeddedForm > EmbeddedFormPtr;
+ typedef ::std::auto_ptr< ShapeContainer > ShapeContainerPtr;
+ typedef ::std::map< ::rtl::OUString, OleObjectInfo > OleObjectInfoMap;
+ typedef ::std::map< ::rtl::OUString, ControlInfo > ControlInfoMap;
+
+ ::oox::core::XmlFilterBase& mrFilter; /// Filter object that imports/exports the VML drawing.
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >
+ mxDrawPage; /// UNO draw page used to insert the shapes.
+ mutable EmbeddedFormPtr mxCtrlForm; /// The control form used to process ActiveX controls.
+ ShapeContainerPtr mxShapes; /// All shapes and shape templates.
+ OleObjectInfoMap maOleObjects; /// Info about all embedded OLE objects, mapped by shape id.
+ ControlInfoMap maControls; /// Info about all embedded form controls, mapped by control name.
+ const DrawingType meType; /// Application type containing the drawing.
+};
+
+// ============================================================================
+
+} // namespace vml
+} // namespace oox
+
+#endif
+
diff --git a/oox/inc/oox/vml/vmldrawingfragment.hxx b/oox/inc/oox/vml/vmldrawingfragment.hxx
new file mode 100644
index 000000000000..e0ffcd9c5203
--- /dev/null
+++ b/oox/inc/oox/vml/vmldrawingfragment.hxx
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_VML_VMLDRAWINGFRAGMENT_HXX
+#define OOX_VML_VMLDRAWINGFRAGMENT_HXX
+
+#include "oox/core/fragmenthandler2.hxx"
+
+namespace oox {
+namespace vml {
+
+class Drawing;
+
+// ============================================================================
+
+class DrawingFragment : public ::oox::core::FragmentHandler2
+{
+public:
+ explicit DrawingFragment(
+ ::oox::core::XmlFilterBase& rFilter,
+ const ::rtl::OUString& rFragmentPath,
+ Drawing& rDrawing );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
+ openFragmentStream() const;
+
+ virtual ::oox::core::ContextHandlerRef
+ onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs );
+
+ virtual void finalizeImport();
+
+private:
+ Drawing& mrDrawing;
+};
+
+// ============================================================================
+
+} // namespace vml
+} // namespace oox
+
+#endif
+
diff --git a/oox/inc/oox/vml/vmlformatting.hxx b/oox/inc/oox/vml/vmlformatting.hxx
new file mode 100644
index 000000000000..db67d7a85af4
--- /dev/null
+++ b/oox/inc/oox/vml/vmlformatting.hxx
@@ -0,0 +1,190 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_VML_VMLFORMATTING_HXX
+#define OOX_VML_VMLFORMATTING_HXX
+
+#include "oox/helper/helper.hxx"
+
+namespace oox {
+ class GraphicHelper;
+ class ModelObjectHelper;
+ class PropertyMap;
+}
+
+namespace oox {
+namespace vml {
+
+// ============================================================================
+
+typedef ::std::pair< sal_Int32, sal_Int32 > Int32Pair;
+typedef ::std::pair< double, double > DoublePair;
+
+// ============================================================================
+
+class ConversionHelper
+{
+public:
+ /** Returns two values contained in rValue separated by cSep.
+ */
+ static bool separatePair(
+ ::rtl::OUString& orValue1, ::rtl::OUString& orValue2,
+ const ::rtl::OUString& rValue, sal_Unicode cSep );
+
+ /** Returns the boolean value from the passed string of a VML attribute.
+ Supported values: 'f', 't', 'false', 'true'. False for anything else.
+ */
+ static bool decodeBool( const ::rtl::OUString& rValue );
+
+ /** Converts the passed VML percentage measure string to a normalized
+ floating-point value.
+
+ @param rValue The VML percentage value. This is a floating-point value
+ with optional following '%' sign. If the '%' sign is missing, the
+ floating point value will be returned unmodified. If the '%' sign
+ is present, the value will be divided by 100.
+ */
+ static double decodePercent(
+ const ::rtl::OUString& rValue,
+ double fDefValue );
+
+ /** Converts the passed VML measure string to EMU (English Metric Units).
+
+ @param rGraphicHelper The graphic helper needed to perform pixel
+ conversion according to the current output device.
+
+ @param rValue The VML measure value. This is a floating-point value
+ with optional measure string following the value.
+
+ @param nRefValue Reference value needed for percentage measure.
+
+ @param bPixelX Set to true if the value is oriented horizontally (e.g.
+ X coordinates, widths). Set to false if the value is oriented
+ vertically (e.g. Y coordinates, heights). This is needed because
+ output devices may specify different width and height for a pixel.
+
+ @param bDefaultAsPixel Set to true if omitted measure unit means
+ pixel. Set to false if omitted measure unit means EMU.
+ */
+ static sal_Int32 decodeMeasureToEmu(
+ const GraphicHelper& rGraphicHelper,
+ const ::rtl::OUString& rValue,
+ sal_Int32 nRefValue,
+ bool bPixelX,
+ bool bDefaultAsPixel );
+
+ /** Converts the passed VML measure string to 1/100 mm.
+
+ @param rGraphicHelper See above.
+ @param rValue See above.
+ @param nRefValue See above.
+ @param bPixelX See above.
+ @param bDefaultAsPixel See above.
+ */
+ static sal_Int32 decodeMeasureToHmm(
+ const GraphicHelper& rGraphicHelper,
+ const ::rtl::OUString& rValue,
+ sal_Int32 nRefValue,
+ bool bPixelX,
+ bool bDefaultAsPixel );
+
+private:
+ ConversionHelper();
+ ~ConversionHelper();
+};
+
+// ============================================================================
+
+/** The stroke arrow model structure contains all properties for an line end arrow. */
+struct StrokeArrowModel
+{
+ OptValue< sal_Int32 > moArrowType;
+ OptValue< sal_Int32 > moArrowWidth;
+ OptValue< sal_Int32 > moArrowLength;
+
+ void assignUsed( const StrokeArrowModel& rSource );
+};
+
+// ============================================================================
+
+/** The stroke model structure contains all shape border properties. */
+struct StrokeModel
+{
+ OptValue< bool > moStroked; /// Shape border line on/off.
+ StrokeArrowModel maStartArrow; /// Start line arrow style.
+ StrokeArrowModel maEndArrow; /// End line arrow style.
+ OptValue< ::rtl::OUString > moColor; /// Solid line color.
+ OptValue< double > moOpacity; /// Solid line color opacity.
+ OptValue< ::rtl::OUString > moWeight; /// Line width.
+ OptValue< ::rtl::OUString > moDashStyle; /// Line dash (predefined or manually).
+ OptValue< sal_Int32 > moLineStyle; /// Line style (single, double, ...).
+ OptValue< sal_Int32 > moEndCap; /// Type of line end cap.
+ OptValue< sal_Int32 > moJoinStyle; /// Type of line join.
+
+ void assignUsed( const StrokeModel& rSource );
+
+ /** Writes the properties to the passed property map. */
+ void pushToPropMap(
+ PropertyMap& rPropMap,
+ ModelObjectHelper& rModelObjectHelper,
+ const GraphicHelper& rGraphicHelper ) const;
+};
+
+// ============================================================================
+
+/** The fill model structure contains all shape fill properties. */
+struct FillModel
+{
+ OptValue< bool > moFilled; /// Shape fill on/off.
+ OptValue< ::rtl::OUString > moColor; /// Solid fill color.
+ OptValue< double > moOpacity; /// Solid fill color opacity.
+ OptValue< ::rtl::OUString > moColor2; /// End color of gradient.
+ OptValue< double > moOpacity2; /// End color opycity of gradient.
+ OptValue< sal_Int32 > moType; /// Fill type.
+ OptValue< sal_Int32 > moAngle; /// Gradient rotation angle.
+ OptValue< double > moFocus; /// Linear gradient focus of second color.
+ OptValue< DoublePair > moFocusPos; /// Rectanguar gradient focus position of second color.
+ OptValue< DoublePair > moFocusSize; /// Rectanguar gradient focus size of second color.
+ OptValue< ::rtl::OUString > moBitmapPath; /// Path to fill bitmap fragment.
+ OptValue< bool > moRotate; /// True = rotate gradient/bitmap with shape.
+
+ void assignUsed( const FillModel& rSource );
+
+ /** Writes the properties to the passed property map. */
+ void pushToPropMap(
+ PropertyMap& rPropMap,
+ ModelObjectHelper& rModelObjectHelper,
+ const GraphicHelper& rGraphicHelper ) const;
+};
+
+// ============================================================================
+
+} // namespace vml
+} // namespace oox
+
+#endif
+
diff --git a/oox/inc/oox/vml/vmlinputstream.hxx b/oox/inc/oox/vml/vmlinputstream.hxx
new file mode 100644
index 000000000000..311fc17df960
--- /dev/null
+++ b/oox/inc/oox/vml/vmlinputstream.hxx
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_VML_VMLINPUTSTREAM_HXX
+#define OOX_VML_VMLINPUTSTREAM_HXX
+
+#include <comphelper/seqstream.hxx>
+
+namespace oox {
+namespace vml {
+
+// ============================================================================
+
+struct StreamDataContainer
+{
+ ::comphelper::ByteSequence maDataSeq;
+
+ explicit StreamDataContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm );
+};
+
+// ============================================================================
+
+/** An input stream class for VML streams.
+
+ This stream reads the entire data from the input stream passed to the
+ constructor, and parses all XML elements for features unsupported by the
+ current Expat parser.
+
+ All elements that have the form '<![inst]>' where 'inst' is any string not
+ containing the characters '<' and '>' are stripped from the input stream.
+ */
+class InputStream : private StreamDataContainer, public ::comphelper::SequenceInputStream
+{
+public:
+ explicit InputStream( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm );
+ virtual ~InputStream();
+};
+
+// ============================================================================
+
+} // namespace vml
+} // namespace oox
+
+#endif
+
diff --git a/oox/inc/oox/vml/vmlshape.hxx b/oox/inc/oox/vml/vmlshape.hxx
new file mode 100644
index 000000000000..7c770df28477
--- /dev/null
+++ b/oox/inc/oox/vml/vmlshape.hxx
@@ -0,0 +1,330 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_VML_VMLSHAPE_HXX
+#define OOX_VML_VMLSHAPE_HXX
+
+#include <memory>
+#include <vector>
+#include <com/sun/star/awt/Point.hpp>
+#include "oox/vml/vmlformatting.hxx"
+
+namespace com { namespace sun { namespace star {
+ namespace awt { struct Rectangle; }
+ namespace drawing { class XShape; }
+ namespace drawing { class XShapes; }
+} } }
+
+namespace oox {
+namespace vml {
+
+class Drawing;
+struct ShapeParentAnchor;
+class ShapeContainer;
+
+// ============================================================================
+
+/** The shape model structure contains all properties shared by all types of shapes. */
+struct ShapeTypeModel
+{
+ ::rtl::OUString maShapeId; /// Unique identifier of the shape.
+ ::rtl::OUString maName; /// Name of the shape, if present.
+ OptValue< sal_Int32 > moShapeType; /// Builtin shape type identifier.
+
+ OptValue< Int32Pair > moCoordPos; /// Top-left position of coordinate system for children scaling.
+ OptValue< Int32Pair > moCoordSize; /// Size of coordinate system for children scaling.
+ ::rtl::OUString maPosition; /// Position type of the shape.
+ ::rtl::OUString maLeft; /// X position of the shape bounding box (number with unit).
+ ::rtl::OUString maTop; /// Y position of the shape bounding box (number with unit).
+ ::rtl::OUString maWidth; /// Width of the shape bounding box (number with unit).
+ ::rtl::OUString maHeight; /// Height of the shape bounding box (number with unit).
+ ::rtl::OUString maMarginLeft; /// X position of the shape bounding box to shape anchor (number with unit).
+ ::rtl::OUString maMarginTop; /// Y position of the shape bounding box to shape anchor (number with unit).
+
+ StrokeModel maStrokeModel; /// Border line formatting.
+ FillModel maFillModel; /// Shape fill formatting.
+
+ OptValue< ::rtl::OUString > moGraphicPath; /// Path to a graphic for this shape.
+ OptValue< ::rtl::OUString > moGraphicTitle; /// Title of the graphic.
+
+ explicit ShapeTypeModel();
+
+ void assignUsed( const ShapeTypeModel& rSource );
+};
+
+// ----------------------------------------------------------------------------
+
+/** A shape template contains all formatting properties of shapes and can serve
+ as templates for several shapes in a drawing. */
+class ShapeType
+{
+public:
+ explicit ShapeType( Drawing& rDrawing );
+ virtual ~ShapeType();
+
+ /** Returns read/write access to the shape template model structure. */
+ inline ShapeTypeModel& getTypeModel() { return maTypeModel; }
+ /** Returns read access to the shape template model structure. */
+ inline const ShapeTypeModel& getTypeModel() const { return maTypeModel; }
+
+ /** Returns the shape identifier (which is unique through the containing drawing). */
+ inline const ::rtl::OUString& getShapeId() const { return maTypeModel.maShapeId; }
+ /** Returns the fragment path to the embedded graphic used by this shape. */
+ ::rtl::OUString getGraphicPath() const;
+
+protected:
+ /** Returns the coordinate system of this shape. */
+ ::com::sun::star::awt::Rectangle getCoordSystem() const;
+ /** Returns the absolute shape rectangle according to the passed anchor. */
+ ::com::sun::star::awt::Rectangle getRectangle( const ShapeParentAnchor* pParentAnchor ) const;
+
+private:
+ /** Returns the absolute shape rectangle. */
+ ::com::sun::star::awt::Rectangle getAbsRectangle() const;
+ /** Returns the rectangle relative to the parent coordinate system. */
+ ::com::sun::star::awt::Rectangle getRelRectangle() const;
+
+protected:
+ Drawing& mrDrawing; /// The VML drawing page that contains this shape.
+ ShapeTypeModel maTypeModel; /// The model structure containing shape type data.
+};
+
+// ============================================================================
+
+/** Excel specific shape client data (such as cell anchor). */
+struct ShapeClientData
+{
+ ::rtl::OUString maAnchor; /// Cell anchor as comma-separated string.
+ ::rtl::OUString maPictureLink; /// Target cell range of picture links.
+ ::rtl::OUString maLinkedCell; /// Link to value cell associated to the control.
+ ::rtl::OUString maSourceRange; /// Link to cell range used as data source for the control.
+ sal_Int32 mnObjType; /// Type of the shape.
+ sal_Int32 mnCol; /// Column index for spreadsheet cell note.
+ sal_Int32 mnRow; /// Row index for spreadsheet cell note.
+ bool mbPrintObject; /// True = print the object.
+ bool mbVisible; /// True = cell note is visible.
+
+ explicit ShapeClientData();
+};
+
+// ----------------------------------------------------------------------------
+
+struct ShapeModel
+{
+ typedef ::std::vector< ::com::sun::star::awt::Point > PointVector;
+ typedef ::std::auto_ptr< ShapeClientData > ShapeClientDataPtr;
+
+ ::rtl::OUString maType; /// Shape template with default properties.
+ PointVector maPoints; /// Points for the polyline shape.
+ ShapeClientDataPtr mxClientData; /// Excel specific shape client data.
+
+ explicit ShapeModel();
+
+ /** Creates and returns a new shape client data structure. */
+ ShapeClientData& createClientData();
+};
+
+// ----------------------------------------------------------------------------
+
+/** A shape object that is part of a drawing. May inherit properties from a
+ shape template. */
+class ShapeBase : public ShapeType
+{
+public:
+ /** Returns read/write access to the shape model structure. */
+ inline ShapeModel& getShapeModel() { return maShapeModel; }
+ /** Returns read access to the shape model structure. */
+ inline const ShapeModel& getShapeModel() const { return maShapeModel; }
+
+ /** Final processing after import of the drawing fragment. */
+ virtual void finalizeFragmentImport();
+
+ /** Returns the shape template with the passed identifier from the child shapes. */
+ virtual const ShapeType* getChildTypeById( const ::rtl::OUString& rShapeId ) const;
+ /** Returns the shape with the passed identifier from the child shapes. */
+ virtual const ShapeBase* getChildById( const ::rtl::OUString& rShapeId ) const;
+
+ /** Creates the corresponding XShape and inserts it into the passed container. */
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
+ convertAndInsert(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
+ const ShapeParentAnchor* pParentAnchor = 0 ) const;
+
+ /** Converts position and formatting into the passed existing XShape. */
+ void convertFormatting(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape,
+ const ShapeParentAnchor* pParentAnchor = 0 ) const;
+
+protected:
+ explicit ShapeBase( Drawing& rDrawing );
+
+ /** Derived classes create the corresponding XShape and insert it into the passed container. */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
+ implConvertAndInsert(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
+ const ::com::sun::star::awt::Rectangle& rShapeRect ) const = 0;
+
+ /** Calculates the final shape rectangle according to the passed anchor,
+ if present, otherwise according to the own anchor settings. */
+ ::com::sun::star::awt::Rectangle calcShapeRectangle(
+ const ShapeParentAnchor* pParentAnchor ) const;
+
+ /** Converts common shape properties such as formatting attributes. */
+ void convertShapeProperties(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape ) const;
+
+protected:
+ ShapeModel maShapeModel; /// The model structure containing shape data.
+};
+
+// ============================================================================
+
+/** A simple shape object based on a specific UNO shape service. */
+class SimpleShape : public ShapeBase
+{
+public:
+ explicit SimpleShape( Drawing& rDrawing, const ::rtl::OUString& rService );
+
+protected:
+ /** Creates the corresponding XShape and inserts it into the passed container. */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
+ implConvertAndInsert(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
+ const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
+
+private:
+ ::rtl::OUString maService; /// Name of the UNO shape service.
+};
+
+// ============================================================================
+
+/** A rectangular shape object. */
+class RectangleShape : public SimpleShape
+{
+public:
+ explicit RectangleShape( Drawing& rDrawing );
+};
+
+// ============================================================================
+
+/** An oval shape object. */
+class EllipseShape : public SimpleShape
+{
+public:
+ explicit EllipseShape( Drawing& rDrawing );
+};
+
+// ============================================================================
+
+/** A polygon shape object. */
+class PolyLineShape : public SimpleShape
+{
+public:
+ explicit PolyLineShape( Drawing& rDrawing );
+
+protected:
+ /** Creates the corresponding XShape and inserts it into the passed container. */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
+ implConvertAndInsert(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
+ const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
+};
+
+// ============================================================================
+
+/** A shape object with custom geometry. */
+class CustomShape : public SimpleShape
+{
+public:
+ explicit CustomShape( Drawing& rDrawing );
+
+protected:
+ /** Creates the corresponding XShape and inserts it into the passed container. */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
+ implConvertAndInsert(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
+ const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
+};
+
+// ============================================================================
+
+/** A complex shape object. This can be a picture shape, a custom shape, an OLE
+ object, or an ActiveX form control. */
+class ComplexShape : public CustomShape
+{
+public:
+ explicit ComplexShape( Drawing& rDrawing );
+
+protected:
+ /** Creates the corresponding XShape and inserts it into the passed container. */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
+ implConvertAndInsert(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
+ const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
+};
+
+// ============================================================================
+
+/** A group shape that extends the basic shape by a container of child shapes. */
+class GroupShape : public ShapeBase
+{
+public:
+ explicit GroupShape( Drawing& rDrawing );
+ virtual ~GroupShape();
+
+ /** Returns read/write access to the container of child shapes and templates. */
+ inline ShapeContainer& getChildren() { return *mxChildren; }
+ /** Returns read access to the container of child shapes and templates. */
+ inline const ShapeContainer& getChildren() const { return *mxChildren; }
+
+ /** Final processing after import of the drawing fragment. */
+ virtual void finalizeFragmentImport();
+
+ /** Returns the shape template with the passed identifier from the child shapes. */
+ virtual const ShapeType* getChildTypeById( const ::rtl::OUString& rShapeId ) const;
+ /** Returns the shape with the passed identifier from the child shapes. */
+ virtual const ShapeBase* getChildById( const ::rtl::OUString& rShapeId ) const;
+
+protected:
+ /** Creates the corresponding XShape and inserts it into the passed container. */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
+ implConvertAndInsert(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
+ const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
+
+private:
+ typedef ::std::auto_ptr< ShapeContainer > ShapeContainerPtr;
+ ShapeContainerPtr mxChildren; /// Shapes and templates that are part of this group.
+};
+
+// ============================================================================
+
+} // namespace vml
+} // namespace oox
+
+#endif
+
diff --git a/oox/inc/oox/vml/vmlshapecontainer.hxx b/oox/inc/oox/vml/vmlshapecontainer.hxx
new file mode 100644
index 000000000000..a878fda2b74c
--- /dev/null
+++ b/oox/inc/oox/vml/vmlshapecontainer.hxx
@@ -0,0 +1,139 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_VML_VMLSHAPECONTAINER_HXX
+#define OOX_VML_VMLSHAPECONTAINER_HXX
+
+#include <com/sun/star/awt/Rectangle.hpp>
+#include "oox/helper/containerhelper.hxx"
+
+namespace com { namespace sun { namespace star {
+ namespace drawing { class XShapes; }
+} } }
+
+namespace oox {
+namespace vml {
+
+class Drawing;
+class ShapeType;
+class ShapeBase;
+
+// ============================================================================
+
+struct ShapeParentAnchor
+{
+ ::com::sun::star::awt::Rectangle maShapeRect;
+ ::com::sun::star::awt::Rectangle maCoordSys;
+};
+
+// ============================================================================
+
+/** Container that holds a list of shapes and shape templates. */
+class ShapeContainer
+{
+public:
+ explicit ShapeContainer( Drawing& rDrawing );
+ ~ShapeContainer();
+
+ /** Creates and returns a new shape template object. */
+ ShapeType& createShapeType();
+ /** Creates and returns a new shape object of the specified type. */
+ template< typename ShapeT >
+ ShapeT& createShape();
+
+ /** Final processing after import of the drawing fragment. */
+ void finalizeFragmentImport();
+
+ /** Returns true, if this contaikner does not contain any shapes. */
+ inline bool empty() const { return maShapes.empty(); }
+
+ /** Returns the shape template with the passed identifier.
+ @param bDeep True = searches in all group shapes too. */
+ const ShapeType* getShapeTypeById( const ::rtl::OUString& rShapeId, bool bDeep ) const;
+ /** Returns the shape with the passed identifier.
+ @param bDeep True = searches in all group shapes too. */
+ const ShapeBase* getShapeById( const ::rtl::OUString& rShapeId, bool bDeep ) const;
+
+ /** Searches for a shape type by using the passed functor that takes a
+ constant reference of a ShapeType object. */
+ template< typename Functor >
+ const ShapeType* findShapeType( const Functor& rFunctor ) const;
+ /** Searches for a shape by using the passed functor that takes a constant
+ reference of a ShapeBase object. */
+ template< typename Functor >
+ const ShapeBase* findShape( const Functor& rFunctor ) const;
+
+ /** Returns the first shape in the collection (Word only). */
+ const ShapeBase* getFirstShape() const;
+
+ /** Creates and inserts all UNO shapes into the passed container. */
+ void convertAndInsert(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
+ const ShapeParentAnchor* pParentAnchor = 0 ) const;
+
+private:
+ typedef RefVector< ShapeType > ShapeTypeVector;
+ typedef RefVector< ShapeBase > ShapeVector;
+ typedef RefMap< ::rtl::OUString, ShapeType > ShapeTypeMap;
+ typedef RefMap< ::rtl::OUString, ShapeBase > ShapeMap;
+
+ Drawing& mrDrawing; /// The VML drawing page that contains this shape.
+ ShapeTypeVector maTypes; /// All shape templates.
+ ShapeVector maShapes; /// All shape definitions.
+ ShapeTypeMap maTypesById; /// All shape templates mapped by identifier.
+ ShapeMap maShapesById; /// All shape definitions mapped by identifier.
+};
+
+// ----------------------------------------------------------------------------
+
+template< typename ShapeT >
+ShapeT& ShapeContainer::createShape()
+{
+ ::boost::shared_ptr< ShapeT > xShape( new ShapeT( mrDrawing ) );
+ maShapes.push_back( xShape );
+ return *xShape;
+}
+
+template< typename Functor >
+const ShapeType* ShapeContainer::findShapeType( const Functor& rFunctor ) const
+{
+ return maTypes.findIf( rFunctor ).get();
+}
+
+template< typename Functor >
+const ShapeBase* ShapeContainer::findShape( const Functor& rFunctor ) const
+{
+ return maShapes.findIf( rFunctor ).get();
+}
+
+// ============================================================================
+
+} // namespace vml
+} // namespace oox
+
+#endif
+
diff --git a/oox/inc/oox/vml/vmlshapecontext.hxx b/oox/inc/oox/vml/vmlshapecontext.hxx
new file mode 100644
index 000000000000..bda7d90f34e2
--- /dev/null
+++ b/oox/inc/oox/vml/vmlshapecontext.hxx
@@ -0,0 +1,148 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_VML_VMLSHAPECONTEXT_HXX
+#define OOX_VML_VMLSHAPECONTEXT_HXX
+
+#include "oox/core/contexthandler2.hxx"
+
+namespace oox {
+namespace vml {
+
+struct ShapeTypeModel;
+class ShapeType;
+
+struct ShapeClientData;
+struct ShapeModel;
+class ShapeBase;
+class GroupShape;
+
+class ShapeContainer;
+
+// ============================================================================
+
+class ShapeClientDataContext : public ::oox::core::ContextHandler2
+{
+public:
+ explicit ShapeClientDataContext(
+ ::oox::core::ContextHandler2Helper& rParent,
+ const AttributeList& rAttribs,
+ ShapeClientData& rClientData );
+
+ virtual ::oox::core::ContextHandlerRef
+ onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs );
+ virtual void onEndElement( const ::rtl::OUString& rChars );
+
+private:
+ ShapeClientData& mrClientData;
+};
+
+// ============================================================================
+
+class ShapeContextBase : public ::oox::core::ContextHandler2
+{
+public:
+ static ::oox::core::ContextHandlerRef
+ createShapeContext(
+ ::oox::core::ContextHandler2Helper& rParent,
+ sal_Int32 nElement,
+ const AttributeList& rAttribs,
+ ShapeContainer& rShapes );
+
+protected:
+ explicit ShapeContextBase( ::oox::core::ContextHandler2Helper& rParent );
+};
+
+// ============================================================================
+
+class ShapeTypeContext : public ShapeContextBase
+{
+public:
+ explicit ShapeTypeContext(
+ ::oox::core::ContextHandler2Helper& rParent,
+ const AttributeList& rAttribs,
+ ShapeType& rShapeType );
+
+ virtual ::oox::core::ContextHandlerRef
+ onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs );
+
+private:
+ /** Processes the 'style' attribute. */
+ void setStyle( const ::rtl::OUString& rStyle );
+
+ /** Resolve a relation identifier to a fragment path. */
+ OptValue< ::rtl::OUString > decodeFragmentPath( const AttributeList& rAttribs, sal_Int32 nToken ) const;
+
+private:
+ ShapeTypeModel& mrTypeModel;
+};
+
+// ============================================================================
+
+class ShapeContext : public ShapeTypeContext
+{
+public:
+ explicit ShapeContext(
+ ::oox::core::ContextHandler2Helper& rParent,
+ const AttributeList& rAttribs,
+ ShapeBase& rShape );
+
+ virtual ::oox::core::ContextHandlerRef
+ onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs );
+
+private:
+ /** Processes the 'points' attribute. */
+ void setPoints( const ::rtl::OUString& rPoints );
+
+private:
+ ShapeModel& mrShapeModel;
+};
+
+// ============================================================================
+
+class GroupShapeContext : public ShapeContext
+{
+public:
+ explicit GroupShapeContext(
+ ::oox::core::ContextHandler2Helper& rParent,
+ const AttributeList& rAttribs,
+ GroupShape& rShape );
+
+ virtual ::oox::core::ContextHandlerRef
+ onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs );
+
+private:
+ ShapeContainer& mrShapes;
+};
+
+// ============================================================================
+
+} // namespace vml
+} // namespace oox
+
+#endif
+