LCOV - code coverage report
Current view: top level - sd/source/ui/slidesorter/view - SlsViewCacheContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 30 39 76.9 %
Date: 2012-08-25 Functions: 10 11 90.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 16 56 28.6 %

           Branch data     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 "SlsViewCacheContext.hxx"
      22                 :            : 
      23                 :            : #include "SlideSorter.hxx"
      24                 :            : #include "model/SlideSorterModel.hxx"
      25                 :            : #include "model/SlsPageDescriptor.hxx"
      26                 :            : #include "model/SlsPageEnumerationProvider.hxx"
      27                 :            : #include "view/SlideSorterView.hxx"
      28                 :            : #include "sdpage.hxx"
      29                 :            : #include "Window.hxx"
      30                 :            : #include "drawdoc.hxx"
      31                 :            : #include "tools/IdleDetection.hxx"
      32                 :            : #include <svx/svdpage.hxx>
      33                 :            : #include <svx/sdr/contact/viewcontact.hxx>
      34                 :            : #include <vcl/window.hxx>
      35                 :            : #include <svx/sdr/contact/objectcontact.hxx>
      36                 :            : 
      37                 :            : namespace sd { namespace slidesorter { namespace view {
      38                 :            : 
      39                 :            : 
      40                 :        130 : ViewCacheContext::ViewCacheContext (SlideSorter& rSlideSorter)
      41         [ +  - ]:        130 :     : mrModel(rSlideSorter.GetModel()),
      42                 :        130 :       mrSlideSorter(rSlideSorter)
      43                 :            : {
      44                 :        130 : }
      45                 :            : 
      46                 :            : 
      47                 :            : 
      48                 :            : 
      49                 :        130 : ViewCacheContext::~ViewCacheContext (void)
      50                 :            : {
      51         [ -  + ]:        260 : }
      52                 :            : 
      53                 :            : 
      54                 :            : 
      55                 :            : 
      56                 :        270 : void ViewCacheContext::NotifyPreviewCreation (
      57                 :            :     cache::CacheKey aKey,
      58                 :            :     const Bitmap&)
      59                 :            : {
      60         [ +  - ]:        270 :     const model::SharedPageDescriptor pDescriptor (GetDescriptor(aKey));
      61         [ +  - ]:        270 :     if (pDescriptor.get() != NULL)
      62                 :            :     {
      63                 :            :         // Force a repaint that will trigger their re-creation.
      64 [ +  - ][ +  - ]:        270 :         mrSlideSorter.GetView().RequestRepaint(pDescriptor);
      65                 :            :     }
      66                 :            :     else
      67                 :            :     {
      68                 :            :         OSL_ASSERT(pDescriptor);
      69         [ +  - ]:        270 :     }
      70                 :        270 : }
      71                 :            : 
      72                 :            : 
      73                 :            : 
      74                 :            : 
      75                 :        270 : bool ViewCacheContext::IsIdle (void)
      76                 :            : {
      77         [ +  - ]:        270 :     sal_Int32 nIdleState (tools::IdleDetection::GetIdleState(mrSlideSorter.GetContentWindow().get()));
      78         [ +  - ]:        270 :     if (nIdleState == tools::IdleDetection::IDET_IDLE)
      79                 :        270 :         return true;
      80                 :            :     else
      81                 :        270 :         return false;
      82                 :            : }
      83                 :            : 
      84                 :            : 
      85                 :            : 
      86                 :            : 
      87                 :       1242 : bool ViewCacheContext::IsVisible (cache::CacheKey aKey)
      88                 :            : {
      89         [ +  - ]:       1242 :     const model::SharedPageDescriptor pDescriptor (GetDescriptor(aKey));
      90 [ +  - ][ +  - ]:       1242 :     return pDescriptor && pDescriptor->HasState(model::PageDescriptor::ST_Visible);
         [ +  + ][ +  - ]
      91                 :            : }
      92                 :            : 
      93                 :            : 
      94                 :            : 
      95                 :            : 
      96                 :       5288 : const SdrPage* ViewCacheContext::GetPage (cache::CacheKey aKey)
      97                 :            : {
      98                 :       5288 :     return static_cast<const SdrPage*>(aKey);
      99                 :            : }
     100                 :            : 
     101                 :            : 
     102                 :            : 
     103                 :            : 
     104                 :          0 : ::boost::shared_ptr<std::vector<cache::CacheKey> > ViewCacheContext::GetEntryList (bool bVisible)
     105                 :            : {
     106 [ #  # ][ #  # ]:          0 :     ::boost::shared_ptr<std::vector<cache::CacheKey> > pKeys (new std::vector<cache::CacheKey>());
                 [ #  # ]
     107                 :            : 
     108                 :            :     model::PageEnumeration aPageEnumeration (
     109                 :            :         bVisible
     110                 :            :             ? model::PageEnumerationProvider::CreateVisiblePagesEnumeration(mrModel)
     111 [ #  # ][ #  # ]:          0 :             : model::PageEnumerationProvider::CreateAllPagesEnumeration(mrModel));
                 [ #  # ]
     112                 :            : 
     113 [ #  # ][ #  # ]:          0 :     while (aPageEnumeration.HasMoreElements())
     114                 :            :     {
     115         [ #  # ]:          0 :         model::SharedPageDescriptor pDescriptor (aPageEnumeration.GetNextElement());
     116 [ #  # ][ #  # ]:          0 :         pKeys->push_back(pDescriptor->GetPage());
     117         [ #  # ]:          0 :     }
     118                 :            : 
     119         [ #  # ]:          0 :     return pKeys;
     120                 :            : }
     121                 :            : 
     122                 :            : 
     123                 :            : 
     124                 :            : 
     125                 :       1243 : sal_Int32 ViewCacheContext::GetPriority (cache::CacheKey aKey)
     126                 :            : {
     127                 :       1243 :     return - (static_cast<const SdrPage*>(aKey)->GetPageNum()-1) / 2;
     128                 :            : }
     129                 :            : 
     130                 :            : 
     131                 :            : 
     132                 :            : 
     133                 :       1512 : model::SharedPageDescriptor ViewCacheContext::GetDescriptor (cache::CacheKey aKey)
     134                 :            : {
     135                 :       1512 :     sal_uInt16 nPageIndex ((static_cast<const SdrPage*>(aKey)->GetPageNum() - 1) / 2);
     136                 :       1512 :     return mrModel.GetPageDescriptor(nPageIndex);
     137                 :            : }
     138                 :            : 
     139                 :            : 
     140                 :            : 
     141                 :            : 
     142                 :        136 : ::com::sun::star::uno::Reference<com::sun::star::uno::XInterface> ViewCacheContext::GetModel (void)
     143                 :            : {
     144         [ -  + ]:        136 :     if (mrModel.GetDocument() == NULL)
     145                 :          0 :         return NULL;
     146                 :            :     else
     147                 :        136 :         return mrModel.GetDocument()->getUnoModel();
     148                 :            : }
     149                 :            : 
     150                 :            : } } } // end of namespace ::sd::slidesorter::view
     151                 :            : 
     152                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10