LCOV - code coverage report
Current view: top level - sd/source/ui/sidebar - MasterPageContainerFiller.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 51 0.0 %
Date: 2014-04-14 Functions: 0 7 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 "MasterPageContainerFiller.hxx"
      21             : 
      22             : #include "MasterPageDescriptor.hxx"
      23             : #include "MasterPageContainerProviders.hxx"
      24             : #include "TemplateScanner.hxx"
      25             : 
      26             : using namespace ::com::sun::star;
      27             : using namespace ::com::sun::star::uno;
      28             : 
      29             : 
      30             : namespace sd { namespace sidebar {
      31             : 
      32           0 : MasterPageContainerFiller::MasterPageContainerFiller (ContainerAdapter& rpAdapter)
      33             :     : mrContainerAdapter(rpAdapter),
      34             :       meState(INITIALIZE_TEMPLATE_SCANNER),
      35             :       mpScannerTask(),
      36             :       mpLastAddedEntry(NULL),
      37           0 :       mnIndex(1)
      38             : {
      39             :     // Add one entry for the default master page.  We use temporarily the
      40             :     // DefaultPagePreviewProvider to prevent the rendering (and the
      41             :     // expensive creation) of the default page.  It is replaced later on by
      42             :     // another.
      43             :     SharedMasterPageDescriptor pDescriptor (new MasterPageDescriptor(
      44             :         MasterPageContainer::DEFAULT,
      45             :         0,
      46             :         OUString(),
      47             :         OUString(),
      48             :         OUString(),
      49             :         false,
      50           0 :         ::boost::shared_ptr<PageObjectProvider>(new DefaultPageObjectProvider()),
      51           0 :         ::boost::shared_ptr<PreviewProvider>(new PagePreviewProvider())));
      52           0 :     mrContainerAdapter.PutMasterPage(pDescriptor);
      53           0 : }
      54             : 
      55             : 
      56             : 
      57             : 
      58           0 : MasterPageContainerFiller::~MasterPageContainerFiller (void)
      59             : {
      60           0 : }
      61             : 
      62             : 
      63             : 
      64             : 
      65           0 : void MasterPageContainerFiller::RunNextStep (void)
      66             : {
      67           0 :     switch (meState)
      68             :     {
      69             :         case INITIALIZE_TEMPLATE_SCANNER:
      70           0 :             mpScannerTask.reset(new TemplateScanner());
      71           0 :             meState = SCAN_TEMPLATE;
      72           0 :             break;
      73             : 
      74             :         case SCAN_TEMPLATE:
      75           0 :             meState = ScanTemplate();
      76           0 :             break;
      77             : 
      78             :         case ADD_TEMPLATE:
      79           0 :             meState = AddTemplate();
      80           0 :             break;
      81             : 
      82             :         case DONE:
      83             :         case ERROR:
      84             :         default:
      85           0 :             break;
      86             :     }
      87             : 
      88             :     // When the state has just been set to DONE or ERROR then tell the
      89             :     // container that no more templates will be coming and stop the
      90             :     // scanning.
      91           0 :     switch (meState)
      92             :     {
      93             :         case DONE:
      94             :         case ERROR:
      95           0 :             if (mpScannerTask.get() != NULL)
      96             :             {
      97           0 :                 mrContainerAdapter.FillingDone();
      98           0 :                 mpScannerTask.reset();
      99             :             }
     100             :         default:
     101           0 :             break;
     102             :     }
     103           0 : }
     104             : 
     105             : 
     106             : 
     107             : 
     108           0 : bool MasterPageContainerFiller::HasNextStep (void)
     109             : {
     110           0 :     switch (meState)
     111             :     {
     112             :         case DONE:
     113             :         case ERROR:
     114           0 :             return false;
     115             : 
     116             :         default:
     117           0 :             return true;
     118             :     }
     119             : }
     120             : 
     121             : 
     122             : 
     123             : 
     124           0 : MasterPageContainerFiller::State MasterPageContainerFiller::ScanTemplate (void)
     125             : {
     126           0 :     State eState (ERROR);
     127             : 
     128           0 :     if (mpScannerTask.get() != NULL)
     129             :     {
     130           0 :         if (mpScannerTask->HasNextStep())
     131             :         {
     132           0 :             mpScannerTask->RunNextStep();
     133           0 :             if (mpScannerTask->GetLastAddedEntry() != mpLastAddedEntry)
     134             :             {
     135           0 :                 mpLastAddedEntry = mpScannerTask->GetLastAddedEntry();
     136           0 :                 if (mpLastAddedEntry != NULL)
     137           0 :                     eState = ADD_TEMPLATE;
     138             :                 else
     139           0 :                     eState = SCAN_TEMPLATE;
     140             :             }
     141             :             else
     142           0 :                 eState = SCAN_TEMPLATE;
     143             :         }
     144             :         else
     145           0 :             eState = DONE;
     146             :     }
     147             : 
     148           0 :     return eState;
     149             : }
     150             : 
     151             : 
     152             : 
     153             : 
     154           0 : MasterPageContainerFiller::State MasterPageContainerFiller::AddTemplate (void)
     155             : {
     156           0 :     if (mpLastAddedEntry != NULL)
     157             :     {
     158             :         SharedMasterPageDescriptor pDescriptor (new MasterPageDescriptor(
     159             :             MasterPageContainer::TEMPLATE,
     160             :             mnIndex,
     161             :             mpLastAddedEntry->msPath,
     162             :             mpLastAddedEntry->msTitle,
     163             :             OUString(),
     164             :             false,
     165             :             ::boost::shared_ptr<PageObjectProvider>(
     166           0 :                 new TemplatePageObjectProvider(mpLastAddedEntry->msPath)),
     167             :             ::boost::shared_ptr<PreviewProvider>(
     168           0 :                 new TemplatePreviewProvider(mpLastAddedEntry->msPath))));
     169             :         // For user supplied templates we use a different preview provider:
     170             :         // The preview in the document shows not only shapes on the master
     171             :         // page but also shapes on the foreground.  This is misleading and
     172             :         // therefore these previews are discarded and created directly from
     173             :         // the page objects.
     174           0 :         if (pDescriptor->GetURLClassification() == MasterPageDescriptor::URLCLASS_USER)
     175           0 :             pDescriptor->mpPreviewProvider = ::boost::shared_ptr<PreviewProvider>(
     176           0 :                 new PagePreviewProvider());
     177             : 
     178           0 :         mrContainerAdapter.PutMasterPage(pDescriptor);
     179           0 :         ++mnIndex;
     180             :     }
     181             : 
     182           0 :     return SCAN_TEMPLATE;
     183             : }
     184             : 
     185             : 
     186             : 
     187             : } } // end of namespace sd::sidebar
     188             : 
     189             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10