Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / editeng / brushitem.hxx
blob350b4d6cd97770dae9e01fa0ef4d8232fe078d36
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
27 #include <memory>
29 // class SvxBrushItem ----------------------------------------------------
31 class Graphic;
32 class GraphicObject;
33 class CntWallpaperItem;
35 #define BRUSH_GRAPHIC_VERSION ((sal_uInt16)0x0001)
37 enum SvxGraphicPosition
39 GPOS_NONE,
40 GPOS_LT, GPOS_MT, GPOS_RT,
41 GPOS_LM, GPOS_MM, GPOS_RM,
42 GPOS_LB, GPOS_MB, GPOS_RB,
43 GPOS_AREA, GPOS_TILED
46 class EDITENG_DLLPUBLIC SvxBrushItem : public SfxPoolItem
48 Color aColor;
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;
54 OUString maStrLink;
55 OUString maStrFilter;
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 );
64 public:
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;
82 public:
84 virtual bool GetPresentation( SfxItemPresentation ePres,
85 MapUnit eCoreMetric,
86 MapUnit ePresMetric,
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: */