1c142477cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3c142477cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4c142477cSAndrew Rist * or more contributor license agreements. See the NOTICE file
5c142477cSAndrew Rist * distributed with this work for additional information
6c142477cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7c142477cSAndrew Rist * to you under the Apache License, Version 2.0 (the
8c142477cSAndrew Rist * "License"); you may not use this file except in compliance
9c142477cSAndrew Rist * with the License. You may obtain a copy of the License at
10c142477cSAndrew Rist *
11c142477cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12c142477cSAndrew Rist *
13c142477cSAndrew Rist * Unless required by applicable law or agreed to in writing,
14c142477cSAndrew Rist * software distributed under the License is distributed on an
15c142477cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16c142477cSAndrew Rist * KIND, either express or implied. See the License for the
17c142477cSAndrew Rist * specific language governing permissions and limitations
18c142477cSAndrew Rist * under the License.
19c142477cSAndrew Rist *
20c142477cSAndrew Rist *************************************************************/
21c142477cSAndrew Rist
22c142477cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sdext.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "pagecollector.hxx"
28cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
29cdf0e10cSrcweir #include <com/sun/star/presentation/XPresentationPage.hpp>
30cdf0e10cSrcweir #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
31cdf0e10cSrcweir #include <com/sun/star/drawing/XMasterPageTarget.hpp>
32cdf0e10cSrcweir #include <com/sun/star/presentation/XCustomPresentationSupplier.hpp>
33cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
34cdf0e10cSrcweir #include <com/sun/star/container/XIndexContainer.hpp>
35cdf0e10cSrcweir
36cdf0e10cSrcweir using namespace ::com::sun::star;
37cdf0e10cSrcweir using namespace ::com::sun::star::uno;
38cdf0e10cSrcweir using namespace ::com::sun::star::awt;
39cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
40cdf0e10cSrcweir using namespace ::com::sun::star::frame;
41cdf0e10cSrcweir using namespace ::com::sun::star::beans;
42cdf0e10cSrcweir using namespace ::com::sun::star::container;
43cdf0e10cSrcweir using namespace ::com::sun::star::presentation;
44cdf0e10cSrcweir
45*597a4c59SAriel Constenla-Haile using ::rtl::OUString;
46*597a4c59SAriel Constenla-Haile
CollectCustomShowPages(const com::sun::star::uno::Reference<com::sun::star::frame::XModel> & rxModel,const rtl::OUString & rCustomShowName,std::vector<Reference<XDrawPage>> & rUsedPageList)47cdf0e10cSrcweir void PageCollector::CollectCustomShowPages( const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rxModel, const rtl::OUString& rCustomShowName, std::vector< Reference< XDrawPage > >& rUsedPageList )
48cdf0e10cSrcweir {
49cdf0e10cSrcweir try
50cdf0e10cSrcweir {
51cdf0e10cSrcweir Reference< XCustomPresentationSupplier > aXCPSup( rxModel, UNO_QUERY_THROW );
52cdf0e10cSrcweir Reference< XNameContainer > aXCont( aXCPSup->getCustomPresentations() );
53cdf0e10cSrcweir if ( aXCont.is() )
54cdf0e10cSrcweir {
55cdf0e10cSrcweir // creating a list of every page that is used within our customshow
56cdf0e10cSrcweir Sequence< OUString> aNameSeq( aXCont->getElementNames() );
57cdf0e10cSrcweir const OUString* pUString = aNameSeq.getArray();
58cdf0e10cSrcweir sal_Int32 i, nCount = aNameSeq.getLength();
59cdf0e10cSrcweir for ( i = 0; i < nCount; i++ )
60cdf0e10cSrcweir {
61cdf0e10cSrcweir if ( pUString[ i ] == rCustomShowName )
62cdf0e10cSrcweir {
63cdf0e10cSrcweir Reference< container::XIndexContainer > aXIC( aXCont->getByName( pUString[ i ] ), UNO_QUERY_THROW );
64cdf0e10cSrcweir sal_Int32 j, nSlideCount = aXIC->getCount();
65cdf0e10cSrcweir for ( j = 0; j < nSlideCount; j++ )
66cdf0e10cSrcweir {
67cdf0e10cSrcweir Reference< XDrawPage > xDrawPage( aXIC->getByIndex( j ), UNO_QUERY_THROW );
68cdf0e10cSrcweir std::vector< Reference< XDrawPage > >::iterator aIter( rUsedPageList.begin() );
69cdf0e10cSrcweir std::vector< Reference< XDrawPage > >::iterator aEnd( rUsedPageList.end() );
70cdf0e10cSrcweir while( aIter != aEnd )
71cdf0e10cSrcweir {
72cdf0e10cSrcweir if ( *aIter == xDrawPage )
73cdf0e10cSrcweir break;
74cdf0e10cSrcweir aIter++;
75cdf0e10cSrcweir }
76cdf0e10cSrcweir if ( aIter == aEnd )
77cdf0e10cSrcweir rUsedPageList.push_back( xDrawPage );
78cdf0e10cSrcweir }
79cdf0e10cSrcweir }
80cdf0e10cSrcweir }
81cdf0e10cSrcweir }
82cdf0e10cSrcweir }
83cdf0e10cSrcweir catch( Exception& )
84cdf0e10cSrcweir {
85cdf0e10cSrcweir
86cdf0e10cSrcweir }
87cdf0e10cSrcweir }
88cdf0e10cSrcweir
CollectNonCustomShowPages(const com::sun::star::uno::Reference<com::sun::star::frame::XModel> & rxModel,const rtl::OUString & rCustomShowName,std::vector<Reference<XDrawPage>> & rNonUsedPageList)89cdf0e10cSrcweir void PageCollector::CollectNonCustomShowPages( const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rxModel, const rtl::OUString& rCustomShowName, std::vector< Reference< XDrawPage > >& rNonUsedPageList )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir try
92cdf0e10cSrcweir {
93cdf0e10cSrcweir std::vector< Reference< XDrawPage > > vUsedPageList;
94cdf0e10cSrcweir PageCollector::CollectCustomShowPages( rxModel, rCustomShowName, vUsedPageList );
95cdf0e10cSrcweir if ( vUsedPageList.size() )
96cdf0e10cSrcweir {
97cdf0e10cSrcweir Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW );
98cdf0e10cSrcweir Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
99cdf0e10cSrcweir for ( sal_Int32 j = 0; j < xDrawPages->getCount(); j++ )
100cdf0e10cSrcweir {
101cdf0e10cSrcweir Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( j ), UNO_QUERY_THROW );
102cdf0e10cSrcweir std::vector< Reference< XDrawPage > >::iterator aIter( vUsedPageList.begin() );
103cdf0e10cSrcweir std::vector< Reference< XDrawPage > >::iterator aEnd( vUsedPageList.end() );
104cdf0e10cSrcweir while( aIter != aEnd )
105cdf0e10cSrcweir {
106cdf0e10cSrcweir if ( *aIter == xDrawPage )
107cdf0e10cSrcweir break;
108cdf0e10cSrcweir aIter++;
109cdf0e10cSrcweir }
110cdf0e10cSrcweir if ( aIter == aEnd )
111cdf0e10cSrcweir rNonUsedPageList.push_back( xDrawPage );
112cdf0e10cSrcweir }
113cdf0e10cSrcweir }
114cdf0e10cSrcweir }
115cdf0e10cSrcweir catch( Exception& )
116cdf0e10cSrcweir {
117cdf0e10cSrcweir }
118cdf0e10cSrcweir }
119cdf0e10cSrcweir
120cdf0e10cSrcweir
CollectMasterPages(const Reference<XModel> & rxModel,std::vector<PageCollector::MasterPageEntity> & rMasterPageList)121cdf0e10cSrcweir void PageCollector::CollectMasterPages( const Reference< XModel >& rxModel, std::vector< PageCollector::MasterPageEntity >& rMasterPageList )
122cdf0e10cSrcweir {
123cdf0e10cSrcweir typedef std::vector< MasterPageEntity > MasterPageList;
124cdf0e10cSrcweir typedef MasterPageList::iterator MasterPageIter;
125cdf0e10cSrcweir
126cdf0e10cSrcweir try
127cdf0e10cSrcweir {
128cdf0e10cSrcweir // generating list of all master pages
129cdf0e10cSrcweir Reference< XMasterPagesSupplier > xMasterPagesSupplier( rxModel, UNO_QUERY_THROW );
130cdf0e10cSrcweir Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW );
131cdf0e10cSrcweir for ( sal_Int32 i = 0; i < xMasterPages->getCount(); i++ )
132cdf0e10cSrcweir {
133cdf0e10cSrcweir Reference< XDrawPage > xMasterPage( xMasterPages->getByIndex( i ), UNO_QUERY_THROW );
134cdf0e10cSrcweir MasterPageIter aIter( rMasterPageList.begin() );
135cdf0e10cSrcweir MasterPageIter aEnd ( rMasterPageList.end() );
136cdf0e10cSrcweir while( aIter != aEnd )
137cdf0e10cSrcweir {
138cdf0e10cSrcweir if ( aIter->xMasterPage == xMasterPage )
139cdf0e10cSrcweir break;
140cdf0e10cSrcweir aIter++;
141cdf0e10cSrcweir }
142cdf0e10cSrcweir if ( aIter == aEnd )
143cdf0e10cSrcweir {
144cdf0e10cSrcweir MasterPageEntity aMasterPageEntity;
145cdf0e10cSrcweir aMasterPageEntity.xMasterPage = xMasterPage;
146cdf0e10cSrcweir aMasterPageEntity.bUsed = sal_False;
147cdf0e10cSrcweir rMasterPageList.push_back( aMasterPageEntity );
148cdf0e10cSrcweir }
149cdf0e10cSrcweir }
150cdf0e10cSrcweir
151cdf0e10cSrcweir // mark masterpages which are referenced by drawpages
152cdf0e10cSrcweir Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW );
153cdf0e10cSrcweir Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
154cdf0e10cSrcweir for ( sal_Int32 j = 0; j < xDrawPages->getCount(); j++ )
155cdf0e10cSrcweir {
156cdf0e10cSrcweir Reference< XMasterPageTarget > xMasterPageTarget( xDrawPages->getByIndex( j ), UNO_QUERY_THROW );
157cdf0e10cSrcweir Reference< XDrawPage > xMasterPage( xMasterPageTarget->getMasterPage(), UNO_QUERY_THROW );
158cdf0e10cSrcweir MasterPageIter aIter( rMasterPageList.begin() );
159cdf0e10cSrcweir MasterPageIter aEnd ( rMasterPageList.end() );
160cdf0e10cSrcweir while( aIter != aEnd )
161cdf0e10cSrcweir {
162cdf0e10cSrcweir if ( aIter->xMasterPage == xMasterPage )
163cdf0e10cSrcweir {
164cdf0e10cSrcweir aIter->bUsed = sal_True;
165cdf0e10cSrcweir break;
166cdf0e10cSrcweir }
167cdf0e10cSrcweir aIter++;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir if ( aIter == aEnd )
170cdf0e10cSrcweir throw uno::RuntimeException();
171cdf0e10cSrcweir }
172cdf0e10cSrcweir }
173cdf0e10cSrcweir catch( Exception& )
174cdf0e10cSrcweir {
175cdf0e10cSrcweir }
176cdf0e10cSrcweir }
177cdf0e10cSrcweir
178