19#include <com/sun/star/chart2/XDiagram.hpp>
20#include <com/sun/star/container/XNameAccess.hpp>
21#include <com/sun/star/lang/XMultiServiceFactory.hpp>
22#include <com/sun/star/view/XSelectionSupplier.hpp>
23#include <com/sun/star/frame/XController.hpp>
34#include <LibreOfficeKit/LibreOfficeKitEnums.h>
40OUString getCID(
const css::uno::Reference<css::frame::XModel>& xModel)
45 css::uno::Reference<css::frame::XController>
xController(
xModel->getCurrentController());
46 css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(xController, css::uno::UNO_QUERY);
47 if (!xSelectionSupplier.is())
50 css::uno::Any aAny = xSelectionSupplier->getSelection();
60css::uno::Reference<css::beans::XPropertySet> getPropSet(
63 OUString aCID = getCID(xModel);
64 css::uno::Reference<css::beans::XPropertySet> xPropSet =
70 css::uno::Reference<css::chart2::XDiagram> xDiagram(
71 xPropSet, css::uno::UNO_QUERY);
75 xPropSet.set(xDiagram->getWall());
95 css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(
mxModel);
99 SAL_WARN(
"chart2",
"Invalid reference to xPropSet");
113 static constexpr OUStringLiteral aLineColor =
u"LineColor";
114 static const std::u16string_view aCommands[2] = {
u".uno:XLineColor",
u".uno:FillColor"};
116 css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(
mxModel);
121 aUrl.Complete = (
maPropertyName == aLineColor) ? aCommands[0] : aCommands[1];
123 css::frame::FeatureStateEvent
aEvent;
133 sal_Int32 nColor = -1;
136 sCommand +
"=" + OString::number(nColor));
144 , mpControl(pControl)
155 css::uno::Any getLineDash(
156 const css::uno::Reference<css::frame::XModel>& xModel,
const OUString& rDashName)
158 css::uno::Reference<css::lang::XMultiServiceFactory> xFact(xModel, css::uno::UNO_QUERY);
159 css::uno::Reference<css::container::XNameAccess> xNameAccess(
160 xFact->createInstance(
"com.sun.star.drawing.DashTable"),
161 css::uno::UNO_QUERY );
164 if (!xNameAccess->hasByName(rDashName))
165 return css::uno::Any();
167 return xNameAccess->getByName(rDashName);
170 return css::uno::Any();
176 css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(
mxModel);
181 aUrl.Complete =
".uno:XLineStyle";
183 css::frame::FeatureStateEvent
aEvent;
187 aEvent.State = xPropSet->getPropertyValue(
"LineStyle");
190 aUrl.Complete =
".uno:LineDash";
192 auto aLineDashName = xPropSet->getPropertyValue(
"LineDashName");
194 aLineDashName >>= aDashName;
195 css::uno::Any aLineDash = getLineDash(
mxModel, aDashName);
206 css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(
mxModel);
210 SAL_WARN(
"chart2",
"Invalid reference to xPropSet");
214 if (rCommand ==
u".uno:XLineStyle")
216 xPropSet->setPropertyValue(
"LineStyle", rValue);
219 else if (rCommand ==
u".uno:LineDash")
228 xPropSet->setPropertyValue(
"LineDash", aAny);
229 xPropSet->setPropertyValue(
"LineDashName", css::uno::Any(aDashName));
css::uno::Reference< css::frame::XModel2 > mxModel
virtual void libreOfficeKitViewCallback(int nType, const OString &pPayload) const override
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
static css::uno::Reference< css::beans::XPropertySet > getObjectPropertySet(std::u16string_view rObjectCID, const rtl::Reference< ::chart::ChartModel > &xChartDocument)
ObjectType getObjectType() const
#define SAL_WARN(area, stream)
OOO_DLLPUBLIC_CHARTTOOLS OUString addLineDashUniqueNameToTable(const css::uno::Any &rValue, const css::uno::Reference< css::lang::XMultiServiceFactory > &xFact, const OUString &rPreferredName)
adds a line dash with a unique name to the gradient obtained by the given factory.
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
Reference< XController > xController
Reference< XModel > xModel