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 .
19 #ifndef INCLUDED_EDITENG_BRUSHITEM_HXX
20 #define INCLUDED_EDITENG_BRUSHITEM_HXX
22 #include <svl/poolitem.hxx>
23 #include <vcl/wall.hxx>
24 #include <tools/link.hxx>
25 #include <unotools/securityoptions.hxx>
26 #include <editeng/editengdllapi.h>
29 // class SvxBrushItem ----------------------------------------------------
33 class CntWallpaperItem
;
35 #define BRUSH_GRAPHIC_VERSION ((sal_uInt16)0x0001)
37 enum SvxGraphicPosition
40 GPOS_LT
, GPOS_MT
, GPOS_RT
,
41 GPOS_LM
, GPOS_MM
, GPOS_RM
,
42 GPOS_LB
, GPOS_MB
, GPOS_RB
,
46 class EDITENG_DLLPUBLIC SvxBrushItem
: public SfxPoolItem
49 sal_Int32 nShadingValue
;
50 mutable std::unique_ptr
<GraphicObject
> xGraphicObject
;
51 sal_Int8 nGraphicTransparency
; //contains a percentage value which is
52 //copied to the GraphicObject when necessary
53 SvtSecurityOptions maSecOptions
;
56 SvxGraphicPosition eGraphicPos
;
57 mutable bool bLoadAgain
;
59 void ApplyGraphicTransparency_Impl();
60 // only used by Create
61 SvxBrushItem( SvStream
& rStrm
,
62 sal_uInt16 nVersion
, sal_uInt16 nWhich
);
65 static SfxPoolItem
* CreateDefault();
67 explicit SvxBrushItem( sal_uInt16 nWhich
);
68 SvxBrushItem( const Color
& rColor
, sal_uInt16 nWhich
);
70 SvxBrushItem( const Graphic
& rGraphic
,
71 SvxGraphicPosition ePos
, sal_uInt16 nWhich
);
72 SvxBrushItem( const GraphicObject
& rGraphicObj
,
73 SvxGraphicPosition ePos
, sal_uInt16 nWhich
);
74 SvxBrushItem( const OUString
& rLink
, const OUString
& rFilter
,
75 SvxGraphicPosition ePos
, sal_uInt16 nWhich
);
76 SvxBrushItem( const SvxBrushItem
& );
77 SvxBrushItem( SvxBrushItem
&& );
78 SvxBrushItem( const CntWallpaperItem
&, sal_uInt16 nWhich
);
80 virtual ~SvxBrushItem() override
;
84 virtual bool GetPresentation( SfxItemPresentation ePres
,
87 OUString
&rText
, const IntlWrapper
* = nullptr ) const override
;
89 virtual bool operator==( const SfxPoolItem
& ) const override
;
90 virtual bool QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) const override
;
91 virtual bool PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
) override
;
93 virtual SfxPoolItem
* Clone( SfxItemPool
*pPool
= nullptr ) const override
;
94 virtual SfxPoolItem
* Create( SvStream
&, sal_uInt16 nVersion
) const override
;
95 virtual SvStream
& Store( SvStream
& , sal_uInt16 nItemVersion
) const override
;
96 virtual sal_uInt16
GetVersion( sal_uInt16 nFileVersion
) const override
;
98 const Color
& GetColor() const { return aColor
; }
99 Color
& GetColor() { return aColor
; }
100 void SetColor( const Color
& rCol
) { aColor
= rCol
; }
102 SvxGraphicPosition
GetGraphicPos() const { return eGraphicPos
; }
104 sal_Int32
GetShadingValue() const { return nShadingValue
; }
105 const Graphic
* GetGraphic(OUString
const & referer
= OUString()/*TODO*/) const;
106 const GraphicObject
* GetGraphicObject(OUString
const & referer
= OUString()/*TODO*/) const;
107 const OUString
& GetGraphicLink() const { return maStrLink
; }
108 const OUString
& GetGraphicFilter() const { return maStrFilter
; }
110 // get graphic transparency in percent
111 sal_Int8
getGraphicTransparency() const { return nGraphicTransparency
; }
112 void setGraphicTransparency(sal_Int8 nNew
);
114 void SetGraphicPos( SvxGraphicPosition eNew
);
115 void SetGraphic( const Graphic
& rNew
);
116 void SetGraphicObject( const GraphicObject
& rNewObj
);
117 void SetGraphicLink( const OUString
& rNew
);
118 void SetGraphicFilter( const OUString
& rNew
);
120 SvxBrushItem
& operator=(const SvxBrushItem
& rItem
);
121 SvxBrushItem
& operator=(SvxBrushItem
&& rItem
);
123 static SvxGraphicPosition
WallpaperStyle2GraphicPos( WallpaperStyle eStyle
);
124 static WallpaperStyle
GraphicPos2WallpaperStyle( SvxGraphicPosition ePos
);
125 static sal_Int8
TransparencyToPercent(sal_Int32 nTrans
);
127 void dumpAsXml(struct _xmlTextWriter
* pWriter
) const override
;
130 #endif // INCLUDED_EDITENG_BRUSHITEM_HXX
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */