LibreOffice Module svx (master) 1
StylesPreviewWindow.hxx
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
20#ifndef INCLUDED_SVX_SOURCE_INC_STYLES_PREVIEW_WINDOW_HXX
21#define INCLUDED_SVX_SOURCE_INC_STYLES_PREVIEW_WINDOW_HXX
22
24#include <svl/style.hxx>
25#include <com/sun/star/frame/XDispatchProvider.hpp>
26#include <com/sun/star/frame/XFrame.hpp>
28
30
33{
35
36public:
38 StylesPreviewWindow_Base* pPreviewControl,
39 const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider);
40
41 void StateChangedAtStatusListener(SfxItemState eState, const SfxPoolItem* pState) override;
42};
43
46{
49
50public:
53
54 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
55};
56
58{
59 static constexpr unsigned LEFT_MARGIN = 8;
60
62 std::pair<OUString, OUString> m_aStyleName;
63
64public:
65 StyleItemController(std::pair<OUString, OUString> aStyleName);
66
67 void Paint(vcl::RenderContext& rRenderContext);
68
69private:
70 void DrawEntry(vcl::RenderContext& rRenderContext);
71 void DrawText(vcl::RenderContext& rRenderContext);
72 void DrawHighlight(vcl::RenderContext& rRenderContext, Color aFontBack);
73 static void DrawContentBackground(vcl::RenderContext& rRenderContext,
74 const tools::Rectangle& aContentRect, const Color& aColor);
75};
76
77class StylesListUpdateTask final : public Idle
78{
80
81public:
83 : Idle("StylesListUpdateTask")
84 , m_rStylesList(rStylesList)
85 {
86 SetPriority(TaskPriority::HIGH_IDLE);
87 }
88
89 virtual void Invoke() override;
90};
91
93{
95
96protected:
97 static constexpr unsigned STYLES_COUNT = 6;
98
99 css::uno::Reference<css::frame::XFrame> m_xFrame;
100
101 std::unique_ptr<weld::IconView> m_xStylesView;
102
104
106 std::unique_ptr<StylePoolChangeListener> m_pStylePoolChangeListener;
107
108 std::vector<std::pair<OUString, OUString>> m_aDefaultStyles;
109 std::vector<std::pair<OUString, OUString>> m_aAllStyles;
110
112
113 DECL_LINK(Selected, weld::IconView&, void);
114 DECL_LINK(DoubleClick, weld::IconView&, bool);
115 DECL_LINK(DoCommand, const CommandEvent&, bool);
116 DECL_LINK(DoJsonProperty, const weld::json_prop_query&, bool);
117
118public:
120 std::vector<std::pair<OUString, OUString>>&& aDefaultStyles,
121 const css::uno::Reference<css::frame::XFrame>& xFrame);
123
124 void Select(const OUString& rStyleName);
126 static VclPtr<VirtualDevice> GetCachedPreview(const std::pair<OUString, OUString>& rStyle);
127 static OString GetCachedPreviewJson(const std::pair<OUString, OUString>& rStyle);
128
129private:
130 void UpdateStylesList();
131 void UpdateSelection();
132 bool Command(const CommandEvent& rEvent);
133};
134
136{
137public:
139 std::vector<std::pair<OUString, OUString>>&& aDefaultStyles,
140 const css::uno::Reference<css::frame::XFrame>& xFrame);
142
143 void dispose();
144
145 void SetOptimalSize();
146};
147
148#endif
149
150/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
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
StylesListUpdateTask(StylesPreviewWindow_Base &rStylesList)
StylesPreviewWindow_Base & m_rStylesList
StylesPreviewWindow_Base(weld::Builder &xBuilder, std::vector< std::pair< OUString, OUString > > &&aDefaultStyles, const css::uno::Reference< css::frame::XFrame > &xFrame)
DECL_LINK(DoJsonProperty, const weld::json_prop_query &, bool)
std::vector< std::pair< OUString, OUString > > m_aDefaultStyles
DECL_LINK(DoCommand, const CommandEvent &, bool)
static constexpr unsigned STYLES_COUNT
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)
DECL_LINK(Selected, weld::IconView &, void)
rtl::Reference< StyleStatusListener > m_xStatusListener
std::unique_ptr< StylePoolChangeListener > m_pStylePoolChangeListener
DECL_LINK(DoubleClick, weld::IconView &, bool)
StylesPreviewWindow_Impl(vcl::Window *pParent, std::vector< std::pair< OUString, OUString > > &&aDefaultStyles, const css::uno::Reference< css::frame::XFrame > &xFrame)
void SetPriority(TaskPriority ePriority)
std::tuple< tools::JsonWriter &, const TreeIter &, std::string_view > json_prop_query
SfxItemState
SfxStyleFamily
Reference< XFrame > xFrame