LCOV - code coverage report
Current view: top level - svx/source/sdr/contact - viewcontactofsdrobj.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 46 63 73.0 %
Date: 2014-11-03 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             : 
      38             : 
      39             : namespace sdr
      40             : {
      41             :     namespace contact
      42             :     {
      43             :         // Create a Object-Specific ViewObjectContact, set ViewContact and
      44             :         // ObjectContact. Always needs to return something.
      45       13828 :         ViewObjectContact& ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
      46             :         {
      47       13828 :             ViewObjectContact* pRetval = new ViewObjectContactOfSdrObj(rObjectContact, *this);
      48             :             DBG_ASSERT(pRetval, "ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact() failed (!)");
      49             : 
      50       13828 :             return *pRetval;
      51             :         }
      52             : 
      53       97148 :         ViewContactOfSdrObj::ViewContactOfSdrObj(SdrObject& rObj)
      54             :         :   ViewContact(),
      55             :             mrObject(rObj),
      56       97148 :             meRememberedAnimationKind(SDRTEXTANI_NONE)
      57             :         {
      58             :             // init AnimationKind
      59       97148 :             if(GetSdrObject().ISA(SdrTextObj))
      60             :             {
      61       58909 :                 SdrTextObj& rTextObj = static_cast<SdrTextObj&>(GetSdrObject());
      62       58909 :                 meRememberedAnimationKind = rTextObj.GetTextAniKind();
      63             :             }
      64       97148 :         }
      65             : 
      66       95438 :         ViewContactOfSdrObj::~ViewContactOfSdrObj()
      67             :         {
      68       95438 :         }
      69             : 
      70             :         // Access to possible sub-hierarchy
      71      301661 :         sal_uInt32 ViewContactOfSdrObj::GetObjectCount() const
      72             :         {
      73      301661 :             if(GetSdrObject().GetSubList())
      74             :             {
      75      116410 :                 return GetSdrObject().GetSubList()->GetObjCount();
      76             :             }
      77             : 
      78      185251 :             return 0L;
      79             :         }
      80             : 
      81      223472 :         ViewContact& ViewContactOfSdrObj::GetViewContact(sal_uInt32 nIndex) const
      82             :         {
      83             :             assert(GetSdrObject().GetSubList() &&
      84             :                 "ViewContactOfSdrObj::GetViewContact: Access to non-existent Sub-List (!)");
      85      223472 :             SdrObject* pObj = GetSdrObject().GetSubList()->GetObj(nIndex);
      86             :             assert(pObj && "ViewContactOfSdrObj::GetViewContact: Corrupt SdrObjList (!)");
      87      223472 :             return pObj->GetViewContact();
      88             :         }
      89             : 
      90       90554 :         ViewContact* ViewContactOfSdrObj::GetParentContact() const
      91             :         {
      92       90554 :             ViewContact* pRetval = 0L;
      93       90554 :             SdrObjList* pObjList = GetSdrObject().GetObjList();
      94             : 
      95       90554 :             if(pObjList)
      96             :             {
      97       90554 :                 if(pObjList->ISA(SdrPage))
      98             :                 {
      99             :                     // Is a page
     100       24550 :                     pRetval = &(static_cast<SdrPage*>(pObjList)->GetViewContact());
     101             :                 }
     102             :                 else
     103             :                 {
     104             :                     // Is a group?
     105       66004 :                     if(pObjList->GetOwnerObj())
     106             :                     {
     107       66004 :                         pRetval = &(pObjList->GetOwnerObj()->GetViewContact());
     108             :                     }
     109             :                 }
     110             :             }
     111             : 
     112       90554 :             return pRetval;
     113             :         }
     114             : 
     115             :         // React on changes of the object of this ViewContact
     116     1216792 :         void ViewContactOfSdrObj::ActionChanged()
     117             :         {
     118             :             // look for own changes
     119     1216792 :             if(GetSdrObject().ISA(SdrTextObj))
     120             :             {
     121      951527 :                 SdrTextObj& rTextObj = static_cast<SdrTextObj&>(GetSdrObject());
     122             : 
     123      951527 :                 if(rTextObj.GetTextAniKind() != meRememberedAnimationKind)
     124             :                 {
     125             :                     // #i38135# now remember new type
     126           0 :                     meRememberedAnimationKind = rTextObj.GetTextAniKind();
     127             :                 }
     128             :             }
     129             : 
     130             :             // call parent
     131     1216792 :             ViewContact::ActionChanged();
     132     1216792 :         }
     133             : 
     134             :         // overload for acessing the SdrObject
     135       23749 :         SdrObject* ViewContactOfSdrObj::TryToGetSdrObject() const
     136             :         {
     137       23749 :             return &GetSdrObject();
     138             :         }
     139             : 
     140             : 
     141             :         // primitive stuff
     142             : 
     143             :         // add Gluepoints (if available)
     144           0 :         drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrObj::createGluePointPrimitive2DSequence() const
     145             :         {
     146           0 :             drawinglayer::primitive2d::Primitive2DSequence xRetval;
     147           0 :             const SdrGluePointList* pGluePointList = GetSdrObject().GetGluePointList();
     148             : 
     149           0 :             if(pGluePointList)
     150             :             {
     151           0 :                 const sal_uInt32 nCount(pGluePointList->GetCount());
     152             : 
     153           0 :                 if(nCount)
     154             :                 {
     155             :                     // prepare point vector
     156           0 :                     std::vector< basegfx::B2DPoint > aGluepointVector;
     157             : 
     158             :                     // create GluePoint primitives. ATM these are relative to the SnapRect
     159           0 :                     for(sal_uInt32 a(0L); a < nCount; a++)
     160             :                     {
     161           0 :                         const SdrGluePoint& rCandidate = (*pGluePointList)[(sal_uInt16)a];
     162           0 :                         const Point aPosition(rCandidate.GetAbsolutePos(GetSdrObject()));
     163             : 
     164           0 :                         aGluepointVector.push_back(basegfx::B2DPoint(aPosition.X(), aPosition.Y()));
     165             :                     }
     166             : 
     167           0 :                     if(!aGluepointVector.empty())
     168             :                     {
     169             :                         const drawinglayer::primitive2d::Primitive2DReference xReference(
     170             :                                 new drawinglayer::primitive2d::MarkerArrayPrimitive2D(
     171           0 :                                         aGluepointVector, SdrHdl::createGluePointBitmap()));
     172           0 :                         xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
     173           0 :                     }
     174             :                 }
     175             :             }
     176             : 
     177           0 :             return xRetval;
     178             :         }
     179             : 
     180       83918 :         drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrObj::embedToObjectSpecificInformation(const drawinglayer::primitive2d::Primitive2DSequence& rSource) const
     181             :         {
     182      361808 :             if(rSource.hasElements() &&
     183      451332 :                 (!GetSdrObject().GetName().isEmpty() ||
     184      315238 :                  !GetSdrObject().GetTitle().isEmpty() ||
     185      199578 :                  !GetSdrObject().GetDescription().isEmpty()))
     186             :             {
     187             :                 const drawinglayer::primitive2d::Primitive2DReference xRef(
     188             :                     new drawinglayer::primitive2d::ObjectInfoPrimitive2D(
     189             :                         rSource,
     190       26136 :                         GetSdrObject().GetName(),
     191       26136 :                         GetSdrObject().GetTitle(),
     192       52272 :                         GetSdrObject().GetDescription()));
     193             : 
     194       26136 :                 return drawinglayer::primitive2d::Primitive2DSequence(&xRef, 1);
     195             :             }
     196             : 
     197       57782 :             return rSource;
     198             :         }
     199             : 
     200             :     } // end of namespace contact
     201         651 : } // end of namespace sdr
     202             : 
     203             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10