bump product version to 7.6.3.2-android
[LibreOffice.git] / svx / source / tbxctrls / StylesPreviewWindow.cxx
blob53a8f14511a99e1af556ea6c8e4bd8e36739a782
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.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <StylesPreviewWindow.hxx>
22 #include <comphelper/base64.hxx>
23 #include <comphelper/lok.hxx>
24 #include <comphelper/propertyvalue.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>
33 #include <vcl/filter/PngImageWriter.hxx>
34 #include <vcl/glyphitemcache.hxx>
35 #include <vcl/virdev.hxx>
36 #include <vcl/settings.hxx>
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>
44 #include <editeng/contouritem.hxx>
45 #include <editeng/shdditem.hxx>
46 #include <editeng/charreliefitem.hxx>
47 #include <editeng/udlnitem.hxx>
48 #include <editeng/crossedoutitem.hxx>
49 #include <editeng/colritem.hxx>
50 #include <editeng/cmapitem.hxx>
51 #include <editeng/emphasismarkitem.hxx>
52 #include <editeng/brushitem.hxx>
54 #include <i18nlangtag/mslangid.hxx>
56 #include <svx/xfillit0.hxx>
57 #include <svx/xdef.hxx>
58 #include <svx/xflclit.hxx>
60 #include <com/sun/star/drawing/FillStyle.hpp>
61 #include <com/sun/star/i18n/ScriptType.hpp>
62 #include <com/sun/star/uno/Sequence.hxx>
64 #include <vcl/commandevent.hxx>
65 #include <tools/json_writer.hxx>
67 namespace
69 class StylePreviewCache
71 static std::map<OUString, VclPtr<VirtualDevice>> gStylePreviewCache;
72 static std::map<OUString, OString> gJsonStylePreviewCache;
73 static int gStylePreviewCacheClients;
75 public:
76 static std::map<OUString, VclPtr<VirtualDevice>>& Get() { return gStylePreviewCache; }
77 static std::map<OUString, OString>& GetJson() { return gJsonStylePreviewCache; }
79 static void ClearCache()
81 for (auto& aPreview : gStylePreviewCache)
82 aPreview.second.disposeAndClear();
84 gStylePreviewCache.clear();
85 gJsonStylePreviewCache.clear();
88 static void RegisterClient() { gStylePreviewCacheClients++; }
89 static void UnregisterClient()
91 gStylePreviewCacheClients--;
92 if (!gStylePreviewCacheClients)
93 ClearCache();
97 std::map<OUString, VclPtr<VirtualDevice>> StylePreviewCache::gStylePreviewCache;
98 std::map<OUString, OString> StylePreviewCache::gJsonStylePreviewCache;
99 int StylePreviewCache::gStylePreviewCacheClients;
102 StyleStatusListener::StyleStatusListener(
103 StylesPreviewWindow_Base* pPreviewControl,
104 const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider)
105 : SfxStatusListener(xDispatchProvider, SID_STYLE_FAMILY2, ".uno:ParaStyle")
106 , m_pPreviewControl(pPreviewControl)
108 ReBind();
111 void StyleStatusListener::StateChangedAtStatusListener(SfxItemState /*eState*/,
112 const SfxPoolItem* pState)
114 const SfxTemplateItem* pStateItem = dynamic_cast<const SfxTemplateItem*>(pState);
115 if (pStateItem)
117 if (pStateItem->GetStyleIdentifier().isEmpty())
118 m_pPreviewControl->Select(pStateItem->GetStyleName());
119 else
120 m_pPreviewControl->Select(pStateItem->GetStyleIdentifier());
124 StylePoolChangeListener::StylePoolChangeListener(StylesPreviewWindow_Base* pPreviewControl)
125 : m_pPreviewControl(pPreviewControl)
127 SfxObjectShell* pDocShell = SfxObjectShell::Current();
129 m_pStyleSheetPool = pDocShell ? pDocShell->GetStyleSheetPool() : nullptr;
131 if (m_pStyleSheetPool)
133 StartListening(*m_pStyleSheetPool);
137 StylePoolChangeListener::~StylePoolChangeListener()
139 if (m_pStyleSheetPool)
140 EndListening(*m_pStyleSheetPool);
143 void StylePoolChangeListener::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint)
145 if (rHint.GetId() == SfxHintId::StyleSheetModified)
146 StylePreviewCache::ClearCache();
147 m_pPreviewControl->RequestStylesListUpdate();
150 StyleItemController::StyleItemController(std::pair<OUString, OUString> aStyleName)
151 : m_eStyleFamily(SfxStyleFamily::Para)
152 , m_aStyleName(std::move(aStyleName))
156 void StyleItemController::Paint(vcl::RenderContext& rRenderContext)
158 rRenderContext.Push(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::FONT
159 | vcl::PushFlags::TEXTCOLOR);
161 DrawEntry(rRenderContext);
163 rRenderContext.Pop();
166 bool StylesPreviewWindow_Base::Command(const CommandEvent& rEvent)
168 if (rEvent.GetCommand() != CommandEventId::ContextMenu)
169 return false;
171 std::unique_ptr<weld::Builder> xBuilder(
172 Application::CreateBuilder(m_xStylesView.get(), "svx/ui/stylemenu.ui"));
173 std::unique_ptr<weld::Menu> xMenu(xBuilder->weld_menu("menu"));
174 OUString rIdent = xMenu->popup_at_rect(m_xStylesView.get(),
175 tools::Rectangle(rEvent.GetMousePosPixel(), Size(1, 1)));
176 if (rIdent == "update" || rIdent == "edit")
178 css::uno::Sequence<css::beans::PropertyValue> aArgs(0);
180 SfxToolBoxControl::Dispatch(m_xDispatchProvider,
181 rIdent == "update" ? OUString(".uno:StyleUpdateByExample")
182 : OUString(".uno:EditStyle"),
183 aArgs);
185 return true;
188 return false;
191 static Color GetTextColorFromItemSet(std::optional<SfxItemSet> const& pItemSet)
193 const SfxPoolItem* pItem = pItemSet->GetItem(SID_ATTR_CHAR_COLOR);
194 if (pItem)
195 return static_cast<const SvxColorItem*>(pItem)->GetValue();
197 return COL_AUTO;
200 static Color GetHighlightColorFromItemSet(std::optional<SfxItemSet> const& pItemSet)
202 const SfxPoolItem* pItem = pItemSet->GetItem(SID_ATTR_BRUSH_CHAR);
203 if (pItem)
204 return static_cast<const SvxBrushItem*>(pItem)->GetColor();
206 return COL_AUTO;
209 static Color GetBackgroundColorFromItemSet(std::optional<SfxItemSet> const& pItemSet)
211 const SfxPoolItem* pItem = pItemSet->GetItem(XATTR_FILLCOLOR);
212 if (pItem)
213 return static_cast<const XFillColorItem*>(pItem)->GetColorValue();
215 return COL_AUTO;
218 static css::drawing::FillStyle GetFillStyleFromItemSet(std::optional<SfxItemSet> const& pItemSet)
220 const SfxPoolItem* pItem = pItemSet->GetItem(XATTR_FILLSTYLE);
221 if (pItem)
222 return static_cast<const XFillStyleItem*>(pItem)->GetValue();
224 return css::drawing::FillStyle_NONE;
227 static SvxFont GetFontFromItems(const SvxFontItem* pFontItem, Size aPixelFontSize,
228 std::optional<SfxItemSet> const& pItemSet)
230 SvxFont aFont;
232 aFont.SetFamilyName(pFontItem->GetFamilyName());
233 aFont.SetStyleName(pFontItem->GetStyleName());
234 aFont.SetFontSize(aPixelFontSize);
236 const SfxPoolItem* pItem = pItemSet->GetItem(SID_ATTR_CHAR_WEIGHT);
237 if (pItem)
238 aFont.SetWeight(static_cast<const SvxWeightItem*>(pItem)->GetWeight());
240 pItem = pItemSet->GetItem(SID_ATTR_CHAR_POSTURE);
241 if (pItem)
242 aFont.SetItalic(static_cast<const SvxPostureItem*>(pItem)->GetPosture());
244 pItem = pItemSet->GetItem(SID_ATTR_CHAR_CONTOUR);
245 if (pItem)
246 aFont.SetOutline(static_cast<const SvxContourItem*>(pItem)->GetValue());
248 pItem = pItemSet->GetItem(SID_ATTR_CHAR_SHADOWED);
249 if (pItem)
250 aFont.SetShadow(static_cast<const SvxShadowedItem*>(pItem)->GetValue());
252 pItem = pItemSet->GetItem(SID_ATTR_CHAR_RELIEF);
253 if (pItem)
254 aFont.SetRelief(static_cast<const SvxCharReliefItem*>(pItem)->GetValue());
256 pItem = pItemSet->GetItem(SID_ATTR_CHAR_UNDERLINE);
257 if (pItem)
258 aFont.SetUnderline(static_cast<const SvxUnderlineItem*>(pItem)->GetLineStyle());
260 pItem = pItemSet->GetItem(SID_ATTR_CHAR_OVERLINE);
261 if (pItem)
262 aFont.SetOverline(static_cast<const SvxOverlineItem*>(pItem)->GetValue());
264 pItem = pItemSet->GetItem(SID_ATTR_CHAR_STRIKEOUT);
265 if (pItem)
266 aFont.SetStrikeout(static_cast<const SvxCrossedOutItem*>(pItem)->GetStrikeout());
268 pItem = pItemSet->GetItem(SID_ATTR_CHAR_CASEMAP);
269 if (pItem)
270 aFont.SetCaseMap(static_cast<const SvxCaseMapItem*>(pItem)->GetCaseMap());
272 pItem = pItemSet->GetItem(SID_ATTR_CHAR_EMPHASISMARK);
273 if (pItem)
274 aFont.SetEmphasisMark(static_cast<const SvxEmphasisMarkItem*>(pItem)->GetEmphasisMark());
276 return aFont;
279 void StyleItemController::DrawEntry(vcl::RenderContext& rRenderContext)
281 SfxObjectShell* pShell = SfxObjectShell::Current();
282 if (!pShell)
283 return;
285 SfxStyleSheetBasePool* pPool = pShell->GetStyleSheetPool();
286 SfxStyleSheetBase* pStyle = nullptr;
288 if (!pPool)
289 return;
291 pStyle = pPool->First(m_eStyleFamily);
292 while (pStyle && pStyle->GetName() != m_aStyleName.first
293 && pStyle->GetName() != m_aStyleName.second)
294 pStyle = pPool->Next();
296 if (!pStyle)
297 return;
299 Size aSize(rRenderContext.GetOutputSizePixel());
300 tools::Rectangle aFullRect(Point(0, 0), aSize);
301 tools::Rectangle aContentRect(aFullRect);
303 Color aOriginalColor = rRenderContext.GetFillColor();
304 Color aOriginalLineColor = rRenderContext.GetLineColor();
306 DrawContentBackground(rRenderContext, aContentRect, aOriginalColor);
308 std::optional<SfxItemSet> const pItemSet(pStyle->GetItemSetForPreview());
309 if (!pItemSet)
310 return;
312 Color aFontHighlight = COL_AUTO;
314 sal_Int16 nScriptType
315 = MsLangId::getScriptType(Application::GetSettings().GetUILanguageTag().getLanguageType());
317 sal_uInt16 nFontSlot = SID_ATTR_CHAR_FONT;
318 if (nScriptType == css::i18n::ScriptType::ASIAN)
319 nFontSlot = SID_ATTR_CHAR_CJK_FONT;
320 else if (nScriptType == css::i18n::ScriptType::COMPLEX)
321 nFontSlot = SID_ATTR_CHAR_CTL_FONT;
323 const SvxFontItem* const pFontItem = pItemSet->GetItem<SvxFontItem>(nFontSlot);
324 const SvxFontHeightItem* const pFontHeightItem
325 = pItemSet->GetItem<SvxFontHeightItem>(SID_ATTR_CHAR_FONTHEIGHT);
327 if (pFontItem && pFontHeightItem)
329 Size aFontSize(0, pFontHeightItem->GetHeight());
330 Size aPixelSize(rRenderContext.LogicToPixel(aFontSize, MapMode(pShell->GetMapUnit())));
332 SvxFont aFont = GetFontFromItems(pFontItem, aPixelSize, pItemSet);
333 rRenderContext.SetFont(aFont);
335 Color aFontCol = GetTextColorFromItemSet(pItemSet);
336 if (aFontCol != COL_AUTO)
337 rRenderContext.SetTextColor(aFontCol);
339 aFontHighlight = GetHighlightColorFromItemSet(pItemSet);
341 css::drawing::FillStyle style = GetFillStyleFromItemSet(pItemSet);
343 switch (style)
345 case css::drawing::FillStyle_SOLID:
347 Color aBackCol = GetBackgroundColorFromItemSet(pItemSet);
348 if (aBackCol != COL_AUTO)
349 DrawContentBackground(rRenderContext, aContentRect, aBackCol);
351 break;
353 default:
354 break;
355 //TODO Draw the other background styles: gradient, hatching and bitmap
359 if (aFontHighlight != COL_AUTO)
360 DrawHighlight(rRenderContext, aFontHighlight);
362 DrawText(rRenderContext);
364 rRenderContext.SetFillColor(aOriginalColor);
365 rRenderContext.SetLineColor(aOriginalLineColor);
368 void StyleItemController::DrawContentBackground(vcl::RenderContext& rRenderContext,
369 const tools::Rectangle& aContentRect,
370 const Color& aColor)
372 rRenderContext.SetLineColor(aColor);
373 rRenderContext.SetFillColor(aColor);
374 rRenderContext.DrawRect(aContentRect);
377 void StyleItemController::DrawHighlight(vcl::RenderContext& rRenderContext, Color aFontBack)
379 tools::Rectangle aTextRect;
380 rRenderContext.GetTextBoundRect(aTextRect, m_aStyleName.second);
382 Size aSize = aTextRect.GetSize();
383 aSize.AdjustHeight(aSize.getHeight());
384 aTextRect.SetSize(aSize);
386 Point aPos(0, 0);
387 aPos.AdjustX(LEFT_MARGIN);
388 aPos.AdjustY((rRenderContext.GetOutputHeightPixel() - aTextRect.Bottom()) / 2);
389 aTextRect.SetPos(aPos);
391 rRenderContext.SetLineColor(aFontBack);
392 rRenderContext.SetFillColor(aFontBack);
394 rRenderContext.DrawRect(aTextRect);
397 void StyleItemController::DrawText(vcl::RenderContext& rRenderContext)
399 const SalLayoutGlyphs* layoutGlyphs
400 = SalLayoutGlyphsCache::self()->GetLayoutGlyphs(&rRenderContext, m_aStyleName.second);
401 tools::Rectangle aTextRect;
402 rRenderContext.GetTextBoundRect(aTextRect, m_aStyleName.second, 0, 0, -1, 0, {}, {},
403 layoutGlyphs);
405 Point aPos(0, 0);
406 aPos.AdjustX(LEFT_MARGIN);
407 aPos.AdjustY((rRenderContext.GetOutputHeightPixel() - aTextRect.Bottom()) / 2);
409 rRenderContext.DrawText(aPos, m_aStyleName.second, 0, -1, nullptr, nullptr, layoutGlyphs);
412 StylesPreviewWindow_Base::StylesPreviewWindow_Base(
413 weld::Builder& xBuilder, std::vector<std::pair<OUString, OUString>>&& aDefaultStyles,
414 const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider)
415 : m_xDispatchProvider(xDispatchProvider)
416 , m_xStylesView(xBuilder.weld_icon_view("stylesview"))
417 , m_aUpdateTask(*this)
418 , m_aDefaultStyles(std::move(aDefaultStyles))
420 StylePreviewCache::RegisterClient();
422 m_xStylesView->connect_selection_changed(LINK(this, StylesPreviewWindow_Base, Selected));
423 m_xStylesView->connect_item_activated(LINK(this, StylesPreviewWindow_Base, DoubleClick));
424 m_xStylesView->connect_command(LINK(this, StylesPreviewWindow_Base, DoCommand));
425 m_xStylesView->connect_get_property_tree_elem(
426 LINK(this, StylesPreviewWindow_Base, DoJsonProperty));
428 m_xStatusListener = new StyleStatusListener(this, xDispatchProvider);
430 m_pStylePoolChangeListener.reset(new StylePoolChangeListener(this));
432 RequestStylesListUpdate();
435 IMPL_LINK(StylesPreviewWindow_Base, Selected, weld::IconView&, rIconView, void)
437 OUString sStyleName = rIconView.get_selected_text();
439 css::uno::Sequence<css::beans::PropertyValue> aArgs{
440 comphelper::makePropertyValue("Template", sStyleName),
441 comphelper::makePropertyValue("Family", sal_Int16(SfxStyleFamily::Para))
443 SfxToolBoxControl::Dispatch(m_xDispatchProvider, ".uno:StyleApply", aArgs);
446 IMPL_LINK(StylesPreviewWindow_Base, DoubleClick, weld::IconView&, rIconView, bool)
448 OUString sStyleName = rIconView.get_selected_text();
450 css::uno::Sequence<css::beans::PropertyValue> aArgs{
451 comphelper::makePropertyValue("Param", sStyleName),
452 comphelper::makePropertyValue("Family", sal_Int16(SfxStyleFamily::Para))
454 SfxToolBoxControl::Dispatch(m_xDispatchProvider, ".uno:EditStyle", aArgs);
456 return true;
459 IMPL_LINK(StylesPreviewWindow_Base, DoCommand, const CommandEvent&, rPos, bool)
461 return Command(rPos);
464 StylesPreviewWindow_Base::~StylesPreviewWindow_Base()
466 m_xStatusListener->UnBind();
468 m_aUpdateTask.Stop();
470 StylePreviewCache::UnregisterClient();
474 m_xStatusListener->dispose();
476 catch (css::uno::Exception&)
480 m_xStatusListener = nullptr;
483 void StylesPreviewWindow_Base::Select(const OUString& rStyleName)
485 m_sSelectedStyle = rStyleName;
487 UpdateSelection();
490 void StylesPreviewWindow_Base::UpdateSelection()
492 for (std::vector<std::pair<OUString, OUString>>::size_type i = 0; i < m_aAllStyles.size(); ++i)
494 if (m_aAllStyles[i].first == m_sSelectedStyle || m_aAllStyles[i].second == m_sSelectedStyle)
496 m_xStylesView->select(i);
497 break;
502 void StylesPreviewWindow_Base::RequestStylesListUpdate() { m_aUpdateTask.Start(); }
504 void StylesListUpdateTask::Invoke()
506 m_rStylesList.UpdateStylesList();
507 m_rStylesList.UpdateSelection();
510 static OString extractPngString(const BitmapEx& rBitmap)
512 SvMemoryStream aOStm(65535, 65535);
513 // Use fastest compression "1"
514 css::uno::Sequence<css::beans::PropertyValue> aFilterData{
515 comphelper::makePropertyValue("Compression", sal_Int32(1)),
517 vcl::PngImageWriter aPNGWriter(aOStm);
518 aPNGWriter.setParameters(aFilterData);
519 if (aPNGWriter.write(rBitmap))
521 css::uno::Sequence<sal_Int8> aSeq(static_cast<sal_Int8 const*>(aOStm.GetData()),
522 aOStm.Tell());
523 OStringBuffer aBuffer("data:image/png;base64,");
524 ::comphelper::Base64::encode(aBuffer, aSeq);
525 return aBuffer.makeStringAndClear();
528 return "";
531 // 0: json writer, 1: TreeIter, 2: property. returns true if supported
532 IMPL_LINK(StylesPreviewWindow_Base, DoJsonProperty, const weld::json_prop_query&, rQuery, bool)
534 if (std::get<2>(rQuery) != "image")
535 return false;
537 const weld::TreeIter& rIter = std::get<1>(rQuery);
538 OUString sStyleId(m_xStylesView->get_id(rIter));
539 OUString sStyleName(m_xStylesView->get_text(rIter));
540 OString sBase64Png(GetCachedPreviewJson(std::pair<OUString, OUString>(sStyleId, sStyleName)));
541 if (sBase64Png.isEmpty())
542 return false;
544 tools::JsonWriter& rJsonWriter = std::get<0>(rQuery);
545 rJsonWriter.put("image", sBase64Png);
547 return true;
550 VclPtr<VirtualDevice>
551 StylesPreviewWindow_Base::GetCachedPreview(const std::pair<OUString, OUString>& rStyle)
553 auto aFound = StylePreviewCache::Get().find(rStyle.second);
554 if (aFound != StylePreviewCache::Get().end())
555 return StylePreviewCache::Get()[rStyle.second];
556 else
558 VclPtr<VirtualDevice> pImg = VclPtr<VirtualDevice>::Create();
559 const Size aSize(100, 30);
560 pImg->SetOutputSizePixel(aSize);
562 StyleItemController aStyleController(rStyle);
563 aStyleController.Paint(*pImg);
564 StylePreviewCache::Get()[rStyle.second] = pImg;
566 return pImg;
570 OString StylesPreviewWindow_Base::GetCachedPreviewJson(const std::pair<OUString, OUString>& rStyle)
572 auto aJsonFound = StylePreviewCache::GetJson().find(rStyle.second);
573 if (aJsonFound != StylePreviewCache::GetJson().end())
574 return StylePreviewCache::GetJson()[rStyle.second];
576 VclPtr<VirtualDevice> xDev = GetCachedPreview(rStyle);
577 BitmapEx aBitmap(xDev->GetBitmapEx(Point(0, 0), xDev->GetOutputSize()));
578 OString sResult = extractPngString(aBitmap);
579 StylePreviewCache::GetJson()[rStyle.second] = sResult;
580 return sResult;
583 void StylesPreviewWindow_Base::UpdateStylesList()
585 m_aAllStyles = m_aDefaultStyles;
587 SfxObjectShell* pDocShell = SfxObjectShell::Current();
588 SfxStyleSheetBasePool* pStyleSheetPool = nullptr;
590 if (pDocShell)
591 pStyleSheetPool = pDocShell->GetStyleSheetPool();
593 if (pStyleSheetPool)
595 auto xIter = pStyleSheetPool->CreateIterator(SfxStyleFamily::Para,
596 SfxStyleSearchBits::UserDefined);
598 SfxStyleSheetBase* pStyle = xIter->First();
600 while (pStyle)
602 OUString sName(pStyle->GetName());
603 m_aAllStyles.push_back(std::pair<OUString, OUString>(sName, sName));
604 pStyle = xIter->Next();
608 m_xStylesView->freeze();
609 m_xStylesView->clear();
610 // for online we can skip inserting the preview into the IconView and rely
611 // on DoJsonProperty to provide the image to clients
612 const bool bNeedInsertPreview = !comphelper::LibreOfficeKit::isActive();
613 for (const auto& rStyle : m_aAllStyles)
615 VclPtr<VirtualDevice> pImg = bNeedInsertPreview ? GetCachedPreview(rStyle) : nullptr;
616 m_xStylesView->append(rStyle.first, rStyle.second, pImg);
618 m_xStylesView->thaw();
621 StylesPreviewWindow_Impl::StylesPreviewWindow_Impl(
622 vcl::Window* pParent, std::vector<std::pair<OUString, OUString>>&& aDefaultStyles,
623 const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider)
624 : InterimItemWindow(pParent, "svx/ui/stylespreview.ui", "ApplyStyleBox", true,
625 reinterpret_cast<sal_uInt64>(SfxViewShell::Current()))
626 , StylesPreviewWindow_Base(*m_xBuilder, std::move(aDefaultStyles), xDispatchProvider)
628 SetOptimalSize();
631 StylesPreviewWindow_Impl::~StylesPreviewWindow_Impl() { disposeOnce(); }
633 void StylesPreviewWindow_Impl::dispose()
635 m_xStylesView.reset();
637 InterimItemWindow::dispose();
640 void StylesPreviewWindow_Impl::SetOptimalSize() { SetSizePixel(get_preferred_size()); }
642 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */