diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2024-01-15 09:49:18 +0100 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2024-01-29 08:38:29 +0100 |
commit | 22e656741725ab366aeed21cef92136808ac32cb (patch) | |
tree | 3af9250b1b9dee21d9db6905fc4a8296e047b855 /include | |
parent | 031f11bd9096fb192ced1328f9bbcd1b1903e3e7 (diff) |
Use correct type when getting document colors
After commit 0460be8848b0ce02c07183e41dd7137ac3b94164
Send document colors with lok callback
There was issue detected by CI:
/sc/source/core/data/document10.cxx:198:46: runtime error: downcast of address 0x6100000efa40 which does not point to an object of type 'const SvxColorItem'
0x6100000efa40: note: object is of type 'SvxBrushItem'
00 00 00 00 b0 79 19 48 ce 7f 00 00 01 00 00 00 94 00 be be 4c 17 00 00 a0 be be be cc cc ff 00
^~~~~~~~~~~~~~~~~~~~~~~
vptr for 'SvxBrushItem'
#0 0x7fce1fbed369 in ScDocument::GetDocColors() /sc/source/core/data/document10.cxx:198:46
Change-Id: I41f28b6bb54d7720d58c16d75b9d116a53f106cc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162076
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/svx/DocumentColorHelper.hxx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/include/svx/DocumentColorHelper.hxx b/include/svx/DocumentColorHelper.hxx new file mode 100644 index 000000000000..71eccde99582 --- /dev/null +++ b/include/svx/DocumentColorHelper.hxx @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#pragma once + +#include <editeng/brushitem.hxx> +#include <editeng/colritem.hxx> +#include <set> +#include <svl/itempool.hxx> + +namespace svx +{ +namespace DocumentColorHelper +{ +static inline Color getColorFromItem(const SvxColorItem* pItem) { return pItem->GetValue(); } + +static inline Color getColorFromItem(const SvxBrushItem* pItem) { return pItem->GetColor(); } + +template <class T> +void queryColors(const sal_uInt16 nAttrib, const SfxItemPool* pPool, std::set<Color>& rOutput) +{ + for (const SfxPoolItem* pItem : pPool->GetItemSurrogates(nAttrib)) + { + auto pColorItem = static_cast<const T*>(pItem); + Color aColor(getColorFromItem(pColorItem)); + if (COL_AUTO != aColor) + rOutput.insert(aColor); + } +} +} + +} // end of namespace svx + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |