From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- .../sidebar/text/TextCharacterSpacingControl.cxx | 224 +++++++++++++++++++++ .../sidebar/text/TextCharacterSpacingControl.hxx | 69 +++++++ .../sidebar/text/TextCharacterSpacingPopup.cxx | 82 ++++++++ svx/source/sidebar/text/TextPropertyPanel.cxx | 155 ++++++++++++++ svx/source/sidebar/text/TextPropertyPanel.hxx | 78 +++++++ svx/source/sidebar/text/TextUnderlineControl.cxx | 141 +++++++++++++ svx/source/sidebar/text/TextUnderlineControl.hxx | 60 ++++++ svx/source/sidebar/text/TextUnderlinePopup.cxx | 82 ++++++++ 8 files changed, 891 insertions(+) create mode 100644 svx/source/sidebar/text/TextCharacterSpacingControl.cxx create mode 100644 svx/source/sidebar/text/TextCharacterSpacingControl.hxx create mode 100644 svx/source/sidebar/text/TextCharacterSpacingPopup.cxx create mode 100644 svx/source/sidebar/text/TextPropertyPanel.cxx create mode 100644 svx/source/sidebar/text/TextPropertyPanel.hxx create mode 100644 svx/source/sidebar/text/TextUnderlineControl.cxx create mode 100644 svx/source/sidebar/text/TextUnderlineControl.hxx create mode 100644 svx/source/sidebar/text/TextUnderlinePopup.cxx (limited to 'svx/source/sidebar/text') 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 +#include "TextCharacterSpacingControl.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#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 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 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 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(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 + +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 mxEditKerning; + std::unique_ptr mxTight; + std::unique_ptr mxVeryTight; + std::unique_ptr mxNormal; + std::unique_ptr mxLoose; + std::unique_ptr mxVeryLoose; + std::unique_ptr mxLastCustom; + + rtl::Reference 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 +#include "TextCharacterSpacingControl.hxx" +#include + +using namespace svx; + +TextCharacterSpacingPopup::TextCharacterSpacingPopup( + const css::uno::Reference& rContext) + : PopupWindowController(rContext, nullptr, OUString()) +{ +} + +void TextCharacterSpacingPopup::initialize(const css::uno::Sequence& 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 TextCharacterSpacingPopup::weldPopupWindow() +{ + return std::make_unique(this, m_pToolbar); +} + +VclPtr TextCharacterSpacingPopup::createVclPopupWindow(vcl::Window* pParent) +{ + mxInterimPopover = VclPtr::Create( + getFrameInterface(), pParent, + std::make_unique(this, pParent->GetFrameWeld())); + + mxInterimPopover->Show(); + + return mxInterimPopover; +} + +OUString TextCharacterSpacingPopup::getImplementationName() +{ + return "com.sun.star.comp.svx.CharacterSpacingToolBoxControl"; +} + +css::uno::Sequence 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 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 +#include +#include + +using namespace css; + +namespace svx::sidebar { + +std::unique_ptr TextPropertyPanel::Create ( + weld::Widget* pParent, + const css::uno::Reference& 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(pParent, rxFrame); +} + +TextPropertyPanel::TextPropertyPanel(weld::Widget* pParent, const css::uno::Reference& 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 +#include +#include +#include + +namespace svx::sidebar { + +class TextPropertyPanel + : public PanelLayout, + public ::sfx2::sidebar::IContextChangeReceiver +{ +public: + virtual ~TextPropertyPanel() override; + + static std::unique_ptr Create ( + weld::Widget* pParent, + const css::uno::Reference& rxFrame); + + virtual void HandleContextChange ( + const vcl::EnumContext& rContext) override; + + TextPropertyPanel ( + weld::Widget* pParent, + const css::uno::Reference& rxFrame); + +private: + std::unique_ptr mxFont; + std::unique_ptr mxFontDispatch; + std::unique_ptr mxFontHeight; + std::unique_ptr mxFontHeightDispatch; + std::unique_ptr mxFontEffects; + std::unique_ptr mxFontEffectsDispatch; + std::unique_ptr mxFontAdjust; + std::unique_ptr mxFontAdjustDispatch; + std::unique_ptr mxToolBoxFontColorSw; + std::unique_ptr mxToolBoxFontColorSwDispatch; + std::unique_ptr mxToolBoxFontColor; + std::unique_ptr mxToolBoxFontColorDispatch; + std::unique_ptr mxToolBoxBackgroundColor; + std::unique_ptr mxToolBoxBackgroundColorDispatch; + std::unique_ptr mxResetBar; + std::unique_ptr mxResetBarDispatch; + std::unique_ptr mxDefaultBar; + std::unique_ptr mxDefaultBarDispatch; + std::unique_ptr mxPositionBar; + std::unique_ptr mxPositionBarDispatch; + std::unique_ptr mxSpacingBar; + std::unique_ptr 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 +#include +#include +#include +#include +#include +#include + +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 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 + +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 mxNone; + std::unique_ptr mxSingle; + std::unique_ptr mxDouble; + std::unique_ptr mxBold; + std::unique_ptr mxDot; + std::unique_ptr mxDotBold; + std::unique_ptr mxDash; + std::unique_ptr mxDashLong; + std::unique_ptr mxDashDot; + std::unique_ptr mxDashDotDot; + std::unique_ptr mxWave; + std::unique_ptr mxMoreOptions; + + rtl::Reference 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 +#include "TextUnderlineControl.hxx" +#include + +using namespace svx; + +TextUnderlinePopup::TextUnderlinePopup( + const css::uno::Reference& rContext) + : PopupWindowController(rContext, nullptr, OUString()) +{ +} + +TextUnderlinePopup::~TextUnderlinePopup() {} + +void TextUnderlinePopup::initialize(const css::uno::Sequence& 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 TextUnderlinePopup::weldPopupWindow() +{ + return std::make_unique(this, m_pToolbar); +} + +VclPtr TextUnderlinePopup::createVclPopupWindow(vcl::Window* pParent) +{ + mxInterimPopover = VclPtr::Create( + getFrameInterface(), pParent, + std::make_unique(this, pParent->GetFrameWeld())); + + mxInterimPopover->Show(); + + return mxInterimPopover; +} + +OUString TextUnderlinePopup::getImplementationName() +{ + return "com.sun.star.comp.svx.UnderlineToolBoxControl"; +} + +css::uno::Sequence 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 const&) +{ + return cppu::acquire(new TextUnderlinePopup(rContext)); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3