diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-18 18:26:28 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-23 22:20:31 +0200 |
commit | b9337e22ce1dbf2eba0e8c8db294ae99f4111f91 (patch) | |
tree | 53ee1bd3dfd213815a21579151983cb997922b05 /include/oox/vml | |
parent | f4e1642a1761d5eab6ccdd89928869c2b2f1528a (diff) |
execute move of global headers
see https://gerrit.libreoffice.org/#/c/3367/
and Change-Id: I00c96fa77d04b33a6f8c8cd3490dfcd9bdc9e84a for details
Change-Id: I199a75bc4042af20817265d5ef85b1134a96ff5a
Diffstat (limited to 'include/oox/vml')
-rw-r--r-- | include/oox/vml/vmldrawing.hxx | 213 | ||||
-rw-r--r-- | include/oox/vml/vmldrawingfragment.hxx | 60 | ||||
-rw-r--r-- | include/oox/vml/vmlformatting.hxx | 248 | ||||
-rw-r--r-- | include/oox/vml/vmlinputstream.hxx | 98 | ||||
-rw-r--r-- | include/oox/vml/vmlshape.hxx | 439 | ||||
-rw-r--r-- | include/oox/vml/vmlshapecontainer.hxx | 153 | ||||
-rw-r--r-- | include/oox/vml/vmlshapecontext.hxx | 188 | ||||
-rw-r--r-- | include/oox/vml/vmltextbox.hxx | 104 | ||||
-rw-r--r-- | include/oox/vml/vmltextboxcontext.hxx | 78 |
9 files changed, 1581 insertions, 0 deletions
diff --git a/include/oox/vml/vmldrawing.hxx b/include/oox/vml/vmldrawing.hxx new file mode 100644 index 000000000000..ad7790962366 --- /dev/null +++ b/include/oox/vml/vmldrawing.hxx @@ -0,0 +1,213 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef OOX_VML_VMLDRAWING_HXX +#define OOX_VML_VMLDRAWING_HXX + +#include <map> +#include <memory> +#include <vector> +#include <oox/ole/axcontrol.hxx> +#include <oox/ole/oleobjecthelper.hxx> +#include <oox/vml/vmlshapecontainer.hxx> +#include "oox/dllapi.h" + +namespace com { namespace sun { namespace star { + namespace awt { struct Rectangle; } + namespace awt { class XControlModel; } + namespace drawing { class XDrawPage; } + namespace drawing { class XShape; } + namespace drawing { class XShapes; } +} } } + +namespace oox { + namespace core { class XmlFilterBase; } + namespace ole { class EmbeddedControl; } +} + +namespace oox { +namespace vml { + +class ShapeBase; +struct ClientData; + +// ============================================================================ + +/** 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 OOX_DLLPUBLIC OleObjectInfo : public ::oox::ole::OleObjectInfo +{ + OUString maShapeId; ///< Shape identifier for shape lookup. + 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 OOX_DLLPUBLIC ControlInfo +{ + OUString maShapeId; ///< Shape identifier for shape lookup. + OUString maFragmentPath; ///< Path to the fragment describing the form control properties. + 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 OOX_DLLPUBLIC 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 a block of shape identifiers reserved by this drawing. Block + size is 1024, shape identifiers are one-based (block 1 => 1025-2048). */ + void registerBlockId( sal_Int32 nBlockId ); + /** 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 draw page. The virtual + function notifyXShapeInserted() will be called for each new shape. */ + void convertAndInsert() const; + + /** Returns the local shape index from the passed global shape identifier. */ + sal_Int32 getLocalShapeIndex( const OUString& rShapeId ) const; + /** Returns the registered info structure for an OLE object, if extant. */ + const OleObjectInfo* getOleObjectInfo( const OUString& rShapeId ) const; + /** Returns the registered info structure for a form control, if extant. */ + const ControlInfo* getControlInfo( const OUString& rShapeId ) const; + + /** Creates a new UNO shape object, inserts it into the passed UNO shape + container, and sets the shape position and size. */ + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > + createAndInsertXShape( + const OUString& rService, + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes, + const ::com::sun::star::awt::Rectangle& rShapeRect ) const; + + /** Creates a new UNO shape object for a form control, inserts the control + model into the form, and the shape into the passed UNO shape container. */ + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > + createAndInsertXControlShape( + const ::oox::ole::EmbeddedControl& rControl, + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes, + const ::com::sun::star::awt::Rectangle& rShapeRect, + sal_Int32& rnCtrlIndex ) const; + + /** Derived classes may disable conversion of specific shapes. */ + virtual bool isShapeSupported( const ShapeBase& rShape ) const; + + /** Derived classes may return additional base names for automatic shape + name creation. */ + virtual OUString getShapeBaseName( const ShapeBase& rShape ) const; + + /** Derived classes may calculate the shape rectangle from a non-standard + anchor information string. */ + virtual bool convertClientAnchor( + ::com::sun::star::awt::Rectangle& orShapeRect, + const OUString& rShapeAnchor ) const; + + /** Derived classes create a UNO shape according to the passed shape model. + Called for shape models that specify being under host control. */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > + createAndInsertClientXShape( + const ShapeBase& rShape, + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes, + const ::com::sun::star::awt::Rectangle& rShapeRect ) const; + + /** Derived classes may want to know that a UNO shape has been inserted. + Will be called from the convertAndInsert() implementation. + @param bGroupChild True = inserted into a group shape, + false = inserted directly into this drawing. */ + virtual void notifyXShapeInserted( + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape, + const ::com::sun::star::awt::Rectangle& rShapeRect, + const ShapeBase& rShape, bool bGroupChild ); + +private: + typedef ::std::vector< sal_Int32 > BlockIdVector; + SAL_WNODEPRECATED_DECLARATIONS_PUSH + typedef ::std::auto_ptr< ::oox::ole::EmbeddedForm > EmbeddedFormPtr; + typedef ::std::auto_ptr< ShapeContainer > ShapeContainerPtr; + SAL_WNODEPRECATED_DECLARATIONS_POP + typedef ::std::map< OUString, OleObjectInfo > OleObjectInfoMap; + typedef ::std::map< 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 embedded controls. + mutable BlockIdVector maBlockIds; ///< Block identifiers used by this drawing. + 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 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/vml/vmldrawingfragment.hxx b/include/oox/vml/vmldrawingfragment.hxx new file mode 100644 index 000000000000..f0947998a092 --- /dev/null +++ b/include/oox/vml/vmldrawingfragment.hxx @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef OOX_VML_VMLDRAWINGFRAGMENT_HXX +#define OOX_VML_VMLDRAWINGFRAGMENT_HXX + +#include "oox/core/fragmenthandler2.hxx" +#include "oox/dllapi.h" + +namespace oox { +namespace vml { + +class Drawing; + +// ============================================================================ + +class OOX_DLLPUBLIC DrawingFragment : public ::oox::core::FragmentHandler2 +{ +public: + explicit DrawingFragment( + ::oox::core::XmlFilterBase& rFilter, + const 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 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/vml/vmlformatting.hxx b/include/oox/vml/vmlformatting.hxx new file mode 100644 index 000000000000..79fa38009e4d --- /dev/null +++ b/include/oox/vml/vmlformatting.hxx @@ -0,0 +1,248 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef OOX_VML_VMLFORMATTING_HXX +#define OOX_VML_VMLFORMATTING_HXX + +#include "oox/helper/helper.hxx" +#include "oox/dllapi.h" +#include <com/sun/star/awt/Point.hpp> +#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp> + +#include <vector> + +namespace oox { + class GraphicHelper; + namespace drawingml { class Color; } + namespace drawingml { class ShapePropertyMap; } +} + +namespace oox { +namespace vml { + +// ============================================================================ + +typedef ::std::pair< sal_Int32, sal_Int32 > Int32Pair; +typedef ::std::pair< double, double > DoublePair; + +// ============================================================================ + +class OOX_DLLPUBLIC ConversionHelper +{ +public: + /** Returns two values contained in rValue separated by cSep. + */ + static bool separatePair( + OUString& orValue1, OUString& orValue2, + const 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 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 '%' or 'f' 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. If the 'f' sign is present, + the value will be divided by 65536. + */ + static double decodePercent( + const 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_Int64 decodeMeasureToEmu( + const GraphicHelper& rGraphicHelper, + const 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 OUString& rValue, + sal_Int32 nRefValue, + bool bPixelX, + bool bDefaultAsPixel ); + + /** Converts VML color attributes to a DrawingML color. + + @param roVmlColor The VML string representation of the color. If + existing, this can be a 3-digit or 6-digit hexadecimal RGB value + with leading '#' character, a predefined color name (e.g. 'black', + 'red', etc.), the index into an application defined color palette + in brackets with leading color name (e.g. 'red [9]' or + 'windowColor [64]'), or a color modifier used in one-color + gradients (e.g. 'fill darken(128)' or 'fill lighten(0)'). + + @param roVmlOpacity The opacity of the color. If existing, this should + be a floating-point value in the range [0.0;1.0]. + + @param nDefaultRgb Deafult RGB color used if the parameter roVmlColor + is empty. + + @param nPrimaryRgb If set to something else than API_RGB_TRANSPARENT, + specifies the color to be used to resolve the color modifiers used + in one-color gradients. + + @return The resulting DrawingML color. + */ + static ::oox::drawingml::Color decodeColor( + const GraphicHelper& rGraphicHelper, + const OptValue< OUString >& roVmlColor, + const OptValue< double >& roVmlOpacity, + sal_Int32 nDefaultRgb, + sal_Int32 nPrimaryRgb = API_RGB_TRANSPARENT ); + + /** Converts VML path string into point and flag vectors. + + @param rPoints The point vector to fill with coordinates. + + @param rFlags The flag vector to fill. PolygonFlags_NORMAL indicates + a corresponding plain shape coordinate in rPoints and + PolygonFlags_CONTROL indicates a bezier curve control point. + + @param rPath The VML path string. + + @param rGraphicHelper See above. + */ + static void decodeVmlPath( + ::std::vector< ::std::vector< ::com::sun::star::awt::Point > >& rPoints, + ::std::vector< ::std::vector< ::com::sun::star::drawing::PolygonFlags > >& rFlags, + const OUString& rPath ); + +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< OUString > moColor; ///< Solid line color. + OptValue< double > moOpacity; ///< Solid line color opacity. + OptValue< OUString > moWeight; ///< Line width. + OptValue< 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( + ::oox::drawingml::ShapePropertyMap& rPropMap, + const GraphicHelper& rGraphicHelper ) const; +}; + +// ============================================================================ + +/** The fill model structure contains all shape fill properties. */ +struct OOX_DLLPUBLIC FillModel +{ + OptValue< bool > moFilled; ///< Shape fill on/off. + OptValue< OUString > moColor; ///< Solid fill color. + OptValue< double > moOpacity; ///< Solid fill color opacity. + OptValue< OUString > moColor2; ///< End color of gradient. + OptValue< double > moOpacity2; ///< End color opacity 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; ///< Rectangular gradient focus position of second color. + OptValue< DoublePair > moFocusSize; ///< Rectangular gradient focus size of second color. + OptValue< 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( + ::oox::drawingml::ShapePropertyMap& rPropMap, + const GraphicHelper& rGraphicHelper ) const; +}; + +// ============================================================================ + +/** The shadow model structure contains all shape shadow properties. */ +struct OOX_DLLPUBLIC ShadowModel +{ + bool mbHasShadow; ///< Is a v:shadow element seen? + OptValue<bool> moShadowOn; ///< Is the element turned on? + OptValue<OUString> moColor; ///< Specifies the color of the shadow. + OptValue<OUString> moOffset; ///< Specifies the shadow's offset from the shape's location. + OptValue<double> moOpacity; ///< Specifies the opacity of the shadow. + + ShadowModel(); + + /** Writes the properties to the passed property map. */ + void pushToPropMap(oox::drawingml::ShapePropertyMap& rPropMap, const GraphicHelper& rGraphicHelper) const; +}; + +} // namespace vml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/vml/vmlinputstream.hxx b/include/oox/vml/vmlinputstream.hxx new file mode 100644 index 000000000000..7c8e13160722 --- /dev/null +++ b/include/oox/vml/vmlinputstream.hxx @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef OOX_VML_VMLINPUTSTREAM_HXX +#define OOX_VML_VMLINPUTSTREAM_HXX + +#include <com/sun/star/io/XInputStream.hpp> +#include <cppuhelper/implbase1.hxx> +#include <rtl/string.hxx> + +namespace com { namespace sun { namespace star { + namespace io { class XTextInputStream2; } + namespace uno { class XComponentContext; } +} } } + +namespace oox { +namespace vml { + +// ============================================================================ + +typedef ::cppu::WeakImplHelper1< ::com::sun::star::io::XInputStream > InputStream_BASE; + +/** An input stream class for VML streams, implementing the UNO interface + com.sun.star.io.XInputStream needed by the Expat XML parsers. + + This stream reads the data from the input stream passed to the constructor, + and parses all XML elements for features unsupported by the current Expat + XML parser: + + 1) All elements that have the form '<![inst]>' where 'inst' is any string + not containing the characters '<' and '>' are stripped from the input + stream. + + 2) Multiple occurences of the same attribute in an element but the last + are removed. + + 3) Line breaks represented by a single <br> element (without matching + </br> element) are replaced by a literal LF character. + */ +class InputStream : public InputStream_BASE +{ +public: + explicit InputStream( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm ); + virtual ~InputStream(); + + virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& rData, sal_Int32 nBytesToRead ) + throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& rData, sal_Int32 nMaxBytesToRead ) + throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) + throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL available() + throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL closeInput() + throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + +private: + void updateBuffer() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + OString readToElementBegin() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + OString readToElementEnd() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextInputStream2 > + mxTextStrm; + ::com::sun::star::uno::Sequence< sal_Unicode > maOpeningBracket; + ::com::sun::star::uno::Sequence< sal_Unicode > maClosingBracket; + const OString maOpeningCData; + const OString maClosingCData; + OString maBuffer; + sal_Int32 mnBufferPos; +}; + +// ============================================================================ + +} // namespace vml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/vml/vmlshape.hxx b/include/oox/vml/vmlshape.hxx new file mode 100644 index 000000000000..7b6a4a9376c7 --- /dev/null +++ b/include/oox/vml/vmlshape.hxx @@ -0,0 +1,439 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#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" +#include "oox/vml/vmltextbox.hxx" +#include "oox/dllapi.h" + +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; + +// ============================================================================ + +const sal_Int32 VML_CLIENTDATA_UNCHECKED = 0; +const sal_Int32 VML_CLIENTDATA_CHECKED = 1; +const sal_Int32 VML_CLIENTDATA_MIXED = 2; + +const sal_Int32 VML_CLIENTDATA_TEXT = 0; +const sal_Int32 VML_CLIENTDATA_INTEGER = 1; +const sal_Int32 VML_CLIENTDATA_NUMBER = 2; +const sal_Int32 VML_CLIENTDATA_REFERENCE = 3; +const sal_Int32 VML_CLIENTDATA_FORMULA = 4; + +// ============================================================================ + +/** The shape model structure contains all properties shared by all types of shapes. */ +struct OOX_DLLPUBLIC ShapeTypeModel +{ + OUString maShapeId; ///< Unique identifier of the shape. + OUString maShapeName; ///< 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. + OUString maPosition; ///< Position type of the shape. + OUString maLeft; ///< X position of the shape bounding box (number with unit). + OUString maTop; ///< Y position of the shape bounding box (number with unit). + OUString maWidth; ///< Width of the shape bounding box (number with unit). + OUString maHeight; ///< Height of the shape bounding box (number with unit). + OUString maMarginLeft; ///< X position of the shape bounding box to shape anchor (number with unit). + OUString maMarginTop; ///< Y position of the shape bounding box to shape anchor (number with unit). + OUString maPositionHorizontalRelative; ///< The X position is relative to this. + OUString maPositionVerticalRelative; ///< The Y position is relative to this. + OUString maPositionHorizontal; ///< The X position orientation (default: absolute). + OUString maPositionVertical; ///< The Y position orientation. + OUString maWidthPercent; ///< The width in percents of the WidthRelative + OUString maHeightPercent; ///< The height in percents of the HeightRelative + OUString maWidthRelative; ///< To what the width is relative + OUString maHeightRelative; ///< To what the height is relative + OUString maRotation; ///< Rotation of the shape, in degrees. + OUString maFlip; ///< Flip type of the shape (can be "x" or "y"). + sal_Bool mbAutoHeight; ///< If true, the height value is a minimum value (mostly used for textboxes) + sal_Bool mbVisible; ///< Visible or Hidden + OUString maWrapStyle; ///< Wrapping mode for text. + OUString maArcsize; ///< round rectangles arc size + + StrokeModel maStrokeModel; ///< Border line formatting. + FillModel maFillModel; ///< Shape fill formatting. + ShadowModel maShadowModel; ///< Shape shadow formatting. + + OptValue< OUString > moGraphicPath; ///< Path to a graphic for this shape. + OptValue< OUString > moGraphicTitle; ///< Title of the graphic. + OptValue< OUString > moWrapAnchorX; ///< The base object from which our horizontal positioning should be calculated. + OptValue< OUString > moWrapAnchorY; ///< The base object from which our vertical positioning should be calculated. + + 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 OUString& getShapeId() const { return maTypeModel.maShapeId; } + /** Returns the application defined shape type. */ + sal_Int32 getShapeType() const; + /** Returns the fragment path to the embedded graphic used by this shape. */ + OUString getGraphicPath() const; + + const Drawing& getDrawing() const { return mrDrawing; } + +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; + /** Returns the absolute shape rectangle. */ + virtual ::com::sun::star::awt::Rectangle getAbsRectangle() const; + /** Returns the rectangle relative to the parent coordinate system. */ + virtual ::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 ClientData +{ + OUString maAnchor; ///< Cell anchor as comma-separated string. + OUString maFmlaMacro; ///< Link to macro associated to the control. + OUString maFmlaPict; ///< Target cell range of picture links. + OUString maFmlaLink; ///< Link to value cell associated to the control. + OUString maFmlaRange; ///< Link to cell range used as data source for the control. + OUString maFmlaGroup; ///< Link to value cell associated to a group of option buttons. + sal_Int32 mnObjType; ///< Type of the shape. + sal_Int32 mnTextHAlign; ///< Horizontal text alignment. + sal_Int32 mnTextVAlign; ///< Vertical text alignment. + sal_Int32 mnCol; ///< Column index for spreadsheet cell note. + sal_Int32 mnRow; ///< Row index for spreadsheet cell note. + sal_Int32 mnChecked; ///< State for checkboxes and option buttons. + sal_Int32 mnDropStyle; ///< Drop down box style (read-only or editable). + sal_Int32 mnDropLines; ///< Number of lines in drop down box. + sal_Int32 mnVal; ///< Current value of spin buttons and scroll bars. + sal_Int32 mnMin; ///< Minimum value of spin buttons and scroll bars. + sal_Int32 mnMax; ///< Maximum value of spin buttons and scroll bars. + sal_Int32 mnInc; ///< Small increment of spin buttons and scroll bars. + sal_Int32 mnPage; ///< Large increment of spin buttons and scroll bars. + sal_Int32 mnSelType; ///< Listbox selection type. + sal_Int32 mnVTEdit; ///< Data type of the textbox. + bool mbPrintObject; ///< True = print the object. + bool mbVisible; ///< True = cell note is visible. + bool mbDde; ///< True = object is linked through DDE. + bool mbNo3D; ///< True = flat style, false = 3D style. + bool mbNo3D2; ///< True = flat style, false = 3D style (listboxes and dropdowns). + bool mbMultiLine; ///< True = textbox allows line breaks. + bool mbVScroll; ///< True = textbox has a vertical scrollbar. + bool mbSecretEdit; ///< True = textbox is a password edit field. + + explicit ClientData(); +}; + +// ---------------------------------------------------------------------------- + +struct ShapeModel +{ + typedef ::std::vector< ::com::sun::star::awt::Point > PointVector; + SAL_WNODEPRECATED_DECLARATIONS_PUSH + typedef ::std::auto_ptr< TextBox > TextBoxPtr; + typedef ::std::auto_ptr< ClientData > ClientDataPtr; + SAL_WNODEPRECATED_DECLARATIONS_POP + + OUString maType; ///< Shape template with default properties. + PointVector maPoints; ///< Points for the polyline shape. + TextBoxPtr mxTextBox; ///< Text contents and properties. + ClientDataPtr mxClientData; ///< Excel specific client data. + OUString maLegacyDiagramPath;///< Legacy Diagram Fragment Path + OUString maFrom; ///< Start point for line shape. + OUString maTo; ///< End point for line shape. + OUString maControl1; ///< Bezier control point 1 + OUString maControl2; ///< Bezier control point 2 + OUString maVmlPath; ///< VML path for this shape + + explicit ShapeModel(); + ~ShapeModel(); + + /** Creates and returns a new shape textbox structure. */ + TextBox& createTextBox(ShapeTypeModel& rModel); + /** Creates and returns a new shape client data structure. */ + ClientData& createClientData(); +}; + +// ---------------------------------------------------------------------------- + +/** A shape object that is part of a drawing. May inherit properties from a + shape template. */ +class OOX_DLLPUBLIC 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; } + + /** Returns read access to the shape textbox. */ + inline const TextBox* getTextBox() const { return maShapeModel.mxTextBox.get(); } + /** Returns read access to the shape client data structure. */ + inline const ClientData* getClientData() const { return maShapeModel.mxClientData.get(); } + + /** Final processing after import of the drawing fragment. */ + virtual void finalizeFragmentImport(); + + /** Returns the real shape name if existing, or a generated shape name. */ + OUString getShapeName() const; + + /** Returns the shape template with the passed identifier from the child shapes. */ + virtual const ShapeType* getChildTypeById( const OUString& rShapeId ) const; + /** Returns the shape with the passed identifier from the child shapes. */ + virtual const ShapeBase* getChildById( const 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 OUString& rService ); + + void setService( OUString aService ) { maService = aService; } + +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; + /** Used by both RectangleShape and ComplexShape. */ + com::sun::star::uno::Reference<com::sun::star::drawing::XShape>createPictureObject( + const com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rxShapes, + const com::sun::star::awt::Rectangle& rShapeRect, OUString& rGraphicPath ) const; + +private: + OUString maService; ///< Name of the UNO shape service. +}; + +// ============================================================================ + +/** A rectangular shape object. */ +class RectangleShape : public SimpleShape +{ +public: + explicit RectangleShape( 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; +}; + +// ============================================================================ + +/** 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 Line shape object. */ +class LineShape : public SimpleShape +{ +public: + explicit LineShape( Drawing& rDrawing ); + +protected: + /** Returns the absolute shape rectangle. */ + virtual ::com::sun::star::awt::Rectangle getAbsRectangle() const SAL_OVERRIDE; + /** Returns the rectangle relative to the parent coordinate system. */ + virtual ::com::sun::star::awt::Rectangle getRelRectangle() const SAL_OVERRIDE; +}; + +/** Bezier shape object that supports to, from, control1 and control2 + attribute or path attribute specification */ +class BezierShape : public SimpleShape +{ +public: + explicit BezierShape( 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 OUString& rShapeId ) const; + /** Returns the shape with the passed identifier from the child shapes. */ + virtual const ShapeBase* getChildById( const 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: + SAL_WNODEPRECATED_DECLARATIONS_PUSH + typedef ::std::auto_ptr< ShapeContainer > ShapeContainerPtr; + SAL_WNODEPRECATED_DECLARATIONS_POP + ShapeContainerPtr mxChildren; ///< Shapes and templates that are part of this group. +}; + +// ============================================================================ + +} // namespace vml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/vml/vmlshapecontainer.hxx b/include/oox/vml/vmlshapecontainer.hxx new file mode 100644 index 000000000000..5e6a2c2a9d75 --- /dev/null +++ b/include/oox/vml/vmlshapecontainer.hxx @@ -0,0 +1,153 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef OOX_VML_VMLSHAPECONTAINER_HXX +#define OOX_VML_VMLSHAPECONTAINER_HXX + +#include <com/sun/star/awt/Rectangle.hpp> +#include "oox/helper/refmap.hxx" +#include "oox/helper/refvector.hxx" +#include <stack> + +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(); + + /** Returns the drawing this shape container is part of. */ + inline Drawing& getDrawing() { return mrDrawing; } + + /** 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 container 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 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 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; + + /** + (Word only) Returns the last shape in the collection, if it is after the last + mark from pushMark(), and removes it. + */ + boost::shared_ptr< ShapeBase > takeLastShape(); + /** + Adds a recursion mark to the stack. It is possible that a shape contains <w:txbxContent> + which contains another shape, and writerfilter needs to know which shape is from the inner + ooxml context and which from the outer ooxml context, while it is necessary to keep + at least shape types across such blocks. Therefore this function marks beginning + of each shape xml block, and takeLastShape() returns only shapes from this block. + */ + void pushMark(); + /** + Removes a recursion mark. + */ + void popMark(); + + /** 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< OUString, ShapeType > ShapeTypeMap; + typedef RefMap< 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. + std::stack< size_t > markStack; ///< Recursion marks from pushMark()/popMark(). +}; + +// ---------------------------------------------------------------------------- + +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 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/vml/vmlshapecontext.hxx b/include/oox/vml/vmlshapecontext.hxx new file mode 100644 index 000000000000..803674088e37 --- /dev/null +++ b/include/oox/vml/vmlshapecontext.hxx @@ -0,0 +1,188 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef OOX_VML_VMLSHAPECONTEXT_HXX +#define OOX_VML_VMLSHAPECONTEXT_HXX + +#include "oox/core/contexthandler2.hxx" + +namespace oox { +namespace vml { + +class Drawing; + +struct ShapeTypeModel; +class ShapeType; + +struct ClientData; +struct ShapeModel; +class ShapeBase; +class GroupShape; +class RectangleShape; + +class ShapeContainer; + +// ============================================================================ + +class ShapeLayoutContext : public ::oox::core::ContextHandler2 +{ +public: + explicit ShapeLayoutContext( + ::oox::core::ContextHandler2Helper& rParent, + Drawing& rDrawing ); + + virtual ::oox::core::ContextHandlerRef + onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); + +private: + Drawing& mrDrawing; +}; + +// ============================================================================ + +class ClientDataContext : public ::oox::core::ContextHandler2 +{ +public: + explicit ClientDataContext( + ::oox::core::ContextHandler2Helper& rParent, + ClientData& rClientData, + const AttributeList& rAttribs ); + + virtual ::oox::core::ContextHandlerRef + onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); + virtual void onCharacters( const OUString& rChars ); + virtual void onEndElement(); + +private: + ClientData& mrClientData; + OUString maElementText; +}; + +// ============================================================================ + +class ShapeContextBase : public ::oox::core::ContextHandler2 +{ +public: + static ::oox::core::ContextHandlerRef + createShapeContext( + ::oox::core::ContextHandler2Helper& rParent, + ShapeContainer& rShapes, + sal_Int32 nElement, + const AttributeList& rAttribs ); + +protected: + explicit ShapeContextBase( ::oox::core::ContextHandler2Helper& rParent ); +}; + +// ============================================================================ + +class ShapeTypeContext : public ShapeContextBase +{ +public: + explicit ShapeTypeContext( + ::oox::core::ContextHandler2Helper& rParent, + ShapeType& rShapeType, + const AttributeList& rAttribs ); + + virtual ::oox::core::ContextHandlerRef + onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); + +private: + /** Processes the 'style' attribute. */ + void setStyle( const OUString& rStyle ); + + /** Resolve a relation identifier to a fragment path. */ + OptValue< OUString > decodeFragmentPath( const AttributeList& rAttribs, sal_Int32 nToken ) const; + +private: + ShapeTypeModel& mrTypeModel; +}; + +// ============================================================================ + +class ShapeContext : public ShapeTypeContext +{ +public: + explicit ShapeContext( + ::oox::core::ContextHandler2Helper& rParent, + ShapeBase& rShape, + const AttributeList& rAttribs ); + + virtual ::oox::core::ContextHandlerRef + onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); + +private: + /** Processes the 'points' attribute. */ + void setPoints( const OUString& rPoints ); + /** Processes the 'from' attribute. */ + void setFrom( const OUString& rPoints ); + /** Processes the 'to' attribute. */ + void setTo( const OUString& rPoints ); + /** Processes the 'control1' attribute. */ + void setControl1( const OUString& rPoints ); + /** Processes the 'control2' attribute. */ + void setControl2( const OUString& rPoints ); + /** Processes the 'path' attribute. */ + void setVmlPath( const OUString& rPath ); + +protected: + ShapeBase& mrShape; + +private: + ShapeModel& mrShapeModel; +}; + +// ============================================================================ + +class GroupShapeContext : public ShapeContext +{ +public: + explicit GroupShapeContext( + ::oox::core::ContextHandler2Helper& rParent, + GroupShape& rShape, + const AttributeList& rAttribs ); + + virtual ::oox::core::ContextHandlerRef + onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); + +private: + ShapeContainer& mrShapes; +}; + +// ============================================================================ + +class RectangleShapeContext : public ShapeContext +{ +public: + explicit RectangleShapeContext( + ::oox::core::ContextHandler2Helper& rParent, + const AttributeList& rAttribs, + RectangleShape& rShape ); + + virtual ::oox::core::ContextHandlerRef + onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); +}; +// ============================================================================ + +} // namespace vml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/vml/vmltextbox.hxx b/include/oox/vml/vmltextbox.hxx new file mode 100644 index 000000000000..4975e6bb26b6 --- /dev/null +++ b/include/oox/vml/vmltextbox.hxx @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef OOX_VML_VMLTEXTBOX_HXX +#define OOX_VML_VMLTEXTBOX_HXX + +#include <vector> +#include <rtl/ustring.hxx> +#include "oox/helper/helper.hxx" +#include "oox/dllapi.h" +#include <com/sun/star/uno/Reference.h> + +namespace com { namespace sun { namespace star { + namespace drawing { class XShape; } +} } } + +namespace oox { +namespace vml { + +struct ShapeTypeModel; + +// ============================================================================ + +/** Font settings for a text portion in a textbox. */ +struct OOX_DLLPUBLIC TextFontModel +{ + OptValue< OUString > moName; ///< Font name. + OptValue< OUString > moColor; ///< Font color, HTML encoded, sort of. + OptValue< sal_Int32 > monSize; ///< Font size in twips. + OptValue< sal_Int32 > monUnderline; ///< Single or double underline. + OptValue< sal_Int32 > monEscapement; ///< Subscript or superscript. + OptValue< bool > mobBold; + OptValue< bool > mobItalic; + OptValue< bool > mobStrikeout; + + explicit TextFontModel(); +}; + +// ============================================================================ + +/** A text portion in a textbox with the same formatting for all characters. */ +struct TextPortionModel +{ + TextFontModel maFont; + OUString maText; + + explicit TextPortionModel( const TextFontModel& rFont, const OUString& rText ); +}; + +// ============================================================================ + +/** The textbox contains all text contents and properties. */ +class OOX_DLLPUBLIC TextBox +{ +public: + explicit TextBox(ShapeTypeModel& rTypeModel); + + /** Appends a new text portion to the textbox. */ + void appendPortion( const TextFontModel& rFont, const OUString& rText ); + + /** Returns the current number of text portions. */ + inline size_t getPortionCount() const { return maPortions.size(); } + /** Returns the font settings of the first text portion. */ + const TextFontModel* getFirstFont() const; + /** Returns the entire text of all text portions. */ + OUString getText() const; + void convert(com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xShape) const; + + ShapeTypeModel& mrTypeModel; + /// Text distance from the border (inset attribute of v:textbox), valid only if set. + bool borderDistanceSet; + int borderDistanceLeft, borderDistanceTop, borderDistanceRight, borderDistanceBottom; + OUString maLayoutFlow; + +private: + typedef ::std::vector< TextPortionModel > PortionVector; + + PortionVector maPortions; +}; + +// ============================================================================ + +} // namespace vml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/oox/vml/vmltextboxcontext.hxx b/include/oox/vml/vmltextboxcontext.hxx new file mode 100644 index 000000000000..47d71ac41b41 --- /dev/null +++ b/include/oox/vml/vmltextboxcontext.hxx @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef OOX_VML_VMLTEXTBOXCONTEXT_HXX +#define OOX_VML_VMLTEXTBOXCONTEXT_HXX + +#include "oox/core/contexthandler2.hxx" +#include "oox/vml/vmltextbox.hxx" + +namespace oox { +namespace vml { + +// ============================================================================ + +class TextPortionContext : public ::oox::core::ContextHandler2 +{ +public: + explicit TextPortionContext( + ::oox::core::ContextHandler2Helper& rParent, + TextBox& rTextBox, + const TextFontModel& rParentFont, + sal_Int32 nElement, + const AttributeList& rAttribs ); + + virtual ::oox::core::ContextHandlerRef + onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); + virtual void onCharacters( const OUString& rChars ); + virtual void onStartElement(const AttributeList& rAttribs); + virtual void onEndElement(); + +private: + TextBox& mrTextBox; + TextFontModel maFont; + size_t mnInitialPortions; +}; + +// ============================================================================ + +class TextBoxContext : public ::oox::core::ContextHandler2 +{ +public: + explicit TextBoxContext( + ::oox::core::ContextHandler2Helper& rParent, + TextBox& rTextBox, + const AttributeList& rAttribs, + const GraphicHelper& graphicHelper ); + + virtual ::oox::core::ContextHandlerRef + onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); + +private: + TextBox& mrTextBox; +}; + +// ============================================================================ + +} // namespace vml +} // namespace oox + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |