LibreOffice Module svx (master) 1
TextPropertyPanel.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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#include "TextPropertyPanel.hxx"
21
22#include <com/sun/star/lang/IllegalArgumentException.hpp>
23#include <comphelper/lok.hxx>
24#include <sfx2/viewsh.hxx>
25
26using namespace css;
27
28namespace svx::sidebar {
29
30std::unique_ptr<PanelLayout> TextPropertyPanel::Create (
31 weld::Widget* pParent,
32 const css::uno::Reference<css::frame::XFrame>& rxFrame)
33{
34 if (pParent == nullptr)
35 throw lang::IllegalArgumentException("no parent Window given to TextPropertyPanel::Create", nullptr, 0);
36 if ( ! rxFrame.is())
37 throw lang::IllegalArgumentException("no XFrame given to TextPropertyPanel::Create", nullptr, 1);
38
39 return std::make_unique<TextPropertyPanel>(pParent, rxFrame);
40}
41
42TextPropertyPanel::TextPropertyPanel(weld::Widget* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame)
43 : PanelLayout(pParent, "SidebarTextPanel", "svx/ui/sidebartextpanel.ui")
44 , mxFont(m_xBuilder->weld_toolbar("font"))
45 , mxFontDispatch(new ToolbarUnoDispatcher(*mxFont, *m_xBuilder, rxFrame))
46 , mxFontHeight(m_xBuilder->weld_toolbar("fontheight"))
47 , mxFontHeightDispatch(new ToolbarUnoDispatcher(*mxFontHeight, *m_xBuilder, rxFrame))
48 , mxFontEffects(m_xBuilder->weld_toolbar("fonteffects"))
49 , mxFontEffectsDispatch(new ToolbarUnoDispatcher(*mxFontEffects, *m_xBuilder, rxFrame))
50 , mxFontAdjust(m_xBuilder->weld_toolbar("fontadjust"))
51 , mxFontAdjustDispatch(new ToolbarUnoDispatcher(*mxFontAdjust, *m_xBuilder, rxFrame))
52 , mxToolBoxFontColor(m_xBuilder->weld_toolbar("colorbar"))
53 , mxToolBoxFontColorDispatch(new ToolbarUnoDispatcher(*mxToolBoxFontColor, *m_xBuilder, rxFrame))
54 , mxToolBoxBackgroundColor(m_xBuilder->weld_toolbar("colorbar_background"))
55 , mxToolBoxBackgroundColorDispatch(new ToolbarUnoDispatcher(*mxToolBoxBackgroundColor, *m_xBuilder, rxFrame))
56 , mxResetBar(m_xBuilder->weld_toolbar("resetattr"))
57 , mxResetBarDispatch(new ToolbarUnoDispatcher(*mxResetBar, *m_xBuilder, rxFrame))
58 , mxDefaultBar(m_xBuilder->weld_toolbar("defaultattr"))
59 , mxDefaultBarDispatch(new ToolbarUnoDispatcher(*mxDefaultBar, *m_xBuilder, rxFrame))
60 , mxPositionBar(m_xBuilder->weld_toolbar("position"))
61 , mxPositionBarDispatch(new ToolbarUnoDispatcher(*mxPositionBar, *m_xBuilder, rxFrame))
62 , mxSpacingBar(m_xBuilder->weld_toolbar("spacingbar"))
63 , mxSpacingBarDispatch(new ToolbarUnoDispatcher(*mxSpacingBar, *m_xBuilder, rxFrame))
64{
65 bool isMobilePhone = false;
66 const SfxViewShell* pViewShell = SfxViewShell::Current();
68 pViewShell && pViewShell->isLOKMobilePhone())
69 isMobilePhone = true;
70 mxSpacingBar->set_visible(!isMobilePhone);
71}
72
74{
75 mxResetBarDispatch.reset();
84 mxFontDispatch.reset();
85
86 mxResetBar.reset();
87 mxDefaultBar.reset();
88 mxPositionBar.reset();
89 mxSpacingBar.reset();
90 mxToolBoxFontColor.reset();
92 mxFontAdjust.reset();
93 mxFontEffects.reset();
94 mxFontHeight.reset();
95 mxFont.reset();
96}
97
99 const vcl::EnumContext& rContext)
100{
101 if (maContext == rContext)
102 return;
103
104 maContext = rContext;
105
106 bool bWriterText = false;
107 bool bDrawText = false;
108 bool bCalcText = false;
109
111 {
112 case CombinedEnumContext(Application::Calc, Context::DrawText):
113 case CombinedEnumContext(Application::WriterVariants, Context::DrawText):
114 case CombinedEnumContext(Application::WriterVariants, Context::Annotation):
115 case CombinedEnumContext(Application::DrawImpress, Context::DrawText):
116 case CombinedEnumContext(Application::DrawImpress, Context::Text):
117 case CombinedEnumContext(Application::DrawImpress, Context::Table):
118 case CombinedEnumContext(Application::DrawImpress, Context::OutlineText):
119 case CombinedEnumContext(Application::DrawImpress, Context::Draw):
120 case CombinedEnumContext(Application::DrawImpress, Context::TextObject):
121 case CombinedEnumContext(Application::DrawImpress, Context::Graphic):
122 bDrawText = true;
123 break;
124
125 case CombinedEnumContext(Application::WriterVariants, Context::Text):
126 case CombinedEnumContext(Application::WriterVariants, Context::Table):
127 bWriterText = true;
128 break;
129
130 case CombinedEnumContext(Application::Calc, Context::Text):
131 case CombinedEnumContext(Application::Calc, Context::Table):
132 case CombinedEnumContext(Application::Calc, Context::Cell):
133 case CombinedEnumContext(Application::Calc, Context::EditCell):
134 case CombinedEnumContext(Application::Calc, Context::Grid):
135 bCalcText = true;
136 break;
137
138 default:
139 break;
140 }
141
142 mxToolBoxBackgroundColor->set_visible(bWriterText || bDrawText);
143 mxResetBar->set_visible(bWriterText || bCalcText);
144 mxDefaultBar->set_visible(bDrawText);
145}
146
147} // end of namespace svx::sidebar
148
149/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define CombinedEnumContext(a, e)
bool isLOKMobilePhone() const
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
std::unique_ptr< weld::Toolbar > mxFontAdjust
std::unique_ptr< ToolbarUnoDispatcher > mxFontAdjustDispatch
std::unique_ptr< weld::Toolbar > mxResetBar
std::unique_ptr< weld::Toolbar > mxSpacingBar
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, const css::uno::Reference< css::frame::XFrame > &rxFrame)
std::unique_ptr< ToolbarUnoDispatcher > mxFontDispatch
virtual void HandleContextChange(const vcl::EnumContext &rContext) override
std::unique_ptr< weld::Toolbar > mxPositionBar
TextPropertyPanel(weld::Widget *pParent, const css::uno::Reference< css::frame::XFrame > &rxFrame)
std::unique_ptr< weld::Toolbar > mxToolBoxFontColor
std::unique_ptr< weld::Toolbar > mxFontEffects
std::unique_ptr< ToolbarUnoDispatcher > mxDefaultBarDispatch
std::unique_ptr< ToolbarUnoDispatcher > mxPositionBarDispatch
std::unique_ptr< weld::Toolbar > mxFontHeight
std::unique_ptr< ToolbarUnoDispatcher > mxResetBarDispatch
std::unique_ptr< weld::Toolbar > mxDefaultBar
std::unique_ptr< weld::Toolbar > mxToolBoxBackgroundColor
std::unique_ptr< ToolbarUnoDispatcher > mxFontEffectsDispatch
std::unique_ptr< ToolbarUnoDispatcher > mxSpacingBarDispatch
std::unique_ptr< ToolbarUnoDispatcher > mxToolBoxFontColorDispatch
std::unique_ptr< ToolbarUnoDispatcher > mxFontHeightDispatch
std::unique_ptr< ToolbarUnoDispatcher > mxToolBoxBackgroundColorDispatch
std::unique_ptr< weld::Toolbar > mxFont
sal_Int32 GetCombinedContext_DI() const
uno::Reference< rendering::XCanvasFont > mxFont