LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/oox/source/ppt - presentationfragmenthandler.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 176 258 68.2 %
Date: 2013-07-09 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 "oox/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           7 : PresentationFragmentHandler::PresentationFragmentHandler( XmlFilterBase& rFilter, const OUString& rFragmentPath ) throw()
      60             : : FragmentHandler2( rFilter, rFragmentPath )
      61           7 : , mpTextListStyle( new TextListStyle )
      62          14 : , mbCommentAuthorsRead(false)
      63             : {
      64           7 :     TextParagraphPropertiesVector& rParagraphDefaulsVector( mpTextListStyle->getListStyle() );
      65           7 :     TextParagraphPropertiesVector::iterator aParagraphDefaultIter( rParagraphDefaulsVector.begin() );
      66          77 :     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          63 :         (*aParagraphDefaultIter++)->getParaBottomMargin() = TextSpacing( 0 );
      71             :     }
      72           7 : }
      73             : 
      74          14 : PresentationFragmentHandler::~PresentationFragmentHandler() throw()
      75             : {
      76          14 : }
      77             : 
      78           7 : void ResolveTextFields( XmlFilterBase& rFilter )
      79             : {
      80           7 :     const oox::core::TextFieldStack& rTextFields = rFilter.getTextFieldStack();
      81           7 :     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 :                     sal_Bool bNotes = sal_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 = sal_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           7 : }
     137             : 
     138           8 : void PresentationFragmentHandler::importSlide(sal_uInt32 nSlide, sal_Bool bFirstPage, sal_Bool bImportNotesPage)
     139             : {
     140           8 :     PowerPointImport& rFilter = dynamic_cast< PowerPointImport& >( getFilter() );
     141             : 
     142           8 :     Reference< frame::XModel > xModel( rFilter.getModel() );
     143          16 :     Reference< drawing::XDrawPage > xSlide;
     144             : 
     145             :     // importing slide pages and its corresponding notes page
     146          16 :     Reference< drawing::XDrawPagesSupplier > xDPS( xModel, uno::UNO_QUERY_THROW );
     147          16 :     Reference< drawing::XDrawPages > xDrawPages( xDPS->getDrawPages(), uno::UNO_QUERY_THROW );
     148             : 
     149             :     try {
     150             : 
     151           8 :         if( bFirstPage )
     152           7 :             xDrawPages->getByIndex( 0 ) >>= xSlide;
     153             :         else
     154           1 :             xSlide = xDrawPages->insertNewByIndex( xDrawPages->getCount() );
     155             : 
     156           8 :         OUString aSlideFragmentPath = getFragmentPathFromRelId( maSlidesVector[ nSlide ] );
     157           8 :         if( !aSlideFragmentPath.isEmpty() )
     158             :         {
     159           8 :             SlidePersistPtr pMasterPersistPtr;
     160             :             SlidePersistPtr pSlidePersistPtr( new SlidePersist( rFilter, sal_False, sal_False, xSlide,
     161          16 :                                 ShapePtr( new PPTShape( Slide, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle ) );
     162             : 
     163          16 :             FragmentHandlerRef xSlideFragmentHandler( new SlideFragmentHandler( rFilter, aSlideFragmentPath, pSlidePersistPtr, Slide ) );
     164             : 
     165             :             // importing the corresponding masterpage/layout
     166          16 :             OUString aLayoutFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "slideLayout" ) );
     167          16 :             OUString aCommentFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "comments" ) );
     168           8 :             if ( !aLayoutFragmentPath.isEmpty() )
     169             :             {
     170             :                 // importing layout
     171           8 :                 RelationsRef xLayoutRelations = rFilter.importRelations( aLayoutFragmentPath );
     172          16 :                 OUString aMasterFragmentPath = xLayoutRelations->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "slideMaster" ) );
     173           8 :                 if( !aMasterFragmentPath.isEmpty() )
     174             :                 {
     175             :                     // check if the corresponding masterpage+layout has already been imported
     176           8 :                     std::vector< SlidePersistPtr >& rMasterPages( rFilter.getMasterPages() );
     177           8 :                     std::vector< SlidePersistPtr >::iterator aIter( rMasterPages.begin() );
     178          17 :                     while( aIter != rMasterPages.end() )
     179             :                     {
     180           1 :                         if ( ( (*aIter)->getPath() == aMasterFragmentPath ) && ( (*aIter)->getLayoutPath() == aLayoutFragmentPath ) )
     181             :                         {
     182           0 :                             pMasterPersistPtr = *aIter;
     183           0 :                             break;
     184             :                         }
     185           1 :                         ++aIter;
     186             :                     }
     187             : 
     188           8 :                     if ( !pMasterPersistPtr.get() )
     189             :                     {   // masterpersist not found, we have to load it
     190           8 :                         Reference< drawing::XDrawPage > xMasterPage;
     191          16 :                         Reference< drawing::XMasterPagesSupplier > xMPS( xModel, uno::UNO_QUERY_THROW );
     192          16 :                         Reference< drawing::XDrawPages > xMasterPages( xMPS->getMasterPages(), uno::UNO_QUERY_THROW );
     193             : 
     194           8 :                         if( !(rFilter.getMasterPages().size() ))
     195           7 :                             xMasterPages->getByIndex( 0 ) >>= xMasterPage;
     196             :                         else
     197           1 :                             xMasterPage = xMasterPages->insertNewByIndex( xMasterPages->getCount() );
     198             : 
     199          32 :                         pMasterPersistPtr = SlidePersistPtr( new SlidePersist( rFilter, sal_True, sal_False, xMasterPage,
     200          24 :                             ShapePtr( new PPTShape( Master, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle ) );
     201           8 :                         pMasterPersistPtr->setLayoutPath( aLayoutFragmentPath );
     202           8 :                         rFilter.getMasterPages().push_back( pMasterPersistPtr );
     203           8 :                         rFilter.setActualSlidePersist( pMasterPersistPtr );
     204          16 :                         FragmentHandlerRef xMasterFragmentHandler( new SlideFragmentHandler( rFilter, aMasterFragmentPath, pMasterPersistPtr, Master ) );
     205             : 
     206             :                         // set the correct theme
     207          16 :                         OUString aThemeFragmentPath = xMasterFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "theme" ) );
     208           8 :                         if( !aThemeFragmentPath.isEmpty() )
     209             :                         {
     210           8 :                             std::map< OUString, oox::drawingml::ThemePtr >& rThemes( rFilter.getThemes() );
     211           8 :                             std::map< OUString, oox::drawingml::ThemePtr >::iterator aIter2( rThemes.find( aThemeFragmentPath ) );
     212           8 :                             if( aIter2 == rThemes.end() )
     213             :                             {
     214           7 :                                 oox::drawingml::ThemePtr pThemePtr( new oox::drawingml::Theme() );
     215           7 :                                 pMasterPersistPtr->setTheme( pThemePtr );
     216             :                                 Reference<xml::dom::XDocument> xDoc=
     217          14 :                                     rFilter.importFragment(aThemeFragmentPath);
     218             : 
     219             :                                 rFilter.importFragment(
     220             :                                     new ThemeFragmentHandler(
     221           7 :                                         rFilter, aThemeFragmentPath, *pThemePtr ),
     222             :                                     Reference<xml::sax::XFastSAXSerializable>(
     223             :                                         xDoc,
     224          14 :                                         UNO_QUERY_THROW));
     225           7 :                                 rThemes[ aThemeFragmentPath ] = pThemePtr;
     226          14 :                                 pThemePtr->setFragment(xDoc);
     227             :                             }
     228             :                             else
     229             :                             {
     230           1 :                                 pMasterPersistPtr->setTheme( (*aIter2).second );
     231             :                             }
     232             :                         }
     233           8 :                         importSlide( xMasterFragmentHandler, pMasterPersistPtr );
     234           8 :                         rFilter.importFragment( new LayoutFragmentHandler( rFilter, aLayoutFragmentPath, pMasterPersistPtr ) );
     235           8 :                         pMasterPersistPtr->createBackground( rFilter );
     236          16 :                         pMasterPersistPtr->createXShapes( rFilter );
     237             :                     }
     238           8 :                 }
     239             :             }
     240             : 
     241             :             // importing slide page
     242           8 :             if (pMasterPersistPtr.get()) {
     243           8 :                 pSlidePersistPtr->setMasterPersist( pMasterPersistPtr );
     244           8 :                 pSlidePersistPtr->setTheme( pMasterPersistPtr->getTheme() );
     245           8 :                 Reference< drawing::XMasterPageTarget > xMasterPageTarget( pSlidePersistPtr->getPage(), UNO_QUERY );
     246           8 :                 if( xMasterPageTarget.is() )
     247           8 :                     xMasterPageTarget->setMasterPage( pMasterPersistPtr->getPage() );
     248             :             }
     249           8 :             rFilter.getDrawPages().push_back( pSlidePersistPtr );
     250           8 :             rFilter.setActualSlidePersist( pSlidePersistPtr );
     251           8 :             importSlide( xSlideFragmentHandler, pSlidePersistPtr );
     252           8 :             pSlidePersistPtr->createBackground( rFilter );
     253           8 :             pSlidePersistPtr->createXShapes( rFilter );
     254             : 
     255           8 :             if(bImportNotesPage) {
     256             : 
     257             :                 // now importing the notes page
     258           8 :                 OUString aNotesFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "notesSlide" ) );
     259           8 :                 if( !aNotesFragmentPath.isEmpty() )
     260             :                 {
     261           3 :                     Reference< XPresentationPage > xPresentationPage( xSlide, UNO_QUERY );
     262           3 :                     if ( xPresentationPage.is() )
     263             :                     {
     264           3 :                         Reference< XDrawPage > xNotesPage( xPresentationPage->getNotesPage() );
     265           3 :                         if ( xNotesPage.is() )
     266             :                         {
     267             :                             SlidePersistPtr pNotesPersistPtr( new SlidePersist( rFilter, sal_False, sal_True, xNotesPage,
     268           3 :                                 ShapePtr( new PPTShape( Slide, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle ) );
     269           6 :                             FragmentHandlerRef xNotesFragmentHandler( new SlideFragmentHandler( getFilter(), aNotesFragmentPath, pNotesPersistPtr, Slide ) );
     270           3 :                             rFilter.getNotesPages().push_back( pNotesPersistPtr );
     271           3 :                             rFilter.setActualSlidePersist( pNotesPersistPtr );
     272           3 :                             importSlide( xNotesFragmentHandler, pNotesPersistPtr );
     273           3 :                             pNotesPersistPtr->createBackground( rFilter );
     274           6 :                             pNotesPersistPtr->createXShapes( rFilter );
     275           3 :                         }
     276           3 :                     }
     277           8 :                 }
     278             :             }
     279             : 
     280           8 :             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, sal_False, sal_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           8 :             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, sal_False, sal_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           0 :                 pCommentsPersistPtr->getCommentsList().cmLst.back().setText(
     327           0 :                     comment_handler->getCharVector().back() );
     328           0 :                 pCommentsPersistPtr->getCommentAuthors().setValues(maAuthorList);
     329             : 
     330             :                 //insert all comments from commentsList
     331           0 :                 for(int i=0; i<pCommentsPersistPtr->getCommentsList().getSize(); i++)
     332             :                 {
     333             :                     try {
     334           0 :                         Comment aComment = pCommentsPersistPtr->getCommentsList().getCommentAtIndex(i);
     335           0 :                         uno::Reference< office::XAnnotationAccess > xAnnotationAccess( xSlide, UNO_QUERY_THROW );
     336           0 :                         uno::Reference< office::XAnnotation > xAnnotation( xAnnotationAccess->createAndInsertAnnotation() );
     337           0 :                         int nPosX = aComment.getIntX();
     338           0 :                         int nPosY = aComment.getIntY();
     339           0 :                         xAnnotation->setPosition(
     340             :                             geometry::RealPoint2D(
     341           0 :                                 ::oox::drawingml::convertEmuToHmm( nPosX ) * 15.87,
     342           0 :                                 ::oox::drawingml::convertEmuToHmm( nPosY ) * 15.87 ) );
     343           0 :                         xAnnotation->setAuthor( aComment.getAuthor(maAuthorList) );
     344           0 :                         xAnnotation->setDateTime( aComment.getDateTime() );
     345           0 :                         uno::Reference< text::XText > xText( xAnnotation->getTextRange() );
     346           0 :                         xText->setString( aComment.get_text());
     347           0 :                     } catch( css::lang::IllegalArgumentException& ) {}
     348           0 :                 }
     349           8 :             }
     350           8 :         }
     351             :     }
     352           0 :     catch( uno::Exception& )
     353             :     {
     354             :         OSL_FAIL( OString("oox::ppt::PresentationFragmentHandler::EndDocument(), "
     355             :                     "exception caught: " +
     356             :             OUStringToOString(
     357             :                 comphelper::anyToString( cppu::getCaughtException() ),
     358             :                 RTL_TEXTENCODING_UTF8 )).getStr() );
     359             : 
     360           8 :     }
     361           8 : }
     362             : 
     363           7 : void PresentationFragmentHandler::finalizeImport()
     364             : {
     365           7 :     PowerPointImport& rFilter = dynamic_cast< PowerPointImport& >( getFilter() );
     366             : 
     367           7 :     sal_Int32 nPageCount = maSlidesVector.size();
     368             : 
     369             :     // we will take the FilterData property "PageRange" if available, otherwise full range is used
     370           7 :     comphelper::SequenceAsHashMap& rFilterData = rFilter.getFilterData();
     371             : 
     372             :     // writing back the original PageCount of this document, it can be accessed from the XModel
     373             :     // via getArgs after the import.
     374           7 :     rFilterData["OriginalPageCount"] = makeAny(nPageCount);
     375           7 :     sal_Bool bImportNotesPages = rFilterData.getUnpackedValueOrDefault("ImportNotesPages", sal_True);
     376           7 :     OUString aPageRange = rFilterData.getUnpackedValueOrDefault("PageRange", OUString());
     377             : 
     378           7 :     if( !aPageRange.getLength() )
     379             :     {
     380          21 :         aPageRange = OUStringBuffer()
     381          14 :             .append( static_cast< sal_Int32 >( 1 ) )
     382           7 :             .append( static_cast< sal_Unicode >( '-' ) )
     383          14 :             .append( nPageCount ).makeStringAndClear();
     384             :     }
     385             : 
     386          14 :     StringRangeEnumerator aRangeEnumerator( aPageRange, 0, nPageCount - 1 );
     387           7 :     StringRangeEnumerator::Iterator aIter = aRangeEnumerator.begin();
     388           7 :     StringRangeEnumerator::Iterator aEnd  = aRangeEnumerator.end();
     389           7 :     if(aIter!=aEnd) {
     390             : 
     391             :         // todo: localized progress bar text
     392           7 :         const Reference< task::XStatusIndicator >& rxStatusIndicator( getFilter().getStatusIndicator() );
     393           7 :         if ( rxStatusIndicator.is() )
     394           0 :             rxStatusIndicator->start( OUString(), 10000 );
     395             : 
     396             :         try
     397             :         {
     398           7 :             int nPagesImported = 0;
     399          22 :             while (aIter!=aEnd)
     400             :             {
     401           8 :                 if ( rxStatusIndicator.is() )
     402           0 :                     rxStatusIndicator->setValue((nPagesImported * 10000) / aRangeEnumerator.size());
     403             : 
     404           8 :                 importSlide(*aIter, !nPagesImported, bImportNotesPages);
     405           8 :                 nPagesImported++;
     406           8 :                 ++aIter;
     407             :             }
     408           7 :             ResolveTextFields( rFilter );
     409             :         }
     410           0 :         catch( uno::Exception& )
     411             :         {
     412             :             OSL_FAIL( OString("oox::ppt::PresentationFragmentHandler::finalizeImport(), "
     413             :                         "exception caught: " +
     414             :                 OUStringToOString(
     415             :                     comphelper::anyToString( cppu::getCaughtException() ),
     416             :                     RTL_TEXTENCODING_UTF8 )).getStr() );
     417             :         }
     418             :         // todo error handling;
     419           7 :         if ( rxStatusIndicator.is() )
     420           0 :             rxStatusIndicator->end();
     421           7 :     }
     422           7 : }
     423             : 
     424             : // CT_Presentation
     425          76 : ::oox::core::ContextHandlerRef PresentationFragmentHandler::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
     426             : {
     427          76 :     switch( aElementToken )
     428             :     {
     429             :     case PPT_TOKEN( presentation ):
     430             :     case PPT_TOKEN( sldMasterIdLst ):
     431             :     case PPT_TOKEN( notesMasterIdLst ):
     432             :     case PPT_TOKEN( sldIdLst ):
     433          25 :         return this;
     434             :     case PPT_TOKEN( sldMasterId ):
     435           7 :         maSlideMasterVector.push_back( rAttribs.getString( R_TOKEN( id ), OUString() ) );
     436           7 :         return this;
     437             :     case PPT_TOKEN( sldId ):
     438           8 :         maSlidesVector.push_back( rAttribs.getString( R_TOKEN( id ), OUString() ) );
     439           8 :         return this;
     440             :     case PPT_TOKEN( notesMasterId ):
     441           4 :         maNotesMasterVector.push_back( rAttribs.getString( R_TOKEN( id ), OUString() ) );
     442           4 :         return this;
     443             :     case PPT_TOKEN( sldSz ):
     444           7 :         maSlideSize = GetSize2D( rAttribs.getFastAttributeList() );
     445           7 :         return this;
     446             :     case PPT_TOKEN( notesSz ):
     447           7 :         maNotesSize = GetSize2D( rAttribs.getFastAttributeList() );
     448           7 :         return this;
     449             :     case PPT_TOKEN( custShowLst ):
     450           0 :         return new CustomShowListContext( *this, maCustomShowList );
     451             :     case PPT_TOKEN( defaultTextStyle ):
     452           6 :         return new TextListStyleContext( *this, *mpTextListStyle );
     453             :     }
     454          12 :     return this;
     455             : }
     456             : 
     457          19 : bool PresentationFragmentHandler::importSlide( const FragmentHandlerRef& rxSlideFragmentHandler,
     458             :         const SlidePersistPtr pSlidePersistPtr )
     459             : {
     460          19 :     Reference< drawing::XDrawPage > xSlide( pSlidePersistPtr->getPage() );
     461          38 :     SlidePersistPtr pMasterPersistPtr( pSlidePersistPtr->getMasterPersist() );
     462          19 :     if ( pMasterPersistPtr.get() )
     463             :     {
     464           8 :         const OUString sLayout = "Layout";
     465          16 :         uno::Reference< beans::XPropertySet > xSet( xSlide, uno::UNO_QUERY_THROW );
     466          16 :         xSet->setPropertyValue( sLayout, Any( pMasterPersistPtr->getLayoutFromValueToken() ) );
     467             :     }
     468          88 :     while( xSlide->getCount() )
     469             :     {
     470          50 :         Reference< drawing::XShape > xShape;
     471          50 :         xSlide->getByIndex(0) >>= xShape;
     472          50 :         xSlide->remove( xShape );
     473          50 :     }
     474             : 
     475          38 :     Reference< XPropertySet > xPropertySet( xSlide, UNO_QUERY );
     476          19 :     if ( xPropertySet.is() )
     477             :     {
     478          19 :         awt::Size& rPageSize( pSlidePersistPtr->isNotesPage() ? maNotesSize : maSlideSize );
     479          19 :         xPropertySet->setPropertyValue( "Width", Any( rPageSize.Width ) );
     480          19 :         xPropertySet->setPropertyValue( "Height", Any( rPageSize.Height ) );
     481             : 
     482          19 :         oox::ppt::HeaderFooter aHeaderFooter( pSlidePersistPtr->getHeaderFooter() );
     483          19 :         if ( !pSlidePersistPtr->isMasterPage() )
     484          11 :             aHeaderFooter.mbSlideNumber = aHeaderFooter.mbHeader = aHeaderFooter.mbFooter = aHeaderFooter.mbDateTime = sal_False;
     485             :         try
     486             :         {
     487          19 :             if ( pSlidePersistPtr->isNotesPage() )
     488           3 :                 xPropertySet->setPropertyValue( "IsHeaderVisible", Any( aHeaderFooter.mbHeader ) );
     489          27 :             xPropertySet->setPropertyValue( "IsFooterVisible", Any( aHeaderFooter.mbFooter ) );
     490          11 :             xPropertySet->setPropertyValue( "IsDateTimeVisible", Any( aHeaderFooter.mbDateTime ) );
     491          11 :             xPropertySet->setPropertyValue( "IsPageNumberVisible", Any( aHeaderFooter.mbSlideNumber ) );
     492             :         }
     493           8 :         catch( uno::Exception& )
     494             :         {
     495             :         }
     496             :     }
     497          19 :     pSlidePersistPtr->setPath( rxSlideFragmentHandler->getFragmentPath() );
     498          38 :     return getFilter().importFragment( rxSlideFragmentHandler );
     499             : }
     500             : 
     501         141 : } }
     502             : 
     503             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10