LCOV - code coverage report
Current view: top level - svx/source/sdr/contact - viewcontactofsdrobj.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 46 63 73.0 %
Date: 2015-06-13 12:38:46 Functions: 11 13 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             : #include <svx/sdr/contact/viewcontactofsdrobj.hxx>
      21             : #include <svx/sdr/contact/viewobjectcontactofsdrobj.hxx>
      22             : #include <svx/sdr/contact/viewobjectcontact.hxx>
      23             : #include <svx/svdobj.hxx>
      24             : #include <svx/sdr/contact/displayinfo.hxx>
      25             : #include <vcl/outdev.hxx>
      26             : #include <svx/svdoole2.hxx>
      27             : #include <svx/svdpage.hxx>
      28             : #include <svx/sdr/contact/objectcontact.hxx>
      29             : #include <basegfx/color/bcolor.hxx>
      30             : #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx>
      31             : #include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx>
      32             : #include <sdr/contact/objectcontactofpageview.hxx>
      33             : #include <svx/sdrpagewindow.hxx>
      34             : #include <svx/sdrpaintwindow.hxx>
      35             : #include <svx/svdhdl.hxx>
      36             : 
      37             : namespace sdr { namespace contact {
      38             : 
      39             : // Create a Object-Specific ViewObjectContact, set ViewContact and
      40             : // ObjectContact. Always needs to return something.
      41       32500 : ViewObjectContact& ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
      42             : {
      43       32500 :     ViewObjectContact* pRetval = new ViewObjectContactOfSdrObj(rObjectContact, *this);
      44             :     DBG_ASSERT(pRetval, "ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact() failed (!)");
      45             : 
      46       32500 :     return *pRetval;
      47             : }
      48             : 
      49      115627 : ViewContactOfSdrObj::ViewContactOfSdrObj(SdrObject& rObj)
      50             : :   ViewContact(),
      51             :     mrObject(rObj),
      52      115627 :     meRememberedAnimationKind(SDRTEXTANI_NONE)
      53             : {
      54             :     // init AnimationKind
      55      115627 :     if(GetSdrObject().ISA(SdrTextObj))
      56             :     {
      57       67895 :         SdrTextObj& rTextObj = static_cast<SdrTextObj&>(GetSdrObject());
      58       67895 :         meRememberedAnimationKind = rTextObj.GetTextAniKind();
      59             :     }
      60      115627 : }
      61             : 
      62      114443 : ViewContactOfSdrObj::~ViewContactOfSdrObj()
      63             : {
      64      114443 : }
      65             : 
      66             : // Access to possible sub-hierarchy
      67      458721 : sal_uInt32 ViewContactOfSdrObj::GetObjectCount() const
      68             : {
      69      458721 :     if(GetSdrObject().GetSubList())
      70             :     {
      71      190978 :         return GetSdrObject().GetSubList()->GetObjCount();
      72             :     }
      73             : 
      74      267743 :     return 0L;
      75             : }
      76             : 
      77      364005 : ViewContact& ViewContactOfSdrObj::GetViewContact(sal_uInt32 nIndex) const
      78             : {
      79             :     assert(GetSdrObject().GetSubList() &&
      80             :         "ViewContactOfSdrObj::GetViewContact: Access to non-existent Sub-List (!)");
      81      364005 :     SdrObject* pObj = GetSdrObject().GetSubList()->GetObj(nIndex);
      82             :     assert(pObj && "ViewContactOfSdrObj::GetViewContact: Corrupt SdrObjList (!)");
      83      364005 :     return pObj->GetViewContact();
      84             : }
      85             : 
      86      111933 : ViewContact* ViewContactOfSdrObj::GetParentContact() const
      87             : {
      88      111933 :     ViewContact* pRetval = 0L;
      89      111933 :     SdrObjList* pObjList = GetSdrObject().GetObjList();
      90             : 
      91      111933 :     if(pObjList)
      92             :     {
      93      111933 :         if(pObjList->ISA(SdrPage))
      94             :         {
      95             :             // Is a page
      96       17053 :             pRetval = &(static_cast<SdrPage*>(pObjList)->GetViewContact());
      97             :         }
      98             :         else
      99             :         {
     100             :             // Is a group?
     101       94880 :             if(pObjList->GetOwnerObj())
     102             :             {
     103       94880 :                 pRetval = &(pObjList->GetOwnerObj()->GetViewContact());
     104             :             }
     105             :         }
     106             :     }
     107             : 
     108      111933 :     return pRetval;
     109             : }
     110             : 
     111             : // React on changes of the object of this ViewContact
     112     1350475 : void ViewContactOfSdrObj::ActionChanged()
     113             : {
     114             :     // look for own changes
     115     1350475 :     if(GetSdrObject().ISA(SdrTextObj))
     116             :     {
     117      975623 :         SdrTextObj& rTextObj = static_cast<SdrTextObj&>(GetSdrObject());
     118             : 
     119      975623 :         if(rTextObj.GetTextAniKind() != meRememberedAnimationKind)
     120             :         {
     121             :             // #i38135# now remember new type
     122           0 :             meRememberedAnimationKind = rTextObj.GetTextAniKind();
     123             :         }
     124             :     }
     125             : 
     126             :     // call parent
     127     1350475 :     ViewContact::ActionChanged();
     128     1350475 : }
     129             : 
     130             : // override for acessing the SdrObject
     131       34175 : SdrObject* ViewContactOfSdrObj::TryToGetSdrObject() const
     132             : {
     133       34175 :     return &GetSdrObject();
     134             : }
     135             : 
     136             : 
     137             : // primitive stuff
     138             : 
     139             : // add Gluepoints (if available)
     140           0 : drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrObj::createGluePointPrimitive2DSequence() const
     141             : {
     142           0 :     drawinglayer::primitive2d::Primitive2DSequence xRetval;
     143           0 :     const SdrGluePointList* pGluePointList = GetSdrObject().GetGluePointList();
     144             : 
     145           0 :     if(pGluePointList)
     146             :     {
     147           0 :         const sal_uInt32 nCount(pGluePointList->GetCount());
     148             : 
     149           0 :         if(nCount)
     150             :         {
     151             :             // prepare point vector
     152           0 :             std::vector< basegfx::B2DPoint > aGluepointVector;
     153             : 
     154             :             // create GluePoint primitives. ATM these are relative to the SnapRect
     155           0 :             for(sal_uInt32 a(0L); a < nCount; a++)
     156             :             {
     157           0 :                 const SdrGluePoint& rCandidate = (*pGluePointList)[(sal_uInt16)a];
     158           0 :                 const Point aPosition(rCandidate.GetAbsolutePos(GetSdrObject()));
     159             : 
     160           0 :                 aGluepointVector.push_back(basegfx::B2DPoint(aPosition.X(), aPosition.Y()));
     161             :             }
     162             : 
     163           0 :             if(!aGluepointVector.empty())
     164             :             {
     165             :                 const drawinglayer::primitive2d::Primitive2DReference xReference(
     166             :                         new drawinglayer::primitive2d::MarkerArrayPrimitive2D(
     167           0 :                                 aGluepointVector, SdrHdl::createGluePointBitmap()));
     168           0 :                 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
     169           0 :             }
     170             :         }
     171             :     }
     172             : 
     173           0 :     return xRetval;
     174             : }
     175             : 
     176      102909 : drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrObj::embedToObjectSpecificInformation(const drawinglayer::primitive2d::Primitive2DSequence& rSource) const
     177             : {
     178      452706 :     if(rSource.hasElements() &&
     179      535434 :         (!GetSdrObject().GetName().isEmpty() ||
     180      350505 :          !GetSdrObject().GetTitle().isEmpty() ||
     181      226707 :          !GetSdrObject().GetDescription().isEmpty()))
     182             :     {
     183             :         const drawinglayer::primitive2d::Primitive2DReference xRef(
     184             :             new drawinglayer::primitive2d::ObjectInfoPrimitive2D(
     185             :                 rSource,
     186       41070 :                 GetSdrObject().GetName(),
     187       41070 :                 GetSdrObject().GetTitle(),
     188       82140 :                 GetSdrObject().GetDescription()));
     189             : 
     190       41070 :         return drawinglayer::primitive2d::Primitive2DSequence(&xRef, 1);
     191             :     }
     192             : 
     193       61839 :     return rSource;
     194             : }
     195             : 
     196         435 : }}
     197             : 
     198             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11