LCOV - code coverage report
Current view: top level - sdext/source/presenter - PresenterSprite.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 73 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 12 0.0 %
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 "PresenterSprite.hxx"
      21             : 
      22             : #include <com/sun/star/lang/XComponent.hpp>
      23             : #include <com/sun/star/rendering/CompositeOperation.hpp>
      24             : #include <com/sun/star/rendering/RenderState.hpp>
      25             : #include <com/sun/star/rendering/ViewState.hpp>
      26             : 
      27             : using namespace ::com::sun::star;
      28             : using ::com::sun::star::uno::Reference;
      29             : using ::com::sun::star::uno::UNO_QUERY;
      30             : 
      31             : namespace sdext { namespace presenter {
      32             : 
      33           0 : PresenterSprite::PresenterSprite()
      34             :     : mxSpriteFactory(),
      35             :       mxSprite(),
      36             :       maSize(0,0),
      37             :       maLocation(0,0),
      38             :       mbIsVisible(false),
      39             :       mnPriority(0),
      40           0 :       mnAlpha(1.0)
      41             : {
      42           0 : }
      43             : 
      44           0 : PresenterSprite::~PresenterSprite()
      45             : {
      46           0 :     if (mxSprite.is())
      47             :     {
      48           0 :         mxSprite->hide();
      49           0 :         Reference<lang::XComponent> xComponent (mxSprite, UNO_QUERY);
      50           0 :         if (xComponent.is())
      51           0 :             xComponent->dispose();
      52           0 :         mxSprite = NULL;
      53             :     }
      54           0 : }
      55             : 
      56           0 : void PresenterSprite::SetFactory (
      57             :     const css::uno::Reference<css::rendering::XSpriteCanvas>& rxSpriteFactory)
      58             : {
      59           0 :     if (mxSpriteFactory != rxSpriteFactory)
      60             :     {
      61           0 :         DisposeSprite();
      62           0 :         mxSpriteFactory = rxSpriteFactory;
      63           0 :         if (mbIsVisible)
      64           0 :             ProvideSprite();
      65             :     }
      66           0 : }
      67             : 
      68           0 : css::uno::Reference<css::rendering::XCanvas> PresenterSprite::GetCanvas()
      69             : {
      70           0 :     ProvideSprite();
      71           0 :     if (mxSprite.is())
      72           0 :         return mxSprite->getContentCanvas();
      73             :     else
      74           0 :         return NULL;
      75             : }
      76             : 
      77           0 : void PresenterSprite::Show()
      78             : {
      79           0 :     mbIsVisible = true;
      80           0 :     if (mxSprite.is())
      81           0 :         mxSprite->show();
      82             :     else
      83           0 :         ProvideSprite();
      84           0 : }
      85             : 
      86           0 : void PresenterSprite::Hide()
      87             : {
      88           0 :     mbIsVisible = false;
      89           0 :     if (mxSprite.is())
      90           0 :         mxSprite->hide();
      91           0 : }
      92             : 
      93           0 : void PresenterSprite::Resize (const css::geometry::RealSize2D& rSize)
      94             : {
      95           0 :     maSize = rSize;
      96           0 :     if (mxSprite.is())
      97           0 :         DisposeSprite();
      98           0 :     if (mbIsVisible)
      99           0 :         ProvideSprite();
     100           0 : }
     101             : 
     102           0 : void PresenterSprite::MoveTo (const css::geometry::RealPoint2D& rLocation)
     103             : {
     104           0 :     maLocation = rLocation;
     105           0 :     if (mxSprite.is())
     106           0 :         mxSprite->move(
     107             :             maLocation,
     108             :             rendering::ViewState(
     109             :                 geometry::AffineMatrix2D(1,0,0, 0,1,0),
     110             :                 NULL),
     111             :             rendering::RenderState(
     112             :                 geometry::AffineMatrix2D(1,0,0, 0,1,0),
     113             :                 NULL,
     114             :                 uno::Sequence<double>(4),
     115             :                 rendering::CompositeOperation::SOURCE)
     116           0 :             );
     117           0 : }
     118             : 
     119           0 : void PresenterSprite::Update()
     120             : {
     121           0 :     if (mxSpriteFactory.is())
     122           0 :         mxSpriteFactory->updateScreen(sal_False);
     123           0 : }
     124             : 
     125           0 : void PresenterSprite::ProvideSprite()
     126             : {
     127           0 :     if ( ! mxSprite.is()
     128           0 :         && mxSpriteFactory.is()
     129           0 :         && maSize.Width>0
     130           0 :         && maSize.Height>0)
     131             :     {
     132           0 :         mxSprite = mxSpriteFactory->createCustomSprite(maSize);
     133           0 :         if (mxSprite.is())
     134             :         {
     135           0 :             mxSprite->move(maLocation,
     136             :                 rendering::ViewState(
     137             :                 geometry::AffineMatrix2D(1,0,0, 0,1,0),
     138             :                 NULL),
     139             :             rendering::RenderState(
     140             :                 geometry::AffineMatrix2D(1,0,0, 0,1,0),
     141             :                 NULL,
     142             :                 uno::Sequence<double>(4),
     143             :                 rendering::CompositeOperation::SOURCE)
     144           0 :                 );
     145           0 :             mxSprite->setAlpha(mnAlpha);
     146           0 :             mxSprite->setPriority(mnPriority);
     147           0 :             if (mbIsVisible)
     148           0 :                 mxSprite->show();
     149             :         }
     150             :     }
     151           0 : }
     152             : 
     153           0 : void PresenterSprite::DisposeSprite()
     154             : {
     155           0 :     if (mxSprite.is())
     156             :     {
     157           0 :         mxSprite->hide();
     158           0 :         Reference<lang::XComponent> xComponent (mxSprite, UNO_QUERY);
     159           0 :         if (xComponent.is())
     160           0 :             xComponent->dispose();
     161           0 :         mxSprite = NULL;
     162             :     }
     163           0 : }
     164             : 
     165             : } } //end of namespace sdext::presenter
     166             : 
     167             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11