Bump version to 24.04.3.4
[LibreOffice.git] / svx / source / sidebar / text / TextPropertyPanel.cxx
blob5b4e907cd86bc1be5f1302f28d367b304a0a1d59
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "TextPropertyPanel.hxx"
22 #include <com/sun/star/lang/IllegalArgumentException.hpp>
23 #include <comphelper/lok.hxx>
24 #include <sfx2/viewsh.hxx>
26 using namespace css;
28 namespace svx::sidebar {
30 std::unique_ptr<PanelLayout> TextPropertyPanel::Create (
31 weld::Widget* pParent,
32 const css::uno::Reference<css::frame::XFrame>& rxFrame)
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);
39 return std::make_unique<TextPropertyPanel>(pParent, rxFrame);
42 TextPropertyPanel::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))
65 bool isMobilePhone = false;
66 const SfxViewShell* pViewShell = SfxViewShell::Current();
67 if (comphelper::LibreOfficeKit::isActive() &&
68 pViewShell && pViewShell->isLOKMobilePhone())
69 isMobilePhone = true;
70 mxSpacingBar->set_visible(!isMobilePhone);
73 TextPropertyPanel::~TextPropertyPanel()
75 mxResetBarDispatch.reset();
76 mxDefaultBarDispatch.reset();
77 mxPositionBarDispatch.reset();
78 mxSpacingBarDispatch.reset();
79 mxToolBoxFontColorDispatch.reset();
80 mxToolBoxBackgroundColorDispatch.reset();
81 mxFontAdjustDispatch.reset();
82 mxFontEffectsDispatch.reset();
83 mxFontHeightDispatch.reset();
84 mxFontDispatch.reset();
86 mxResetBar.reset();
87 mxDefaultBar.reset();
88 mxPositionBar.reset();
89 mxSpacingBar.reset();
90 mxToolBoxFontColor.reset();
91 mxToolBoxBackgroundColor.reset();
92 mxFontAdjust.reset();
93 mxFontEffects.reset();
94 mxFontHeight.reset();
95 mxFont.reset();
98 void TextPropertyPanel::HandleContextChange (
99 const vcl::EnumContext& rContext)
101 if (maContext == rContext)
102 return;
104 maContext = rContext;
106 bool bWriterText = false;
107 bool bDrawText = false;
108 bool bCalcText = false;
110 switch (maContext.GetCombinedContext_DI())
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;
125 case CombinedEnumContext(Application::WriterVariants, Context::Text):
126 case CombinedEnumContext(Application::WriterVariants, Context::Table):
127 bWriterText = true;
128 break;
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;
138 default:
139 break;
142 mxToolBoxBackgroundColor->set_visible(bWriterText || bDrawText);
143 mxResetBar->set_visible(bWriterText || bCalcText);
144 mxDefaultBar->set_visible(bDrawText);
147 } // end of namespace svx::sidebar
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */