LCOV - code coverage report
Current view: top level - sd/source/ui/slidesorter/view - SlsViewCacheContext.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 30 40 75.0 %
Date: 2015-06-13 12:38:46 Functions: 12 13 92.3 %
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 "SlsViewCacheContext.hxx"
      21             : 
      22             : #include "SlideSorter.hxx"
      23             : #include "model/SlideSorterModel.hxx"
      24             : #include "model/SlsPageDescriptor.hxx"
      25             : #include "model/SlsPageEnumerationProvider.hxx"
      26             : #include "view/SlideSorterView.hxx"
      27             : #include "sdpage.hxx"
      28             : #include "Window.hxx"
      29             : #include "drawdoc.hxx"
      30             : #include "tools/IdleDetection.hxx"
      31             : #include <svx/svdpage.hxx>
      32             : #include <svx/sdr/contact/viewcontact.hxx>
      33             : #include <vcl/window.hxx>
      34             : #include <svx/sdr/contact/objectcontact.hxx>
      35             : 
      36             : namespace sd { namespace slidesorter { namespace view {
      37             : 
      38          64 : ViewCacheContext::ViewCacheContext (SlideSorter& rSlideSorter)
      39          64 :     : mrModel(rSlideSorter.GetModel()),
      40         128 :       mrSlideSorter(rSlideSorter)
      41             : {
      42          64 : }
      43             : 
      44         128 : ViewCacheContext::~ViewCacheContext()
      45             : {
      46         128 : }
      47             : 
      48         145 : void ViewCacheContext::NotifyPreviewCreation (
      49             :     cache::CacheKey aKey,
      50             :     const Bitmap&)
      51             : {
      52         145 :     const model::SharedPageDescriptor pDescriptor (GetDescriptor(aKey));
      53         145 :     if (pDescriptor.get() != NULL)
      54             :     {
      55             :         // Force a repaint that will trigger their re-creation.
      56         145 :         mrSlideSorter.GetView().RequestRepaint(pDescriptor);
      57             :     }
      58             :     else
      59             :     {
      60             :         // It is OK when a preview was created for a page that is not
      61             :         // currently displayed because both normal and master pages are
      62             :         // kept in the same cache.
      63         145 :     }
      64         145 : }
      65             : 
      66         145 : bool ViewCacheContext::IsIdle()
      67             : {
      68         145 :     sal_Int32 nIdleState (tools::IdleDetection::GetIdleState(mrSlideSorter.GetContentWindow()));
      69         145 :     if (nIdleState == tools::IdleDetection::IDET_IDLE)
      70         145 :         return true;
      71             :     else
      72           0 :         return false;
      73             : }
      74             : 
      75         570 : bool ViewCacheContext::IsVisible (cache::CacheKey aKey)
      76             : {
      77         570 :     const model::SharedPageDescriptor pDescriptor (GetDescriptor(aKey));
      78         570 :     return pDescriptor && pDescriptor->HasState(model::PageDescriptor::ST_Visible);
      79             : }
      80             : 
      81        2572 : const SdrPage* ViewCacheContext::GetPage (cache::CacheKey aKey)
      82             : {
      83        2572 :     return static_cast<const SdrPage*>(aKey);
      84             : }
      85             : 
      86           0 : ::boost::shared_ptr<std::vector<cache::CacheKey> > ViewCacheContext::GetEntryList (bool bVisible)
      87             : {
      88           0 :     ::boost::shared_ptr<std::vector<cache::CacheKey> > pKeys (new std::vector<cache::CacheKey>());
      89             : 
      90             :     model::PageEnumeration aPageEnumeration (
      91             :         bVisible
      92             :             ? model::PageEnumerationProvider::CreateVisiblePagesEnumeration(mrModel)
      93           0 :             : model::PageEnumerationProvider::CreateAllPagesEnumeration(mrModel));
      94             : 
      95           0 :     while (aPageEnumeration.HasMoreElements())
      96             :     {
      97           0 :         model::SharedPageDescriptor pDescriptor (aPageEnumeration.GetNextElement());
      98           0 :         pKeys->push_back(pDescriptor->GetPage());
      99           0 :     }
     100             : 
     101           0 :     return pKeys;
     102             : }
     103             : 
     104         572 : sal_Int32 ViewCacheContext::GetPriority (cache::CacheKey aKey)
     105             : {
     106         572 :     return - (static_cast<const SdrPage*>(aKey)->GetPageNum()-1) / 2;
     107             : }
     108             : 
     109         715 : model::SharedPageDescriptor ViewCacheContext::GetDescriptor (cache::CacheKey aKey)
     110             : {
     111         715 :     sal_uInt16 nPageIndex ((static_cast<const SdrPage*>(aKey)->GetPageNum() - 1) / 2);
     112         715 :     return mrModel.GetPageDescriptor(nPageIndex);
     113             : }
     114             : 
     115          69 : ::com::sun::star::uno::Reference<com::sun::star::uno::XInterface> ViewCacheContext::GetModel()
     116             : {
     117          69 :     if (mrModel.GetDocument() == NULL)
     118           0 :         return NULL;
     119             :     else
     120          69 :         return mrModel.GetDocument()->getUnoModel();
     121             : }
     122             : 
     123          66 : } } } // end of namespace ::sd::slidesorter::view
     124             : 
     125             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11