LibreOffice Module svx (master) 1
DefaultShapesPanel.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
20
21#include <com/sun/star/lang/IllegalArgumentException.hpp>
23#include <utility>
25#include <vcl/settings.hxx>
26#include <vcl/svapp.hxx>
27
28namespace svx::sidebar {
29
31 weld::Widget* pParent,
32 css::uno::Reference<css::frame::XFrame> xFrame)
33 : PanelLayout(pParent, "DefaultShapesPanel", "svx/ui/defaultshapespanel.ui")
34 , mxLineArrowSet(new ValueSet(nullptr))
35 , mxLineArrowSetWin(new weld::CustomWeld(*m_xBuilder, "LinesArrows", *mxLineArrowSet))
36 , mxCurveSet(new ValueSet(nullptr))
37 , mxCurveSetWin(new weld::CustomWeld(*m_xBuilder, "Curves", *mxCurveSet))
38 , mxConnectorSet(new ValueSet(nullptr))
39 , mxConnectorSetWin(new weld::CustomWeld(*m_xBuilder, "Connectors", *mxConnectorSet))
40 , mxBasicShapeSet(new ValueSet(nullptr))
41 , mxBasicShapeSetWin(new weld::CustomWeld(*m_xBuilder, "BasicShapes", *mxBasicShapeSet))
42 , mxSymbolShapeSet(new ValueSet(nullptr))
43 , mxSymbolShapeSetWin(new weld::CustomWeld(*m_xBuilder, "SymbolShapes", *mxSymbolShapeSet))
44 , mxBlockArrowSet(new ValueSet(nullptr))
45 , mxBlockArrowSetWin(new weld::CustomWeld(*m_xBuilder, "BlockArrows", *mxBlockArrowSet))
46 , mxFlowchartSet(new ValueSet(nullptr))
47 , mxFlowchartSetWin(new weld::CustomWeld(*m_xBuilder, "Flowcharts", *mxFlowchartSet))
48 , mxCalloutSet(new ValueSet(nullptr))
49 , mxCalloutSetWin(new weld::CustomWeld(*m_xBuilder, "Callouts", *mxCalloutSet))
50 , mxStarSet(new ValueSet(nullptr))
51 , mxStarSetWin(new weld::CustomWeld(*m_xBuilder, "Stars", *mxStarSet))
52 , mx3DObjectSet(new ValueSet(nullptr))
53 , mx3DObjectSetWin(new weld::CustomWeld(*m_xBuilder, "3DObjects", *mx3DObjectSet))
54 , mxFrame(std::move(xFrame))
55{
56 Initialize();
57 pParent->set_size_request(pParent->get_approximate_digit_width() * 20, -1);
58 m_xContainer->set_size_request(m_xContainer->get_approximate_digit_width() * 25, -1);
59}
60
61std::unique_ptr<PanelLayout> DefaultShapesPanel::Create(
62 weld::Widget* pParent,
63 const Reference< XFrame >& rxFrame)
64{
65 if (pParent == nullptr)
66 throw lang::IllegalArgumentException("no parent Window given to DefaultShapesPanel::Create", nullptr, 0);
67 if ( ! rxFrame.is())
68 throw lang::IllegalArgumentException("no XFrame given to DefaultShapesPanel::Create", nullptr, 1);
69
70 return std::make_unique<DefaultShapesPanel>(pParent, rxFrame);
71}
72
74{
77 { mxCurveSet.get(), mpCurveShapes },
84 { mxStarSet.get(), mpStarShapes },
85 { mx3DObjectSet.get(), mp3DShapes }
86 };
88 for(auto& aSetMap: mpShapesSetMap)
89 {
90 aSetMap.first->SetColor(Application::GetSettings().GetStyleSettings().GetDialogColor());
91 aSetMap.first->SetSelectHdl(LINK(this, DefaultShapesPanel, ShapeSelectHdl));
92 }
93}
94
96{
97 mpShapesSetMap.clear();
98 mxLineArrowSetWin.reset();
99 mxLineArrowSet.reset();
100 mxCurveSetWin.reset();
101 mxCurveSet.reset();
102 mxConnectorSetWin.reset();
103 mxConnectorSet.reset();
104 mxBasicShapeSetWin.reset();
105 mxBasicShapeSet.reset();
106 mxSymbolShapeSetWin.reset();
107 mxSymbolShapeSet.reset();
108 mxBlockArrowSetWin.reset();
109 mxBlockArrowSet.reset();
110 mxFlowchartSetWin.reset();
111 mxFlowchartSet.reset();
112 mxCalloutSetWin.reset();
113 mxCalloutSet.reset();
114 mxStarSetWin.reset();
115 mxStarSet.reset();
116 mx3DObjectSetWin.reset();
117 mx3DObjectSet.reset();
118}
119
120IMPL_LINK(DefaultShapesPanel, ShapeSelectHdl, ValueSet*, rValueSet, void)
121{
122 for(auto& aSetMap : mpShapesSetMap)
123 {
124 if(rValueSet == aSetMap.first)
125 {
126 sal_uInt16 nSelectionId = aSetMap.first->GetSelectedItemId();
127 comphelper::dispatchCommand(aSetMap.second[nSelectionId - 1], {});
128 }
129 else
130 aSetMap.first->SetNoSelection();
131 }
132}
133
135{
136 OUString sSlotStr, sLabel;
137 Image aSlotImage;
138 for(auto& aSet : mpShapesSetMap)
139 {
140 aSet.first->SetColCount(6);
141 for(std::map<sal_uInt16, OUString>::size_type i = 0; i < aSet.second.size(); i++)
142 {
143 sSlotStr = aSet.second[i];
148 sal_uInt16 nSelectionId = i + 1; // tdf#142767 id 0 is reserved for nothing-selected
149 aSet.first->InsertItem(nSelectionId, aSlotImage, sLabel);
150 }
151 }
152}
153
154} // end of namespace svx::sidebar
155
156/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PropertiesInfo aProperties
static const AllSettings & GetSettings()
std::unique_ptr< weld::Container > m_xContainer
This panel provides buttons for inserting shapes into a document.
std::map< ValueSet *, std::map< sal_uInt16, OUString > > mpShapesSetMap
std::unique_ptr< ValueSet > mxSymbolShapeSet
std::unique_ptr< weld::CustomWeld > mxStarSetWin
std::unique_ptr< weld::CustomWeld > mxFlowchartSetWin
std::unique_ptr< weld::CustomWeld > mxSymbolShapeSetWin
std::unique_ptr< ValueSet > mxCalloutSet
std::unique_ptr< ValueSet > mxCurveSet
std::unique_ptr< weld::CustomWeld > mxCurveSetWin
std::unique_ptr< ValueSet > mxConnectorSet
std::unique_ptr< ValueSet > mxBasicShapeSet
static std::unique_ptr< PanelLayout > Create(weld::Widget *pParent, const css::uno::Reference< css::frame::XFrame > &rxFrame)
std::unique_ptr< weld::CustomWeld > mxCalloutSetWin
std::unique_ptr< weld::CustomWeld > mxBlockArrowSetWin
std::unique_ptr< weld::CustomWeld > mxBasicShapeSetWin
std::unique_ptr< ValueSet > mxFlowchartSet
std::unique_ptr< weld::CustomWeld > mx3DObjectSetWin
DefaultShapesPanel(weld::Widget *pParent, css::uno::Reference< css::frame::XFrame > xFrame)
std::unique_ptr< weld::CustomWeld > mxLineArrowSetWin
std::unique_ptr< ValueSet > mxBlockArrowSet
std::unique_ptr< ValueSet > mxStarSet
std::unique_ptr< ValueSet > mx3DObjectSet
std::unique_ptr< ValueSet > mxLineArrowSet
std::unique_ptr< weld::CustomWeld > mxConnectorSetWin
std::map< sal_uInt16, OUString > mpSymbolShapes
Definition: ShapesUtil.hxx:31
std::map< sal_uInt16, OUString > mp3DShapes
Definition: ShapesUtil.hxx:33
std::map< sal_uInt16, OUString > mpConnectorShapes
Definition: ShapesUtil.hxx:31
std::map< sal_uInt16, OUString > mpStarShapes
Definition: ShapesUtil.hxx:33
std::map< sal_uInt16, OUString > mpCurveShapes
Definition: ShapesUtil.hxx:30
std::map< sal_uInt16, OUString > mpBasicShapes
Definition: ShapesUtil.hxx:31
std::map< sal_uInt16, OUString > mpLineShapes
Definition: ShapesUtil.hxx:30
std::map< sal_uInt16, OUString > mpCalloutShapes
Definition: ShapesUtil.hxx:33
std::map< sal_uInt16, OUString > mpFlowchartShapes
Definition: ShapesUtil.hxx:32
std::map< sal_uInt16, OUString > mpBlockArrowShapes
Definition: ShapesUtil.hxx:32
virtual void set_size_request(int nWidth, int nHeight)=0
virtual float get_approximate_digit_width() const=0
bool dispatchCommand(const OUString &rCommand, const uno::Reference< css::frame::XFrame > &rFrame, const css::uno::Sequence< css::beans::PropertyValue > &rArguments, const uno::Reference< css::frame::XDispatchResultListener > &rListener)
int i
IMPL_LINK(MediaPlaybackPanel, PlayToolBoxSelectHdl, const OUString &, rId, void)
Sequence< beans::PropertyValue > GetCommandProperties(const OUString &rsCommandName, const OUString &rsModuleName)
OUString GetTooltipForCommand(const OUString &rsCommandName, const css::uno::Sequence< css::beans::PropertyValue > &rProperties, const Reference< frame::XFrame > &rxFrame)
OUString GetModuleIdentifier(const Reference< frame::XFrame > &rxFrame)
Image GetImageForCommand(const OUString &rsCommandName, const Reference< frame::XFrame > &rxFrame, vcl::ImageType eImageType)
Reference< XFrame > xFrame