LibreOffice Module svx (master) 1
StylesPreviewWindow.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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
21
22#include <comphelper/base64.hxx>
23#include <comphelper/lok.hxx>
25#include <utility>
26#include <vcl/svapp.hxx>
27#include <sfx2/objsh.hxx>
28#include <svl/itemset.hxx>
29#include <sfx2/tbxctrl.hxx>
30#include <sfx2/sfxsids.hrc>
31#include <sfx2/tplpitem.hxx>
32#include <sfx2/viewsh.hxx>
35#include <vcl/virdev.hxx>
36#include <vcl/settings.hxx>
37
38#include <editeng/editids.hrc>
39#include <editeng/fontitem.hxx>
40#include <editeng/fhgtitem.hxx>
41#include <editeng/svxfont.hxx>
42#include <editeng/wghtitem.hxx>
43#include <editeng/postitem.hxx>
45#include <editeng/shdditem.hxx>
47#include <editeng/udlnitem.hxx>
49#include <editeng/colritem.hxx>
50#include <editeng/cmapitem.hxx>
52#include <editeng/brushitem.hxx>
53
55
56#include <svx/xfillit0.hxx>
57#include <svx/xdef.hxx>
58#include <svx/xflclit.hxx>
59
60#include <com/sun/star/drawing/FillStyle.hpp>
61#include <com/sun/star/i18n/ScriptType.hpp>
62#include <com/sun/star/uno/Sequence.hxx>
63
64#include <vcl/commandevent.hxx>
65#include <tools/json_writer.hxx>
66
67namespace
68{
69class StylePreviewCache
70{
71private:
72 class JsonStylePreviewCacheClear final : public Timer
73 {
74 public:
75 JsonStylePreviewCacheClear()
76 : Timer("Json Style Preview Cache clear callback")
77 {
78 // a generous 30 secs
79 SetTimeout(30000);
80 SetStatic();
81 }
82 virtual void Invoke() override { StylePreviewCache::gJsonStylePreviewCache.clear(); }
83 };
84
85 static std::map<OUString, VclPtr<VirtualDevice>> gStylePreviewCache;
86 static std::map<OUString, OString> gJsonStylePreviewCache;
87 static int gStylePreviewCacheClients;
88 static JsonStylePreviewCacheClear gJsonIdleClear;
89
90public:
91 static std::map<OUString, VclPtr<VirtualDevice>>& Get() { return gStylePreviewCache; }
92 static std::map<OUString, OString>& GetJson() { return gJsonStylePreviewCache; }
93
94 static void ClearCache(bool bHard)
95 {
96 for (auto& aPreview : gStylePreviewCache)
97 aPreview.second.disposeAndClear();
98
99 gStylePreviewCache.clear();
100 if (bHard)
101 {
102 StylePreviewCache::gJsonStylePreviewCache.clear();
103 gJsonIdleClear.Stop();
104 }
105 else
106 {
107 // tdf#155720 don't immediately clear the json representation
108 gJsonIdleClear.Start();
109 }
110 }
111
112 static void RegisterClient()
113 {
114 if (!gStylePreviewCacheClients)
115 gJsonIdleClear.Stop();
116 gStylePreviewCacheClients++;
117 }
118
119 static void UnregisterClient()
120 {
121 gStylePreviewCacheClients--;
122 if (!gStylePreviewCacheClients)
123 ClearCache(false);
124 }
125};
126
127std::map<OUString, VclPtr<VirtualDevice>> StylePreviewCache::gStylePreviewCache;
128std::map<OUString, OString> StylePreviewCache::gJsonStylePreviewCache;
129int StylePreviewCache::gStylePreviewCacheClients;
130StylePreviewCache::JsonStylePreviewCacheClear StylePreviewCache::gJsonIdleClear;
131}
132
134 StylesPreviewWindow_Base* pPreviewControl,
135 const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider)
136 : SfxStatusListener(xDispatchProvider, SID_STYLE_FAMILY2, ".uno:ParaStyle")
137 , m_pPreviewControl(pPreviewControl)
138{
139 ReBind();
140}
141
143 const SfxPoolItem* pState)
144{
145 const SfxTemplateItem* pStateItem = dynamic_cast<const SfxTemplateItem*>(pState);
146 if (pStateItem)
147 {
148 if (pStateItem->GetStyleIdentifier().isEmpty())
149 m_pPreviewControl->Select(pStateItem->GetStyleName());
150 else
152 }
153}
154
156 : m_pPreviewControl(pPreviewControl)
157{
159
160 m_pStyleSheetPool = pDocShell ? pDocShell->GetStyleSheetPool() : nullptr;
161
163 {
165 }
166}
167
169{
172}
173
175{
176 if (rHint.GetId() == SfxHintId::StyleSheetModified)
177 StylePreviewCache::ClearCache(true);
179}
180
181StyleItemController::StyleItemController(std::pair<OUString, OUString> aStyleName)
182 : m_eStyleFamily(SfxStyleFamily::Para)
183 , m_aStyleName(std::move(aStyleName))
184{
185}
186
188{
191
192 DrawEntry(rRenderContext);
193
194 rRenderContext.Pop();
195}
196
198{
199 if (rEvent.GetCommand() != CommandEventId::ContextMenu)
200 return false;
201
202 std::unique_ptr<weld::Builder> xBuilder(
203 Application::CreateBuilder(m_xStylesView.get(), "svx/ui/stylemenu.ui"));
204 std::unique_ptr<weld::Menu> xMenu(xBuilder->weld_menu("menu"));
205 OUString rIdent = xMenu->popup_at_rect(m_xStylesView.get(),
206 tools::Rectangle(rEvent.GetMousePosPixel(), Size(1, 1)));
207 if (rIdent == "update" || rIdent == "edit")
208 {
209 css::uno::Sequence<css::beans::PropertyValue> aArgs(0);
210
211 const css::uno::Reference<css::frame::XDispatchProvider> xProvider(m_xFrame,
212 css::uno::UNO_QUERY);
214 rIdent == "update" ? OUString(".uno:StyleUpdateByExample")
215 : OUString(".uno:EditStyle"),
216 aArgs);
217
218 return true;
219 }
220
221 return false;
222}
223
224static Color GetTextColorFromItemSet(std::optional<SfxItemSet> const& pItemSet)
225{
226 const SfxPoolItem* pItem = pItemSet->GetItem(SID_ATTR_CHAR_COLOR);
227 if (pItem)
228 return static_cast<const SvxColorItem*>(pItem)->GetValue();
229
230 return COL_AUTO;
231}
232
233static Color GetHighlightColorFromItemSet(std::optional<SfxItemSet> const& pItemSet)
234{
235 const SfxPoolItem* pItem = pItemSet->GetItem(SID_ATTR_BRUSH_CHAR);
236 if (pItem)
237 return static_cast<const SvxBrushItem*>(pItem)->GetColor();
238
239 return COL_AUTO;
240}
241
242static Color GetBackgroundColorFromItemSet(std::optional<SfxItemSet> const& pItemSet)
243{
244 const SfxPoolItem* pItem = pItemSet->GetItem(XATTR_FILLCOLOR);
245 if (pItem)
246 return static_cast<const XFillColorItem*>(pItem)->GetColorValue();
247
248 return COL_AUTO;
249}
250
251static css::drawing::FillStyle GetFillStyleFromItemSet(std::optional<SfxItemSet> const& pItemSet)
252{
253 const SfxPoolItem* pItem = pItemSet->GetItem(XATTR_FILLSTYLE);
254 if (pItem)
255 return static_cast<const XFillStyleItem*>(pItem)->GetValue();
256
257 return css::drawing::FillStyle_NONE;
258}
259
260static SvxFont GetFontFromItems(const SvxFontItem* pFontItem, Size aPixelFontSize,
261 std::optional<SfxItemSet> const& pItemSet)
262{
263 SvxFont aFont;
264
265 aFont.SetFamilyName(pFontItem->GetFamilyName());
266 aFont.SetStyleName(pFontItem->GetStyleName());
267 aFont.SetFontSize(aPixelFontSize);
268
269 const SfxPoolItem* pItem = pItemSet->GetItem(SID_ATTR_CHAR_WEIGHT);
270 if (pItem)
271 aFont.SetWeight(static_cast<const SvxWeightItem*>(pItem)->GetWeight());
272
273 pItem = pItemSet->GetItem(SID_ATTR_CHAR_POSTURE);
274 if (pItem)
275 aFont.SetItalic(static_cast<const SvxPostureItem*>(pItem)->GetPosture());
276
277 pItem = pItemSet->GetItem(SID_ATTR_CHAR_CONTOUR);
278 if (pItem)
279 aFont.SetOutline(static_cast<const SvxContourItem*>(pItem)->GetValue());
280
281 pItem = pItemSet->GetItem(SID_ATTR_CHAR_SHADOWED);
282 if (pItem)
283 aFont.SetShadow(static_cast<const SvxShadowedItem*>(pItem)->GetValue());
284
285 pItem = pItemSet->GetItem(SID_ATTR_CHAR_RELIEF);
286 if (pItem)
287 aFont.SetRelief(static_cast<const SvxCharReliefItem*>(pItem)->GetValue());
288
289 pItem = pItemSet->GetItem(SID_ATTR_CHAR_UNDERLINE);
290 if (pItem)
291 aFont.SetUnderline(static_cast<const SvxUnderlineItem*>(pItem)->GetLineStyle());
292
293 pItem = pItemSet->GetItem(SID_ATTR_CHAR_OVERLINE);
294 if (pItem)
295 aFont.SetOverline(static_cast<const SvxOverlineItem*>(pItem)->GetValue());
296
297 pItem = pItemSet->GetItem(SID_ATTR_CHAR_STRIKEOUT);
298 if (pItem)
299 aFont.SetStrikeout(static_cast<const SvxCrossedOutItem*>(pItem)->GetStrikeout());
300
301 pItem = pItemSet->GetItem(SID_ATTR_CHAR_CASEMAP);
302 if (pItem)
303 aFont.SetCaseMap(static_cast<const SvxCaseMapItem*>(pItem)->GetCaseMap());
304
305 pItem = pItemSet->GetItem(SID_ATTR_CHAR_EMPHASISMARK);
306 if (pItem)
307 aFont.SetEmphasisMark(static_cast<const SvxEmphasisMarkItem*>(pItem)->GetEmphasisMark());
308
309 return aFont;
310}
311
313{
315 if (!pShell)
316 return;
317
318 SfxStyleSheetBasePool* pPool = pShell->GetStyleSheetPool();
319 SfxStyleSheetBase* pStyle = nullptr;
320
321 if (!pPool)
322 return;
323
324 pStyle = pPool->First(m_eStyleFamily);
325 while (pStyle && pStyle->GetName() != m_aStyleName.first
326 && pStyle->GetName() != m_aStyleName.second)
327 pStyle = pPool->Next();
328
329 if (!pStyle)
330 return;
331
332 Size aSize(rRenderContext.GetOutputSizePixel());
333 tools::Rectangle aFullRect(Point(0, 0), aSize);
334 tools::Rectangle aContentRect(aFullRect);
335
336 Color aOriginalColor = rRenderContext.GetFillColor();
337 Color aOriginalLineColor = rRenderContext.GetLineColor();
338
339 DrawContentBackground(rRenderContext, aContentRect, aOriginalColor);
340
341 std::optional<SfxItemSet> const pItemSet(pStyle->GetItemSetForPreview());
342 if (!pItemSet)
343 return;
344
345 Color aFontHighlight = COL_AUTO;
346
347 sal_Int16 nScriptType
348 = MsLangId::getScriptType(Application::GetSettings().GetUILanguageTag().getLanguageType());
349
350 sal_uInt16 nFontSlot = SID_ATTR_CHAR_FONT;
351 if (nScriptType == css::i18n::ScriptType::ASIAN)
352 nFontSlot = SID_ATTR_CHAR_CJK_FONT;
353 else if (nScriptType == css::i18n::ScriptType::COMPLEX)
354 nFontSlot = SID_ATTR_CHAR_CTL_FONT;
355
356 const SvxFontItem* const pFontItem = pItemSet->GetItem<SvxFontItem>(nFontSlot);
357 const SvxFontHeightItem* const pFontHeightItem
358 = pItemSet->GetItem<SvxFontHeightItem>(SID_ATTR_CHAR_FONTHEIGHT);
359
360 if (pFontItem && pFontHeightItem)
361 {
362 Size aFontSize(0, pFontHeightItem->GetHeight());
363 Size aPixelSize(rRenderContext.LogicToPixel(aFontSize, MapMode(pShell->GetMapUnit())));
364
365 SvxFont aFont = GetFontFromItems(pFontItem, aPixelSize, pItemSet);
366 rRenderContext.SetFont(aFont);
367
368 Color aFontCol = GetTextColorFromItemSet(pItemSet);
369 if (aFontCol != COL_AUTO)
370 rRenderContext.SetTextColor(aFontCol);
371
372 aFontHighlight = GetHighlightColorFromItemSet(pItemSet);
373
374 css::drawing::FillStyle style = GetFillStyleFromItemSet(pItemSet);
375
376 switch (style)
377 {
378 case css::drawing::FillStyle_SOLID:
379 {
380 Color aBackCol = GetBackgroundColorFromItemSet(pItemSet);
381 if (aBackCol != COL_AUTO)
382 DrawContentBackground(rRenderContext, aContentRect, aBackCol);
383 }
384 break;
385
386 default:
387 break;
388 //TODO Draw the other background styles: gradient, hatching and bitmap
389 }
390 }
391
392 if (aFontHighlight != COL_AUTO)
393 DrawHighlight(rRenderContext, aFontHighlight);
394
395 DrawText(rRenderContext);
396
397 rRenderContext.SetFillColor(aOriginalColor);
398 rRenderContext.SetLineColor(aOriginalLineColor);
399}
400
402 const tools::Rectangle& aContentRect,
403 const Color& aColor)
404{
405 rRenderContext.SetLineColor(aColor);
406 rRenderContext.SetFillColor(aColor);
407 rRenderContext.DrawRect(aContentRect);
408}
409
411{
412 tools::Rectangle aTextRect;
413 rRenderContext.GetTextBoundRect(aTextRect, m_aStyleName.second);
414
415 Size aSize = aTextRect.GetSize();
416 aSize.AdjustHeight(aSize.getHeight());
417 aTextRect.SetSize(aSize);
418
419 Point aPos(0, 0);
420 aPos.AdjustX(LEFT_MARGIN);
421 aPos.AdjustY((rRenderContext.GetOutputHeightPixel() - aTextRect.Bottom()) / 2);
422 aTextRect.SetPos(aPos);
423
424 rRenderContext.SetLineColor(aFontBack);
425 rRenderContext.SetFillColor(aFontBack);
426
427 rRenderContext.DrawRect(aTextRect);
428}
429
431{
432 const SalLayoutGlyphs* layoutGlyphs
433 = SalLayoutGlyphsCache::self()->GetLayoutGlyphs(&rRenderContext, m_aStyleName.second);
434 tools::Rectangle aTextRect;
435 rRenderContext.GetTextBoundRect(aTextRect, m_aStyleName.second, 0, 0, -1, 0, {}, {},
436 layoutGlyphs);
437
438 Point aPos(0, 0);
439 aPos.AdjustX(LEFT_MARGIN);
440 aPos.AdjustY((rRenderContext.GetOutputHeightPixel() - aTextRect.Bottom()) / 2);
441
442 rRenderContext.DrawText(aPos, m_aStyleName.second, 0, -1, nullptr, nullptr, layoutGlyphs);
443}
444
446 weld::Builder& xBuilder, std::vector<std::pair<OUString, OUString>>&& aDefaultStyles,
447 const css::uno::Reference<css::frame::XFrame>& xFrame)
449 , m_xStylesView(xBuilder.weld_icon_view("stylesview"))
450 , m_aUpdateTask(*this)
451 , m_aDefaultStyles(std::move(aDefaultStyles))
452{
453 StylePreviewCache::RegisterClient();
454
455 m_xStylesView->connect_selection_changed(LINK(this, StylesPreviewWindow_Base, Selected));
456 m_xStylesView->connect_item_activated(LINK(this, StylesPreviewWindow_Base, DoubleClick));
457 m_xStylesView->connect_command(LINK(this, StylesPreviewWindow_Base, DoCommand));
458 m_xStylesView->connect_get_property_tree_elem(
459 LINK(this, StylesPreviewWindow_Base, DoJsonProperty));
460
461 const css::uno::Reference<css::frame::XDispatchProvider> xProvider(m_xFrame,
462 css::uno::UNO_QUERY);
463 m_xStatusListener = new StyleStatusListener(this, xProvider);
464
466
468}
469
471{
472 OUString sStyleName = rIconView.get_selected_text();
473
474 css::uno::Sequence<css::beans::PropertyValue> aArgs{
475 comphelper::makePropertyValue("Template", sStyleName),
476 comphelper::makePropertyValue("Family", sal_Int16(SfxStyleFamily::Para))
477 };
478 const css::uno::Reference<css::frame::XDispatchProvider> xProvider(m_xFrame,
479 css::uno::UNO_QUERY);
480 SfxToolBoxControl::Dispatch(xProvider, ".uno:StyleApply", aArgs);
481}
482
483IMPL_LINK(StylesPreviewWindow_Base, DoubleClick, weld::IconView&, rIconView, bool)
484{
485 OUString sStyleName = rIconView.get_selected_text();
486
487 css::uno::Sequence<css::beans::PropertyValue> aArgs{
488 comphelper::makePropertyValue("Param", sStyleName),
489 comphelper::makePropertyValue("Family", sal_Int16(SfxStyleFamily::Para))
490 };
491 const css::uno::Reference<css::frame::XDispatchProvider> xProvider(m_xFrame,
492 css::uno::UNO_QUERY);
493 SfxToolBoxControl::Dispatch(xProvider, ".uno:EditStyle", aArgs);
494
495 return true;
496}
497
498IMPL_LINK(StylesPreviewWindow_Base, DoCommand, const CommandEvent&, rPos, bool)
499{
500 return Command(rPos);
501}
502
504{
505 m_xStatusListener->UnBind();
506
508
509 StylePreviewCache::UnregisterClient();
510
511 try
512 {
513 m_xStatusListener->dispose();
514 }
515 catch (css::uno::Exception&)
516 {
517 }
518
519 m_xStatusListener = nullptr;
520}
521
522void StylesPreviewWindow_Base::Select(const OUString& rStyleName)
523{
524 m_sSelectedStyle = rStyleName;
525
527}
528
530{
531 for (std::vector<std::pair<OUString, OUString>>::size_type i = 0; i < m_aAllStyles.size(); ++i)
532 {
534 {
535 m_xStylesView->select(i);
536 break;
537 }
538 }
539}
540
542
544{
547}
548
549static OString extractPngString(const BitmapEx& rBitmap)
550{
551 SvMemoryStream aOStm(65535, 65535);
552 // Use fastest compression "1"
553 css::uno::Sequence<css::beans::PropertyValue> aFilterData{
554 comphelper::makePropertyValue("Compression", sal_Int32(1)),
555 };
556 vcl::PngImageWriter aPNGWriter(aOStm);
557 aPNGWriter.setParameters(aFilterData);
558 if (aPNGWriter.write(rBitmap))
559 {
560 css::uno::Sequence<sal_Int8> aSeq(static_cast<sal_Int8 const*>(aOStm.GetData()),
561 aOStm.Tell());
562 OStringBuffer aBuffer("data:image/png;base64,");
564 return aBuffer.makeStringAndClear();
565 }
566
567 return "";
568}
569
570// 0: json writer, 1: TreeIter, 2: property. returns true if supported
571IMPL_LINK(StylesPreviewWindow_Base, DoJsonProperty, const weld::json_prop_query&, rQuery, bool)
572{
573 if (std::get<2>(rQuery) != "image")
574 return false;
575
576 const weld::TreeIter& rIter = std::get<1>(rQuery);
577 OUString sStyleId(m_xStylesView->get_id(rIter));
578 OUString sStyleName(m_xStylesView->get_text(rIter));
579 OString sBase64Png(GetCachedPreviewJson(std::pair<OUString, OUString>(sStyleId, sStyleName)));
580 if (sBase64Png.isEmpty())
581 return false;
582
583 tools::JsonWriter& rJsonWriter = std::get<0>(rQuery);
584 rJsonWriter.put("image", sBase64Png);
585
586 return true;
587}
588
590StylesPreviewWindow_Base::GetCachedPreview(const std::pair<OUString, OUString>& rStyle)
591{
592 auto aFound = StylePreviewCache::Get().find(rStyle.second);
593 if (aFound != StylePreviewCache::Get().end())
594 return StylePreviewCache::Get()[rStyle.second];
595 else
596 {
598 const Size aSize(100, 30);
599 pImg->SetOutputSizePixel(aSize);
600
601 StyleItemController aStyleController(rStyle);
602 aStyleController.Paint(*pImg);
603 StylePreviewCache::Get()[rStyle.second] = pImg;
604
605 return pImg;
606 }
607}
608
609OString StylesPreviewWindow_Base::GetCachedPreviewJson(const std::pair<OUString, OUString>& rStyle)
610{
611 auto aJsonFound = StylePreviewCache::GetJson().find(rStyle.second);
612 if (aJsonFound != StylePreviewCache::GetJson().end())
613 return StylePreviewCache::GetJson()[rStyle.second];
614
616 BitmapEx aBitmap(xDev->GetBitmapEx(Point(0, 0), xDev->GetOutputSize()));
617 OString sResult = extractPngString(aBitmap);
618 StylePreviewCache::GetJson()[rStyle.second] = sResult;
619 return sResult;
620}
621
623{
625
627 SfxStyleSheetBasePool* pStyleSheetPool = nullptr;
628
629 if (pDocShell)
630 pStyleSheetPool = pDocShell->GetStyleSheetPool();
631
632 if (pStyleSheetPool)
633 {
634 auto xIter = pStyleSheetPool->CreateIterator(SfxStyleFamily::Para,
635 SfxStyleSearchBits::UserDefined);
636
637 SfxStyleSheetBase* pStyle = xIter->First();
638
639 while (pStyle)
640 {
641 OUString sName(pStyle->GetName());
642 m_aAllStyles.push_back(std::pair<OUString, OUString>(sName, sName));
643 pStyle = xIter->Next();
644 }
645 }
646
647 m_xStylesView->freeze();
648 m_xStylesView->clear();
649 // for online we can skip inserting the preview into the IconView and rely
650 // on DoJsonProperty to provide the image to clients
651 const bool bNeedInsertPreview = !comphelper::LibreOfficeKit::isActive();
652 for (const auto& rStyle : m_aAllStyles)
653 {
654 VclPtr<VirtualDevice> pImg = bNeedInsertPreview ? GetCachedPreview(rStyle) : nullptr;
655 m_xStylesView->append(rStyle.first, rStyle.second, pImg);
656 }
657 m_xStylesView->thaw();
658}
659
661 vcl::Window* pParent, std::vector<std::pair<OUString, OUString>>&& aDefaultStyles,
662 const css::uno::Reference<css::frame::XFrame>& xFrame)
663 : InterimItemWindow(pParent, "svx/ui/stylespreview.ui", "ApplyStyleBox", true,
664 reinterpret_cast<sal_uInt64>(SfxViewShell::Current()))
665 , StylesPreviewWindow_Base(*m_xBuilder, std::move(aDefaultStyles), xFrame)
666{
668}
669
671
673{
674 m_xStylesView.reset();
675
677}
678
680
681/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
static Color GetTextColorFromItemSet(std::optional< SfxItemSet > const &pItemSet)
static OString extractPngString(const BitmapEx &rBitmap)
IMPL_LINK(StylesPreviewWindow_Base, Selected, weld::IconView &, rIconView, void)
static css::drawing::FillStyle GetFillStyleFromItemSet(std::optional< SfxItemSet > const &pItemSet)
static SvxFont GetFontFromItems(const SvxFontItem *pFontItem, Size aPixelFontSize, std::optional< SfxItemSet > const &pItemSet)
static Color GetHighlightColorFromItemSet(std::optional< SfxItemSet > const &pItemSet)
static Color GetBackgroundColorFromItemSet(std::optional< SfxItemSet > const &pItemSet)
css::uno::Reference< css::lang::XComponent > m_xFrame
static const AllSettings & GetSettings()
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
CommandEventId GetCommand() const
const Point & GetMousePosPixel() const
virtual void Start(bool bStartTimer=true) override
virtual void dispose() override
static sal_Int16 getScriptType(LanguageType nLang)
void SetFont(const vcl::Font &rNewFont)
Size GetOutputSizePixel() const
void DrawRect(const tools::Rectangle &rRect)
tools::Long GetOutputHeightPixel() const
bool GetTextBoundRect(tools::Rectangle &rRect, const OUString &rStr, sal_Int32 nBase=0, sal_Int32 nIndex=0, sal_Int32 nLen=-1, sal_uLong nLayoutWidth=0, KernArraySpan aDXArray=KernArraySpan(), o3tl::span< const sal_Bool > pKashidaArray={}, const SalLayoutGlyphs *pGlyphs=nullptr) const
void SetLineColor()
void SetTextColor(const Color &rColor)
void SetFillColor()
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
const Color & GetLineColor() const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
const Color & GetFillColor() const
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
static SalLayoutGlyphsCache * self()
const SalLayoutGlyphs * GetLayoutGlyphs(VclPtr< const OutputDevice > outputDevice, const OUString &text, const vcl::text::TextLayoutCache *layoutCache=nullptr)
SfxHintId GetId() const
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
virtual SfxStyleSheetBasePool * GetStyleSheetPool()
MapUnit GetMapUnit() const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
SfxStyleSheetBase * First(SfxStyleFamily eFamily, SfxStyleSearchBits eMask=SfxStyleSearchBits::All)
virtual std::unique_ptr< SfxStyleSheetIterator > CreateIterator(SfxStyleFamily, SfxStyleSearchBits nMask=SfxStyleSearchBits::All)
SfxStyleSheetBase * Next()
const OUString & GetName() const
virtual std::optional< SfxItemSet > GetItemSetForPreview()
const OUString & GetStyleName() const
const OUString & GetStyleIdentifier() const
void Dispatch(const OUString &aCommand, css::uno::Sequence< css::beans::PropertyValue > const &aArgs)
constexpr tools::Long getHeight() const
tools::Long AdjustHeight(tools::Long n)
void DrawHighlight(vcl::RenderContext &rRenderContext, Color aFontBack)
void Paint(vcl::RenderContext &rRenderContext)
void DrawText(vcl::RenderContext &rRenderContext)
StyleItemController(std::pair< OUString, OUString > aStyleName)
static void DrawContentBackground(vcl::RenderContext &rRenderContext, const tools::Rectangle &aContentRect, const Color &aColor)
void DrawEntry(vcl::RenderContext &rRenderContext)
static constexpr unsigned LEFT_MARGIN
SfxStyleFamily m_eStyleFamily
std::pair< OUString, OUString > m_aStyleName
Listener for styles creation or modification.
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
StylesPreviewWindow_Base * m_pPreviewControl
StylePoolChangeListener(StylesPreviewWindow_Base *pPreviewControl)
SfxStyleSheetBasePool * m_pStyleSheetPool
Listener for style selection.
StyleStatusListener(StylesPreviewWindow_Base *pPreviewControl, const css::uno::Reference< css::frame::XDispatchProvider > &xDispatchProvider)
void StateChangedAtStatusListener(SfxItemState eState, const SfxPoolItem *pState) override
StylesPreviewWindow_Base * m_pPreviewControl
virtual void Invoke() override
StylesPreviewWindow_Base & m_rStylesList
StylesPreviewWindow_Base(weld::Builder &xBuilder, std::vector< std::pair< OUString, OUString > > &&aDefaultStyles, const css::uno::Reference< css::frame::XFrame > &xFrame)
std::vector< std::pair< OUString, OUString > > m_aDefaultStyles
StylesListUpdateTask m_aUpdateTask
std::unique_ptr< weld::IconView > m_xStylesView
static OString GetCachedPreviewJson(const std::pair< OUString, OUString > &rStyle)
css::uno::Reference< css::frame::XFrame > m_xFrame
std::vector< std::pair< OUString, OUString > > m_aAllStyles
bool Command(const CommandEvent &rEvent)
static VclPtr< VirtualDevice > GetCachedPreview(const std::pair< OUString, OUString > &rStyle)
void Select(const OUString &rStyleName)
rtl::Reference< StyleStatusListener > m_xStatusListener
std::unique_ptr< StylePoolChangeListener > m_pStylePoolChangeListener
StylesPreviewWindow_Impl(vcl::Window *pParent, std::vector< std::pair< OUString, OUString > > &&aDefaultStyles, const css::uno::Reference< css::frame::XFrame > &xFrame)
const void * GetData()
sal_uInt64 Tell() const
const OUString & GetStyleName() const
const OUString & GetFamilyName() const
void SetCaseMap(const SvxCaseMap eNew)
void Stop()
static VclPtr< reference_type > Create(Arg &&... arg)
static void encode(OUStringBuffer &aStrBuffer, const css::uno::Sequence< sal_Int8 > &aPass)
void put(std::u16string_view pPropName, const OUString &rPropValue)
void SetSize(const Size &)
void SetPos(const Point &rPoint)
constexpr Size GetSize() const
constexpr tools::Long Bottom() const
void setParameters(css::uno::Sequence< css::beans::PropertyValue > const &rParameters)
bool write(const BitmapEx &rBitmap)
virtual void SetSizePixel(const Size &rNewSize)
Size get_preferred_size() const
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
STDMETHOD() Get(VARIANT *val)=0
OUString sName
Sequence< sal_Int8 > aSeq
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
int i
constexpr OUStringLiteral first
sal_Int16 GetCaseMap(sal_Int32 nToken)
end
std::tuple< tools::JsonWriter &, const TreeIter &, std::string_view > json_prop_query
const char GetValue[]
SfxItemState
SfxStyleFamily
Reference< XFrame > xFrame
signed char sal_Int8
std::unique_ptr< char[]> aBuffer
constexpr TypedWhichId< XFillColorItem > XATTR_FILLCOLOR(XATTR_FILL_FIRST+1)
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)