fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sdext / source / minimizer / pagecollector.cxx
blob753119a77295eeda0343e9b3f59328ae214a68bc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
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;
39 void PageCollector::CollectCustomShowPages( const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rxModel, const OUString& rCustomShowName, std::vector< Reference< XDrawPage > >& rUsedPageList )
41 try
43 Reference< XCustomPresentationSupplier > aXCPSup( rxModel, UNO_QUERY_THROW );
44 Reference< XNameContainer > aXCont( aXCPSup->getCustomPresentations() );
45 if ( aXCont.is() )
47 // creating a list of every page that is used within our customshow
48 Sequence< OUString> aNameSeq( aXCont->getElementNames() );
49 const OUString* pUString = aNameSeq.getArray();
50 sal_Int32 i, nCount = aNameSeq.getLength();
51 for ( i = 0; i < nCount; i++ )
53 if ( pUString[ i ] == rCustomShowName )
55 Reference< container::XIndexContainer > aXIC( aXCont->getByName( pUString[ i ] ), UNO_QUERY_THROW );
56 sal_Int32 j, nSlideCount = aXIC->getCount();
57 for ( j = 0; j < nSlideCount; j++ )
59 Reference< XDrawPage > xDrawPage( aXIC->getByIndex( j ), UNO_QUERY_THROW );
60 std::vector< Reference< XDrawPage > >::iterator aIter( rUsedPageList.begin() );
61 std::vector< Reference< XDrawPage > >::iterator aEnd( rUsedPageList.end() );
62 while( aIter != aEnd )
64 if ( *aIter == xDrawPage )
65 break;
66 ++aIter;
68 if ( aIter == aEnd )
69 rUsedPageList.push_back( xDrawPage );
75 catch( Exception& )
81 void PageCollector::CollectNonCustomShowPages( const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rxModel, const OUString& rCustomShowName, std::vector< Reference< XDrawPage > >& rNonUsedPageList )
83 try
85 std::vector< Reference< XDrawPage > > vUsedPageList;
86 PageCollector::CollectCustomShowPages( rxModel, rCustomShowName, vUsedPageList );
87 if ( !vUsedPageList.empty() )
89 Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW );
90 Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
91 for ( sal_Int32 j = 0; j < xDrawPages->getCount(); j++ )
93 Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( j ), UNO_QUERY_THROW );
94 std::vector< Reference< XDrawPage > >::iterator aIter( vUsedPageList.begin() );
95 std::vector< Reference< XDrawPage > >::iterator aEnd( vUsedPageList.end() );
96 while( aIter != aEnd )
98 if ( *aIter == xDrawPage )
99 break;
100 ++aIter;
102 if ( aIter == aEnd )
103 rNonUsedPageList.push_back( xDrawPage );
107 catch( Exception& )
113 void PageCollector::CollectMasterPages( const Reference< XModel >& rxModel, std::vector< PageCollector::MasterPageEntity >& rMasterPageList )
115 typedef std::vector< MasterPageEntity > MasterPageList;
116 typedef MasterPageList::iterator MasterPageIter;
120 // generating list of all master pages
121 Reference< XMasterPagesSupplier > xMasterPagesSupplier( rxModel, UNO_QUERY_THROW );
122 Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW );
123 for ( sal_Int32 i = 0; i < xMasterPages->getCount(); i++ )
125 Reference< XDrawPage > xMasterPage( xMasterPages->getByIndex( i ), UNO_QUERY_THROW );
126 MasterPageIter aIter( rMasterPageList.begin() );
127 MasterPageIter aEnd ( rMasterPageList.end() );
128 while( aIter != aEnd )
130 if ( aIter->xMasterPage == xMasterPage )
131 break;
132 ++aIter;
134 if ( aIter == aEnd )
136 MasterPageEntity aMasterPageEntity;
137 aMasterPageEntity.xMasterPage = xMasterPage;
138 aMasterPageEntity.bUsed = false;
139 rMasterPageList.push_back( aMasterPageEntity );
143 // mark masterpages which are referenced by drawpages
144 Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW );
145 Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
146 for ( sal_Int32 j = 0; j < xDrawPages->getCount(); j++ )
148 Reference< XMasterPageTarget > xMasterPageTarget( xDrawPages->getByIndex( j ), UNO_QUERY_THROW );
149 Reference< XDrawPage > xMasterPage( xMasterPageTarget->getMasterPage(), UNO_QUERY_THROW );
150 MasterPageIter aIter( rMasterPageList.begin() );
151 MasterPageIter aEnd ( rMasterPageList.end() );
152 while( aIter != aEnd )
154 if ( aIter->xMasterPage == xMasterPage )
156 aIter->bUsed = true;
157 break;
159 ++aIter;
161 if ( aIter == aEnd )
162 throw uno::RuntimeException();
165 catch( Exception& )
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */