diff options
author | Susobhan Ghosh <susobhang70@gmail.com> | 2016-06-29 19:13:53 +0530 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2016-07-08 20:10:02 +0000 |
commit | ab9708e179762f97bd1a0ee4c0d4b439f1dabfd5 (patch) | |
tree | daae95a1a288f72285341dd19ca8a32a99d61698 /svx/source/sidebar/shapes/DefaultShapesPanel.cxx | |
parent | Make bitmap preset preview resizable (diff) | |
download | core-ab9708e179762f97bd1a0ee4c0d4b439f1dabfd5.tar.gz core-ab9708e179762f97bd1a0ee4c0d4b439f1dabfd5.zip |
tdf#87643: Default Shapes Panel for Shapes Deck
Change-Id: Ib3d4a32e70b6dc2ae0898846a27d3ffcb43c2a75
Reviewed-on: https://gerrit.libreoffice.org/26770
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
Diffstat (limited to 'svx/source/sidebar/shapes/DefaultShapesPanel.cxx')
-rw-r--r-- | svx/source/sidebar/shapes/DefaultShapesPanel.cxx | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/svx/source/sidebar/shapes/DefaultShapesPanel.cxx b/svx/source/sidebar/shapes/DefaultShapesPanel.cxx new file mode 100644 index 000000000000..66f1189ab48b --- /dev/null +++ b/svx/source/sidebar/shapes/DefaultShapesPanel.cxx @@ -0,0 +1,141 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#include "DefaultShapesPanel.hxx" + +#include <sfx2/imagemgr.hxx> +#include <comphelper/dispatchcommand.hxx> +#include <vcl/outdev.hxx> +#include <vcl/commandinfoprovider.hxx> + +using ::rtl::OUString; + +namespace svx { namespace sidebar { + +DefaultShapesPanel::DefaultShapesPanel ( + vcl::Window* pParent, + const css::uno::Reference<css::frame::XFrame>& rxFrame) + : PanelLayout(pParent, "DefaultShapesPanel", "svx/ui/defaultshapespanel.ui", rxFrame), + SvxShapeCommandsMap(), + mxFrame(rxFrame) +{ + get(mpScrollWindow, "scrolledwindow1"); + get(mpLineArrowSet, "LinesArrows"); + get(mpCurveSet, "Curves"); + get(mpConnectorSet, "Connectors"); + get(mpBasicShapeSet, "BasicShapes"); + get(mpSymbolShapeSet, "SymbolShapes"); + get(mpBlockArrowSet, "BlockArrows"); + get(mpFlowchartSet, "Flowcharts"); + get(mpCalloutSet, "Callouts"); + get(mpStarSet, "Stars"); + get(mp3DObjectSet, "3DObjects"); + Initialize(); +} + +VclPtr< vcl::Window > DefaultShapesPanel::Create( + vcl::Window* pParent, + const Reference< XFrame >& rxFrame) +{ + if (pParent == nullptr) + throw lang::IllegalArgumentException("no parent Window given to DefaultShapesPanel::Create", nullptr, 0); + if ( ! rxFrame.is()) + throw lang::IllegalArgumentException("no XFrame given to DefaultShapesPanel::Create", nullptr, 1); + + return VclPtr<DefaultShapesPanel>::Create( + pParent, + rxFrame); +} + +DefaultShapesPanel::~DefaultShapesPanel() +{ + disposeOnce(); +} + +void DefaultShapesPanel::Initialize() +{ + mpShapesSetMap = decltype(mpShapesSetMap){ + { mpLineArrowSet, mpLineShapes }, + { mpCurveSet, mpCurveShapes }, + { mpConnectorSet, mpConnectorShapes }, + { mpBasicShapeSet, mpBasicShapes }, + { mpSymbolShapeSet, mpSymbolShapes }, + { mpBlockArrowSet, mpBlockArrowShapes }, + { mpFlowchartSet, mpFlowchartShapes }, + { mpCalloutSet, mpCalloutShapes }, + { mpStarSet, mpStarShapes }, + { mp3DObjectSet, mp3DShapes } + }; + populateShapes(); + for(auto& aSetMap: mpShapesSetMap) + { + aSetMap.first->SetColor(GetSettings().GetStyleSettings().GetMenuColor()); + aSetMap.first->SetSelectHdl(LINK(this, DefaultShapesPanel, ShapeSelectHdl)); + } +} + +void DefaultShapesPanel::dispose() +{ + mpScrollWindow.clear(); + mpLineArrowSet.clear(); + mpCurveSet.clear(); + mpConnectorSet.clear(); + mpBasicShapeSet.clear(); + mpSymbolShapeSet.clear(); + mpBlockArrowSet.clear(); + mpFlowchartSet.clear(); + mpCalloutSet.clear(); + mpStarSet.clear(); + mp3DObjectSet.clear(); + PanelLayout::dispose(); +} + +IMPL_LINK_TYPED(DefaultShapesPanel, ShapeSelectHdl, ValueSet*, rValueSet, void) +{ + for(auto& aSetMap : mpShapesSetMap) + { + if(rValueSet == aSetMap.first) + { + int aSelection = aSetMap.first->GetSelectItemId(); + comphelper::dispatchCommand(aSetMap.second[aSelection], {}); + } + else + aSetMap.first->SetNoSelection(); + } +} + +void DefaultShapesPanel::populateShapes() +{ + OUString sSlotStr, sLabel; + Image aSlotImage; + for(auto& aSet : mpShapesSetMap) + { + aSet.first->SetColCount(6); + for(sal_uInt16 i = 0; i < aSet.second.size(); i++) + { + sSlotStr = aSet.second[i]; + aSlotImage = ::GetImage(mxFrame, sSlotStr, false); + sLabel = vcl::CommandInfoProvider::Instance().GetTooltipForCommand(sSlotStr, mxFrame); + aSet.first->InsertItem(i, aSlotImage, sLabel); + } + } +} + +} } // end of namespace sd::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file |