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

Generated by: LCOV version 1.10