summaryrefslogtreecommitdiffstats
path: root/svx/source/sidebar/text
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /svx/source/sidebar/text
parentInitial commit. (diff)
downloadlibreoffice-upstream.tar.xz
libreoffice-upstream.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'svx/source/sidebar/text')
-rw-r--r--svx/source/sidebar/text/TextCharacterSpacingControl.cxx224
-rw-r--r--svx/source/sidebar/text/TextCharacterSpacingControl.hxx69
-rw-r--r--svx/source/sidebar/text/TextCharacterSpacingPopup.cxx82
-rw-r--r--svx/source/sidebar/text/TextPropertyPanel.cxx155
-rw-r--r--svx/source/sidebar/text/TextPropertyPanel.hxx78
-rw-r--r--svx/source/sidebar/text/TextUnderlineControl.cxx141
-rw-r--r--svx/source/sidebar/text/TextUnderlineControl.hxx60
-rw-r--r--svx/source/sidebar/text/TextUnderlinePopup.cxx82
8 files changed, 891 insertions, 0 deletions
diff --git a/svx/source/sidebar/text/TextCharacterSpacingControl.cxx b/svx/source/sidebar/text/TextCharacterSpacingControl.cxx
new file mode 100644
index 000000000..ad9650477
--- /dev/null
+++ b/svx/source/sidebar/text/TextCharacterSpacingControl.cxx
@@ -0,0 +1,224 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#include <sfx2/bindings.hxx>
+#include "TextCharacterSpacingControl.hxx"
+#include <unotools/viewoptions.hxx>
+#include <editeng/editids.hrc>
+#include <editeng/kernitem.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <TextCharacterSpacingPopup.hxx>
+#include <svl/itempool.hxx>
+#include <helpids.h>
+
+#include <com/sun/star/beans/NamedValue.hpp>
+
+#define SPACING_VERY_TIGHT -30
+#define SPACING_TIGHT -15
+#define SPACING_NORMAL 0
+#define SPACING_LOOSE 30
+#define SPACING_VERY_LOOSE 60
+
+namespace svx {
+
+TextCharacterSpacingControl::TextCharacterSpacingControl(TextCharacterSpacingPopup* pControl, weld::Widget* pParent)
+ : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/textcharacterspacingcontrol.ui", "TextCharacterSpacingControl")
+ , mnCustomKern(0)
+ , mnLastCus(SPACING_NOCUSTOM)
+ , mxEditKerning(m_xBuilder->weld_metric_spin_button("kerning", FieldUnit::POINT))
+ , mxTight(m_xBuilder->weld_button("tight"))
+ , mxVeryTight(m_xBuilder->weld_button("very_tight"))
+ , mxNormal(m_xBuilder->weld_button("normal"))
+ , mxLoose(m_xBuilder->weld_button("loose"))
+ , mxVeryLoose(m_xBuilder->weld_button("very_loose"))
+ , mxLastCustom(m_xBuilder->weld_button("last_custom"))
+ , mxControl(pControl)
+{
+ mxEditKerning->connect_value_changed(LINK(this, TextCharacterSpacingControl, KerningModifyHdl));
+ mxEditKerning->set_help_id(HID_SPACING_MB_KERN);
+
+ Link<weld::Button&,void> aLink = LINK(this, TextCharacterSpacingControl, PredefinedValuesHdl);
+ mxNormal->connect_clicked(aLink);
+ mxVeryTight->connect_clicked(aLink);
+ mxTight->connect_clicked(aLink);
+ mxVeryLoose->connect_clicked(aLink);
+ mxLoose->connect_clicked(aLink);
+ mxLastCustom->connect_clicked(aLink);
+
+ Initialize();
+}
+
+void TextCharacterSpacingControl::GrabFocus()
+{
+ tools::Long nKerning = mxEditKerning->get_value(FieldUnit::NONE);
+ switch (nKerning)
+ {
+ case SPACING_VERY_TIGHT:
+ mxVeryTight->grab_focus();
+ break;
+ case SPACING_TIGHT:
+ mxTight->grab_focus();
+ break;
+ case SPACING_NORMAL:
+ mxNormal->grab_focus();
+ break;
+ case SPACING_LOOSE:
+ mxLoose->grab_focus();
+ break;
+ case SPACING_VERY_LOOSE:
+ mxVeryLoose->grab_focus();
+ break;
+ default:
+ if (nKerning == mnCustomKern)
+ mxLastCustom->grab_focus();
+ else
+ mxEditKerning->grab_focus();
+ }
+}
+
+TextCharacterSpacingControl::~TextCharacterSpacingControl()
+{
+ if (mnLastCus == SPACING_CLOSE_BY_CUS_EDIT)
+ {
+ SvtViewOptions aWinOpt(EViewType::Window, SIDEBAR_SPACING_GLOBAL_VALUE);
+ css::uno::Sequence<css::beans::NamedValue> aSeq
+ { { "Spacing", css::uno::Any(OUString::number(mnCustomKern)) } };
+ aWinOpt.SetUserData(aSeq);
+ }
+}
+
+void TextCharacterSpacingControl::Initialize()
+{
+ const SvxKerningItem* pKerningItem(nullptr);
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ SfxItemState eState = pViewFrm ? pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_CHAR_KERNING, pKerningItem) : SfxItemState::UNKNOWN;
+
+ tools::Long nKerning = 0;
+
+ if(pKerningItem)
+ nKerning = pKerningItem->GetValue();
+
+ SvtViewOptions aWinOpt(EViewType::Window, SIDEBAR_SPACING_GLOBAL_VALUE);
+ if(aWinOpt.Exists())
+ {
+ css::uno::Sequence<css::beans::NamedValue> aSeq = aWinOpt.GetUserData();
+ OUString aTmp;
+ if(aSeq.hasElements())
+ aSeq[0].Value >>= aTmp;
+
+ OUString aWinData(aTmp);
+ mnCustomKern = aWinData.toInt32();
+ mnLastCus = SPACING_CLOSE_BY_CUS_EDIT;
+ }
+ else
+ {
+ mnLastCus = SPACING_NOCUSTOM;
+ }
+
+ if(eState >= SfxItemState::DEFAULT)
+ {
+ MapUnit eUnit = GetCoreMetric();
+ MapUnit eOrgUnit = eUnit;
+ tools::Long nBig = mxEditKerning->normalize(nKerning);
+ nKerning = OutputDevice::LogicToLogic(nBig, eOrgUnit, MapUnit::MapPoint);
+ mxEditKerning->set_value(nKerning, FieldUnit::NONE);
+ }
+ else if(SfxItemState::DISABLED == eState)
+ {
+ mxEditKerning->set_text(OUString());
+ mxEditKerning->set_sensitive(false);
+ }
+ else
+ {
+ mxEditKerning->set_text(OUString());
+ mxEditKerning->set_sensitive(false);
+ }
+}
+
+void TextCharacterSpacingControl::ExecuteCharacterSpacing(tools::Long nValue, bool bClose)
+{
+ MapUnit eUnit = GetCoreMetric();
+
+ tools::Long nSign = (nValue < 0) ? -1 : 1;
+ nValue = nValue * nSign;
+
+ tools::Long nVal = OutputDevice::LogicToLogic(nValue, MapUnit::MapPoint, eUnit);
+ short nKern = (nValue == 0) ? 0 : static_cast<short>(mxEditKerning->denormalize(nVal));
+
+ SvxKerningItem aKernItem(nSign * nKern, SID_ATTR_CHAR_KERNING);
+
+ if (SfxViewFrame* pViewFrm = SfxViewFrame::Current())
+ {
+ pViewFrm->GetBindings().GetDispatcher()->ExecuteList(SID_ATTR_CHAR_KERNING,
+ SfxCallMode::RECORD, { &aKernItem });
+ }
+
+ if (bClose)
+ mxControl->EndPopupMode();
+}
+
+IMPL_LINK(TextCharacterSpacingControl, PredefinedValuesHdl, weld::Button&, rControl, void)
+{
+ mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
+
+ if (&rControl == mxNormal.get())
+ {
+ ExecuteCharacterSpacing(SPACING_NORMAL);
+ }
+ else if (&rControl == mxVeryTight.get())
+ {
+ ExecuteCharacterSpacing(SPACING_VERY_TIGHT);
+ }
+ else if (&rControl == mxTight.get())
+ {
+ ExecuteCharacterSpacing(SPACING_TIGHT);
+ }
+ else if (&rControl == mxVeryLoose.get())
+ {
+ ExecuteCharacterSpacing(SPACING_VERY_LOOSE);
+ }
+ else if (&rControl == mxLoose.get())
+ {
+ ExecuteCharacterSpacing(SPACING_LOOSE);
+ }
+ else if (&rControl == mxLastCustom.get())
+ {
+ ExecuteCharacterSpacing(mnCustomKern);
+ }
+}
+
+IMPL_LINK_NOARG(TextCharacterSpacingControl, KerningModifyHdl, weld::MetricSpinButton&, void)
+{
+ mnLastCus = SPACING_CLOSE_BY_CUS_EDIT;
+ mnCustomKern = mxEditKerning->get_value(FieldUnit::NONE);
+
+ ExecuteCharacterSpacing(mnCustomKern, false);
+}
+
+MapUnit TextCharacterSpacingControl::GetCoreMetric()
+{
+ SfxItemPool &rPool = SfxGetpApp()->GetPool();
+ sal_uInt16 nWhich = rPool.GetWhich(SID_ATTR_CHAR_KERNING);
+ return rPool.GetMetric(nWhich);
+}
+
+} // end of namespace svx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sidebar/text/TextCharacterSpacingControl.hxx b/svx/source/sidebar/text/TextCharacterSpacingControl.hxx
new file mode 100644
index 000000000..a8ce8b7fb
--- /dev/null
+++ b/svx/source/sidebar/text/TextCharacterSpacingControl.hxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SVX_SOURCE_SIDEBAR_TEXT_TEXTCHARACTERSPACINGCONTROL_HXX
+#define INCLUDED_SVX_SOURCE_SIDEBAR_TEXT_TEXTCHARACTERSPACINGCONTROL_HXX
+
+#include <svtools/toolbarmenu.hxx>
+
+namespace svx {
+#define SPACING_NOCUSTOM 0
+#define SPACING_CLOSE_BY_CLICK_ICON -1
+#define SPACING_CLOSE_BY_CUS_EDIT 1
+
+inline constexpr OUStringLiteral SIDEBAR_SPACING_GLOBAL_VALUE = u"PopupPanel_Spacing";
+
+class TextCharacterSpacingPopup;
+
+class TextCharacterSpacingControl final : public WeldToolbarPopup
+{
+public:
+ explicit TextCharacterSpacingControl(TextCharacterSpacingPopup* pControl, weld::Widget* pParent);
+
+ virtual void GrabFocus() override;
+
+ virtual ~TextCharacterSpacingControl() override;
+
+private:
+ tools::Long mnCustomKern;
+ short mnLastCus;
+
+ std::unique_ptr<weld::MetricSpinButton> mxEditKerning;
+ std::unique_ptr<weld::Button> mxTight;
+ std::unique_ptr<weld::Button> mxVeryTight;
+ std::unique_ptr<weld::Button> mxNormal;
+ std::unique_ptr<weld::Button> mxLoose;
+ std::unique_ptr<weld::Button> mxVeryLoose;
+ std::unique_ptr<weld::Button> mxLastCustom;
+
+ rtl::Reference<TextCharacterSpacingPopup> mxControl;
+
+ void Initialize();
+ void ExecuteCharacterSpacing(tools::Long nValue, bool bClose = true);
+
+ DECL_LINK(PredefinedValuesHdl, weld::Button&, void);
+ DECL_LINK(KerningModifyHdl, weld::MetricSpinButton&, void);
+
+ static MapUnit GetCoreMetric();
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sidebar/text/TextCharacterSpacingPopup.cxx b/svx/source/sidebar/text/TextCharacterSpacingPopup.cxx
new file mode 100644
index 000000000..a8eef9000
--- /dev/null
+++ b/svx/source/sidebar/text/TextCharacterSpacingPopup.cxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#include <TextCharacterSpacingPopup.hxx>
+#include "TextCharacterSpacingControl.hxx"
+#include <vcl/toolbox.hxx>
+
+using namespace svx;
+
+TextCharacterSpacingPopup::TextCharacterSpacingPopup(
+ const css::uno::Reference<css::uno::XComponentContext>& rContext)
+ : PopupWindowController(rContext, nullptr, OUString())
+{
+}
+
+void TextCharacterSpacingPopup::initialize(const css::uno::Sequence<css::uno::Any>& rArguments)
+{
+ PopupWindowController::initialize(rArguments);
+
+ if (m_pToolbar)
+ {
+ mxPopoverContainer.reset(new ToolbarPopupContainer(m_pToolbar));
+ m_pToolbar->set_item_popover(m_aCommandURL.toUtf8(), mxPopoverContainer->getTopLevel());
+ }
+
+ ToolBox* pToolBox = nullptr;
+ ToolBoxItemId nId;
+ if (getToolboxId(nId, &pToolBox))
+ pToolBox->SetItemBits(nId, ToolBoxItemBits::DROPDOWNONLY | pToolBox->GetItemBits(nId));
+}
+
+TextCharacterSpacingPopup::~TextCharacterSpacingPopup() {}
+
+std::unique_ptr<WeldToolbarPopup> TextCharacterSpacingPopup::weldPopupWindow()
+{
+ return std::make_unique<TextCharacterSpacingControl>(this, m_pToolbar);
+}
+
+VclPtr<vcl::Window> TextCharacterSpacingPopup::createVclPopupWindow(vcl::Window* pParent)
+{
+ mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(
+ getFrameInterface(), pParent,
+ std::make_unique<TextCharacterSpacingControl>(this, pParent->GetFrameWeld()));
+
+ mxInterimPopover->Show();
+
+ return mxInterimPopover;
+}
+
+OUString TextCharacterSpacingPopup::getImplementationName()
+{
+ return "com.sun.star.comp.svx.CharacterSpacingToolBoxControl";
+}
+
+css::uno::Sequence<OUString> TextCharacterSpacingPopup::getSupportedServiceNames()
+{
+ return { "com.sun.star.frame.ToolbarController" };
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+com_sun_star_comp_svx_CharacterSpacingToolBoxControl_get_implementation(
+ css::uno::XComponentContext* rContext, css::uno::Sequence<css::uno::Any> const&)
+{
+ return cppu::acquire(new TextCharacterSpacingPopup(rContext));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sidebar/text/TextPropertyPanel.cxx b/svx/source/sidebar/text/TextPropertyPanel.cxx
new file mode 100644
index 000000000..1b59a79aa
--- /dev/null
+++ b/svx/source/sidebar/text/TextPropertyPanel.cxx
@@ -0,0 +1,155 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "TextPropertyPanel.hxx"
+
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <comphelper/lok.hxx>
+#include <sfx2/viewsh.hxx>
+
+using namespace css;
+
+namespace svx::sidebar {
+
+std::unique_ptr<PanelLayout> TextPropertyPanel::Create (
+ weld::Widget* pParent,
+ const css::uno::Reference<css::frame::XFrame>& rxFrame)
+{
+ if (pParent == nullptr)
+ throw lang::IllegalArgumentException("no parent Window given to TextPropertyPanel::Create", nullptr, 0);
+ if ( ! rxFrame.is())
+ throw lang::IllegalArgumentException("no XFrame given to TextPropertyPanel::Create", nullptr, 1);
+
+ return std::make_unique<TextPropertyPanel>(pParent, rxFrame);
+}
+
+TextPropertyPanel::TextPropertyPanel(weld::Widget* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame)
+ : PanelLayout(pParent, "SidebarTextPanel", "svx/ui/sidebartextpanel.ui")
+ , mxFont(m_xBuilder->weld_toolbar("font"))
+ , mxFontDispatch(new ToolbarUnoDispatcher(*mxFont, *m_xBuilder, rxFrame))
+ , mxFontHeight(m_xBuilder->weld_toolbar("fontheight"))
+ , mxFontHeightDispatch(new ToolbarUnoDispatcher(*mxFontHeight, *m_xBuilder, rxFrame))
+ , mxFontEffects(m_xBuilder->weld_toolbar("fonteffects"))
+ , mxFontEffectsDispatch(new ToolbarUnoDispatcher(*mxFontEffects, *m_xBuilder, rxFrame))
+ , mxFontAdjust(m_xBuilder->weld_toolbar("fontadjust"))
+ , mxFontAdjustDispatch(new ToolbarUnoDispatcher(*mxFontAdjust, *m_xBuilder, rxFrame))
+ , mxToolBoxFontColorSw(m_xBuilder->weld_toolbar("colorbar_writer"))
+ , mxToolBoxFontColorSwDispatch(new ToolbarUnoDispatcher(*mxToolBoxFontColorSw, *m_xBuilder, rxFrame))
+ , mxToolBoxFontColor(m_xBuilder->weld_toolbar("colorbar_others"))
+ , mxToolBoxFontColorDispatch(new ToolbarUnoDispatcher(*mxToolBoxFontColor, *m_xBuilder, rxFrame))
+ , mxToolBoxBackgroundColor(m_xBuilder->weld_toolbar("colorbar_background"))
+ , mxToolBoxBackgroundColorDispatch(new ToolbarUnoDispatcher(*mxToolBoxBackgroundColor, *m_xBuilder, rxFrame))
+ , mxResetBar(m_xBuilder->weld_toolbar("resetattr"))
+ , mxResetBarDispatch(new ToolbarUnoDispatcher(*mxResetBar, *m_xBuilder, rxFrame))
+ , mxDefaultBar(m_xBuilder->weld_toolbar("defaultattr"))
+ , mxDefaultBarDispatch(new ToolbarUnoDispatcher(*mxDefaultBar, *m_xBuilder, rxFrame))
+ , mxPositionBar(m_xBuilder->weld_toolbar("position"))
+ , mxPositionBarDispatch(new ToolbarUnoDispatcher(*mxPositionBar, *m_xBuilder, rxFrame))
+ , mxSpacingBar(m_xBuilder->weld_toolbar("spacingbar"))
+ , mxSpacingBarDispatch(new ToolbarUnoDispatcher(*mxSpacingBar, *m_xBuilder, rxFrame))
+{
+ bool isMobilePhone = false;
+ const SfxViewShell* pViewShell = SfxViewShell::Current();
+ if (comphelper::LibreOfficeKit::isActive() &&
+ pViewShell && pViewShell->isLOKMobilePhone())
+ isMobilePhone = true;
+ mxSpacingBar->set_visible(!isMobilePhone);
+}
+
+TextPropertyPanel::~TextPropertyPanel()
+{
+ mxResetBarDispatch.reset();
+ mxDefaultBarDispatch.reset();
+ mxPositionBarDispatch.reset();
+ mxSpacingBarDispatch.reset();
+ mxToolBoxFontColorSwDispatch.reset();
+ mxToolBoxFontColorDispatch.reset();
+ mxToolBoxBackgroundColorDispatch.reset();
+ mxFontAdjustDispatch.reset();
+ mxFontEffectsDispatch.reset();
+ mxFontHeightDispatch.reset();
+ mxFontDispatch.reset();
+
+ mxResetBar.reset();
+ mxDefaultBar.reset();
+ mxPositionBar.reset();
+ mxSpacingBar.reset();
+ mxToolBoxFontColorSw.reset();
+ mxToolBoxFontColor.reset();
+ mxToolBoxBackgroundColor.reset();
+ mxFontAdjust.reset();
+ mxFontEffects.reset();
+ mxFontHeight.reset();
+ mxFont.reset();
+}
+
+void TextPropertyPanel::HandleContextChange (
+ const vcl::EnumContext& rContext)
+{
+ if (maContext == rContext)
+ return;
+
+ maContext = rContext;
+
+ bool bWriterText = false;
+ bool bDrawText = false;
+ bool bCalcText = false;
+
+ switch (maContext.GetCombinedContext_DI())
+ {
+ case CombinedEnumContext(Application::Calc, Context::DrawText):
+ case CombinedEnumContext(Application::WriterVariants, Context::DrawText):
+ case CombinedEnumContext(Application::WriterVariants, Context::Annotation):
+ case CombinedEnumContext(Application::DrawImpress, Context::DrawText):
+ case CombinedEnumContext(Application::DrawImpress, Context::Text):
+ case CombinedEnumContext(Application::DrawImpress, Context::Table):
+ case CombinedEnumContext(Application::DrawImpress, Context::OutlineText):
+ case CombinedEnumContext(Application::DrawImpress, Context::Draw):
+ case CombinedEnumContext(Application::DrawImpress, Context::TextObject):
+ case CombinedEnumContext(Application::DrawImpress, Context::Graphic):
+ bDrawText = true;
+ break;
+
+ case CombinedEnumContext(Application::WriterVariants, Context::Text):
+ case CombinedEnumContext(Application::WriterVariants, Context::Table):
+ bWriterText = true;
+ break;
+
+ case CombinedEnumContext(Application::Calc, Context::Text):
+ case CombinedEnumContext(Application::Calc, Context::Table):
+ case CombinedEnumContext(Application::Calc, Context::Cell):
+ case CombinedEnumContext(Application::Calc, Context::EditCell):
+ case CombinedEnumContext(Application::Calc, Context::Grid):
+ bCalcText = true;
+ break;
+
+ default:
+ break;
+ }
+
+ mxToolBoxFontColor->set_visible(!bWriterText);
+ mxToolBoxFontColorSw->set_visible(bWriterText);
+ mxToolBoxBackgroundColor->set_visible(bDrawText);
+ mxResetBar->set_visible(bWriterText || bCalcText);
+ mxDefaultBar->set_visible(bDrawText);
+}
+
+} // end of namespace svx::sidebar
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sidebar/text/TextPropertyPanel.hxx b/svx/source/sidebar/text/TextPropertyPanel.hxx
new file mode 100644
index 000000000..3ad44bde7
--- /dev/null
+++ b/svx/source/sidebar/text/TextPropertyPanel.hxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SVX_SOURCE_SIDEBAR_TEXT_TEXTPROPERTYPANEL_HXX
+#define INCLUDED_SVX_SOURCE_SIDEBAR_TEXT_TEXTPROPERTYPANEL_HXX
+
+#include <sfx2/sidebar/IContextChangeReceiver.hxx>
+#include <sfx2/weldutils.hxx>
+#include <vcl/EnumContext.hxx>
+#include <sfx2/sidebar/PanelLayout.hxx>
+
+namespace svx::sidebar {
+
+class TextPropertyPanel
+ : public PanelLayout,
+ public ::sfx2::sidebar::IContextChangeReceiver
+{
+public:
+ virtual ~TextPropertyPanel() override;
+
+ static std::unique_ptr<PanelLayout> Create (
+ weld::Widget* pParent,
+ const css::uno::Reference<css::frame::XFrame>& rxFrame);
+
+ virtual void HandleContextChange (
+ const vcl::EnumContext& rContext) override;
+
+ TextPropertyPanel (
+ weld::Widget* pParent,
+ const css::uno::Reference<css::frame::XFrame>& rxFrame);
+
+private:
+ std::unique_ptr<weld::Toolbar> mxFont;
+ std::unique_ptr<ToolbarUnoDispatcher> mxFontDispatch;
+ std::unique_ptr<weld::Toolbar> mxFontHeight;
+ std::unique_ptr<ToolbarUnoDispatcher> mxFontHeightDispatch;
+ std::unique_ptr<weld::Toolbar> mxFontEffects;
+ std::unique_ptr<ToolbarUnoDispatcher> mxFontEffectsDispatch;
+ std::unique_ptr<weld::Toolbar> mxFontAdjust;
+ std::unique_ptr<ToolbarUnoDispatcher> mxFontAdjustDispatch;
+ std::unique_ptr<weld::Toolbar> mxToolBoxFontColorSw;
+ std::unique_ptr<ToolbarUnoDispatcher> mxToolBoxFontColorSwDispatch;
+ std::unique_ptr<weld::Toolbar> mxToolBoxFontColor;
+ std::unique_ptr<ToolbarUnoDispatcher> mxToolBoxFontColorDispatch;
+ std::unique_ptr<weld::Toolbar> mxToolBoxBackgroundColor;
+ std::unique_ptr<ToolbarUnoDispatcher> mxToolBoxBackgroundColorDispatch;
+ std::unique_ptr<weld::Toolbar> mxResetBar;
+ std::unique_ptr<ToolbarUnoDispatcher> mxResetBarDispatch;
+ std::unique_ptr<weld::Toolbar> mxDefaultBar;
+ std::unique_ptr<ToolbarUnoDispatcher> mxDefaultBarDispatch;
+ std::unique_ptr<weld::Toolbar> mxPositionBar;
+ std::unique_ptr<ToolbarUnoDispatcher> mxPositionBarDispatch;
+ std::unique_ptr<weld::Toolbar> mxSpacingBar;
+ std::unique_ptr<ToolbarUnoDispatcher> mxSpacingBarDispatch;
+
+ vcl::EnumContext maContext;
+};
+
+} // end of namespace svx::sidebar
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sidebar/text/TextUnderlineControl.cxx b/svx/source/sidebar/text/TextUnderlineControl.cxx
new file mode 100644
index 000000000..ac65b8271
--- /dev/null
+++ b/svx/source/sidebar/text/TextUnderlineControl.cxx
@@ -0,0 +1,141 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#include "TextUnderlineControl.hxx"
+#include <svx/svxids.hrc>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <TextUnderlinePopup.hxx>
+#include <editeng/editids.hrc>
+#include <editeng/udlnitem.hxx>
+#include <helpids.h>
+
+namespace svx {
+
+TextUnderlineControl::TextUnderlineControl(TextUnderlinePopup* pControl, weld::Widget* pParent)
+ : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/textunderlinecontrol.ui", "TextUnderlineControl")
+ , mxNone(m_xBuilder->weld_button("none"))
+ , mxSingle(m_xBuilder->weld_button("single"))
+ , mxDouble(m_xBuilder->weld_button("double"))
+ , mxBold(m_xBuilder->weld_button("bold"))
+ , mxDot(m_xBuilder->weld_button("dot"))
+ , mxDotBold(m_xBuilder->weld_button("dotbold"))
+ , mxDash(m_xBuilder->weld_button("dash"))
+ , mxDashLong(m_xBuilder->weld_button("dashlong"))
+ , mxDashDot(m_xBuilder->weld_button("dashdot"))
+ , mxDashDotDot(m_xBuilder->weld_button("dashdotdot"))
+ , mxWave(m_xBuilder->weld_button("wave"))
+ , mxMoreOptions(m_xBuilder->weld_button("moreoptions"))
+ , mxControl(pControl)
+{
+ mxMoreOptions->set_help_id(HID_UNDERLINE_BTN);
+
+ Link<weld::Button&,void> aLink = LINK(this, TextUnderlineControl, PBClickHdl);
+ mxNone->connect_clicked(aLink);
+ mxSingle->connect_clicked(aLink);
+ mxDouble->connect_clicked(aLink);
+ mxBold->connect_clicked(aLink);
+ mxDot->connect_clicked(aLink);
+ mxDotBold->connect_clicked(aLink);
+ mxDash->connect_clicked(aLink);
+ mxDashLong->connect_clicked(aLink);
+ mxDashDot->connect_clicked(aLink);
+ mxDashDotDot->connect_clicked(aLink);
+ mxWave->connect_clicked(aLink);
+ mxMoreOptions->connect_clicked(aLink);
+}
+
+void TextUnderlineControl::GrabFocus()
+{
+ mxNone->grab_focus();
+}
+
+TextUnderlineControl::~TextUnderlineControl()
+{
+}
+
+FontLineStyle TextUnderlineControl::getLineStyle(const weld::Button& rButton) const
+{
+ if (&rButton == mxSingle.get())
+ return LINESTYLE_SINGLE;
+ else if (&rButton == mxDouble.get())
+ return LINESTYLE_DOUBLE;
+ else if (&rButton == mxBold.get())
+ return LINESTYLE_BOLD;
+ else if (&rButton == mxDot.get())
+ return LINESTYLE_DOTTED;
+ else if (&rButton == mxDotBold.get())
+ return LINESTYLE_BOLDDOTTED;
+ else if (&rButton == mxDash.get())
+ return LINESTYLE_DASH;
+ else if (&rButton == mxDashLong.get())
+ return LINESTYLE_LONGDASH;
+ else if (&rButton == mxDashDot.get())
+ return LINESTYLE_DASHDOT;
+ else if (&rButton == mxDashDotDot.get())
+ return LINESTYLE_DASHDOTDOT;
+ else if (&rButton == mxWave.get())
+ return LINESTYLE_WAVE;
+
+ return LINESTYLE_NONE;
+}
+
+namespace {
+
+Color GetUnderlineColor()
+{
+ if (SfxViewFrame* pViewFrm = SfxViewFrame::Current())
+ {
+ const SvxUnderlineItem* pUnderlineItem;
+ pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_CHAR_UNDERLINE, pUnderlineItem);
+
+ if (pUnderlineItem)
+ return pUnderlineItem->GetColor();
+ }
+
+ return COL_AUTO;
+}
+
+}
+
+IMPL_LINK(TextUnderlineControl, PBClickHdl, weld::Button&, rButton, void)
+{
+ if (SfxViewFrame* pViewFrm = SfxViewFrame::Current())
+ {
+ if (&rButton == mxMoreOptions.get())
+ {
+ SfxDispatcher* pDisp = pViewFrm->GetBindings().GetDispatcher();
+ pDisp->Execute(SID_CHAR_DLG_EFFECT, SfxCallMode::ASYNCHRON);
+ }
+ else
+ {
+ const FontLineStyle eUnderline = getLineStyle(rButton);
+
+ SvxUnderlineItem aLineItem(eUnderline, SID_ATTR_CHAR_UNDERLINE);
+ aLineItem.SetColor(GetUnderlineColor());
+
+ pViewFrm->GetBindings().GetDispatcher()->ExecuteList(SID_ATTR_CHAR_UNDERLINE,
+ SfxCallMode::RECORD, { &aLineItem });
+ }
+ }
+ mxControl->EndPopupMode();
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sidebar/text/TextUnderlineControl.hxx b/svx/source/sidebar/text/TextUnderlineControl.hxx
new file mode 100644
index 000000000..cc1a19c67
--- /dev/null
+++ b/svx/source/sidebar/text/TextUnderlineControl.hxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SVX_SOURCE_SIDEBAR_TEXT_TEXTUNDERLINECONTROL_HXX
+#define INCLUDED_SVX_SOURCE_SIDEBAR_TEXT_TEXTUNDERLINECONTROL_HXX
+
+#include <svtools/toolbarmenu.hxx>
+
+namespace svx
+{
+class TextUnderlinePopup;
+
+class TextUnderlineControl final : public WeldToolbarPopup
+{
+public:
+ explicit TextUnderlineControl(TextUnderlinePopup* pControl, weld::Widget* pParent);
+ virtual void GrabFocus() override;
+ virtual ~TextUnderlineControl() override;
+
+private:
+ std::unique_ptr<weld::Button> mxNone;
+ std::unique_ptr<weld::Button> mxSingle;
+ std::unique_ptr<weld::Button> mxDouble;
+ std::unique_ptr<weld::Button> mxBold;
+ std::unique_ptr<weld::Button> mxDot;
+ std::unique_ptr<weld::Button> mxDotBold;
+ std::unique_ptr<weld::Button> mxDash;
+ std::unique_ptr<weld::Button> mxDashLong;
+ std::unique_ptr<weld::Button> mxDashDot;
+ std::unique_ptr<weld::Button> mxDashDotDot;
+ std::unique_ptr<weld::Button> mxWave;
+ std::unique_ptr<weld::Button> mxMoreOptions;
+
+ rtl::Reference<TextUnderlinePopup> mxControl;
+
+ FontLineStyle getLineStyle(const weld::Button& rButton) const;
+
+ DECL_LINK(PBClickHdl, weld::Button&, void);
+};
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sidebar/text/TextUnderlinePopup.cxx b/svx/source/sidebar/text/TextUnderlinePopup.cxx
new file mode 100644
index 000000000..75529f297
--- /dev/null
+++ b/svx/source/sidebar/text/TextUnderlinePopup.cxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#include <TextUnderlinePopup.hxx>
+#include "TextUnderlineControl.hxx"
+#include <vcl/toolbox.hxx>
+
+using namespace svx;
+
+TextUnderlinePopup::TextUnderlinePopup(
+ const css::uno::Reference<css::uno::XComponentContext>& rContext)
+ : PopupWindowController(rContext, nullptr, OUString())
+{
+}
+
+TextUnderlinePopup::~TextUnderlinePopup() {}
+
+void TextUnderlinePopup::initialize(const css::uno::Sequence<css::uno::Any>& rArguments)
+{
+ PopupWindowController::initialize(rArguments);
+
+ if (m_pToolbar)
+ {
+ mxPopoverContainer.reset(new ToolbarPopupContainer(m_pToolbar));
+ m_pToolbar->set_item_popover(m_aCommandURL.toUtf8(), mxPopoverContainer->getTopLevel());
+ }
+
+ ToolBox* pToolBox = nullptr;
+ ToolBoxItemId nId;
+ if (getToolboxId(nId, &pToolBox) && pToolBox->GetItemCommand(nId) == m_aCommandURL)
+ pToolBox->SetItemBits(nId, ToolBoxItemBits::DROPDOWN | pToolBox->GetItemBits(nId));
+}
+
+std::unique_ptr<WeldToolbarPopup> TextUnderlinePopup::weldPopupWindow()
+{
+ return std::make_unique<TextUnderlineControl>(this, m_pToolbar);
+}
+
+VclPtr<vcl::Window> TextUnderlinePopup::createVclPopupWindow(vcl::Window* pParent)
+{
+ mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(
+ getFrameInterface(), pParent,
+ std::make_unique<TextUnderlineControl>(this, pParent->GetFrameWeld()));
+
+ mxInterimPopover->Show();
+
+ return mxInterimPopover;
+}
+
+OUString TextUnderlinePopup::getImplementationName()
+{
+ return "com.sun.star.comp.svx.UnderlineToolBoxControl";
+}
+
+css::uno::Sequence<OUString> TextUnderlinePopup::getSupportedServiceNames()
+{
+ return { "com.sun.star.frame.ToolbarController" };
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+com_sun_star_comp_svx_UnderlineToolBoxControl_get_implementation(
+ css::uno::XComponentContext* rContext, css::uno::Sequence<css::uno::Any> const&)
+{
+ return cppu::acquire(new TextUnderlinePopup(rContext));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */