diff options
Diffstat (limited to '')
-rw-r--r-- | sc/source/ui/sidebar/AlignmentPropertyPanel.cxx | 414 | ||||
-rw-r--r-- | sc/source/ui/sidebar/AlignmentPropertyPanel.hxx | 122 | ||||
-rw-r--r-- | sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx | 512 | ||||
-rw-r--r-- | sc/source/ui/sidebar/CellAppearancePropertyPanel.hxx | 153 | ||||
-rw-r--r-- | sc/source/ui/sidebar/CellBorderStyleControl.cxx | 280 | ||||
-rw-r--r-- | sc/source/ui/sidebar/CellBorderStyleControl.hxx | 55 | ||||
-rw-r--r-- | sc/source/ui/sidebar/CellLineStyleControl.cxx | 224 | ||||
-rw-r--r-- | sc/source/ui/sidebar/CellLineStyleControl.hxx | 57 | ||||
-rw-r--r-- | sc/source/ui/sidebar/CellLineStyleValueSet.cxx | 171 | ||||
-rw-r--r-- | sc/source/ui/sidebar/CellLineStyleValueSet.hxx | 47 | ||||
-rw-r--r-- | sc/source/ui/sidebar/NumberFormatControl.cxx | 77 | ||||
-rw-r--r-- | sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx | 302 | ||||
-rw-r--r-- | sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx | 101 | ||||
-rw-r--r-- | sc/source/ui/sidebar/ScPanelFactory.cxx | 142 | ||||
-rw-r--r-- | sc/source/ui/sidebar/ScPanelFactory.hxx | 61 |
15 files changed, 2718 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..4d7183d5f --- /dev/null +++ b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx @@ -0,0 +1,414 @@ +/* -*- 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 <svx/sdangitm.hxx> +#include <svtools/unitconv.hxx> +#include <unotools/localedatawrapper.hxx> +#include <com/sun/star/lang/IllegalArgumentException.hpp> +#include <boost/property_tree/json_parser.hpp> +#include <sfx2/lokhelper.hxx> +#include <comphelper/lok.hxx> + +using namespace css; +using namespace css::uno; + +// namespace open + +namespace sc::sidebar { + +AlignmentPropertyPanel::AlignmentPropertyPanel( + vcl::Window* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings) + : PanelLayout(pParent, "AlignmentPropertyPanel", "modules/scalc/ui/sidebaralignment.ui", rxFrame) + , 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_radio_button("bottom")) + , mxRefEdgeTop(m_xBuilder->weld_radio_button("top")) + , mxRefEdgeStd(m_xBuilder->weld_radio_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) + , mbSettingToggles(false) + , maContext() + , mpBindings(pBindings) +{ + Initialize(); +} + +AlignmentPropertyPanel::~AlignmentPropertyPanel() +{ + disposeOnce(); +} + +void AlignmentPropertyPanel::dispose() +{ + 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(); + + PanelLayout::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::ToggleButton&,void> aLink2 = LINK(this, AlignmentPropertyPanel, ReferenceEdgeHdl); + mxRefEdgeBottom->connect_toggled(aLink2); + mxRefEdgeTop->connect_toggled(aLink2); + mxRefEdgeStd->connect_toggled(aLink2); +} + +namespace { + +void eraseNode(boost::property_tree::ptree& pTree, const std::string& aValue) +{ + boost::optional<boost::property_tree::ptree&> pId; + boost::optional<boost::property_tree::ptree&> pSubTree = pTree.get_child_optional("children"); + + if (pSubTree) + { + boost::property_tree::ptree::iterator itFound = pSubTree.get().end(); + for (boost::property_tree::ptree::iterator it = pSubTree.get().begin(); it != pSubTree.get().end(); ++it) + { + pId = it->second.get_child_optional("id"); + if (pId && pId.get().get_value<std::string>("") == aValue) + { + itFound = it; + break; + } + + eraseNode(it->second, aValue); + } + + if (itFound != pSubTree.get().end()) + { + pSubTree.get().erase(itFound); + } + } +} + +} + +boost::property_tree::ptree AlignmentPropertyPanel::DumpAsPropertyTree() +{ + boost::property_tree::ptree aTree = PanelLayout::DumpAsPropertyTree(); + + const SfxViewShell* pViewShell = SfxViewShell::Current(); + if (pViewShell && pViewShell->isLOKMobilePhone()) + { + eraseNode(aTree, "textorientbox"); + } + + return aTree; +} + +IMPL_LINK(AlignmentPropertyPanel, ReferenceEdgeHdl, weld::ToggleButton&, rToggle, void) +{ + if (mbSettingToggles) + return; + SvxRotateMode eMode; + if (&rToggle == mxRefEdgeBottom.get() && mxRefEdgeBottom->get_active()) + eMode = SVX_ROTATE_MODE_BOTTOM; + else if (&rToggle == mxRefEdgeTop.get() && mxRefEdgeTop->get_active()) + eMode = SVX_ROTATE_MODE_TOP; + else if (&rToggle == mxRefEdgeStd.get() && mxRefEdgeStd->get_active()) + eMode = SVX_ROTATE_MODE_STANDARD; + else + return; + SvxRotateModeItem aItem(eMode, ATTR_ROTATE_MODE); + GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_ALIGN_LOCKPOS, + SfxCallMode::RECORD, { &aItem }); +} + +IMPL_LINK_NOARG( AlignmentPropertyPanel, AngleModifiedHdl, weld::MetricSpinButton&, void ) +{ + sal_uInt32 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::ToggleButton&, 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::ToggleButton&, 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::ToggleButton&, void) +{ + bool bState = mxCBXWrapText->get_active(); + ScLineBreakCell aItem(bState); + GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_ALIGN_LINEBREAK, + SfxCallMode::RECORD, { &aItem }); +} + +VclPtr<vcl::Window> AlignmentPropertyPanel::Create ( + vcl::Window* 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 VclPtr<AlignmentPropertyPanel>::Create( + pParent, rxFrame, pBindings); +} + +void AlignmentPropertyPanel::DataChanged( + const DataChangedEvent&) +{} + +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 && dynamic_cast<const SvxHorJustifyItem*>( pState) ) + { + const SvxHorJustifyItem* pItem = static_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) + { + mbSettingToggles = true; + const SvxRotateModeItem* pItem = static_cast<const SvxRotateModeItem*>(pState); + SvxRotateMode eMode = pItem->GetValue(); + if(eMode == SVX_ROTATE_MODE_BOTTOM) + { + mxRefEdgeBottom->set_state(TRISTATE_TRUE); + } + else if(eMode == SVX_ROTATE_MODE_TOP) + { + mxRefEdgeTop->set_state(TRISTATE_TRUE); + } + else if(eMode == SVX_ROTATE_MODE_STANDARD) + { + mxRefEdgeStd->set_state(TRISTATE_TRUE); + } + mbSettingToggles = false; + } + break; + case SID_ATTR_ALIGN_DEGREES: + if (eState >= SfxItemState::DEFAULT) + { + long nTmp = static_cast<const ScRotateValueItem*>(pState)->GetValue(); + mxMtrAngle->set_value(nTmp / 100, 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..bcd3e1eba --- /dev/null +++ b/sc/source/ui/sidebar/AlignmentPropertyPanel.hxx @@ -0,0 +1,122 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SC_SOURCE_UI_SIDEBAR_ALIGNMENTPROPERTYPANEL_HXX +#define INCLUDED_SC_SOURCE_UI_SIDEBAR_ALIGNMENTPROPERTYPANEL_HXX + +#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 VclPtr<vcl::Window> Create( + vcl::Window* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings); + + virtual void DataChanged( + const DataChangedEvent& rEvent) override; + + 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;} + + virtual boost::property_tree::ptree DumpAsPropertyTree() override; + + // constructor/destructor + AlignmentPropertyPanel( + vcl::Window* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings); + virtual ~AlignmentPropertyPanel() override; + virtual void dispose() 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::RadioButton> mxRefEdgeBottom; + std::unique_ptr<weld::RadioButton> mxRefEdgeTop; + std::unique_ptr<weld::RadioButton> 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; + bool mbSettingToggles : 1; + + vcl::EnumContext maContext; + SfxBindings* mpBindings; + + DECL_LINK( MFLeftIndentMdyHdl, weld::MetricSpinButton&, void ); + DECL_LINK( CBOXMergnCellClkHdl, weld::ToggleButton&, void ); + DECL_LINK( CBOXWrapTextClkHdl, weld::ToggleButton&, void ); + DECL_LINK( AngleModifiedHdl, weld::MetricSpinButton&, void ); + DECL_LINK( ClickStackHdl, weld::ToggleButton&, void ); + DECL_LINK( ReferenceEdgeHdl, weld::ToggleButton&, void ); + + void Initialize(); +}; + +} // end of namespace ::sc::sidebar + +#endif + +/* 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..43bc3b857 --- /dev/null +++ b/sc/source/ui/sidebar/CellAppearancePropertyPanel.cxx @@ -0,0 +1,512 @@ +/* -*- 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; + +const char SETBORDERSTYLE[] = "SetBorderStyle"; +const char LINESTYLE[] = "LineStyle"; + +// namespace open + +namespace sc::sidebar { + +CellAppearancePropertyPanel::CellAppearancePropertyPanel( + vcl::Window* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings) +: PanelLayout(pParent, "CellAppearancePropertyPanel", "modules/scalc/ui/sidebarcellappearance.ui", rxFrame), + + 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), + maContext(), + mpBindings(pBindings) +{ + Initialize(); +} + +CellAppearancePropertyPanel::~CellAppearancePropertyPanel() +{ + disposeOnce(); +} + +void CellAppearancePropertyPanel::dispose() +{ + 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(); + + PanelLayout::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(); +} + +VclPtr<vcl::Window> CellAppearancePropertyPanel::Create ( + vcl::Window* 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 VclPtr<CellAppearancePropertyPanel>::Create( + pParent, rxFrame, pBindings); +} + +void CellAppearancePropertyPanel::DataChanged( + const DataChangedEvent&) +{} + +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); + else + UpdateCellBorder(mbTop, mbBottom, mbRight, mbLeft, mbVer, mbHor); + + 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); + else + UpdateCellBorder(bTop, bBottom, bRight, bLeft, mbVer, mbHor); + + 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); + } + } + } + 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); + } + } + } + UpdateControlState(); + break; + } +} + +void CellAppearancePropertyPanel::SetStyleIcon() +{ + //FIXME: update for new line border possibilities + if(mnOutWidth == DEF_LINE_WIDTH_0 && mnInWidth == 0 && mnDistance == 0) //1 + mxTBLineStyle->set_item_icon_name(LINESTYLE, msIMGLineStyle1); + else if(mnOutWidth == DEF_LINE_WIDTH_2 && mnInWidth == 0 && mnDistance == 0) //2 + mxTBLineStyle->set_item_icon_name(LINESTYLE, msIMGLineStyle2); + else if(mnOutWidth == DEF_LINE_WIDTH_3 && mnInWidth == 0 && mnDistance == 0) //3 + mxTBLineStyle->set_item_icon_name(LINESTYLE, msIMGLineStyle3); + else if(mnOutWidth == DEF_LINE_WIDTH_4 && mnInWidth == 0 && mnDistance == 0) //4 + mxTBLineStyle->set_item_icon_name(LINESTYLE, msIMGLineStyle4); + else if(mnOutWidth == DEF_LINE_WIDTH_0 && mnInWidth == DEF_LINE_WIDTH_0 && mnDistance == DEF_LINE_WIDTH_1) //5 + mxTBLineStyle->set_item_icon_name(LINESTYLE, msIMGLineStyle5); + else if(mnOutWidth == DEF_LINE_WIDTH_0 && mnInWidth == DEF_LINE_WIDTH_0 && mnDistance == DEF_LINE_WIDTH_2) //6 + mxTBLineStyle->set_item_icon_name(LINESTYLE, msIMGLineStyle6); + else if(mnOutWidth == DEF_LINE_WIDTH_1 && mnInWidth == DEF_LINE_WIDTH_2 && mnDistance == DEF_LINE_WIDTH_1) //7 + mxTBLineStyle->set_item_icon_name(LINESTYLE, msIMGLineStyle7); + else if(mnOutWidth == DEF_LINE_WIDTH_2 && mnInWidth == DEF_LINE_WIDTH_0 && mnDistance == DEF_LINE_WIDTH_2) //8 + mxTBLineStyle->set_item_icon_name(LINESTYLE, msIMGLineStyle8); + else if(mnOutWidth == DEF_LINE_WIDTH_2 && mnInWidth == DEF_LINE_WIDTH_2 && mnDistance == DEF_LINE_WIDTH_2) //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) +{ + 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 ); + 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..1747e9f0a --- /dev/null +++ b/sc/source/ui/sidebar/CellAppearancePropertyPanel.hxx @@ -0,0 +1,153 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SC_SOURCE_UI_SIDEBAR_CELLAPPEARANCEPROPERTYPANEL_HXX +#define INCLUDED_SC_SOURCE_UI_SIDEBAR_CELLAPPEARANCEPROPERTYPANEL_HXX + +#include <sfx2/sidebar/ControllerItem.hxx> +#include <sfx2/sidebar/IContextChangeReceiver.hxx> +#include <sfx2/sidebar/PanelLayout.hxx> +#include "CellBorderStyleControl.hxx" +#include "CellLineStyleControl.hxx" + +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 VclPtr<vcl::Window> Create( + vcl::Window* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings); + + virtual void DataChanged( + const DataChangedEvent& rEvent) override; + + 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( + vcl::Window* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings); + virtual ~CellAppearancePropertyPanel() override; + virtual void dispose() 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); +}; + +} // end of namespace ::sc::sidebar + +#endif + +/* 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..6a6d7c74d --- /dev/null +++ b/sc/source/ui/sidebar/CellBorderStyleControl.cxx @@ -0,0 +1,280 @@ +/* -*- 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/app.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, 1); + 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(DEF_LINE_WIDTH_2); + 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, 1 ); + 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, 1 ); + 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, 1); + 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, DEF_LINE_WIDTH_2 )); + nValidFlags |= FRM_VALID_BOTTOM; + } + else if (rId == "doublebottom") + { + pBottom.reset(new editeng::SvxBorderLine(nullptr)); + pBottom->GuessLinesWidths(SvxBorderLineStyle::DOUBLE, DEF_LINE_WIDTH_0, DEF_LINE_WIDTH_0, DEF_LINE_WIDTH_1); + nValidFlags |= FRM_VALID_BOTTOM; + } + else if (rId == "topthickbottom") + { + pBottom.reset(new editeng::SvxBorderLine(nullptr, DEF_LINE_WIDTH_2 )); + pTop.reset(new editeng::SvxBorderLine(nullptr, 1)); + nValidFlags |= FRM_VALID_BOTTOM|FRM_VALID_TOP; + } + else if (rId == "topdoublebottom") + { + pBottom.reset(new editeng::SvxBorderLine(nullptr)); + pBottom->GuessLinesWidths(SvxBorderLineStyle::DOUBLE, DEF_LINE_WIDTH_0, DEF_LINE_WIDTH_0, DEF_LINE_WIDTH_1); + pTop.reset(new editeng::SvxBorderLine(nullptr, 1)); + 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..cadce62cc --- /dev/null +++ b/sc/source/ui/sidebar/CellBorderStyleControl.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 . + */ +#ifndef INCLUDED_SC_SOURCE_UI_SIDEBAR_CELLBORDERSTYLECONTROL_HXX +#define INCLUDED_SC_SOURCE_UI_SIDEBAR_CELLBORDERSTYLECONTROL_HXX + +#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 + +#endif // INCLUDED_SC_SOURCE_UI_SIDEBAR_CELLBORDERSTYLECONTROL_HXX + +/* 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..beae25ff0 --- /dev/null +++ b/sc/source/ui/sidebar/CellLineStyleControl.cxx @@ -0,0 +1,224 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "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/app.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <svx/svxids.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, "valueset", *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 <= 9 ; i++) + { + mxCellLineStyleValueSet->InsertItem(i); + } + + + const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetLocaleI18nHelper(); + maStr[0] = rI18nHelper.GetNum( 5, 2 ) + "pt"; + maStr[1] = rI18nHelper.GetNum( 250, 2 ) + "pt"; + maStr[2] = rI18nHelper.GetNum( 400, 2 ) + "pt"; + maStr[3] = rI18nHelper.GetNum( 500, 2 ) + "pt"; + maStr[4] = rI18nHelper.GetNum( 110, 2 ) + "pt"; + maStr[5] = rI18nHelper.GetNum( 260, 2 ) + "pt"; + maStr[6] = rI18nHelper.GetNum( 450, 2 ) + "pt"; + maStr[7] = rI18nHelper.GetNum( 505, 2 ) + "pt"; + maStr[8] = rI18nHelper.GetNum( 750, 2 ) + "pt"; + 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 = DEF_LINE_WIDTH_0; + break; + case 2: + n1 = DEF_LINE_WIDTH_2; + break; + case 3: + n1 = DEF_LINE_WIDTH_3; + break; + case 4: + n1 = DEF_LINE_WIDTH_4; + break; + case 5: + n1 = DEF_LINE_WIDTH_0; + n2 = DEF_LINE_WIDTH_0; + n3 = DEF_LINE_WIDTH_1; + nStyle = SvxBorderLineStyle::DOUBLE; + break; + case 6: + n1 = DEF_LINE_WIDTH_0; + n2 = DEF_LINE_WIDTH_0; + n3 = DEF_LINE_WIDTH_2; + nStyle = SvxBorderLineStyle::DOUBLE; + break; + case 7: + n1 = DEF_LINE_WIDTH_1; + n2 = DEF_LINE_WIDTH_2; + n3 = DEF_LINE_WIDTH_1; + nStyle = SvxBorderLineStyle::DOUBLE; + break; + case 8: + n1 = DEF_LINE_WIDTH_2; + n2 = DEF_LINE_WIDTH_0; + n3 = DEF_LINE_WIDTH_2; + nStyle = SvxBorderLineStyle::DOUBLE; + break; + case 9: + n1 = DEF_LINE_WIDTH_2; + n2 = DEF_LINE_WIDTH_2; + n3 = DEF_LINE_WIDTH_2; + 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 == DEF_LINE_WIDTH_0 && in == 0 && dis == 0) //1 + { + mxCellLineStyleValueSet->SetSelItem(1); + } + else if(out == DEF_LINE_WIDTH_2 && in == 0 && dis == 0) //2 + { + mxCellLineStyleValueSet->SetSelItem(2); + } + else if(out == DEF_LINE_WIDTH_3 && in == 0 && dis == 0) //3 + { + mxCellLineStyleValueSet->SetSelItem(3); + } + else if(out == DEF_LINE_WIDTH_4 && in == 0 && dis == 0) //4 + { + mxCellLineStyleValueSet->SetSelItem(4); + } + else if(out == DEF_LINE_WIDTH_0 && in == DEF_LINE_WIDTH_0 && dis == DEF_LINE_WIDTH_1) //5 + { + mxCellLineStyleValueSet->SetSelItem(5); + } + else if(out == DEF_LINE_WIDTH_0 && in == DEF_LINE_WIDTH_0 && dis == DEF_LINE_WIDTH_2) //6 + { + mxCellLineStyleValueSet->SetSelItem(6); + } + else if(out == DEF_LINE_WIDTH_1 && in == DEF_LINE_WIDTH_2 && dis == DEF_LINE_WIDTH_1) //7 + { + mxCellLineStyleValueSet->SetSelItem(7); + } + else if(out == DEF_LINE_WIDTH_2 && in == DEF_LINE_WIDTH_0 && dis == DEF_LINE_WIDTH_2) //8 + { + mxCellLineStyleValueSet->SetSelItem(8); + } + else if(out == DEF_LINE_WIDTH_2 && in == DEF_LINE_WIDTH_2 && dis == DEF_LINE_WIDTH_2) //9 + { + mxCellLineStyleValueSet->SetSelItem(9); + } + 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..97bf480b4 --- /dev/null +++ b/sc/source/ui/sidebar/CellLineStyleControl.hxx @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SC_SOURCE_UI_SIDEBAR_CELLLINESTYLECONTROL_HXX +#define INCLUDED_SC_SOURCE_UI_SIDEBAR_CELLLINESTYLECONTROL_HXX + +#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 + +#endif // INCLUDED_SC_SOURCE_UI_SIDEBAR_CELLLINESTYLECONTROL_HXX + +/* 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..624df4882 --- /dev/null +++ b/sc/source/ui/sidebar/CellLineStyleValueSet.cxx @@ -0,0 +1,171 @@ +/* -*- 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) + , nSelItem(0) +{ +} + +CellLineStyleValueSet::~CellLineStyleValueSet() +{ +} + +void CellLineStyleValueSet::SetDrawingArea(weld::DrawingArea* pDrawingArea) +{ + ValueSet::SetDrawingArea(pDrawingArea); + Size aSize = pDrawingArea->get_ref_device().LogicToPixel(Size(80, 12 * 9), MapMode(MapUnit::MapAppFont)); + pDrawingArea->set_size_request(aSize.Width(), aSize.Height()); + SetOutputSizePixel(aSize); + + SetColCount(); + SetLineCount( 9); +} + +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(); + } +} + +void CellLineStyleValueSet::UserDraw( const UserDrawEvent& rUDEvt ) +{ + tools::Rectangle aRect = rUDEvt.GetRect(); + vcl::RenderContext* pDev = rUDEvt.GetRenderContext(); + sal_uInt16 nItemId = rUDEvt.GetItemId(); + + long nRectHeight = aRect.GetHeight(); + 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::getSystemLanguage(), 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); + long nTextWidth = pDev->GetTextWidth(maStrUnit[nItemId - 1]); + long nTLX = aBLPos.X() + 5, nTLY = aBLPos.Y() + ( nRectHeight - nItemId )/2; + 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: + pDev->DrawRect(tools::Rectangle(nTLX, nTLY , nTRX, nTRY + nItemId * 2 - 1 )); + break; + case 5: + pDev->DrawRect(tools::Rectangle(nTLX, nTLY , nTRX, nTRY + 1 )); + pDev->DrawRect(tools::Rectangle(nTLX, nTLY + 3 , nTRX, nTRY + 4 )); + break; + case 6: + pDev->DrawRect(tools::Rectangle(nTLX, nTLY , nTRX, nTRY + 1 )); + pDev->DrawRect(tools::Rectangle(nTLX, nTLY + 5 , nTRX, nTRY + 6 )); + break; + case 7: + pDev->DrawRect(tools::Rectangle(nTLX, nTLY , nTRX, nTRY + 1 )); + pDev->DrawRect(tools::Rectangle(nTLX, nTLY + 3 , nTRX, nTRY + 6 )); + break; + case 8: + pDev->DrawRect(tools::Rectangle(nTLX, nTLY , nTRX, nTRY + 3 )); + pDev->DrawRect(tools::Rectangle(nTLX, nTLY + 5 , nTRX, nTRY + 6 )); + break; + case 9: + 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..5e3f55c4c --- /dev/null +++ b/sc/source/ui/sidebar/CellLineStyleValueSet.hxx @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SC_SOURCE_UI_SIDEBAR_CELLLINESTYLEVALUESET_HXX +#define INCLUDED_SC_SOURCE_UI_SIDEBAR_CELLLINESTYLEVALUESET_HXX + +#include <svtools/valueset.hxx> + +#define CELL_LINE_STYLE_ENTRIES 9 + +namespace sc::sidebar { + +class CellLineStyleValueSet : public ValueSet +{ +private: + sal_uInt16 nSelItem; + OUString maStrUnit[CELL_LINE_STYLE_ENTRIES]; +public: + CellLineStyleValueSet(); + virtual ~CellLineStyleValueSet() override; + + void SetUnit(const OUString* str); + void SetSelItem(sal_uInt16 nSel); + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; + virtual void UserDraw( const UserDrawEvent& rUDEvt ) override; +}; + +} // end of namespace svx::sidebar + +#endif // INCLUDED_SC_SOURCE_UI_SIDEBAR_CELLLINESTYLEVALUESET_HXX + +/* 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..5f823f1b0 --- /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, sal_uInt16 nId, ToolBox& rTbx) + : SfxToolBoxControl(nSlotId, nId, rTbx) +{ +} + +ScNumberFormatControl::~ScNumberFormatControl() +{ +} + +void ScNumberFormatControl::StateChanged(sal_uInt16, SfxItemState eState, + const SfxPoolItem* pState) +{ + sal_uInt16 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..324ebe8f8 --- /dev/null +++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.cxx @@ -0,0 +1,302 @@ +/* -*- 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 <com/sun/star/lang/IllegalArgumentException.hpp> + +using namespace css; +using namespace css::uno; + +namespace sc::sidebar { + +NumberFormatPropertyPanel::NumberFormatPropertyPanel( + vcl::Window* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings) + : PanelLayout(pParent,"NumberFormatPropertyPanel", "modules/scalc/ui/sidebarnumberformat.ui", rxFrame) + , mxLbCategory(m_xBuilder->weld_combo_box("numberformatcombobox")) + , mxTBCategory(m_xBuilder->weld_toolbar("numberformat")) + , mxCatagoryDispatch(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) + , maContext() + , mpBindings(pBindings) +{ + Initialize(); +} + +NumberFormatPropertyPanel::~NumberFormatPropertyPanel() +{ + disposeOnce(); +} + +void NumberFormatPropertyPanel::dispose() +{ + mxLbCategory.reset(); + mxCatagoryDispatch.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(); + + PanelLayout::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::ToggleButton&, 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 }); +} + +VclPtr<vcl::Window> NumberFormatPropertyPanel::Create ( + vcl::Window* 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 VclPtr<NumberFormatPropertyPanel>::Create( + pParent, rxFrame, pBindings); +} + +void NumberFormatPropertyPanel::DataChanged( + const DataChangedEvent&) +{} + +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 = aCode.getToken(0, ',', nIndex).toInt32(); + 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..4eb246dfc --- /dev/null +++ b/sc/source/ui/sidebar/NumberFormatPropertyPanel.hxx @@ -0,0 +1,101 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SC_SOURCE_UI_SIDEBAR_NUMBERFORMATPROPERTYPANEL_HXX +#define INCLUDED_SC_SOURCE_UI_SIDEBAR_NUMBERFORMATPROPERTYPANEL_HXX + +#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 VclPtr<vcl::Window> Create( + vcl::Window* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings); + + virtual void DataChanged( + const DataChangedEvent& rEvent) override; + + 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( + vcl::Window* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings); + virtual ~NumberFormatPropertyPanel() override; + virtual void dispose() override; +private: + //ui controls + std::unique_ptr<weld::ComboBox> mxLbCategory; + std::unique_ptr<weld::Toolbar> mxTBCategory; + std::unique_ptr<ToolbarUnoDispatcher> mxCatagoryDispatch; + 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::ToggleButton&, void); + + void Initialize(); + void DisableControls(); +}; + +} // end of namespace ::sc::sidebar + +#endif + +/* 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..9bd54bf77 --- /dev/null +++ b/sc/source/ui/sidebar/ScPanelFactory.cxx @@ -0,0 +1,142 @@ +/* -*- 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 <toolkit/helper/vclunohelper.hxx> +#include <vcl/window.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() + : PanelFactoryInterfaceBase(m_aMutex) +{ +} + +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); + + VclPtr<vcl::Window> pParentWindow = VCLUnoHelper::GetWindow(xParentWindow); + if ( ! xParentWindow.is() || pParentWindow==nullptr) + 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; + VclPtr<vcl::Window> pPanel; + if (rsResourceURL.endsWith("/AlignmentPropertyPanel")) + pPanel = AlignmentPropertyPanel::Create( pParentWindow, xFrame, pBindings ); + else if (rsResourceURL.endsWith("/CellAppearancePropertyPanel")) + pPanel = CellAppearancePropertyPanel::Create( pParentWindow, xFrame, pBindings ); + else if (rsResourceURL.endsWith("/NumberFormatPropertyPanel")) + pPanel = NumberFormatPropertyPanel::Create( pParentWindow, xFrame, pBindings ); + else if (rsResourceURL.endsWith("/NavigatorPanel")) + { + pPanel = VclPtr<ScNavigatorDlg>::Create(pBindings, pParentWindow); + nMinimumSize = 0; + } + else if (rsResourceURL.endsWith("/FunctionsPanel")) + { + pPanel = VclPtr<ScFunctionWin>::Create(pParentWindow, xFrame); + nMinimumSize = 0; + } + + if (pPanel) + xElement = sfx2::sidebar::SidebarPanelBase::Create( + rsResourceURL, + xFrame, + pPanel, + 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..8154fd9ee --- /dev/null +++ b/sc/source/ui/sidebar/ScPanelFactory.hxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SC_INC_SCPANELFACTORY_HXX +#define INCLUDED_SC_INC_SCPANELFACTORY_HXX + +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/basemutex.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/ui/XUIElementFactory.hpp> + +namespace sc::sidebar { + +typedef ::cppu::WeakComponentImplHelper < + css::ui::XUIElementFactory, css::lang::XServiceInfo + > PanelFactoryInterfaceBase; + +class ScPanelFactory + : private ::cppu::BaseMutex, + 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 + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |