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, const GraphicObject* pCopyObj = nullptr);
170  void SetGraphic( const Graphic& rGraphic, const OUString& rLink );
171 
198  const Size& rDestSize,
199  const MapMode& rDestMap,
200  const GraphicAttr& rAttr
201  ) const;
202  Graphic GetTransformedGraphic( const GraphicAttr* pAttr ) const; // TODO: Change to Impl
203 
204  void SetAttr( const GraphicAttr& rAttr );
205  const GraphicAttr& GetAttr() const { return maAttr; }
206 
207  bool HasUserData() const { return !maUserData.isEmpty(); }
208  void SetUserData();
209  void SetUserData( const OUString& rUserData );
210  const OUString& GetUserData() const { return maUserData; }
211 
212  OString GetUniqueID() const;
213 
214  GraphicType GetType() const;
215  Size GetPrefSize() const;
216  MapMode GetPrefMapMode() const;
217  bool IsTransparent() const;
218  bool IsAnimated() const;
219  bool IsEPS() const;
220 
221  bool Draw(
222  OutputDevice* pOut,
223  const Point& rPt,
224  const Size& rSz,
225  const GraphicAttr* pAttr = nullptr
226  );
227 
256  void DrawTiled(
257  OutputDevice* pOut,
258  const tools::Rectangle& rArea,
259  const Size& rSize,
260  const Size& rOffset,
261  int nTileCacheSize1D=128
262  );
263 
264  bool StartAnimation(
265  OutputDevice* pOut,
266  const Point& rPt,
267  const Size& rSz,
268  tools::Long nExtraData = 0,
269  OutputDevice* pFirstFrameOutDev = nullptr
270  );
271 
272  void StopAnimation( const OutputDevice* pOut = nullptr, tools::Long nExtraData = 0 );
273 
274  static bool isGraphicObjectUniqueIdURL(OUString const & rURL);
275 
276  // create CropScaling information
277  // fWidth, fHeight: object size
278  // f*Crop: crop values relative to original bitmap size
279  basegfx::B2DVector calculateCropScaling(
280  double fWidth,
281  double fHeight,
282  double fLeftCrop,
283  double fTopCrop,
284  double fRightCrop,
285  double fBottomCrop) const;
286 };
287 
288 namespace vcl::graphic
289 {
290 
291 // Will search an object ( e.g. a control ) for any 'ImageURL' or 'Graphic'
292 // properties and return graphics from the properties in a vector. ImageURL
293 // will be loaded from the URL.
294 //
295 // Note: this implementation will cater for XNameContainer objects and deep inspect any containers
296 // if they exist
297 
298 VCL_DLLPUBLIC void SearchForGraphics(css::uno::Reference<css::uno::XInterface> const & rxInterface,
299  std::vector<css::uno::Reference<css::graphic::XGraphic>> & raGraphicList);
300 
301 
302 } // end namespace vcl::graphic
303 
304 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsEPS() const
const OUString & GetUserData() const
#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:206
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:302
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)
SdrGrafObj & operator=(const SdrGrafObj &rObj)
void StartAnimation()