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 , mxToolBoxFontColorSw(m_xBuilder->weld_toolbar("colorbar_writer"))
53 , mxToolBoxFontColorSwDispatch(new ToolbarUnoDispatcher(*mxToolBoxFontColorSw, *m_xBuilder, rxFrame))
54 , mxToolBoxFontColor(m_xBuilder->weld_toolbar("colorbar_others"))
55 , mxToolBoxFontColorDispatch(new ToolbarUnoDispatcher(*mxToolBoxFontColor, *m_xBuilder, rxFrame))
56 , mxToolBoxBackgroundColor(m_xBuilder->weld_toolbar("colorbar_background"))
57 , mxToolBoxBackgroundColorDispatch(new ToolbarUnoDispatcher(*mxToolBoxBackgroundColor, *m_xBuilder, rxFrame))
58 , mxResetBar(m_xBuilder->weld_toolbar("resetattr"))
59 , mxResetBarDispatch(new ToolbarUnoDispatcher(*mxResetBar, *m_xBuilder, rxFrame))
60 , mxDefaultBar(m_xBuilder->weld_toolbar("defaultattr"))
61 , mxDefaultBarDispatch(new ToolbarUnoDispatcher(*mxDefaultBar, *m_xBuilder, rxFrame))
62 , mxPositionBar(m_xBuilder->weld_toolbar("position"))
63 , mxPositionBarDispatch(new ToolbarUnoDispatcher(*mxPositionBar, *m_xBuilder, rxFrame))
64 , mxSpacingBar(m_xBuilder->weld_toolbar("spacingbar"))
65 , mxSpacingBarDispatch(new ToolbarUnoDispatcher(*mxSpacingBar, *m_xBuilder, rxFrame))
66{
67 bool isMobilePhone = false;
68 const SfxViewShell* pViewShell = SfxViewShell::Current();
70 pViewShell && pViewShell->isLOKMobilePhone())
71 isMobilePhone = true;
72 mxSpacingBar->set_visible(!isMobilePhone);
73}
74
76{
77 mxResetBarDispatch.reset();
87 mxFontDispatch.reset();
88
89 mxResetBar.reset();
90 mxDefaultBar.reset();
91 mxPositionBar.reset();
92 mxSpacingBar.reset();
94 mxToolBoxFontColor.reset();
96 mxFontAdjust.reset();
97 mxFontEffects.reset();
98 mxFontHeight.reset();
99 mxFont.reset();
100}
101
103 const vcl::EnumContext& rContext)
104{
105 if (maContext == rContext)
106 return;
107
108 maContext = rContext;
109
110 bool bWriterText = false;
111 bool bDrawText = false;
112 bool bCalcText = false;
113
115 {
116 case CombinedEnumContext(Application::Calc, Context::DrawText):
117 case CombinedEnumContext(Application::WriterVariants, Context::DrawText):
118 case CombinedEnumContext(Application::WriterVariants, Context::Annotation):
119 case CombinedEnumContext(Application::DrawImpress, Context::DrawText):
120 case CombinedEnumContext(Application::DrawImpress, Context::Text):
121 case CombinedEnumContext(Application::DrawImpress, Context::Table):
122 case CombinedEnumContext(Application::DrawImpress, Context::OutlineText):
123 case CombinedEnumContext(Application::DrawImpress, Context::Draw):
124 case CombinedEnumContext(Application::DrawImpress, Context::TextObject):
125 case CombinedEnumContext(Application::DrawImpress, Context::Graphic):
126 bDrawText = true;
127 break;
128
129 case CombinedEnumContext(Application::WriterVariants, Context::Text):
130 case CombinedEnumContext(Application::WriterVariants, Context::Table):
131 bWriterText = true;
132 break;
133
134 case CombinedEnumContext(Application::Calc, Context::Text):
135 case CombinedEnumContext(Application::Calc, Context::Table):
136 case CombinedEnumContext(Application::Calc, Context::Cell):
137 case CombinedEnumContext(Application::Calc, Context::EditCell):
138 case CombinedEnumContext(Application::Calc, Context::Grid):
139 bCalcText = true;
140 break;
141
142 default:
143 break;
144 }
145
146 mxToolBoxFontColor->set_visible(!bWriterText);
147 mxToolBoxFontColorSw->set_visible(bWriterText);
148 mxToolBoxBackgroundColor->set_visible(bDrawText);
149 mxResetBar->set_visible(bWriterText || bCalcText);
150 mxDefaultBar->set_visible(bDrawText);
151}
152
153} // end of namespace svx::sidebar
154
155/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define CombinedEnumContext(a, e)
bool isLOKMobilePhone() const
static 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< ToolbarUnoDispatcher > mxToolBoxFontColorSwDispatch
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 > mxToolBoxFontColorSw
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