LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/oox/vml - vmlshape.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 19 20 95.0 %
Date: 2013-07-09 Functions: 24 29 82.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef OOX_VML_VMLSHAPE_HXX
      21             : #define OOX_VML_VMLSHAPE_HXX
      22             : 
      23             : #include <memory>
      24             : #include <vector>
      25             : #include <com/sun/star/awt/Point.hpp>
      26             : #include "oox/vml/vmlformatting.hxx"
      27             : #include "oox/vml/vmltextbox.hxx"
      28             : #include "oox/dllapi.h"
      29             : 
      30             : namespace com { namespace sun { namespace star {
      31             :     namespace awt { struct Rectangle; }
      32             :     namespace drawing { class XShape; }
      33             :     namespace drawing { class XShapes; }
      34             : } } }
      35             : 
      36             : namespace oox {
      37             : namespace vml {
      38             : 
      39             : class Drawing;
      40             : struct ShapeParentAnchor;
      41             : class ShapeContainer;
      42             : 
      43             : // ============================================================================
      44             : 
      45             : const sal_Int32 VML_CLIENTDATA_UNCHECKED        = 0;
      46             : const sal_Int32 VML_CLIENTDATA_CHECKED          = 1;
      47             : const sal_Int32 VML_CLIENTDATA_MIXED            = 2;
      48             : 
      49             : const sal_Int32 VML_CLIENTDATA_TEXT             = 0;
      50             : const sal_Int32 VML_CLIENTDATA_INTEGER          = 1;
      51             : const sal_Int32 VML_CLIENTDATA_NUMBER           = 2;
      52             : const sal_Int32 VML_CLIENTDATA_REFERENCE        = 3;
      53             : const sal_Int32 VML_CLIENTDATA_FORMULA          = 4;
      54             : 
      55             : // ============================================================================
      56             : 
      57             : /** The shape model structure contains all properties shared by all types of shapes. */
      58         101 : struct OOX_DLLPUBLIC ShapeTypeModel
      59             : {
      60             :     OUString     maShapeId;              ///< Unique identifier of the shape.
      61             :     OUString     maShapeName;            ///< Name of the shape, if present.
      62             :     OptValue< sal_Int32 > moShapeType;          ///< Builtin shape type identifier.
      63             : 
      64             :     OptValue< Int32Pair > moCoordPos;           ///< Top-left position of coordinate system for children scaling.
      65             :     OptValue< Int32Pair > moCoordSize;          ///< Size of coordinate system for children scaling.
      66             :     OUString     maPosition;             ///< Position type of the shape.
      67             :     OUString     maLeft;                 ///< X position of the shape bounding box (number with unit).
      68             :     OUString     maTop;                  ///< Y position of the shape bounding box (number with unit).
      69             :     OUString     maWidth;                ///< Width of the shape bounding box (number with unit).
      70             :     OUString     maHeight;               ///< Height of the shape bounding box (number with unit).
      71             :     OUString     maMarginLeft;           ///< X position of the shape bounding box to shape anchor (number with unit).
      72             :     OUString     maMarginTop;            ///< Y position of the shape bounding box to shape anchor (number with unit).
      73             :     OUString     maPositionHorizontalRelative; ///< The X position is relative to this.
      74             :     OUString     maPositionVerticalRelative; ///< The Y position is relative to this.
      75             :     OUString     maPositionHorizontal;   ///< The X position orientation (default: absolute).
      76             :     OUString     maPositionVertical;     ///< The Y position orientation.
      77             :     OUString     maWidthPercent;         ///< The width in percents of the WidthRelative
      78             :     OUString     maHeightPercent;        ///< The height in percents of the HeightRelative
      79             :     OUString     maWidthRelative;        ///< To what the width is relative
      80             :     OUString     maHeightRelative;       ///< To what the height is relative
      81             :     OUString     maRotation;             ///< Rotation of the shape, in degrees.
      82             :     OUString     maFlip;                 ///< Flip type of the shape (can be "x" or "y").
      83             :     sal_Bool            mbAutoHeight;           ///< If true, the height value is a minimum value (mostly used for textboxes)
      84             :     sal_Bool            mbVisible;              ///< Visible or Hidden
      85             :     OUString     maWrapStyle;            ///< Wrapping mode for text.
      86             :     OUString     maArcsize;              ///< round rectangles arc size
      87             : 
      88             :     StrokeModel         maStrokeModel;          ///< Border line formatting.
      89             :     FillModel           maFillModel;            ///< Shape fill formatting.
      90             :     ShadowModel         maShadowModel;          ///< Shape shadow formatting.
      91             :     TextpathModel       maTextpathModel;        ///< Shape textpath formatting.
      92             : 
      93             :     OptValue< OUString > moGraphicPath;  ///< Path to a graphic for this shape.
      94             :     OptValue< OUString > moGraphicTitle; ///< Title of the graphic.
      95             :     OptValue< OUString > moWrapAnchorX;  ///< The base object from which our horizontal positioning should be calculated.
      96             :     OptValue< OUString > moWrapAnchorY;  ///< The base object from which our vertical positioning should be calculated.
      97             :     OptValue< ::rtl::OUString > moWrapType;     ///< How to wrap the text around the object
      98             :     OptValue< ::rtl::OUString > moWrapSide;     ///< On which side to wrap the text around the object
      99             :     OUString maVTextAnchor; ///< How the text inside the shape is anchored vertically.
     100             : 
     101             :     explicit            ShapeTypeModel();
     102             : 
     103             :     void                assignUsed( const ShapeTypeModel& rSource );
     104             : };
     105             : 
     106             : // ----------------------------------------------------------------------------
     107             : 
     108             : /** A shape template contains all formatting properties of shapes and can serve
     109             :     as templates for several shapes in a drawing. */
     110             : class ShapeType
     111             : {
     112             : public:
     113             :     explicit            ShapeType( Drawing& rDrawing );
     114             :     virtual             ~ShapeType();
     115             : 
     116             :     /** Returns read/write access to the shape template model structure. */
     117         137 :     inline ShapeTypeModel& getTypeModel() { return maTypeModel; }
     118             :     /** Returns read access to the shape template model structure. */
     119          32 :     inline const ShapeTypeModel& getTypeModel() const { return maTypeModel; }
     120             : 
     121             :     /** Returns the shape identifier (which is unique through the containing drawing). */
     122         110 :     inline const OUString& getShapeId() const { return maTypeModel.maShapeId; }
     123             :     /** Returns the application defined shape type. */
     124             :     sal_Int32           getShapeType() const;
     125             :     /** Returns the fragment path to the embedded graphic used by this shape. */
     126             :     OUString     getGraphicPath() const;
     127             : 
     128          36 :     const Drawing& getDrawing() const { return mrDrawing; }
     129             : 
     130             : protected:
     131             :     /** Returns the coordinate system of this shape. */
     132             :     ::com::sun::star::awt::Rectangle getCoordSystem() const;
     133             :     /** Returns the absolute shape rectangle according to the passed anchor. */
     134             :     ::com::sun::star::awt::Rectangle getRectangle( const ShapeParentAnchor* pParentAnchor ) const;
     135             :     /** Returns the absolute shape rectangle. */
     136             :     virtual ::com::sun::star::awt::Rectangle getAbsRectangle() const;
     137             :     /** Returns the rectangle relative to the parent coordinate system. */
     138             :     virtual ::com::sun::star::awt::Rectangle getRelRectangle() const;
     139             : 
     140             : protected:
     141             :     Drawing&            mrDrawing;          ///< The VML drawing page that contains this shape.
     142             :     ShapeTypeModel      maTypeModel;        ///< The model structure containing shape type data.
     143             : };
     144             : 
     145             : // ============================================================================
     146             : 
     147             : /** Excel specific shape client data (such as cell anchor). */
     148           2 : struct ClientData
     149             : {
     150             :     OUString     maAnchor;           ///< Cell anchor as comma-separated string.
     151             :     OUString     maFmlaMacro;        ///< Link to macro associated to the control.
     152             :     OUString     maFmlaPict;         ///< Target cell range of picture links.
     153             :     OUString     maFmlaLink;         ///< Link to value cell associated to the control.
     154             :     OUString     maFmlaRange;        ///< Link to cell range used as data source for the control.
     155             :     OUString     maFmlaGroup;        ///< Link to value cell associated to a group of option buttons.
     156             :     sal_Int32           mnObjType;          ///< Type of the shape.
     157             :     sal_Int32           mnTextHAlign;       ///< Horizontal text alignment.
     158             :     sal_Int32           mnTextVAlign;       ///< Vertical text alignment.
     159             :     sal_Int32           mnCol;              ///< Column index for spreadsheet cell note.
     160             :     sal_Int32           mnRow;              ///< Row index for spreadsheet cell note.
     161             :     sal_Int32           mnChecked;          ///< State for checkboxes and option buttons.
     162             :     sal_Int32           mnDropStyle;        ///< Drop down box style (read-only or editable).
     163             :     sal_Int32           mnDropLines;        ///< Number of lines in drop down box.
     164             :     sal_Int32           mnVal;              ///< Current value of spin buttons and scroll bars.
     165             :     sal_Int32           mnMin;              ///< Minimum value of spin buttons and scroll bars.
     166             :     sal_Int32           mnMax;              ///< Maximum value of spin buttons and scroll bars.
     167             :     sal_Int32           mnInc;              ///< Small increment of spin buttons and scroll bars.
     168             :     sal_Int32           mnPage;             ///< Large increment of spin buttons and scroll bars.
     169             :     sal_Int32           mnSelType;          ///< Listbox selection type.
     170             :     sal_Int32           mnVTEdit;           ///< Data type of the textbox.
     171             :     bool                mbPrintObject;      ///< True = print the object.
     172             :     bool                mbVisible;          ///< True = cell note is visible.
     173             :     bool                mbDde;              ///< True = object is linked through DDE.
     174             :     bool                mbNo3D;             ///< True = flat style, false = 3D style.
     175             :     bool                mbNo3D2;            ///< True = flat style, false = 3D style (listboxes and dropdowns).
     176             :     bool                mbMultiLine;        ///< True = textbox allows line breaks.
     177             :     bool                mbVScroll;          ///< True = textbox has a vertical scrollbar.
     178             :     bool                mbSecretEdit;       ///< True = textbox is a password edit field.
     179             : 
     180             :     explicit            ClientData();
     181             : };
     182             : 
     183             : // ----------------------------------------------------------------------------
     184             : 
     185             : struct ShapeModel
     186             : {
     187             :     typedef ::std::vector< ::com::sun::star::awt::Point >   PointVector;
     188             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     189             :     typedef ::std::auto_ptr< TextBox >                      TextBoxPtr;
     190             :     typedef ::std::auto_ptr< ClientData >                   ClientDataPtr;
     191             :     SAL_WNODEPRECATED_DECLARATIONS_POP
     192             : 
     193             :     OUString     maType;             ///< Shape template with default properties.
     194             :     PointVector         maPoints;           ///< Points for the polyline shape.
     195             :     TextBoxPtr          mxTextBox;          ///< Text contents and properties.
     196             :     ClientDataPtr       mxClientData;       ///< Excel specific client data.
     197             :     OUString     maLegacyDiagramPath;///< Legacy Diagram Fragment Path
     198             :     OUString     maFrom;             ///< Start point for line shape.
     199             :     OUString     maTo;               ///< End point for line shape.
     200             :     OUString     maControl1;         ///< Bezier control point 1
     201             :     OUString     maControl2;         ///< Bezier control point 2
     202             :     OUString     maVmlPath;          ///< VML path for this shape
     203             : 
     204             :     explicit            ShapeModel();
     205             :                         ~ShapeModel();
     206             : 
     207             :     /** Creates and returns a new shape textbox structure. */
     208             :     TextBox&            createTextBox(ShapeTypeModel& rModel);
     209             :     /** Creates and returns a new shape client data structure. */
     210             :     ClientData&         createClientData();
     211             : };
     212             : 
     213             : // ----------------------------------------------------------------------------
     214             : 
     215             : /** A shape object that is part of a drawing. May inherit properties from a
     216             :     shape template. */
     217          79 : class OOX_DLLPUBLIC ShapeBase : public ShapeType
     218             : {
     219             : public:
     220             :     /** Returns read/write access to the shape model structure. */
     221          79 :     inline ShapeModel&  getShapeModel() { return maShapeModel; }
     222             :     /** Returns read access to the shape model structure. */
     223             :     inline const ShapeModel& getShapeModel() const { return maShapeModel; }
     224             : 
     225             :     /** Returns read access to the shape textbox. */
     226         146 :     inline const TextBox* getTextBox() const { return maShapeModel.mxTextBox.get(); }
     227             :     /** Returns read access to the shape client data structure. */
     228          85 :     inline const ClientData* getClientData() const { return maShapeModel.mxClientData.get(); }
     229             : 
     230             :     /** Final processing after import of the drawing fragment. */
     231             :     virtual void        finalizeFragmentImport();
     232             : 
     233             :     /** Returns the real shape name if existing, or a generated shape name. */
     234             :     OUString     getShapeName() const;
     235             : 
     236             :     /** Returns the shape template with the passed identifier from the child shapes. */
     237             :     virtual const ShapeType* getChildTypeById( const OUString& rShapeId ) const;
     238             :     /** Returns the shape with the passed identifier from the child shapes. */
     239             :     virtual const ShapeBase* getChildById( const OUString& rShapeId ) const;
     240             : 
     241             :     /** Creates the corresponding XShape and inserts it into the passed container. */
     242             :     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     243             :                         convertAndInsert(
     244             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     245             :                             const ShapeParentAnchor* pParentAnchor = 0 ) const;
     246             : 
     247             :     /** Converts position and formatting into the passed existing XShape. */
     248             :     void                convertFormatting(
     249             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape,
     250             :                             const ShapeParentAnchor* pParentAnchor = 0 ) const;
     251             : 
     252             : protected:
     253             :     explicit            ShapeBase( Drawing& rDrawing );
     254             : 
     255             :     /** Derived classes create the corresponding XShape and insert it into the passed container. */
     256             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     257             :                         implConvertAndInsert(
     258             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     259             :                             const ::com::sun::star::awt::Rectangle& rShapeRect ) const = 0;
     260             : 
     261             :     /** Calculates the final shape rectangle according to the passed anchor,
     262             :         if present, otherwise according to the own anchor settings. */
     263             :     ::com::sun::star::awt::Rectangle calcShapeRectangle(
     264             :                             const ShapeParentAnchor* pParentAnchor ) const;
     265             : 
     266             :     /** Converts common shape properties such as formatting attributes. */
     267             :     void                convertShapeProperties(
     268             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape ) const;
     269             : 
     270             : protected:
     271             :     ShapeModel          maShapeModel;       ///< The model structure containing shape data.
     272             : };
     273             : 
     274             : // ============================================================================
     275             : 
     276             : /** A simple shape object based on a specific UNO shape service. */
     277          68 : class SimpleShape : public ShapeBase
     278             : {
     279             : public:
     280             :     explicit            SimpleShape( Drawing& rDrawing, const OUString& rService );
     281             : 
     282          23 :     void setService( OUString aService ) { maService = aService; }
     283             : 
     284             : protected:
     285             :     /** Creates the corresponding XShape and inserts it into the passed container. */
     286             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     287             :                         implConvertAndInsert(
     288             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     289             :                             const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
     290             :     /** Used by both RectangleShape and ComplexShape. */
     291             :     com::sun::star::uno::Reference<com::sun::star::drawing::XShape>createPictureObject(
     292             :             const com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rxShapes,
     293             :             const com::sun::star::awt::Rectangle& rShapeRect, OUString& rGraphicPath ) const;
     294             : 
     295             : private:
     296             :     OUString     maService;          ///< Name of the UNO shape service.
     297             : };
     298             : 
     299             : // ============================================================================
     300             : 
     301             : /** A rectangular shape object. */
     302          42 : class RectangleShape : public SimpleShape
     303             : {
     304             : public:
     305             :     explicit            RectangleShape( Drawing& rDrawing );
     306             : protected:
     307             :     /** Creates the corresponding XShape and inserts it into the passed container. */
     308             :     virtual com::sun::star::uno::Reference<com::sun::star::drawing::XShape>
     309             :                         implConvertAndInsert(
     310             :                             const com::sun::star::uno::Reference<com::sun::star::drawing::XShapes>& rxShapes,
     311             :                             const com::sun::star::awt::Rectangle& rShapeRect) const;
     312             : };
     313             : 
     314             : // ============================================================================
     315             : 
     316             : /** An oval shape object. */
     317           4 : class EllipseShape : public SimpleShape
     318             : {
     319             : public:
     320             :     explicit            EllipseShape( Drawing& rDrawing );
     321             : };
     322             : 
     323             : // ============================================================================
     324             : 
     325             : /** A polygon shape object. */
     326           0 : class PolyLineShape : public SimpleShape
     327             : {
     328             : public:
     329             :     explicit            PolyLineShape( Drawing& rDrawing );
     330             : 
     331             : protected:
     332             :     /** Creates the corresponding XShape and inserts it into the passed container. */
     333             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     334             :                         implConvertAndInsert(
     335             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     336             :                             const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
     337             : };
     338             : 
     339             : /** A Line shape object. */
     340          10 : class LineShape : public SimpleShape
     341             : {
     342             : public:
     343             :     explicit            LineShape( Drawing& rDrawing );
     344             : 
     345             : protected:
     346             :     /** Returns the absolute shape rectangle. */
     347             :     virtual ::com::sun::star::awt::Rectangle getAbsRectangle() const SAL_OVERRIDE;
     348             :     /** Returns the rectangle relative to the parent coordinate system. */
     349             :     virtual ::com::sun::star::awt::Rectangle getRelRectangle() const SAL_OVERRIDE;
     350             : };
     351             : 
     352             : /** Bezier shape object that supports to, from, control1 and control2
     353             :     attribute or path attribute specification */
     354           4 : class BezierShape : public SimpleShape
     355             : {
     356             : public:
     357             :     explicit             BezierShape( Drawing& rDrawing );
     358             : 
     359             : protected:
     360             :     /** Creates the corresponding XShape and inserts it into the passed container. */
     361             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     362             :                         implConvertAndInsert(
     363             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     364             :                             const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
     365             : };
     366             : 
     367             : // ============================================================================
     368             : 
     369             : /** A shape object with custom geometry. */
     370          38 : class CustomShape : public SimpleShape
     371             : {
     372             : public:
     373             :     explicit            CustomShape( Drawing& rDrawing );
     374             : 
     375             : protected:
     376             :     /** Creates the corresponding XShape and inserts it into the passed container. */
     377             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     378             :                         implConvertAndInsert(
     379             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     380             :                             const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
     381             : };
     382             : 
     383             : // ============================================================================
     384             : 
     385             : /** A complex shape object. This can be a picture shape, a custom shape, an OLE
     386             :     object, or an ActiveX form control. */
     387          76 : class ComplexShape : public CustomShape
     388             : {
     389             : public:
     390             :     explicit            ComplexShape( Drawing& rDrawing );
     391             : 
     392             : protected:
     393             :     /** Creates the corresponding XShape and inserts it into the passed container. */
     394             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     395             :                         implConvertAndInsert(
     396             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     397             :                             const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
     398             : };
     399             : 
     400             : // ============================================================================
     401             : 
     402             : /** A group shape that extends the basic shape by a container of child shapes. */
     403             : class GroupShape : public ShapeBase
     404             : {
     405             : public:
     406             :     explicit            GroupShape( Drawing& rDrawing );
     407             :     virtual             ~GroupShape();
     408             : 
     409             :     /** Returns read/write access to the container of child shapes and templates. */
     410          11 :     inline ShapeContainer& getChildren() { return *mxChildren; }
     411             :     /** Returns read access to the container of child shapes and templates. */
     412             :     inline const ShapeContainer& getChildren() const { return *mxChildren; }
     413             : 
     414             :     /** Final processing after import of the drawing fragment. */
     415             :     virtual void        finalizeFragmentImport();
     416             : 
     417             :     /** Returns the shape template with the passed identifier from the child shapes. */
     418             :     virtual const ShapeType* getChildTypeById( const OUString& rShapeId ) const;
     419             :     /** Returns the shape with the passed identifier from the child shapes. */
     420             :     virtual const ShapeBase* getChildById( const OUString& rShapeId ) const;
     421             : 
     422             : protected:
     423             :     /** Creates the corresponding XShape and inserts it into the passed container. */
     424             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
     425             :                         implConvertAndInsert(
     426             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
     427             :                             const ::com::sun::star::awt::Rectangle& rShapeRect ) const;
     428             : 
     429             : private:
     430             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     431             :     typedef ::std::auto_ptr< ShapeContainer > ShapeContainerPtr;
     432             :     SAL_WNODEPRECATED_DECLARATIONS_POP
     433             :     ShapeContainerPtr   mxChildren;         ///< Shapes and templates that are part of this group.
     434             : };
     435             : 
     436             : // ============================================================================
     437             : 
     438             : } // namespace vml
     439             : } // namespace oox
     440             : 
     441             : #endif
     442             : 
     443             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10