1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef INCLUDED_SLIDESHOW_GDIMTFTOOLS_HXX 29 #define INCLUDED_SLIDESHOW_GDIMTFTOOLS_HXX 30 31 #include <com/sun/star/uno/Reference.hxx> 32 #include <com/sun/star/uno/XComponentContext.hpp> 33 #include <com/sun/star/lang/XComponent.hpp> 34 #include <com/sun/star/drawing/XDrawPage.hpp> 35 36 #include <basegfx/range/b2drectangle.hxx> 37 #include <boost/shared_ptr.hpp> 38 39 #include "tools.hxx" 40 41 #include <vector> 42 43 class MetaAction; 44 class GDIMetaFile; 45 class Graphic; 46 47 // ----------------------------------------------------------------------------- 48 49 namespace slideshow 50 { 51 namespace internal 52 { 53 /// meta file loading specialities: 54 enum mtf_load_flags { 55 /// no flags 56 MTF_LOAD_NONE = 0, 57 /// annotate text actions with verbose comments, 58 /// denoting logical and physical text entities. 59 MTF_LOAD_VERBOSE_COMMENTS = 1, 60 /// the source of the metafile might be a foreign 61 /// application. The metafile is checked against unsupported 62 /// content, and, if necessary, returned as a pre-rendererd 63 /// bitmap. 64 MTF_LOAD_FOREIGN_SOURCE = 2, 65 /// retrieve a meta file for the page background only 66 MTF_LOAD_BACKGROUND_ONLY = 4, 67 /// retrieve the drawing layer scroll text metafile 68 MTF_LOAD_SCROLL_TEXT_MTF = 8 69 }; 70 71 // Animation info 72 // ============== 73 74 struct MtfAnimationFrame 75 { 76 MtfAnimationFrame( const GDIMetaFileSharedPtr& rMtf, 77 double nDuration ) : 78 mpMtf( rMtf ), 79 mnDuration( nDuration ) 80 { 81 } 82 83 /// Enables STL algos to be used for duration extraction 84 double getDuration() const 85 { 86 return mnDuration; 87 } 88 89 GDIMetaFileSharedPtr mpMtf; 90 double mnDuration; 91 }; 92 93 typedef ::std::vector< MtfAnimationFrame > VectorOfMtfAnimationFrames; 94 95 96 /** Retrieve a meta file for the given shape 97 98 @param xShape 99 XShape to retrieve a metafile for. 100 101 @param xContainingPage 102 The page that contains this shape. Needed for proper 103 import (currently, the UnoGraphicExporter needs this 104 information). 105 106 @param o_rMtf 107 Metafile to extract shape content into 108 */ 109 bool getMetaFile( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xSource, 110 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xContainingPage, 111 GDIMetaFile& o_rMtf, 112 int mtfLoadFlags, 113 const ::com::sun::star::uno::Reference< 114 ::com::sun::star::uno::XComponentContext >& rxContext ); 115 116 /** Remove all text actions from the given metafile. 117 */ 118 void removeTextActions( GDIMetaFile& io_rMtf ); 119 120 /** Gets the next action offset for iterating meta actions which is most 121 often returns 1. 122 */ 123 sal_Int32 getNextActionOffset( MetaAction * pCurrAct ); 124 125 /** Extract a vector of animation frames from given Graphic. 126 127 @param o_rFrames 128 Resulting vector of animated metafiles 129 130 @param o_rLoopCount 131 Number of times the bitmap animation shall be repeated 132 133 @param o_eCycleMode 134 Repeat mode (normal, or ping-pong mode) 135 136 @param rGraphic 137 Input graphic object, to extract animations from 138 */ 139 bool getAnimationFromGraphic( VectorOfMtfAnimationFrames& o_rFrames, 140 ::std::size_t& o_rLoopCount, 141 CycleMode& o_eCycleMode, 142 const Graphic& rGraphic ); 143 144 /** Retrieve scroll text animation rectangles from given metafile 145 146 @return true, if both rectangles have been found, false 147 otherwise. 148 */ 149 bool getRectanglesFromScrollMtf( ::basegfx::B2DRectangle& o_rScrollRect, 150 ::basegfx::B2DRectangle& o_rPaintRect, 151 const GDIMetaFileSharedPtr& rMtf ); 152 } 153 } 154 155 #endif /* INCLUDED_SLIDESHOW_GDIMTFTOOLS_HXX */ 156