26#include <com/sun/star/uno/Any.hxx>
27#include <com/sun/star/uno/Sequence.hxx>
28#include <com/sun/star/beans/PropertyValue.hpp>
31#include <com/sun/star/uno/Sequence.h>
36#include <osl/diagnose.h>
54 std::mutex& ColorMutex_Impl()
56 static std::mutex SINGLETON;
67 typedef ::std::vector<TConfigValues::iterator>
TMapPos;
88 void Load(
const OUString& rScheme);
93 virtual void Notify(
const uno::Sequence<OUString>& aPropertyNames)
override;
106 TConfigValues::iterator aFind2 = aFind->second.first.find(_sName);
107 if ( aFind2 != aFind->second.first.end() )
108 return aFind2->second;
110#if OSL_DEBUG_LEVEL > 0
111 SAL_WARN(
"svtools",
"Could find the required config:\n"
112 "component: " << _sComponentName
113 <<
"\nname: " << _sName );
122 using ConfigItem::SetModified;
123 using ConfigItem::ClearModified;
138 for(OUString &
i : asNonConstRange(aNames))
140 i = rScheme +
"/" +
i;
156 nSize = aFind->second.first.size();
166 if ( _nPos < aFind->second.second.size() )
168 return aFind->second.second[
_nPos]->second;
179 sRet = aFind->second;
195 m_bIsBroadcastEnabled(true)
198 uno::Sequence < OUString > aNames(1);
223static void lcl_addString(uno::Sequence < OUString >& _rSeq,std::u16string_view _sAdd)
225 for(OUString &
i : asNonConstRange(_rSeq))
237 uno::Sequence < OUString > aComponentNames =
GetPropertyNames(
"EntryNames");
239 for(OUString & componentName : asNonConstRange(aComponentNames))
242 OUString sComponentDisplayName;
243 if ( aComponentDisplayNamesValue.hasElements() && (aComponentDisplayNamesValue[0] >>= sComponentDisplayName) )
248 componentName +=
"/Entries";
252 uno::Sequence< uno::Any > aDisplayNamesValue =
GetProperties( aDisplayNames );
254 const OUString* pDispIter = aDisplayNames.getConstArray();
255 const OUString* pDispEnd = pDispIter + aDisplayNames.getLength();
256 for(sal_Int32 j = 0;pDispIter != pDispEnd;++pDispIter,++j)
260 std::u16string_view
sName = pDispIter->subView(
nIndex);
262 OUString sCurrentDisplayName;
263 aDisplayNamesValue[j] >>= sCurrentDisplayName;
264 aDisplayNameMap.emplace(OUString(
sName),sCurrentDisplayName);
269 OUString sScheme(rScheme);
271 if(sScheme.isEmpty())
274 uno::Sequence < OUString > aCurrent {
"ExtendedColorScheme/CurrentColorScheme" };
275 uno::Sequence< uno::Any > aCurrentVal =
GetProperties( aCurrent );
276 aCurrentVal.getConstArray()[0] >>= sScheme;
280 OUString sBase =
"ExtendedColorScheme/ColorSchemes/"
293 if ( sScheme !=
"default" )
297 aComponentNames =
GetPropertyNames(
"ExtendedColorScheme/ColorSchemes/default");
301 if ( !bFound && !sScheme.isEmpty() )
310 static constexpr OUStringLiteral sColorEntries(
u"/Entries");
311 for(OUString
const & component : _rComponents)
313 OUString sComponentName = component.copy(component.lastIndexOf(
'/')+1);
316 OUString sEntry = component + sColorEntries;
319 uno::Sequence < OUString > aDefaultColorNames = aColorNames;
321 static constexpr OUStringLiteral
sColor(
u"/Color");
324 uno::Sequence< uno::Any > aColors =
GetProperties( aColorNames );
325 const uno::Any* pColors = aColors.getConstArray();
327 uno::Sequence< uno::Any > aDefaultColors =
GetProperties( aDefaultColorNames );
328 bool bDefaultColorFound = aDefaultColors.hasElements();
329 const uno::Any* pDefaultColors = aDefaultColors.getConstArray();
331 OUString* pColorIter = aColorNames.getArray();
332 OUString* pColorEnd = pColorIter + aColorNames.getLength();
337 for(
int i = 0; pColorIter != pColorEnd; ++pColorIter ,++
i)
339 if ( aConfigValues.find(*pColorIter) == aConfigValues.end() )
346 TDisplayNames::const_iterator aFind = _rDisplayNames.find(sTemp);
348 OSL_ENSURE(aFind != _rDisplayNames.end(),
"DisplayName is not in EntryNames config list!");
349 if ( aFind != _rDisplayNames.end() )
352 OSL_ENSURE(pColors[
i].hasValue(),
"Color config entry has NIL as color value set!");
353 OSL_ENSURE(pDefaultColors[
i].hasValue(),
"Color config entry has NIL as color value set!");
354 Color nColor, nDefaultColor;
355 pColors[
i] >>= nColor;
356 if ( bDefaultColorFound )
357 pDefaultColors[
i] >>= nDefaultColor;
359 nDefaultColor = nColor;
361 aConfigValuesPos.push_back(aConfigValues.emplace(
sName,aValue).first);
387 static constexpr OUStringLiteral sColorEntries(
u"Entries");
388 static constexpr OUStringLiteral
sColor(
u"/Color");
389 OUString sBase =
"ExtendedColorScheme/ColorSchemes/"
391 static constexpr OUStringLiteral s_sSep(
u"/");
395 if ( ConfigItem::AddNode(sBase, configValue.first) )
397 OUString sNode = sBase
404 uno::Sequence < beans::PropertyValue > aPropValues(configValue.second.first.size());
405 beans::PropertyValue* pPropValues = aPropValues.getArray();
406 for (
auto const& elem : configValue.second.first)
408 pPropValues->Name = sNode + s_sSep + elem.first;
409 ConfigItem::AddNode(sNode, elem.first);
410 pPropValues->Name +=
sColor;
411 pPropValues->Value <<= elem.second.getColor();
425 uno::Sequence < OUString > aCurrent {
"ExtendedColorScheme/CurrentColorScheme" };
426 uno::Sequence< uno::Any > aCurrentVal(1);
433 OUString sBase(
"ExtendedColorScheme/ColorSchemes");
436 sBase += OUString::Concat(
"/") + _sSchemeName;
445 TConfigValues::iterator aFind2 = aFind->second.first.find(rValue.
getName());
446 if ( aFind2 != aFind->second.first.end() )
447 aFind2->second = rValue;
454 if(ConfigItem::AddNode(
"ExtendedColorScheme/ColorSchemes", rScheme))
463 uno::Sequence< OUString > aElements { rScheme };
498 if ( rEvent.GetId() == VclEventId::ApplicationDataChanged )
501 if ( (
pData->GetType() == DataChangedEventType::SETTINGS) &&
502 (
pData->GetFlags() & AllSettingsFlags::STYLE) )
512 std::unique_lock aGuard( ColorMutex_Impl() );
521 std::unique_lock aGuard( ColorMutex_Impl() );
585 m_pImpl->RemoveScheme(rScheme);
602 m_pImpl->CommitCurrentSchemeName();
608 m_pImpl->SetCurrentSchemeName(rScheme);
609 m_pImpl->CommitCurrentSchemeName();
615 m_pImpl->SetColorConfigValue(_sName, rValue);
646 return m_pImpl->GetComponentCount();
651 return m_pImpl->GetComponentColorCount(_sName);
656 return m_pImpl->GetComponentColorConfigValue(_sName,
_nPos);
static void AddEventListener(const Link< VclSimpleEvent &, void > &rEventListener)
static void RemoveEventListener(const Link< VclSimpleEvent &, void > &rEventListener)
void Broadcast(const SfxHint &rHint)
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
static bool PutProperties(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const css::uno::Sequence< OUString > &rNames, const css::uno::Sequence< css::uno::Any > &rValues, bool bAllLocales)
static bool SetSetProperties(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const OUString &rNode, const css::uno::Sequence< css::beans::PropertyValue > &rValues)
bool EnableNotification(const css::uno::Sequence< OUString > &rNames, bool bEnableInternalNotification=false)
static css::uno::Sequence< css::uno::Any > GetProperties(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const css::uno::Sequence< OUString > &rNames, bool bAllLocales)
bool ClearNodeElements(const OUString &rNode, css::uno::Sequence< OUString > const &rElements)
static css::uno::Sequence< OUString > GetNodeNames(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const OUString &rNode, ConfigNameFormat eFormat)
constexpr OUStringLiteral sColor
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
std::unique_ptr< sal_Int32[]> pData
sal_Int32 findValue(const css::uno::Sequence< T1 > &_rList, const T2 &_rValue)
constexpr OUStringLiteral first
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)