LCOV - code coverage report
Current view: top level - include/svx - svdoashp.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 3 3 100.0 %
Date: 2015-06-13 12:38:46 Functions: 7 7 100.0 %
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 INCLUDED_SVX_SVDOASHP_HXX
      21             : #define INCLUDED_SVX_SVDOASHP_HXX
      22             : 
      23             : #include <svx/svdobj.hxx>
      24             : #include <svx/svdotext.hxx>
      25             : #include <svx/svdhdl.hxx>
      26             : #include <vector>
      27             : #include <com/sun/star/uno/Reference.h>
      28             : #include <com/sun/star/drawing/XCustomShapeEngine.hpp>
      29             : #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
      30             : #include <svx/svxdllapi.h>
      31             : #include <o3tl/typed_flags_set.hxx>
      32             : 
      33             : 
      34             : //   Initial Declarations
      35             : 
      36             : 
      37             : class SdrObjList;
      38             : class SdrObjListIter;
      39             : class SfxItemSet;
      40             : 
      41             : namespace sdr
      42             : {
      43             :     namespace properties
      44             :     {
      45             :         class CustomShapeProperties;
      46             :     } // end of namespace properties
      47             : } // end of namespace sdr
      48             : 
      49        2662 : class SdrAShapeObjGeoData : public SdrTextObjGeoData
      50             : {
      51             :     public:
      52             : 
      53             :     bool        bMirroredX;
      54             :     bool        bMirroredY;
      55             :     double      fObjectRotation;
      56             : 
      57             :     com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue >
      58             :                 aAdjustmentSeq;
      59             : };
      60             : 
      61             : enum class CustomShapeHandleModes
      62             : {
      63             :     NONE                 = 0,
      64             :     RESIZE_FIXED         = 1,
      65             :     CREATE_FIXED         = 2,
      66             :     RESIZE_ABSOLUTE_X    = 4,
      67             :     RESIZE_ABSOLUTE_Y    = 8,
      68             :     MOVE_SHAPE           = 16,
      69             :     ORTHO4               = 32,
      70             : };
      71             : namespace o3tl
      72             : {
      73             :     template<> struct typed_flags<CustomShapeHandleModes> : is_typed_flags<CustomShapeHandleModes, 63> {};
      74             : }
      75             : 
      76         356 : struct SdrCustomShapeInteraction
      77             : {
      78             :     com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeHandle >   xInteraction;
      79             :     com::sun::star::awt::Point                                                      aPosition;
      80             :     CustomShapeHandleModes                                                          nMode;
      81             : };
      82             : 
      83             : 
      84             : //   SdrObjCustomShape
      85             : 
      86             : 
      87             : class SVX_DLLPUBLIC SdrObjCustomShape : public SdrTextObj
      88             : {
      89             : private:
      90             :     // fObjectRotation is containing the object rotation in degrees.
      91             :     double fObjectRotation;
      92             : 
      93             : protected:
      94             :     virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() SAL_OVERRIDE;
      95             :     virtual void impl_setUnoShape(const com::sun::star::uno::Reference<com::sun::star::uno::XInterface>& rxUnoShape) SAL_OVERRIDE;
      96             : 
      97             : public:
      98             :     virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties() SAL_OVERRIDE;
      99             : 
     100             :     // to allow sdr::properties::CustomShapeProperties access
     101             :     friend class sdr::properties::CustomShapeProperties;
     102             : 
     103             :     com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mXRenderedCustomShape;
     104             : 
     105             :     mutable com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeEngine > mxCustomShapeEngine;
     106             : 
     107             :     // #i37011# render geometry shadow
     108             :     SdrObject*                                          mpLastShadowGeometry;
     109             : 
     110             :     com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeEngine > GetCustomShapeEngine() const;
     111             : 
     112             : //  SVX_DLLPRIVATE com::sun::star::uno::Sequence< com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeHandle > >
     113             : //      SdrObjCustomShape::GetInteraction( const SdrObjCustomShape* pCustomShape ) const;
     114             : // #i47293#
     115             : //  SVX_DLLPRIVATE std::vector< com::sun::star::uno::Reference< com::sun::star::drawing::XCustomShapeHandle > > GetFixedInteractionHandle() const;
     116             : 
     117             :     SVX_DLLPRIVATE std::vector< SdrCustomShapeInteraction > GetInteractionHandles() const;
     118             : 
     119             :     SVX_DLLPRIVATE void DragCreateObject( SdrDragStat& rDrag );
     120             : 
     121             :     SVX_DLLPRIVATE void DragResizeCustomShape( const Rectangle& rNewRect );
     122             :     SVX_DLLPRIVATE void DragMoveCustomShapeHdl( const Point& rDestination,
     123             :             const sal_uInt16 nCustomShapeHdlNum, bool bMoveCalloutRectangle );
     124             : 
     125             :     // #i37011# centralize throw-away of render geometry
     126             :     void InvalidateRenderGeometry();
     127             : 
     128             :     // #i38892#
     129             :     void ImpCheckCustomGluePointsAreAdded();
     130             : 
     131             :     // returns the new text rect that corresponds to the current logic rect, the return value can be empty if nothing changed.
     132             :     Rectangle ImpCalculateTextFrame( const bool bHgt, const bool bWdt );
     133             : 
     134             : public:
     135             :     // #i37011#
     136             :     const SdrObject* GetSdrObjectFromCustomShape() const;
     137             :     const SdrObject* GetSdrObjectShadowFromCustomShape() const;
     138             :     bool GetTextBounds( Rectangle& rTextBound ) const;
     139             :     bool IsTextPath() const;
     140             :     basegfx::B2DPolyPolygon GetLineGeometry( const bool bBezierAllowed ) const;
     141             : 
     142             : protected:
     143             :     // #115391# new method for SdrObjCustomShape and SdrTextObj to correctly handle and set
     144             :     // SdrTextMinFrameWidthItem and SdrTextMinFrameHeightItem based on all settings, necessities
     145             :     // and object sizes
     146             :     virtual void AdaptTextMinSize() SAL_OVERRIDE;
     147             : 
     148             :     OUString      aName;
     149             :     Size          m_aSuggestedTextFrameSize;
     150             : 
     151             : public:
     152             : 
     153             :     bool UseNoFillStyle() const;
     154             : 
     155             :     bool IsMirroredX() const;
     156             :     bool IsMirroredY() const;
     157             :     bool IsPostRotate() const;
     158             :     void SetMirroredX( const bool bMirroredX );
     159             :     void SetMirroredY( const bool bMirroredY );
     160             : 
     161       23723 :     double GetObjectRotation() const { return fObjectRotation;}
     162             :     double GetExtraTextRotation( const bool bPreRotation = false ) const;
     163             : 
     164             :     TYPEINFO_OVERRIDE();
     165             :     SdrObjCustomShape();
     166             :     virtual ~SdrObjCustomShape();
     167             : 
     168             :     /* is merging default attributes from type-shype into the SdrCustomShapeGeometryItem. If pType
     169             :     is NULL then the type is being taken from the "Type" property of the SdrCustomShapeGeometryItem.
     170             :     MergeDefaultAttributes is called when creating CustomShapes via UI and after importing */
     171             :     void MergeDefaultAttributes( const OUString* pType = NULL );
     172             : 
     173             :     /* the method is checking if the geometry data is unchanged/default, in this case the data might not be stored */
     174             :     enum DefaultType
     175             :     {
     176             :         DEFAULT_PATH,
     177             :         DEFAULT_VIEWBOX,
     178             :         DEFAULT_SEGMENTS,
     179             :         DEFAULT_GLUEPOINTS,
     180             :         DEFAULT_STRETCHX,
     181             :         DEFAULT_STRETCHY,
     182             :         DEFAULT_EQUATIONS,
     183             :         DEFAULT_HANDLES,
     184             :         DEFAULT_TEXTFRAMES
     185             :     };
     186             :     bool IsDefaultGeometry( const DefaultType eDefaultType ) const;
     187             : 
     188             :     virtual sal_uInt16 GetObjIdentifier() const SAL_OVERRIDE;
     189             :     virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const SAL_OVERRIDE;
     190             : 
     191             :     virtual void SetModel(SdrModel* pNewModel) SAL_OVERRIDE;
     192             : 
     193             :     virtual void RecalcSnapRect() SAL_OVERRIDE;
     194             : 
     195             :     virtual const Rectangle& GetSnapRect()  const SAL_OVERRIDE;
     196             :     virtual const Rectangle& GetCurrentBoundRect() const SAL_OVERRIDE;
     197             :     virtual const Rectangle& GetLogicRect() const SAL_OVERRIDE;
     198             : 
     199             :     virtual void Move(const Size& rSiz) SAL_OVERRIDE;
     200             :     virtual void Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bUnsetRelative = true) SAL_OVERRIDE;
     201             :     virtual void Shear(const Point& rRef, long nAngle, double tn, bool bVShear) SAL_OVERRIDE;
     202             :     virtual void SetSnapRect(const Rectangle& rRect) SAL_OVERRIDE;
     203             :     virtual void SetLogicRect(const Rectangle& rRect) SAL_OVERRIDE;
     204             : 
     205             :     virtual void NbcMove(const Size& rSiz) SAL_OVERRIDE;
     206             :     virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE;
     207             :     virtual void NbcRotate(const Point& rRef, long nAngle, double sn, double cs) SAL_OVERRIDE;
     208             :     virtual void NbcMirror(const Point& rRef1, const Point& rRef2) SAL_OVERRIDE;
     209             :     virtual void NbcShear(const Point& rRef, long nAngle, double tn, bool bVShear) SAL_OVERRIDE;
     210             :     virtual void NbcSetSnapRect(const Rectangle& rRect) SAL_OVERRIDE;
     211             :     virtual void NbcSetLogicRect(const Rectangle& rRect) SAL_OVERRIDE;
     212             : 
     213             :     virtual SdrGluePoint GetVertexGluePoint(sal_uInt16 nNum) const SAL_OVERRIDE;
     214             : 
     215             :     virtual void NbcSetStyleSheet( SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr ) SAL_OVERRIDE;
     216             : 
     217             :     // special drag methods
     218             :     virtual bool hasSpecialDrag() const SAL_OVERRIDE;
     219             :     virtual bool beginSpecialDrag(SdrDragStat& rDrag) const SAL_OVERRIDE;
     220             :     virtual bool applySpecialDrag(SdrDragStat& rDrag) SAL_OVERRIDE;
     221             : 
     222             :     virtual bool BegCreate( SdrDragStat& rStat ) SAL_OVERRIDE;
     223             :     virtual bool MovCreate(SdrDragStat& rStat) SAL_OVERRIDE; // #i37448#
     224             :     virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) SAL_OVERRIDE;
     225             : 
     226             :     /**
     227             :      * Allows suggesting the text frame size: in case the application has its
     228             :      * own text associated to the shape, instead of using the shape's editeng
     229             :      * text.
     230             :      */
     231             :     void SuggestTextFrameSize(Size aSuggestedTextFrameSize);
     232             :     virtual bool AdjustTextFrameWidthAndHeight(Rectangle& rR, bool bHgt = true, bool bWdt = true) const SAL_OVERRIDE;
     233             :     virtual bool NbcAdjustTextFrameWidthAndHeight(bool bHgt = true, bool bWdt = true) SAL_OVERRIDE;
     234             :     virtual bool AdjustTextFrameWidthAndHeight(bool bHgt = true, bool bWdt = true) SAL_OVERRIDE;
     235             :     virtual bool IsAutoGrowHeight() const SAL_OVERRIDE;
     236             :     virtual bool IsAutoGrowWidth() const SAL_OVERRIDE;
     237             :     virtual void SetVerticalWriting( bool bVertical ) SAL_OVERRIDE;
     238             :     virtual bool BegTextEdit( SdrOutliner& rOutl ) SAL_OVERRIDE;
     239             :     virtual void TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const SAL_OVERRIDE;
     240             :     virtual void EndTextEdit( SdrOutliner& rOutl ) SAL_OVERRIDE;
     241             :     virtual void TakeTextAnchorRect( Rectangle& rAnchorRect ) const SAL_OVERRIDE;
     242             :     virtual void TakeTextRect( SdrOutliner& rOutliner, Rectangle& rTextRect, bool bNoEditText = false,
     243             :         Rectangle* pAnchorRect=NULL, bool bLineWidth = true ) const SAL_OVERRIDE;
     244             :     virtual SdrObjCustomShape* Clone() const SAL_OVERRIDE;
     245             :     SdrObjCustomShape& operator=(const SdrObjCustomShape& rObj);
     246             : 
     247             :     virtual OUString TakeObjNameSingul() const SAL_OVERRIDE;
     248             :     virtual OUString TakeObjNamePlural() const SAL_OVERRIDE;
     249             : 
     250             :     virtual basegfx::B2DPolyPolygon TakeCreatePoly( const SdrDragStat& rDrag) const SAL_OVERRIDE;
     251             : 
     252             :     virtual basegfx::B2DPolyPolygon TakeXorPoly() const SAL_OVERRIDE;
     253             :     virtual basegfx::B2DPolyPolygon TakeContour() const SAL_OVERRIDE;
     254             : 
     255             :     virtual void NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject) SAL_OVERRIDE;
     256             : 
     257             :     virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const SAL_OVERRIDE;
     258             : 
     259             :     virtual void SetPage( SdrPage* pNewPage ) SAL_OVERRIDE;
     260             : 
     261             :     virtual SdrObjGeoData *NewGeoData() const SAL_OVERRIDE;
     262             :     virtual void          SaveGeoData(SdrObjGeoData &rGeo) const SAL_OVERRIDE;
     263             :     virtual void          RestGeoData(const SdrObjGeoData &rGeo) SAL_OVERRIDE;
     264             : 
     265             :     // need to take fObjectRotation instead of aGeo.nAngle, replace it temporary
     266             :     virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const SAL_OVERRIDE;
     267             :     virtual void TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon) SAL_OVERRIDE;
     268             : 
     269             :     virtual const SdrGluePointList* GetGluePointList() const SAL_OVERRIDE;
     270             :     //virtual SdrGluePointList* GetGluePointList();
     271             :     virtual SdrGluePointList* ForceGluePointList() SAL_OVERRIDE;
     272             : 
     273             :     virtual sal_uInt32 GetHdlCount() const SAL_OVERRIDE;
     274             :     virtual SdrHdl* GetHdl( sal_uInt32 nHdlNum ) const SAL_OVERRIDE;
     275             : 
     276             :     // #i33136#
     277             :     static bool doConstructOrthogonal(const OUString& rName);
     278             : 
     279             :     using SdrTextObj::NbcSetOutlinerParaObject;
     280             : 
     281             :     OUString GetCustomShapeName();
     282             : };
     283             : 
     284             : #endif // INCLUDED_SVX_SVDOASHP_HXX
     285             : 
     286             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11