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 #ifndef INCLUDED_SLIDESHOW_SOURCE_INC_SHAPEIMPORTER_HXX 20 #define INCLUDED_SLIDESHOW_SOURCE_INC_SHAPEIMPORTER_HXX 21 22 #include <com/sun/star/drawing/XDrawPage.hpp> 23 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> 24 #include <com/sun/star/drawing/XShapes.hpp> 25 #include <com/sun/star/beans/XPropertySet.hpp> 26 #include <com/sun/star/drawing/XLayer.hpp> 27 28 #include <cppcanvas/canvasgraphic.hxx> 29 30 #include "unoview.hxx" 31 32 #include "shape.hxx" 33 34 #include <stack> 35 36 namespace slideshow::internal { 37 38 struct SlideShowContext; 39 40 typedef std::vector< ::cppcanvas::PolyPolygonSharedPtr> PolyPolygonVector; 41 typedef std::shared_ptr< UnoView > UnoViewSharedPtr; 42 typedef std::vector< UnoViewSharedPtr > UnoViewVector; 43 44 /** This class imports all shapes from a given XShapes object 45 */ 46 class ShapeImporter 47 { 48 public: 49 /** Create shape importer. 50 51 @param xPage 52 Page containing the shapes 53 54 @param xActualPage 55 Actual page that's imported - if xPage is a master 56 page, this argument must refer to the using, i.e the 57 page that embeds this specific masterpage. Otherwise, 58 this argument is probably equal to xPage. 59 60 @param nOrdNumStart 61 Each shape receives a z order number, in order of 62 import (which relies on the fact that the API returns 63 the shapes in draw order - which it does, 64 currently). Since we might mix several pages on screen 65 (e.g. master page and foreground page), this value can 66 be used as an offset to distinguish those pages. 67 68 @param bConvertingMasterPage 69 When true, then the master page is imported. Otherwise, this 70 object imports the draw page. 71 */ 72 ShapeImporter( const css::uno::Reference< css::drawing::XDrawPage >& xPage, 73 const css::uno::Reference< css::drawing::XDrawPage >& xActualPage, 74 const css::uno::Reference< css::drawing::XDrawPagesSupplier>& xPagesSupplier, 75 const SlideShowContext& rContext, 76 sal_Int32 nOrdNumStart, 77 bool bConvertingMasterPage ); 78 79 /** This method imports the presentation background shape 80 */ 81 ShapeSharedPtr importBackgroundShape(); // throw (ShapeLoadFailedException) 82 83 /** This method imports presentation-visible shapes (and skips all others). 84 85 @return the generated Shape, or NULL for no more shapes. 86 */ 87 ShapeSharedPtr importShape(); // throw (ConversionFailedException) 88 89 /** Test whether import is done. 90 91 @return true, if all shapes are imported via the 92 importShape() call. 93 */ 94 bool isImportDone() const; 95 const PolyPolygonVector& getPolygons() const; 96 getImportedShapesCount() const97 double getImportedShapesCount() const{ return mnAscendingPrio; } 98 private: 99 bool isSkip( css::uno::Reference<css::beans::XPropertySet> const& xPropSet, 100 std::u16string_view shapeType, 101 css::uno::Reference<css::drawing::XLayer> const& xLayer); 102 103 ShapeSharedPtr createShape( 104 css::uno::Reference<css::drawing::XShape> const& xCurrShape, 105 css::uno::Reference<css::beans::XPropertySet> const& xPropSet, 106 std::u16string_view shapeType ) const; 107 108 void importPolygons(css::uno::Reference< css::beans::XPropertySet > const& xPropSet) ; 109 110 struct XShapesEntry 111 { 112 ShapeSharedPtr const mpGroupShape; 113 css::uno::Reference<css::drawing::XShapes> const mxShapes; 114 sal_Int32 const mnCount; 115 sal_Int32 mnPos; 116 XShapesEntryslideshow::internal::ShapeImporter::XShapesEntry117 explicit XShapesEntry( ShapeSharedPtr const& pGroupShape ) 118 : mpGroupShape(pGroupShape), 119 mxShapes( pGroupShape->getXShape(), 120 css::uno::UNO_QUERY_THROW ), 121 mnCount(mxShapes->getCount()), mnPos(0) {} XShapesEntryslideshow::internal::ShapeImporter::XShapesEntry122 explicit XShapesEntry( css::uno::Reference< 123 css::drawing::XShapes> const& xShapes ) 124 : mpGroupShape(), mxShapes(xShapes), 125 mnCount(xShapes->getCount()), mnPos(0) {} 126 }; 127 128 css::uno::Reference<css::drawing::XDrawPage> mxPage; 129 css::uno::Reference<css::drawing::XDrawPagesSupplier> mxPagesSupplier; 130 const SlideShowContext& mrContext; 131 PolyPolygonVector maPolygons; 132 ::std::stack<XShapesEntry> maShapesStack; 133 double mnAscendingPrio; 134 bool mbConvertingMasterPage; 135 }; 136 137 } // namespace presentation::internal 138 139 #endif 140 141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 142