LCOV - code coverage report
Current view: top level - include/svx - svdglue.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 22 30 73.3 %
Date: 2015-06-13 12:38:46 Functions: 22 26 84.6 %
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_SVDGLUE_HXX
      21             : #define INCLUDED_SVX_SVDGLUE_HXX
      22             : 
      23             : namespace vcl { class Window; }
      24             : class OutputDevice;
      25             : class SvStream;
      26             : class SdrObject;
      27             : 
      28             : #include <tools/gen.hxx>
      29             : #include <svx/svxdllapi.h>
      30             : #include <vector>
      31             : #include <o3tl/typed_flags_set.hxx>
      32             : 
      33             : 
      34             : enum class SdrEscapeDirection
      35             : {
      36             :     SMART  = 0x0000,
      37             :     LEFT   = 0x0001,
      38             :     RIGHT  = 0x0002,
      39             :     TOP    = 0x0004,
      40             :     BOTTOM = 0x0008,
      41             :     HORZ   = LEFT | RIGHT,
      42             :     VERT   = TOP | BOTTOM,
      43             :     ALL    = 0x00ff,
      44             : };
      45             : namespace o3tl
      46             : {
      47             :     template<> struct typed_flags<SdrEscapeDirection> : is_typed_flags<SdrEscapeDirection, 0x00ff> {};
      48             : }
      49             : 
      50             : enum class SdrAlign
      51             : {
      52             :     NONE          = 0x0000,
      53             :     HORZ_CENTER   = 0x0000,
      54             :     HORZ_LEFT     = 0x0001,
      55             :     HORZ_RIGHT    = 0x0002,
      56             :     HORZ_DONTCARE = 0x0010,
      57             :     VERT_CENTER   = 0x0000,
      58             :     VERT_TOP      = 0x0100,
      59             :     VERT_BOTTOM   = 0x0200,
      60             :     VERT_DONTCARE = 0x1000,
      61             : };
      62             : namespace o3tl
      63             : {
      64             :     template<> struct typed_flags<SdrAlign> : is_typed_flags<SdrAlign, 0x1313> {};
      65             : }
      66             : 
      67             : class SVX_DLLPUBLIC SdrGluePoint {
      68             :     // Reference Point is SdrObject::GetSnapRect().Center()
      69             :     // bNoPercent=false: position is -5000..5000 (1/100)% or 0..10000 (depending on align)
      70             :     // bNoPercent=true : position is in log unit, relativ to the reference point
      71             :     Point    aPos;
      72             :     SdrEscapeDirection nEscDir;
      73             :     sal_uInt16   nId;
      74             :     SdrAlign     nAlign;
      75             :     bool bNoPercent:1;
      76             :     bool bReallyAbsolute:1; // temp for transformations on the reference object
      77             :     bool bUserDefined:1; // #i38892#
      78             : public:
      79         328 :     SdrGluePoint(): nEscDir(SdrEscapeDirection::SMART),nId(0),nAlign(SdrAlign::NONE),bNoPercent(false),bReallyAbsolute(false),bUserDefined(true) {}
      80         644 :     SdrGluePoint(const Point& rNewPos, bool bNewPercent=true, SdrAlign nNewAlign = SdrAlign::HORZ_CENTER): aPos(rNewPos),nEscDir(SdrEscapeDirection::SMART),nId(0),nAlign(nNewAlign),bNoPercent(!bNewPercent),bReallyAbsolute(false),bUserDefined(true) {}
      81             :     bool operator==(const SdrGluePoint& rCmpGP) const   { return aPos==rCmpGP.aPos && nEscDir==rCmpGP.nEscDir && nId==rCmpGP.nId && nAlign==rCmpGP.nAlign && bNoPercent==rCmpGP.bNoPercent && bReallyAbsolute==rCmpGP.bReallyAbsolute && bUserDefined==rCmpGP.bUserDefined; }
      82             :     bool operator!=(const SdrGluePoint& rCmpGP) const   { return !operator==(rCmpGP); }
      83        1502 :     const Point& GetPos() const                             { return aPos; }
      84         422 :     void         SetPos(const Point& rNewPos)               { aPos=rNewPos; }
      85         648 :     SdrEscapeDirection GetEscDir() const                          { return nEscDir; }
      86         216 :     void         SetEscDir(SdrEscapeDirection nNewEsc)                  { nEscDir=nNewEsc; }
      87        3030 :     sal_uInt16   GetId() const                              { return nId; }
      88         216 :     void         SetId(sal_uInt16 nNewId)                       { nId=nNewId; }
      89         648 :     bool         IsPercent() const                          { return !bNoPercent; }
      90         860 :     void         SetPercent(bool bOn)                   { bNoPercent  = !bOn; }
      91             :     // temp for transformations on the reference object
      92             :     bool         IsReallyAbsolute() const                   { return bReallyAbsolute; }
      93             :     void         SetReallyAbsolute(bool bOn, const SdrObject& rObj);
      94             : 
      95             :     // #i38892#
      96         651 :     bool         IsUserDefined() const                      { return bUserDefined; }
      97         712 :     void         SetUserDefined(bool bNew)              { bUserDefined = bNew; }
      98             : 
      99         648 :     SdrAlign     GetAlign() const                           { return nAlign; }
     100         216 :     void         SetAlign(SdrAlign nAlg)                    { nAlign=nAlg; }
     101         306 :     SdrAlign     GetHorzAlign() const                       { return nAlign & static_cast<SdrAlign>(0x00FF); }
     102           0 :     void         SetHorzAlign(SdrAlign nAlg)                { assert((nAlg & static_cast<SdrAlign>(0xff)) == SdrAlign::NONE); nAlign = SdrAlign(nAlign & static_cast<SdrAlign>(0xFF00)) | (nAlg & static_cast<SdrAlign>(0x00FF)); }
     103         306 :     SdrAlign     GetVertAlign() const                       { return nAlign & static_cast<SdrAlign>(0xFF00); }
     104           0 :     void         SetVertAlign(SdrAlign nAlg)                { assert((nAlg & static_cast<SdrAlign>(0xff00)) == SdrAlign::NONE); nAlign = SdrAlign(nAlign & static_cast<SdrAlign>(0x00FF)) | (nAlg & static_cast<SdrAlign>(0xFF00)); }
     105             :     bool         IsHit(const Point& rPnt, const OutputDevice& rOut, const SdrObject* pObj) const;
     106             :     void         Invalidate(vcl::Window& rWin, const SdrObject* pObj) const;
     107             :     Point        GetAbsolutePos(const SdrObject& rObj) const;
     108             :     void         SetAbsolutePos(const Point& rNewPos, const SdrObject& rObj);
     109             :     long         GetAlignAngle() const;
     110             :     void         SetAlignAngle(long nAngle);
     111             :     static long  EscDirToAngle(SdrEscapeDirection nEsc);
     112             :     static SdrEscapeDirection EscAngleToDir(long nAngle);
     113             :     void         Rotate(const Point& rRef, long nAngle, double sn, double cs, const SdrObject* pObj);
     114             :     void         Mirror(const Point& rRef1, const Point& rRef2, long nAngle, const SdrObject* pObj);
     115             :     void         Shear (const Point& rRef, long nAngle, double tn, bool bVShear, const SdrObject* pObj);
     116             : };
     117             : 
     118             : #define SDRGLUEPOINT_NOTFOUND 0xFFFF
     119             : 
     120             : class SVX_DLLPUBLIC SdrGluePointList {
     121             :     std::vector<SdrGluePoint*> aList;
     122             : protected:
     123        5613 :     SdrGluePoint* GetObject(sal_uInt16 i) const { return aList[i]; }
     124             : public:
     125         167 :     SdrGluePointList(): aList() {}
     126           0 :     SdrGluePointList(const SdrGluePointList& rSrcList): aList()     { *this=rSrcList; }
     127         167 :     ~SdrGluePointList()                                                     { Clear(); }
     128             :     void                Clear();
     129             :     void                operator=(const SdrGluePointList& rSrcList);
     130        4205 :     sal_uInt16          GetCount() const                                    { return sal_uInt16(aList.size()); }
     131             :     // At insert, the object (GluePoint) automatically gets an ID assigned.
     132             :     // Return value is the index of the new GluePoint in the list.
     133             :     sal_uInt16          Insert(const SdrGluePoint& rGP);
     134           0 :     void                Delete(sal_uInt16 nPos)
     135             :     {
     136           0 :         SdrGluePoint* p = aList[nPos];
     137           0 :         aList.erase(aList.begin()+nPos);
     138           0 :         delete p;
     139           0 :     }
     140         210 :     SdrGluePoint&       operator[](sal_uInt16 nPos)                             { return *GetObject(nPos); }
     141        2085 :     const SdrGluePoint& operator[](sal_uInt16 nPos) const                       { return *GetObject(nPos); }
     142             :     sal_uInt16          FindGluePoint(sal_uInt16 nId) const;
     143             :     sal_uInt16          HitTest(const Point& rPnt, const OutputDevice& rOut, const SdrObject* pObj, bool bBack = false, bool bNext = false, sal_uInt16 nId0=0) const;
     144             :     void                Invalidate(vcl::Window& rWin, const SdrObject* pObj) const;
     145             :     // temp for transformations on the reference object
     146             :     void                SetReallyAbsolute(bool bOn, const SdrObject& rObj);
     147             :     void                Rotate(const Point& rRef, long nAngle, double sn, double cs, const SdrObject* pObj);
     148             :     void                Mirror(const Point& rRef1, const Point& rRef2, const SdrObject* pObj);
     149             :     void                Mirror(const Point& rRef1, const Point& rRef2, long nAngle, const SdrObject* pObj);
     150             :     void                Shear (const Point& rRef, long nAngle, double tn, bool bVShear, const SdrObject* pObj);
     151             : };
     152             : 
     153             : 
     154             : 
     155             : 
     156             : #endif // INCLUDED_SVX_SVDGLUE_HXX
     157             : 
     158             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11