1*aaef562fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*aaef562fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*aaef562fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*aaef562fSAndrew Rist * distributed with this work for additional information 6*aaef562fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*aaef562fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*aaef562fSAndrew Rist * "License"); you may not use this file except in compliance 9*aaef562fSAndrew Rist * with the License. You may obtain a copy of the License at 10*aaef562fSAndrew Rist * 11*aaef562fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*aaef562fSAndrew Rist * 13*aaef562fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*aaef562fSAndrew Rist * software distributed under the License is distributed on an 15*aaef562fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*aaef562fSAndrew Rist * KIND, either express or implied. See the License for the 17*aaef562fSAndrew Rist * specific language governing permissions and limitations 18*aaef562fSAndrew Rist * under the License. 19*aaef562fSAndrew Rist * 20*aaef562fSAndrew Rist *************************************************************/ 21*aaef562fSAndrew Rist 22*aaef562fSAndrew Rist 23cdf0e10cSrcweir #ifndef INCLUDED_SLIDESHOW_SHAPEIMPORTER_HXX 24cdf0e10cSrcweir #define INCLUDED_SLIDESHOW_SHAPEIMPORTER_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPage.hpp> 27cdf0e10cSrcweir #include <com/sun/star/drawing/XShapes.hpp> 28cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 29cdf0e10cSrcweir #include <com/sun/star/drawing/XLayer.hpp> 30cdf0e10cSrcweir #include "unoviewcontainer.hxx" 31cdf0e10cSrcweir #include "unoview.hxx" 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include "shape.hxx" 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include <stack> 36cdf0e10cSrcweir 37cdf0e10cSrcweir namespace slideshow { 38cdf0e10cSrcweir namespace internal { 39cdf0e10cSrcweir 40cdf0e10cSrcweir struct SlideShowContext; 41cdf0e10cSrcweir 42cdf0e10cSrcweir typedef ::std::vector< ::cppcanvas::PolyPolygonSharedPtr> PolyPolygonVector; 43cdf0e10cSrcweir typedef ::boost::shared_ptr< UnoView > UnoViewSharedPtr; 44cdf0e10cSrcweir typedef ::std::vector< UnoViewSharedPtr > UnoViewVector; 45cdf0e10cSrcweir 46cdf0e10cSrcweir /** This class imports all shapes from a given XShapes object 47cdf0e10cSrcweir */ 48cdf0e10cSrcweir class ShapeImporter 49cdf0e10cSrcweir { 50cdf0e10cSrcweir public: 51cdf0e10cSrcweir /** Create shape importer. 52cdf0e10cSrcweir 53cdf0e10cSrcweir @param xPage 54cdf0e10cSrcweir Page containing the shapes 55cdf0e10cSrcweir 56cdf0e10cSrcweir @param xActualPage 57cdf0e10cSrcweir Actual page that's imported - if xPage is a master 58cdf0e10cSrcweir page, this argument must refer to the using, i.e the 59cdf0e10cSrcweir page that embeds this specific masterpage. Otherwise, 60cdf0e10cSrcweir this argument is probably equal to xPage. 61cdf0e10cSrcweir 62cdf0e10cSrcweir @param nOrdNumStart 63cdf0e10cSrcweir Each shape receives a z order number, in order of 64cdf0e10cSrcweir import (which relies on the fact that the API returns 65cdf0e10cSrcweir the shapes in draw order - which it does, 66cdf0e10cSrcweir currently). Since we might mix several pages on screen 67cdf0e10cSrcweir (e.g. master page and foreground page), this value can 68cdf0e10cSrcweir be used as an offset to distinguish those pages. 69cdf0e10cSrcweir 70cdf0e10cSrcweir @param bConvertingMasterPage 71cdf0e10cSrcweir When true, then the master page is imported. Otherwise, this 72cdf0e10cSrcweir object imports the draw page. 73cdf0e10cSrcweir */ 74cdf0e10cSrcweir ShapeImporter( const ::com::sun::star::uno::Reference< 75cdf0e10cSrcweir ::com::sun::star::drawing::XDrawPage >& xPage, 76cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 77cdf0e10cSrcweir ::com::sun::star::drawing::XDrawPage >& xActualPage, 78cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 79cdf0e10cSrcweir ::com::sun::star::drawing::XDrawPagesSupplier>& xPagesSupplier, 80cdf0e10cSrcweir const SlideShowContext& rContext, 81cdf0e10cSrcweir sal_Int32 nOrdNumStart, 82cdf0e10cSrcweir bool bConvertingMasterPage ); 83cdf0e10cSrcweir 84cdf0e10cSrcweir /** This method imports the presentation background shape 85cdf0e10cSrcweir */ 86cdf0e10cSrcweir ShapeSharedPtr importBackgroundShape(); // throw (ShapeLoadFailedException) 87cdf0e10cSrcweir 88cdf0e10cSrcweir /** This method imports presentation-visible shapes (and skips all others). 89cdf0e10cSrcweir 90cdf0e10cSrcweir @return the generated Shape, or NULL for no more shapes. 91cdf0e10cSrcweir */ 92cdf0e10cSrcweir ShapeSharedPtr importShape(); // throw (ConversionFailedException) 93cdf0e10cSrcweir 94cdf0e10cSrcweir /** Test whether import is done. 95cdf0e10cSrcweir 96cdf0e10cSrcweir @return true, if all shapes are imported via the 97cdf0e10cSrcweir importShape() call. 98cdf0e10cSrcweir */ 99cdf0e10cSrcweir bool isImportDone() const; 100cdf0e10cSrcweir PolyPolygonVector getPolygons(); 101cdf0e10cSrcweir private: 102cdf0e10cSrcweir bool isSkip( ::com::sun::star::uno::Reference< 103cdf0e10cSrcweir ::com::sun::star::beans::XPropertySet> const& xPropSet, 104cdf0e10cSrcweir ::rtl::OUString const& shapeType, 105cdf0e10cSrcweir ::com::sun::star::uno::Reference< 106cdf0e10cSrcweir ::com::sun::star::drawing::XLayer> const& xLayer); 107cdf0e10cSrcweir 108cdf0e10cSrcweir ShapeSharedPtr createShape( 109cdf0e10cSrcweir ::com::sun::star::uno::Reference< 110cdf0e10cSrcweir ::com::sun::star::drawing::XShape> const& xCurrShape, 111cdf0e10cSrcweir ::com::sun::star::uno::Reference< 112cdf0e10cSrcweir ::com::sun::star::beans::XPropertySet> const& xPropSet, 113cdf0e10cSrcweir ::rtl::OUString const& shapeType ) const; 114cdf0e10cSrcweir 115cdf0e10cSrcweir void importPolygons(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > const& xPropSet) ; 116cdf0e10cSrcweir 117cdf0e10cSrcweir struct XShapesEntry 118cdf0e10cSrcweir { 119cdf0e10cSrcweir ShapeSharedPtr const mpGroupShape; 120cdf0e10cSrcweir ::com::sun::star::uno::Reference< 121cdf0e10cSrcweir ::com::sun::star::drawing::XShapes> const mxShapes; 122cdf0e10cSrcweir sal_Int32 const mnCount; 123cdf0e10cSrcweir sal_Int32 mnPos; 124cdf0e10cSrcweir XShapesEntryslideshow::internal::ShapeImporter::XShapesEntry125cdf0e10cSrcweir explicit XShapesEntry( ShapeSharedPtr const& pGroupShape ) 126cdf0e10cSrcweir : mpGroupShape(pGroupShape), 127cdf0e10cSrcweir mxShapes( pGroupShape->getXShape(), 128cdf0e10cSrcweir ::com::sun::star::uno::UNO_QUERY_THROW ), 129cdf0e10cSrcweir mnCount(mxShapes->getCount()), mnPos(0) {} XShapesEntryslideshow::internal::ShapeImporter::XShapesEntry130cdf0e10cSrcweir explicit XShapesEntry( ::com::sun::star::uno::Reference< 131cdf0e10cSrcweir ::com::sun::star::drawing::XShapes> const& xShapes ) 132cdf0e10cSrcweir : mpGroupShape(), mxShapes(xShapes), 133cdf0e10cSrcweir mnCount(xShapes->getCount()), mnPos(0) {} 134cdf0e10cSrcweir }; 135cdf0e10cSrcweir typedef ::std::stack<XShapesEntry> XShapesStack; 136cdf0e10cSrcweir 137cdf0e10cSrcweir ::com::sun::star::uno::Reference< 138cdf0e10cSrcweir ::com::sun::star::drawing::XDrawPage> mxPage; 139cdf0e10cSrcweir ::com::sun::star::uno::Reference< 140cdf0e10cSrcweir ::com::sun::star::drawing::XDrawPagesSupplier> mxPagesSupplier; 141cdf0e10cSrcweir const SlideShowContext& mrContext; 142cdf0e10cSrcweir PolyPolygonVector maPolygons; 143cdf0e10cSrcweir XShapesStack maShapesStack; 144cdf0e10cSrcweir double mnAscendingPrio; 145cdf0e10cSrcweir bool mbConvertingMasterPage; 146cdf0e10cSrcweir }; 147cdf0e10cSrcweir 148cdf0e10cSrcweir } // namespace internal 149cdf0e10cSrcweir } // namespace presentation 150cdf0e10cSrcweir 151cdf0e10cSrcweir #endif 152