LibreOffice Module svx (master) 1
xtabcolr.cxx
Go to the documentation of this file.
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
20#include <memory>
21#include <XPropertyTable.hxx>
24
25#include <svx/strings.hrc>
26#include <svx/dialmgr.hxx>
27#include <svx/xtable.hxx>
28
29using namespace com::sun::star;
30
32{
36 SvtPathOptions().GetPalettePath() :
37 "", ""));
38}
39
41{
43 return aTable;
44}
45
46void XColorList::Replace(tools::Long nIndex, std::unique_ptr<XColorEntry> pEntry)
47{
48 XPropertyList::Replace(std::move(pEntry), nIndex);
49}
51{
52 return static_cast<XColorEntry*>( XPropertyList::Get(nIndex) );
53}
54
55uno::Reference< container::XNameContainer > XColorList::createInstance()
56{
58}
59
61{
62 sal_uInt32 a(0);
63 sal_uInt32 b(0);
64
65 // <!-- Gray palette from white to black -->
66 const OUString aStrGrey( SvxResId( RID_SVXSTR_COLOR_GREY ) );
67
68 Insert( std::make_unique<XColorEntry>( Color( 0xff, 0xff, 0xff ), SvxResId( RID_SVXSTR_COLOR_WHITE ) ) );
69 Insert( std::make_unique<XColorEntry>( Color( 0xee, 0xee, 0xee ), aStrGrey + " 1" ) );
70 Insert( std::make_unique<XColorEntry>( Color( 0xdd, 0xdd, 0xdd ), aStrGrey + " 2" ) );
71 Insert( std::make_unique<XColorEntry>( Color( 0xcc, 0xcc, 0xcc ), aStrGrey + " 3" ) );
72 Insert( std::make_unique<XColorEntry>( Color( 0xb2, 0xb2, 0xb2 ), aStrGrey + " 4" ) );
73 Insert( std::make_unique<XColorEntry>( Color( 0x99, 0x99, 0x99 ), aStrGrey + " 5" ) );
74 Insert( std::make_unique<XColorEntry>( Color( 0x80, 0x80, 0x80 ), aStrGrey + " 6" ) );
75 Insert( std::make_unique<XColorEntry>( Color( 0x66, 0x66, 0x66 ), aStrGrey + " 7" ) );
76 Insert( std::make_unique<XColorEntry>( Color( 0x33, 0x33, 0x33 ), aStrGrey + " 8" ) );
77 Insert( std::make_unique<XColorEntry>( Color( 0x1c, 0x1c, 0x1c ), aStrGrey + " 9" ) );
78 Insert( std::make_unique<XColorEntry>( Color( 0x11, 0x11, 0x11 ), aStrGrey + " 10") );
79 Insert( std::make_unique<XColorEntry>( Color( 0x00, 0x00, 0x00 ), SvxResId( RID_SVXSTR_COLOR_BLACK ) ) );
80
81 // <!-- Base colors step 0 to 10 -->
82 const sal_uInt32 nNumColorsInGroup(12);
83 const sal_uInt32 nNumGroups(11);
84 const OUString aStrCol[nNumColorsInGroup] = {
85 SvxResId(RID_SVXSTR_COLOR_YELLOW),
86 SvxResId(RID_SVXSTR_COLOR_ORANGE),
87 SvxResId(RID_SVXSTR_COLOR_RED),
88 SvxResId(RID_SVXSTR_COLOR_PINK),
89 SvxResId(RID_SVXSTR_COLOR_MAGENTA),
90 SvxResId(RID_SVXSTR_COLOR_PURPLE),
91 SvxResId(RID_SVXSTR_COLOR_BLUE),
92 SvxResId(RID_SVXSTR_COLOR_SKYBLUE),
93 SvxResId(RID_SVXSTR_COLOR_CYAN),
94 SvxResId(RID_SVXSTR_COLOR_TURQUOISE),
95 SvxResId(RID_SVXSTR_COLOR_GREEN),
96 SvxResId(RID_SVXSTR_COLOR_YELLOWGREEN) };
97 static const sal_uInt32 aStdCol[nNumColorsInGroup * nNumGroups] = {
98 0xffff99, 0xff6600, 0xff3333, 0xff00cc, 0xff33ff, 0x9900ff, 0x6666ff, 0x00ccff, 0x66ffff, 0x33ff99, 0x99ff66, 0xccff00,
99 0xffff66, 0xffcc00, 0xff9999, 0xff66cc, 0xff99ff, 0xcc66ff, 0x9999ff, 0x9999ff, 0x99ffff, 0x66ff99, 0x99ff99, 0xccff66,
100 0xffff00, 0xff9900, 0xff6666, 0xff3399, 0xff66ff, 0x9933ff, 0x3333ff, 0x3399ff, 0x00ffff, 0x00ff66, 0x66ff66, 0x99ff33,
101 0xcc9900, 0xff3300, 0xff0000, 0xff0066, 0xff00ff, 0x6600ff, 0x0000ff, 0x0066ff, 0x00cccc, 0x00cc33, 0x00cc00, 0x66ff00,
102 0x996600, 0xcc3300, 0xcc0000, 0xcc0066, 0xcc00cc, 0x6600cc, 0x0000cc, 0x0066cc, 0x009999, 0x009933, 0x009900, 0x66cc00,
103 0x663300, 0x801900, 0x990000, 0x990066, 0x990099, 0x330099, 0x000099, 0x006699, 0x006666, 0x007826, 0x006600, 0x669900,
104 0x333300, 0x461900, 0x330000, 0x330033, 0x660066, 0x000033, 0x000066, 0x000080, 0x003333, 0x00331a, 0x003300, 0x193300,
105 0x666633, 0x661900, 0x663333, 0x660033, 0x663366, 0x330066, 0x333366, 0x003366, 0x336666, 0x006633, 0x336633, 0x336600,
106 0x999966, 0x996633, 0x996666, 0x993366, 0x996699, 0x663399, 0x666699, 0x336699, 0x669999, 0x339966, 0x669966, 0x669933,
107 0xcccc99, 0xcc9966, 0xcc9999, 0xcc6699, 0xcc99cc, 0x9966cc, 0x9999cc, 0x6699cc, 0x99cccc, 0x66cc99, 0x99cc99, 0x99cc66,
108 0xffffcc, 0xffcc99, 0xffcccc, 0xff99cc, 0xffccff, 0xcc99ff, 0xccccff, 0x99ccff, 0xccffff, 0x99ffcc, 0xccffcc, 0xccff99 };
109
110 for(a = 0; a < nNumGroups; a++)
111 {
112 OUString aSuffix;
113 if (a > 0) aSuffix = OUString::number(a);
114
115 const sal_uInt32 nOffset(a * nNumColorsInGroup);
116
117 for(b = 0; b < nNumColorsInGroup; b++)
118 {
119 Insert( std::make_unique<XColorEntry>( Color(ColorTransparency, aStdCol[nOffset + b]), aStrCol[b] + aSuffix ) );
120 }
121 }
122
123 // <!-- use some 'nice' colors from original palette -->
124 Insert( std::make_unique<XColorEntry>( Color( 0xe6, 0xe6, 0xff ), SvxResId( RID_SVXSTR_COLOR_BLUEGREY) ) );
125 Insert( std::make_unique<XColorEntry>( Color( 0xCF, 0xE7, 0xF5 ), SvxResId( RID_SVXSTR_COLOR_BLUE_CLASSIC ) ) );
126
127 // <!-- add 'pale' colors from original palette -->
128 Insert( std::make_unique<XColorEntry>( Color( 0x99, 0x99, 0xff ), SvxResId( RID_SVXSTR_COLOR_VIOLET ) ) );
129 Insert( std::make_unique<XColorEntry>( Color( 0x99, 0x33, 0x66 ), SvxResId( RID_SVXSTR_COLOR_BORDEAUX ) ) );
130 Insert( std::make_unique<XColorEntry>( Color( 0xff, 0xff, 0xcc ), SvxResId( RID_SVXSTR_COLOR_PALE_YELLOW ) ) );
131 Insert( std::make_unique<XColorEntry>( Color( 0xcc, 0xff, 0xff ), SvxResId( RID_SVXSTR_COLOR_PALE_GREEN ) ) );
132 Insert( std::make_unique<XColorEntry>( Color( 0x66, 0x00, 0x66 ), SvxResId( RID_SVXSTR_COLOR_DARKVIOLET ) ) );
133 Insert( std::make_unique<XColorEntry>( Color( 0xff, 0x80, 0x80 ), SvxResId( RID_SVXSTR_COLOR_SALMON ) ) );
134 Insert( std::make_unique<XColorEntry>( Color( 0x00, 0x66, 0xcc ), SvxResId( RID_SVXSTR_COLOR_SEABLUE ) ) );
135
136 // <!-- add Chart colors from original palette (also 12, coincidence?) -->
137 const OUString aStrChart( SvxResId( RID_SVXSTR_COLOR_CHART ) );
138 Insert( std::make_unique<XColorEntry>( Color( 0x00, 0x45, 0x86 ), aStrChart + " 1" ) );
139 Insert( std::make_unique<XColorEntry>( Color( 0xff, 0x42, 0x0e ), aStrChart + " 2" ) );
140 Insert( std::make_unique<XColorEntry>( Color( 0xff, 0xd3, 0x20 ), aStrChart + " 3" ) );
141 Insert( std::make_unique<XColorEntry>( Color( 0x57, 0x9d, 0x1c ), aStrChart + " 4" ) );
142 Insert( std::make_unique<XColorEntry>( Color( 0x7e, 0x00, 0x21 ), aStrChart + " 5" ) );
143 Insert( std::make_unique<XColorEntry>( Color( 0x83, 0xca, 0xff ), aStrChart + " 6" ) );
144 Insert( std::make_unique<XColorEntry>( Color( 0x31, 0x40, 0x04 ), aStrChart + " 7" ) );
145 Insert( std::make_unique<XColorEntry>( Color( 0xae, 0xcf, 0x00 ), aStrChart + " 8" ) );
146 Insert( std::make_unique<XColorEntry>( Color( 0x4b, 0x1f, 0x6f ), aStrChart + " 9" ) );
147 Insert( std::make_unique<XColorEntry>( Color( 0xff, 0x95, 0x0e ), aStrChart + " 10" ) );
148 Insert( std::make_unique<XColorEntry>( Color( 0xc5, 0x00, 0x0b ), aStrChart + " 11" ) );
149 Insert( std::make_unique<XColorEntry>( Color( 0x00, 0x84, 0xd1 ), aStrChart + " 12" ) );
150
151 return(165 == Count());
152}
153
155{
156 return BitmapEx();
157}
158
160{
161 for( tools::Long i = 0, n = maList.size(); i < n; ++i )
162 {
163 const Color aColor = static_cast<XColorEntry*>( maList[i].get() )->GetColor();
164
165 if (aColor == rColor )
166 return i;
167 }
168
169 return -1;
170}
171
172/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
uno::Reference< container::XNameContainer > SvxUnoXColorTable_createInstance(XPropertyList &rList) noexcept
virtual css::uno::Reference< css::container::XNameContainer > createInstance() override
Definition: xtabcolr.cxx:55
virtual bool Create() override
Definition: xtabcolr.cxx:60
static XColorListRef CreateStdColorList()
Definition: xtabcolr.cxx:31
static XColorListRef GetStdColorList()
Definition: xtabcolr.cxx:40
virtual BitmapEx CreateBitmapForUI(tools::Long nIndex) override
Definition: xtabcolr.cxx:154
XColorEntry * GetColor(tools::Long nIndex) const
Definition: xtabcolr.cxx:50
void Replace(tools::Long nIndex, std::unique_ptr< XColorEntry > pEntry)
Definition: xtabcolr.cxx:46
tools::Long GetIndexOfColor(const Color &rColor) const
Definition: xtabcolr.cxx:159
static XPropertyListRef CreatePropertyList(XPropertyListType t, const OUString &rPath, const OUString &rReferer)
Definition: xtable.cxx:316
std::vector< std::unique_ptr< XPropertyEntry > > maList
Definition: xtable.hxx:161
static XColorListRef AsColorList(rtl::Reference< XPropertyList > const &plist)
Definition: xtable.hxx:376
tools::Long Count() const
Definition: xtable.cxx:122
void Insert(std::unique_ptr< XPropertyEntry > pEntry, tools::Long nIndex=std::numeric_limits< tools::Long >::max())
Definition: xtable.cxx:178
void Replace(std::unique_ptr< XPropertyEntry > pEntry, tools::Long nIndex)
Definition: xtable.cxx:193
XPropertyEntry * Get(tools::Long nIndex) const
Definition: xtable.cxx:132
static bool IsFuzzing()
ColorTransparency
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
sal_Int32 nIndex
sal_Int64 n
uno_Any a
int i
long Long