LCOV - code coverage report
Current view: top level - sd/source/ui/presenter - CanvasUpdateRequester.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 33 6.1 %
Date: 2015-06-13 12:38:46 Functions: 2 9 22.2 %
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 "CanvasUpdateRequester.hxx"
      21             : #include <vcl/svapp.hxx>
      22             : #include <com/sun/star/lang/XComponent.hpp>
      23             : 
      24             : using namespace ::com::sun::star;
      25             : using namespace ::com::sun::star::uno;
      26             : 
      27             : namespace sd { namespace presenter {
      28             : 
      29             : //===== CanvasUpdateRequester::Deleter ========================================
      30             : 
      31             : class CanvasUpdateRequester::Deleter
      32             : {
      33             : public:
      34           0 :     void operator() (CanvasUpdateRequester* pObject) { delete pObject; }
      35             : };
      36             : 
      37             : //===== CanvasUpdateRequester =================================================
      38             : 
      39          22 : CanvasUpdateRequester::RequesterMap CanvasUpdateRequester::maRequesterMap;
      40             : 
      41           0 : ::boost::shared_ptr<CanvasUpdateRequester> CanvasUpdateRequester::Instance (
      42             :     const Reference<rendering::XSpriteCanvas>& rxSharedCanvas)
      43             : {
      44           0 :     RequesterMap::const_iterator iRequester;
      45           0 :     for (iRequester=maRequesterMap.begin(); iRequester!=maRequesterMap.end(); ++iRequester)
      46             :     {
      47           0 :         if (iRequester->first == rxSharedCanvas)
      48           0 :             return iRequester->second;
      49             :     }
      50             : 
      51             :     // No requester for the given canvas found.  Create a new one.
      52             :     ::boost::shared_ptr<CanvasUpdateRequester> pRequester (
      53           0 :         new CanvasUpdateRequester(rxSharedCanvas), Deleter());
      54           0 :     maRequesterMap.push_back(RequesterMap::value_type(rxSharedCanvas,pRequester));
      55           0 :     return pRequester;
      56             : }
      57             : 
      58           0 : CanvasUpdateRequester::CanvasUpdateRequester (
      59             :     const Reference<rendering::XSpriteCanvas>& rxCanvas)
      60             :     : mxCanvas(rxCanvas),
      61             :       mnUserEventId(0),
      62           0 :       mbUpdateFlag(false)
      63             : {
      64           0 :     Reference<lang::XComponent> xComponent (mxCanvas, UNO_QUERY);
      65           0 :     if (xComponent.is())
      66             :     {
      67             :         //xComponent->addEventListener(this);
      68           0 :     }
      69           0 : }
      70             : 
      71           0 : CanvasUpdateRequester::~CanvasUpdateRequester()
      72             : {
      73           0 :     if (mnUserEventId != 0)
      74           0 :         Application::RemoveUserEvent(mnUserEventId);
      75           0 : }
      76             : 
      77           0 : void CanvasUpdateRequester::RequestUpdate (const bool bUpdateAll)
      78             : {
      79           0 :     if (mnUserEventId == 0)
      80             :     {
      81           0 :         mbUpdateFlag = bUpdateAll;
      82           0 :         mnUserEventId = Application::PostUserEvent(LINK(this, CanvasUpdateRequester, Callback));
      83             :     }
      84             :     else
      85             :     {
      86           0 :         mbUpdateFlag |= bUpdateAll;
      87             :     }
      88           0 : }
      89             : 
      90           0 : IMPL_LINK_NOARG(CanvasUpdateRequester, Callback)
      91             : {
      92           0 :     mnUserEventId = 0;
      93           0 :     if (mxCanvas.is())
      94             :     {
      95           0 :         mxCanvas->updateScreen(mbUpdateFlag);
      96           0 :         mbUpdateFlag = false;
      97             :     }
      98           0 :     return 0;
      99             : }
     100             : 
     101          66 : } } // end of namespace ::sd::presenter
     102             : 
     103             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11