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 GRAPHICCOLLECTOR_HXX 25 #define GRAPHICCOLLECTOR_HXX 26 27 #include <com/sun/star/uno/XComponentContext.hpp> 28 #include <com/sun/star/awt/DeviceInfo.hpp> 29 #include <com/sun/star/text/GraphicCrop.hpp> 30 #include <com/sun/star/drawing/XShape.hpp> 31 #include <com/sun/star/beans/XPropertySet.hpp> 32 #include <com/sun/star/awt/Size.hpp> 33 #include <com/sun/star/graphic/XGraphic.hpp> 34 #include <com/sun/star/frame/XModel.hpp> 35 #include <vector> 36 37 38 struct GraphicSettings 39 { 40 sal_Bool mbJPEGCompression; 41 sal_Int32 mnJPEGQuality; 42 sal_Bool mbRemoveCropArea; 43 sal_Int32 mnImageResolution; 44 sal_Bool mbEmbedLinkedGraphics; 45 GraphicSettingsGraphicSettings46 GraphicSettings( sal_Bool bJPEGCompression, sal_Int32 nJPEGQuality, sal_Bool bRemoveCropArea, 47 sal_Int32 nImageResolution, sal_Bool bEmbedLinkedGraphics ) 48 : mbJPEGCompression( bJPEGCompression ) 49 , mnJPEGQuality( nJPEGQuality ) 50 , mbRemoveCropArea( bRemoveCropArea ) 51 , mnImageResolution( nImageResolution ) 52 , mbEmbedLinkedGraphics( bEmbedLinkedGraphics ) {}; 53 }; 54 55 class GraphicCollector 56 { 57 public: 58 59 struct GraphicUser 60 { 61 com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mxShape; // if mbFillBitmap is false the xShape has 62 com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > mxPropertySet; // to be used otherwise the PropertySet 63 com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > mxPagePropertySet; 64 rtl::OUString maGraphicURL; 65 rtl::OUString maGraphicStreamURL; 66 com::sun::star::text::GraphicCrop maGraphicCropLogic; 67 com::sun::star::awt::Size maLogicalSize; 68 sal_Bool mbFillBitmap; 69 GraphicUserGraphicCollector::GraphicUser70 GraphicUser() : mxShape(), maGraphicCropLogic( 0, 0, 0, 0 ), mbFillBitmap( sal_False ) {}; 71 }; 72 73 struct GraphicEntity 74 { 75 com::sun::star::awt::Size maLogicalSize; // the biggest logical size the graphic will be displayed 76 sal_Bool mbRemoveCropArea; // 77 com::sun::star::text::GraphicCrop maGraphicCropLogic; 78 std::vector< GraphicUser > maUser; 79 GraphicEntityGraphicCollector::GraphicEntity80 GraphicEntity( const GraphicUser& rUser ) 81 : maLogicalSize( rUser.maLogicalSize ), mbRemoveCropArea( sal_False ), maGraphicCropLogic( 0, 0, 0, 0 ) { maUser.push_back( rUser ); }; 82 }; 83 84 static const com::sun::star::awt::DeviceInfo& GetDeviceInfo( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxFact ); 85 static com::sun::star::awt::Size GetOriginalSize( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext, 86 const com::sun::star::uno::Reference< com::sun::star::graphic::XGraphic >& rxGraphic ); 87 88 // collecting graphic instances, the downside of this method is that every graphic is swapped in 89 static void CollectGraphics( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext, const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rxModel, 90 const GraphicSettings& rGraphicSettings, std::vector< GraphicEntity >& io_rGraphicList ); 91 // counting graphics without swapping in graphics 92 static void CountGraphics( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext, const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rxModel, 93 const GraphicSettings& rGraphicSettings, sal_Int32& rGraphics ); 94 }; 95 96 // -------------------- 97 // - GRAPHICCOLLECTOR - 98 // -------------------- 99 100 101 #endif // GRAPHICCOLLECTOR_HXX 102