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