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  */
19 #include <DefaultShapesPanel.hxx>
20 
21 #include <com/sun/star/lang/IllegalArgumentException.hpp>
24 #include <vcl/settings.hxx>
25 
26 namespace svx::sidebar {
27 
29  vcl::Window* pParent,
30  const css::uno::Reference<css::frame::XFrame>& rxFrame)
31  : PanelLayout(pParent, "DefaultShapesPanel", "svx/ui/defaultshapespanel.ui", rxFrame)
33  , mxLineArrowSet(new ValueSet(nullptr))
34  , mxLineArrowSetWin(new weld::CustomWeld(*m_xBuilder, "LinesArrows", *mxLineArrowSet))
35  , mxCurveSet(new ValueSet(nullptr))
36  , mxCurveSetWin(new weld::CustomWeld(*m_xBuilder, "Curves", *mxCurveSet))
37  , mxConnectorSet(new ValueSet(nullptr))
38  , mxConnectorSetWin(new weld::CustomWeld(*m_xBuilder, "Connectors", *mxConnectorSet))
39  , mxBasicShapeSet(new ValueSet(nullptr))
40  , mxBasicShapeSetWin(new weld::CustomWeld(*m_xBuilder, "BasicShapes", *mxBasicShapeSet))
41  , mxSymbolShapeSet(new ValueSet(nullptr))
42  , mxSymbolShapeSetWin(new weld::CustomWeld(*m_xBuilder, "SymbolShapes", *mxSymbolShapeSet))
43  , mxBlockArrowSet(new ValueSet(nullptr))
44  , mxBlockArrowSetWin(new weld::CustomWeld(*m_xBuilder, "BlockArrows", *mxBlockArrowSet))
45  , mxFlowchartSet(new ValueSet(nullptr))
46  , mxFlowchartSetWin(new weld::CustomWeld(*m_xBuilder, "Flowcharts", *mxFlowchartSet))
47  , mxCalloutSet(new ValueSet(nullptr))
48  , mxCalloutSetWin(new weld::CustomWeld(*m_xBuilder, "Callouts", *mxCalloutSet))
49  , mxStarSet(new ValueSet(nullptr))
50  , mxStarSetWin(new weld::CustomWeld(*m_xBuilder, "Stars", *mxStarSet))
51  , mx3DObjectSet(new ValueSet(nullptr))
52  , mx3DObjectSetWin(new weld::CustomWeld(*m_xBuilder, "3DObjects", *mx3DObjectSet))
53  , mxFrame(rxFrame)
54 {
55  Initialize();
56 }
57 
59  vcl::Window* pParent,
60  const Reference< XFrame >& rxFrame)
61 {
62  if (pParent == nullptr)
63  throw lang::IllegalArgumentException("no parent Window given to DefaultShapesPanel::Create", nullptr, 0);
64  if ( ! rxFrame.is())
65  throw lang::IllegalArgumentException("no XFrame given to DefaultShapesPanel::Create", nullptr, 1);
66 
68  pParent,
69  rxFrame);
70 }
71 
73 {
74  disposeOnce();
75 }
76 
78 {
79  mpShapesSetMap = decltype(mpShapesSetMap){
80  { mxLineArrowSet.get(), mpLineShapes },
81  { mxCurveSet.get(), mpCurveShapes },
83  { mxBasicShapeSet.get(), mpBasicShapes },
87  { mxCalloutSet.get(), mpCalloutShapes },
88  { mxStarSet.get(), mpStarShapes },
89  { mx3DObjectSet.get(), mp3DShapes }
90  };
92  for(auto& aSetMap: mpShapesSetMap)
93  {
94  aSetMap.first->SetColor(GetSettings().GetStyleSettings().GetDialogColor());
95  aSetMap.first->SetSelectHdl(LINK(this, DefaultShapesPanel, ShapeSelectHdl));
96  }
97 }
98 
100 {
101  mpShapesSetMap.clear();
102  mxLineArrowSetWin.reset();
103  mxLineArrowSet.reset();
104  mxCurveSetWin.reset();
105  mxCurveSet.reset();
106  mxConnectorSetWin.reset();
107  mxConnectorSet.reset();
108  mxBasicShapeSetWin.reset();
109  mxBasicShapeSet.reset();
110  mxSymbolShapeSetWin.reset();
111  mxSymbolShapeSet.reset();
112  mxBlockArrowSetWin.reset();
113  mxBlockArrowSet.reset();
114  mxFlowchartSetWin.reset();
115  mxFlowchartSet.reset();
116  mxCalloutSetWin.reset();
117  mxCalloutSet.reset();
118  mxStarSetWin.reset();
119  mxStarSet.reset();
120  mx3DObjectSetWin.reset();
121  mx3DObjectSet.reset();
123 }
124 
125 IMPL_LINK(DefaultShapesPanel, ShapeSelectHdl, ValueSet*, rValueSet, void)
126 {
127  for(auto& aSetMap : mpShapesSetMap)
128  {
129  if(rValueSet == aSetMap.first)
130  {
131  int aSelection = aSetMap.first->GetSelectedItemId();
132  comphelper::dispatchCommand(aSetMap.second[aSelection], {});
133  }
134  else
135  aSetMap.first->SetNoSelection();
136  }
137 }
138 
140 {
141  OUString sSlotStr, sLabel;
142  Image aSlotImage;
143  for(auto& aSet : mpShapesSetMap)
144  {
145  aSet.first->SetColCount(6);
146  for(std::map<sal_uInt16, OUString>::size_type i = 0; i < aSet.second.size(); i++)
147  {
148  sSlotStr = aSet.second[i];
153  aSet.first->InsertItem(i, aSlotImage, sLabel);
154  }
155  }
156 }
157 
158 } // end of namespace svx::sidebar
159 
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::map< sal_uInt16, OUString > mpFlowchartShapes
Definition: ShapesUtil.hxx:30
std::unique_ptr< weld::CustomWeld > mxConnectorSetWin
std::map< sal_uInt16, OUString > mpConnectorShapes
Definition: ShapesUtil.hxx:30
std::map< sal_uInt16, OUString > mpStarShapes
Definition: ShapesUtil.hxx:30
std::unique_ptr< ValueSet > mxBlockArrowSet
std::unique_ptr< weld::CustomWeld > mxSymbolShapeSetWin
std::unique_ptr< weld::CustomWeld > mxStarSetWin
std::map< sal_uInt16, OUString > mpLineShapes
Definition: ShapesUtil.hxx:30
std::unique_ptr< weld::CustomWeld > mx3DObjectSetWin
std::map< sal_uInt16, OUString > mpBasicShapes
Definition: ShapesUtil.hxx:30
std::map< sal_uInt16, OUString > mpBlockArrowShapes
Definition: ShapesUtil.hxx:30
DefaultShapesPanel(vcl::Window *pParent, const css::uno::Reference< css::frame::XFrame > &rxFrame)
static VclPtr< vcl::Window > Create(vcl::Window *pParent, const css::uno::Reference< css::frame::XFrame > &rxFrame)
std::unique_ptr< ValueSet > mxStarSet
std::unique_ptr< weld::CustomWeld > mxLineArrowSetWin
This panel provides buttons for inserting shapes into a document.
PropertiesInfo aProperties
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)
std::unique_ptr< ValueSet > mxSymbolShapeSet
std::map< sal_uInt16, OUString > mpCurveShapes
Definition: ShapesUtil.hxx:30
std::unique_ptr< weld::CustomWeld > mxBasicShapeSetWin
std::unique_ptr< ValueSet > mxLineArrowSet
Image GetImageForCommand(const OUString &rsCommandName, const Reference< frame::XFrame > &rxFrame, vcl::ImageType eImageType)
std::unique_ptr< ValueSet > mxCalloutSet
IMPL_LINK(MediaPlaybackPanel, PlayToolBoxSelectHdl, const OString &, rId, void)
OUString GetModuleIdentifier(const Reference< frame::XFrame > &rxFrame)
int i
std::unique_ptr< weld::CustomWeld > mxFlowchartSetWin
std::unique_ptr< ValueSet > mxBasicShapeSet
std::map< ValueSet *, std::map< sal_uInt16, OUString > > mpShapesSetMap
std::unique_ptr< weld::CustomWeld > mxBlockArrowSetWin
std::unique_ptr< ValueSet > mx3DObjectSet
std::unique_ptr< ValueSet > mxCurveSet
std::unique_ptr< weld::CustomWeld > mxCalloutSetWin
std::map< sal_uInt16, OUString > mpSymbolShapes
Definition: ShapesUtil.hxx:30
std::unique_ptr< weld::CustomWeld > mxCurveSetWin
virtual void dispose() override
Sequence< beans::PropertyValue > GetCommandProperties(const OUString &rsCommandName, const OUString &rsModuleName)
std::map< sal_uInt16, OUString > mp3DShapes
Definition: ShapesUtil.hxx:30
std::unique_ptr< ValueSet > mxConnectorSet
static VclPtr< reference_type > Create(Arg &&...arg)
std::map< sal_uInt16, OUString > mpCalloutShapes
Definition: ShapesUtil.hxx:30
std::unique_ptr< ValueSet > mxFlowchartSet
OUString GetTooltipForCommand(const OUString &rsCommandName, const css::uno::Sequence< css::beans::PropertyValue > &rProperties, const Reference< frame::XFrame > &rxFrame)