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 24 #ifndef INCLUDED_SLIDESHOW_GDIMTFTOOLS_HXX 25 #define INCLUDED_SLIDESHOW_GDIMTFTOOLS_HXX 26 27 #include <com/sun/star/uno/Reference.hxx> 28 #include <com/sun/star/uno/XComponentContext.hpp> 29 #include <com/sun/star/lang/XComponent.hpp> 30 #include <com/sun/star/drawing/XDrawPage.hpp> 31 32 #include <basegfx/range/b2drectangle.hxx> 33 #include <boost/shared_ptr.hpp> 34 35 #include "tools.hxx" 36 37 #include <vector> 38 39 class MetaAction; 40 class GDIMetaFile; 41 class Graphic; 42 43 // ----------------------------------------------------------------------------- 44 45 namespace slideshow 46 { 47 namespace internal 48 { 49 /// meta file loading specialities: 50 enum mtf_load_flags { 51 /// no flags 52 MTF_LOAD_NONE = 0, 53 /// annotate text actions with verbose comments, 54 /// denoting logical and physical text entities. 55 MTF_LOAD_VERBOSE_COMMENTS = 1, 56 /// the source of the metafile might be a foreign 57 /// application. The metafile is checked against unsupported 58 /// content, and, if necessary, returned as a pre-rendererd 59 /// bitmap. 60 MTF_LOAD_FOREIGN_SOURCE = 2, 61 /// retrieve a meta file for the page background only 62 MTF_LOAD_BACKGROUND_ONLY = 4, 63 /// retrieve the drawing layer scroll text metafile 64 MTF_LOAD_SCROLL_TEXT_MTF = 8 65 }; 66 67 // Animation info 68 // ============== 69 70 struct MtfAnimationFrame 71 { MtfAnimationFrameslideshow::internal::MtfAnimationFrame72 MtfAnimationFrame( const GDIMetaFileSharedPtr& rMtf, 73 double nDuration ) : 74 mpMtf( rMtf ), 75 mnDuration( nDuration ) 76 { 77 } 78 79 /// Enables STL algos to be used for duration extraction getDurationslideshow::internal::MtfAnimationFrame80 double getDuration() const 81 { 82 return mnDuration; 83 } 84 85 GDIMetaFileSharedPtr mpMtf; 86 double mnDuration; 87 }; 88 89 typedef ::std::vector< MtfAnimationFrame > VectorOfMtfAnimationFrames; 90 91 92 /** Retrieve a meta file for the given shape 93 94 @param xShape 95 XShape to retrieve a metafile for. 96 97 @param xContainingPage 98 The page that contains this shape. Needed for proper 99 import (currently, the UnoGraphicExporter needs this 100 information). 101 102 @param o_rMtf 103 Metafile to extract shape content into 104 */ 105 bool getMetaFile( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xSource, 106 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xContainingPage, 107 GDIMetaFile& o_rMtf, 108 int mtfLoadFlags, 109 const ::com::sun::star::uno::Reference< 110 ::com::sun::star::uno::XComponentContext >& rxContext ); 111 112 /** Remove all text actions from the given metafile. 113 */ 114 void removeTextActions( GDIMetaFile& io_rMtf ); 115 116 /** Gets the next action offset for iterating meta actions which is most 117 often returns 1. 118 */ 119 sal_Int32 getNextActionOffset( MetaAction * pCurrAct ); 120 121 /** Extract a vector of animation frames from given Graphic. 122 123 @param o_rFrames 124 Resulting vector of animated metafiles 125 126 @param o_rLoopCount 127 Number of times the bitmap animation shall be repeated 128 129 @param o_eCycleMode 130 Repeat mode (normal, or ping-pong mode) 131 132 @param rGraphic 133 Input graphic object, to extract animations from 134 */ 135 bool getAnimationFromGraphic( VectorOfMtfAnimationFrames& o_rFrames, 136 ::std::size_t& o_rLoopCount, 137 CycleMode& o_eCycleMode, 138 const Graphic& rGraphic ); 139 140 /** Retrieve scroll text animation rectangles from given metafile 141 142 @return true, if both rectangles have been found, false 143 otherwise. 144 */ 145 bool getRectanglesFromScrollMtf( ::basegfx::B2DRectangle& o_rScrollRect, 146 ::basegfx::B2DRectangle& o_rPaintRect, 147 const GDIMetaFileSharedPtr& rMtf ); 148 } 149 } 150 151 #endif /* INCLUDED_SLIDESHOW_GDIMTFTOOLS_HXX */ 152