xref: /AOO42X/main/sdext/source/minimizer/graphiccollector.hxx (revision 9bce9b0d387299c68bd81d539e1478357a103de5)
106bcd5d2SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
306bcd5d2SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
406bcd5d2SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
506bcd5d2SAndrew Rist  * distributed with this work for additional information
606bcd5d2SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
706bcd5d2SAndrew Rist  * to you under the Apache License, Version 2.0 (the
806bcd5d2SAndrew Rist  * "License"); you may not use this file except in compliance
906bcd5d2SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
1106bcd5d2SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
1306bcd5d2SAndrew Rist  * Unless required by applicable law or agreed to in writing,
1406bcd5d2SAndrew Rist  * software distributed under the License is distributed on an
1506bcd5d2SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1606bcd5d2SAndrew Rist  * KIND, either express or implied.  See the License for the
1706bcd5d2SAndrew Rist  * specific language governing permissions and limitations
1806bcd5d2SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
2006bcd5d2SAndrew Rist  *************************************************************/
2106bcd5d2SAndrew Rist 
2206bcd5d2SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef GRAPHICCOLLECTOR_HXX
25cdf0e10cSrcweir #define GRAPHICCOLLECTOR_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
28cdf0e10cSrcweir #include <com/sun/star/awt/DeviceInfo.hpp>
29cdf0e10cSrcweir #include <com/sun/star/text/GraphicCrop.hpp>
30cdf0e10cSrcweir #include <com/sun/star/drawing/XShape.hpp>
31cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
32cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp>
33cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphic.hpp>
34cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp>
35cdf0e10cSrcweir #include <vector>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir 
38cdf0e10cSrcweir struct GraphicSettings
39cdf0e10cSrcweir {
40cdf0e10cSrcweir     sal_Bool    mbJPEGCompression;
41cdf0e10cSrcweir     sal_Int32   mnJPEGQuality;
42cdf0e10cSrcweir     sal_Bool    mbRemoveCropArea;
43cdf0e10cSrcweir     sal_Int32   mnImageResolution;
44cdf0e10cSrcweir     sal_Bool    mbEmbedLinkedGraphics;
45cdf0e10cSrcweir 
GraphicSettingsGraphicSettings46cdf0e10cSrcweir     GraphicSettings( sal_Bool bJPEGCompression, sal_Int32 nJPEGQuality, sal_Bool bRemoveCropArea,
47cdf0e10cSrcweir                         sal_Int32 nImageResolution, sal_Bool bEmbedLinkedGraphics )
48cdf0e10cSrcweir     : mbJPEGCompression( bJPEGCompression )
49cdf0e10cSrcweir     , mnJPEGQuality( nJPEGQuality )
50cdf0e10cSrcweir     , mbRemoveCropArea( bRemoveCropArea )
51cdf0e10cSrcweir     , mnImageResolution( nImageResolution )
52cdf0e10cSrcweir     , mbEmbedLinkedGraphics( bEmbedLinkedGraphics ) {};
53cdf0e10cSrcweir };
54cdf0e10cSrcweir 
55cdf0e10cSrcweir class GraphicCollector
56cdf0e10cSrcweir {
57cdf0e10cSrcweir     public:
58cdf0e10cSrcweir 
59cdf0e10cSrcweir     struct GraphicUser
60cdf0e10cSrcweir     {
61cdf0e10cSrcweir         com::sun::star::uno::Reference< com::sun::star::drawing::XShape >       mxShape;            // if mbFillBitmap is false the xShape has
62cdf0e10cSrcweir         com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >   mxPropertySet;      // to be used otherwise the PropertySet
63cdf0e10cSrcweir         com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >   mxPagePropertySet;
64cdf0e10cSrcweir         rtl::OUString                       maGraphicURL;
65cdf0e10cSrcweir         rtl::OUString                       maGraphicStreamURL;
66cdf0e10cSrcweir         com::sun::star::text::GraphicCrop   maGraphicCropLogic;
67cdf0e10cSrcweir         com::sun::star::awt::Size           maLogicalSize;
68cdf0e10cSrcweir         sal_Bool                            mbFillBitmap;
69cdf0e10cSrcweir 
GraphicUserGraphicCollector::GraphicUser70cdf0e10cSrcweir         GraphicUser() : mxShape(), maGraphicCropLogic( 0, 0, 0, 0 ), mbFillBitmap( sal_False ) {};
71cdf0e10cSrcweir     };
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     struct GraphicEntity
74cdf0e10cSrcweir     {
75cdf0e10cSrcweir         com::sun::star::awt::Size                       maLogicalSize;                          // the biggest logical size the graphic will be displayed
76cdf0e10cSrcweir         sal_Bool                                        mbRemoveCropArea;                       //
77cdf0e10cSrcweir         com::sun::star::text::GraphicCrop               maGraphicCropLogic;
78cdf0e10cSrcweir         std::vector< GraphicUser >                      maUser;
79cdf0e10cSrcweir 
GraphicEntityGraphicCollector::GraphicEntity80cdf0e10cSrcweir         GraphicEntity( const GraphicUser& rUser )
81cdf0e10cSrcweir             : maLogicalSize( rUser.maLogicalSize ), mbRemoveCropArea( sal_False ), maGraphicCropLogic( 0, 0, 0, 0 ) { maUser.push_back( rUser ); };
82cdf0e10cSrcweir     };
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     static const com::sun::star::awt::DeviceInfo& GetDeviceInfo( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxFact );
85*597a4c59SAriel Constenla-Haile     static com::sun::star::awt::Size GetOriginalSize( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext,
86cdf0e10cSrcweir                 const com::sun::star::uno::Reference< com::sun::star::graphic::XGraphic >& rxGraphic );
87cdf0e10cSrcweir 
88cdf0e10cSrcweir     // collecting graphic instances, the downside of this method is that every graphic is swapped in
89*597a4c59SAriel Constenla-Haile     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,
90cdf0e10cSrcweir         const GraphicSettings& rGraphicSettings, std::vector< GraphicEntity >& io_rGraphicList );
91cdf0e10cSrcweir     // counting graphics without swapping in graphics
92*597a4c59SAriel Constenla-Haile     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,
93cdf0e10cSrcweir         const GraphicSettings& rGraphicSettings, sal_Int32& rGraphics );
94cdf0e10cSrcweir };
95cdf0e10cSrcweir 
96cdf0e10cSrcweir // --------------------
97cdf0e10cSrcweir // - GRAPHICCOLLECTOR -
98cdf0e10cSrcweir // --------------------
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 
101cdf0e10cSrcweir #endif // GRAPHICCOLLECTOR_HXX
102