LibreOffice Module vcl (master)  1
impgraph.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 #ifndef INCLUDED_VCL_INC_IMPGRAPH_HXX
21 #define INCLUDED_VCL_INC_IMPGRAPH_HXX
22 
23 #include <vcl/dllapi.h>
25 #include <vcl/gdimtf.hxx>
26 #include <vcl/graph.hxx>
27 #include "graphic/Manager.hxx"
28 #include "graphic/GraphicID.hxx"
29 
31 {
35 
37  bool mbIsEPS;
39  bool mbIsAlpha;
40 
42 };
43 
44 class OutputDevice;
45 class GfxLink;
46 class ImpSwapFile;
48 class ImpGraphic;
49 
51 {
52  friend class Graphic;
53  friend class GraphicID;
54  friend class vcl::graphic::Manager;
55 
56 private:
57 
63  std::unique_ptr<Animation> mpAnimation;
64  std::shared_ptr<GraphicReader> mpContext;
65  std::shared_ptr<ImpSwapFile> mpSwapFile;
66  std::shared_ptr<GfxLink> mpGfxLink;
69  bool mbSwapOut;
71  std::shared_ptr<VectorGraphicData> maVectorGraphicData;
72  // cache checksum computation
73  mutable BitmapChecksum mnChecksum = 0;
74 
75  std::unique_ptr<GraphicID> mpGraphicID;
77 
78  std::chrono::high_resolution_clock::time_point maLastUsed;
79  bool mbPrepared;
80 
81 public:
82  ImpGraphic();
83  ImpGraphic( const ImpGraphic& rImpGraphic );
84  ImpGraphic( ImpGraphic&& rImpGraphic ) noexcept;
85  ImpGraphic( const GraphicExternalLink& rExternalLink);
86  ImpGraphic( const Bitmap& rBmp );
87  ImpGraphic( const BitmapEx& rBmpEx );
88  ImpGraphic(const std::shared_ptr<VectorGraphicData>& rVectorGraphicDataPtr);
89  ImpGraphic( const Animation& rAnimation );
90  ImpGraphic( const GDIMetaFile& rMtf );
91  ~ImpGraphic();
92 
93  void ImplSetPrepared(bool bAnimated, const Size* pSizeHint);
94 
95 private:
96 
97  ImpGraphic& operator=( const ImpGraphic& rImpGraphic );
98  ImpGraphic& operator=( ImpGraphic&& rImpGraphic );
99  bool operator==( const ImpGraphic& rImpGraphic ) const;
100  bool operator!=( const ImpGraphic& rImpGraphic ) const { return !( *this == rImpGraphic ); }
101 
102  OUString const & getOriginURL() const
103  {
104  return maGraphicExternalLink.msURL;
105  }
106 
107  void setOriginURL(OUString const & rOriginURL)
108  {
109  maGraphicExternalLink.msURL = rOriginURL;
110  }
111 
112  OString getUniqueID()
113  {
114  if (!mpGraphicID)
115  mpGraphicID.reset(new GraphicID(*this));
116  return mpGraphicID->getIDString();
117  }
118 
119  void createSwapInfo();
120  void ImplClearGraphics();
121  void ImplClear();
122 
123  GraphicType ImplGetType() const { return meType;}
124  void ImplSetDefaultType();
125  bool ImplIsSupportedGraphic() const;
126 
127  bool ImplIsTransparent() const;
128  bool ImplIsAlpha() const;
129  bool ImplIsAnimated() const;
130  bool ImplIsEPS() const;
131 
132  bool isAvailable() const;
133  bool makeAvailable();
134 
135  Bitmap ImplGetBitmap(const GraphicConversionParameters& rParameters) const;
136  BitmapEx ImplGetBitmapEx(const GraphicConversionParameters& rParameters) const;
138  const BitmapEx& ImplGetBitmapExRef() const;
139  Animation ImplGetAnimation() const;
140  const GDIMetaFile& ImplGetGDIMetaFile() const;
141 
142  Size ImplGetSizePixel() const;
143 
144  Size ImplGetPrefSize() const;
145  void ImplSetPrefSize( const Size& rPrefSize );
146 
147  MapMode ImplGetPrefMapMode() const;
148  void ImplSetPrefMapMode( const MapMode& rPrefMapMode );
149 
150  sal_uLong ImplGetSizeBytes() const;
151 
152  void ImplDraw( OutputDevice* pOutDev,
153  const Point& rDestPt ) const;
154  void ImplDraw( OutputDevice* pOutDev,
155  const Point& rDestPt,
156  const Size& rDestSize ) const;
157 
158  void ImplStartAnimation( OutputDevice* pOutDev,
159  const Point& rDestPt,
160  const Size& rDestSize,
161  long nExtraData,
162  OutputDevice* pFirstFrameOutDev );
163  void ImplStopAnimation( OutputDevice* pOutputDevice,
164  long nExtraData );
165 
166  void ImplSetAnimationNotifyHdl( const Link<Animation*,void>& rLink );
167  Link<Animation*,void> ImplGetAnimationNotifyHdl() const;
168 
169  sal_uInt32 ImplGetAnimationLoopCount() const;
170 
171 private:
172 
173  std::shared_ptr<GraphicReader>& ImplGetContext() { return mpContext;}
174  void ImplSetContext( const std::shared_ptr<GraphicReader>& pReader );
175  void ImplSetDummyContext( bool value ) { mbDummyContext = value; }
176  bool ImplReadEmbedded( SvStream& rIStream );
177  bool ImplWriteEmbedded( SvStream& rOStream );
178 
179  bool swapInFromStream(SvStream* pIStm);
180 
181  bool ImplIsDummyContext() const { return mbDummyContext; }
182  void ImplSetLink( const std::shared_ptr<GfxLink>& );
183  std::shared_ptr<GfxLink> ImplGetSharedGfxLink() const;
184  GfxLink ImplGetLink();
185  bool ImplIsLink() const;
186 
187  BitmapChecksum ImplGetChecksum() const;
188 
189  bool ImplExportNative( SvStream& rOStm ) const;
190 
191  friend void WriteImpGraphic(SvStream& rOStm, const ImpGraphic& rImpGraphic);
192  friend void ReadImpGraphic(SvStream& rIStm, ImpGraphic& rImpGraphic);
193 
194  const std::shared_ptr<VectorGraphicData>& getVectorGraphicData() const;
195 
197  BitmapEx getVectorGraphicReplacement() const;
198 
199  bool ensureAvailable () const;
200 
201  bool loadPrepared();
202 
203  sal_Int32 getPageNumber() const;
204 
205 public:
206  bool swapIn();
207  bool swapOut();
208  bool isSwappedOut() const { return mbSwapOut; }
209  OUString getSwapFileURL();
210 };
211 
212 #endif // INCLUDED_VCL_INC_IMPGRAPH_HXX
213 
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool mbDummyContext
Definition: impgraph.hxx:70
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
std::shared_ptr< GraphicReader > mpContext
Definition: impgraph.hxx:64
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
bool mbIsTransparent
Definition: impgraph.hxx:38
sal_uIntPtr sal_uLong
GraphicType
Definition: graph.hxx:35
bool mbIsAlpha
Definition: impgraph.hxx:39
bool mbSwapOut
Definition: impgraph.hxx:69
OUString const & getOriginURL() const
Definition: impgraph.hxx:102
sal_uInt32 mnAnimationLoopCount
Definition: impgraph.hxx:41
GraphicType meType
Definition: impgraph.hxx:67
Size maPrefSize
Definition: impgraph.hxx:33
std::unique_ptr< Animation > mpAnimation
Definition: impgraph.hxx:63
BitmapEx maBitmapEx
Definition: impgraph.hxx:59
bool isSwappedOut() const
Definition: impgraph.hxx:208
std::shared_ptr< ImpSwapFile > mpSwapFile
Definition: impgraph.hxx:65
void setOriginURL(OUString const &rOriginURL)
Definition: impgraph.hxx:107
GDIMetaFile maMetaFile
Definition: impgraph.hxx:58
std::shared_ptr< GraphicReader > & ImplGetContext()
Definition: impgraph.hxx:173
void ReadImpGraphic(SvStream &rIStm, ImpGraphic &rImpGraphic)
Definition: impgraph.cxx:1621
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:302
sal_uLong mnSizeBytes
Definition: impgraph.hxx:68
GraphicType ImplGetType() const
Definition: impgraph.hxx:123
OString getUniqueID()
Definition: impgraph.hxx:112
void WriteImpGraphic(SvStream &rOStm, const ImpGraphic &rImpGraphic)
Definition: impgraph.cxx:1780
bool mbPrepared
Definition: impgraph.hxx:79
Size maExPrefSize
If maBitmapEx is empty, this preferred size will be set on it when it gets initialized.
Definition: impgraph.hxx:61
std::shared_ptr< GfxLink > mpGfxLink
Definition: impgraph.hxx:66
std::chrono::high_resolution_clock::time_point maLastUsed
Definition: impgraph.hxx:78
std::unique_ptr< GraphicID > mpGraphicID
Definition: impgraph.hxx:75
std::shared_ptr< VectorGraphicData > maVectorGraphicData
Definition: impgraph.hxx:71
bool ImplIsDummyContext() const
Definition: impgraph.hxx:181
void ImplSetDummyContext(bool value)
Definition: impgraph.hxx:175
ImpSwapInfo maSwapInfo
Definition: impgraph.hxx:62
bool mbIsAnimated
Definition: impgraph.hxx:36
bool mbIsEPS
Definition: impgraph.hxx:37
GraphicExternalLink maGraphicExternalLink
Definition: impgraph.hxx:76
MapMode maPrefMapMode
Definition: impgraph.hxx:32
Size maSizePixel
Definition: impgraph.hxx:34