1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SVX_SVDOGRAF_HXX
21 #define INCLUDED_SVX_SVDOGRAF_HXX
23 #include <com/sun/star/io/XInputStream.hpp>
24 #include <com/sun/star/graphic/XGraphic.hpp>
25 #include <com/sun/star/uno/Sequence.hxx>
26 #include <vcl/graph.hxx>
27 #include <svx/svdorect.hxx>
28 #include <vcl/GraphicObject.hxx>
29 #include <svx/svxdllapi.h>
30 #include <o3tl/typed_flags_set.hxx>
36 class GraphicProperties
;
37 } // end of namespace properties
40 class ViewObjectContactOfGraphic
;
41 } // end of namespace contact
42 } // end of namespace sdr
45 * Options for GetTransformedGraphic()
47 enum class SdrGrafObjTransformsAttrs
56 template<> struct typed_flags
<SdrGrafObjTransformsAttrs
> : is_typed_flags
<SdrGrafObjTransformsAttrs
, 0x03> {};
59 class SdrGrafObjGeoData
: public SdrTextObjGeoData
74 * This class represents an embedded or linked bitmap graphic object.
76 class SVX_DLLPUBLIC SdrGrafObj
: public SdrRectObj
79 // to allow sdr::properties::GraphicProperties access to SetXPolyDirty()
80 friend class sdr::properties::GraphicProperties
;
82 // to allow sdr::contact::ViewObjectContactOfGraphic access to ImpUpdateGraphicLink()
83 friend class sdr::contact::ViewObjectContactOfGraphic
;
84 friend class SdrExchangeView
; // Only for a ForceSwapIn() call.
85 friend class SdrGraphicLink
;
87 virtual std::unique_ptr
<sdr::contact::ViewContact
> CreateObjectSpecificViewContact() override
;
88 virtual std::unique_ptr
<sdr::properties::BaseProperties
> CreateObjectSpecificProperties() override
;
90 void ImpSetAttrToGrafInfo(); // Copy values from the pool
91 GraphicAttr aGrafInfo
;
93 OUString aFileName
; // If it's a Link, the filename can be found in here
96 std::unique_ptr
<GraphicObject
> mpGraphicObject
; // In order to speed up output of bitmaps, especially rotated ones
97 std::unique_ptr
<GraphicObject
> mpReplacementGraphicObject
;
98 SdrGraphicLink
* pGraphicLink
; // And here a pointer for linked graphics
99 bool bMirrored
:1; // True: the graphic is horizontal, which means it's mirrored along the y-axis
101 // Flag for allowing text animation. Default is true.
102 bool mbGrafAnimationAllowed
:1;
104 bool mbIsSignatureLine
;
105 OUString maSignatureLineId
;
106 OUString maSignatureLineSuggestedSignerName
;
107 OUString maSignatureLineSuggestedSignerTitle
;
108 OUString maSignatureLineSuggestedSignerEmail
;
109 OUString maSignatureLineSigningInstructions
;
110 bool mbIsSignatureLineShowSignDate
;
111 bool mbIsSignatureLineCanAddComment
;
112 bool mbSignatureLineIsSigned
;
113 css::uno::Reference
<css::graphic::XGraphic
> mpSignatureLineUnsignedGraphic
;
115 void ImpRegisterLink();
116 void ImpDeregisterLink();
117 void ImpSetLinkedGraphic( const Graphic
& rGraphic
);
118 DECL_LINK( ImpSwapHdl
, const GraphicObject
*, SvStream
* );
119 DECL_LINK( ReplacementSwapHdl
, const GraphicObject
*, SvStream
* );
120 void onGraphicChanged();
121 GDIMetaFile
GetMetaFile(GraphicType
&rGraphicType
) const;
124 // protected destructor
125 virtual ~SdrGrafObj() override
;
128 SdrGrafObj(SdrModel
& rSdrModel
);
131 const Graphic
& rGrf
);
135 const tools::Rectangle
& rRect
);
137 void SetGraphicObject( const GraphicObject
& rGrfObj
);
138 const GraphicObject
& GetGraphicObject(bool bForceSwapIn
= false) const;
139 const GraphicObject
* GetReplacementGraphicObject() const;
141 void NbcSetGraphic(const Graphic
& rGrf
);
142 void SetGraphic(const Graphic
& rGrf
);
143 const Graphic
& GetGraphic() const;
145 Graphic
GetTransformedGraphic( SdrGrafObjTransformsAttrs nTransformFlags
= SdrGrafObjTransformsAttrs::ALL
) const;
146 GraphicType
GetGraphicType() const;
147 GraphicAttr
GetGraphicAttr( SdrGrafObjTransformsAttrs nTransformFlags
= SdrGrafObjTransformsAttrs::ALL
) const;
150 bool IsAnimated() const;
153 MapMode
GetGrafPrefMapMode() const;
154 Size
GetGrafPrefSize() const;
156 void SetGrafStreamURL( const OUString
& rGraphicStreamURL
);
157 OUString
const & GetGrafStreamURL() const;
158 Size
getOriginalSize() const;
161 void ForceSwapIn() const;
164 void SetGraphicLink(const OUString
& rFileName
, const OUString
& rReferer
, const OUString
& rFilterName
);
165 void ReleaseGraphicLink();
166 bool IsLinkedGraphic() const;
168 const OUString
& GetFileName() const { return aFileName
;}
170 void StartAnimation();
172 virtual void TakeObjInfo(SdrObjTransformInfoRec
& rInfo
) const override
;
173 virtual sal_uInt16
GetObjIdentifier() const override
;
175 virtual OUString
TakeObjNameSingul() const override
;
176 virtual OUString
TakeObjNamePlural() const override
;
178 virtual SdrGrafObj
* CloneSdrObject(SdrModel
& rTargetModel
) const override
;
179 SdrGrafObj
& operator=(const SdrGrafObj
& rObj
);
181 virtual sal_uInt32
GetHdlCount() const override
;
182 virtual void AddToHdlList(SdrHdlList
& rHdlList
) const override
;
184 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
) override
;
185 virtual void NbcMirror(const Point
& rRef1
, const Point
& rRef2
) override
;
186 virtual SdrObjGeoData
* NewGeoData() const override
;
187 virtual void SaveGeoData(SdrObjGeoData
& rGeo
) const override
;
188 virtual void RestGeoData(const SdrObjGeoData
& rGeo
) override
;
190 bool HasGDIMetaFile() const;
192 // react on model/page change
193 virtual void handlePageChange(SdrPage
* pOldPage
, SdrPage
* pNewPage
) override
;
195 bool isEmbeddedVectorGraphicData() const;
196 GDIMetaFile
getMetafileFromEmbeddedVectorGraphicData() const;
198 bool isEmbeddedPdfData() const;
199 std::shared_ptr
<css::uno::Sequence
<sal_Int8
>> const & getEmbeddedPdfData() const;
200 /// Returns the page number of the embedded data (typically to re-render or import it).
201 sal_Int32
getEmbeddedPageNumber() const;
203 virtual SdrObject
* DoConvertToPolyObj(bool bBezier
, bool bAddText
) const override
;
205 virtual void AdjustToMaxRect( const tools::Rectangle
& rMaxRect
, bool bShrinkOnly
= false ) override
;
207 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
209 bool IsMirrored() const { return bMirrored
;}
210 void SetMirrored( bool _bMirrored
);
212 virtual bool shouldKeepAspectRatio() const override
{ return true; }
214 // Access to GrafAnimationAllowed flag
215 void SetGrafAnimationAllowed(bool bNew
);
217 css::uno::Reference
< css::io::XInputStream
> getInputStream();
219 // #i103116# FullDrag support
220 virtual SdrObject
* getFullDragClone() const override
;
222 // add handles for crop mode when selected
223 virtual void addCropHandles(SdrHdlList
& rTarget
) const override
;
226 void setIsSignatureLine(bool bIsSignatureLine
) { mbIsSignatureLine
= bIsSignatureLine
; };
227 bool isSignatureLine() const { return mbIsSignatureLine
; };
228 void setSignatureLineId(const OUString
& rSignatureLineId
)
230 maSignatureLineId
= rSignatureLineId
;
232 const OUString
& getSignatureLineId() const { return maSignatureLineId
; };
233 void setSignatureLineSuggestedSignerName(const OUString
& rSuggestedSignerName
)
235 maSignatureLineSuggestedSignerName
= rSuggestedSignerName
;
237 const OUString
& getSignatureLineSuggestedSignerName() const
239 return maSignatureLineSuggestedSignerName
;
241 void setSignatureLineSuggestedSignerTitle(const OUString
& rSuggestedSignerTitle
)
243 maSignatureLineSuggestedSignerTitle
= rSuggestedSignerTitle
;
245 const OUString
& getSignatureLineSuggestedSignerTitle() const
247 return maSignatureLineSuggestedSignerTitle
;
249 void setSignatureLineSuggestedSignerEmail(const OUString
& rSuggestedSignerEmail
)
251 maSignatureLineSuggestedSignerEmail
= rSuggestedSignerEmail
;
253 const OUString
& getSignatureLineSuggestedSignerEmail() const
255 return maSignatureLineSuggestedSignerEmail
;
257 void setSignatureLineSigningInstructions(const OUString
& rSigningInstructions
)
259 maSignatureLineSigningInstructions
= rSigningInstructions
;
261 const OUString
& getSignatureLineSigningInstructions() const
263 return maSignatureLineSigningInstructions
;
265 void setSignatureLineShowSignDate(bool bIsSignatureLineShowSignDate
)
267 mbIsSignatureLineShowSignDate
= bIsSignatureLineShowSignDate
;
269 bool isSignatureLineShowSignDate() const { return mbIsSignatureLineShowSignDate
; };
270 void setSignatureLineCanAddComment(bool bIsSignatureCanAddComment
)
272 mbIsSignatureLineCanAddComment
= bIsSignatureCanAddComment
;
274 bool isSignatureLineCanAddComment() const { return mbIsSignatureLineCanAddComment
; };
275 css::uno::Reference
<css::graphic::XGraphic
> const & getSignatureLineUnsignedGraphic() const
277 return mpSignatureLineUnsignedGraphic
;
279 void setSignatureLineUnsignedGraphic(css::uno::Reference
<css::graphic::XGraphic
> rGraphic
)
281 mpSignatureLineUnsignedGraphic
= rGraphic
;
283 bool isSignatureLineSigned() const { return mbSignatureLineIsSigned
; };
284 void setSignatureLineIsSigned(bool bIsSigned
) { mbSignatureLineIsSigned
= bIsSigned
; }
287 #endif // INCLUDED_SVX_SVDOGRAF_HXX
289 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */