LibreOffice Module vcl (master)  1
GraphicObject.hxx
Go to the documentation of this file.
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 #pragma once
21 
22 #include <memory>
23 #include <vcl/graph.hxx>
24 #include <vcl/dllapi.h>
25 #include <o3tl/typed_flags_set.hxx>
26 
28 
29 namespace com::sun::star::graphic { class XGraphic; }
30 
31 // Adjustment defines
33 {
34  NONE = 0x00,
35  DRAWMODE = 0x01,
36  COLORS = 0x02,
37  MIRROR = 0x04,
38  ROTATE = 0x08,
39  TRANSPARENCY = 0x10,
40  ALL = 0x1f,
41 };
42 namespace o3tl
43 {
44  template<> struct typed_flags<GraphicAdjustmentFlags> : is_typed_flags<GraphicAdjustmentFlags, 0x1f> {};
45 }
46 
47 class VirtualDevice;
48 struct GrfSimpleCacheObj;
49 struct ImplTileInfo;
50 
52 {
53  friend class SdrGrafObj;
54 
55 private:
58  OUString maUserData;
59  std::unique_ptr<GrfSimpleCacheObj> mxSimpleCache;
60 
61  bool VCL_DLLPRIVATE ImplGetCropParams(
62  OutputDevice const * pOut,
63  Point& rPt,
64  Size& rSz,
65  const GraphicAttr* pAttr,
66  tools::PolyPolygon& rClipPolyPoly,
67  bool& bRectClipRegion
68  ) const;
69 
108  bool VCL_DLLPRIVATE ImplRenderTempTile(
109  VirtualDevice& rVDev,
110  int nNumTilesX,
111  int nNumTilesY,
112  const Size& rTileSizePixel,
113  const GraphicAttr* pAttr
114  );
115 
117  bool VCL_DLLPRIVATE ImplRenderTileRecursive(
118  VirtualDevice& rVDev,
119  int nExponent,
120  int nMSBFactor,
121  int nNumOrigTilesX,
122  int nNumOrigTilesY,
123  int nRemainderTilesX,
124  int nRemainderTilesY,
125  const Size& rTileSizePixel,
126  const GraphicAttr* pAttr,
127  ImplTileInfo& rTileInfo
128  );
129 
130  bool VCL_DLLPRIVATE ImplDrawTiled(
131  OutputDevice* pOut,
132  const tools::Rectangle& rArea,
133  const Size& rSizePixel,
134  const Size& rOffset,
135  const GraphicAttr* pAttr,
136  int nTileCacheSize1D
137  );
138 
139  bool VCL_DLLPRIVATE ImplDrawTiled(
140  OutputDevice& rOut,
141  const Point& rPos,
142  int nNumTilesX,
143  int nNumTilesY,
144  const Size& rTileSize,
145  const GraphicAttr* pAttr
146  );
147 
148  void VCL_DLLPRIVATE ImplTransformBitmap(
149  BitmapEx& rBmpEx,
150  const GraphicAttr& rAttr,
151  const Size& rCropLeftTop,
152  const Size& rCropRightBottom,
153  const tools::Rectangle& rCropRect,
154  const Size& rDstSize,
155  bool bEnlarge
156  ) const;
157 
158 public:
159  GraphicObject();
160  GraphicObject( const Graphic& rGraphic );
161  GraphicObject( const GraphicObject& rCacheObj );
162  ~GraphicObject();
163 
164  GraphicObject& operator=( const GraphicObject& rCacheObj );
165  bool operator==( const GraphicObject& rCacheObj ) const;
166  bool operator!=( const GraphicObject& rCacheObj ) const { return !( *this == rCacheObj ); }
167 
168  const Graphic& GetGraphic() const;
169  void SetGraphic( const Graphic& rGraphic);
170 
197  const Size& rDestSize,
198  const MapMode& rDestMap,
199  const GraphicAttr& rAttr
200  ) const;
201  Graphic GetTransformedGraphic( const GraphicAttr* pAttr ) const; // TODO: Change to Impl
202 
203  void SetAttr( const GraphicAttr& rAttr );
204  const GraphicAttr& GetAttr() const { return maAttr; }
205 
206  bool HasUserData() const { return !maUserData.isEmpty(); }
207  void SetUserData();
208  void SetUserData( const OUString& rUserData );
209  const OUString& GetUserData() const { return maUserData; }
210 
211  OString GetUniqueID() const;
212 
213  GraphicType GetType() const;
214  Size GetPrefSize() const;
215  MapMode GetPrefMapMode() const;
216  bool IsTransparent() const;
217  bool IsAnimated() const;
218  bool IsEPS() const;
219 
220  bool Draw(
221  OutputDevice* pOut,
222  const Point& rPt,
223  const Size& rSz,
224  const GraphicAttr* pAttr = nullptr
225  );
226 
255  void DrawTiled(
256  OutputDevice* pOut,
257  const tools::Rectangle& rArea,
258  const Size& rSize,
259  const Size& rOffset,
260  int nTileCacheSize1D=128
261  );
262 
263  bool StartAnimation(
264  OutputDevice* pOut,
265  const Point& rPt,
266  const Size& rSz,
267  tools::Long nExtraData = 0,
268  OutputDevice* pFirstFrameOutDev = nullptr
269  );
270 
271  void StopAnimation( const OutputDevice* pOut = nullptr, tools::Long nExtraData = 0 );
272 
273  static bool isGraphicObjectUniqueIdURL(OUString const & rURL);
274 
275  // create CropScaling information
276  // fWidth, fHeight: object size
277  // f*Crop: crop values relative to original bitmap size
278  basegfx::B2DVector calculateCropScaling(
279  double fWidth,
280  double fHeight,
281  double fLeftCrop,
282  double fTopCrop,
283  double fRightCrop,
284  double fBottomCrop) const;
285 };
286 
287 namespace vcl::graphic
288 {
289 
290 // Will search an object ( e.g. a control ) for any 'ImageURL' or 'Graphic'
291 // properties and return graphics from the properties in a vector. ImageURL
292 // will be loaded from the URL.
293 //
294 // Note: this implementation will cater for XNameContainer objects and deep inspect any containers
295 // if they exist
296 
297 VCL_DLLPUBLIC void SearchForGraphics(css::uno::Reference<css::uno::XInterface> const & rxInterface,
298  std::vector<css::uno::Reference<css::graphic::XGraphic>> & raGraphicList);
299 
300 
301 } // end namespace vcl::graphic
302 
303 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsEPS() const
const OUString & GetUserData() const
SdrObject & operator=(const SdrObject &rObj)=delete
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
long Long
GraphicType
Definition: graph.hxx:34
GraphicAttr maAttr
void SetGraphic(const Graphic &rGrf)
bool operator==(const ItalicMatrix &a, const ItalicMatrix &b)
Definition: vclenum.hxx:204
bool IsAnimated() const
Graphic GetTransformedGraphic(SdrGrafObjTransformsAttrs nTransformFlags=SdrGrafObjTransformsAttrs::ALL) const
const GraphicAttr & GetAttr() const
const Graphic & GetGraphic() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:303
bool HasUserData() const
GraphicAdjustmentFlags
OUString maUserData
bool operator!=(const GraphicObject &rCacheObj) const
std::unique_ptr< GrfSimpleCacheObj > mxSimpleCache
#define VCL_DLLPRIVATE
Definition: dllapi.h:31
void SearchForGraphics(uno::Reference< uno::XInterface > const &xInterface, std::vector< uno::Reference< css::graphic::XGraphic >> &raGraphicList)
void StartAnimation()