1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: graphiccollector.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef GRAPHICCOLLECTOR_HXX
32 #define GRAPHICCOLLECTOR_HXX
34 #include <com/sun/star/uno/XComponentContext.hpp>
35 #include <com/sun/star/awt/DeviceInfo.hpp>
36 #include <com/sun/star/text/GraphicCrop.hpp>
37 #include <com/sun/star/drawing/XShape.hpp>
38 #include <com/sun/star/beans/XPropertySet.hpp>
39 #include <com/sun/star/awt/Size.hpp>
40 #include <com/sun/star/graphic/XGraphic.hpp>
41 #include <com/sun/star/frame/XModel.hpp>
45 struct GraphicSettings
47 sal_Bool mbJPEGCompression
;
48 sal_Int32 mnJPEGQuality
;
49 sal_Bool mbRemoveCropArea
;
50 sal_Int32 mnImageResolution
;
51 sal_Bool mbEmbedLinkedGraphics
;
53 GraphicSettings( sal_Bool bJPEGCompression
, sal_Int32 nJPEGQuality
, sal_Bool bRemoveCropArea
,
54 sal_Int32 nImageResolution
, sal_Bool bEmbedLinkedGraphics
)
55 : mbJPEGCompression( bJPEGCompression
)
56 , mnJPEGQuality( nJPEGQuality
)
57 , mbRemoveCropArea( bRemoveCropArea
)
58 , mnImageResolution( nImageResolution
)
59 , mbEmbedLinkedGraphics( bEmbedLinkedGraphics
) {};
62 class GraphicCollector
68 com::sun::star::uno::Reference
< com::sun::star::drawing::XShape
> mxShape
; // if mbFillBitmap is false the xShape has
69 com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySet
> mxPropertySet
; // to be used otherwise the PropertySet
70 com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySet
> mxPagePropertySet
;
71 rtl::OUString maGraphicURL
;
72 rtl::OUString maGraphicStreamURL
;
73 com::sun::star::text::GraphicCrop maGraphicCropLogic
;
74 com::sun::star::awt::Size maLogicalSize
;
75 sal_Bool mbFillBitmap
;
77 GraphicUser() : mxShape(), maGraphicCropLogic( 0, 0, 0, 0 ), mbFillBitmap( sal_False
) {};
82 com::sun::star::uno::Reference
< com::sun::star::graphic::XGraphic
> mxGraphic
; // the corresponding XGraphic of the Shape
83 com::sun::star::awt::Size maLogicalSize
; // the biggest logical size the graphic will be displayed
84 sal_Bool mbRemoveCropArea
; //
85 com::sun::star::text::GraphicCrop maGraphicCropLogic
;
86 std::vector
< GraphicUser
> maUser
;
88 GraphicEntity( const com::sun::star::uno::Reference
< com::sun::star::graphic::XGraphic
>& xGraphic
, const GraphicUser
& rUser
)
89 : mxGraphic( xGraphic
), maLogicalSize( rUser
.maLogicalSize
), mbRemoveCropArea( sal_False
), maGraphicCropLogic( 0, 0, 0, 0 ) { maUser
.push_back( rUser
); };
92 static const com::sun::star::awt::DeviceInfo
& GetDeviceInfo( const com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
>& rxFact
);
93 static com::sun::star::awt::Size
GetOriginalSize( const com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
>& rxMSF
,
94 const com::sun::star::uno::Reference
< com::sun::star::graphic::XGraphic
>& rxGraphic
);
96 // collecting graphic instances, the downside of this method is that every graphic is swapped in
97 static void CollectGraphics( const com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
>& rxMSF
, const com::sun::star::uno::Reference
< com::sun::star::frame::XModel
>& rxModel
,
98 const GraphicSettings
& rGraphicSettings
, std::vector
< GraphicEntity
>& io_rGraphicList
);
99 // counting graphics without swapping in graphics
100 static void CountGraphics( const com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
>& rxMSF
, const com::sun::star::uno::Reference
< com::sun::star::frame::XModel
>& rxModel
,
101 const GraphicSettings
& rGraphicSettings
, sal_Int32
& rGraphics
);
104 // --------------------
105 // - GRAPHICCOLLECTOR -
106 // --------------------
109 #endif // GRAPHICCOLLECTOR_HXX