Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / editeng / brushitem.hxx
blob617aa43a4f2497b6136cb4da753325b06f47ccd9
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 #pragma once
21 #include <tools/color.hxx>
22 #include <svl/poolitem.hxx>
23 #include <editeng/editengdllapi.h>
24 #include <memory>
25 #include <docmodel/color/ComplexColor.hxx>
27 class Graphic;
28 class GraphicObject;
30 constexpr sal_uInt16 BRUSH_GRAPHIC_VERSION = 0x0001;
32 enum SvxGraphicPosition
34 GPOS_NONE,
35 GPOS_LT, GPOS_MT, GPOS_RT,
36 GPOS_LM, GPOS_MM, GPOS_RM,
37 GPOS_LB, GPOS_MB, GPOS_RB,
38 GPOS_AREA, GPOS_TILED
41 class EDITENG_DLLPUBLIC SvxBrushItem final : public SfxPoolItem
43 Color aColor;
44 model::ComplexColor maComplexColor;
45 Color aFilterColor;
46 sal_Int32 nShadingValue;
47 mutable std::unique_ptr<GraphicObject> xGraphicObject;
48 sal_Int8 nGraphicTransparency; //contains a percentage value which is
49 //copied to the GraphicObject when necessary
50 OUString maStrLink;
51 OUString maStrFilter;
52 SvxGraphicPosition eGraphicPos;
53 mutable bool bLoadAgain;
55 void ApplyGraphicTransparency_Impl();
57 public:
58 static SfxPoolItem* CreateDefault();
60 explicit SvxBrushItem( sal_uInt16 nWhich );
61 SvxBrushItem(Color const& rColor, sal_uInt16 nWhich);
62 SvxBrushItem(Color const& rColor, model::ComplexColor const& rComplexColor, sal_uInt16 nWhich);
64 SvxBrushItem( const Graphic& rGraphic,
65 SvxGraphicPosition ePos, sal_uInt16 nWhich );
66 SvxBrushItem( const GraphicObject& rGraphicObj,
67 SvxGraphicPosition ePos, sal_uInt16 nWhich );
68 SvxBrushItem( OUString rLink, OUString aFilter,
69 SvxGraphicPosition ePos, sal_uInt16 nWhich );
70 SvxBrushItem( const SvxBrushItem& );
71 SvxBrushItem(SvxBrushItem&&);
73 virtual ~SvxBrushItem() override;
75 public:
76 // check if it's used
77 bool isUsed() const;
79 virtual bool GetPresentation( SfxItemPresentation ePres,
80 MapUnit eCoreMetric,
81 MapUnit ePresMetric,
82 OUString &rText, const IntlWrapper& ) const override;
84 virtual bool operator==( const SfxPoolItem& ) const override;
85 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
86 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
88 virtual SvxBrushItem* Clone( SfxItemPool *pPool = nullptr ) const override;
90 const Color& GetColor() const { return aColor; }
91 Color& GetColor() { return aColor; }
92 void SetColor( const Color& rCol) { aColor = rCol; }
94 model::ComplexColor getComplexColor() const
96 auto pUnConst = const_cast<SvxBrushItem*>(this);
97 pUnConst->maComplexColor.setFinalColor(GetColor());
98 return maComplexColor;
101 void setComplexColor(model::ComplexColor const& rComplexColor)
103 maComplexColor = rComplexColor;
106 const Color& GetFiltColor() const { return aFilterColor; }
107 void SetFiltColor( const Color& rCol) { aFilterColor = rCol; }
109 SvxGraphicPosition GetGraphicPos() const { return eGraphicPos; }
111 sal_Int32 GetShadingValue() const { return nShadingValue; }
112 const Graphic* GetGraphic(OUString const & referer = OUString()/*TODO*/) const;
113 const GraphicObject* GetGraphicObject(OUString const & referer = OUString()/*TODO*/) const;
114 const OUString& GetGraphicLink() const { return maStrLink; }
115 const OUString& GetGraphicFilter() const { return maStrFilter; }
117 // get graphic transparency in percent
118 sal_Int8 getGraphicTransparency() const { return nGraphicTransparency; }
119 void setGraphicTransparency(sal_Int8 nNew);
121 void SetGraphicPos( SvxGraphicPosition eNew );
122 void SetGraphic( const Graphic& rNew );
123 void SetGraphicObject( const GraphicObject& rNewObj );
124 void SetGraphicLink( const OUString& rNew );
125 void SetGraphicFilter( const OUString& rNew );
127 static sal_Int8 TransparencyToPercent(sal_Int32 nTrans);
129 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */