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