LCOV - code coverage report
Current view: top level - sdext/source/minimizer - pagecollector.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 80 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 3 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             : 
      21             : #include "pagecollector.hxx"
      22             : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
      23             : #include <com/sun/star/presentation/XPresentationPage.hpp>
      24             : #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
      25             : #include <com/sun/star/drawing/XMasterPageTarget.hpp>
      26             : #include <com/sun/star/presentation/XCustomPresentationSupplier.hpp>
      27             : #include <com/sun/star/container/XNameContainer.hpp>
      28             : #include <com/sun/star/container/XIndexContainer.hpp>
      29             : 
      30             : using namespace ::com::sun::star;
      31             : using namespace ::com::sun::star::uno;
      32             : using namespace ::com::sun::star::awt;
      33             : using namespace ::com::sun::star::drawing;
      34             : using namespace ::com::sun::star::frame;
      35             : using namespace ::com::sun::star::beans;
      36             : using namespace ::com::sun::star::container;
      37             : using namespace ::com::sun::star::presentation;
      38             : 
      39           0 : void PageCollector::CollectCustomShowPages( const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rxModel, const OUString& rCustomShowName, std::vector< Reference< XDrawPage > >& rUsedPageList )
      40             : {
      41             :     try
      42             :     {
      43           0 :         Reference< XCustomPresentationSupplier > aXCPSup( rxModel, UNO_QUERY_THROW );
      44           0 :         Reference< XNameContainer > aXCont( aXCPSup->getCustomPresentations() );
      45           0 :         if ( aXCont.is() )
      46             :         {
      47             :             // creating a list of every page that is used within our customshow
      48           0 :             Sequence< OUString> aNameSeq( aXCont->getElementNames() );
      49           0 :             const OUString* pUString = aNameSeq.getArray();
      50           0 :             sal_Int32 i, nCount = aNameSeq.getLength();
      51           0 :             for ( i = 0; i < nCount; i++ )
      52             :             {
      53           0 :                 if ( pUString[ i ] == rCustomShowName )
      54             :                 {
      55           0 :                     Reference< container::XIndexContainer > aXIC( aXCont->getByName( pUString[ i ] ), UNO_QUERY_THROW );
      56           0 :                     sal_Int32 j, nSlideCount = aXIC->getCount();
      57           0 :                     for ( j = 0; j < nSlideCount; j++ )
      58             :                     {
      59           0 :                         Reference< XDrawPage > xDrawPage( aXIC->getByIndex( j ), UNO_QUERY_THROW );
      60           0 :                         std::vector< Reference< XDrawPage > >::iterator aIter( rUsedPageList.begin() );
      61           0 :                         std::vector< Reference< XDrawPage > >::iterator aEnd( rUsedPageList.end() );
      62           0 :                         while( aIter != aEnd )
      63             :                         {
      64           0 :                             if ( *aIter == xDrawPage )
      65           0 :                                 break;
      66           0 :                             ++aIter;
      67             :                         }
      68           0 :                         if ( aIter == aEnd )
      69           0 :                             rUsedPageList.push_back( xDrawPage );
      70           0 :                     }
      71             :                 }
      72           0 :             }
      73           0 :         }
      74             :     }
      75           0 :     catch( Exception& )
      76             :     {
      77             : 
      78             :     }
      79           0 : }
      80             : 
      81           0 : void PageCollector::CollectNonCustomShowPages( const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rxModel, const OUString& rCustomShowName, std::vector< Reference< XDrawPage > >& rNonUsedPageList )
      82             : {
      83             :     try
      84             :     {
      85           0 :         std::vector< Reference< XDrawPage > > vUsedPageList;
      86           0 :         PageCollector::CollectCustomShowPages( rxModel, rCustomShowName, vUsedPageList );
      87           0 :         if ( !vUsedPageList.empty() )
      88             :         {
      89           0 :             Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW );
      90           0 :             Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
      91           0 :             for ( sal_Int32 j = 0; j < xDrawPages->getCount(); j++ )
      92             :             {
      93           0 :                 Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( j ), UNO_QUERY_THROW );
      94           0 :                 std::vector< Reference< XDrawPage > >::iterator aIter( vUsedPageList.begin() );
      95           0 :                 std::vector< Reference< XDrawPage > >::iterator aEnd( vUsedPageList.end() );
      96           0 :                 while( aIter != aEnd )
      97             :                 {
      98           0 :                     if ( *aIter == xDrawPage )
      99           0 :                         break;
     100           0 :                     ++aIter;
     101             :                 }
     102           0 :                 if ( aIter == aEnd )
     103           0 :                     rNonUsedPageList.push_back( xDrawPage );
     104           0 :             }
     105           0 :         }
     106             :     }
     107           0 :     catch( Exception& )
     108             :     {
     109             :     }
     110           0 : }
     111             : 
     112             : 
     113           0 : void PageCollector::CollectMasterPages( const Reference< XModel >& rxModel, std::vector< PageCollector::MasterPageEntity >& rMasterPageList )
     114             : {
     115             :     typedef std::vector< MasterPageEntity > MasterPageList;
     116             :     typedef MasterPageList::iterator MasterPageIter;
     117             : 
     118             :     try
     119             :     {
     120             :         // generating list of all master pages
     121           0 :         Reference< XMasterPagesSupplier > xMasterPagesSupplier( rxModel, UNO_QUERY_THROW );
     122           0 :         Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW );
     123           0 :         for ( sal_Int32 i = 0; i < xMasterPages->getCount(); i++ )
     124             :         {
     125           0 :             Reference< XDrawPage > xMasterPage( xMasterPages->getByIndex( i ), UNO_QUERY_THROW );
     126           0 :             MasterPageIter aIter( rMasterPageList.begin() );
     127           0 :             MasterPageIter aEnd ( rMasterPageList.end() );
     128           0 :             while( aIter != aEnd )
     129             :             {
     130           0 :                 if ( aIter->xMasterPage == xMasterPage )
     131           0 :                     break;
     132           0 :                 ++aIter;
     133             :             }
     134           0 :             if ( aIter == aEnd )
     135             :             {
     136           0 :                 MasterPageEntity aMasterPageEntity;
     137           0 :                 aMasterPageEntity.xMasterPage = xMasterPage;
     138           0 :                 aMasterPageEntity.bUsed = false;
     139           0 :                 rMasterPageList.push_back( aMasterPageEntity );
     140             :             }
     141           0 :         }
     142             : 
     143             :         // mark masterpages which are referenced by drawpages
     144           0 :         Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW );
     145           0 :         Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
     146           0 :         for ( sal_Int32 j = 0; j < xDrawPages->getCount(); j++ )
     147             :         {
     148           0 :             Reference< XMasterPageTarget > xMasterPageTarget( xDrawPages->getByIndex( j ), UNO_QUERY_THROW );
     149           0 :             Reference< XDrawPage > xMasterPage( xMasterPageTarget->getMasterPage(), UNO_QUERY_THROW );
     150           0 :             MasterPageIter aIter( rMasterPageList.begin() );
     151           0 :             MasterPageIter aEnd ( rMasterPageList.end() );
     152           0 :             while( aIter != aEnd )
     153             :             {
     154           0 :                 if ( aIter->xMasterPage == xMasterPage )
     155             :                 {
     156           0 :                     aIter->bUsed = true;
     157           0 :                     break;
     158             :                 }
     159           0 :                 ++aIter;
     160             :             }
     161           0 :             if ( aIter == aEnd )
     162           0 :                 throw uno::RuntimeException();
     163           0 :         }
     164             :     }
     165           0 :     catch( Exception& )
     166             :     {
     167             :     }
     168           0 : }
     169             : 
     170             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11