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 #ifndef INCLUDED_EDITENG_BRUSHITEM_HXX 20 #define INCLUDED_EDITENG_BRUSHITEM_HXX 21 22 #include <tools/color.hxx> 23 #include <svl/poolitem.hxx> 24 #include <unotools/securityoptions.hxx> 25 #include <editeng/editengdllapi.h> 26 #include <memory> 27 28 // class SvxBrushItem ---------------------------------------------------- 29 30 class Graphic; 31 class GraphicObject; 32 33 #define BRUSH_GRAPHIC_VERSION (sal_uInt16(0x0001)) 34 35 enum SvxGraphicPosition 36 { 37 GPOS_NONE, 38 GPOS_LT, GPOS_MT, GPOS_RT, 39 GPOS_LM, GPOS_MM, GPOS_RM, 40 GPOS_LB, GPOS_MB, GPOS_RB, 41 GPOS_AREA, GPOS_TILED 42 }; 43 44 class EDITENG_DLLPUBLIC SvxBrushItem final : public SfxPoolItem 45 { 46 Color aColor; 47 sal_Int32 nShadingValue; 48 mutable std::unique_ptr<GraphicObject> xGraphicObject; 49 sal_Int8 nGraphicTransparency; //contains a percentage value which is 50 //copied to the GraphicObject when necessary 51 SvtSecurityOptions maSecOptions; 52 OUString maStrLink; 53 OUString maStrFilter; 54 SvxGraphicPosition eGraphicPos; 55 mutable bool bLoadAgain; 56 57 void ApplyGraphicTransparency_Impl(); 58 59 public: 60 static SfxPoolItem* CreateDefault(); 61 62 explicit SvxBrushItem( sal_uInt16 nWhich ); 63 SvxBrushItem( const Color& rColor, sal_uInt16 nWhich ); 64 65 SvxBrushItem( const Graphic& rGraphic, 66 SvxGraphicPosition ePos, sal_uInt16 nWhich ); 67 SvxBrushItem( const GraphicObject& rGraphicObj, 68 SvxGraphicPosition ePos, sal_uInt16 nWhich ); 69 SvxBrushItem( const OUString& rLink, const OUString& rFilter, 70 SvxGraphicPosition ePos, sal_uInt16 nWhich ); 71 SvxBrushItem( const SvxBrushItem& ); 72 SvxBrushItem(SvxBrushItem&&); 73 74 virtual ~SvxBrushItem() override; 75 76 public: 77 // check if it's used 78 bool isUsed() const; 79 80 virtual bool GetPresentation( SfxItemPresentation ePres, 81 MapUnit eCoreMetric, 82 MapUnit ePresMetric, 83 OUString &rText, const IntlWrapper& ) const override; 84 85 virtual bool operator==( const SfxPoolItem& ) const override; 86 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; 87 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; 88 89 virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override; 90 GetColor() const91 const Color& GetColor() const { return aColor; } GetColor()92 Color& GetColor() { return aColor; } SetColor(const Color & rCol)93 void SetColor( const Color& rCol) { aColor = rCol; } 94 GetGraphicPos() const95 SvxGraphicPosition GetGraphicPos() const { return eGraphicPos; } 96 GetShadingValue() const97 sal_Int32 GetShadingValue() const { return nShadingValue; } 98 const Graphic* GetGraphic(OUString const & referer = OUString()/*TODO*/) const; 99 const GraphicObject* GetGraphicObject(OUString const & referer = OUString()/*TODO*/) const; GetGraphicLink() const100 const OUString& GetGraphicLink() const { return maStrLink; } GetGraphicFilter() const101 const OUString& GetGraphicFilter() const { return maStrFilter; } 102 103 // get graphic transparency in percent getGraphicTransparency() const104 sal_Int8 getGraphicTransparency() const { return nGraphicTransparency; } 105 void setGraphicTransparency(sal_Int8 nNew); 106 107 void SetGraphicPos( SvxGraphicPosition eNew ); 108 void SetGraphic( const Graphic& rNew ); 109 void SetGraphicObject( const GraphicObject& rNewObj ); 110 void SetGraphicLink( const OUString& rNew ); 111 void SetGraphicFilter( const OUString& rNew ); 112 113 static sal_Int8 TransparencyToPercent(sal_Int32 nTrans); 114 115 void dumpAsXml(xmlTextWriterPtr pWriter) const override; 116 }; 117 118 #endif // INCLUDED_EDITENG_BRUSHITEM_HXX 119 120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 121