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>
27
29
32{
34
35public:
37 StylesPreviewWindow_Base* pPreviewControl,
38 const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider);
39
40 void StateChangedAtStatusListener(SfxItemState eState, const SfxPoolItem* pState) override;
41};
42
45{
48
49public:
52
53 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
54};
55
57{
58 static constexpr unsigned LEFT_MARGIN = 8;
59
61 std::pair<OUString, OUString> m_aStyleName;
62
63public:
64 StyleItemController(const std::pair<OUString, OUString>& aStyleName);
65
66 void Paint(vcl::RenderContext& rRenderContext);
67
68private:
69 void DrawEntry(vcl::RenderContext& rRenderContext);
70 void DrawText(vcl::RenderContext& rRenderContext);
71 void DrawHighlight(vcl::RenderContext& rRenderContext, Color aFontBack);
72 static void DrawContentBackground(vcl::RenderContext& rRenderContext,
73 const tools::Rectangle& aContentRect, const Color& aColor);
74};
75
77{
79
80public:
82 : Idle("StylesListUpdateTask")
83 , m_rStylesList(rStylesList)
84 {
85 SetPriority(TaskPriority::HIGH_IDLE);
86 }
87
88 virtual void Invoke() override;
89};
90
92{
94
95protected:
96 static constexpr unsigned STYLES_COUNT = 6;
97
98 css::uno::Reference<css::frame::XDispatchProvider> m_xDispatchProvider;
99
100 std::unique_ptr<weld::IconView> m_xStylesView;
101
103
105 std::unique_ptr<StylePoolChangeListener> m_pStylePoolChangeListener;
106
107 std::vector<std::pair<OUString, OUString>> m_aDefaultStyles;
108 std::vector<std::pair<OUString, OUString>> m_aAllStyles;
109
111
112 DECL_LINK(Selected, weld::IconView&, void);
113 DECL_LINK(DoubleClick, weld::IconView&, bool);
114 DECL_LINK(DoCommand, const CommandEvent&, bool);
115
116public:
118 weld::Builder& xBuilder, std::vector<std::pair<OUString, OUString>>&& aDefaultStyles,
119 const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider);
121
122 void Select(const OUString& rStyleName);
124
125private:
126 void UpdateStylesList();
127 void UpdateSelection();
128 bool Command(const CommandEvent& rEvent);
129};
130
132{
133public:
135 vcl::Window* pParent, std::vector<std::pair<OUString, OUString>>&& aDefaultStyles,
136 const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider);
138
139 void dispose();
140
141 void SetOptimalSize();
142};
143
144#endif
145
146/* 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)
static void DrawContentBackground(vcl::RenderContext &rRenderContext, const tools::Rectangle &aContentRect, const Color &aColor)
StyleItemController(const std::pair< OUString, OUString > &aStyleName)
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
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
css::uno::Reference< css::frame::XDispatchProvider > m_xDispatchProvider
std::vector< std::pair< OUString, OUString > > m_aAllStyles
bool Command(const CommandEvent &rEvent)
void Select(const OUString &rStyleName)
DECL_LINK(Selected, weld::IconView &, void)
StylesPreviewWindow_Base(weld::Builder &xBuilder, std::vector< std::pair< OUString, OUString > > &&aDefaultStyles, const css::uno::Reference< css::frame::XDispatchProvider > &xDispatchProvider)
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::XDispatchProvider > &xDispatchProvider)
void SetPriority(TaskPriority ePriority)
SfxItemState
SfxStyleFamily