25#include <osl/file.hxx>
29#include <svx/strings.hrc>
30#include <svx/svxids.hrc>
37#include <officecfg/Office/Common.hxx>
38#include <com/sun/star/frame/XDispatchProvider.hpp>
39#include <com/sun/star/frame/XDispatch.hpp>
40#include <com/sun/star/frame/Desktop.hpp>
41#include <com/sun/star/util/XURLTransformer.hpp>
42#include <com/sun/star/util/URLTransformer.hpp>
56 mnMaxRecentColors(
Application::GetSettings().GetStyleSettings().GetColorValueSetColumnCount()),
60 mpBtnUpdater(nullptr),
68 if(
nullptr != ( pItem = pDocSh->
GetItem(SID_COLOR_TABLE) ) )
79 : mnMaxRecentColors(pClone->mnMaxRecentColors)
80 , mnNumOfPalettes(pClone->mnNumOfPalettes)
81 , mnCurrentPalette(pClone->mnCurrentPalette)
82 , mnColorCount(pClone->mnColorCount)
83 , mpBtnUpdater(nullptr)
84 , pColorList(pClone->pColorList)
85 , maRecentColors(pClone->maRecentColors)
106 std::stack<OUString> aDirs;
110 aDirs.push(aPalPaths.getToken(0,
';',
nIndex));
114 std::set<OUString> aNames;
117 while (!aDirs.empty())
119 OUString aPalPath = aDirs.top();
122 osl::Directory aDir(aPalPath);
123 osl::DirectoryItem aDirItem;
124 osl::FileStatus aFileStat( osl_FileStatus_Mask_FileName |
125 osl_FileStatus_Mask_FileURL |
126 osl_FileStatus_Mask_Type );
127 if( aDir.open() == osl::FileBase::E_None )
129 while( aDir.getNextItem(aDirItem) == osl::FileBase::E_None )
131 aDirItem.getFileStatus(aFileStat);
132 if(aFileStat.isRegular() || aFileStat.isLink())
134 OUString aFName = aFileStat.getFileName();
136 OUString aFNameWithoutExt = aURLObj.
GetBase();
137 if (aNames.find(aFName) == aNames.end())
139 std::unique_ptr<Palette> pPalette;
140 if( aFName.endsWithIgnoreAsciiCase(
".gpl") )
141 pPalette.reset(
new PaletteGPL(aFileStat.getFileURL(), aFNameWithoutExt));
142 else if( aFName.endsWithIgnoreAsciiCase(
".soc") )
143 pPalette.reset(
new PaletteSOC(aFileStat.getFileURL(), aFNameWithoutExt));
144 else if ( aFName.endsWithIgnoreAsciiCase(
".ase") )
145 pPalette.reset(
new PaletteASE(aFileStat.getFileURL(), aFNameWithoutExt));
147 if( pPalette && pPalette->IsValid() )
149 aNames.insert(aFNameWithoutExt);
165 rThemeIndex = nItemId % 12;
167 rEffectIndex = nItemId / 12;
168 if (rEffectIndex > 5)
180 rLumMod = aThemeColorData.getLumMod(nEffect);
181 rLumOff = aThemeColorData.getLumOff(nEffect);
192 css::uno::Sequence< sal_Int32 > CustomColorList( officecfg::Office::Common::UserColors::CustomColor::get() );
193 css::uno::Sequence< OUString > CustomColorNameList( officecfg::Office::Common::UserColors::CustomColorName::get() );
195 for (
int i = 0;
i < CustomColorList.getLength(); ++
i)
198 rColorSet.
InsertItem(nIx, aColor, CustomColorNameList[
i]);
210 sal_uInt16 nItemId = 1;
219 for (
size_t nEffect : {0, 1, 2, 3, 4, 5})
224 auto const& rEffect = rColorData.maEffects[nEffect];
225 rColorSet.
InsertItem(nItemId++, rEffect.maColor, rEffect.maColorName);
253 css::uno::Sequence< sal_Int32 > Colorlist(officecfg::Office::Common::UserColors::RecentColor::get());
254 css::uno::Sequence< OUString > ColorNamelist(officecfg::Office::Common::UserColors::RecentColorName::get());
256 const bool bHasColorNames = Colorlist.getLength() == ColorNamelist.getLength();
257 for (
int i = 0;
i < Colorlist.getLength(); ++
i)
260 OUString sColorName = bHasColorNames ? ColorNamelist[
i] : (
"#" + aColor.
AsRGBHexString().toAsciiUpperCase());
262 rColorSet.
InsertItem(nIx, aColor, sColorName);
269 std::vector<OUString> aPaletteNames
275 aPaletteNames.push_back( (*it).GetName() );
277 aPaletteNames.push_back(
SvxResId(RID_SVXSTR_THEME_COLORS));
278 aPaletteNames.push_back(
SvxResId ( RID_SVXSTR_DOC_COLORS ) );
280 return aPaletteNames;
296 if (pShell !=
nullptr)
303 OUString aPaletteName(officecfg::Office::Common::UserColors::PaletteName::get());
307 officecfg::Office::Common::UserColors::PaletteName::set(
GetPaletteName(), batch);
326 if(
nullptr != ( pItem = pDocSh->
GetItem(SID_COLOR_TABLE) ) )
355 [rRecentColor] (
const NamedColor &aColor) { return aColor.m_aColor == rRecentColor; });
366 css::uno::Sequence< sal_Int32 > aColorList(
maRecentColors.size());
367 auto aColorListRange = asNonConstRange(aColorList);
368 css::uno::Sequence< OUString > aColorNameList(
maRecentColors.size());
369 auto aColorNameListRange = asNonConstRange(aColorNameList);
376 officecfg::Office::Common::UserColors::RecentColor::set(aColorList, batch);
377 officecfg::Office::Common::UserColors::RecentColorName::set(aColorNameList, batch);
404 m_pColorDlg->ExecuteAsync(pParent, [
this, aCommandCopy] (sal_Int32 nResult) {
408 OUString sColorName =
"#" + aLastColor.
AsRGBHexString().toAsciiUpperCase();
409 NamedColor aNamedColor(aLastColor, sColorName);
420 using namespace css::uno;
421 using namespace css::frame;
422 using namespace css::beans;
423 using namespace css::util;
426 Reference<XDesktop2> xDesktop = Desktop::create(xContext);
427 Reference<XFrame>
xFrame(xDesktop->getCurrentFrame());
428 Reference<XDispatchProvider> xDispatchProvider(
xFrame, UNO_QUERY);
429 if (!xDispatchProvider.is())
434 std::vector<PropertyValue> aArgs{
458 Reference<XDispatch>
xDispatch = xDispatchProvider->queryDispatch(
aTargetURL, OUString(), 0);
462 if (
xFrame->getContainerWindow().is())
463 xFrame->getContainerWindow()->setFocus();
std::function< void(const OUString &, const NamedColor &)> ColorSelectFunction
OUString AsRGBHexString() const
OUString GetURLPath(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
tools::Long GetColorCount() const
const sal_uInt16 mnMaxRecentColors
bool GetLumModOff(sal_uInt16 nThemeIndex, sal_uInt16 nEffect, sal_Int16 &rLumMod, sal_Int16 &rLumOff)
void SetColorSelectFunction(const ColorSelectFunction &aColorSelectFunction)
void PopupColorPicker(weld::Window *pParent, const OUString &aCommand, const Color &rInitialColor)
std::vector< OUString > GetPaletteList()
svx::ToolboxButtonColorUpdaterBase * mpBtnUpdater
PaletteManager * Clone() const
void ReloadColorSet(SvxColorValueSet &rColorSet)
static bool GetThemeAndEffectIndex(sal_uInt16 nItemId, sal_uInt16 &rThemeIndex, sal_uInt16 &rEffectIndex)
void SetSplitButtonColor(const NamedColor &rColor)
tools::Long GetRecentColorCount() const
std::deque< NamedColor > maRecentColors
std::optional< svx::ThemePaletteCollection > moThemePaletteCollection
sal_uInt16 mnNumOfPalettes
static void DispatchColorCommand(const OUString &aCommand, const NamedColor &rColor)
void ReloadRecentColorSet(SvxColorValueSet &rColorSet)
sal_uInt16 mnCurrentPalette
ColorSelectFunction maColorSelectFunction
std::vector< std::unique_ptr< Palette > > m_Palettes
std::unique_ptr< SvColorDialog > m_pColorDlg
void SetPalette(sal_Int32 nPos)
OUString GetPaletteName()
bool IsThemePaletteSelected() const
OUString GetSelectedPalettePath()
void SetBtnUpdater(svx::ToolboxButtonColorUpdaterBase *pBtnUpdater)
sal_Int32 GetPalette() const
void AddRecentColor(const Color &rRecentColor, const OUString &rColorName, bool bFront=true)
virtual std::shared_ptr< model::ColorSet > GetThemeColors()
virtual std::set< Color > GetDocColors()
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
void PutItem(const SfxPoolItem &rItem)
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
const OUString & GetPalettePath() const
void addEntriesForColorSet(const std::set< Color > &rColorSet, std::u16string_view rNamePrefix)
void InsertItem(sal_uInt16 nItemId, const Image &rImage)
size_t GetItemCount() const
static XColorListRef CreateStdColorList()
static XColorListRef AsColorList(rtl::Reference< XPropertyList > const &plist)
static XPropertyListRef CreatePropertyListFromURL(XPropertyListType t, std::u16string_view rUrl)
static std::shared_ptr< ConfigurationChanges > create()
void setSchemeColor(ThemeColorType eType)
void addTransformation(Transformation const &rTransform)
ThemePaletteCollection generate()
OUString SvxResId(TranslateId aId)
Reference< XDispatch > xDispatch
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
Reference< XComponentContext > getProcessComponentContext()
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
OString convertToJSON(model::ComplexColor const &rComplexColor)
constexpr ThemeColorType convertToThemeColorType(sal_Int32 nIndex)
Reference< XFrame > xFrame