1ca5ec200SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3ca5ec200SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4ca5ec200SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5ca5ec200SAndrew Rist  * distributed with this work for additional information
6ca5ec200SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7ca5ec200SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8ca5ec200SAndrew Rist  * "License"); you may not use this file except in compliance
9ca5ec200SAndrew Rist  * with the License.  You may obtain a copy of the License at
10ca5ec200SAndrew Rist  *
11ca5ec200SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12ca5ec200SAndrew Rist  *
13ca5ec200SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14ca5ec200SAndrew Rist  * software distributed under the License is distributed on an
15ca5ec200SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16ca5ec200SAndrew Rist  * KIND, either express or implied.  See the License for the
17ca5ec200SAndrew Rist  * specific language governing permissions and limitations
18ca5ec200SAndrew Rist  * under the License.
19ca5ec200SAndrew Rist  *
20ca5ec200SAndrew Rist  *************************************************************/
21ca5ec200SAndrew Rist 
22ca5ec200SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "comphelper/anytostring.hxx"
25cdf0e10cSrcweir #include "cppuhelper/exc_hlp.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
28cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPages.hpp>
29cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
30cdf0e10cSrcweir #include <com/sun/star/drawing/XMasterPageTarget.hpp>
31cdf0e10cSrcweir #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
32cdf0e10cSrcweir #include <com/sun/star/style/XStyle.hpp>
33cdf0e10cSrcweir #include <com/sun/star/presentation/XPresentationPage.hpp>
34cdf0e10cSrcweir #include <com/sun/star/task/XStatusIndicator.hpp>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include "oox/drawingml/theme.hxx"
37cdf0e10cSrcweir #include "oox/drawingml/drawingmltypes.hxx"
38cdf0e10cSrcweir #include "oox/drawingml/themefragmenthandler.hxx"
39cdf0e10cSrcweir #include "oox/drawingml/textliststylecontext.hxx"
40cdf0e10cSrcweir #include "oox/ppt/pptshape.hxx"
41cdf0e10cSrcweir #include "oox/ppt/presentationfragmenthandler.hxx"
42cdf0e10cSrcweir #include "oox/ppt/slidefragmenthandler.hxx"
43cdf0e10cSrcweir #include "oox/ppt/layoutfragmenthandler.hxx"
44cdf0e10cSrcweir #include "oox/ppt/pptimport.hxx"
45cdf0e10cSrcweir 
46cdf0e10cSrcweir using rtl::OUString;
47cdf0e10cSrcweir using namespace ::com::sun::star;
48cdf0e10cSrcweir using namespace ::oox::core;
49cdf0e10cSrcweir using namespace ::oox::drawingml;
50cdf0e10cSrcweir using namespace ::com::sun::star::uno;
51cdf0e10cSrcweir using namespace ::com::sun::star::beans;
52cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
53cdf0e10cSrcweir using namespace ::com::sun::star::presentation;
54cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax;
55cdf0e10cSrcweir 
56cdf0e10cSrcweir namespace oox { namespace ppt {
57cdf0e10cSrcweir 
58cdf0e10cSrcweir PresentationFragmentHandler::PresentationFragmentHandler( XmlFilterBase& rFilter, const OUString& rFragmentPath ) throw()
59cdf0e10cSrcweir : FragmentHandler( rFilter, rFragmentPath )
60cdf0e10cSrcweir , mpTextListStyle( new TextListStyle )
61cdf0e10cSrcweir {
62cdf0e10cSrcweir 	TextParagraphPropertiesVector& rParagraphDefaulsVector( mpTextListStyle->getListStyle() );
63cdf0e10cSrcweir 	TextParagraphPropertiesVector::iterator aParagraphDefaultIter( rParagraphDefaulsVector.begin() );
64cdf0e10cSrcweir 	while( aParagraphDefaultIter != rParagraphDefaulsVector.end() )
65cdf0e10cSrcweir 	{
66cdf0e10cSrcweir 		// ppt is having zero bottom margin per default, whereas OOo is 0,5cm,
67cdf0e10cSrcweir 		// so this attribute needs to be set always
68cdf0e10cSrcweir 		(*aParagraphDefaultIter++)->getParaBottomMargin() = TextSpacing( 0 );
69cdf0e10cSrcweir 	}
70cdf0e10cSrcweir }
71cdf0e10cSrcweir 
72cdf0e10cSrcweir PresentationFragmentHandler::~PresentationFragmentHandler() throw()
73cdf0e10cSrcweir {
74cdf0e10cSrcweir 
75cdf0e10cSrcweir }
76cdf0e10cSrcweir void PresentationFragmentHandler::startDocument() throw (SAXException, RuntimeException)
77cdf0e10cSrcweir {
78cdf0e10cSrcweir }
79cdf0e10cSrcweir 
80cdf0e10cSrcweir void ResolveTextFields( XmlFilterBase& rFilter )
81cdf0e10cSrcweir {
82cdf0e10cSrcweir 	const oox::core::TextFieldStack& rTextFields = rFilter.getTextFieldStack();
83cdf0e10cSrcweir 	if ( rTextFields.size() )
84cdf0e10cSrcweir 	{
85cdf0e10cSrcweir 		Reference< frame::XModel > xModel( rFilter.getModel() );
86cdf0e10cSrcweir 		oox::core::TextFieldStack::const_iterator aIter( rTextFields.begin() );
87cdf0e10cSrcweir 		while( aIter != rTextFields.end() )
88cdf0e10cSrcweir 		{
89cdf0e10cSrcweir 	        const OUString sURL = CREATE_OUSTRING( "URL" );
90cdf0e10cSrcweir 			Reference< drawing::XDrawPagesSupplier > xDPS( xModel, uno::UNO_QUERY_THROW );
91cdf0e10cSrcweir 			Reference< drawing::XDrawPages > xDrawPages( xDPS->getDrawPages(), uno::UNO_QUERY_THROW );
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 			const oox::core::TextField& rTextField( *aIter++ );
94cdf0e10cSrcweir 			Reference< XPropertySet > xPropSet( rTextField.xTextField, UNO_QUERY );
95cdf0e10cSrcweir 	        Reference< XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
96cdf0e10cSrcweir 			if ( xPropSetInfo->hasPropertyByName( sURL ) )
97cdf0e10cSrcweir 			{
98cdf0e10cSrcweir 				rtl::OUString aURL;
99cdf0e10cSrcweir 				if ( xPropSet->getPropertyValue( sURL ) >>= aURL )
100cdf0e10cSrcweir 				{
101cdf0e10cSrcweir 					const OUString sSlide = CREATE_OUSTRING( "#Slide " );
102cdf0e10cSrcweir 					const OUString sNotes = CREATE_OUSTRING( "#Notes " );
103cdf0e10cSrcweir 					sal_Bool bNotes = sal_False;
104cdf0e10cSrcweir 					sal_Int32 nPageNumber = 0;
105cdf0e10cSrcweir 					if ( aURL.match( sSlide ) )
106cdf0e10cSrcweir 						nPageNumber = aURL.copy( sSlide.getLength() ).toInt32();
107cdf0e10cSrcweir 					else if ( aURL.match( sNotes ) )
108cdf0e10cSrcweir 					{
109cdf0e10cSrcweir 						nPageNumber = aURL.copy( sNotes.getLength() ).toInt32();
110cdf0e10cSrcweir 						bNotes = sal_True;
111cdf0e10cSrcweir 					}
112cdf0e10cSrcweir 					if ( nPageNumber )
113cdf0e10cSrcweir 					{
114cdf0e10cSrcweir 						try
115cdf0e10cSrcweir 						{
116cdf0e10cSrcweir 							Reference< XDrawPage > xDrawPage;
117cdf0e10cSrcweir 							xDrawPages->getByIndex( nPageNumber - 1 ) >>= xDrawPage;
118cdf0e10cSrcweir 							if ( bNotes )
119cdf0e10cSrcweir 							{
120cdf0e10cSrcweir 								Reference< ::com::sun::star::presentation::XPresentationPage > xPresentationPage( xDrawPage, UNO_QUERY_THROW );
121cdf0e10cSrcweir 					            xDrawPage = xPresentationPage->getNotesPage();
122cdf0e10cSrcweir 							}
123cdf0e10cSrcweir 							Reference< container::XNamed > xNamed( xDrawPage, UNO_QUERY_THROW );
124cdf0e10cSrcweir 							aURL = CREATE_OUSTRING( "#" ).concat( xNamed->getName() );
125cdf0e10cSrcweir 							xPropSet->setPropertyValue( sURL, Any( aURL ) );
126cdf0e10cSrcweir 							Reference< text::XTextContent > xContent( rTextField.xTextField, UNO_QUERY);
127cdf0e10cSrcweir 							Reference< text::XTextRange > xTextRange( rTextField.xTextCursor, UNO_QUERY );
128cdf0e10cSrcweir 							rTextField.xText->insertTextContent( xTextRange, xContent, sal_True );
129cdf0e10cSrcweir 						}
130cdf0e10cSrcweir 						catch( uno::Exception& )
131cdf0e10cSrcweir 						{
132cdf0e10cSrcweir 						}
133cdf0e10cSrcweir 					}
134cdf0e10cSrcweir 				}
135cdf0e10cSrcweir 			}
136cdf0e10cSrcweir 		}
137cdf0e10cSrcweir 	}
138cdf0e10cSrcweir }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir void PresentationFragmentHandler::endDocument() throw (SAXException, RuntimeException)
141cdf0e10cSrcweir {
142cdf0e10cSrcweir 	// todo: localized progress bar text
143cdf0e10cSrcweir 	const Reference< task::XStatusIndicator >& rxStatusIndicator( getFilter().getStatusIndicator() );
144cdf0e10cSrcweir 	if ( rxStatusIndicator.is() )
145cdf0e10cSrcweir 		rxStatusIndicator->start( rtl::OUString(), 10000 );
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 	try
148cdf0e10cSrcweir 	{
149cdf0e10cSrcweir         PowerPointImport& rFilter = dynamic_cast< PowerPointImport& >( getFilter() );
150cdf0e10cSrcweir 
151cdf0e10cSrcweir         Reference< frame::XModel > xModel( rFilter.getModel() );
152cdf0e10cSrcweir 		Reference< drawing::XDrawPage > xSlide;
153cdf0e10cSrcweir 		sal_uInt32 nSlide;
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 		// importing slide pages and its corresponding notes page
156cdf0e10cSrcweir 		Reference< drawing::XDrawPagesSupplier > xDPS( xModel, uno::UNO_QUERY_THROW );
157cdf0e10cSrcweir 		Reference< drawing::XDrawPages > xDrawPages( xDPS->getDrawPages(), uno::UNO_QUERY_THROW );
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 		for( nSlide = 0; nSlide < maSlidesVector.size(); nSlide++ )
160cdf0e10cSrcweir 		{
161cdf0e10cSrcweir 			if ( rxStatusIndicator.is() )
162cdf0e10cSrcweir 				rxStatusIndicator->setValue( ( nSlide * 10000 ) / maSlidesVector.size() );
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 			if( nSlide == 0 )
165cdf0e10cSrcweir 				xDrawPages->getByIndex( 0 ) >>= xSlide;
166cdf0e10cSrcweir 			else
167cdf0e10cSrcweir 				xSlide = xDrawPages->insertNewByIndex( nSlide );
168cdf0e10cSrcweir 
169cdf0e10cSrcweir             OUString aSlideFragmentPath = getFragmentPathFromRelId( maSlidesVector[ nSlide ] );
170cdf0e10cSrcweir             if( aSlideFragmentPath.getLength() > 0 )
171cdf0e10cSrcweir 			{
17232f3c4faSEike Rathke 				rtl::OUString aMasterFragmentPath;
173cdf0e10cSrcweir 				SlidePersistPtr pMasterPersistPtr;
174cdf0e10cSrcweir                 SlidePersistPtr pSlidePersistPtr( new SlidePersist( rFilter, sal_False, sal_False, xSlide,
175cdf0e10cSrcweir 									ShapePtr( new PPTShape( Slide, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle ) );
176cdf0e10cSrcweir 
177cdf0e10cSrcweir                 FragmentHandlerRef xSlideFragmentHandler( new SlideFragmentHandler( rFilter, aSlideFragmentPath, pSlidePersistPtr, Slide ) );
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 				// importing the corresponding masterpage/layout
180cdf0e10cSrcweir                 OUString aLayoutFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "slideLayout" ) );
181cdf0e10cSrcweir                 if ( aLayoutFragmentPath.getLength() > 0 )
182cdf0e10cSrcweir 				{
183cdf0e10cSrcweir 					// importing layout
184cdf0e10cSrcweir                     RelationsRef xLayoutRelations = rFilter.importRelations( aLayoutFragmentPath );
18532f3c4faSEike Rathke                     aMasterFragmentPath = xLayoutRelations->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "slideMaster" ) );
186cdf0e10cSrcweir                     if( aMasterFragmentPath.getLength() )
187cdf0e10cSrcweir                     {
188cdf0e10cSrcweir                         // check if the corresponding masterpage+layout has already been imported
189cdf0e10cSrcweir                         std::vector< SlidePersistPtr >& rMasterPages( rFilter.getMasterPages() );
190cdf0e10cSrcweir                         std::vector< SlidePersistPtr >::iterator aIter( rMasterPages.begin() );
191cdf0e10cSrcweir                         while( aIter != rMasterPages.end() )
192cdf0e10cSrcweir                         {
193cdf0e10cSrcweir                             if ( ( (*aIter)->getPath() == aMasterFragmentPath ) && ( (*aIter)->getLayoutPath() == aLayoutFragmentPath ) )
194cdf0e10cSrcweir                             {
195cdf0e10cSrcweir                                 pMasterPersistPtr = *aIter;
196cdf0e10cSrcweir                                 break;
197cdf0e10cSrcweir                             }
198cdf0e10cSrcweir                             aIter++;
199cdf0e10cSrcweir                         }
20032f3c4faSEike Rathke 					}
20132f3c4faSEike Rathke 				}
202cdf0e10cSrcweir 
20332f3c4faSEike Rathke                 if ( !pMasterPersistPtr.get() )
20432f3c4faSEike Rathke                 {   // masterpersist not found, we have to load it
20532f3c4faSEike Rathke                     Reference< drawing::XDrawPage > xMasterPage;
20632f3c4faSEike Rathke                     Reference< drawing::XMasterPagesSupplier > xMPS( xModel, uno::UNO_QUERY_THROW );
20732f3c4faSEike Rathke                     Reference< drawing::XDrawPages > xMasterPages( xMPS->getMasterPages(), uno::UNO_QUERY_THROW );
208cdf0e10cSrcweir 
20932f3c4faSEike Rathke                     if( !(rFilter.getMasterPages().size() ))
21032f3c4faSEike Rathke                         xMasterPages->getByIndex( 0 ) >>= xMasterPage;
21132f3c4faSEike Rathke                     else
21232f3c4faSEike Rathke                         xMasterPage = xMasterPages->insertNewByIndex( xMasterPages->getCount() );
213cdf0e10cSrcweir 
21432f3c4faSEike Rathke                     pMasterPersistPtr = SlidePersistPtr( new SlidePersist( rFilter, sal_True, sal_False, xMasterPage,
21532f3c4faSEike Rathke                         ShapePtr( new PPTShape( Master, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle ) );
21632f3c4faSEike Rathke                     pMasterPersistPtr->setLayoutPath( aLayoutFragmentPath );
21732f3c4faSEike Rathke                     rFilter.getMasterPages().push_back( pMasterPersistPtr );
21832f3c4faSEike Rathke                     rFilter.setActualSlidePersist( pMasterPersistPtr );
21932f3c4faSEike Rathke 
22032f3c4faSEike Rathke                     FragmentHandlerRef xMasterFragmentHandler( new SlideFragmentHandler( rFilter, aMasterFragmentPath, pMasterPersistPtr, Master ) );
22132f3c4faSEike Rathke 
22232f3c4faSEike Rathke                     // set the correct theme
22332f3c4faSEike Rathke                     OUString aThemeFragmentPath = xMasterFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "theme" ) );
22432f3c4faSEike Rathke                     if( aThemeFragmentPath.getLength() > 0 )
22532f3c4faSEike Rathke                     {
22632f3c4faSEike Rathke                         std::map< OUString, oox::drawingml::ThemePtr >& rThemes( rFilter.getThemes() );
22732f3c4faSEike Rathke                         std::map< OUString, oox::drawingml::ThemePtr >::iterator aIter2( rThemes.find( aThemeFragmentPath ) );
22832f3c4faSEike Rathke                         if( aIter2 == rThemes.end() )
22932f3c4faSEike Rathke                         {
23032f3c4faSEike Rathke                             oox::drawingml::ThemePtr pThemePtr( new oox::drawingml::Theme() );
23132f3c4faSEike Rathke                             pMasterPersistPtr->setTheme( pThemePtr );
23232f3c4faSEike Rathke                             rFilter.importFragment( new ThemeFragmentHandler( rFilter, aThemeFragmentPath, *pThemePtr ) );
23332f3c4faSEike Rathke                             rThemes[ aThemeFragmentPath ] = pThemePtr;
23432f3c4faSEike Rathke                         }
23532f3c4faSEike Rathke                         else
23632f3c4faSEike Rathke                         {
23732f3c4faSEike Rathke                             pMasterPersistPtr->setTheme( (*aIter2).second );
238cdf0e10cSrcweir                         }
239cdf0e10cSrcweir                     }
24032f3c4faSEike Rathke                     importSlide( xMasterFragmentHandler, pMasterPersistPtr );
24132f3c4faSEike Rathke                     rFilter.importFragment( new LayoutFragmentHandler( rFilter, aLayoutFragmentPath, pMasterPersistPtr ) );
24232f3c4faSEike Rathke                     pMasterPersistPtr->createBackground( rFilter );
24332f3c4faSEike Rathke                     pMasterPersistPtr->createXShapes( rFilter );
24432f3c4faSEike Rathke                 }
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 				// importing slide page
247cdf0e10cSrcweir 				pSlidePersistPtr->setMasterPersist( pMasterPersistPtr );
248cdf0e10cSrcweir 				pSlidePersistPtr->setTheme( pMasterPersistPtr->getTheme() );
249cdf0e10cSrcweir 				Reference< drawing::XMasterPageTarget > xMasterPageTarget( pSlidePersistPtr->getPage(), UNO_QUERY );
250cdf0e10cSrcweir 				if( xMasterPageTarget.is() )
251cdf0e10cSrcweir 					xMasterPageTarget->setMasterPage( pMasterPersistPtr->getPage() );
252cdf0e10cSrcweir                 rFilter.getDrawPages().push_back( pSlidePersistPtr );
253cdf0e10cSrcweir                 rFilter.setActualSlidePersist( pSlidePersistPtr );
254cdf0e10cSrcweir                 importSlide( xSlideFragmentHandler, pSlidePersistPtr );
255cdf0e10cSrcweir                 pSlidePersistPtr->createBackground( rFilter );
256cdf0e10cSrcweir                 pSlidePersistPtr->createXShapes( rFilter );
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 				// now importing the notes page
259cdf0e10cSrcweir                 OUString aNotesFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "notesSlide" ) );
260cdf0e10cSrcweir                 if( aNotesFragmentPath.getLength() > 0 )
261cdf0e10cSrcweir                 {
262cdf0e10cSrcweir 					Reference< XPresentationPage > xPresentationPage( xSlide, UNO_QUERY );
263cdf0e10cSrcweir 					if ( xPresentationPage.is() )
264cdf0e10cSrcweir 					{
265cdf0e10cSrcweir 						Reference< XDrawPage > xNotesPage( xPresentationPage->getNotesPage() );
266cdf0e10cSrcweir 						if ( xNotesPage.is() )
267cdf0e10cSrcweir 						{
268cdf0e10cSrcweir                             SlidePersistPtr pNotesPersistPtr( new SlidePersist( rFilter, sal_False, sal_True, xNotesPage,
269cdf0e10cSrcweir 								ShapePtr( new PPTShape( Slide, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle ) );
270cdf0e10cSrcweir                             FragmentHandlerRef xNotesFragmentHandler( new SlideFragmentHandler( getFilter(), aNotesFragmentPath, pNotesPersistPtr, Slide ) );
271*4b2c1a94SSteve Yin 							// import notesMaster slide for notes slide shapes format
272*4b2c1a94SSteve Yin 							OUString aNotesMasterFragmentPath = xNotesFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "notesMaster" ) );
273*4b2c1a94SSteve Yin 							SlidePersistPtr pNotesMasterPersistPtr( new SlidePersist( rFilter, sal_True/*sal_False*/, sal_True, xNotesPage,
274*4b2c1a94SSteve Yin 								ShapePtr( new PPTShape( Slide, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle ) );
275*4b2c1a94SSteve Yin 							FragmentHandlerRef xNotesMasterFragmentHandler( new SlideFragmentHandler( getFilter(), aNotesMasterFragmentPath, pNotesMasterPersistPtr, Slide ) );
276*4b2c1a94SSteve Yin 							importSlide( xNotesMasterFragmentHandler, pNotesMasterPersistPtr );
277*4b2c1a94SSteve Yin 							pNotesMasterPersistPtr->createXShapes( rFilter );
278*4b2c1a94SSteve Yin 							pNotesPersistPtr->setMasterPersist(pNotesMasterPersistPtr);
279cdf0e10cSrcweir                             rFilter.getNotesPages().push_back( pNotesPersistPtr );
280cdf0e10cSrcweir                             rFilter.setActualSlidePersist( pNotesPersistPtr );
281cdf0e10cSrcweir                             importSlide( xNotesFragmentHandler, pNotesPersistPtr );
282cdf0e10cSrcweir                             pNotesPersistPtr->createBackground( rFilter );
283cdf0e10cSrcweir                             pNotesPersistPtr->createXShapes( rFilter );
284cdf0e10cSrcweir 						}
285cdf0e10cSrcweir 					}
286cdf0e10cSrcweir 				}
287cdf0e10cSrcweir 			}
288cdf0e10cSrcweir 		}
289cdf0e10cSrcweir 		ResolveTextFields( rFilter );
290cdf0e10cSrcweir 	}
291cdf0e10cSrcweir 	catch( uno::Exception& )
292cdf0e10cSrcweir 	{
293cdf0e10cSrcweir         OSL_ENSURE( false,
294cdf0e10cSrcweir 			(rtl::OString("oox::ppt::PresentationFragmentHandler::EndDocument(), "
295cdf0e10cSrcweir 					"exception caught: ") +
296cdf0e10cSrcweir 			rtl::OUStringToOString(
297cdf0e10cSrcweir 				comphelper::anyToString( cppu::getCaughtException() ),
298cdf0e10cSrcweir 				RTL_TEXTENCODING_UTF8 )).getStr() );
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 	}
301cdf0e10cSrcweir 
302cdf0e10cSrcweir 	// todo	error handling;
303cdf0e10cSrcweir 	if ( rxStatusIndicator.is() )
304cdf0e10cSrcweir 		rxStatusIndicator->end();
305cdf0e10cSrcweir }
306cdf0e10cSrcweir 
307cdf0e10cSrcweir // CT_Presentation
308cdf0e10cSrcweir Reference< XFastContextHandler > PresentationFragmentHandler::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
309cdf0e10cSrcweir {
310cdf0e10cSrcweir 	Reference< XFastContextHandler > xRet;
311cdf0e10cSrcweir 	switch( aElementToken )
312cdf0e10cSrcweir 	{
313cdf0e10cSrcweir 	case PPT_TOKEN( presentation ):
314cdf0e10cSrcweir 	case PPT_TOKEN( sldMasterIdLst ):
315cdf0e10cSrcweir 	case PPT_TOKEN( notesMasterIdLst ):
316cdf0e10cSrcweir 	case PPT_TOKEN( sldIdLst ):
317cdf0e10cSrcweir 		break;
318cdf0e10cSrcweir 	case PPT_TOKEN( sldMasterId ):
319cdf0e10cSrcweir 		maSlideMasterVector.push_back( xAttribs->getOptionalValue( R_TOKEN( id ) ) );
320cdf0e10cSrcweir 		break;
321cdf0e10cSrcweir 	case PPT_TOKEN( sldId ):
322cdf0e10cSrcweir 		maSlidesVector.push_back( xAttribs->getOptionalValue( R_TOKEN( id ) ) );
323cdf0e10cSrcweir 		break;
324cdf0e10cSrcweir 	case PPT_TOKEN( notesMasterId ):
325cdf0e10cSrcweir 		maNotesMasterVector.push_back( xAttribs->getOptionalValue(R_TOKEN( id ) ) );
326cdf0e10cSrcweir 		break;
327cdf0e10cSrcweir 	case PPT_TOKEN( sldSz ):
328cdf0e10cSrcweir 		maSlideSize = GetSize2D( xAttribs );
329cdf0e10cSrcweir 		break;
330cdf0e10cSrcweir 	case PPT_TOKEN( notesSz ):
331cdf0e10cSrcweir 		maNotesSize = GetSize2D( xAttribs );
332cdf0e10cSrcweir 		break;
333cdf0e10cSrcweir 	case PPT_TOKEN( custShowLst ):
334cdf0e10cSrcweir         xRet.set( new CustomShowListContext( *this, maCustomShowList ) );
335cdf0e10cSrcweir 		break;
336cdf0e10cSrcweir 	case PPT_TOKEN( defaultTextStyle ):
337cdf0e10cSrcweir         xRet.set( new TextListStyleContext( *this, *mpTextListStyle ) );
338cdf0e10cSrcweir 		break;
339cdf0e10cSrcweir 	}
340cdf0e10cSrcweir 	if ( !xRet.is() )
341cdf0e10cSrcweir         xRet = getFastContextHandler();
342cdf0e10cSrcweir 	return xRet;
343cdf0e10cSrcweir }
344cdf0e10cSrcweir 
345cdf0e10cSrcweir bool PresentationFragmentHandler::importSlide( const FragmentHandlerRef& rxSlideFragmentHandler,
346cdf0e10cSrcweir         const SlidePersistPtr pSlidePersistPtr )
347cdf0e10cSrcweir {
348cdf0e10cSrcweir 	Reference< drawing::XDrawPage > xSlide( pSlidePersistPtr->getPage() );
349cdf0e10cSrcweir 	SlidePersistPtr pMasterPersistPtr( pSlidePersistPtr->getMasterPersist() );
350cdf0e10cSrcweir 	if ( pMasterPersistPtr.get() )
351cdf0e10cSrcweir 	{
352cdf0e10cSrcweir         const OUString sLayout = CREATE_OUSTRING( "Layout" );
353cdf0e10cSrcweir 		uno::Reference< beans::XPropertySet > xSet( xSlide, uno::UNO_QUERY_THROW );
354cdf0e10cSrcweir 		xSet->setPropertyValue(	sLayout, Any( pMasterPersistPtr->getLayoutFromValueToken() ) );
355cdf0e10cSrcweir 	}
356cdf0e10cSrcweir 	while( xSlide->getCount() )
357cdf0e10cSrcweir 	{
358cdf0e10cSrcweir 		Reference< drawing::XShape > xShape;
359cdf0e10cSrcweir 		xSlide->getByIndex(0) >>= xShape;
360cdf0e10cSrcweir 		xSlide->remove( xShape );
361cdf0e10cSrcweir 	}
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 	Reference< XPropertySet > xPropertySet( xSlide, UNO_QUERY );
364cdf0e10cSrcweir 	if ( xPropertySet.is() )
365cdf0e10cSrcweir 	{
366cdf0e10cSrcweir         static const OUString sWidth = CREATE_OUSTRING( "Width" );
367cdf0e10cSrcweir         static const OUString sHeight = CREATE_OUSTRING( "Height" );
368cdf0e10cSrcweir 		awt::Size& rPageSize( pSlidePersistPtr->isNotesPage() ? maNotesSize : maSlideSize );
369cdf0e10cSrcweir 		xPropertySet->setPropertyValue( sWidth, Any( rPageSize.Width ) );
370cdf0e10cSrcweir 		xPropertySet->setPropertyValue( sHeight, Any( rPageSize.Height ) );
371cdf0e10cSrcweir 
372cdf0e10cSrcweir 		oox::ppt::HeaderFooter aHeaderFooter( pSlidePersistPtr->getHeaderFooter() );
373cdf0e10cSrcweir 		if ( !pSlidePersistPtr->isMasterPage() )
374cdf0e10cSrcweir 			aHeaderFooter.mbSlideNumber = aHeaderFooter.mbHeader = aHeaderFooter.mbFooter = aHeaderFooter.mbDateTime = sal_False;
375cdf0e10cSrcweir 		try
376cdf0e10cSrcweir 		{
377cdf0e10cSrcweir 			static const OUString sIsHeaderVisible = CREATE_OUSTRING( "IsHeaderVisible" );
378cdf0e10cSrcweir 			static const OUString sIsFooterVisible = CREATE_OUSTRING( "IsFooterVisible" );
379cdf0e10cSrcweir 			static const OUString sIsDateTimeVisible = CREATE_OUSTRING( "IsDateTimeVisible" );
380cdf0e10cSrcweir 			static const OUString sIsPageNumberVisible = CREATE_OUSTRING( "IsPageNumberVisible" );
381cdf0e10cSrcweir 
382cdf0e10cSrcweir 			if ( pSlidePersistPtr->isNotesPage() )
383cdf0e10cSrcweir 				xPropertySet->setPropertyValue( sIsHeaderVisible, Any( aHeaderFooter.mbHeader ) );
384cdf0e10cSrcweir 			xPropertySet->setPropertyValue( sIsFooterVisible, Any( aHeaderFooter.mbFooter ) );
385cdf0e10cSrcweir 			xPropertySet->setPropertyValue( sIsDateTimeVisible, Any( aHeaderFooter.mbDateTime ) );
386cdf0e10cSrcweir 			xPropertySet->setPropertyValue( sIsPageNumberVisible, Any( aHeaderFooter.mbSlideNumber ) );
387cdf0e10cSrcweir 		}
388cdf0e10cSrcweir 		catch( uno::Exception& )
389cdf0e10cSrcweir 		{
390cdf0e10cSrcweir 		}
391cdf0e10cSrcweir 	}
392cdf0e10cSrcweir     pSlidePersistPtr->setPath( rxSlideFragmentHandler->getFragmentPath() );
393cdf0e10cSrcweir     return getFilter().importFragment( rxSlideFragmentHandler );
394cdf0e10cSrcweir }
395cdf0e10cSrcweir 
396cdf0e10cSrcweir } }
397cdf0e10cSrcweir 
398