/* -*- 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <memory>
#include <XPropertyTable.hxx>
#include <comphelper/configuration.hxx>
#include <unotools/pathoptions.hxx>
#include <svx/strings.hrc>
#include <svx/dialmgr.hxx>
#include <svx/xtable.hxx>
using namespace com::sun::star;
XColorListRef XColorList::CreateStdColorList()
{
return XPropertyList::AsColorList(
XPropertyList::CreatePropertyList(
XPropertyListType::Color, !comphelper::IsFuzzing() ?
SvtPathOptions().GetPalettePath() :
u
"" _ustr, u
"" _ustr));
}
XColorListRef XColorList::GetStdColorList()
{
XColorListRef aTable( CreateStdColorList() );
return aTable;
}
void XColorList::Replace(tools::
Long nIndex, std::unique_ptr<XColorEntry> pEntry)
{
XPropertyList::Replace(std::move(pEntry), nIndex);
}
XColorEntry* XColorList::GetColor(tools::
Long nIndex)
const
{
return static_cast <XColorEntry*>( XPropertyList::Get(nIndex) );
}
uno::Reference< container::XNameContainer > XColorList::createInstance()
{
return SvxUnoXColorTable_createInstance( *
this );
}
bool XColorList::Create()
{
sal_uInt32 a(
0 );
sal_uInt32 b(
0 );
// <!-- Gray palette from white to black -->
const OUString aStrGrey( SvxResId( RID_SVXSTR_COLOR_GREY ) );
Insert( std::make_unique<XColorEntry>( Color(
0 xff,
0 xff,
0 xff ), SvxResId( RID_SVXSTR_COL
OR_WHITE ) ) );
Insert( std::make_unique<XColorEntry>( Color( 0 xee, 0 xee, 0 xee ), aStrGrey + " 1" ) );
Insert( std::make_unique<XColorEntry>( Color( 0 xdd, 0 xdd, 0 xdd ), aStrGrey + " 2" ) );
Insert( std::make_unique<XColorEntry>( Color( 0 xcc, 0 xcc, 0 xcc ), aStrGrey + " 3" ) );
Insert( std::make_unique<XColorEntry>( Color( 0 xb2, 0 xb2, 0 xb2 ), aStrGrey + " 4" ) );
Insert( std::make_unique<XColorEntry>( Color( 0 x99, 0 x99, 0 x99 ), aStrGrey + " 5" ) );
Insert( std::make_unique<XColorEntry>( Color( 0 x80, 0 x80, 0 x80 ), aStrGrey + " 6" ) );
Insert( std::make_unique<XColorEntry>( Color( 0 x66, 0 x66, 0 x66 ), aStrGrey + " 7" ) );
Insert( std::make_unique<XColorEntry>( Color( 0 x33, 0 x33, 0 x33 ), aStrGrey + " 8" ) );
Insert( std::make_unique<XColorEntry>( Color( 0 x1c, 0 x1c, 0 x1c ), aStrGrey + " 9" ) );
Insert( std::make_unique<XColorEntry>( Color( 0 x11, 0 x11, 0 x11 ), aStrGrey + " 10" ) );
Insert( std::make_unique<XColorEntry>( Color( 0 x00, 0 x00, 0 x00 ), SvxResId( RID_SVXSTR_COLOR_BLACK ) ) );
// <!-- Base colors step 0 to 10 -->
const sal_uInt32 nNumColorsInGroup(12 );
const sal_uInt32 nNumGroups(11 );
const OUString aStrCol[nNumColorsInGroup] = {
SvxResId(RID_SVXSTR_COLOR_YELLOW),
SvxResId(RID_SVXSTR_COLOR_ORANGE),
SvxResId(RID_SVXSTR_COLOR_RED),
SvxResId(RID_SVXSTR_COLOR_PINK),
SvxResId(RID_SVXSTR_COLOR_MAGENTA),
SvxResId(RID_SVXSTR_COLOR_PURPLE),
SvxResId(RID_SVXSTR_COLOR_BLUE),
SvxResId(RID_SVXSTR_COLOR_SKYBLUE),
SvxResId(RID_SVXSTR_COLOR_CYAN),
SvxResId(RID_SVXSTR_COLOR_TURQUOISE),
SvxResId(RID_SVXSTR_COLOR_GREEN),
SvxResId(RID_SVXSTR_COLOR_YELLOWGREEN) };
static const sal_uInt32 aStdCol[nNumColorsInGroup * nNumGroups] = {
0 xffff99, 0 xff6600, 0 xff3333, 0 xff00cc, 0 xff33ff, 0 x9900ff, 0 x6666ff, 0 x00ccff, 0 x66ffff, 0 x33ff99, 0 x99ff66, 0 xccff00,
0 xffff66, 0 xffcc00, 0 xff9999, 0 xff66cc, 0 xff99ff, 0 xcc66ff, 0 x9999ff, 0 x9999ff, 0 x99ffff, 0 x66ff99, 0 x99ff99, 0 xccff66,
0 xffff00, 0 xff9900, 0 xff6666, 0 xff3399, 0 xff66ff, 0 x9933ff, 0 x3333ff, 0 x3399ff, 0 x00ffff, 0 x00ff66, 0 x66ff66, 0 x99ff33,
0 xcc9900, 0 xff3300, 0 xff0000, 0 xff0066, 0 xff00ff, 0 x6600ff, 0 x0000ff, 0 x0066ff, 0 x00cccc, 0 x00cc33, 0 x00cc00, 0 x66ff00,
0 x996600, 0 xcc3300, 0 xcc0000, 0 xcc0066, 0 xcc00cc, 0 x6600cc, 0 x0000cc, 0 x0066cc, 0 x009999, 0 x009933, 0 x009900, 0 x66cc00,
0 x663300, 0 x801900, 0 x990000, 0 x990066, 0 x990099, 0 x330099, 0 x000099, 0 x006699, 0 x006666, 0 x007826, 0 x006600, 0 x669900,
0 x333300, 0 x461900, 0 x330000, 0 x330033, 0 x660066, 0 x000033, 0 x000066, 0 x000080, 0 x003333, 0 x00331a, 0 x003300, 0 x193300,
0 x666633, 0 x661900, 0 x663333, 0 x660033, 0 x663366, 0 x330066, 0 x333366, 0 x003366, 0 x336666, 0 x006633, 0 x336633, 0 x336600,
0 x999966, 0 x996633, 0 x996666, 0 x993366, 0 x996699, 0 x663399, 0 x666699, 0 x336699, 0 x669999, 0 x339966, 0 x669966, 0 x669933,
0 xcccc99, 0 xcc9966, 0 xcc9999, 0 xcc6699, 0 xcc99cc, 0 x9966cc, 0 x9999cc, 0 x6699cc, 0 x99cccc, 0 x66cc99, 0 x99cc99, 0 x99cc66,
0 xffffcc, 0 xffcc99, 0 xffcccc, 0 xff99cc, 0 xffccff, 0 xcc99ff, 0 xccccff, 0 x99ccff, 0 xccffff, 0 x99ffcc, 0 xccffcc, 0 xccff99 };
for (a = 0 ; a < nNumGroups; a++)
{
OUString aSuffix;
if (a > 0 ) aSuffix = OUString::number(a);
const sal_uInt32 nOffset(a * nNumColorsInGroup);
for (b = 0 ; b < nNumColorsInGroup; b++)
{
Insert( std::make_unique<XColorEntry>( Color(ColorTransparency, aStdCol[nOffset + b]), aStrCol[b] + aSuffix ) );
}
}
// <!-- use some 'nice' colors from original palette -->
Insert( std::make_unique<XColorEntry>( Color( 0 xe6, 0 xe6, 0 xff ), SvxResId( RID_SVXSTR_COLOR_BLUEGREY) ) );
Insert( std::make_unique<XColorEntry>( Color( 0 xCF, 0 xE7, 0 xF5 ), SvxResId( RID_SVXSTR_COLOR_BLUE_CLASSIC ) ) );
// <!-- add 'pale' colors from original palette -->
Insert( std::make_unique<XColorEntry>( Color( 0 x99, 0 x99, 0 xff ), SvxResId( RID_SVXSTR_COLOR_VIOLET ) ) );
Insert( std::make_unique<XColorEntry>( Color( 0 x99, 0 x33, 0 x66 ), SvxResId( RID_SVXSTR_COLOR_BORDEAUX ) ) );
Insert( std::make_unique<XColorEntry>( Color( 0 xff, 0 xff, 0 xcc ), SvxResId( RID_SVXSTR_COLOR_PALE_YELLOW ) ) );
Insert( std::make_unique<XColorEntry>( Color( 0 xcc, 0 xff, 0 xff ), SvxResId( RID_SVXSTR_COLOR_PALE_GREEN ) ) );
Insert( std::make_unique<XColorEntry>( Color( 0 x66, 0 x00, 0 x66 ), SvxResId( RID_SVXSTR_COLOR_DARKVIOLET ) ) );
Insert( std::make_unique<XColorEntry>( Color( 0 xff, 0 x80, 0 x80 ), SvxResId( RID_SVXSTR_COLOR_SALMON ) ) );
Insert( std::make_unique<XColorEntry>( Color( 0 x00, 0 x66, 0 xcc ), SvxResId( RID_SVXSTR_COLOR_SEABLUE ) ) );
// <!-- add Chart colors from original palette (also 12, coincidence?) -->
const OUString aStrChart( SvxResId( RID_SVXSTR_COLOR_CHART ) );
Insert( std::make_unique<XColorEntry>( Color( 0 x00, 0 x45, 0 x86 ), aStrChart + " 1" ) );
Insert( std::make_unique<XColorEntry>( Color( 0 xff, 0 x42, 0 x0e ), aStrChart + " 2" ) );
Insert( std::make_unique<XColorEntry>( Color( 0 xff, 0 xd3, 0 x20 ), aStrChart + " 3" ) );
Insert( std::make_unique<XColorEntry>( Color( 0 x57, 0 x9d, 0 x1c ), aStrChart + " 4" ) );
Insert( std::make_unique<XColorEntry>( Color( 0 x7e, 0 x00, 0 x21 ), aStrChart + " 5" ) );
Insert( std::make_unique<XColorEntry>( Color( 0 x83, 0 xca, 0 xff ), aStrChart + " 6" ) );
Insert( std::make_unique<XColorEntry>( Color( 0 x31, 0 x40, 0 x04 ), aStrChart + " 7" ) );
Insert( std::make_unique<XColorEntry>( Color( 0 xae, 0 xcf, 0 x00 ), aStrChart + " 8" ) );
Insert( std::make_unique<XColorEntry>( Color( 0 x4b, 0 x1f, 0 x6f ), aStrChart + " 9" ) );
Insert( std::make_unique<XColorEntry>( Color( 0 xff, 0 x95, 0 x0e ), aStrChart + " 10" ) );
Insert( std::make_unique<XColorEntry>( Color( 0 xc5, 0 x00, 0 x0b ), aStrChart + " 11" ) );
Insert( std::make_unique<XColorEntry>( Color( 0 x00, 0 x84, 0 xd1 ), aStrChart + " 12" ) );
return (165 == Count());
}
BitmapEx XColorList::CreateBitmapForUI( tools::Long /*nIndex*/ )
{
return BitmapEx();
}
tools::Long XColorList::GetIndexOfColor( const Color& rColor ) const
{
for ( tools::Long i = 0 , n = maList.size(); i < n; ++i )
{
const Color aColor = static_cast <XColorEntry*>( maList[i].get() )->GetColor();
if (aColor == rColor )
return i;
}
return -1 ;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Messung V0.5 in Prozent C=93 H=94 G=93
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-06-05)
¤
*© Formatika GbR, Deutschland