LCOV - code coverage report
Current view: top level - svx/source/sdr/contact - viewcontactofsdrmediaobj.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 10 48 20.8 %
Date: 2015-06-13 12:38:46 Functions: 6 11 54.5 %
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             : 
      21             : #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
      22             : #include <svx/svdomedia.hxx>
      23             : #include <sdr/contact/viewobjectcontactofsdrmediaobj.hxx>
      24             : #include <drawinglayer/primitive2d/mediaprimitive2d.hxx>
      25             : #include <avmedia/mediawindow.hxx>
      26             : 
      27             : namespace sdr { namespace contact {
      28             : 
      29           7 : ViewContactOfSdrMediaObj::ViewContactOfSdrMediaObj( SdrMediaObj& rMediaObj ) :
      30           7 :     ViewContactOfSdrObj( rMediaObj )
      31             : {
      32           7 : }
      33             : 
      34          14 : ViewContactOfSdrMediaObj::~ViewContactOfSdrMediaObj()
      35             : {
      36          14 : }
      37             : 
      38           0 : ViewObjectContact& ViewContactOfSdrMediaObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
      39             : {
      40           0 :     return *( new ViewObjectContactOfSdrMediaObj( rObjectContact, *this, static_cast< SdrMediaObj& >( GetSdrObject() ).getMediaProperties() ) );
      41             : }
      42             : 
      43           0 : Size ViewContactOfSdrMediaObj::getPreferredSize() const
      44             : {
      45             :     // #i71805# Since we may have a whole bunch of VOCs here, make a loop
      46             :     // return first useful size -> the size from the first which is visualized as a window
      47           0 :     const sal_uInt32 nCount(getViewObjectContactCount());
      48             : 
      49           0 :     for(sal_uInt32 a(0); a < nCount; a++)
      50             :     {
      51           0 :         ViewObjectContact* pCandidate = getViewObjectContact(a);
      52           0 :         Size aSize(pCandidate ? static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->getPreferredSize() : Size());
      53             : 
      54           0 :         if(0 != aSize.getWidth() || 0 != aSize.getHeight())
      55             :         {
      56           0 :             return aSize;
      57             :         }
      58             :     }
      59             : 
      60           0 :     return Size();
      61             : }
      62             : 
      63           0 : void ViewContactOfSdrMediaObj::updateMediaItem( ::avmedia::MediaItem& rItem ) const
      64             : {
      65             :     // #i71805# Since we may have a whole bunch of VOCs here, make a loop
      66           0 :     const sal_uInt32 nCount(getViewObjectContactCount());
      67             : 
      68           0 :     for(sal_uInt32 a(0); a < nCount; a++)
      69             :     {
      70           0 :         ViewObjectContact* pCandidate = getViewObjectContact(a);
      71             : 
      72           0 :         if(pCandidate)
      73             :         {
      74           0 :             static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->updateMediaItem(rItem);
      75             :         }
      76             :     }
      77           0 : }
      78             : 
      79          46 : void ViewContactOfSdrMediaObj::executeMediaItem( const ::avmedia::MediaItem& rItem )
      80             : {
      81          46 :     const sal_uInt32 nCount(getViewObjectContactCount());
      82             : 
      83          46 :     for(sal_uInt32 a(0); a < nCount; a++)
      84             :     {
      85           0 :         ViewObjectContact* pCandidate = getViewObjectContact(a);
      86             : 
      87           0 :         if(pCandidate)
      88             :         {
      89           0 :             static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->executeMediaItem(rItem);
      90             :         }
      91             :     }
      92          46 : }
      93             : 
      94           0 : void ViewContactOfSdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewState )
      95             : {
      96           0 :     static_cast< SdrMediaObj& >(GetSdrObject()).mediaPropertiesChanged(rNewState);
      97           0 : }
      98             : 
      99           0 : drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrMediaObj::createViewIndependentPrimitive2DSequence() const
     100             : {
     101             :     // create range using the model data directly. This is in SdrTextObj::aRect which i will access using
     102             :     // GetGeoRect() to not trigger any calculations. It's the unrotated geometry which is okay for MediaObjects ATM.
     103           0 :     Rectangle aRectangle(GetSdrMediaObj().GetGeoRect());
     104             :     // Hack for calc, transform position of object according
     105             :     // to current zoom so as objects relative position to grid
     106             :     // appears stable
     107           0 :     aRectangle += GetSdrMediaObj().GetGridOffset();
     108             :     const basegfx::B2DRange aRange(
     109           0 :         aRectangle.Left(), aRectangle.Top(),
     110           0 :         aRectangle.Right(), aRectangle.Bottom());
     111             : 
     112             :     // create object transform
     113           0 :     basegfx::B2DHomMatrix aTransform;
     114           0 :     aTransform.set(0, 0, aRange.getWidth());
     115           0 :     aTransform.set(1, 1, aRange.getHeight());
     116           0 :     aTransform.set(0, 2, aRange.getMinX());
     117           0 :     aTransform.set(1, 2, aRange.getMinY());
     118             : 
     119             :     // create media primitive. Always create primitives to allow the
     120             :     // decomposition of MediaPrimitive2D to create needed invisible elements for HitTest
     121             :     // and/or BoundRect
     122           0 :     const basegfx::BColor aBackgroundColor(67.0 / 255.0, 67.0 / 255.0, 67.0 / 255.0);
     123           0 :     const OUString& rURL(GetSdrMediaObj().getURL());
     124           0 :     const sal_uInt32 nPixelBorder(4L);
     125             :     const drawinglayer::primitive2d::Primitive2DReference xRetval(
     126             :         new drawinglayer::primitive2d::MediaPrimitive2D(
     127             :             aTransform, rURL, aBackgroundColor, nPixelBorder,
     128           0 :             GetSdrMediaObj().getSnapshot()));
     129             : 
     130           0 :     return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1);
     131             : }
     132             : 
     133         435 : }}
     134             : 
     135             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11