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 : #include "comphelper/anytostring.hxx"
21 : #include "cppuhelper/exc_hlp.hxx"
22 : #include <osl/diagnose.h>
23 : #include <tools/multisel.hxx>
24 :
25 : #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
26 : #include <com/sun/star/drawing/XDrawPages.hpp>
27 : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
28 : #include <com/sun/star/drawing/XMasterPageTarget.hpp>
29 : #include <com/sun/star/xml/dom/XDocument.hpp>
30 : #include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
31 : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
32 : #include <com/sun/star/style/XStyle.hpp>
33 : #include <com/sun/star/presentation/XPresentationPage.hpp>
34 : #include <com/sun/star/task/XStatusIndicator.hpp>
35 :
36 : #include "oox/drawingml/theme.hxx"
37 : #include "oox/drawingml/drawingmltypes.hxx"
38 : #include "oox/drawingml/themefragmenthandler.hxx"
39 : #include "drawingml/textliststylecontext.hxx"
40 : #include "oox/ppt/pptshape.hxx"
41 : #include "oox/ppt/presentationfragmenthandler.hxx"
42 : #include "oox/ppt/slidefragmenthandler.hxx"
43 : #include "oox/ppt/layoutfragmenthandler.hxx"
44 : #include "oox/ppt/pptimport.hxx"
45 :
46 : #include <com/sun/star/office/XAnnotation.hpp>
47 : #include <com/sun/star/office/XAnnotationAccess.hpp>
48 :
49 : using namespace ::com::sun::star;
50 : using namespace ::oox::core;
51 : using namespace ::oox::drawingml;
52 : using namespace ::com::sun::star::uno;
53 : using namespace ::com::sun::star::beans;
54 : using namespace ::com::sun::star::drawing;
55 : using namespace ::com::sun::star::presentation;
56 : using namespace ::com::sun::star::xml::sax;
57 :
58 : namespace oox { namespace ppt {
59 :
60 83 : PresentationFragmentHandler::PresentationFragmentHandler( XmlFilterBase& rFilter, const OUString& rFragmentPath ) throw()
61 : : FragmentHandler2( rFilter, rFragmentPath )
62 83 : , mpTextListStyle( new TextListStyle )
63 166 : , mbCommentAuthorsRead(false)
64 : {
65 83 : TextParagraphPropertiesVector& rParagraphDefaulsVector( mpTextListStyle->getListStyle() );
66 83 : TextParagraphPropertiesVector::iterator aParagraphDefaultIter( rParagraphDefaulsVector.begin() );
67 913 : while( aParagraphDefaultIter != rParagraphDefaulsVector.end() )
68 : {
69 : // ppt is having zero bottom margin per default, whereas OOo is 0,5cm,
70 : // so this attribute needs to be set always
71 747 : (*aParagraphDefaultIter++)->getParaBottomMargin() = TextSpacing( 0 );
72 : }
73 83 : }
74 :
75 166 : PresentationFragmentHandler::~PresentationFragmentHandler() throw()
76 : {
77 166 : }
78 :
79 83 : void ResolveTextFields( XmlFilterBase& rFilter )
80 : {
81 83 : const oox::core::TextFieldStack& rTextFields = rFilter.getTextFieldStack();
82 83 : if ( rTextFields.size() )
83 : {
84 0 : Reference< frame::XModel > xModel( rFilter.getModel() );
85 0 : oox::core::TextFieldStack::const_iterator aIter( rTextFields.begin() );
86 0 : while( aIter != rTextFields.end() )
87 : {
88 0 : const OUString sURL = "URL";
89 0 : Reference< drawing::XDrawPagesSupplier > xDPS( xModel, uno::UNO_QUERY_THROW );
90 0 : Reference< drawing::XDrawPages > xDrawPages( xDPS->getDrawPages(), uno::UNO_QUERY_THROW );
91 :
92 0 : const oox::core::TextField& rTextField( *aIter++ );
93 0 : Reference< XPropertySet > xPropSet( rTextField.xTextField, UNO_QUERY );
94 0 : Reference< XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
95 0 : if ( xPropSetInfo->hasPropertyByName( sURL ) )
96 : {
97 0 : OUString aURL;
98 0 : if ( xPropSet->getPropertyValue( sURL ) >>= aURL )
99 : {
100 0 : const OUString sSlide = "#Slide ";
101 0 : const OUString sNotes = "#Notes ";
102 0 : bool bNotes = false;
103 0 : sal_Int32 nPageNumber = 0;
104 0 : if ( aURL.match( sSlide ) )
105 0 : nPageNumber = aURL.copy( sSlide.getLength() ).toInt32();
106 0 : else if ( aURL.match( sNotes ) )
107 : {
108 0 : nPageNumber = aURL.copy( sNotes.getLength() ).toInt32();
109 0 : bNotes = true;
110 : }
111 0 : if ( nPageNumber )
112 : {
113 : try
114 : {
115 0 : Reference< XDrawPage > xDrawPage;
116 0 : xDrawPages->getByIndex( nPageNumber - 1 ) >>= xDrawPage;
117 0 : if ( bNotes )
118 : {
119 0 : Reference< ::com::sun::star::presentation::XPresentationPage > xPresentationPage( xDrawPage, UNO_QUERY_THROW );
120 0 : xDrawPage = xPresentationPage->getNotesPage();
121 : }
122 0 : Reference< container::XNamed > xNamed( xDrawPage, UNO_QUERY_THROW );
123 0 : aURL = "#" + xNamed->getName();
124 0 : xPropSet->setPropertyValue( sURL, Any( aURL ) );
125 0 : Reference< text::XTextContent > xContent( rTextField.xTextField, UNO_QUERY);
126 0 : Reference< text::XTextRange > xTextRange( rTextField.xTextCursor, UNO_QUERY );
127 0 : rTextField.xText->insertTextContent( xTextRange, xContent, sal_True );
128 : }
129 0 : catch( uno::Exception& )
130 : {
131 : }
132 0 : }
133 0 : }
134 : }
135 0 : }
136 : }
137 83 : }
138 :
139 94 : void PresentationFragmentHandler::importSlide(sal_uInt32 nSlide, bool bFirstPage, bool bImportNotesPage)
140 : {
141 94 : PowerPointImport& rFilter = dynamic_cast< PowerPointImport& >( getFilter() );
142 :
143 94 : Reference< frame::XModel > xModel( rFilter.getModel() );
144 188 : Reference< drawing::XDrawPage > xSlide;
145 :
146 : // importing slide pages and its corresponding notes page
147 188 : Reference< drawing::XDrawPagesSupplier > xDPS( xModel, uno::UNO_QUERY_THROW );
148 188 : Reference< drawing::XDrawPages > xDrawPages( xDPS->getDrawPages(), uno::UNO_QUERY_THROW );
149 :
150 : try {
151 :
152 94 : if( bFirstPage )
153 83 : xDrawPages->getByIndex( 0 ) >>= xSlide;
154 : else
155 11 : xSlide = xDrawPages->insertNewByIndex( xDrawPages->getCount() );
156 :
157 94 : OUString aSlideFragmentPath = getFragmentPathFromRelId( maSlidesVector[ nSlide ] );
158 94 : if( !aSlideFragmentPath.isEmpty() )
159 : {
160 94 : SlidePersistPtr pMasterPersistPtr;
161 : SlidePersistPtr pSlidePersistPtr( new SlidePersist( rFilter, false, false, xSlide,
162 188 : ShapePtr( new PPTShape( Slide, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle ) );
163 :
164 188 : FragmentHandlerRef xSlideFragmentHandler( new SlideFragmentHandler( rFilter, aSlideFragmentPath, pSlidePersistPtr, Slide ) );
165 :
166 : // importing the corresponding masterpage/layout
167 188 : OUString aLayoutFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( "slideLayout" );
168 188 : OUString aCommentFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( "comments" );
169 94 : if ( !aLayoutFragmentPath.isEmpty() )
170 : {
171 : // importing layout
172 94 : RelationsRef xLayoutRelations = rFilter.importRelations( aLayoutFragmentPath );
173 188 : OUString aMasterFragmentPath = xLayoutRelations->getFragmentPathFromFirstTypeFromOfficeDoc( "slideMaster" );
174 94 : if( !aMasterFragmentPath.isEmpty() )
175 : {
176 : // check if the corresponding masterpage+layout has already been imported
177 94 : std::vector< SlidePersistPtr >& rMasterPages( rFilter.getMasterPages() );
178 94 : std::vector< SlidePersistPtr >::iterator aIter( rMasterPages.begin() );
179 193 : while( aIter != rMasterPages.end() )
180 : {
181 11 : if ( ( (*aIter)->getPath() == aMasterFragmentPath ) && ( (*aIter)->getLayoutPath() == aLayoutFragmentPath ) )
182 : {
183 6 : pMasterPersistPtr = *aIter;
184 6 : break;
185 : }
186 5 : ++aIter;
187 : }
188 :
189 94 : if ( !pMasterPersistPtr.get() )
190 : { // masterpersist not found, we have to load it
191 88 : Reference< drawing::XDrawPage > xMasterPage;
192 176 : Reference< drawing::XMasterPagesSupplier > xMPS( xModel, uno::UNO_QUERY_THROW );
193 176 : Reference< drawing::XDrawPages > xMasterPages( xMPS->getMasterPages(), uno::UNO_QUERY_THROW );
194 :
195 88 : if( !(rFilter.getMasterPages().size() ))
196 83 : xMasterPages->getByIndex( 0 ) >>= xMasterPage;
197 : else
198 5 : xMasterPage = xMasterPages->insertNewByIndex( xMasterPages->getCount() );
199 :
200 352 : pMasterPersistPtr = SlidePersistPtr( new SlidePersist( rFilter, true, false, xMasterPage,
201 264 : ShapePtr( new PPTShape( Master, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle ) );
202 88 : pMasterPersistPtr->setLayoutPath( aLayoutFragmentPath );
203 88 : rFilter.getMasterPages().push_back( pMasterPersistPtr );
204 88 : rFilter.setActualSlidePersist( pMasterPersistPtr );
205 176 : FragmentHandlerRef xMasterFragmentHandler( new SlideFragmentHandler( rFilter, aMasterFragmentPath, pMasterPersistPtr, Master ) );
206 :
207 : // set the correct theme
208 176 : OUString aThemeFragmentPath = xMasterFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( "theme" );
209 88 : if( !aThemeFragmentPath.isEmpty() )
210 : {
211 88 : std::map< OUString, oox::drawingml::ThemePtr >& rThemes( rFilter.getThemes() );
212 88 : std::map< OUString, oox::drawingml::ThemePtr >::iterator aIter2( rThemes.find( aThemeFragmentPath ) );
213 88 : if( aIter2 == rThemes.end() )
214 : {
215 83 : oox::drawingml::ThemePtr pThemePtr( new oox::drawingml::Theme() );
216 83 : pMasterPersistPtr->setTheme( pThemePtr );
217 : Reference<xml::dom::XDocument> xDoc=
218 166 : rFilter.importFragment(aThemeFragmentPath);
219 :
220 : rFilter.importFragment(
221 : new ThemeFragmentHandler(
222 83 : rFilter, aThemeFragmentPath, *pThemePtr ),
223 : Reference<xml::sax::XFastSAXSerializable>(
224 : xDoc,
225 166 : UNO_QUERY_THROW));
226 83 : rThemes[ aThemeFragmentPath ] = pThemePtr;
227 166 : pThemePtr->setFragment(xDoc);
228 : }
229 : else
230 : {
231 5 : pMasterPersistPtr->setTheme( (*aIter2).second );
232 : }
233 : }
234 88 : importSlide( xMasterFragmentHandler, pMasterPersistPtr );
235 88 : rFilter.importFragment( new LayoutFragmentHandler( rFilter, aLayoutFragmentPath, pMasterPersistPtr ) );
236 88 : pMasterPersistPtr->createBackground( rFilter );
237 176 : pMasterPersistPtr->createXShapes( rFilter );
238 : }
239 94 : }
240 : }
241 :
242 : // importing slide page
243 94 : if (pMasterPersistPtr.get()) {
244 94 : pSlidePersistPtr->setMasterPersist( pMasterPersistPtr );
245 94 : pSlidePersistPtr->setTheme( pMasterPersistPtr->getTheme() );
246 94 : Reference< drawing::XMasterPageTarget > xMasterPageTarget( pSlidePersistPtr->getPage(), UNO_QUERY );
247 94 : if( xMasterPageTarget.is() )
248 94 : xMasterPageTarget->setMasterPage( pMasterPersistPtr->getPage() );
249 : }
250 94 : rFilter.getDrawPages().push_back( pSlidePersistPtr );
251 94 : rFilter.setActualSlidePersist( pSlidePersistPtr );
252 94 : importSlide( xSlideFragmentHandler, pSlidePersistPtr );
253 94 : pSlidePersistPtr->createBackground( rFilter );
254 94 : pSlidePersistPtr->createXShapes( rFilter );
255 :
256 94 : if(bImportNotesPage) {
257 :
258 : // now importing the notes page
259 94 : OUString aNotesFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( "notesSlide" );
260 94 : if( !aNotesFragmentPath.isEmpty() )
261 : {
262 11 : Reference< XPresentationPage > xPresentationPage( xSlide, UNO_QUERY );
263 11 : if ( xPresentationPage.is() )
264 : {
265 11 : Reference< XDrawPage > xNotesPage( xPresentationPage->getNotesPage() );
266 11 : if ( xNotesPage.is() )
267 : {
268 : SlidePersistPtr pNotesPersistPtr( new SlidePersist( rFilter, false, true, xNotesPage,
269 11 : ShapePtr( new PPTShape( Slide, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle ) );
270 22 : FragmentHandlerRef xNotesFragmentHandler( new SlideFragmentHandler( getFilter(), aNotesFragmentPath, pNotesPersistPtr, Slide ) );
271 11 : rFilter.getNotesPages().push_back( pNotesPersistPtr );
272 11 : rFilter.setActualSlidePersist( pNotesPersistPtr );
273 11 : importSlide( xNotesFragmentHandler, pNotesPersistPtr );
274 11 : pNotesPersistPtr->createBackground( rFilter );
275 22 : pNotesPersistPtr->createXShapes( rFilter );
276 11 : }
277 11 : }
278 94 : }
279 : }
280 :
281 94 : if( !mbCommentAuthorsRead && !aCommentFragmentPath.isEmpty() )
282 : {
283 : // Comments are present and commentAuthors.xml has still not been read
284 0 : mbCommentAuthorsRead = true;
285 0 : OUString aCommentAuthorsFragmentPath = "ppt/commentAuthors.xml";
286 0 : Reference< XPresentationPage > xPresentationPage( xSlide, UNO_QUERY );
287 0 : Reference< XDrawPage > xCommentAuthorsPage( xPresentationPage->getNotesPage() );
288 : SlidePersistPtr pCommentAuthorsPersistPtr(
289 : new SlidePersist( rFilter, false, true, xCommentAuthorsPage,
290 : ShapePtr(
291 : new PPTShape(
292 0 : Slide, "com.sun.star.drawing.GroupShape" ) ),
293 0 : mpTextListStyle ) );
294 : FragmentHandlerRef xCommentAuthorsFragmentHandler(
295 0 : new SlideFragmentHandler( getFilter(),
296 : aCommentAuthorsFragmentPath,
297 : pCommentAuthorsPersistPtr,
298 0 : Slide ) );
299 :
300 0 : importSlide( xCommentAuthorsFragmentHandler, pCommentAuthorsPersistPtr );
301 0 : maAuthorList.setValues( pCommentAuthorsPersistPtr->getCommentAuthors() );
302 : }
303 94 : if( !aCommentFragmentPath.isEmpty() )
304 : {
305 0 : Reference< XPresentationPage > xPresentationPage( xSlide, UNO_QUERY );
306 0 : Reference< XDrawPage > xCommentsPage( xPresentationPage->getNotesPage() );
307 : SlidePersistPtr pCommentsPersistPtr(
308 : new SlidePersist(
309 : rFilter, false, true, xCommentsPage,
310 : ShapePtr(
311 : new PPTShape(
312 0 : Slide, "com.sun.star.drawing.GroupShape" ) ),
313 0 : mpTextListStyle ) );
314 :
315 : FragmentHandlerRef xCommentsFragmentHandler(
316 : new SlideFragmentHandler(
317 0 : getFilter(),
318 : aCommentFragmentPath,
319 : pCommentsPersistPtr,
320 0 : Slide ) );
321 0 : pCommentsPersistPtr->getCommentsList().cmLst.clear();
322 0 : importSlide( xCommentsFragmentHandler, pCommentsPersistPtr );
323 :
324 : //set comment chars for last comment on slide
325 : SlideFragmentHandler* comment_handler =
326 0 : dynamic_cast<SlideFragmentHandler*>(xCommentsFragmentHandler.get());
327 : // some comments have no text -> set empty string as text to avoid
328 : // crash (back() on empty vector is undefined) and losing other
329 : // comment data that might be there (author, position, timestamp etc.)
330 0 : pCommentsPersistPtr->getCommentsList().cmLst.back().setText(
331 0 : comment_handler->getCharVector().empty() ? "" :
332 0 : comment_handler->getCharVector().back() );
333 0 : pCommentsPersistPtr->getCommentAuthors().setValues(maAuthorList);
334 :
335 : //insert all comments from commentsList
336 0 : for(int i=0; i<pCommentsPersistPtr->getCommentsList().getSize(); i++)
337 : {
338 : try {
339 0 : Comment aComment = pCommentsPersistPtr->getCommentsList().getCommentAtIndex(i);
340 0 : uno::Reference< office::XAnnotationAccess > xAnnotationAccess( xSlide, UNO_QUERY_THROW );
341 0 : uno::Reference< office::XAnnotation > xAnnotation( xAnnotationAccess->createAndInsertAnnotation() );
342 0 : int nPosX = aComment.getIntX();
343 0 : int nPosY = aComment.getIntY();
344 0 : xAnnotation->setPosition(
345 : geometry::RealPoint2D(
346 0 : ::oox::drawingml::convertEmuToHmm( nPosX ) * 15.87,
347 0 : ::oox::drawingml::convertEmuToHmm( nPosY ) * 15.87 ) );
348 0 : xAnnotation->setAuthor( aComment.getAuthor(maAuthorList) );
349 0 : xAnnotation->setDateTime( aComment.getDateTime() );
350 0 : uno::Reference< text::XText > xText( xAnnotation->getTextRange() );
351 0 : xText->setString( aComment.get_text());
352 0 : } catch( css::lang::IllegalArgumentException& ) {}
353 0 : }
354 94 : }
355 94 : }
356 : }
357 0 : catch( uno::Exception& )
358 : {
359 : OSL_FAIL( OString("oox::ppt::PresentationFragmentHandler::EndDocument(), "
360 : "exception caught: " +
361 : OUStringToOString(
362 : comphelper::anyToString( cppu::getCaughtException() ),
363 : RTL_TEXTENCODING_UTF8 )).getStr() );
364 :
365 94 : }
366 94 : }
367 :
368 83 : void PresentationFragmentHandler::finalizeImport()
369 : {
370 83 : PowerPointImport& rFilter = dynamic_cast< PowerPointImport& >( getFilter() );
371 :
372 83 : sal_Int32 nPageCount = maSlidesVector.size();
373 :
374 : // we will take the FilterData property "PageRange" if available, otherwise full range is used
375 83 : comphelper::SequenceAsHashMap& rFilterData = rFilter.getFilterData();
376 :
377 : // writing back the original PageCount of this document, it can be accessed from the XModel
378 : // via getArgs after the import.
379 83 : rFilterData["OriginalPageCount"] = makeAny(nPageCount);
380 83 : bool bImportNotesPages = rFilterData.getUnpackedValueOrDefault("ImportNotesPages", true);
381 83 : OUString aPageRange = rFilterData.getUnpackedValueOrDefault("PageRange", OUString());
382 :
383 83 : if( !aPageRange.getLength() )
384 : {
385 249 : aPageRange = OUStringBuffer()
386 166 : .append( static_cast< sal_Int32 >( 1 ) )
387 83 : .append( '-' )
388 166 : .append( nPageCount ).makeStringAndClear();
389 : }
390 :
391 166 : StringRangeEnumerator aRangeEnumerator( aPageRange, 0, nPageCount - 1 );
392 83 : StringRangeEnumerator::Iterator aIter = aRangeEnumerator.begin();
393 83 : StringRangeEnumerator::Iterator aEnd = aRangeEnumerator.end();
394 83 : if(aIter!=aEnd) {
395 :
396 : // todo: localized progress bar text
397 83 : const Reference< task::XStatusIndicator >& rxStatusIndicator( getFilter().getStatusIndicator() );
398 83 : if ( rxStatusIndicator.is() )
399 6 : rxStatusIndicator->start( OUString(), 10000 );
400 :
401 : try
402 : {
403 83 : int nPagesImported = 0;
404 260 : while (aIter!=aEnd)
405 : {
406 94 : if ( rxStatusIndicator.is() )
407 9 : rxStatusIndicator->setValue((nPagesImported * 10000) / aRangeEnumerator.size());
408 :
409 94 : importSlide(*aIter, !nPagesImported, bImportNotesPages);
410 94 : nPagesImported++;
411 94 : ++aIter;
412 : }
413 83 : ResolveTextFields( rFilter );
414 : }
415 0 : catch( uno::Exception& )
416 : {
417 : OSL_FAIL( OString("oox::ppt::PresentationFragmentHandler::finalizeImport(), "
418 : "exception caught: " +
419 : OUStringToOString(
420 : comphelper::anyToString( cppu::getCaughtException() ),
421 : RTL_TEXTENCODING_UTF8 )).getStr() );
422 : }
423 : // todo error handling;
424 83 : if ( rxStatusIndicator.is() )
425 6 : rxStatusIndicator->end();
426 83 : }
427 83 : }
428 :
429 : // CT_Presentation
430 717 : ::oox::core::ContextHandlerRef PresentationFragmentHandler::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
431 : {
432 717 : switch( aElementToken )
433 : {
434 : case PPT_TOKEN( presentation ):
435 : case PPT_TOKEN( sldMasterIdLst ):
436 : case PPT_TOKEN( notesMasterIdLst ):
437 : case PPT_TOKEN( sldIdLst ):
438 264 : return this;
439 : case PPT_TOKEN( sldMasterId ):
440 83 : maSlideMasterVector.push_back( rAttribs.getString( R_TOKEN( id ), OUString() ) );
441 83 : return this;
442 : case PPT_TOKEN( sldId ):
443 94 : maSlidesVector.push_back( rAttribs.getString( R_TOKEN( id ), OUString() ) );
444 94 : return this;
445 : case PPT_TOKEN( notesMasterId ):
446 15 : maNotesMasterVector.push_back( rAttribs.getString( R_TOKEN( id ), OUString() ) );
447 15 : return this;
448 : case PPT_TOKEN( sldSz ):
449 83 : maSlideSize = GetSize2D( rAttribs.getFastAttributeList() );
450 83 : return this;
451 : case PPT_TOKEN( notesSz ):
452 83 : maNotesSize = GetSize2D( rAttribs.getFastAttributeList() );
453 83 : return this;
454 : case PPT_TOKEN( custShowLst ):
455 0 : return new CustomShowListContext( *this, maCustomShowList );
456 : case PPT_TOKEN( defaultTextStyle ):
457 53 : return new TextListStyleContext( *this, *mpTextListStyle );
458 : }
459 42 : return this;
460 : }
461 :
462 193 : bool PresentationFragmentHandler::importSlide( const FragmentHandlerRef& rxSlideFragmentHandler,
463 : const SlidePersistPtr& rSlidePersistPtr )
464 : {
465 193 : Reference< drawing::XDrawPage > xSlide( rSlidePersistPtr->getPage() );
466 386 : SlidePersistPtr pMasterPersistPtr( rSlidePersistPtr->getMasterPersist() );
467 193 : if ( pMasterPersistPtr.get() )
468 : {
469 : // Setting "Layout" property adds extra title and outliner preset shapes to the master slide
470 94 : Reference< drawing::XDrawPage > xMasterSlide(pMasterPersistPtr->getPage());
471 94 : const int nCount = xMasterSlide->getCount();
472 :
473 188 : const OUString sLayout = "Layout";
474 188 : uno::Reference< beans::XPropertySet > xSet( xSlide, uno::UNO_QUERY_THROW );
475 94 : xSet->setPropertyValue( sLayout, Any( pMasterPersistPtr->getLayoutFromValueToken() ) );
476 :
477 271 : while( nCount < xMasterSlide->getCount())
478 : {
479 83 : Reference< drawing::XShape > xShape;
480 83 : xMasterSlide->getByIndex(xMasterSlide->getCount()-1) >>= xShape;
481 83 : xMasterSlide->remove(xShape);
482 177 : }
483 : }
484 968 : while( xSlide->getCount() )
485 : {
486 582 : Reference< drawing::XShape > xShape;
487 582 : xSlide->getByIndex(0) >>= xShape;
488 582 : xSlide->remove( xShape );
489 582 : }
490 :
491 386 : Reference< XPropertySet > xPropertySet( xSlide, UNO_QUERY );
492 193 : if ( xPropertySet.is() )
493 : {
494 193 : awt::Size& rPageSize( rSlidePersistPtr->isNotesPage() ? maNotesSize : maSlideSize );
495 193 : xPropertySet->setPropertyValue( "Width", Any( rPageSize.Width ) );
496 193 : xPropertySet->setPropertyValue( "Height", Any( rPageSize.Height ) );
497 :
498 193 : oox::ppt::HeaderFooter aHeaderFooter( rSlidePersistPtr->getHeaderFooter() );
499 193 : if ( !rSlidePersistPtr->isMasterPage() )
500 105 : aHeaderFooter.mbSlideNumber = aHeaderFooter.mbHeader = aHeaderFooter.mbFooter = aHeaderFooter.mbDateTime = false;
501 : try
502 : {
503 193 : if ( rSlidePersistPtr->isNotesPage() )
504 11 : xPropertySet->setPropertyValue( "IsHeaderVisible", Any( aHeaderFooter.mbHeader ) );
505 281 : xPropertySet->setPropertyValue( "IsFooterVisible", Any( aHeaderFooter.mbFooter ) );
506 105 : xPropertySet->setPropertyValue( "IsDateTimeVisible", Any( aHeaderFooter.mbDateTime ) );
507 105 : xPropertySet->setPropertyValue( "IsPageNumberVisible", Any( aHeaderFooter.mbSlideNumber ) );
508 : }
509 88 : catch( uno::Exception& )
510 : {
511 : }
512 : }
513 193 : rSlidePersistPtr->setPath( rxSlideFragmentHandler->getFragmentPath() );
514 386 : return getFilter().importFragment( rxSlideFragmentHandler );
515 : }
516 :
517 246 : } }
518 :
519 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|