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

Generated by: LCOV version 1.10