17#include <com/sun/star/lang/IllegalArgumentException.hpp>
40 OUString msHeadingFont;
48 sal_Int16 mnTintShade;
55 ColorVariable(
tools::Long nIndex, sal_Int16 nTintShade)
57 , mnTintShade(nTintShade)
61class StyleRedefinition
63 ColorVariable maVariable;
69 explicit StyleRedefinition(
const OUString& aElementName)
73 void setColorVariable(ColorVariable aVariable)
75 maVariable = aVariable;
81 if (maVariable.mnIndex > -1)
83 aColor = rColorSet.
getColor(maVariable.mnIndex);
96 std::vector<StyleRedefinition> maStyles;
102 void add(StyleRedefinition
const & aRedefinition)
104 maStyles.push_back(aRedefinition);
107 StyleRedefinition*
get(std::u16string_view aString)
109 for (StyleRedefinition & rStyle : maStyles)
111 if (rStyle.maElementName == aString)
120StyleSet setupThemes()
125 StyleRedefinition aRedefinition(
"Heading 1");
126 aRedefinition.setColorVariable(ColorVariable(10, -1000));
127 aSet.add(aRedefinition);
131 StyleRedefinition aRedefinition(
"Heading 2");
132 aRedefinition.setColorVariable(ColorVariable(7, -500));
133 aSet.add(aRedefinition);
137 StyleRedefinition aRedefinition(
"Heading 3");
138 aRedefinition.setColorVariable(ColorVariable(5, 0));
139 aSet.add(aRedefinition);
143 StyleRedefinition aRedefinition(
"Heading 4");
144 aRedefinition.setColorVariable(ColorVariable(6, -1000));
145 aSet.add(aRedefinition);
149 StyleRedefinition aRedefinition(
"Heading 5");
150 aRedefinition.setColorVariable(ColorVariable(4, -1500));
151 aSet.add(aRedefinition);
155 StyleRedefinition aRedefinition(
"Heading 6");
156 aRedefinition.setColorVariable(ColorVariable(3, -2500));
157 aSet.add(aRedefinition);
161 StyleRedefinition aRedefinition(
"Heading 7");
162 aRedefinition.setColorVariable(ColorVariable(3, -2500));
163 aSet.add(aRedefinition);
167 StyleRedefinition aRedefinition(
"Heading 8");
168 aRedefinition.setColorVariable(ColorVariable(2, 0));
169 aSet.add(aRedefinition);
173 StyleRedefinition aRedefinition(
"Heading 9");
174 aRedefinition.setColorVariable(ColorVariable(2, 0));
175 aSet.add(aRedefinition);
179 StyleRedefinition aRedefinition(
"Heading 10");
180 aRedefinition.setColorVariable(ColorVariable(0, 0));
181 aSet.add(aRedefinition);
198 if (ePitch == PITCH_FIXED)
200 aFontItem.SetFamilyName(rFontSet.msMonoFont);
204 if (pStyle->
GetName() ==
"Heading")
206 aFontItem.SetFamilyName(rFontSet.msHeadingFont);
210 aFontItem.SetFamilyName(rFontSet.msBaseFont);
233 Color aColor = pRedefinition->getColor(rColorSet);
236 aColorItem.SetValue(aColor);
240std::vector<FontSet> initFontSets()
242 std::vector<FontSet> aFontSets;
245 aFontSet.maName =
"Liberation Family";
246 aFontSet.msHeadingFont =
"Liberation Sans";
247 aFontSet.msBaseFont =
"Liberation Serif";
248 aFontSet.msMonoFont =
"Liberation Mono";
249 aFontSets.push_back(aFontSet);
253 aFontSet.maName =
"DejaVu Family";
254 aFontSet.msHeadingFont =
"DejaVu Sans";
255 aFontSet.msBaseFont =
"DejaVu Serif";
256 aFontSet.msMonoFont =
"DejaVu Sans Mono";
257 aFontSets.push_back(aFontSet);
261 aFontSet.maName =
"Croscore Modern";
262 aFontSet.msHeadingFont =
"Caladea";
263 aFontSet.msBaseFont =
"Carlito";
264 aFontSet.msMonoFont =
"Liberation Mono";
265 aFontSets.push_back(aFontSet);
269 aFontSet.maName =
"Carlito";
270 aFontSet.msHeadingFont =
"Carlito";
271 aFontSet.msBaseFont =
"Carlito";
272 aFontSet.msMonoFont =
"Liberation Mono";
273 aFontSets.push_back(aFontSet);
277 aFontSet.maName =
"Source Sans Family";
278 aFontSet.msHeadingFont =
"Source Sans Pro";
279 aFontSet.msBaseFont =
"Source Sans Pro";
280 aFontSet.msMonoFont =
"Source Code Pro";
281 aFontSets.push_back(aFontSet);
285 aFontSet.maName =
"Source Sans Family 2";
286 aFontSet.msHeadingFont =
"Source Sans Pro";
287 aFontSet.msBaseFont =
"Source Sans Pro Light";
288 aFontSet.msMonoFont =
"Source Code Pro";
289 aFontSets.push_back(aFontSet);
293 aFontSet.maName =
"Libertine Family";
294 aFontSet.msHeadingFont =
"Linux Biolinum G";
295 aFontSet.msBaseFont =
"Linux Libertine G";
296 aFontSet.msMonoFont =
"Liberation Mono";
297 aFontSets.push_back(aFontSet);
301 aFontSet.maName =
"Noto Sans";
302 aFontSet.msHeadingFont =
"Noto Sans";
303 aFontSet.msBaseFont =
"Noto Sans";
304 aFontSet.msMonoFont =
"Noto Mono";
305 aFontSets.push_back(aFontSet);
309 aFontSet.maName =
"Droid Sans";
310 aFontSet.msHeadingFont =
"Droid Sans";
311 aFontSet.msBaseFont =
"Droid Sans";
312 aFontSet.msMonoFont =
"Droid Sans Mono";
313 aFontSets.push_back(aFontSet);
318FontSet getFontSet(std::u16string_view rFontVariant, std::vector<FontSet>& aFontSets)
320 for (
const FontSet & rFontSet : aFontSets)
322 if (rFontSet.maName == rFontVariant)
328void applyTheme(
SfxStyleSheetBasePool* pPool, std::u16string_view sFontSetName, std::u16string_view sColorSetName,
333 std::vector<FontSet> aFontSets = initFontSets();
334 FontSet aFontSet = getFontSet(sFontSetName, aFontSets);
343 changeFont(pCollection, pStyle, aFontSet);
345 StyleRedefinition* pRedefinition = rStyleSet.get(pStyle->
GetName());
349 changeColor(pCollection, aColorSet, pRedefinition);
360 changeFont(
static_cast<SwFormat*
>(pCharFormat), pStyle, aFontSet);
369 float fScaleFactor = pVirtualDev->GetDPIScaleFactor();
375 Size aSize(BORDER * 7 + SIZE * 6 + BORDER * 2, BORDER * 3 + SIZE * 2 + LABEL_HEIGHT);
376 pVirtualDev->SetOutputSizePixel(aSize);
378 pVirtualDev->Erase();
384 pVirtualDev->SetLineColor(COL_LIGHTGRAY);
385 pVirtualDev->SetFillColor(COL_LIGHTGRAY);
387 pVirtualDev->DrawRect(aNameRect);
392 pVirtualDev->SetFont(aFont);
394 Size aTextSize(pVirtualDev->GetTextWidth(aName), pVirtualDev->GetTextHeight());
396 Point aPoint((aNameRect.GetWidth() / 2.0) - (aTextSize.Width() / 2.0),
397 (aNameRect.GetHeight() / 2.0) - (aTextSize.Height() / 2.0));
399 pVirtualDev->DrawText(aPoint, aName);
401 pVirtualDev->SetLineColor(COL_LIGHTGRAY);
402 pVirtualDev->SetFillColor();
404 for (sal_uInt32 i = 0;
i < 12;
i += 2)
406 pVirtualDev->SetFillColor(rColorSet.
getColor(i));
409 pVirtualDev->SetFillColor(rColorSet.
getColor(i + 1));
413 if (i == 2 || i == 8)
417 return pVirtualDev->GetBitmapEx(
Point(), aSize);
426 if (pParent ==
nullptr)
427 throw css::lang::IllegalArgumentException(
"no parent Window given to PagePropertyPanel::Create",
nullptr, 0);
429 return std::make_unique<ThemePanel>(pParent);
433 :
PanelLayout(pParent,
"ThemePanel",
"modules/swriter/ui/sidebartheme.ui")
434 , mxListBoxFonts(m_xBuilder->weld_tree_view(
"listbox_fonts"))
435 , mxValueSetColors(new
ValueSet(nullptr))
436 , mxValueSetColorsWin(new
weld::CustomWeld(*m_xBuilder,
"valueset_colors", *mxValueSetColors))
437 , mxApplyButton(m_xBuilder->weld_button(
"apply"))
447 std::vector<FontSet> aFontSets = initFontSets();
448 for (
const FontSet & rFontSet : aFontSets)
455 for (
size_t i = 0;
i < aColorSets.size(); ++
i)
460 BitmapEx aPreview = GenerateColorPreview(rColorSet);
462 sal_uInt16
nId =
i + 1;
468 if (!aColorSets.empty())
506 sal_uInt32
nIndex = nItemId - 1;
509 StyleSet aStyleSet = setupThemes();
static OutputDevice * GetDefaultDevice()
static const AllSettings & GetSettings()
void ApplyTintOrShade(sal_Int16 n100thPercent)
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
static SfxObjectShell * Current()
SfxStyleSheetBase * First(SfxStyleFamily eFamily, SfxStyleSearchBits eMask=SfxStyleSearchBits::All)
SfxStyleSheetBase * Next()
const OUString & GetName() const
virtual SfxStyleSheetBasePool * GetStyleSheetPool() override
For Style PI.
SwCharFormat * GetCharFormat()
SwTextFormatColl * GetCollection()
Represents the style of a paragraph.
virtual bool SetFormatAttr(const SfxPoolItem &rAttr) override
Override to recognize changes on the <SwNumRuleItem> and register/unregister the paragragh style at t...
const OUString & getName() const
const Color & getColor(sal_uInt32 nIndex) const
const std::vector< ColorSet > & getColorSets() const
const ColorSet & getColorSet(sal_uInt32 nIndex)
void SetFontHeight(tools::Long nHeight)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_FONT(7)
#define LINK(Instance, Class, Member)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)