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