LCOV - code coverage report
Current view: top level - oox/source/ppt - presentationfragmenthandler.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 188 266 70.7 %
Date: 2014-11-03 Functions: 10 10 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10