LCOV - code coverage report
Current view: top level - libreoffice/slideshow/source/engine/shapes - shapeimporter.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 211 0.0 %
Date: 2012-12-27 Functions: 0 25 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             :  *
       4             :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5             :  *
       6             :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7             :  *
       8             :  * OpenOffice.org - a multi-platform office productivity suite
       9             :  *
      10             :  * This file is part of OpenOffice.org.
      11             :  *
      12             :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13             :  * it under the terms of the GNU Lesser General Public License version 3
      14             :  * only, as published by the Free Software Foundation.
      15             :  *
      16             :  * OpenOffice.org is distributed in the hope that it will be useful,
      17             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19             :  * GNU Lesser General Public License version 3 for more details
      20             :  * (a copy is included in the LICENSE file that accompanied this code).
      21             :  *
      22             :  * You should have received a copy of the GNU Lesser General Public License
      23             :  * version 3 along with OpenOffice.org.  If not, see
      24             :  * <http://www.openoffice.org/license.html>
      25             :  * for a copy of the LGPLv3 License.
      26             :  *
      27             :  ************************************************************************/
      28             : 
      29             : 
      30             : // must be first
      31             : #include <canvas/debug.hxx>
      32             : #include <vcl/cvtgrf.hxx>
      33             : #include <tools/urlobj.hxx>
      34             : #include <tools/stream.hxx>
      35             : #include <svtools/grfmgr.hxx>
      36             : #include <unotools/ucbstreamhelper.hxx>
      37             : #include <unotools/streamwrap.hxx>
      38             : #include <basegfx/point/b2dpoint.hxx>
      39             : #include <basegfx/polygon/b2dpolygon.hxx>
      40             : #include <cppcanvas/basegfxfactory.hxx>
      41             : #include <cppcanvas/polypolygon.hxx>
      42             : #include <com/sun/star/awt/Rectangle.hpp>
      43             : #include <com/sun/star/drawing/ColorMode.hpp>
      44             : #include <com/sun/star/text/GraphicCrop.hpp>
      45             : #include <com/sun/star/container/XNameContainer.hpp>
      46             : #include <com/sun/star/drawing/PointSequenceSequence.hpp>
      47             : #include <com/sun/star/drawing/PointSequence.hpp>
      48             : #include <com/sun/star/lang/XMultiComponentFactory.hpp>
      49             : #include <com/sun/star/drawing/XLayerSupplier.hpp>
      50             : #include <com/sun/star/drawing/XLayerManager.hpp>
      51             : #include <com/sun/star/container/XNameAccess.hpp>
      52             : #include <com/sun/star/lang/XComponent.hpp>
      53             : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
      54             : 
      55             : #include "drawshapesubsetting.hxx"
      56             : #include "drawshape.hxx"
      57             : #include "backgroundshape.hxx"
      58             : #include "mediashape.hxx"
      59             : #include "appletshape.hxx"
      60             : #include "shapeimporter.hxx"
      61             : #include "slideshowexceptions.hxx"
      62             : #include "gdimtftools.hxx"
      63             : #include "tools.hxx"
      64             : #include "slideshowcontext.hxx"
      65             : 
      66             : #include <boost/shared_ptr.hpp>
      67             : #include <boost/scoped_ptr.hpp>
      68             : 
      69             : using namespace com::sun::star;
      70             : 
      71             : namespace slideshow {
      72             : namespace internal {
      73             : 
      74             : namespace {
      75             : 
      76           0 : bool importShapeGraphic(
      77             :     GraphicObject & o_rGraphic,
      78             :     uno::Reference<beans::XPropertySet> const& xPropSet )
      79             : {
      80           0 :     rtl::OUString aURL;
      81           0 :     if( !getPropertyValue( aURL, xPropSet, OUSTR("GraphicURL")) ||
      82           0 :         aURL.isEmpty() )
      83             :     {
      84             :         // no or empty property - cannot import shape graphic
      85           0 :         return false;
      86             :     }
      87             : 
      88             :     rtl::OUString const aVndUrl(
      89           0 :         "vnd.sun.star.GraphicObject:"  );
      90           0 :     sal_Int32 nIndex( aURL.indexOf( aVndUrl ) );
      91             : 
      92           0 :     if(nIndex != -1)
      93             :     {
      94             :         // skip past the end of the "vnd..." prefix
      95           0 :         nIndex += aVndUrl.getLength();
      96             : 
      97           0 :         if(nIndex >= aURL.getLength())
      98             :         {
      99             :             OSL_FAIL( "ShapeImporter::importShape(): "
     100             :                         "embedded graphic has no graphic ID" );
     101           0 :             return false;
     102             :         }
     103             : 
     104             :         // unique ID string found in URL, extract
     105             :         // to separate string
     106             :         rtl::OUString const aUniqueId(
     107           0 :             aURL.copy( nIndex, aURL.getLength() - nIndex ) );
     108             : 
     109             :         // TODO(T2): Creating a GraphicObject is not
     110             :         // thread safe (internally calls VCL, and has
     111             :         // unguarded internal singleton mpGlobalMgr)
     112             : 
     113             :         // fetch already loaded graphic from graphic manager.
     114             :         rtl::OString const aOldString(rtl::OUStringToOString(aUniqueId,
     115           0 :             RTL_TEXTENCODING_UTF8));
     116           0 :         o_rGraphic = GraphicObject( aOldString );
     117             : 
     118             : 
     119           0 :         if( GRAPHIC_DEFAULT == o_rGraphic.GetType()
     120           0 :             || GRAPHIC_NONE == o_rGraphic.GetType() )
     121             :         {
     122             :             // even the GrfMgr does not seem to know this graphic
     123           0 :             return false;
     124           0 :         }
     125             :     }
     126             :     else
     127             :     {
     128             :         // no special string found, graphic must be
     129             :         // external. Load via GraphicIm porter
     130           0 :         INetURLObject aTmp( aURL );
     131             :         boost::scoped_ptr<SvStream> pGraphicStream(
     132             :             utl::UcbStreamHelper::CreateStream(
     133             :                 aTmp.GetMainURL( INetURLObject::NO_DECODE ),
     134           0 :                 STREAM_READ ) );
     135           0 :         if( !pGraphicStream )
     136             :         {
     137             :             OSL_FAIL( "ShapeImporter::importShape(): "
     138             :                         "cannot create input stream for graphic" );
     139           0 :             return false;
     140             :         }
     141             : 
     142           0 :         Graphic aTmpGraphic;
     143           0 :         if( GraphicConverter::Import(
     144           0 :                 *pGraphicStream, aTmpGraphic ) != ERRCODE_NONE )
     145             :         {
     146             :             OSL_FAIL( "ShapeImporter::importShape(): "
     147             :                         "Failed to import shape graphic from given URL" );
     148           0 :             return false;
     149             :         }
     150             : 
     151           0 :         o_rGraphic = GraphicObject( aTmpGraphic );
     152             :     }
     153           0 :     return true;
     154             : }
     155             : 
     156             : /** This shape implementation just acts as a dummy for the layermanager.
     157             :     Its sole role is for hit test detection of group shapes.
     158             : */
     159           0 : class ShapeOfGroup : public Shape
     160             : {
     161             : public:
     162             :     ShapeOfGroup( ShapeSharedPtr const&                      pGroupShape,
     163             :                   uno::Reference<drawing::XShape> const&     xShape,
     164             :                   uno::Reference<beans::XPropertySet> const& xPropSet,
     165             :                   double                                     nPrio );
     166             : 
     167             :     // Shape:
     168             :     virtual uno::Reference<drawing::XShape> getXShape() const;
     169             :     virtual void addViewLayer( ViewLayerSharedPtr const& pNewLayer,
     170             :                                bool                      bRedrawLayer );
     171             :     virtual bool removeViewLayer( ViewLayerSharedPtr const& pNewLayer );
     172             :     virtual bool clearAllViewLayers();
     173             :     virtual bool update() const;
     174             :     virtual bool render() const;
     175             :     virtual bool isContentChanged() const;
     176             :     virtual basegfx::B2DRectangle getBounds() const;
     177             :     virtual basegfx::B2DRectangle getDomBounds() const;
     178             :     virtual basegfx::B2DRectangle getUpdateArea() const;
     179             :     virtual bool isVisible() const;
     180             :     virtual double getPriority() const;
     181             :     virtual bool isBackgroundDetached() const;
     182             : 
     183             : private:
     184             :     ShapeSharedPtr const                  mpGroupShape;
     185             :     uno::Reference<drawing::XShape> const mxShape;
     186             :     double const                          mnPrio;
     187             :     basegfx::B2DPoint                     maPosOffset;
     188             :     double                                mnWidth;
     189             :     double                                mnHeight;
     190             : };
     191             : 
     192           0 : ShapeOfGroup::ShapeOfGroup( ShapeSharedPtr const&                      pGroupShape,
     193             :                             uno::Reference<drawing::XShape> const&     xShape,
     194             :                             uno::Reference<beans::XPropertySet> const& xPropSet,
     195             :                             double                                     nPrio ) :
     196             :     mpGroupShape(pGroupShape),
     197             :     mxShape(xShape),
     198           0 :     mnPrio(nPrio)
     199             : {
     200             :     // read bound rect
     201           0 :     uno::Any const aTmpRect_( xPropSet->getPropertyValue( OUSTR("BoundRect") ));
     202           0 :     awt::Rectangle const aTmpRect( aTmpRect_.get<awt::Rectangle>() );
     203           0 :     basegfx::B2DRectangle const groupPosSize( pGroupShape->getBounds() );
     204           0 :     maPosOffset = basegfx::B2DPoint( aTmpRect.X - groupPosSize.getMinX(),
     205           0 :                                      aTmpRect.Y - groupPosSize.getMinY() );
     206           0 :     mnWidth = aTmpRect.Width;
     207           0 :     mnHeight = aTmpRect.Height;
     208           0 : }
     209             : 
     210           0 : uno::Reference<drawing::XShape> ShapeOfGroup::getXShape() const
     211             : {
     212           0 :     return mxShape;
     213             : }
     214             : 
     215           0 : void ShapeOfGroup::addViewLayer( ViewLayerSharedPtr const& /*pNewLayer*/,
     216             :                                  bool                      /*bRedrawLayer*/ )
     217             : {
     218           0 : }
     219             : 
     220           0 : bool ShapeOfGroup::removeViewLayer( ViewLayerSharedPtr const& /*pNewLayer*/ )
     221             : {
     222           0 :     return true;
     223             : }
     224             : 
     225           0 : bool ShapeOfGroup::clearAllViewLayers()
     226             : {
     227           0 :     return true;
     228             : }
     229             : 
     230           0 : bool ShapeOfGroup::update() const
     231             : {
     232           0 :     return true;
     233             : }
     234             : 
     235           0 : bool ShapeOfGroup::render() const
     236             : {
     237           0 :     return true;
     238             : }
     239             : 
     240           0 : bool ShapeOfGroup::isContentChanged() const
     241             : {
     242           0 :     return false;
     243             : }
     244             : 
     245           0 : basegfx::B2DRectangle ShapeOfGroup::getBounds() const
     246             : {
     247           0 :     basegfx::B2DRectangle const groupPosSize( mpGroupShape->getBounds() );
     248           0 :     double const posX = (groupPosSize.getMinX() + maPosOffset.getX());
     249           0 :     double const posY = (groupPosSize.getMinY() + maPosOffset.getY());
     250           0 :     return basegfx::B2DRectangle( posX, posY, posX + mnWidth, posY + mnHeight );
     251             : }
     252             : 
     253           0 : basegfx::B2DRectangle ShapeOfGroup::getDomBounds() const
     254             : {
     255           0 :     return getBounds();
     256             : }
     257             : 
     258           0 : basegfx::B2DRectangle ShapeOfGroup::getUpdateArea() const
     259             : {
     260           0 :     return getBounds();
     261             : }
     262             : 
     263           0 : bool ShapeOfGroup::isVisible() const
     264             : {
     265           0 :     return mpGroupShape->isVisible();
     266             : }
     267             : 
     268           0 : double ShapeOfGroup::getPriority() const
     269             : {
     270           0 :     return mnPrio;
     271             : }
     272             : 
     273           0 : bool ShapeOfGroup::isBackgroundDetached() const
     274             : {
     275           0 :     return false;
     276             : }
     277             : 
     278             : } // anon namespace
     279             : 
     280           0 : ShapeSharedPtr ShapeImporter::createShape(
     281             :     uno::Reference<drawing::XShape> const& xCurrShape,
     282             :     uno::Reference<beans::XPropertySet> const& xPropSet,
     283             :     rtl::OUString const& shapeType ) const
     284             : {
     285           0 :     if( shapeType == "com.sun.star.drawing.MediaShape" || shapeType == "com.sun.star.presentation.MediaShape" )
     286             :     {
     287             :         // Media shape (video etc.). This is a special object
     288             :         return createMediaShape(xCurrShape,
     289             :                                 mnAscendingPrio,
     290           0 :                                 mrContext);
     291             :     }
     292           0 :     else if( shapeType == "com.sun.star.drawing.PluginShape" )
     293             :     {
     294             :         // PropertyValues to copy from XShape to plugin
     295             :         static const char* aPropertyValues[] =
     296             :             {
     297             :                 "PluginURL",
     298             :                 "PluginMimeType",
     299             :                 "PluginCommands"
     300             :             };
     301             : 
     302             :         // (Netscape)Plugin shape. This is a special object
     303             :         return createAppletShape( xCurrShape,
     304             :                                   mnAscendingPrio,
     305             :                                   ::rtl::OUString( "com.sun.star.comp.sfx2.PluginObject" ),
     306             :                                   aPropertyValues,
     307             :                                   SAL_N_ELEMENTS(aPropertyValues),
     308           0 :                                   mrContext );
     309             :     }
     310           0 :     else if( shapeType == "com.sun.star.drawing.AppletShape" )
     311             :     {
     312             :         // PropertyValues to copy from XShape to applet
     313             :         static const char* aPropertyValues[] =
     314             :             {
     315             :                 "AppletCodeBase",
     316             :                 "AppletName",
     317             :                 "AppletCode",
     318             :                 "AppletCommands",
     319             :                 "AppletIsScript"
     320             :             };
     321             : 
     322             :         // (Java)Applet shape. This is a special object
     323             :         return createAppletShape( xCurrShape,
     324             :                                   mnAscendingPrio,
     325             :                                   ::rtl::OUString( "com.sun.star.comp.sfx2.AppletObject" ),
     326             :                                   aPropertyValues,
     327             :                                   SAL_N_ELEMENTS(aPropertyValues),
     328           0 :                                   mrContext );
     329             :     }
     330           0 :     else if( shapeType == "com.sun.star.drawing.OLE2Shape" || shapeType == "com.sun.star.presentation.OLE2Shape" )
     331             :     {
     332             :         // #i46224# Mark OLE shapes as foreign content - scan them for
     333             :         // unsupported actions, and fallback to bitmap, if necessary
     334             :         return DrawShape::create( xCurrShape,
     335             :                                   mxPage,
     336             :                                   mnAscendingPrio,
     337             :                                   true,
     338           0 :                                   mrContext );
     339             :     }
     340           0 :     else if( shapeType == "com.sun.star.drawing.GraphicObjectShape" || shapeType == "com.sun.star.presentation.GraphicObjectShape" )
     341             :     {
     342           0 :         GraphicObject aGraphicObject;
     343             : 
     344             :         // to get hold of GIF animations, inspect Graphic
     345             :         // objects more thoroughly (the plain-jane shape
     346             :         // metafile of course would only contain the first
     347             :         // animation frame)
     348           0 :         if( !importShapeGraphic( aGraphicObject, xPropSet ) )
     349           0 :             return ShapeSharedPtr(); // error loading graphic -
     350             :                                      // no placeholders in
     351             :                                      // slideshow
     352             : 
     353           0 :         if( !aGraphicObject.IsAnimated() )
     354             :         {
     355             :             // no animation - simply utilize plain draw shape import
     356             : 
     357             :             // import shape as bitmap - either its a bitmap
     358             :             // anyway, or its a metafile, which currently the
     359             :             // metafile renderer might not display correctly.
     360             :             return DrawShape::create( xCurrShape,
     361             :                                       mxPage,
     362             :                                       mnAscendingPrio,
     363             :                                       true,
     364           0 :                                       mrContext );
     365             :         }
     366             : 
     367             : 
     368             :         // now extract relevant shape attributes via API
     369             :         // ---------------------------------------------
     370             : 
     371           0 :         drawing::ColorMode eColorMode( drawing::ColorMode_STANDARD );
     372           0 :         sal_Int16 nLuminance(0);
     373           0 :         sal_Int16 nContrast(0);
     374           0 :         sal_Int16 nRed(0);
     375           0 :         sal_Int16 nGreen(0);
     376           0 :         sal_Int16 nBlue(0);
     377           0 :         double    nGamma(1.0);
     378           0 :         sal_Int16 nTransparency(0);
     379           0 :         sal_Int32 nRotation(0);
     380             : 
     381           0 :         getPropertyValue( eColorMode, xPropSet, OUSTR("GraphicColorMode") );
     382           0 :         getPropertyValue( nLuminance, xPropSet, OUSTR("AdjustLuminance") );
     383           0 :         getPropertyValue( nContrast, xPropSet, OUSTR("AdjustContrast") );
     384           0 :         getPropertyValue( nRed, xPropSet, OUSTR("AdjustRed") );
     385           0 :         getPropertyValue( nGreen, xPropSet, OUSTR("AdjustGreen") );
     386           0 :         getPropertyValue( nBlue, xPropSet, OUSTR("AdjustBlue") );
     387           0 :         getPropertyValue( nGamma, xPropSet, OUSTR("Gamma") );
     388           0 :         getPropertyValue( nTransparency, xPropSet, OUSTR("Transparency") );
     389           0 :         getPropertyValue( nRotation, xPropSet, OUSTR("RotateAngle") );
     390             : 
     391           0 :         GraphicAttr aGraphAttrs;
     392           0 :         aGraphAttrs.SetDrawMode( (GraphicDrawMode)eColorMode );
     393           0 :         aGraphAttrs.SetLuminance( nLuminance );
     394           0 :         aGraphAttrs.SetContrast( nContrast );
     395           0 :         aGraphAttrs.SetChannelR( nRed );
     396           0 :         aGraphAttrs.SetChannelG( nGreen );
     397           0 :         aGraphAttrs.SetChannelB( nBlue );
     398           0 :         aGraphAttrs.SetGamma( nGamma );
     399           0 :         aGraphAttrs.SetTransparency( static_cast<sal_uInt8>(nTransparency) );
     400           0 :         aGraphAttrs.SetRotation( static_cast<sal_uInt16>(nRotation*10) );
     401             : 
     402           0 :         text::GraphicCrop aGraphCrop;
     403           0 :         if( getPropertyValue( aGraphCrop, xPropSet, OUSTR("GraphicCrop") ))
     404             :         {
     405             :             aGraphAttrs.SetCrop( aGraphCrop.Left,
     406             :                                  aGraphCrop.Top,
     407             :                                  aGraphCrop.Right,
     408           0 :                                  aGraphCrop.Bottom );
     409             :         }
     410             : 
     411             :         // fetch readily transformed and color-modified
     412             :         // graphic
     413             :         // ---------------------------------------------
     414             : 
     415             :         Graphic aGraphic(
     416             :             aGraphicObject.GetTransformedGraphic(
     417           0 :                 aGraphicObject.GetPrefSize(),
     418           0 :                 aGraphicObject.GetPrefMapMode(),
     419           0 :                 aGraphAttrs ) );
     420             : 
     421             :         return DrawShape::create( xCurrShape,
     422             :                                   mxPage,
     423             :                                   mnAscendingPrio,
     424             :                                   aGraphic,
     425           0 :                                   mrContext );
     426             :     }
     427             :     else
     428             :     {
     429             :         return DrawShape::create( xCurrShape,
     430             :                                   mxPage,
     431             :                                   mnAscendingPrio,
     432             :                                   false,
     433           0 :                                   mrContext );
     434             :     }
     435             : }
     436             : 
     437           0 : bool ShapeImporter::isSkip(
     438             :     uno::Reference<beans::XPropertySet> const& xPropSet,
     439             :     rtl::OUString const& shapeType,
     440             :     uno::Reference< drawing::XLayer> const& xLayer )
     441             : {
     442             :     // skip empty presentation objects:
     443           0 :     bool bEmpty = false;
     444           0 :     if( getPropertyValue( bEmpty,
     445             :                           xPropSet,
     446           0 :                           OUSTR("IsEmptyPresentationObject")) &&
     447             :         bEmpty )
     448             :     {
     449           0 :         return true;
     450             :     }
     451             : 
     452             :     //skip shapes which corresponds to annotations
     453           0 :     if(xLayer.is())
     454             :     {
     455           0 :         rtl::OUString layerName;
     456             :         uno::Reference<beans::XPropertySet> xPropLayerSet(
     457           0 :                                                           xLayer, uno::UNO_QUERY );
     458           0 :         const uno::Any& a(xPropLayerSet->getPropertyValue(rtl::OUString("Name")) );
     459           0 :         bool const bRet = (a >>= layerName);
     460           0 :         if(bRet)
     461             :         {
     462           0 :             if( layerName == "DrawnInSlideshow" )
     463             :             {
     464             :                 //Transform shapes into PolyPolygons
     465           0 :                 importPolygons(xPropSet);
     466             : 
     467           0 :                 return true;
     468             :             }
     469           0 :         }
     470             :     }
     471             : 
     472             :     // don't export presentation placeholders on masterpage
     473             :     // they can be non empty when user edits the default texts
     474           0 :     if(mbConvertingMasterPage)
     475             :     {
     476           0 :         if( shapeType == "com.sun.star.presentation.TitleTextShape" || shapeType == "com.sun.star.presentation.OutlinerShape" )
     477             :         {
     478           0 :             return true;
     479             :         }
     480             :     }
     481           0 :     return false;
     482             : }
     483             : 
     484             : 
     485           0 : void ShapeImporter::importPolygons(uno::Reference<beans::XPropertySet> const& xPropSet) {
     486             : 
     487           0 :     drawing::PointSequenceSequence aRetval;
     488           0 :     sal_Int32           nLineColor=0;
     489             :     double              fLineWidth;
     490           0 :     getPropertyValue( aRetval, xPropSet, OUSTR("PolyPolygon") );
     491           0 :     getPropertyValue( nLineColor, xPropSet, OUSTR("LineColor") );
     492           0 :     getPropertyValue( fLineWidth, xPropSet, OUSTR("LineWidth") );
     493             : 
     494           0 :     drawing::PointSequence* pOuterSequence = aRetval.getArray();
     495           0 :     awt::Point* pInnerSequence = pOuterSequence->getArray();
     496             : 
     497           0 :     ::basegfx::B2DPolygon aPoly;
     498           0 :     basegfx::B2DPoint aPoint;
     499           0 :     for( sal_Int32 nCurrPoly=0; nCurrPoly<pOuterSequence->getLength(); ++nCurrPoly, ++pInnerSequence )
     500             :     {
     501           0 :         aPoint.setX((*pInnerSequence).X);
     502           0 :         aPoint.setY((*pInnerSequence).Y);
     503           0 :         aPoly.append( aPoint );
     504             :     }
     505           0 :     UnoViewVector::const_iterator aIter=(mrContext.mrViewContainer).begin();
     506           0 :     UnoViewVector::const_iterator aEnd=(mrContext.mrViewContainer).end();
     507           0 :     while(aIter != aEnd)
     508             :     {
     509             :         ::cppcanvas::PolyPolygonSharedPtr pPolyPoly(
     510           0 :             ::cppcanvas::BaseGfxFactory::getInstance().createPolyPolygon( (*aIter)->getCanvas(),
     511           0 :                                                                           aPoly ) );
     512           0 :         if( pPolyPoly )
     513             :         {
     514           0 :                 pPolyPoly->setRGBALineColor( unoColor2RGBColor( nLineColor ).getIntegerColor() );
     515           0 :                 pPolyPoly->setStrokeWidth(fLineWidth);
     516           0 :                 pPolyPoly->draw();
     517           0 :                 maPolygons.push_back(pPolyPoly);
     518             :         }
     519           0 :         ++aIter;
     520           0 :     }
     521           0 : }
     522             : 
     523           0 : ShapeSharedPtr ShapeImporter::importBackgroundShape() // throw (ShapeLoadFailedException)
     524             : {
     525           0 :     if( maShapesStack.empty() )
     526           0 :         throw ShapeLoadFailedException();
     527             : 
     528           0 :     XShapesEntry& rTop = maShapesStack.top();
     529             :     ShapeSharedPtr pBgShape(
     530             :         createBackgroundShape(mxPage,
     531             :                               uno::Reference<drawing::XDrawPage>(
     532             :                                   rTop.mxShapes,
     533             :                                   uno::UNO_QUERY_THROW),
     534           0 :                               mrContext) );
     535           0 :     mnAscendingPrio += 1.0;
     536             : 
     537           0 :     return pBgShape;
     538             : }
     539             : 
     540           0 : ShapeSharedPtr ShapeImporter::importShape() // throw (ShapeLoadFailedException)
     541             : {
     542           0 :     ShapeSharedPtr pRet;
     543           0 :     bool bIsGroupShape = false;
     544             : 
     545           0 :     while( !maShapesStack.empty() && !pRet )
     546             :     {
     547           0 :         XShapesEntry& rTop = maShapesStack.top();
     548           0 :         if( rTop.mnPos < rTop.mnCount )
     549             :         {
     550             :             uno::Reference<drawing::XShape> const xCurrShape(
     551           0 :                 rTop.mxShapes->getByIndex( rTop.mnPos ), uno::UNO_QUERY );
     552           0 :             ++rTop.mnPos;
     553             :             uno::Reference<beans::XPropertySet> xPropSet(
     554           0 :                 xCurrShape, uno::UNO_QUERY );
     555           0 :             if( !xPropSet.is() )
     556             :             {
     557             :                 // we definitely need the properties of
     558             :                 // the shape here. This will also fail,
     559             :                 // if getByIndex did not return a valid
     560             :                 // shape
     561           0 :                 throw ShapeLoadFailedException();
     562             :             }
     563             : 
     564             :             //Retrieve the layer for the current shape
     565           0 :             uno::Reference< drawing::XLayer > xDrawnInSlideshow;
     566             : 
     567           0 :             uno::Reference< drawing::XLayerSupplier > xLayerSupplier(mxPagesSupplier, uno::UNO_QUERY);
     568           0 :             if(xLayerSupplier.is())
     569             :             {
     570           0 :                 uno::Reference< container::XNameAccess > xNameAccess = xLayerSupplier->getLayerManager();
     571             : 
     572           0 :                 uno::Reference< drawing::XLayerManager > xLayerManager(xNameAccess, uno::UNO_QUERY);
     573             : 
     574           0 :                    xDrawnInSlideshow = xLayerManager->getLayerForShape(xCurrShape);
     575             :             }
     576             : 
     577           0 :             rtl::OUString const shapeType( xCurrShape->getShapeType());
     578             : 
     579             :             // is this shape presentation-invisible?
     580           0 :             if( !isSkip(xPropSet, shapeType, xDrawnInSlideshow) )
     581             :             {
     582           0 :                 bIsGroupShape = shapeType == "com.sun.star.drawing.GroupShape";
     583             : 
     584           0 :                 if( rTop.mpGroupShape ) // in group particle mode?
     585             :                 {
     586             :                     pRet.reset( new ShapeOfGroup(
     587             :                                     rTop.mpGroupShape /* container shape */,
     588             :                                     xCurrShape, xPropSet,
     589           0 :                                     mnAscendingPrio ) );
     590             :                 }
     591             :                 else
     592             :                 {
     593           0 :                     pRet = createShape( xCurrShape, xPropSet, shapeType );
     594             :                 }
     595           0 :                 mnAscendingPrio += 1.0;
     596           0 :             }
     597             :         }
     598           0 :         if( rTop.mnPos >= rTop.mnCount )
     599             :         {
     600             :             // group or top-level shapes finished:
     601           0 :             maShapesStack.pop();
     602             :         }
     603           0 :         if( bIsGroupShape && pRet )
     604             :         {
     605             :             // push new group on the stack: group traversal
     606           0 :             maShapesStack.push( XShapesEntry( pRet ) );
     607             :         }
     608             :     }
     609             : 
     610           0 :     return pRet;
     611             : }
     612             : 
     613           0 : bool ShapeImporter::isImportDone() const
     614             : {
     615           0 :     return maShapesStack.empty();
     616             : }
     617             : 
     618           0 : PolyPolygonVector ShapeImporter::getPolygons()
     619             : {
     620           0 :     return maPolygons;
     621             : }
     622             : 
     623           0 : ShapeImporter::ShapeImporter( uno::Reference<drawing::XDrawPage> const&          xPage,
     624             :                               uno::Reference<drawing::XDrawPage> const&          xActualPage,
     625             :                               uno::Reference<drawing::XDrawPagesSupplier> const& xPagesSupplier,
     626             :                               const SlideShowContext&                            rContext,
     627             :                               sal_Int32                                          nOrdNumStart,
     628             :                               bool                                               bConvertingMasterPage ) :
     629             :     mxPage( xActualPage ),
     630             :     mxPagesSupplier( xPagesSupplier ),
     631             :     mrContext( rContext ),
     632             :     maPolygons(),
     633             :     maShapesStack(),
     634             :     mnAscendingPrio( nOrdNumStart ),
     635           0 :     mbConvertingMasterPage( bConvertingMasterPage )
     636             : {
     637             :     uno::Reference<drawing::XShapes> const xShapes(
     638           0 :         xPage, uno::UNO_QUERY_THROW );
     639           0 :     maShapesStack.push( XShapesEntry(xShapes) );
     640           0 : }
     641             : 
     642             : } // namespace internal
     643             : } // namespace presentation
     644             : 
     645             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10