LCOV - code coverage report
Current view: top level - sdext/source/minimizer - pagecollector.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 80 0.0 %
Date: 2012-08-25 Functions: 0 3 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            :  /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "pagecollector.hxx"
      31                 :            : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
      32                 :            : #include <com/sun/star/presentation/XPresentationPage.hpp>
      33                 :            : #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
      34                 :            : #include <com/sun/star/drawing/XMasterPageTarget.hpp>
      35                 :            : #include <com/sun/star/presentation/XCustomPresentationSupplier.hpp>
      36                 :            : #include <com/sun/star/container/XNameContainer.hpp>
      37                 :            : #include <com/sun/star/container/XIndexContainer.hpp>
      38                 :            : 
      39                 :            : using namespace ::rtl;
      40                 :            : using namespace ::com::sun::star;
      41                 :            : using namespace ::com::sun::star::uno;
      42                 :            : using namespace ::com::sun::star::awt;
      43                 :            : using namespace ::com::sun::star::drawing;
      44                 :            : using namespace ::com::sun::star::frame;
      45                 :            : using namespace ::com::sun::star::beans;
      46                 :            : using namespace ::com::sun::star::container;
      47                 :            : using namespace ::com::sun::star::presentation;
      48                 :            : 
      49                 :          0 : void PageCollector::CollectCustomShowPages( const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rxModel, const rtl::OUString& rCustomShowName, std::vector< Reference< XDrawPage > >& rUsedPageList )
      50                 :            : {
      51                 :            :     try
      52                 :            :     {
      53                 :          0 :         Reference< XCustomPresentationSupplier > aXCPSup( rxModel, UNO_QUERY_THROW );
      54                 :          0 :         Reference< XNameContainer > aXCont( aXCPSup->getCustomPresentations() );
      55                 :          0 :         if ( aXCont.is() )
      56                 :            :         {
      57                 :            :             // creating a list of every page that is used within our customshow
      58                 :          0 :             Sequence< OUString> aNameSeq( aXCont->getElementNames() );
      59                 :          0 :             const OUString* pUString = aNameSeq.getArray();
      60                 :          0 :             sal_Int32 i, nCount = aNameSeq.getLength();
      61                 :          0 :             for ( i = 0; i < nCount; i++ )
      62                 :            :             {
      63                 :          0 :                 if ( pUString[ i ] == rCustomShowName )
      64                 :            :                 {
      65                 :          0 :                     Reference< container::XIndexContainer > aXIC( aXCont->getByName( pUString[ i ] ), UNO_QUERY_THROW );
      66                 :          0 :                     sal_Int32 j, nSlideCount = aXIC->getCount();
      67                 :          0 :                     for ( j = 0; j < nSlideCount; j++ )
      68                 :            :                     {
      69                 :          0 :                         Reference< XDrawPage > xDrawPage( aXIC->getByIndex( j ), UNO_QUERY_THROW );
      70                 :          0 :                         std::vector< Reference< XDrawPage > >::iterator aIter( rUsedPageList.begin() );
      71                 :          0 :                         std::vector< Reference< XDrawPage > >::iterator aEnd( rUsedPageList.end() );
      72                 :          0 :                         while( aIter != aEnd )
      73                 :            :                         {
      74                 :          0 :                             if ( *aIter == xDrawPage )
      75                 :          0 :                                 break;
      76                 :          0 :                             ++aIter;
      77                 :            :                         }
      78                 :          0 :                         if ( aIter == aEnd )
      79                 :          0 :                             rUsedPageList.push_back( xDrawPage );
      80                 :          0 :                     }
      81                 :            :                 }
      82                 :          0 :             }
      83                 :          0 :         }
      84                 :            :     }
      85                 :          0 :     catch( Exception& )
      86                 :            :     {
      87                 :            : 
      88                 :            :     }
      89                 :          0 : }
      90                 :            : 
      91                 :          0 : void PageCollector::CollectNonCustomShowPages( const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rxModel, const rtl::OUString& rCustomShowName, std::vector< Reference< XDrawPage > >& rNonUsedPageList )
      92                 :            : {
      93                 :            :     try
      94                 :            :     {
      95                 :          0 :         std::vector< Reference< XDrawPage > > vUsedPageList;
      96                 :          0 :         PageCollector::CollectCustomShowPages( rxModel, rCustomShowName, vUsedPageList );
      97                 :          0 :         if ( !vUsedPageList.empty() )
      98                 :            :         {
      99                 :          0 :             Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW );
     100                 :          0 :             Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
     101                 :          0 :             for ( sal_Int32 j = 0; j < xDrawPages->getCount(); j++ )
     102                 :            :             {
     103                 :          0 :                 Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( j ), UNO_QUERY_THROW );
     104                 :          0 :                 std::vector< Reference< XDrawPage > >::iterator aIter( vUsedPageList.begin() );
     105                 :          0 :                 std::vector< Reference< XDrawPage > >::iterator aEnd( vUsedPageList.end() );
     106                 :          0 :                 while( aIter != aEnd )
     107                 :            :                 {
     108                 :          0 :                     if ( *aIter == xDrawPage )
     109                 :          0 :                         break;
     110                 :          0 :                     ++aIter;
     111                 :            :                 }
     112                 :          0 :                 if ( aIter == aEnd )
     113                 :          0 :                     rNonUsedPageList.push_back( xDrawPage );
     114                 :          0 :             }
     115                 :          0 :         }
     116                 :            :     }
     117                 :          0 :     catch( Exception& )
     118                 :            :     {
     119                 :            :     }
     120                 :          0 : }
     121                 :            : 
     122                 :            : 
     123                 :          0 : void PageCollector::CollectMasterPages( const Reference< XModel >& rxModel, std::vector< PageCollector::MasterPageEntity >& rMasterPageList )
     124                 :            : {
     125                 :            :     typedef std::vector< MasterPageEntity > MasterPageList;
     126                 :            :     typedef MasterPageList::iterator MasterPageIter;
     127                 :            : 
     128                 :            :     try
     129                 :            :     {
     130                 :            :         // generating list of all master pages
     131                 :          0 :         Reference< XMasterPagesSupplier > xMasterPagesSupplier( rxModel, UNO_QUERY_THROW );
     132                 :          0 :         Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW );
     133                 :          0 :         for ( sal_Int32 i = 0; i < xMasterPages->getCount(); i++ )
     134                 :            :         {
     135                 :          0 :             Reference< XDrawPage > xMasterPage( xMasterPages->getByIndex( i ), UNO_QUERY_THROW );
     136                 :          0 :             MasterPageIter aIter( rMasterPageList.begin() );
     137                 :          0 :             MasterPageIter aEnd ( rMasterPageList.end() );
     138                 :          0 :             while( aIter != aEnd )
     139                 :            :             {
     140                 :          0 :                 if ( aIter->xMasterPage == xMasterPage )
     141                 :          0 :                     break;
     142                 :          0 :                 ++aIter;
     143                 :            :             }
     144                 :          0 :             if ( aIter == aEnd )
     145                 :            :             {
     146                 :          0 :                 MasterPageEntity aMasterPageEntity;
     147                 :          0 :                 aMasterPageEntity.xMasterPage = xMasterPage;
     148                 :          0 :                 aMasterPageEntity.bUsed = sal_False;
     149                 :          0 :                 rMasterPageList.push_back( aMasterPageEntity );
     150                 :            :             }
     151                 :          0 :         }
     152                 :            : 
     153                 :            :         // mark masterpages which are referenced by drawpages
     154                 :          0 :         Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW );
     155                 :          0 :         Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
     156                 :          0 :         for ( sal_Int32 j = 0; j < xDrawPages->getCount(); j++ )
     157                 :            :         {
     158                 :          0 :             Reference< XMasterPageTarget > xMasterPageTarget( xDrawPages->getByIndex( j ), UNO_QUERY_THROW );
     159                 :          0 :             Reference< XDrawPage > xMasterPage( xMasterPageTarget->getMasterPage(), UNO_QUERY_THROW );
     160                 :          0 :             MasterPageIter aIter( rMasterPageList.begin() );
     161                 :          0 :             MasterPageIter aEnd ( rMasterPageList.end() );
     162                 :          0 :             while( aIter != aEnd )
     163                 :            :             {
     164                 :          0 :                 if ( aIter->xMasterPage == xMasterPage )
     165                 :            :                 {
     166                 :          0 :                     aIter->bUsed = sal_True;
     167                 :          0 :                     break;
     168                 :            :                 }
     169                 :          0 :                 ++aIter;
     170                 :            :             }
     171                 :          0 :             if ( aIter == aEnd )
     172                 :          0 :                 throw uno::RuntimeException();
     173                 :          0 :         }
     174                 :            :     }
     175                 :          0 :     catch( Exception& )
     176                 :            :     {
     177                 :            :     }
     178                 :          0 : }
     179                 :            : 
     180                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10