LCOV - code coverage report
Current view: top level - svx/source/sdr/contact - viewcontactofsdrobj.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 35 52 67.3 %
Date: 2012-08-25 Functions: 8 10 80.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 16 58 27.6 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <svx/sdr/contact/viewcontactofsdrobj.hxx>
      30                 :            : #include <svx/sdr/contact/viewobjectcontactofsdrobj.hxx>
      31                 :            : #include <svx/sdr/contact/viewobjectcontact.hxx>
      32                 :            : #include <svx/svdobj.hxx>
      33                 :            : #include <svx/sdr/contact/displayinfo.hxx>
      34                 :            : #include <vcl/outdev.hxx>
      35                 :            : #include <svx/svdoole2.hxx>
      36                 :            : #include <svx/svdpage.hxx>
      37                 :            : #include <svx/sdr/contact/objectcontact.hxx>
      38                 :            : #include <basegfx/color/bcolor.hxx>
      39                 :            : #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx>
      40                 :            : #include <svx/sdr/contact/objectcontactofpageview.hxx>
      41                 :            : #include <svx/sdrpagewindow.hxx>
      42                 :            : #include <svx/sdrpaintwindow.hxx>
      43                 :            : #include <svx/svdhdl.hxx>
      44                 :            : 
      45                 :            : //////////////////////////////////////////////////////////////////////////////
      46                 :            : 
      47                 :            : namespace sdr
      48                 :            : {
      49                 :            :     namespace contact
      50                 :            :     {
      51                 :            :         // Create a Object-Specific ViewObjectContact, set ViewContact and
      52                 :            :         // ObjectContact. Always needs to return something.
      53                 :      38640 :         ViewObjectContact& ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
      54                 :            :         {
      55         [ +  - ]:      38640 :             ViewObjectContact* pRetval = new ViewObjectContactOfSdrObj(rObjectContact, *this);
      56                 :            :             DBG_ASSERT(pRetval, "ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact() failed (!)");
      57                 :            : 
      58                 :      38640 :             return *pRetval;
      59                 :            :         }
      60                 :            : 
      61                 :      96230 :         ViewContactOfSdrObj::ViewContactOfSdrObj(SdrObject& rObj)
      62                 :            :         :   ViewContact(),
      63                 :            :             mrObject(rObj),
      64                 :      96230 :             meRememberedAnimationKind(SDRTEXTANI_NONE)
      65                 :            :         {
      66                 :            :             // init AnimationKind
      67 [ +  - ][ +  + ]:      96230 :             if(GetSdrObject().ISA(SdrTextObj))
                 [ +  - ]
      68                 :            :             {
      69                 :      57404 :                 SdrTextObj& rTextObj = (SdrTextObj&)GetSdrObject();
      70         [ +  - ]:      57404 :                 meRememberedAnimationKind = rTextObj.GetTextAniKind();
      71                 :            :             }
      72                 :      96230 :         }
      73                 :            : 
      74                 :      95977 :         ViewContactOfSdrObj::~ViewContactOfSdrObj()
      75                 :            :         {
      76         [ -  + ]:      95977 :         }
      77                 :            : 
      78                 :            :         // Access to possible sub-hierarchy
      79                 :     429806 :         sal_uInt32 ViewContactOfSdrObj::GetObjectCount() const
      80                 :            :         {
      81         [ +  + ]:     429806 :             if(GetSdrObject().GetSubList())
      82                 :            :             {
      83                 :     186191 :                 return GetSdrObject().GetSubList()->GetObjCount();
      84                 :            :             }
      85                 :            : 
      86                 :     429806 :             return 0L;
      87                 :            :         }
      88                 :            : 
      89                 :     358615 :         ViewContact& ViewContactOfSdrObj::GetViewContact(sal_uInt32 nIndex) const
      90                 :            :         {
      91                 :            :             DBG_ASSERT(GetSdrObject().GetSubList(),
      92                 :            :                 "ViewContactOfSdrObj::GetViewContact: Access to non-existent Sub-List (!)");
      93                 :     358615 :             SdrObject* pObj = GetSdrObject().GetSubList()->GetObj(nIndex);
      94                 :            :             DBG_ASSERT(pObj, "ViewContactOfSdrObj::GetViewContact: Corrupt SdrObjList (!)");
      95                 :     358615 :             return pObj->GetViewContact();
      96                 :            :         }
      97                 :            : 
      98                 :      93067 :         ViewContact* ViewContactOfSdrObj::GetParentContact() const
      99                 :            :         {
     100                 :      93067 :             ViewContact* pRetval = 0L;
     101                 :      93067 :             SdrObjList* pObjList = GetSdrObject().GetObjList();
     102                 :            : 
     103         [ +  - ]:      93067 :             if(pObjList)
     104                 :            :             {
     105         [ +  + ]:      93067 :                 if(pObjList->ISA(SdrPage))
     106                 :            :                 {
     107                 :            :                     // Is a page
     108                 :       4153 :                     pRetval = &(((SdrPage*)pObjList)->GetViewContact());
     109                 :            :                 }
     110                 :            :                 else
     111                 :            :                 {
     112                 :            :                     // Is a group?
     113         [ +  - ]:      88914 :                     if(pObjList->GetOwnerObj())
     114                 :            :                     {
     115                 :      88914 :                         pRetval = &(pObjList->GetOwnerObj()->GetViewContact());
     116                 :            :                     }
     117                 :            :                 }
     118                 :            :             }
     119                 :            : 
     120                 :      93067 :             return pRetval;
     121                 :            :         }
     122                 :            : 
     123                 :            :         // React on changes of the object of this ViewContact
     124                 :     794691 :         void ViewContactOfSdrObj::ActionChanged()
     125                 :            :         {
     126                 :            :             // look for own changes
     127         [ +  + ]:     794691 :             if(GetSdrObject().ISA(SdrTextObj))
     128                 :            :             {
     129                 :     479471 :                 SdrTextObj& rTextObj = (SdrTextObj&)GetSdrObject();
     130                 :            : 
     131         [ -  + ]:     479471 :                 if(rTextObj.GetTextAniKind() != meRememberedAnimationKind)
     132                 :            :                 {
     133                 :            :                     // #i38135# now remember new type
     134                 :          0 :                     meRememberedAnimationKind = rTextObj.GetTextAniKind();
     135                 :            :                 }
     136                 :            :             }
     137                 :            : 
     138                 :            :             // call parent
     139                 :     794691 :             ViewContact::ActionChanged();
     140                 :     794691 :         }
     141                 :            : 
     142                 :            :         // overload for acessing the SdrObject
     143                 :      33070 :         SdrObject* ViewContactOfSdrObj::TryToGetSdrObject() const
     144                 :            :         {
     145                 :      33070 :             return &GetSdrObject();
     146                 :            :         }
     147                 :            : 
     148                 :            :         //////////////////////////////////////////////////////////////////////////////
     149                 :            :         // primitive stuff
     150                 :            : 
     151                 :            :         // add Gluepoints (if available)
     152                 :          0 :         drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrObj::createGluePointPrimitive2DSequence() const
     153                 :            :         {
     154                 :          0 :             drawinglayer::primitive2d::Primitive2DSequence xRetval;
     155         [ #  # ]:          0 :             const SdrGluePointList* pGluePointList = GetSdrObject().GetGluePointList();
     156                 :            : 
     157         [ #  # ]:          0 :             if(pGluePointList)
     158                 :            :             {
     159                 :          0 :                 const sal_uInt32 nCount(pGluePointList->GetCount());
     160                 :            : 
     161         [ #  # ]:          0 :                 if(nCount)
     162                 :            :                 {
     163                 :            :                     // prepare point vector
     164         [ #  # ]:          0 :                     std::vector< basegfx::B2DPoint > aGluepointVector;
     165                 :            : 
     166                 :            :                     // create GluePoint primitives. ATM these are relative to the SnapRect
     167         [ #  # ]:          0 :                     for(sal_uInt32 a(0L); a < nCount; a++)
     168                 :            :                     {
     169         [ #  # ]:          0 :                         const SdrGluePoint& rCandidate = (*pGluePointList)[(sal_uInt16)a];
     170         [ #  # ]:          0 :                         const Point aPosition(rCandidate.GetAbsolutePos(GetSdrObject()));
     171                 :            : 
     172         [ #  # ]:          0 :                         aGluepointVector.push_back(basegfx::B2DPoint(aPosition.X(), aPosition.Y()));
     173                 :            :                     }
     174                 :            : 
     175         [ #  # ]:          0 :                     if(!aGluepointVector.empty())
     176                 :            :                     {
     177                 :            :                         const drawinglayer::primitive2d::Primitive2DReference xReference(
     178                 :            :                                 new drawinglayer::primitive2d::MarkerArrayPrimitive2D(
     179 [ #  # ][ #  # ]:          0 :                                         aGluepointVector, SdrHdl::createGluePointBitmap()));
         [ #  # ][ #  # ]
                 [ #  # ]
     180 [ #  # ][ #  # ]:          0 :                         xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
                 [ #  # ]
     181                 :          0 :                     }
     182                 :            :                 }
     183                 :            :             }
     184                 :            : 
     185                 :          0 :             return xRetval;
     186                 :            :         }
     187                 :            :     } // end of namespace contact
     188                 :            : } // end of namespace sdr
     189                 :            : 
     190                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10