cid#1640468 Dereference after null check
[LibreOffice.git] / include / svtools / extcolorcfg.hxx
blob1b1f4a9d0b08be760603a4cda7f9f333e3157509
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 <config_options.h>
22 #include <svtools/svtdllapi.h>
23 #include <rtl/ustring.hxx>
24 #include <svl/SfxBroadcaster.hxx>
25 #include <svl/lstner.hxx>
26 #include <tools/color.hxx>
27 #include <memory>
28 #include <utility>
31 namespace svtools {
33 class ExtendedColorConfig_Impl;
35 class ExtendedColorConfigValue
37 OUString m_sName;
38 OUString m_sDisplayName;
39 Color m_nColor;
40 Color m_nDefaultColor;
41 public:
42 ExtendedColorConfigValue() : m_nColor(0),m_nDefaultColor(0){}
43 ExtendedColorConfigValue(OUString _sName
44 ,OUString _sDisplayName
45 ,Color _nColor
46 ,Color _nDefaultColor)
47 : m_sName(std::move(_sName))
48 ,m_sDisplayName(std::move(_sDisplayName))
49 ,m_nColor(_nColor)
50 ,m_nDefaultColor(_nDefaultColor)
53 const OUString& getName() const { return m_sName; }
54 const OUString& getDisplayName() const { return m_sDisplayName; }
55 Color getColor() const { return m_nColor; }
56 Color getDefaultColor() const { return m_nDefaultColor; }
58 void setColor(Color _nColor) { m_nColor = _nColor; }
61 class UNLESS_MERGELIBS_MORE(SVT_DLLPUBLIC) ExtendedColorConfig final : public SfxBroadcaster, public SfxListener
63 friend class ExtendedColorConfig_Impl;
64 private:
65 static ExtendedColorConfig_Impl* m_pImpl;
66 public:
67 ExtendedColorConfig();
68 virtual ~ExtendedColorConfig() override;
70 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
72 // get the configured value
73 ExtendedColorConfigValue GetColorValue(const OUString& _sComponentName,const OUString& _sName)const;
74 sal_Int32 GetComponentCount() const;
75 OUString GetComponentName(sal_uInt32 _nPos) const;
76 OUString GetComponentDisplayName(const OUString& _sComponentName) const;
77 sal_Int32 GetComponentColorCount(const OUString& _sName) const;
78 ExtendedColorConfigValue GetComponentColorConfigValue(const OUString& _sComponentName,sal_uInt32 _nPos) const;
81 class SVT_DLLPUBLIC EditableExtendedColorConfig
83 std::unique_ptr<ExtendedColorConfig_Impl> m_pImpl;
84 bool m_bModified;
85 public:
86 EditableExtendedColorConfig();
87 ~EditableExtendedColorConfig();
89 void DeleteScheme(const OUString& rScheme );
90 void AddScheme(const OUString& rScheme );
91 void LoadScheme(const OUString& rScheme );
92 void SetCurrentSchemeName(const OUString& rScheme);
94 sal_Int32 GetComponentCount() const;
95 OUString GetComponentName(sal_uInt32 _nPos) const;
96 sal_Int32 GetComponentColorCount(const OUString& _sName) const;
97 ExtendedColorConfigValue GetComponentColorConfigValue(const OUString& _sName,sal_uInt32 _nPos) const;
98 void SetColorValue(const OUString& _sComponentName, const ExtendedColorConfigValue& rValue);
99 void SetModified();
100 void ClearModified() {m_bModified = false;}
101 bool IsModified() const {return m_bModified;}
102 void Commit();
104 void DisableBroadcast();
105 void EnableBroadcast();
107 }//namespace svtools
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */