LCOV - code coverage report
Current view: top level - oox/source/ppt - presentationfragmenthandler.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 259 0.0 %
Date: 2014-04-14 Functions: 0 10 0.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           0 : PresentationFragmentHandler::PresentationFragmentHandler( XmlFilterBase& rFilter, const OUString& rFragmentPath ) throw()
      60             : : FragmentHandler2( rFilter, rFragmentPath )
      61           0 : , mpTextListStyle( new TextListStyle )
      62           0 : , mbCommentAuthorsRead(false)
      63             : {
      64           0 :     TextParagraphPropertiesVector& rParagraphDefaulsVector( mpTextListStyle->getListStyle() );
      65           0 :     TextParagraphPropertiesVector::iterator aParagraphDefaultIter( rParagraphDefaulsVector.begin() );
      66           0 :     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           0 :         (*aParagraphDefaultIter++)->getParaBottomMargin() = TextSpacing( 0 );
      71             :     }
      72           0 : }
      73             : 
      74           0 : PresentationFragmentHandler::~PresentationFragmentHandler() throw()
      75             : {
      76           0 : }
      77             : 
      78           0 : void ResolveTextFields( XmlFilterBase& rFilter )
      79             : {
      80           0 :     const oox::core::TextFieldStack& rTextFields = rFilter.getTextFieldStack();
      81           0 :     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           0 : }
     137             : 
     138           0 : void PresentationFragmentHandler::importSlide(sal_uInt32 nSlide, bool bFirstPage, bool bImportNotesPage)
     139             : {
     140           0 :     PowerPointImport& rFilter = dynamic_cast< PowerPointImport& >( getFilter() );
     141             : 
     142           0 :     Reference< frame::XModel > xModel( rFilter.getModel() );
     143           0 :     Reference< drawing::XDrawPage > xSlide;
     144             : 
     145             :     // importing slide pages and its corresponding notes page
     146           0 :     Reference< drawing::XDrawPagesSupplier > xDPS( xModel, uno::UNO_QUERY_THROW );
     147           0 :     Reference< drawing::XDrawPages > xDrawPages( xDPS->getDrawPages(), uno::UNO_QUERY_THROW );
     148             : 
     149             :     try {
     150             : 
     151           0 :         if( bFirstPage )
     152           0 :             xDrawPages->getByIndex( 0 ) >>= xSlide;
     153             :         else
     154           0 :             xSlide = xDrawPages->insertNewByIndex( xDrawPages->getCount() );
     155             : 
     156           0 :         OUString aSlideFragmentPath = getFragmentPathFromRelId( maSlidesVector[ nSlide ] );
     157           0 :         if( !aSlideFragmentPath.isEmpty() )
     158             :         {
     159           0 :             SlidePersistPtr pMasterPersistPtr;
     160             :             SlidePersistPtr pSlidePersistPtr( new SlidePersist( rFilter, false, false, xSlide,
     161           0 :                                 ShapePtr( new PPTShape( Slide, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle ) );
     162             : 
     163           0 :             FragmentHandlerRef xSlideFragmentHandler( new SlideFragmentHandler( rFilter, aSlideFragmentPath, pSlidePersistPtr, Slide ) );
     164             : 
     165             :             // importing the corresponding masterpage/layout
     166           0 :             OUString aLayoutFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( "slideLayout" );
     167           0 :             OUString aCommentFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( "comments" );
     168           0 :             if ( !aLayoutFragmentPath.isEmpty() )
     169             :             {
     170             :                 // importing layout
     171           0 :                 RelationsRef xLayoutRelations = rFilter.importRelations( aLayoutFragmentPath );
     172           0 :                 OUString aMasterFragmentPath = xLayoutRelations->getFragmentPathFromFirstTypeFromOfficeDoc( "slideMaster" );
     173           0 :                 if( !aMasterFragmentPath.isEmpty() )
     174             :                 {
     175             :                     // check if the corresponding masterpage+layout has already been imported
     176           0 :                     std::vector< SlidePersistPtr >& rMasterPages( rFilter.getMasterPages() );
     177           0 :                     std::vector< SlidePersistPtr >::iterator aIter( rMasterPages.begin() );
     178           0 :                     while( aIter != rMasterPages.end() )
     179             :                     {
     180           0 :                         if ( ( (*aIter)->getPath() == aMasterFragmentPath ) && ( (*aIter)->getLayoutPath() == aLayoutFragmentPath ) )
     181             :                         {
     182           0 :                             pMasterPersistPtr = *aIter;
     183           0 :                             break;
     184             :                         }
     185           0 :                         ++aIter;
     186             :                     }
     187             : 
     188           0 :                     if ( !pMasterPersistPtr.get() )
     189             :                     {   // masterpersist not found, we have to load it
     190           0 :                         Reference< drawing::XDrawPage > xMasterPage;
     191           0 :                         Reference< drawing::XMasterPagesSupplier > xMPS( xModel, uno::UNO_QUERY_THROW );
     192           0 :                         Reference< drawing::XDrawPages > xMasterPages( xMPS->getMasterPages(), uno::UNO_QUERY_THROW );
     193             : 
     194           0 :                         if( !(rFilter.getMasterPages().size() ))
     195           0 :                             xMasterPages->getByIndex( 0 ) >>= xMasterPage;
     196             :                         else
     197           0 :                             xMasterPage = xMasterPages->insertNewByIndex( xMasterPages->getCount() );
     198             : 
     199           0 :                         pMasterPersistPtr = SlidePersistPtr( new SlidePersist( rFilter, true, false, xMasterPage,
     200           0 :                             ShapePtr( new PPTShape( Master, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle ) );
     201           0 :                         pMasterPersistPtr->setLayoutPath( aLayoutFragmentPath );
     202           0 :                         rFilter.getMasterPages().push_back( pMasterPersistPtr );
     203           0 :                         rFilter.setActualSlidePersist( pMasterPersistPtr );
     204           0 :                         FragmentHandlerRef xMasterFragmentHandler( new SlideFragmentHandler( rFilter, aMasterFragmentPath, pMasterPersistPtr, Master ) );
     205             : 
     206             :                         // set the correct theme
     207           0 :                         OUString aThemeFragmentPath = xMasterFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( "theme" );
     208           0 :                         if( !aThemeFragmentPath.isEmpty() )
     209             :                         {
     210           0 :                             std::map< OUString, oox::drawingml::ThemePtr >& rThemes( rFilter.getThemes() );
     211           0 :                             std::map< OUString, oox::drawingml::ThemePtr >::iterator aIter2( rThemes.find( aThemeFragmentPath ) );
     212           0 :                             if( aIter2 == rThemes.end() )
     213             :                             {
     214           0 :                                 oox::drawingml::ThemePtr pThemePtr( new oox::drawingml::Theme() );
     215           0 :                                 pMasterPersistPtr->setTheme( pThemePtr );
     216             :                                 Reference<xml::dom::XDocument> xDoc=
     217           0 :                                     rFilter.importFragment(aThemeFragmentPath);
     218             : 
     219             :                                 rFilter.importFragment(
     220             :                                     new ThemeFragmentHandler(
     221           0 :                                         rFilter, aThemeFragmentPath, *pThemePtr ),
     222             :                                     Reference<xml::sax::XFastSAXSerializable>(
     223             :                                         xDoc,
     224           0 :                                         UNO_QUERY_THROW));
     225           0 :                                 rThemes[ aThemeFragmentPath ] = pThemePtr;
     226           0 :                                 pThemePtr->setFragment(xDoc);
     227             :                             }
     228             :                             else
     229             :                             {
     230           0 :                                 pMasterPersistPtr->setTheme( (*aIter2).second );
     231             :                             }
     232             :                         }
     233           0 :                         importSlide( xMasterFragmentHandler, pMasterPersistPtr );
     234           0 :                         rFilter.importFragment( new LayoutFragmentHandler( rFilter, aLayoutFragmentPath, pMasterPersistPtr ) );
     235           0 :                         pMasterPersistPtr->createBackground( rFilter );
     236           0 :                         pMasterPersistPtr->createXShapes( rFilter );
     237             :                     }
     238           0 :                 }
     239             :             }
     240             : 
     241             :             // importing slide page
     242           0 :             if (pMasterPersistPtr.get()) {
     243           0 :                 pSlidePersistPtr->setMasterPersist( pMasterPersistPtr );
     244           0 :                 pSlidePersistPtr->setTheme( pMasterPersistPtr->getTheme() );
     245           0 :                 Reference< drawing::XMasterPageTarget > xMasterPageTarget( pSlidePersistPtr->getPage(), UNO_QUERY );
     246           0 :                 if( xMasterPageTarget.is() )
     247           0 :                     xMasterPageTarget->setMasterPage( pMasterPersistPtr->getPage() );
     248             :             }
     249           0 :             rFilter.getDrawPages().push_back( pSlidePersistPtr );
     250           0 :             rFilter.setActualSlidePersist( pSlidePersistPtr );
     251           0 :             importSlide( xSlideFragmentHandler, pSlidePersistPtr );
     252           0 :             pSlidePersistPtr->createBackground( rFilter );
     253           0 :             pSlidePersistPtr->createXShapes( rFilter );
     254             : 
     255           0 :             if(bImportNotesPage) {
     256             : 
     257             :                 // now importing the notes page
     258           0 :                 OUString aNotesFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( "notesSlide" );
     259           0 :                 if( !aNotesFragmentPath.isEmpty() )
     260             :                 {
     261           0 :                     Reference< XPresentationPage > xPresentationPage( xSlide, UNO_QUERY );
     262           0 :                     if ( xPresentationPage.is() )
     263             :                     {
     264           0 :                         Reference< XDrawPage > xNotesPage( xPresentationPage->getNotesPage() );
     265           0 :                         if ( xNotesPage.is() )
     266             :                         {
     267             :                             SlidePersistPtr pNotesPersistPtr( new SlidePersist( rFilter, false, true, xNotesPage,
     268           0 :                                 ShapePtr( new PPTShape( Slide, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle ) );
     269           0 :                             FragmentHandlerRef xNotesFragmentHandler( new SlideFragmentHandler( getFilter(), aNotesFragmentPath, pNotesPersistPtr, Slide ) );
     270           0 :                             rFilter.getNotesPages().push_back( pNotesPersistPtr );
     271           0 :                             rFilter.setActualSlidePersist( pNotesPersistPtr );
     272           0 :                             importSlide( xNotesFragmentHandler, pNotesPersistPtr );
     273           0 :                             pNotesPersistPtr->createBackground( rFilter );
     274           0 :                             pNotesPersistPtr->createXShapes( rFilter );
     275           0 :                         }
     276           0 :                     }
     277           0 :                 }
     278             :             }
     279             : 
     280           0 :             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           0 :             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           0 :             }
     354           0 :         }
     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           0 :     }
     365           0 : }
     366             : 
     367           0 : void PresentationFragmentHandler::finalizeImport()
     368             : {
     369           0 :     PowerPointImport& rFilter = dynamic_cast< PowerPointImport& >( getFilter() );
     370             : 
     371           0 :     sal_Int32 nPageCount = maSlidesVector.size();
     372             : 
     373             :     // we will take the FilterData property "PageRange" if available, otherwise full range is used
     374           0 :     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           0 :     rFilterData["OriginalPageCount"] = makeAny(nPageCount);
     379           0 :     sal_Bool bImportNotesPages = rFilterData.getUnpackedValueOrDefault("ImportNotesPages", sal_True);
     380           0 :     OUString aPageRange = rFilterData.getUnpackedValueOrDefault("PageRange", OUString());
     381             : 
     382           0 :     if( !aPageRange.getLength() )
     383             :     {
     384           0 :         aPageRange = OUStringBuffer()
     385           0 :             .append( static_cast< sal_Int32 >( 1 ) )
     386           0 :             .append( '-' )
     387           0 :             .append( nPageCount ).makeStringAndClear();
     388             :     }
     389             : 
     390           0 :     StringRangeEnumerator aRangeEnumerator( aPageRange, 0, nPageCount - 1 );
     391           0 :     StringRangeEnumerator::Iterator aIter = aRangeEnumerator.begin();
     392           0 :     StringRangeEnumerator::Iterator aEnd  = aRangeEnumerator.end();
     393           0 :     if(aIter!=aEnd) {
     394             : 
     395             :         // todo: localized progress bar text
     396           0 :         const Reference< task::XStatusIndicator >& rxStatusIndicator( getFilter().getStatusIndicator() );
     397           0 :         if ( rxStatusIndicator.is() )
     398           0 :             rxStatusIndicator->start( OUString(), 10000 );
     399             : 
     400             :         try
     401             :         {
     402           0 :             int nPagesImported = 0;
     403           0 :             while (aIter!=aEnd)
     404             :             {
     405           0 :                 if ( rxStatusIndicator.is() )
     406           0 :                     rxStatusIndicator->setValue((nPagesImported * 10000) / aRangeEnumerator.size());
     407             : 
     408           0 :                 importSlide(*aIter, !nPagesImported, bImportNotesPages);
     409           0 :                 nPagesImported++;
     410           0 :                 ++aIter;
     411             :             }
     412           0 :             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           0 :         if ( rxStatusIndicator.is() )
     424           0 :             rxStatusIndicator->end();
     425           0 :     }
     426           0 : }
     427             : 
     428             : // CT_Presentation
     429           0 : ::oox::core::ContextHandlerRef PresentationFragmentHandler::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
     430             : {
     431           0 :     switch( aElementToken )
     432             :     {
     433             :     case PPT_TOKEN( presentation ):
     434             :     case PPT_TOKEN( sldMasterIdLst ):
     435             :     case PPT_TOKEN( notesMasterIdLst ):
     436             :     case PPT_TOKEN( sldIdLst ):
     437           0 :         return this;
     438             :     case PPT_TOKEN( sldMasterId ):
     439           0 :         maSlideMasterVector.push_back( rAttribs.getString( R_TOKEN( id ), OUString() ) );
     440           0 :         return this;
     441             :     case PPT_TOKEN( sldId ):
     442           0 :         maSlidesVector.push_back( rAttribs.getString( R_TOKEN( id ), OUString() ) );
     443           0 :         return this;
     444             :     case PPT_TOKEN( notesMasterId ):
     445           0 :         maNotesMasterVector.push_back( rAttribs.getString( R_TOKEN( id ), OUString() ) );
     446           0 :         return this;
     447             :     case PPT_TOKEN( sldSz ):
     448           0 :         maSlideSize = GetSize2D( rAttribs.getFastAttributeList() );
     449           0 :         return this;
     450             :     case PPT_TOKEN( notesSz ):
     451           0 :         maNotesSize = GetSize2D( rAttribs.getFastAttributeList() );
     452           0 :         return this;
     453             :     case PPT_TOKEN( custShowLst ):
     454           0 :         return new CustomShowListContext( *this, maCustomShowList );
     455             :     case PPT_TOKEN( defaultTextStyle ):
     456           0 :         return new TextListStyleContext( *this, *mpTextListStyle );
     457             :     }
     458           0 :     return this;
     459             : }
     460             : 
     461           0 : bool PresentationFragmentHandler::importSlide( const FragmentHandlerRef& rxSlideFragmentHandler,
     462             :         const SlidePersistPtr pSlidePersistPtr )
     463             : {
     464           0 :     Reference< drawing::XDrawPage > xSlide( pSlidePersistPtr->getPage() );
     465           0 :     SlidePersistPtr pMasterPersistPtr( pSlidePersistPtr->getMasterPersist() );
     466           0 :     if ( pMasterPersistPtr.get() )
     467             :     {
     468           0 :         const OUString sLayout = "Layout";
     469           0 :         uno::Reference< beans::XPropertySet > xSet( xSlide, uno::UNO_QUERY_THROW );
     470           0 :         xSet->setPropertyValue( sLayout, Any( pMasterPersistPtr->getLayoutFromValueToken() ) );
     471             :     }
     472           0 :     while( xSlide->getCount() )
     473             :     {
     474           0 :         Reference< drawing::XShape > xShape;
     475           0 :         xSlide->getByIndex(0) >>= xShape;
     476           0 :         xSlide->remove( xShape );
     477           0 :     }
     478             : 
     479           0 :     Reference< XPropertySet > xPropertySet( xSlide, UNO_QUERY );
     480           0 :     if ( xPropertySet.is() )
     481             :     {
     482           0 :         awt::Size& rPageSize( pSlidePersistPtr->isNotesPage() ? maNotesSize : maSlideSize );
     483           0 :         xPropertySet->setPropertyValue( "Width", Any( rPageSize.Width ) );
     484           0 :         xPropertySet->setPropertyValue( "Height", Any( rPageSize.Height ) );
     485             : 
     486           0 :         oox::ppt::HeaderFooter aHeaderFooter( pSlidePersistPtr->getHeaderFooter() );
     487           0 :         if ( !pSlidePersistPtr->isMasterPage() )
     488           0 :             aHeaderFooter.mbSlideNumber = aHeaderFooter.mbHeader = aHeaderFooter.mbFooter = aHeaderFooter.mbDateTime = false;
     489             :         try
     490             :         {
     491           0 :             if ( pSlidePersistPtr->isNotesPage() )
     492           0 :                 xPropertySet->setPropertyValue( "IsHeaderVisible", Any( aHeaderFooter.mbHeader ) );
     493           0 :             xPropertySet->setPropertyValue( "IsFooterVisible", Any( aHeaderFooter.mbFooter ) );
     494           0 :             xPropertySet->setPropertyValue( "IsDateTimeVisible", Any( aHeaderFooter.mbDateTime ) );
     495           0 :             xPropertySet->setPropertyValue( "IsPageNumberVisible", Any( aHeaderFooter.mbSlideNumber ) );
     496             :         }
     497           0 :         catch( uno::Exception& )
     498             :         {
     499             :         }
     500             :     }
     501           0 :     pSlidePersistPtr->setPath( rxSlideFragmentHandler->getFragmentPath() );
     502           0 :     return getFilter().importFragment( rxSlideFragmentHandler );
     503             : }
     504             : 
     505           0 : } }
     506             : 
     507             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10