Avoid potential negative array index access to cached text.
[LibreOffice.git] / include / svtools / colorcfg.hxx
blob9e9d5bca7da8c576eff594d60686490cb04d742a
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 <svtools/svtdllapi.h>
22 #include <rtl/ustring.hxx>
23 #include <tools/color.hxx>
24 #include <com/sun/star/uno/Sequence.h>
25 #include <unotools/options.hxx>
26 #include <memory>
29 namespace svtools{
30 enum ColorConfigEntry : int
32 DOCCOLOR ,
33 DOCBOUNDARIES ,
34 APPBACKGROUND ,
35 OBJECTBOUNDARIES ,
36 TABLEBOUNDARIES ,
37 FONTCOLOR ,
38 LINKS ,
39 LINKSVISITED ,
40 SPELL ,
41 GRAMMAR ,
42 SMARTTAGS ,
43 SHADOWCOLOR ,
44 WRITERTEXTGRID ,
45 WRITERFIELDSHADINGS ,
46 WRITERIDXSHADINGS ,
47 WRITERDIRECTCURSOR , // unused
48 WRITERSCRIPTINDICATOR,
49 WRITERSECTIONBOUNDARIES,
50 WRITERHEADERFOOTERMARK,
51 WRITERPAGEBREAKS,
52 HTMLSGML ,
53 HTMLCOMMENT ,
54 HTMLKEYWORD ,
55 HTMLUNKNOWN ,
56 CALCGRID ,
57 CALCPAGEBREAK ,
58 CALCPAGEBREAKMANUAL,
59 CALCPAGEBREAKAUTOMATIC,
60 CALCHIDDENROWCOL ,
61 CALCTEXTOVERFLOW ,
62 CALCCOMMENTS ,
63 CALCDETECTIVE ,
64 CALCDETECTIVEERROR ,
65 CALCREFERENCE ,
66 CALCNOTESBACKGROUND ,
67 CALCVALUE,
68 CALCFORMULA,
69 CALCTEXT,
70 CALCPROTECTEDBACKGROUND,
71 DRAWGRID ,
72 BASICEDITOR,
73 BASICIDENTIFIER,
74 BASICCOMMENT ,
75 BASICNUMBER ,
76 BASICSTRING ,
77 BASICOPERATOR ,
78 BASICKEYWORD ,
79 BASICERROR ,
80 SQLIDENTIFIER,
81 SQLNUMBER,
82 SQLSTRING,
83 SQLOPERATOR,
84 SQLKEYWORD,
85 SQLPARAMETER,
86 SQLCOMMENT,
87 ColorConfigEntryCount
90 class ColorConfig_Impl;
91 struct ColorConfigValue
94 bool bIsVisible; //validity depends on the element type
95 ::Color nColor;
96 ColorConfigValue() : bIsVisible(false), nColor(0) {}
97 bool operator !=(const ColorConfigValue& rCmp) const
98 { return nColor != rCmp.nColor || bIsVisible != rCmp.bIsVisible;}
101 class SAL_WARN_UNUSED SVT_DLLPUBLIC ColorConfig final :
102 public utl::detail::Options
104 friend class ColorConfig_Impl;
105 private:
106 static ColorConfig_Impl* m_pImpl;
107 public:
108 ColorConfig();
109 virtual ~ColorConfig() override;
111 // get the configured value - if bSmart is set the default color setting is provided
112 // instead of the automatic color
113 ColorConfigValue GetColorValue(ColorConfigEntry eEntry, bool bSmart = true) const;
114 static Color GetDefaultColor(ColorConfigEntry eEntry);
115 static const OUString& GetCurrentSchemeName();
118 class SVT_DLLPUBLIC EditableColorConfig
120 std::unique_ptr<ColorConfig_Impl> m_pImpl;
121 bool m_bModified;
122 public:
123 EditableColorConfig();
124 ~EditableColorConfig();
126 css::uno::Sequence< OUString > GetSchemeNames() const;
127 void DeleteScheme(const OUString& rScheme );
128 void AddScheme(const OUString& rScheme );
129 void LoadScheme(const OUString& rScheme );
130 const OUString& GetCurrentSchemeName() const;
131 void SetCurrentSchemeName(const OUString& rScheme);
133 const ColorConfigValue& GetColorValue(ColorConfigEntry eEntry) const;
134 void SetColorValue(ColorConfigEntry eEntry, const ColorConfigValue& rValue);
135 void SetModified();
136 void ClearModified() {m_bModified = false;}
137 bool IsModified() const {return m_bModified;}
138 void Commit();
140 void DisableBroadcast();
141 void EnableBroadcast();
143 }//namespace svtools
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */