diff options
Diffstat (limited to 'sc/source/ui/sidebar')
-rw-r--r-- | sc/source/ui/sidebar/AlignmentPropertyPanel.cxx | 339 | ||||
-rw-r--r-- | sc/source/ui/sidebar/AlignmentPropertyPanel.hxx | 112 | ||||
-rw-r--r-- | sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx | 506 | ||||
-rw-r--r-- | sc/source/ui/sidebar/CellAppearancePropertyPanel.hxx | 147 | ||||
-rw-r--r-- | sc/source/ui/sidebar/CellBorderStyleControl.cxx | 281 | ||||
-rw-r--r-- | sc/source/ui/sidebar/CellBorderStyleControl.hxx | 52 | ||||
-rw-r--r-- | sc/source/ui/sidebar/CellLineStyleControl.cxx | 243 | ||||
-rw-r--r-- | sc/source/ui/sidebar/CellLineStyleControl.hxx | 54 | ||||
-rw-r--r-- | sc/source/ui/sidebar/CellLineStyleValueSet.cxx | 187 | ||||
-rw-r--r-- | sc/source/ui/sidebar/CellLineStyleValueSet.hxx | 48 | ||||
-rw-r--r-- | sc/source/ui/sidebar/NumberFormatControl.cxx | 77 | ||||
-rw-r--r-- | sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx | 290 | ||||
-rw-r--r-- | sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx | 94 | ||||
-rw-r--r-- | sc/source/ui/sidebar/ScPanelFactory.cxx | 143 | ||||
-rw-r--r-- | sc/source/ui/sidebar/ScPanelFactory.hxx | 55 |
15 files changed, 2628 insertions, 0 deletions
diff --git a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx new file mode 100644 index 000000000..370b79157 --- /dev/null +++ b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx @@ -0,0 +1,339 @@ +/* -*- 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 "AlignmentPropertyPanel.hxx" +#include <editeng/justifyitem.hxx> +#include <sc.hrc> +#include <attrib.hxx> +#include <scitems.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <svl/intitem.hxx> +#include <svx/rotmodit.hxx> +#include <svtools/unitconv.hxx> +#include <com/sun/star/lang/IllegalArgumentException.hpp> + +using namespace css; +using namespace css::uno; + +// namespace open + +namespace sc::sidebar { + +AlignmentPropertyPanel::AlignmentPropertyPanel( + weld::Widget* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings) + : PanelLayout(pParent, "AlignmentPropertyPanel", "modules/scalc/ui/sidebaralignment.ui") + , mxFTLeftIndent(m_xBuilder->weld_label("leftindentlabel")) + , mxMFLeftIndent(m_xBuilder->weld_metric_spin_button("leftindent", FieldUnit::POINT)) + , mxCBXWrapText(m_xBuilder->weld_check_button("wraptext")) + , mxCBXMergeCell(m_xBuilder->weld_check_button("mergecells")) + , mxFtRotate(m_xBuilder->weld_label("orientationlabel")) + , mxMtrAngle(m_xBuilder->weld_metric_spin_button("orientationdegrees", FieldUnit::DEGREE)) + , mxRefEdgeBottom(m_xBuilder->weld_toggle_button("bottom")) + , mxRefEdgeTop(m_xBuilder->weld_toggle_button("top")) + , mxRefEdgeStd(m_xBuilder->weld_toggle_button("standard")) + , mxCBStacked(m_xBuilder->weld_check_button("stacked")) + , mxTextOrientBox(m_xBuilder->weld_widget("textorientbox")) + , mxHorizontalAlign(m_xBuilder->weld_toolbar("horizontalalignment")) + , mxHorizontalAlignDispatch(new ToolbarUnoDispatcher(*mxHorizontalAlign, *m_xBuilder, rxFrame)) + , mxVertAlign(m_xBuilder->weld_toolbar("verticalalignment")) + , mxVertAlignDispatch(new ToolbarUnoDispatcher(*mxVertAlign, *m_xBuilder, rxFrame)) + , mxWriteDirection(m_xBuilder->weld_toolbar("writedirection")) + , mxWriteDirectionDispatch(new ToolbarUnoDispatcher(*mxWriteDirection, *m_xBuilder, rxFrame)) + , mxIndentButtons(m_xBuilder->weld_toolbar("indentbuttons")) + , mxIndentButtonsDispatch(new ToolbarUnoDispatcher(*mxIndentButtons, *m_xBuilder, rxFrame)) + , maAlignHorControl(SID_H_ALIGNCELL, *pBindings, *this) + , maLeftIndentControl(SID_ATTR_ALIGN_INDENT, *pBindings, *this) + , maMergeCellControl(FID_MERGE_TOGGLE, *pBindings, *this) + , maWrapTextControl(SID_ATTR_ALIGN_LINEBREAK, *pBindings, *this) + , maAngleControl(SID_ATTR_ALIGN_DEGREES, *pBindings, *this) + , maVrtStackControl(SID_ATTR_ALIGN_STACKED, *pBindings, *this) + , maRefEdgeControl(SID_ATTR_ALIGN_LOCKPOS, *pBindings, *this) + , mbMultiDisable(false) + , mpBindings(pBindings) +{ + Initialize(); +} + +AlignmentPropertyPanel::~AlignmentPropertyPanel() +{ + mxIndentButtonsDispatch.reset(); + mxIndentButtons.reset(); + mxWriteDirectionDispatch.reset(); + mxWriteDirection.reset(); + mxVertAlignDispatch.reset(); + mxVertAlign.reset(); + mxHorizontalAlignDispatch.reset(); + mxHorizontalAlign.reset(); + + mxFTLeftIndent.reset(); + mxMFLeftIndent.reset(); + mxCBXWrapText.reset(); + mxCBXMergeCell.reset(); + mxFtRotate.reset(); + mxMtrAngle.reset(); + mxCBStacked.reset(); + mxRefEdgeBottom.reset(); + mxRefEdgeTop.reset(); + mxRefEdgeStd.reset(); + mxTextOrientBox.reset(); + + maAlignHorControl.dispose(); + maLeftIndentControl.dispose(); + maMergeCellControl.dispose(); + maWrapTextControl.dispose(); + maAngleControl.dispose(); + maVrtStackControl.dispose(); + maRefEdgeControl.dispose(); +} + +void AlignmentPropertyPanel::Initialize() +{ + mxFTLeftIndent->set_sensitive(false); + mxMFLeftIndent->set_sensitive(false); + Link<weld::MetricSpinButton&,void> aLink = LINK(this, AlignmentPropertyPanel, MFLeftIndentMdyHdl); + mxMFLeftIndent->connect_value_changed( aLink ); + + mxCBXMergeCell->connect_toggled( LINK(this, AlignmentPropertyPanel, CBOXMergnCellClkHdl) ); + + mxCBXWrapText->connect_toggled( LINK(this, AlignmentPropertyPanel, CBOXWrapTextClkHdl) ); + + //rotation + mxMtrAngle->connect_value_changed(LINK( this, AlignmentPropertyPanel, AngleModifiedHdl)); + mxCBStacked->connect_toggled(LINK(this, AlignmentPropertyPanel, ClickStackHdl)); + + Link<weld::Button&,void> aLink2 = LINK(this, AlignmentPropertyPanel, ReferenceEdgeHdl); + mxRefEdgeBottom->connect_clicked(aLink2); + mxRefEdgeTop->connect_clicked(aLink2); + mxRefEdgeStd->connect_clicked(aLink2); +} + +IMPL_LINK(AlignmentPropertyPanel, ReferenceEdgeHdl, weld::Button&, rToggle, void) +{ + SvxRotateMode eMode; + if (&rToggle == mxRefEdgeBottom.get()) + eMode = SVX_ROTATE_MODE_BOTTOM; + else if (&rToggle == mxRefEdgeTop.get()) + eMode = SVX_ROTATE_MODE_TOP; + else /*if (&rToggle == mxRefEdgeStd.get())*/ + eMode = SVX_ROTATE_MODE_STANDARD; + + mxRefEdgeBottom->set_active(eMode == SVX_ROTATE_MODE_BOTTOM); + mxRefEdgeTop->set_active(eMode == SVX_ROTATE_MODE_TOP); + mxRefEdgeStd->set_active(eMode == SVX_ROTATE_MODE_STANDARD); + + SvxRotateModeItem aItem(eMode, ATTR_ROTATE_MODE); + GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_ALIGN_LOCKPOS, + SfxCallMode::RECORD, { &aItem }); +} + +IMPL_LINK_NOARG( AlignmentPropertyPanel, AngleModifiedHdl, weld::MetricSpinButton&, void ) +{ + Degree100 nAngle(mxMtrAngle->get_value(FieldUnit::DEGREE) * 100); + ScRotateValueItem aAngleItem(nAngle); + + GetBindings()->GetDispatcher()->ExecuteList( + SID_ATTR_ALIGN_DEGREES, SfxCallMode::RECORD, { &aAngleItem }); +} + +IMPL_LINK_NOARG( AlignmentPropertyPanel, ClickStackHdl, weld::Toggleable&, void ) +{ + bool bVertical = mxCBStacked->get_active(); + ScVerticalStackCell aStackItem(bVertical); + GetBindings()->GetDispatcher()->ExecuteList( + SID_ATTR_ALIGN_STACKED, SfxCallMode::RECORD, { &aStackItem }); +} + +IMPL_LINK_NOARG(AlignmentPropertyPanel, MFLeftIndentMdyHdl, weld::MetricSpinButton&, void) +{ + sal_uInt16 nVal = mxMFLeftIndent->get_value(FieldUnit::NONE); + ScIndentItem aItem(static_cast<sal_uInt16>(CalcToUnit(nVal, MapUnit::MapTwip))); + + GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_ALIGN_INDENT, + SfxCallMode::RECORD, { &aItem }); +} + +IMPL_LINK_NOARG(AlignmentPropertyPanel, CBOXMergnCellClkHdl, weld::Toggleable&, void) +{ + bool bState = mxCBXMergeCell->get_active(); + + if( bState) + GetBindings()->GetDispatcher()->Execute(FID_MERGE_ON, SfxCallMode::RECORD); + else + GetBindings()->GetDispatcher()->Execute(FID_MERGE_OFF, SfxCallMode::RECORD); + GetBindings()->Invalidate(FID_MERGE_TOGGLE,true); +} + +IMPL_LINK_NOARG(AlignmentPropertyPanel, CBOXWrapTextClkHdl, weld::Toggleable&, void) +{ + bool bState = mxCBXWrapText->get_active(); + ScLineBreakCell aItem(bState); + GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_ALIGN_LINEBREAK, + SfxCallMode::RECORD, { &aItem }); +} + +std::unique_ptr<PanelLayout> AlignmentPropertyPanel::Create ( + weld::Widget* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings) +{ + if (pParent == nullptr) + throw lang::IllegalArgumentException("no parent Window given to AlignmentPropertyPanel::Create", nullptr, 0); + if ( ! rxFrame.is()) + throw lang::IllegalArgumentException("no XFrame given to AlignmentPropertyPanel::Create", nullptr, 1); + if (pBindings == nullptr) + throw lang::IllegalArgumentException("no SfxBindings given to AlignmentPropertyPanel::Create", nullptr, 2); + + return std::make_unique<AlignmentPropertyPanel>(pParent, rxFrame, pBindings); +} + +void AlignmentPropertyPanel::HandleContextChange( + const vcl::EnumContext& rContext) +{ + if (maContext == rContext) + { + // Nothing to do. + return; + } + + maContext = rContext; +} + +void AlignmentPropertyPanel::NotifyItemUpdate( + sal_uInt16 nSID, + SfxItemState eState, + const SfxPoolItem* pState) +{ + switch(nSID) + { + case SID_H_ALIGNCELL: + { + SvxCellHorJustify meHorAlignState = SvxCellHorJustify::Standard; + if(eState >= SfxItemState::DEFAULT) + if (auto pItem = dynamic_cast<const SvxHorJustifyItem*>( pState) ) + meHorAlignState = pItem->GetValue(); + + if( meHorAlignState == SvxCellHorJustify::Repeat ) + { + mxFtRotate->set_sensitive(false); + mxMtrAngle->set_sensitive(false); + } + else + { + mxFtRotate->set_sensitive(!mbMultiDisable); + mxMtrAngle->set_sensitive(!mbMultiDisable); + } + + mxFTLeftIndent->set_sensitive( meHorAlignState == SvxCellHorJustify::Left ); + mxMFLeftIndent->set_sensitive( meHorAlignState == SvxCellHorJustify::Left ); + } + break; + case SID_ATTR_ALIGN_INDENT: + if(eState >= SfxItemState::DEFAULT && dynamic_cast<const SfxUInt16Item*>( pState) ) + { + const SfxUInt16Item* pItem = static_cast<const SfxUInt16Item*>(pState); + sal_uInt16 nVal = pItem->GetValue(); + mxMFLeftIndent->set_value( CalcToPoint(nVal, MapUnit::MapTwip, 1), FieldUnit::NONE ); + } + else + { + mxMFLeftIndent->set_value(0, FieldUnit::NONE); + mxMFLeftIndent->set_text(OUString()); + } + break; + case FID_MERGE_TOGGLE: + if(eState >= SfxItemState::DEFAULT && dynamic_cast<const SfxBoolItem*>( pState) ) + { + mxCBXMergeCell->set_sensitive(true); + const SfxBoolItem* pItem = static_cast<const SfxBoolItem*>(pState); + mxCBXMergeCell->set_active(pItem->GetValue()); + } + else + { + mxCBXMergeCell->set_active(false); + mxCBXMergeCell->set_sensitive(false); + } + break; + + case SID_ATTR_ALIGN_LINEBREAK: + if(eState == SfxItemState::DISABLED) + { + mxCBXWrapText->set_active(false); + mxCBXWrapText->set_sensitive(false); + } + else + { + mxCBXWrapText->set_sensitive(true); + if(eState >= SfxItemState::DEFAULT && dynamic_cast<const ScLineBreakCell*>( pState) ) + { + const ScLineBreakCell* pItem = static_cast<const ScLineBreakCell*>(pState); + mxCBXWrapText->set_active(pItem->GetValue()); + } + else if(eState == SfxItemState::DONTCARE) + { + mxCBXWrapText->set_state(TRISTATE_INDET); + } + } + break; + case SID_ATTR_ALIGN_STACKED: + if (eState >= SfxItemState::DEFAULT) + { + const SfxBoolItem* pStackItem = static_cast<const ScVerticalStackCell*>(pState); + mbMultiDisable = pStackItem->GetValue(); + mxCBStacked->set_active(mbMultiDisable); + mxTextOrientBox->set_sensitive(!mbMultiDisable); + } + else + { + mbMultiDisable = true; + mxTextOrientBox->set_sensitive(false); + mxCBStacked->set_state(TRISTATE_INDET); + } + break; + case SID_ATTR_ALIGN_LOCKPOS: + if( eState >= SfxItemState::DEFAULT) + { + const SvxRotateModeItem* pItem = static_cast<const SvxRotateModeItem*>(pState); + SvxRotateMode eMode = pItem->GetValue(); + mxRefEdgeBottom->set_active(eMode == SVX_ROTATE_MODE_BOTTOM); + mxRefEdgeTop->set_active(eMode == SVX_ROTATE_MODE_TOP); + mxRefEdgeStd->set_active(eMode == SVX_ROTATE_MODE_STANDARD); + } + break; + case SID_ATTR_ALIGN_DEGREES: + if (eState >= SfxItemState::DEFAULT) + { + Degree100 nTmp = static_cast<const ScRotateValueItem*>(pState)->GetValue(); + mxMtrAngle->set_value(toDegrees(nTmp), FieldUnit::DEGREE); + } + else + { + mxMtrAngle->set_text( OUString() ); + } + break; + } +} + +// namespace close + +} // end of namespace ::sc::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/sidebar/AlignmentPropertyPanel.hxx b/sc/source/ui/sidebar/AlignmentPropertyPanel.hxx new file mode 100644 index 000000000..7de9cc633 --- /dev/null +++ b/sc/source/ui/sidebar/AlignmentPropertyPanel.hxx @@ -0,0 +1,112 @@ +/* -*- 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 . + */ +#pragma once + +#include <sfx2/sidebar/ControllerItem.hxx> +#include <sfx2/sidebar/IContextChangeReceiver.hxx> +#include <sfx2/weldutils.hxx> +#include <sfx2/sidebar/PanelLayout.hxx> +#include <vcl/EnumContext.hxx> + +namespace sc::sidebar { + +class AlignmentPropertyPanel +: public PanelLayout, + public ::sfx2::sidebar::IContextChangeReceiver, + public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface +{ +public: + static std::unique_ptr<PanelLayout> Create( + weld::Widget* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings); + + virtual void HandleContextChange( + const vcl::EnumContext& rContext) override; + + virtual void NotifyItemUpdate( + const sal_uInt16 nSId, + const SfxItemState eState, + const SfxPoolItem* pState) override; + + virtual void GetControlState( + const sal_uInt16 /*nSId*/, + boost::property_tree::ptree& /*rState*/) override {}; + + SfxBindings* GetBindings() { return mpBindings;} + + // constructor/destructor + AlignmentPropertyPanel( + weld::Widget* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings); + virtual ~AlignmentPropertyPanel() override; + +private: + //ui controls + std::unique_ptr<weld::Label> mxFTLeftIndent; + std::unique_ptr<weld::MetricSpinButton> mxMFLeftIndent; + std::unique_ptr<weld::CheckButton> mxCBXWrapText; + std::unique_ptr<weld::CheckButton> mxCBXMergeCell; + std::unique_ptr<weld::Label> mxFtRotate; + std::unique_ptr<weld::MetricSpinButton> mxMtrAngle; + std::unique_ptr<weld::ToggleButton> mxRefEdgeBottom; + std::unique_ptr<weld::ToggleButton> mxRefEdgeTop; + std::unique_ptr<weld::ToggleButton> mxRefEdgeStd; + std::unique_ptr<weld::CheckButton> mxCBStacked; + std::unique_ptr<weld::Widget> mxTextOrientBox; + + std::unique_ptr<weld::Toolbar> mxHorizontalAlign; + std::unique_ptr<ToolbarUnoDispatcher> mxHorizontalAlignDispatch; + + std::unique_ptr<weld::Toolbar> mxVertAlign; + std::unique_ptr<ToolbarUnoDispatcher> mxVertAlignDispatch; + + std::unique_ptr<weld::Toolbar> mxWriteDirection; + std::unique_ptr<ToolbarUnoDispatcher> mxWriteDirectionDispatch; + + std::unique_ptr<weld::Toolbar> mxIndentButtons; + std::unique_ptr<ToolbarUnoDispatcher> mxIndentButtonsDispatch; + + ::sfx2::sidebar::ControllerItem maAlignHorControl; + ::sfx2::sidebar::ControllerItem maLeftIndentControl; + ::sfx2::sidebar::ControllerItem maMergeCellControl; + ::sfx2::sidebar::ControllerItem maWrapTextControl; + ::sfx2::sidebar::ControllerItem maAngleControl; + ::sfx2::sidebar::ControllerItem maVrtStackControl; + ::sfx2::sidebar::ControllerItem maRefEdgeControl; + + bool mbMultiDisable : 1; + + vcl::EnumContext maContext; + SfxBindings* mpBindings; + + DECL_LINK( MFLeftIndentMdyHdl, weld::MetricSpinButton&, void ); + DECL_LINK( CBOXMergnCellClkHdl, weld::Toggleable&, void ); + DECL_LINK( CBOXWrapTextClkHdl, weld::Toggleable&, void ); + DECL_LINK( AngleModifiedHdl, weld::MetricSpinButton&, void ); + DECL_LINK( ClickStackHdl, weld::Toggleable&, void ); + DECL_LINK( ReferenceEdgeHdl, weld::Button&, void ); + + void Initialize(); +}; + +} // end of namespace ::sc::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx b/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx new file mode 100644 index 000000000..d09b8a5ca --- /dev/null +++ b/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx @@ -0,0 +1,506 @@ +/* -*- 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 "CellAppearancePropertyPanel.hxx" +#include <sc.hrc> +#include <bitmaps.hlst> +#include <sfx2/bindings.hxx> +#include <sfx2/weldutils.hxx> +#include <svtools/toolbarmenu.hxx> +#include <editeng/borderline.hxx> +#include <editeng/boxitem.hxx> +#include <editeng/lineitem.hxx> +#include <vcl/svapp.hxx> +#include <vcl/settings.hxx> +#include <vcl/virdev.hxx> +#include <com/sun/star/lang/IllegalArgumentException.hpp> +#include "CellLineStyleControl.hxx" +#include "CellBorderStyleControl.hxx" + +using namespace css; +using namespace css::uno; + +constexpr OStringLiteral SETBORDERSTYLE = "SetBorderStyle"; +constexpr OStringLiteral LINESTYLE = "LineStyle"; + +// namespace open + +namespace sc::sidebar { + +CellAppearancePropertyPanel::CellAppearancePropertyPanel( + weld::Widget* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings) +: PanelLayout(pParent, "CellAppearancePropertyPanel", "modules/scalc/ui/sidebarcellappearance.ui"), + + mxTBCellBorder(m_xBuilder->weld_toolbar("cellbordertype")), + mxTBCellBackground(m_xBuilder->weld_toolbar("cellbackgroundcolor")), + mxBackColorDispatch(new ToolbarUnoDispatcher(*mxTBCellBackground, *m_xBuilder, rxFrame)), + mxTBLineStyle(m_xBuilder->weld_toolbar("borderlinestyle")), + mxTBLineColor(m_xBuilder->weld_toolbar("borderlinecolor")), + mxLineColorDispatch(new ToolbarUnoDispatcher(*mxTBLineColor, *m_xBuilder, rxFrame)), + + mbCellBorderPopoverCreated(false), + mbLinePopoverCreated(false), + + maLineStyleControl(SID_FRAME_LINESTYLE, *pBindings, *this), + maBorderOuterControl(SID_ATTR_BORDER_OUTER, *pBindings, *this), + maBorderInnerControl(SID_ATTR_BORDER_INNER, *pBindings, *this), + maGridShowControl(FID_TAB_TOGGLE_GRID, *pBindings, *this), + maBorderTLBRControl(SID_ATTR_BORDER_DIAG_TLBR, *pBindings, *this), + maBorderBLTRControl(SID_ATTR_BORDER_DIAG_BLTR, *pBindings, *this), + + maIMGCellBorder(StockImage::Yes, RID_BMP_CELL_BORDER), + msIMGCellBorder(RID_BMP_CELL_BORDER), + msIMGLineStyle1(RID_BMP_LINE_STYLE1), + msIMGLineStyle2(RID_BMP_LINE_STYLE2), + msIMGLineStyle3(RID_BMP_LINE_STYLE3), + msIMGLineStyle4(RID_BMP_LINE_STYLE4), + msIMGLineStyle5(RID_BMP_LINE_STYLE5), + msIMGLineStyle6(RID_BMP_LINE_STYLE6), + msIMGLineStyle7(RID_BMP_LINE_STYLE7), + msIMGLineStyle8(RID_BMP_LINE_STYLE8), + msIMGLineStyle9(RID_BMP_LINE_STYLE9), + + mnInWidth(0), + mnOutWidth(0), + mnDistance(0), + mnDiagTLBRInWidth(0), + mnDiagTLBROutWidth(0), + mnDiagTLBRDistance(0), + mnDiagBLTRInWidth(0), + mnDiagBLTROutWidth(0), + mnDiagBLTRDistance(0), + mbBorderStyleAvailable(true), + mbLeft(false), + mbRight(false), + mbTop(false), + mbBottom(false), + mbVer(false), + mbHor(false), + mbOuterBorder(false), + mbInnerBorder(false), + mbDiagTLBR(false), + mbDiagBLTR(false), + mpBindings(pBindings) +{ + Initialize(); +} + +CellAppearancePropertyPanel::~CellAppearancePropertyPanel() +{ + mxCellBorderPopoverContainer.reset(); + mxTBCellBorder.reset(); + mxBackColorDispatch.reset(); + mxTBCellBackground.reset(); + mxLinePopoverContainer.reset(); + mxTBLineStyle.reset(); + mxLineColorDispatch.reset(); + mxTBLineColor.reset(); + + maLineStyleControl.dispose(); + maBorderOuterControl.dispose(); + maBorderInnerControl.dispose(); + maGridShowControl.dispose(); + maBorderTLBRControl.dispose(); + maBorderBLTRControl.dispose(); +} + +void CellAppearancePropertyPanel::Initialize() +{ + mxTBCellBorder->set_item_icon_name(SETBORDERSTYLE, msIMGCellBorder); + mxCellBorderPopoverContainer.reset(new ToolbarPopupContainer(mxTBCellBorder.get())); + mxTBCellBorder->set_item_popover(SETBORDERSTYLE, mxCellBorderPopoverContainer->getTopLevel()); + mxTBCellBorder->connect_clicked(LINK(this, CellAppearancePropertyPanel, TbxCellBorderSelectHdl)); + mxTBCellBorder->connect_menu_toggled(LINK(this, CellAppearancePropertyPanel, TbxCellBorderMenuHdl)); + + mxTBLineStyle->set_item_icon_name(LINESTYLE, msIMGLineStyle1); + mxLinePopoverContainer.reset(new ToolbarPopupContainer(mxTBLineStyle.get())); + mxTBLineStyle->set_item_popover(LINESTYLE, mxLinePopoverContainer->getTopLevel()); + mxTBLineStyle->connect_clicked(LINK(this, CellAppearancePropertyPanel, TbxLineStyleSelectHdl)); + mxTBLineStyle->connect_menu_toggled(LINK(this, CellAppearancePropertyPanel, TbxLineStyleMenuHdl)); + mxTBLineStyle->set_sensitive(false); + + mxTBLineColor->set_sensitive(false); +} + +IMPL_LINK_NOARG(CellAppearancePropertyPanel, TbxCellBorderSelectHdl, const OString&, void) +{ + mxTBCellBorder->set_menu_item_active(SETBORDERSTYLE, !mxTBCellBorder->get_menu_item_active(SETBORDERSTYLE)); +} + +IMPL_LINK_NOARG(CellAppearancePropertyPanel, TbxCellBorderMenuHdl, const OString&, void) +{ + if (!mxTBCellBorder->get_menu_item_active(SETBORDERSTYLE)) + return; + if (!mbCellBorderPopoverCreated) + { + mxCellBorderPopoverContainer->setPopover(std::make_unique<CellBorderStylePopup>(mxTBCellBorder.get(), SETBORDERSTYLE, GetBindings()->GetDispatcher())); + mbCellBorderPopoverCreated = true; + } + mxCellBorderPopoverContainer->getPopover()->GrabFocus(); +} + +IMPL_LINK_NOARG(CellAppearancePropertyPanel, TbxLineStyleSelectHdl, const OString&, void) +{ + mxTBLineStyle->set_menu_item_active(LINESTYLE, !mxTBLineStyle->get_menu_item_active(LINESTYLE)); +} + +IMPL_LINK_NOARG(CellAppearancePropertyPanel, TbxLineStyleMenuHdl, const OString&, void) +{ + if (!mxTBLineStyle->get_menu_item_active(LINESTYLE)) + return; + if (!mbLinePopoverCreated) + { + mxLinePopoverContainer->setPopover(std::make_unique<CellLineStylePopup>(mxTBLineStyle.get(), LINESTYLE, GetBindings()->GetDispatcher())); + mbLinePopoverCreated = true; + } + auto pPopup = static_cast<CellLineStylePopup*>(mxLinePopoverContainer->getPopover()); + pPopup->SetLineStyleSelect(mnOutWidth, mnInWidth, mnDistance); + pPopup->GrabFocus(); +} + +std::unique_ptr<PanelLayout> CellAppearancePropertyPanel::Create ( + weld::Widget* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings) +{ + if (pParent == nullptr) + throw lang::IllegalArgumentException("no parent Window given to CellAppearancePropertyPanel::Create", nullptr, 0); + if ( ! rxFrame.is()) + throw lang::IllegalArgumentException("no XFrame given to CellAppearancePropertyPanel::Create", nullptr, 1); + if (pBindings == nullptr) + throw lang::IllegalArgumentException("no SfxBindings given to CellAppearancePropertyPanel::Create", nullptr, 2); + + return std::make_unique<CellAppearancePropertyPanel>(pParent, rxFrame, pBindings); +} + +void CellAppearancePropertyPanel::HandleContextChange(const vcl::EnumContext& rContext) +{ + if (maContext == rContext) + { + // Nothing to do. + return; + } + + maContext = rContext; +} + +void CellAppearancePropertyPanel::NotifyItemUpdate( + sal_uInt16 nSID, + SfxItemState eState, + const SfxPoolItem* pState) +{ + switch(nSID) + { + case SID_FRAME_LINESTYLE: + mbBorderStyleAvailable = false; + if( eState == SfxItemState::DONTCARE ) + { + mbBorderStyleAvailable = true; + mnInWidth = 0; + mnOutWidth = 0; + mnDistance = 0; + } + else if(eState >= SfxItemState::DEFAULT) + { + const SvxLineItem* pSvxLineItem = dynamic_cast< const SvxLineItem* >(pState); + if(pSvxLineItem) + { + const editeng::SvxBorderLine* pLineItem = pSvxLineItem->GetLine(); + mnInWidth = pLineItem->GetInWidth(); + mnOutWidth = pLineItem->GetOutWidth(); + mnDistance = pLineItem->GetDistance(); + mbBorderStyleAvailable = !(mnInWidth == 0 && mnOutWidth == 0 && mnDistance == 0); + } + } + SetStyleIcon(); + break; + case SID_ATTR_BORDER_OUTER: + if(eState >= SfxItemState::DEFAULT) + { + const SvxBoxItem* pBoxItem = dynamic_cast< const SvxBoxItem* >(pState); + + if(pBoxItem) + { + mbLeft=false; + mbRight=false; + mbTop=false; + mbBottom=false; + + if(pBoxItem->GetLeft()) + mbLeft = true; + + if(pBoxItem->GetRight()) + mbRight = true; + + if(pBoxItem->GetTop()) + mbTop = true; + + if(pBoxItem->GetBottom()) + mbBottom = true; + + if(!AllSettings::GetLayoutRTL()) + UpdateCellBorder(mbTop, mbBottom, mbLeft, mbRight, mbVer, mbHor, mbDiagTLBR, mbDiagBLTR); + else + UpdateCellBorder(mbTop, mbBottom, mbRight, mbLeft, mbVer, mbHor, mbDiagTLBR, mbDiagBLTR); + + if(mbLeft || mbRight || mbTop || mbBottom) + mbOuterBorder = true; + else + mbOuterBorder = false; + + UpdateControlState(); + } + } + break; + case SID_ATTR_BORDER_INNER: + if(eState >= SfxItemState::DEFAULT) + { + const SvxBoxInfoItem* pBoxInfoItem = dynamic_cast< const SvxBoxInfoItem* >(pState); + if(pBoxInfoItem) + { + bool bLeft(false), bRight(false), bTop(false), bBottom(false); + + mbVer = false; + mbHor = false; + + if(!pBoxInfoItem->IsValid( SvxBoxInfoItemValidFlags::VERT ) || pBoxInfoItem->GetVert()) + mbVer = true; + + if(!pBoxInfoItem->IsValid( SvxBoxInfoItemValidFlags::HORI ) || pBoxInfoItem->GetHori()) + mbHor = true; + + if(!pBoxInfoItem->IsValid( SvxBoxInfoItemValidFlags::LEFT ) || mbLeft) + bLeft = true; + + if(!pBoxInfoItem->IsValid( SvxBoxInfoItemValidFlags::RIGHT ) || mbRight) + bRight = true; + + if(!pBoxInfoItem->IsValid( SvxBoxInfoItemValidFlags::TOP ) || mbTop) + bTop = true; + + if(!pBoxInfoItem->IsValid( SvxBoxInfoItemValidFlags::BOTTOM ) || mbBottom) + bBottom = true; + + if(!AllSettings::GetLayoutRTL()) + UpdateCellBorder(bTop, bBottom, bLeft, bRight, mbVer, mbHor, mbDiagTLBR, mbDiagBLTR); + else + UpdateCellBorder(bTop, bBottom, bRight, bLeft, mbVer, mbHor, mbDiagTLBR, mbDiagBLTR); + + if(mbVer || mbHor || bLeft || bRight || bTop || bBottom) + mbInnerBorder = true; + else + mbInnerBorder = false; + + UpdateControlState(); + } + } + break; + case SID_ATTR_BORDER_DIAG_TLBR: + mbDiagTLBR = false; + if( eState == SfxItemState::DONTCARE ) + { + mbDiagTLBR = true; + mnDiagTLBRInWidth = mnDiagTLBROutWidth = mnDiagTLBRDistance = 0; + } + else if(eState >= SfxItemState::DEFAULT) + { + const SvxLineItem* pItem = dynamic_cast< const SvxLineItem* >(pState); + if(pItem) + { + const editeng::SvxBorderLine* aLine = pItem->GetLine(); + if(aLine) + { + mnDiagTLBRInWidth = aLine->GetInWidth(); + mnDiagTLBROutWidth = aLine->GetOutWidth(); + mnDiagTLBRDistance = aLine->GetDistance(); + + mbDiagTLBR = !(mnDiagTLBRInWidth == 0 && mnDiagTLBROutWidth == 0 && mnDiagTLBRDistance == 0); + } + } + } + UpdateCellBorder(mbTop, mbBottom, mbLeft, mbRight, mbVer, mbHor, mbDiagTLBR, mbDiagBLTR); + UpdateControlState(); + break; + case SID_ATTR_BORDER_DIAG_BLTR: + mbDiagBLTR = false; + if( eState == SfxItemState::DONTCARE ) + { + mbDiagBLTR = true; + mnDiagBLTRInWidth = mnDiagBLTROutWidth = mnDiagBLTRDistance = 0; + } + else if(eState >= SfxItemState::DEFAULT) + { + const SvxLineItem* pItem = dynamic_cast< const SvxLineItem* >(pState); + if(pItem) + { + const editeng::SvxBorderLine* aLine = pItem->GetLine(); + + if(aLine) + { + mnDiagBLTRInWidth = aLine->GetInWidth(); + mnDiagBLTROutWidth = aLine->GetOutWidth(); + mnDiagBLTRDistance = aLine->GetDistance(); + + mbDiagBLTR = !(mnDiagBLTRInWidth == 0 && mnDiagBLTROutWidth == 0 && mnDiagBLTRDistance == 0); + } + } + } + UpdateCellBorder(mbTop, mbBottom, mbLeft, mbRight, mbVer, mbHor, mbDiagTLBR, mbDiagBLTR); + UpdateControlState(); + break; + } +} + +void CellAppearancePropertyPanel::SetStyleIcon() +{ + //FIXME: update for new line border possibilities + if(mnOutWidth == SvxBorderLineWidth::Hairline && mnInWidth == 0 && mnDistance == 0) //1 + mxTBLineStyle->set_item_icon_name(LINESTYLE, msIMGLineStyle1); + else if(mnOutWidth == SvxBorderLineWidth::Medium && mnInWidth == 0 && mnDistance == 0) //2 + mxTBLineStyle->set_item_icon_name(LINESTYLE, msIMGLineStyle2); + else if(mnOutWidth == SvxBorderLineWidth::Thick && mnInWidth == 0 && mnDistance == 0) //3 + mxTBLineStyle->set_item_icon_name(LINESTYLE, msIMGLineStyle3); + else if(mnOutWidth == SvxBorderLineWidth::ExtraThick && mnInWidth == 0 && mnDistance == 0) //4 + mxTBLineStyle->set_item_icon_name(LINESTYLE, msIMGLineStyle4); + else if(mnOutWidth == SvxBorderLineWidth::Hairline && mnInWidth == SvxBorderLineWidth::Hairline && mnDistance == SvxBorderLineWidth::Thin) //5 + mxTBLineStyle->set_item_icon_name(LINESTYLE, msIMGLineStyle5); + else if(mnOutWidth == SvxBorderLineWidth::Hairline && mnInWidth == SvxBorderLineWidth::Hairline && mnDistance == SvxBorderLineWidth::Medium) //6 + mxTBLineStyle->set_item_icon_name(LINESTYLE, msIMGLineStyle6); + else if(mnOutWidth == SvxBorderLineWidth::Thin && mnInWidth == SvxBorderLineWidth::Medium && mnDistance == SvxBorderLineWidth::Thin) //7 + mxTBLineStyle->set_item_icon_name(LINESTYLE, msIMGLineStyle7); + else if(mnOutWidth == SvxBorderLineWidth::Medium && mnInWidth == SvxBorderLineWidth::Hairline && mnDistance == SvxBorderLineWidth::Medium) //8 + mxTBLineStyle->set_item_icon_name(LINESTYLE, msIMGLineStyle8); + else if(mnOutWidth == SvxBorderLineWidth::Medium && mnInWidth == SvxBorderLineWidth::Medium && mnDistance == SvxBorderLineWidth::Medium) //9 + mxTBLineStyle->set_item_icon_name(LINESTYLE, msIMGLineStyle9); + else + mxTBLineStyle->set_item_icon_name(LINESTYLE, msIMGLineStyle1); +} + +void CellAppearancePropertyPanel::UpdateControlState() +{ + if(mbOuterBorder || mbInnerBorder || mbDiagTLBR || mbDiagBLTR) + { + mxTBLineColor->set_sensitive(true); + mxTBLineStyle->set_sensitive(true); + + //set line style state + if( mbBorderStyleAvailable && !mbDiagTLBR && !mbDiagBLTR ) + { + } + else if( !mbBorderStyleAvailable && mbDiagTLBR && !mbDiagBLTR ) + { + mnInWidth = mnDiagTLBRInWidth; + mnOutWidth = mnDiagTLBROutWidth; + mnDistance = mnDiagTLBRDistance; + } + else if ( !mbBorderStyleAvailable && !mbDiagTLBR && mbDiagBLTR ) + { + mnInWidth = mnDiagBLTRInWidth; + mnOutWidth = mnDiagBLTROutWidth; + mnDistance = mnDiagBLTRDistance; + } + else if( !mbBorderStyleAvailable && mbDiagTLBR && mbDiagBLTR) + { + if( mnDiagTLBRInWidth == mnDiagBLTRInWidth && mnDiagTLBROutWidth == mnDiagBLTROutWidth && mnDiagTLBRDistance == mnDiagBLTRDistance) + { + mnInWidth = mnDiagTLBRInWidth; + mnOutWidth = mnDiagTLBROutWidth; + mnDistance = mnDiagTLBRDistance; + } + else + { + mnInWidth = 0; + mnOutWidth = 0; + mnDistance = 0; + } + } + else if( mbBorderStyleAvailable && mbDiagTLBR && !mbDiagBLTR ) + { + if( mnDiagTLBRInWidth != mnInWidth || mnDiagTLBROutWidth != mnOutWidth || mnDiagTLBRDistance != mnDistance) + { + mnInWidth = 0; + mnOutWidth = 0; + mnDistance = 0; + } + } + else if( mbBorderStyleAvailable && !mbDiagTLBR && mbDiagBLTR ) + { + if( mnDiagBLTRInWidth != mnInWidth || mnDiagBLTROutWidth != mnOutWidth || mnDiagBLTRDistance != mnDistance ) + { + mnInWidth = 0; + mnOutWidth = 0; + mnDistance = 0; + } + } + else + { + mnInWidth = 0; + mnOutWidth = 0; + mnDistance = 0; + } + SetStyleIcon(); + } + else + { + mxTBLineColor->set_sensitive(false); + mxTBLineStyle->set_sensitive(false); + } +} + +void CellAppearancePropertyPanel::UpdateCellBorder(bool bTop, bool bBot, bool bLeft, bool bRight, + bool bVer, bool bHor, bool bTLBR, bool bBLTR) +{ + const Size aBmpSize = maIMGCellBorder.GetBitmapEx().GetSizePixel(); + + if (aBmpSize.Width() == 43 && aBmpSize.Height() == 43) + { + ScopedVclPtr<VirtualDevice> pVirDev(mxTBCellBorder->create_virtual_device()); + pVirDev->SetOutputSizePixel(aBmpSize); + pVirDev->SetLineColor( ::Application::GetSettings().GetStyleSettings().GetFieldTextColor() ) ; + pVirDev->SetFillColor(COL_BLACK); + pVirDev->DrawImage(Point(0, 0), maIMGCellBorder); + Point aTL(2, 1), aTR(42,1), aBL(2, 41), aBR(42, 41), aHL(2,21), aHR(42, 21), aVT(22,1), aVB(22, 41); + if(bLeft) + pVirDev->DrawLine( aTL,aBL ); + if(bRight) + pVirDev->DrawLine( aTR,aBR ); + if(bTop) + pVirDev->DrawLine( aTL,aTR ); + if(bBot) + pVirDev->DrawLine( aBL,aBR ); + if(bVer) + pVirDev->DrawLine( aVT,aVB ); + if(bHor) + pVirDev->DrawLine( aHL,aHR ); + if(bTLBR) + pVirDev->DrawLine( aTL,aBR ); + if(bBLTR) + pVirDev->DrawLine( aBL,aTR ); + mxTBCellBorder->set_item_image(SETBORDERSTYLE, pVirDev); + } + else + mxTBCellBorder->set_item_icon_name(SETBORDERSTYLE, msIMGCellBorder); +} +// namespace close + +} // end of namespace ::sc::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/sidebar/CellAppearancePropertyPanel.hxx b/sc/source/ui/sidebar/CellAppearancePropertyPanel.hxx new file mode 100644 index 000000000..412cd37e1 --- /dev/null +++ b/sc/source/ui/sidebar/CellAppearancePropertyPanel.hxx @@ -0,0 +1,147 @@ +/* -*- 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 . + */ +#pragma once + +#include <sfx2/sidebar/ControllerItem.hxx> +#include <sfx2/sidebar/IContextChangeReceiver.hxx> +#include <sfx2/sidebar/PanelLayout.hxx> +#include <vcl/EnumContext.hxx> +#include <vcl/image.hxx> +#include <com/sun/star/frame/XFrame.hpp> + +class ToolbarUnoDispatcher; +class ToolbarPopupContainer; + +namespace sc::sidebar { + +class CellAppearancePropertyPanel +: public PanelLayout, + public ::sfx2::sidebar::IContextChangeReceiver, + public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface +{ +private: + friend class CellLineStylePopup; + friend class CellBorderStylePopup; + +public: + static std::unique_ptr<PanelLayout> Create( + weld::Widget* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings); + + virtual void HandleContextChange( + const vcl::EnumContext& rContext) override; + + virtual void NotifyItemUpdate( + const sal_uInt16 nSId, + const SfxItemState eState, + const SfxPoolItem* pState) override; + + virtual void GetControlState( + const sal_uInt16 /*nSId*/, + boost::property_tree::ptree& /*rState*/) override {}; + + SfxBindings* GetBindings() { return mpBindings;} + + // constructor/destructor + CellAppearancePropertyPanel( + weld::Widget* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings); + virtual ~CellAppearancePropertyPanel() override; + +private: + //ui controls + + std::unique_ptr<ToolbarPopupContainer> mxCellBorderPopoverContainer; + std::unique_ptr<weld::Toolbar> mxTBCellBorder; + std::unique_ptr<weld::Toolbar> mxTBCellBackground; + std::unique_ptr<ToolbarUnoDispatcher> mxBackColorDispatch; + std::unique_ptr<ToolbarPopupContainer> mxLinePopoverContainer; + std::unique_ptr<weld::Toolbar> mxTBLineStyle; + std::unique_ptr<weld::Toolbar> mxTBLineColor; + std::unique_ptr<ToolbarUnoDispatcher> mxLineColorDispatch; + + bool mbCellBorderPopoverCreated; + bool mbLinePopoverCreated; + + ::sfx2::sidebar::ControllerItem maLineStyleControl; + ::sfx2::sidebar::ControllerItem maBorderOuterControl; + ::sfx2::sidebar::ControllerItem maBorderInnerControl; + ::sfx2::sidebar::ControllerItem maGridShowControl; + ::sfx2::sidebar::ControllerItem maBorderTLBRControl; + ::sfx2::sidebar::ControllerItem maBorderBLTRControl; + + // images + Image maIMGCellBorder; + OUString msIMGCellBorder; + OUString msIMGLineStyle1; + OUString msIMGLineStyle2; + OUString msIMGLineStyle3; + OUString msIMGLineStyle4; + OUString msIMGLineStyle5; + OUString msIMGLineStyle6; + OUString msIMGLineStyle7; + OUString msIMGLineStyle8; + OUString msIMGLineStyle9; + + // BorderStyle defines + sal_uInt16 mnInWidth; + sal_uInt16 mnOutWidth; + sal_uInt16 mnDistance; + sal_uInt16 mnDiagTLBRInWidth; + sal_uInt16 mnDiagTLBROutWidth; + sal_uInt16 mnDiagTLBRDistance; + sal_uInt16 mnDiagBLTRInWidth; + sal_uInt16 mnDiagBLTROutWidth; + sal_uInt16 mnDiagBLTRDistance; + + bool mbBorderStyleAvailable : 1; + + // CellBorder defines + bool mbLeft : 1; + bool mbRight : 1; + bool mbTop : 1; + bool mbBottom : 1; + bool mbVer : 1; + bool mbHor : 1; + + bool mbOuterBorder : 1; // mbLeft || mbRight || mbTop || mbBottom + bool mbInnerBorder : 1; // mbVer || mbHor || bLeft || bRight || bTop || bBottom + + bool mbDiagTLBR : 1; + bool mbDiagBLTR : 1; + + vcl::EnumContext maContext; + SfxBindings* mpBindings; + + DECL_LINK(TbxCellBorderSelectHdl, const OString&, void); + DECL_LINK(TbxCellBorderMenuHdl, const OString&, void); + DECL_LINK(TbxLineStyleSelectHdl, const OString&, void); + DECL_LINK(TbxLineStyleMenuHdl, const OString&, void); + + void Initialize(); + void SetStyleIcon(); + void UpdateControlState(); + void UpdateCellBorder(bool bTop, bool bBot, bool bLeft, bool bRight, bool bVer, bool bHor, bool bTLBR, bool bBLTR); +}; + +} // end of namespace ::sc::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/sidebar/CellBorderStyleControl.cxx b/sc/source/ui/sidebar/CellBorderStyleControl.cxx new file mode 100644 index 000000000..6749588b9 --- /dev/null +++ b/sc/source/ui/sidebar/CellBorderStyleControl.cxx @@ -0,0 +1,281 @@ +/* -*- 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 "CellBorderStyleControl.hxx" +#include <editeng/boxitem.hxx> +#include <editeng/borderline.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <svx/svxids.hrc> +#include <vcl/settings.hxx> +#include <editeng/lineitem.hxx> +#include <memory> + +namespace sc::sidebar { + +#define FRM_VALID_LEFT 0x01 +#define FRM_VALID_RIGHT 0x02 +#define FRM_VALID_TOP 0x04 +#define FRM_VALID_BOTTOM 0x08 +#define FRM_VALID_HINNER 0x10 +#define FRM_VALID_VINNER 0x20 +#define FRM_VALID_OUTER 0x0f +#define FRM_VALID_ALL 0xff + +CellBorderStylePopup::CellBorderStylePopup(weld::Toolbar* pParent, const OString& rId, SfxDispatcher* pDispatcher) + : WeldToolbarPopup(nullptr, pParent, "modules/scalc/ui/floatingborderstyle.ui", "FloatingBorderStyle") + , maToolButton(pParent, rId) + , mpDispatcher(pDispatcher) + , mxTBBorder1(m_xBuilder->weld_toolbar("border1")) + , mxTBBorder2(m_xBuilder->weld_toolbar("border2")) + , mxTBBorder3(m_xBuilder->weld_toolbar("border3")) + , mxTBBorder4(m_xBuilder->weld_toolbar("border4")) +{ + Initialize(); +} + +void CellBorderStylePopup::GrabFocus() +{ + mxTBBorder1->grab_focus(); +} + +CellBorderStylePopup::~CellBorderStylePopup() +{ +} + +void CellBorderStylePopup::Initialize() +{ + mxTBBorder1->connect_clicked ( LINK(this, CellBorderStylePopup, TB1SelectHdl) ); + + mxTBBorder2->connect_clicked ( LINK(this, CellBorderStylePopup, TB2and3SelectHdl) ); + mxTBBorder3->connect_clicked ( LINK(this, CellBorderStylePopup, TB2and3SelectHdl) ); + + mxTBBorder4->connect_clicked ( LINK(this, CellBorderStylePopup, TB4SelectHdl) ); +} + +IMPL_LINK(CellBorderStylePopup, TB1SelectHdl, const OString&, rId, void) +{ + SvxBoxItem aBorderOuter( SID_ATTR_BORDER_OUTER ); + SvxBoxInfoItem aBorderInner( SID_ATTR_BORDER_INNER ); + editeng::SvxBorderLine theDefLine(nullptr, SvxBorderLineWidth::Thin); + editeng::SvxBorderLine *pLeft = nullptr, *pRight = nullptr, *pTop = nullptr, *pBottom = nullptr; + sal_uInt8 nValidFlags = 0; + + if (rId == "none") + { + nValidFlags |= FRM_VALID_ALL; + SvxLineItem aLineItem1( SID_ATTR_BORDER_DIAG_BLTR ); + SvxLineItem aLineItem2( SID_ATTR_BORDER_DIAG_TLBR ); + aLineItem1.SetLine( nullptr ); //modify + aLineItem2.SetLine( nullptr ); //modify + mpDispatcher->ExecuteList( + SID_ATTR_BORDER_DIAG_BLTR, SfxCallMode::RECORD, { &aLineItem1 }); + mpDispatcher->ExecuteList( + SID_ATTR_BORDER_DIAG_TLBR, SfxCallMode::RECORD, { &aLineItem2 }); + } + else if (rId == "all") + { + pLeft = pRight = pTop = pBottom = &theDefLine; + aBorderInner.SetLine( &theDefLine, SvxBoxInfoItemLine::HORI ); + aBorderInner.SetLine( &theDefLine, SvxBoxInfoItemLine::VERT ); + nValidFlags |= FRM_VALID_ALL; + } + else if (rId == "outside") + { + pLeft = pRight = pTop = pBottom = &theDefLine; + nValidFlags |= FRM_VALID_OUTER; + } + else if (rId == "thickbox") + { + theDefLine.SetWidth(SvxBorderLineWidth::Thick); + pLeft = pRight = pTop = pBottom = &theDefLine; + nValidFlags |= FRM_VALID_OUTER; + } + + aBorderOuter.SetLine( pLeft, SvxBoxItemLine::LEFT ); + aBorderOuter.SetLine( pRight, SvxBoxItemLine::RIGHT ); + aBorderOuter.SetLine( pTop, SvxBoxItemLine::TOP ); + aBorderOuter.SetLine( pBottom, SvxBoxItemLine::BOTTOM ); + + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::TOP, 0 != (nValidFlags&FRM_VALID_TOP )); + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::BOTTOM, 0 != (nValidFlags&FRM_VALID_BOTTOM )); + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::LEFT, 0 != (nValidFlags&FRM_VALID_LEFT)); + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::RIGHT, 0 != (nValidFlags&FRM_VALID_RIGHT )); + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::HORI, 0 != (nValidFlags&FRM_VALID_HINNER )); + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::VERT, 0 != (nValidFlags&FRM_VALID_VINNER)); + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::DISTANCE ); + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::DISABLE, false ); + + mpDispatcher->ExecuteList( + SID_ATTR_BORDER, SfxCallMode::RECORD, { &aBorderOuter, &aBorderInner }); + + maToolButton.set_inactive(); +} + +IMPL_LINK(CellBorderStylePopup, TB2and3SelectHdl, const OString&, rId, void) +{ + if (rId == "diagup") + { + editeng::SvxBorderLine aTmp( nullptr, SvxBorderLineWidth::Thin ); + SvxLineItem aLineItem( SID_ATTR_BORDER_DIAG_BLTR ); + aLineItem.SetLine( &aTmp ); + mpDispatcher->ExecuteList( + SID_ATTR_BORDER_DIAG_BLTR, SfxCallMode::RECORD, { &aLineItem }); + } + else if (rId == "diagdown") + { + editeng::SvxBorderLine aTmp( nullptr, SvxBorderLineWidth::Thin ); + SvxLineItem aLineItem( SID_ATTR_BORDER_DIAG_TLBR ); + aLineItem.SetLine( &aTmp ); + mpDispatcher->ExecuteList( + SID_ATTR_BORDER_DIAG_TLBR, SfxCallMode::RECORD, { &aLineItem }); + } + else + { + SvxBoxItem aBorderOuter( SID_ATTR_BORDER_OUTER ); + SvxBoxInfoItem aBorderInner( SID_ATTR_BORDER_INNER ); + editeng::SvxBorderLine theDefLine(nullptr, SvxBorderLineWidth::Thin); + editeng::SvxBorderLine *pLeft = nullptr, + *pRight = nullptr, + *pTop = nullptr, + *pBottom = nullptr; + sal_uInt8 nValidFlags = 0; + if (rId == "left") + { + pLeft = &theDefLine; + nValidFlags |= FRM_VALID_LEFT; + } + else if (rId == "right") + { + if(!AllSettings::GetLayoutRTL()) + { + pRight = &theDefLine; + nValidFlags |= FRM_VALID_RIGHT; + } + else + { + pLeft = &theDefLine; + nValidFlags |= FRM_VALID_LEFT; + } + } + else if (rId == "top") + { + pTop = &theDefLine; + nValidFlags |= FRM_VALID_TOP; + } + else if (rId == "bottom") + { + pBottom = &theDefLine; + nValidFlags |= FRM_VALID_BOTTOM; + } + else if (rId == "topbottom") + { + pTop = pBottom = &theDefLine; + nValidFlags |= FRM_VALID_BOTTOM|FRM_VALID_TOP; + } + else if (rId == "leftright") + { + pLeft = pRight = &theDefLine; + nValidFlags |= FRM_VALID_RIGHT|FRM_VALID_LEFT; + } + aBorderOuter.SetLine( pLeft, SvxBoxItemLine::LEFT ); + aBorderOuter.SetLine( pRight, SvxBoxItemLine::RIGHT ); + aBorderOuter.SetLine( pTop, SvxBoxItemLine::TOP ); + aBorderOuter.SetLine( pBottom, SvxBoxItemLine::BOTTOM ); + + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::TOP, 0 != (nValidFlags&FRM_VALID_TOP )); + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::BOTTOM, 0 != (nValidFlags&FRM_VALID_BOTTOM )); + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::LEFT, 0 != (nValidFlags&FRM_VALID_LEFT)); + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::RIGHT, 0 != (nValidFlags&FRM_VALID_RIGHT )); + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::HORI, 0 != (nValidFlags&FRM_VALID_HINNER )); + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::VERT, 0 != (nValidFlags&FRM_VALID_VINNER)); + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::DISTANCE ); + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::DISABLE, false ); + + mpDispatcher->ExecuteList( + SID_ATTR_BORDER, SfxCallMode::RECORD, { &aBorderOuter, &aBorderInner}); + } + + maToolButton.set_inactive(); +} + +IMPL_LINK(CellBorderStylePopup, TB4SelectHdl, const OString&, rId, void) +{ + SvxBoxItem aBorderOuter( SID_ATTR_BORDER_OUTER ); + SvxBoxInfoItem aBorderInner( SID_ATTR_BORDER_INNER ); + std::unique_ptr<editeng::SvxBorderLine> pTop; + std::unique_ptr<editeng::SvxBorderLine> pBottom; + sal_uInt8 nValidFlags = 0; + using namespace ::com::sun::star::table::BorderLineStyle; + + //FIXME: properly adapt to new line border model + + if (rId == "thickbottom") + { + pBottom.reset(new editeng::SvxBorderLine(nullptr, SvxBorderLineWidth::Thick)); + nValidFlags |= FRM_VALID_BOTTOM; + } + else if (rId == "doublebottom") + { + pBottom.reset(new editeng::SvxBorderLine(nullptr)); + pBottom->GuessLinesWidths(SvxBorderLineStyle::DOUBLE, SvxBorderLineWidth::Hairline, + SvxBorderLineWidth::Hairline, SvxBorderLineWidth::Thin); + nValidFlags |= FRM_VALID_BOTTOM; + } + else if (rId == "topthickbottom") + { + pBottom.reset(new editeng::SvxBorderLine(nullptr, SvxBorderLineWidth::Thick)); + pTop.reset(new editeng::SvxBorderLine(nullptr, SvxBorderLineWidth::Thin)); + nValidFlags |= FRM_VALID_BOTTOM|FRM_VALID_TOP; + } + else if (rId == "topdoublebottom") + { + pBottom.reset(new editeng::SvxBorderLine(nullptr)); + pBottom->GuessLinesWidths(SvxBorderLineStyle::DOUBLE, SvxBorderLineWidth::Hairline, + SvxBorderLineWidth::Hairline, SvxBorderLineWidth::Thin); + pTop.reset(new editeng::SvxBorderLine(nullptr, SvxBorderLineWidth::Thin)); + nValidFlags |= FRM_VALID_BOTTOM|FRM_VALID_TOP; + } + + aBorderOuter.SetLine( pTop.get(), SvxBoxItemLine::TOP ); + aBorderOuter.SetLine( pBottom.get(), SvxBoxItemLine::BOTTOM ); + aBorderOuter.SetLine( nullptr, SvxBoxItemLine::LEFT ); + aBorderOuter.SetLine( nullptr, SvxBoxItemLine::RIGHT ); + + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::TOP, 0 != (nValidFlags&FRM_VALID_TOP )); + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::BOTTOM, 0 != (nValidFlags&FRM_VALID_BOTTOM )); + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::LEFT, 0 != (nValidFlags&FRM_VALID_LEFT )); + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::RIGHT, 0 != (nValidFlags&FRM_VALID_RIGHT )); + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::HORI, 0 != (nValidFlags&FRM_VALID_HINNER )); + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::VERT, 0 != (nValidFlags&FRM_VALID_VINNER)); + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::DISTANCE ); + aBorderInner.SetValid( SvxBoxInfoItemValidFlags::DISABLE, false ); + + mpDispatcher->ExecuteList( + SID_ATTR_BORDER, SfxCallMode::RECORD, { &aBorderOuter, &aBorderInner }); + + pTop.reset(); + pBottom.reset(); + + maToolButton.set_inactive(); +} + +} // end of namespace sc::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/sidebar/CellBorderStyleControl.hxx b/sc/source/ui/sidebar/CellBorderStyleControl.hxx new file mode 100644 index 000000000..f6ae6891b --- /dev/null +++ b/sc/source/ui/sidebar/CellBorderStyleControl.hxx @@ -0,0 +1,52 @@ +/* -*- 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 . + */ +#pragma once + +#include <svtools/toolbarmenu.hxx> +#include <svx/colorwindow.hxx> + +class SfxDispatcher; + +namespace sc::sidebar +{ +class CellBorderStylePopup : public WeldToolbarPopup +{ +private: + MenuOrToolMenuButton maToolButton; + SfxDispatcher* mpDispatcher; + std::unique_ptr<weld::Toolbar> mxTBBorder1; + std::unique_ptr<weld::Toolbar> mxTBBorder2; + std::unique_ptr<weld::Toolbar> mxTBBorder3; + std::unique_ptr<weld::Toolbar> mxTBBorder4; + + void Initialize(); + + DECL_LINK(TB1SelectHdl, const OString&, void); + DECL_LINK(TB2and3SelectHdl, const OString&, void); + DECL_LINK(TB4SelectHdl, const OString&, void); + +public: + CellBorderStylePopup(weld::Toolbar* pParent, const OString& rId, SfxDispatcher* pDispatcher); + virtual void GrabFocus() override; + virtual ~CellBorderStylePopup() override; +}; + +} // end of namespace svx::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/sidebar/CellLineStyleControl.cxx b/sc/source/ui/sidebar/CellLineStyleControl.cxx new file mode 100644 index 000000000..5c27ee5a5 --- /dev/null +++ b/sc/source/ui/sidebar/CellLineStyleControl.cxx @@ -0,0 +1,243 @@ +/* -*- 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 "CellLineStyleControl.hxx" +#include "CellLineStyleValueSet.hxx" +#include <vcl/i18nhelp.hxx> +#include <vcl/settings.hxx> +#include <vcl/svapp.hxx> +#include <editeng/borderline.hxx> +#include <editeng/lineitem.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <svx/svxids.hrc> +#include <scresid.hxx> +#include <strings.hrc> + +namespace sc::sidebar { + +CellLineStylePopup::CellLineStylePopup(weld::Toolbar* pParent, const OString& rId, SfxDispatcher* pDispatcher) + : WeldToolbarPopup(nullptr, pParent, "modules/scalc/ui/floatinglinestyle.ui", "FloatingLineStyle") + , maToolButton(pParent, rId) + , mpDispatcher(pDispatcher) + , mxCellLineStyleValueSet(new sc::sidebar::CellLineStyleValueSet) + , mxCellLineStyleValueSetWin(new weld::CustomWeld(*m_xBuilder, "linestylevalueset", *mxCellLineStyleValueSet)) + , mxPushButtonMoreOptions(m_xBuilder->weld_button("more")) +{ + Initialize(); +} + +CellLineStylePopup::~CellLineStylePopup() +{ +} + +void CellLineStylePopup::Initialize() +{ + mxPushButtonMoreOptions->connect_clicked(LINK(this, CellLineStylePopup, PBClickHdl)); + + mxCellLineStyleValueSet->SetStyle(mxCellLineStyleValueSet->GetStyle()| WB_3DLOOK | WB_NO_DIRECTSELECT); + + for(sal_uInt16 i = 1 ; i <= CELL_LINE_STYLE_ENTRIES ; i++) + { + mxCellLineStyleValueSet->InsertItem(i); + } + + const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetLocaleI18nHelper(); + maStr[0] = ScResId(STR_BORDER_HAIRLINE).replaceFirst("%s", rI18nHelper.GetNum(5, 2)); + maStr[1] = ScResId(STR_BORDER_VERY_THIN).replaceFirst("%s", rI18nHelper.GetNum(50, 2)); + maStr[2] = ScResId(STR_BORDER_THIN).replaceFirst("%s", rI18nHelper.GetNum(75, 2)); + maStr[3] = ScResId(STR_BORDER_MEDIUM).replaceFirst("%s", rI18nHelper.GetNum(150, 2)); + maStr[4] = ScResId(STR_BORDER_THICK).replaceFirst("%s", rI18nHelper.GetNum(225, 2)); + maStr[5] = ScResId(STR_BORDER_EXTRA_THICK).replaceFirst("%s", rI18nHelper.GetNum(450, 2)); + + // Numbers in pt are the total width of the double line (inner + outer + distance) + maStr[6] = ScResId(STR_BORDER_DOUBLE_1).replaceFirst("%s", rI18nHelper.GetNum(110, 2)); + maStr[7] = ScResId(STR_BORDER_DOUBLE_1).replaceFirst("%s", rI18nHelper.GetNum(235, 2)); + maStr[8] = ScResId(STR_BORDER_DOUBLE_2).replaceFirst("%s", rI18nHelper.GetNum(300, 2)); + maStr[9] = ScResId(STR_BORDER_DOUBLE_3).replaceFirst("%s", rI18nHelper.GetNum(305, 2)); + maStr[10] = ScResId(STR_BORDER_DOUBLE_4).replaceFirst("%s", rI18nHelper.GetNum(450, 2)); + mxCellLineStyleValueSet->SetUnit(&maStr[0]); + + for (sal_uInt16 i = 1; i <= CELL_LINE_STYLE_ENTRIES; ++i) + { + mxCellLineStyleValueSet->SetItemText(i, maStr[i-1]); + } + + SetAllNoSel(); + mxCellLineStyleValueSet->SetSelectHdl(LINK(this, CellLineStylePopup, VSSelectHdl)); +} + +void CellLineStylePopup::GrabFocus() +{ + mxCellLineStyleValueSet->GrabFocus(); +} + +void CellLineStylePopup::SetAllNoSel() +{ + mxCellLineStyleValueSet->SelectItem(0); + mxCellLineStyleValueSet->SetNoSelection(); + mxCellLineStyleValueSet->SetFormat(); + mxCellLineStyleValueSet->Invalidate(); +} + +IMPL_LINK_NOARG(CellLineStylePopup, VSSelectHdl, ValueSet*, void) +{ + const sal_uInt16 iPos(mxCellLineStyleValueSet->GetSelectedItemId()); + SvxLineItem aLineItem(SID_FRAME_LINESTYLE); + SvxBorderLineStyle nStyle = SvxBorderLineStyle::SOLID; + sal_uInt16 n1 = 0; + sal_uInt16 n2 = 0; + sal_uInt16 n3 = 0; + + //FIXME: fully for new border line possibilities + + switch(iPos) + { + case 1: + n1 = SvxBorderLineWidth::Hairline; + break; + case 2: + n1 = SvxBorderLineWidth::VeryThin; + break; + case 3: + n1 = SvxBorderLineWidth::Thin; + break; + case 4: + n1 = SvxBorderLineWidth::Medium; + break; + case 5: + n1 = SvxBorderLineWidth::Thick; + break; + case 6: + n1 = SvxBorderLineWidth::ExtraThick; + break; + case 7: + n1 = SvxBorderLineWidth::Hairline; + n2 = SvxBorderLineWidth::Hairline; + n3 = SvxBorderLineWidth::Medium; + nStyle = SvxBorderLineStyle::DOUBLE; + break; + case 8: + n1 = SvxBorderLineWidth::Hairline; + n2 = SvxBorderLineWidth::Hairline; + n3 = SvxBorderLineWidth::Thick; + nStyle = SvxBorderLineStyle::DOUBLE; + break; + case 9: + n1 = SvxBorderLineWidth::Thin; + n2 = SvxBorderLineWidth::Medium; + n3 = SvxBorderLineWidth::Thin; + nStyle = SvxBorderLineStyle::DOUBLE; + break; + case 10: + n1 = SvxBorderLineWidth::Medium; + n2 = SvxBorderLineWidth::Hairline; + n3 = SvxBorderLineWidth::Medium; + nStyle = SvxBorderLineStyle::DOUBLE; + break; + case 11: + n1 = SvxBorderLineWidth::Medium; + n2 = SvxBorderLineWidth::Medium; + n3 = SvxBorderLineWidth::Medium; + nStyle = SvxBorderLineStyle::DOUBLE; + break; + default: + break; + } + + editeng::SvxBorderLine aTmp; + aTmp.GuessLinesWidths(nStyle, n1, n2, n3); + aLineItem.SetLine( &aTmp ); + mpDispatcher->ExecuteList( + SID_FRAME_LINESTYLE, SfxCallMode::RECORD, { &aLineItem }); + SetAllNoSel(); + + maToolButton.set_inactive(); +} + +IMPL_LINK_NOARG(CellLineStylePopup, PBClickHdl, weld::Button&, void) +{ + mpDispatcher->Execute(SID_CELL_FORMAT_BORDER, SfxCallMode::ASYNCHRON); + maToolButton.set_inactive(); +} + +void CellLineStylePopup::SetLineStyleSelect(sal_uInt16 out, sal_uInt16 in, sal_uInt16 dis) +{ + mxCellLineStyleValueSet->GrabFocus(); + SetAllNoSel(); + + //FIXME: fully for new border line possibilities + + if(out == SvxBorderLineWidth::Hairline && in == 0 && dis == 0) //1 + { + mxCellLineStyleValueSet->SetSelItem(1); + } + else if(out == SvxBorderLineWidth::VeryThin && in == 0 && dis == 0) //2 + { + mxCellLineStyleValueSet->SetSelItem(2); + } + else if(out == SvxBorderLineWidth::Thin && in == 0 && dis == 0) //3 + { + mxCellLineStyleValueSet->SetSelItem(3); + } + else if(out == SvxBorderLineWidth::Medium && in == 0 && dis == 0) //4 + { + mxCellLineStyleValueSet->SetSelItem(4); + } + else if(out == SvxBorderLineWidth::Thick && in == 0 && dis == 0) //5 + { + mxCellLineStyleValueSet->SetSelItem(5); + } + else if(out == SvxBorderLineWidth::ExtraThick && in == 0 && dis == 0) //6 + { + mxCellLineStyleValueSet->SetSelItem(6); + } + else if(out == SvxBorderLineWidth::Hairline && in == SvxBorderLineWidth::Hairline && dis == SvxBorderLineWidth::Thin) //7 + { + mxCellLineStyleValueSet->SetSelItem(7); + } + else if(out == SvxBorderLineWidth::Hairline && in == SvxBorderLineWidth::Hairline && dis == SvxBorderLineWidth::Medium) //8 + { + mxCellLineStyleValueSet->SetSelItem(8); + } + else if(out == SvxBorderLineWidth::Thin && in == SvxBorderLineWidth::Medium && dis == SvxBorderLineWidth::Thin) //9 + { + mxCellLineStyleValueSet->SetSelItem(9); + } + else if(out == SvxBorderLineWidth::Medium && in == SvxBorderLineWidth::Hairline && dis == SvxBorderLineWidth::Medium) //10 + { + mxCellLineStyleValueSet->SetSelItem(10); + } + else if(out == SvxBorderLineWidth::Medium && in == SvxBorderLineWidth::Medium && dis == SvxBorderLineWidth::Medium) //11 + { + mxCellLineStyleValueSet->SetSelItem(11); + } + + else + { + mxCellLineStyleValueSet->SetSelItem(0); + mxPushButtonMoreOptions->grab_focus(); + } + mxCellLineStyleValueSet->SetFormat(); + mxCellLineStyleValueSet->Invalidate(); +} + +} // end of namespace sc::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/sidebar/CellLineStyleControl.hxx b/sc/source/ui/sidebar/CellLineStyleControl.hxx new file mode 100644 index 000000000..8bb9ba89c --- /dev/null +++ b/sc/source/ui/sidebar/CellLineStyleControl.hxx @@ -0,0 +1,54 @@ +/* -*- 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 . + */ +#pragma once + +#include <svtools/toolbarmenu.hxx> +#include <svx/colorwindow.hxx> +#include "CellLineStyleValueSet.hxx" + +class SfxDispatcher; + +namespace sc::sidebar +{ +class CellLineStylePopup : public WeldToolbarPopup +{ +private: + MenuOrToolMenuButton maToolButton; + SfxDispatcher* mpDispatcher; + std::unique_ptr<CellLineStyleValueSet> mxCellLineStyleValueSet; + std::unique_ptr<weld::CustomWeld> mxCellLineStyleValueSetWin; + std::unique_ptr<weld::Button> mxPushButtonMoreOptions; + OUString maStr[CELL_LINE_STYLE_ENTRIES]; + + void Initialize(); + void SetAllNoSel(); + + DECL_LINK(VSSelectHdl, ValueSet*, void); + DECL_LINK(PBClickHdl, weld::Button&, void); + +public: + CellLineStylePopup(weld::Toolbar* pParent, const OString& rId, SfxDispatcher* pDispatcher); + void SetLineStyleSelect(sal_uInt16 out, sal_uInt16 in, sal_uInt16 dis); + virtual void GrabFocus() override; + virtual ~CellLineStylePopup() override; +}; + +} // end of namespace svx::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/sidebar/CellLineStyleValueSet.cxx b/sc/source/ui/sidebar/CellLineStyleValueSet.cxx new file mode 100644 index 000000000..d7c9e9b3c --- /dev/null +++ b/sc/source/ui/sidebar/CellLineStyleValueSet.cxx @@ -0,0 +1,187 @@ +/* -*- 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 "CellLineStyleValueSet.hxx" +#include <i18nlangtag/mslangid.hxx> +#include <vcl/event.hxx> +#include <vcl/settings.hxx> +#include <vcl/svapp.hxx> + +namespace sc::sidebar { + +CellLineStyleValueSet::CellLineStyleValueSet() + : ValueSet(nullptr) + , mnMaxTextWidth(0) + , nSelItem(0) +{ +} + +CellLineStyleValueSet::~CellLineStyleValueSet() +{ +} + +void CellLineStyleValueSet::SetDrawingArea(weld::DrawingArea* pDrawingArea) +{ + ValueSet::SetDrawingArea(pDrawingArea); + Size aSize = pDrawingArea->get_ref_device().LogicToPixel(Size(120, 12 * CELL_LINE_STYLE_ENTRIES), + MapMode(MapUnit::MapAppFont)); + pDrawingArea->set_size_request(aSize.Width(), aSize.Height()); + SetOutputSizePixel(aSize); + + SetColCount(); + SetLineCount(CELL_LINE_STYLE_ENTRIES); +} + +void CellLineStyleValueSet::SetUnit(const OUString* str) +{ + for (int i = 0; i < CELL_LINE_STYLE_ENTRIES; ++i) + { + maStrUnit[i] = str[i]; + } +} + +void CellLineStyleValueSet::SetSelItem(sal_uInt16 nSel) +{ + nSelItem = nSel; + if(nSel == 0) + { + SelectItem(1); + SetNoSelection(); + } + else + { + SelectItem(nSelItem); + GrabFocus(); + } +} + +tools::Long CellLineStyleValueSet::GetMaxTextWidth(const vcl::RenderContext* pDev) +{ + if (mnMaxTextWidth > 0) + return mnMaxTextWidth; + + for (int i = 0; i < CELL_LINE_STYLE_ENTRIES; ++i) + { + mnMaxTextWidth = std::max(pDev->GetTextWidth(maStrUnit[i]), mnMaxTextWidth); + } + return mnMaxTextWidth; +} + +void CellLineStyleValueSet::UserDraw( const UserDrawEvent& rUDEvt ) +{ + tools::Rectangle aRect = rUDEvt.GetRect(); + vcl::RenderContext* pDev = rUDEvt.GetRenderContext(); + sal_uInt16 nItemId = rUDEvt.GetItemId(); + + tools::Long nRectHeight = aRect.GetHeight(); + tools::Long nRectWidth = aRect.GetWidth(); + Point aBLPos = aRect.TopLeft(); + + vcl::Font aOldFont = pDev->GetFont(); + Color aOldColor = pDev->GetLineColor(); + Color aOldFillColor = pDev->GetFillColor(); + + vcl::Font aFont(OutputDevice::GetDefaultFont(DefaultFontType::UI_SANS, MsLangId::getConfiguredSystemLanguage(), GetDefaultFontFlags::OnlyOne)); + Size aSize = aFont.GetFontSize(); + aSize.setHeight( nRectHeight*3/5 ); + aFont.SetFontSize( aSize ); + + if( nSelItem == nItemId ) + { + tools::Rectangle aBackRect = aRect; + aBackRect.AdjustTop(3 ); + aBackRect.AdjustBottom( -2 ); + pDev->SetFillColor(Color(50,107,197)); + pDev->DrawRect(aBackRect); + } + else + { + pDev->SetFillColor( COL_TRANSPARENT ); + pDev->DrawRect(aRect); + } + + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + + //draw text + if (nSelItem == nItemId ) + aFont.SetColor(COL_WHITE); + else + aFont.SetColor(rStyleSettings.GetFieldTextColor()); //high contrast + + pDev->SetFont(aFont); + tools::Long nTextWidth = GetMaxTextWidth(pDev); + tools::Long nTLX = aBLPos.X() + 5, nTLY = aBLPos.Y() + ( nRectHeight - nItemId )/2; + tools::Long nTRX = aBLPos.X() + nRectWidth - nTextWidth - 15, nTRY = aBLPos.Y() + ( nRectHeight - nItemId )/2; + Point aStart(aBLPos.X() + nRectWidth - nTextWidth - 5 , aBLPos.Y() + nRectHeight/6); + pDev->DrawText(aStart, maStrUnit[nItemId - 1]); //can't set DrawTextFlags::EndEllipsis here, or the text will disappear + + //draw line + if( nSelItem == nItemId ) + { + pDev->SetFillColor(COL_WHITE); + pDev->SetLineColor(COL_WHITE); + } + else + { + pDev->SetFillColor(rStyleSettings.GetFieldTextColor()); //high contrast + pDev->SetLineColor(rStyleSettings.GetFieldTextColor()); //high contrast + } + + switch( nItemId ) + { + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + pDev->DrawRect(tools::Rectangle(nTLX, nTLY , nTRX, nTRY + nItemId * 2 - 1 )); + break; + case 7: + pDev->DrawRect(tools::Rectangle(nTLX, nTLY , nTRX, nTRY + 1 )); + pDev->DrawRect(tools::Rectangle(nTLX, nTLY + 3 , nTRX, nTRY + 4 )); + break; + case 8: + pDev->DrawRect(tools::Rectangle(nTLX, nTLY , nTRX, nTRY + 1 )); + pDev->DrawRect(tools::Rectangle(nTLX, nTLY + 5 , nTRX, nTRY + 6 )); + break; + case 9: + pDev->DrawRect(tools::Rectangle(nTLX, nTLY , nTRX, nTRY + 1 )); + pDev->DrawRect(tools::Rectangle(nTLX, nTLY + 3 , nTRX, nTRY + 6 )); + break; + case 10: + pDev->DrawRect(tools::Rectangle(nTLX, nTLY , nTRX, nTRY + 3 )); + pDev->DrawRect(tools::Rectangle(nTLX, nTLY + 5 , nTRX, nTRY + 6 )); + break; + case 11: + pDev->DrawRect(tools::Rectangle(nTLX, nTLY , nTRX, nTRY + 3 )); + pDev->DrawRect(tools::Rectangle(nTLX, nTLY + 5 , nTRX, nTRY + 8 )); + break; + } + + Invalidate( aRect ); + pDev->SetLineColor(aOldColor); + pDev->SetFillColor(aOldFillColor); + pDev->SetFont(aOldFont); + +} + +} // end of namespace sc::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/sidebar/CellLineStyleValueSet.hxx b/sc/source/ui/sidebar/CellLineStyleValueSet.hxx new file mode 100644 index 000000000..79dd08fb3 --- /dev/null +++ b/sc/source/ui/sidebar/CellLineStyleValueSet.hxx @@ -0,0 +1,48 @@ +/* -*- 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 . + */ +#pragma once + +#include <svtools/valueset.hxx> +#include <tools/long.hxx> + +#define CELL_LINE_STYLE_ENTRIES 11 + +namespace sc::sidebar +{ +class CellLineStyleValueSet : public ValueSet +{ +private: + tools::Long mnMaxTextWidth; + sal_uInt16 nSelItem; + OUString maStrUnit[CELL_LINE_STYLE_ENTRIES]; + +public: + CellLineStyleValueSet(); + virtual ~CellLineStyleValueSet() override; + + void SetUnit(const OUString* str); + void SetSelItem(sal_uInt16 nSel); + tools::Long GetMaxTextWidth(const vcl::RenderContext* pDev); + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; + virtual void UserDraw(const UserDrawEvent& rUDEvt) override; +}; + +} // end of namespace svx::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/sidebar/NumberFormatControl.cxx b/sc/source/ui/sidebar/NumberFormatControl.cxx new file mode 100644 index 000000000..1060f0f5d --- /dev/null +++ b/sc/source/ui/sidebar/NumberFormatControl.cxx @@ -0,0 +1,77 @@ +/* -*- 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 <NumberFormatControl.hxx> +#include <cbnumberformat.hxx> +#include <svl/intitem.hxx> +#include <vcl/toolbox.hxx> + +using namespace sc; + +SFX_IMPL_TOOLBOX_CONTROL(ScNumberFormatControl, SfxUInt16Item); + +ScNumberFormatControl::ScNumberFormatControl(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx) + : SfxToolBoxControl(nSlotId, nId, rTbx) +{ +} + +ScNumberFormatControl::~ScNumberFormatControl() +{ +} + +void ScNumberFormatControl::StateChangedAtToolBoxControl(sal_uInt16, SfxItemState eState, + const SfxPoolItem* pState) +{ + ToolBoxItemId nId = GetId(); + ToolBox& rTbx = GetToolBox(); + ScNumberFormat* pComboBox = static_cast<ScNumberFormat*>(rTbx.GetItemWindow(nId)); + + DBG_ASSERT( pComboBox, "Control not found!" ); + + if(SfxItemState::DISABLED == eState) + pComboBox->Disable(); + else + pComboBox->Enable(); + + rTbx.EnableItem(nId, SfxItemState::DISABLED != eState); + + switch(eState) + { + case SfxItemState::DEFAULT: + { + const SfxUInt16Item* pItem = static_cast<const SfxUInt16Item*>(pState); + sal_uInt16 nVal = pItem->GetValue(); + pComboBox->set_active(nVal); + break; + } + + default: + break; + } +} + +VclPtr<InterimItemWindow> ScNumberFormatControl::CreateItemWindow( vcl::Window *pParent ) +{ + VclPtr<ScNumberFormat> pControl = VclPtr<ScNumberFormat>::Create(pParent); + pControl->Show(); + + return pControl; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx new file mode 100644 index 000000000..c9910cc1d --- /dev/null +++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx @@ -0,0 +1,290 @@ +/* -*- 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 "NumberFormatPropertyPanel.hxx" +#include <sc.hrc> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <svl/intitem.hxx> +#include <svl/stritem.hxx> +#include <o3tl/string_view.hxx> +#include <com/sun/star/lang/IllegalArgumentException.hpp> + +using namespace css; +using namespace css::uno; + +namespace sc::sidebar { + +NumberFormatPropertyPanel::NumberFormatPropertyPanel( + weld::Widget* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings) + : PanelLayout(pParent,"NumberFormatPropertyPanel", "modules/scalc/ui/sidebarnumberformat.ui") + , mxLbCategory(m_xBuilder->weld_combo_box("numberformatcombobox")) + , mxTBCategory(m_xBuilder->weld_toolbar("numberformat")) + , mxCategoryDispatch(new ToolbarUnoDispatcher(*mxTBCategory, *m_xBuilder, rxFrame)) + , mxFtDecimals(m_xBuilder->weld_label("decimalplaceslabel")) + , mxEdDecimals(m_xBuilder->weld_spin_button("decimalplaces")) + , mxFtDenominator(m_xBuilder->weld_label("denominatorplaceslabel")) + , mxEdDenominator(m_xBuilder->weld_spin_button("denominatorplaces")) + , mxFtLeadZeroes(m_xBuilder->weld_label("leadingzeroeslabel")) + , mxEdLeadZeroes(m_xBuilder->weld_spin_button("leadingzeroes")) + , mxBtnNegRed(m_xBuilder->weld_check_button("negativenumbersred")) + , mxBtnThousand(m_xBuilder->weld_check_button("thousandseparator")) + , mxBtnEngineering(m_xBuilder->weld_check_button("engineeringnotation")) + , maNumFormatControl(SID_NUMBER_TYPE_FORMAT, *pBindings, *this) + , maFormatControl(SID_NUMBER_FORMAT, *pBindings, *this) + , mnCategorySelected(0) + , mpBindings(pBindings) +{ + Initialize(); +} + +NumberFormatPropertyPanel::~NumberFormatPropertyPanel() +{ + mxLbCategory.reset(); + mxCategoryDispatch.reset(); + mxTBCategory.reset(); + mxFtDecimals.reset(); + mxEdDecimals.reset(); + mxFtDenominator.reset(); + mxEdDenominator.reset(); + mxFtLeadZeroes.reset(); + mxEdLeadZeroes.reset(); + mxBtnNegRed.reset(); + mxBtnThousand.reset(); + mxBtnEngineering.reset(); + + maNumFormatControl.dispose(); + maFormatControl.dispose(); +} + +void NumberFormatPropertyPanel::Initialize() +{ + mxLbCategory->connect_changed( LINK(this, NumberFormatPropertyPanel, NumFormatSelectHdl) ); + mxLbCategory->set_active(0); + + Link<weld::SpinButton&,void> aLink = LINK(this, NumberFormatPropertyPanel, NumFormatValueHdl); + + mxEdDecimals->connect_value_changed( aLink ); + mxEdDenominator->connect_value_changed( aLink ); + mxEdLeadZeroes->connect_value_changed( aLink ); + + mxBtnNegRed->connect_toggled( LINK(this, NumberFormatPropertyPanel, NumFormatValueClickHdl) ); + mxBtnThousand->connect_toggled( LINK(this, NumberFormatPropertyPanel, NumFormatValueClickHdl) ); + mxBtnEngineering->connect_toggled( LINK(this, NumberFormatPropertyPanel, NumFormatValueClickHdl) ); +} + +IMPL_LINK( NumberFormatPropertyPanel, NumFormatSelectHdl, weld::ComboBox&, rBox, void ) +{ + const sal_Int32 nVal = rBox.get_active(); + if( nVal != mnCategorySelected ) + { + SfxUInt16Item aItem( SID_NUMBER_TYPE_FORMAT, nVal ); + GetBindings()->GetDispatcher()->ExecuteList(SID_NUMBER_TYPE_FORMAT, + SfxCallMode::RECORD, { &aItem }); + mnCategorySelected = nVal; + } +} + +IMPL_LINK_NOARG( NumberFormatPropertyPanel, NumFormatValueClickHdl, weld::Toggleable&, void ) +{ + NumFormatValueHdl(*mxEdDecimals); +} + +IMPL_LINK_NOARG( NumberFormatPropertyPanel, NumFormatValueHdl, weld::SpinButton&, void ) +{ + OUString aFormat; + OUString sBreak = ","; + bool bThousand = ( mxBtnThousand->get_visible() && mxBtnThousand->get_sensitive() && mxBtnThousand->get_active() ) + || ( mxBtnEngineering->get_visible() && mxBtnEngineering->get_sensitive() && mxBtnEngineering->get_active() ); + bool bNegRed = mxBtnNegRed->get_sensitive() && mxBtnNegRed->get_active(); + sal_uInt16 nPrecision = (mxEdDecimals->get_sensitive() && mxEdDecimals->get_visible()) + ? static_cast<sal_uInt16>(mxEdDecimals->get_value()) + : (mxEdDenominator->get_sensitive() && mxEdDenominator->get_visible()) + ? static_cast<sal_uInt16>(mxEdDenominator->get_value()) + : sal_uInt16(0); + sal_uInt16 nLeadZeroes = (mxEdLeadZeroes->get_sensitive()) + ? static_cast<sal_uInt16>(mxEdLeadZeroes->get_value()) + : sal_uInt16(0); + + OUString sThousand = OUString::number(static_cast<sal_Int32>(bThousand)); + OUString sNegRed = OUString::number(static_cast<sal_Int32>(bNegRed)); + OUString sPrecision = OUString::number(nPrecision); + OUString sLeadZeroes = OUString::number(nLeadZeroes); + + aFormat += sThousand + + sBreak + + sNegRed + + sBreak + + sPrecision + + sBreak + + sLeadZeroes + + sBreak; + + SfxStringItem aItem( SID_NUMBER_FORMAT, aFormat ); + GetBindings()->GetDispatcher()->ExecuteList(SID_NUMBER_FORMAT, + SfxCallMode::RECORD, { &aItem }); +} + +std::unique_ptr<PanelLayout> NumberFormatPropertyPanel::Create ( + weld::Widget* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings) +{ + if (pParent == nullptr) + throw lang::IllegalArgumentException("no parent Window given to NumberFormatPropertyPanel::Create", nullptr, 0); + if ( ! rxFrame.is()) + throw lang::IllegalArgumentException("no XFrame given to NumberFormatPropertyPanel::Create", nullptr, 1); + if (pBindings == nullptr) + throw lang::IllegalArgumentException("no SfxBindings given to NumberFormatPropertyPanel::Create", nullptr, 2); + + return std::make_unique<NumberFormatPropertyPanel>(pParent, rxFrame, pBindings); +} + +void NumberFormatPropertyPanel::HandleContextChange( + const vcl::EnumContext& rContext) +{ + if(maContext == rContext) + { + // Nothing to do. + return; + } + + maContext = rContext; +} + +void NumberFormatPropertyPanel::NotifyItemUpdate( + sal_uInt16 nSID, + SfxItemState eState, + const SfxPoolItem* pState) +{ + switch(nSID) + { + case SID_NUMBER_TYPE_FORMAT: + { + if( eState >= SfxItemState::DEFAULT) + { + const SfxInt16Item* pItem = static_cast<const SfxInt16Item*>(pState); + sal_uInt16 nVal = pItem->GetValue(); + mnCategorySelected = nVal; + mxLbCategory->set_active(nVal); + if (nVal < 8 && // General, Number, Percent, Currency, Time, Scientific, Fraction + nVal != 4 ) // not Date + { + bool bIsScientific ( nVal == 6 );// For scientific, Thousand separator is replaced by Engineering notation + bool bIsFraction ( nVal == 7 ); // For fraction, Decimal places is replaced by Denominator places + bool bIsTime ( nVal == 5 ); // For Time, Decimal places and NegRed available + mxBtnThousand->set_visible( !bIsScientific ); + mxBtnThousand->set_sensitive( !bIsScientific && !bIsTime ); + mxBtnThousand->set_active(false); + mxBtnEngineering->set_visible(bIsScientific); + mxBtnEngineering->set_sensitive(bIsScientific); + mxBtnEngineering->set_active(false); + mxBtnNegRed->set_sensitive(true); + mxFtDenominator->set_visible(bIsFraction); + mxEdDenominator->set_visible(bIsFraction); + mxFtDenominator->set_sensitive(bIsFraction); + mxEdDenominator->set_sensitive(bIsFraction); + mxFtDecimals->set_visible(!bIsFraction); + mxEdDecimals->set_visible(!bIsFraction); + mxFtDecimals->set_sensitive(!bIsFraction); + mxEdDecimals->set_sensitive(!bIsFraction); + mxFtLeadZeroes->set_sensitive( !bIsTime ); + mxEdLeadZeroes->set_sensitive( !bIsTime ); + } + else + DisableControls(); + } + else + { + DisableControls(); + mxLbCategory->set_active(-1); + mnCategorySelected = 0; + } + } + break; + case SID_NUMBER_FORMAT: + { + bool bThousand = false; + bool bNegRed = false; + sal_uInt16 nPrecision = 0; + sal_uInt16 nLeadZeroes = 0; + if( eState >= SfxItemState::DEFAULT) + { + const SfxStringItem* pItem = static_cast<const SfxStringItem*>(pState); + const OUString& aCode = pItem->GetValue(); + sal_Int32 nIndex = 0; + sal_Int32 aFormat[4] = {0}; + for (sal_Int32 & rn : aFormat) + { + rn = o3tl::toInt32(o3tl::getToken(aCode, 0, ',', nIndex)); + if (nIndex<0) + break; + } + bThousand = static_cast<bool>(aFormat[0]); + bNegRed = static_cast<bool>(aFormat[1]); + nPrecision = static_cast<sal_uInt16>(aFormat[2]); + nLeadZeroes = static_cast<sal_uInt16>(aFormat[3]); + } + else + { + bThousand = false; + bNegRed = false; + nPrecision = 0; + nLeadZeroes = 1; + } + if ( mxBtnThousand->get_visible() ) + mxBtnThousand->set_active(bThousand); + else if ( mxBtnEngineering->get_visible() ) + mxBtnEngineering->set_active(bThousand); + mxBtnNegRed->set_active(bNegRed); + if ( mxLbCategory->get_active() == 0 ) + mxEdDecimals->set_text(""); // tdf#44399 + else if ( mxEdDecimals->get_visible() ) + mxEdDecimals->set_value(nPrecision); + else if ( mxEdDenominator->get_visible() ) + mxEdDenominator->set_value(nPrecision); + mxEdLeadZeroes->set_value(nLeadZeroes); + } + break; + default: + break; + } +} + +void NumberFormatPropertyPanel::DisableControls() +{ + mxBtnEngineering->hide(); + mxBtnThousand->show(); + mxBtnThousand->set_sensitive(false); + mxBtnNegRed->set_sensitive(false); + mxFtDenominator->hide(); + mxEdDenominator->hide(); + mxFtDecimals->show(); + mxEdDecimals->show(); + mxFtDecimals->set_sensitive(false); + mxEdDecimals->set_sensitive(false); + mxFtLeadZeroes->set_sensitive(false); + mxEdLeadZeroes->set_sensitive(false); +} + +} // end of namespace ::sc::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx b/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx new file mode 100644 index 000000000..7f16dffb9 --- /dev/null +++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx @@ -0,0 +1,94 @@ +/* -*- 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 . + */ +#pragma once + +#include <sfx2/sidebar/ControllerItem.hxx> +#include <sfx2/sidebar/IContextChangeReceiver.hxx> +#include <sfx2/weldutils.hxx> +#include <sfx2/sidebar/PanelLayout.hxx> +#include <vcl/EnumContext.hxx> + +namespace sc::sidebar { + +class NumberFormatPropertyPanel +: public PanelLayout, + public ::sfx2::sidebar::IContextChangeReceiver, + public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface +{ +public: +public: + static std::unique_ptr<PanelLayout> Create( + weld::Widget* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings); + + virtual void HandleContextChange( + const vcl::EnumContext& rContext) override; + + virtual void NotifyItemUpdate( + const sal_uInt16 nSId, + const SfxItemState eState, + const SfxPoolItem* pState) override; + + virtual void GetControlState( + const sal_uInt16 /*nSId*/, + boost::property_tree::ptree& /*rState*/) override {}; + + SfxBindings* GetBindings() { return mpBindings;} + + // constructor/destructor + NumberFormatPropertyPanel( + weld::Widget* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings); + virtual ~NumberFormatPropertyPanel() override; +private: + //ui controls + std::unique_ptr<weld::ComboBox> mxLbCategory; + std::unique_ptr<weld::Toolbar> mxTBCategory; + std::unique_ptr<ToolbarUnoDispatcher> mxCategoryDispatch; + std::unique_ptr<weld::Label> mxFtDecimals; + std::unique_ptr<weld::SpinButton> mxEdDecimals; + std::unique_ptr<weld::Label> mxFtDenominator; + std::unique_ptr<weld::SpinButton> mxEdDenominator; + std::unique_ptr<weld::Label> mxFtLeadZeroes; + std::unique_ptr<weld::SpinButton> mxEdLeadZeroes; + std::unique_ptr<weld::CheckButton> mxBtnNegRed; + std::unique_ptr<weld::CheckButton> mxBtnThousand; + std::unique_ptr<weld::CheckButton> mxBtnEngineering; + + ::sfx2::sidebar::ControllerItem maNumFormatControl; + ::sfx2::sidebar::ControllerItem maFormatControl; + + sal_Int32 mnCategorySelected; + + vcl::EnumContext maContext; + SfxBindings* mpBindings; + + DECL_LINK(NumFormatSelectHdl, weld::ComboBox&, void); + DECL_LINK(NumFormatValueHdl, weld::SpinButton&, void); + DECL_LINK(NumFormatValueClickHdl, weld::Toggleable&, void); + + void Initialize(); + void DisableControls(); +}; + +} // end of namespace ::sc::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/sidebar/ScPanelFactory.cxx b/sc/source/ui/sidebar/ScPanelFactory.cxx new file mode 100644 index 000000000..bbcff315c --- /dev/null +++ b/sc/source/ui/sidebar/ScPanelFactory.cxx @@ -0,0 +1,143 @@ +/* -*- 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 "ScPanelFactory.hxx" + +#include "AlignmentPropertyPanel.hxx" +#include "CellAppearancePropertyPanel.hxx" +#include "NumberFormatPropertyPanel.hxx" +#include <navipi.hxx> +#include <dwfunctr.hxx> + +#include <sfx2/sidebar/SidebarPanelBase.hxx> +#include <vcl/weldutils.hxx> +#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> +#include <comphelper/namedvaluecollection.hxx> +#include <cppuhelper/exc_hlp.hxx> +#include <cppuhelper/supportsservice.hxx> + +using namespace css; +using namespace css::uno; + +namespace sc::sidebar { + +ScPanelFactory::ScPanelFactory() +{ +} + +ScPanelFactory::~ScPanelFactory() +{ +} + +Reference<ui::XUIElement> SAL_CALL ScPanelFactory::createUIElement ( + const OUString& rsResourceURL, + const ::css::uno::Sequence<css::beans::PropertyValue>& rArguments) +{ + Reference<ui::XUIElement> xElement; + + try + { + const ::comphelper::NamedValueCollection aArguments (rArguments); + Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>())); + Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>())); + const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0))); + SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue); + + weld::Widget* pParent(nullptr); + if (weld::TransportAsXWindow* pTunnel = dynamic_cast<weld::TransportAsXWindow*>(xParentWindow.get())) + pParent = pTunnel->getWidget(); + + if (!pParent) + throw RuntimeException( + "PanelFactory::createUIElement called without ParentWindow", + nullptr); + if ( ! xFrame.is()) + throw RuntimeException( + "PanelFactory::createUIElement called without Frame", + nullptr); + if (pBindings == nullptr) + throw RuntimeException( + "PanelFactory::createUIElement called without SfxBindings", + nullptr); + + sal_Int32 nMinimumSize = -1; + std::unique_ptr<PanelLayout> xPanel; + if (rsResourceURL.endsWith("/AlignmentPropertyPanel")) + xPanel = AlignmentPropertyPanel::Create( pParent, xFrame, pBindings ); + else if (rsResourceURL.endsWith("/CellAppearancePropertyPanel")) + xPanel = CellAppearancePropertyPanel::Create( pParent, xFrame, pBindings ); + else if (rsResourceURL.endsWith("/NumberFormatPropertyPanel")) + xPanel = NumberFormatPropertyPanel::Create( pParent, xFrame, pBindings ); + else if (rsResourceURL.endsWith("/NavigatorPanel")) + { + xPanel = std::make_unique<ScNavigatorDlg>(pBindings, pParent, nullptr); + nMinimumSize = 0; + } + else if (rsResourceURL.endsWith("/FunctionsPanel")) + { + xPanel = std::make_unique<ScFunctionWin>(pParent); + nMinimumSize = 0; + } + + if (xPanel) + xElement = sfx2::sidebar::SidebarPanelBase::Create( + rsResourceURL, + xFrame, + std::move(xPanel), + ui::LayoutSize(nMinimumSize,-1,-1)); + } + catch (const uno::RuntimeException &) + { + throw; + } + catch (const uno::Exception&) + { + css::uno::Any anyEx = cppu::getCaughtException(); + throw lang::WrappedTargetRuntimeException( + "ScPanelFactory::createUIElement exception", + nullptr, anyEx); + } + + return xElement; +} + +OUString ScPanelFactory::getImplementationName() +{ + return "org.apache.openoffice.comp.sc.sidebar.ScPanelFactory"; +} + +sal_Bool ScPanelFactory::supportsService(OUString const & ServiceName) +{ + return cppu::supportsService(this, ServiceName); +} + +css::uno::Sequence<OUString> ScPanelFactory::getSupportedServiceNames() +{ + return { "com.sun.star.ui.UIElementFactory" }; +} + +} // end of namespace sc::sidebar + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +ScPanelFactory_get_implementation(css::uno::XComponentContext*, css::uno::Sequence<css::uno::Any> const &) +{ + return cppu::acquire(new sc::sidebar::ScPanelFactory()); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/sidebar/ScPanelFactory.hxx b/sc/source/ui/sidebar/ScPanelFactory.hxx new file mode 100644 index 000000000..b2901e2ab --- /dev/null +++ b/sc/source/ui/sidebar/ScPanelFactory.hxx @@ -0,0 +1,55 @@ +/* -*- 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 . + */ +#pragma once + +#include <comphelper/compbase.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/ui/XUIElementFactory.hpp> + +namespace sc::sidebar { + +typedef comphelper::WeakComponentImplHelper < + css::ui::XUIElementFactory, css::lang::XServiceInfo + > PanelFactoryInterfaceBase; + +class ScPanelFactory final : public PanelFactoryInterfaceBase +{ +public: + // noncopyable + ScPanelFactory(const ScPanelFactory&) = delete; + const ScPanelFactory& operator=(const ScPanelFactory&) = delete; + + ScPanelFactory(); + virtual ~ScPanelFactory() override; + + // XUIElementFactory + css::uno::Reference<css::ui::XUIElement> SAL_CALL createUIElement( + const OUString& rsResourceURL, + const ::css::uno::Sequence<css::beans::PropertyValue>& rArguments) override; + + OUString SAL_CALL getImplementationName() override; + + sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + +} // end of namespace sc::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |