48#include <unonames.hxx>
50#include <com/sun/star/chart2/DataPointLabel.hpp>
51#include <com/sun/star/beans/XPropertyState.hpp>
52#include <com/sun/star/graphic/XGraphic.hpp>
53#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
54#include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
55#include <com/sun/star/chart/ErrorBarStyle.hpp>
56#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
70#include <svx/strings.hrc>
79#include <LibreOfficeKit/LibreOfficeKitEnums.h>
88using ::com::sun::star::uno::Reference;
89using ::com::sun::star::uno::Sequence;
97bool lcl_deleteDataSeries(
98 std::u16string_view rCID,
100 const Reference< document::XUndoManager > & xUndoManager )
102 bool bResult =
false;
104 if( xSeries.is() &&
xModel.is())
110 UndoGuard aUndoGuard(
129bool lcl_deleteDataCurve(
130 std::u16string_view rCID,
132 const Reference< document::XUndoManager > & xUndoManager )
134 bool bResult =
false;
136 uno::Reference< beans::XPropertySet > xProperties(
139 uno::Reference< chart2::XRegressionCurve > xRegressionCurve( xProperties, uno::UNO_QUERY );
141 if( xRegressionCurve.is())
143 uno::Reference< chart2::XRegressionCurveContainer > xRegressionCurveContainer(
147 if( xRegressionCurveContainer.is())
149 UndoGuard aUndoGuard(
154 xRegressionCurveContainer->removeRegressionCurve( xRegressionCurve );
169 return std::make_unique<ReferenceSizeProvider>(aPageSize,
getChartModel());
175 if (pRefSizeProvider)
176 pRefSizeProvider->setValuesAtAllDataSeries();
191 SchResId( STR_ACTION_REARRANGE_CHART ),
196 xDiagram->setPropertyToDefault(
"RelativeSize");
197 xDiagram->setPropertyToDefault(
"RelativePosition");
198 xDiagram->setPropertyToDefault(
"PosSizeExcludeAxes");
201 xDiagram->set3DSettingsToDefault();
207 xLegend->setPropertyToDefault(
"RelativePosition");
208 xLegend->setPropertyToDefault(
"RelativeSize");
209 xLegend->setPropertyToDefault(
"AnchorPosition");
220 if( xTitleState.is())
221 xTitleState->setPropertyToDefault(
"RelativePosition");
225 std::vector< rtl::Reference< RegressionCurveModel > > aRegressionCurves =
226 xDiagram->getAllRegressionCurvesNotMeanValueLine();
229 for(
const auto& xCurve : aRegressionCurves )
235 catch(
const uno::RuntimeException & )
250 OSL_ASSERT(pRefSizeProv);
252 pRefSizeProv->toggleAutoResizeState();
272 if ( aDataHelper.
HasFormat( SotClipboardFormatId::DRAWING ) )
280 std::unique_ptr< SdrModel > spModel(
289 else if ( aDataHelper.
HasFormat( SotClipboardFormatId::SVXB ) )
299 else if( aDataHelper.
HasFormat( SotClipboardFormatId::GDIMETAFILE ))
303 if( aDataHelper.
GetGDIMetaFile( SotClipboardFormatId::GDIMETAFILE, aMetafile ))
304 aGraphic =
Graphic( aMetafile );
306 else if( aDataHelper.
HasFormat( SotClipboardFormatId::BITMAP ))
310 if( aDataHelper.
GetBitmapEx( SotClipboardFormatId::BITMAP, aBmpEx ))
313 else if( aDataHelper.
HasFormat( SotClipboardFormatId::STRING ))
332 if( aGraphic.
GetType() != GraphicType::NONE )
351 if( ! (xGraphic.is() &&
xModel.is()))
354 xGraphicShape->setShapeKind(SdrObjKind::Graphic);
359 xPage->add( xGraphicShape );
361 xModel->setModified(
true );
366 xGraphicShape->SvxShape::setPropertyValue(
"Graphic",
uno::Any( xGraphic ));
368 awt::Size aGraphicSize( 1000, 1000 );
369 bool bGotGraphicSize =
false;
372 bGotGraphicSize = xGraphicShape->SvxShape::getPropertyValue(
"Size100thMM") >>= aGraphicSize;
374 catch (css::beans::UnknownPropertyException& )
378 if( !bGotGraphicSize )
380 bool bGotSizePixel =
false;
383 bGotSizePixel = xGraphicShape->SvxShape::getPropertyValue(
"SizePixel") >>= aGraphicSize;
385 catch (css::beans::UnknownPropertyException& )
387 if ( bGotSizePixel && pChartWindow )
389 ::Size aVCLSize( pChartWindow->PixelToLogic(
Size( aGraphicSize.Width, aGraphicSize.Height )));
390 aGraphicSize.Width = aVCLSize.
getWidth();
391 aGraphicSize.Height = aVCLSize.
getHeight();
394 xGraphicShape->setSize( aGraphicSize );
395 xGraphicShape->setPosition( awt::Point( 0, 0 ) );
412 for ( sal_uInt16
i = 0;
i <
nCount; ++
i )
430 xShape->setPosition( awt::Point( 0, 0 ) );
441 if ( xModifiable.is() )
443 xModifiable->setModified(
true );
462 OSL_ASSERT( xDrawPage.is() );
470 xTextShape->setShapeKind(SdrObjKind::Text);
471 xDrawPage->add( xTextShape );
473 xTextShape->setString( rString );
475 float fCharHeight = 10.0;
476 xTextShape->SvxShape::setPropertyValue(
"TextAutoGrowHeight",
uno::Any(
true ) );
477 xTextShape->SvxShape::setPropertyValue(
"TextAutoGrowWidth",
uno::Any(
true ) );
478 xTextShape->SvxShape::setPropertyValue(
"CharHeight",
uno::Any( fCharHeight ) );
479 xTextShape->SvxShape::setPropertyValue(
"CharHeightAsian",
uno::Any( fCharHeight ) );
480 xTextShape->SvxShape::setPropertyValue(
"CharHeightComplex",
uno::Any( fCharHeight ) );
481 xTextShape->SvxShape::setPropertyValue(
"TextVerticalAdjust",
uno::Any( drawing::TextVerticalAdjust_CENTER ) );
482 xTextShape->SvxShape::setPropertyValue(
"TextHorizontalAdjust",
uno::Any( drawing::TextHorizontalAdjust_CENTER ) );
483 xTextShape->SvxShape::setPropertyValue(
"CharFontName",
uno::Any( OUString(
"Albany") ) );
485 xTextShape->setPosition( rPosition );
500 catch (
const uno::Exception& )
514 pOutlinerView->
Copy();
601 bool bReturn =
false;
605 if( !aCID.isEmpty() )
612 if( !xChartDoc.is() )
616 switch( aObjectType )
642 xLegend->setPropertyValue(
"Show",
uno::Any(
false ));
664 sal_Int32 nEndPos = aCID.lastIndexOf(
':');
665 OUString aParentCID = aCID.copy(0, nEndPos);
682 if( xRegCurveCnt.is())
715 xEqProp->setPropertyValue(
"ShowEquation",
uno::Any(
false ));
716 xEqProp->setPropertyValue(
"XName",
uno::Any( OUString(
"x") ));
717 xEqProp->setPropertyValue(
"YName",
uno::Any( OUString(
"f(x)") ));
718 xEqProp->setPropertyValue(
"ShowCorrelationCoefficient",
uno::Any(
false ));
732 if( xErrorBarProp.is())
737 pId = STR_OBJECT_ERROR_BARS_X;
739 pId = STR_OBJECT_ERROR_BARS_Y;
741 pId = STR_OBJECT_ERROR_BARS_Z;
750 xErrorBarProp->setPropertyValue(
752 uno::Any( css::chart::ErrorBarStyle::NONE ));
765 if( xObjectProperties.is() )
772 chart2::DataPointLabel
aLabel;
774 aLabel.ShowNumber =
false;
775 aLabel.ShowNumberInPercent =
false;
776 aLabel.ShowCategoryName =
false;
777 aLabel.ShowLegendSymbol =
false;
778 aLabel.ShowCustomLabel =
false;
779 aLabel.ShowSeriesName =
false;
843 bool bChanged =
false;
844 if( xLegendProp.is())
849 if( xLegendProp->getPropertyValue(
"Show") >>= bShow )
851 xLegendProp->setPropertyValue(
"Show",
uno::Any( ! bShow ));
855 catch(
const uno::Exception & )
863 if( xLegendProp.is())
879 sal_Int32 nDimensionIndex = 1;
880 sal_Int32 nCooSysIndex = 0;
887 if ( bHasMinorYGrid )
912 sal_Int32 nDimensionIndex = 0;
913 sal_Int32 nCooSysIndex = 0;
943 if( xChartModel.is() )
947 if( xPointProperties.is() )
948 xPointProperties->setPropertyValue(
"FillColor",
uno::Any( nColor ) );
951 catch(
const uno::Exception& )
967 if( xChartModel.is() )
974 OUString aPrefferedName =
975 OUString::number(
static_cast<sal_Int32
>(
Color(aBGradient.
GetColorStops().front().getStopColor())))
976 + OUString::number(
static_cast<sal_Int32
>(
Color(aBGradient.
GetColorStops().back().getStopColor())))
977 + OUString::number(
static_cast<sal_Int32
>(aBGradient.
GetAngle().
get()));
983 xPropSet->setPropertyValue(
"FillGradientName", css::uno::Any(aNewName));
987 catch(
const uno::Exception & )
999 if( xChartModel.is() )
1007 css::uno::Reference<css::chart2::XDiagram> xDiagram(
1008 xPropSet, css::uno::UNO_QUERY);
1010 xPropSet.set(xDiagram->getWall());
1017 catch(
const uno::Exception& )
1029 if( xChartModel.is() )
1037 css::uno::Reference<css::chart2::XDiagram> xDiagram(
1038 xPropSet, css::uno::UNO_QUERY);
1040 xPropSet.set(xDiagram->getWall());
1044 xPropSet->setPropertyValue(
"LineWidth", css::uno::Any( nWidth ) );
1047 catch(
const uno::Exception& )
1069 case LOK_SETTEXTSELECTION_START:
1072 case LOK_SETTEXTSELECTION_END:
1075 case LOK_SETTEXTSELECTION_RESET:
1090 if( xChartModel.is() )
1094 if( xPointProperties.is() )
1095 xPointProperties->setPropertyValue(
"Offset",
uno::Any( nOffset / 100.0 ) );
1098 catch(
const uno::Exception & )
constexpr auto convertTwipToMm100(N n)
static OUString createDescription(ActionType eActionType, std::u16string_view rObjectName)
void SetCursorLogicPosition(const Point &rPosition, bool bPoint, bool bClearMark)
css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const
GraphicType GetType() const
void InsertText(const OUString &rNew, bool bSelect=false)
EditView & GetEditView() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
sal_uInt16 GetPageCount() const
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
virtual rtl::Reference< SdrObject > CloneSdrObject(SdrModel &rTargetModel) const=0
constexpr tools::Long getHeight() const
constexpr tools::Long getWidth() const
bool GetString(SotClipboardFormatId nFormat, OUString &rStr) const
bool GetSotStorageStream(SotClipboardFormatId nFormat, tools::SvRef< SotTempStream > &rStreamRef) const
bool GetGDIMetaFile(SotClipboardFormatId nFormat, GDIMetaFile &rMtf, size_t nMaxActions=0) const
static TransferableDataHelper CreateFromSystemClipboard(vcl::Window *pWindow)
bool HasFormat(SotClipboardFormatId nFormat) const
const css::uno::Reference< css::datatransfer::XTransferable > & GetTransferable() const
bool GetBitmapEx(SotClipboardFormatId nFormat, BitmapEx &rBmp) const
void readGraphic(Graphic &rGraphic)
const basegfx::BColorStops & GetColorStops() const
css::awt::Gradient2 getAsGradient2() const
Degree10 GetAngle() const
static BGradient fromJSON(std::u16string_view rJSON)
static void hideGrid(sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid, const rtl::Reference< ::chart::Diagram > &xDiagram)
static void hideAxisIfNoDataIsAttached(const rtl::Reference< ::chart::Axis > &xAxis, const rtl::Reference< ::chart::Diagram > &xDiagram)
static bool isGridShown(sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid, const rtl::Reference< ::chart::Diagram > &xDiagram)
static void showGrid(sal_Int32 nDimensionIndex, sal_Int32 nCooSysIndex, bool bMainGrid, const rtl::Reference< ::chart::Diagram > &xDiagram)
void executeDispatch_LineColor(sal_uInt32 nColor)
rtl::Reference<::chart::ChartModel > getChartModel()
void executeDispatch_NewArrangement()
void executeDispatch_FillGradient(std::u16string_view sJSONGradient)
std::unique_ptr< DrawViewWrapper > m_pDrawViewWrapper
css::uno::Reference< css::document::XUndoManager > m_xUndoManager
void executeDispatch_LOKPieSegmentDragging(int nOffset)
std::unique_ptr< ReferenceSizeProvider > impl_createReferenceSizeProvider()
void executeDispatch_ToggleGridVertical()
void executeDispatch_FillColor(sal_uInt32 nColor)
void executeDispatch_ScaleText()
void executeDispatch_LOKSetTextSelection(int nType, int nX, int nY)
ChartWindow * GetChartWindow() const
void impl_PasteGraphic(css::uno::Reference< css::graphic::XGraphic > const &xGraphic, const ::Point &aPosition)
std::shared_ptr< DrawModelWrapper > m_pDrawModelWrapper
bool executeDispatch_Delete()
void executeDispatch_Cut()
void executeDispatch_DeleteAxis()
void executeDispatch_DeleteMinorGrid()
void executeDispatch_Copy()
DrawModelWrapper * GetDrawModelWrapper()
void executeDispatch_DeleteMeanValue()
CommandDispatchContainer m_aDispatchContainer
void impl_switchDiagramPositioningToExcludingPositioning()
void executeDispatch_LineWidth(sal_uInt32 nWidth)
void executeDispatch_DeleteMajorGrid()
static bool isObjectDeleteable(const css::uno::Any &rSelection)
void executeDispatch_Paste()
rtl::Reference<::chart::Diagram > getFirstDiagram()
void impl_notifySelectionChangeListeners()
void impl_ShapeControllerDispatch(const css::util::URL &rURL, const css::uno::Sequence< css::beans::PropertyValue > &rArgs)
void impl_ClearSelection()
void executeDispatch_ToggleGridHorizontal()
void impl_PasteShapes(SdrModel *pModel)
bool isShapeContext() const
css::uno::Reference< css::uno::XComponentContext > m_xCC
void impl_adaptDataSeriesAutoResize()
void impl_PasteStringAsTextShape(const OUString &rString, const css::awt::Point &rPosition)
void executeDispatch_ToggleLegend()
static css::awt::Size getPageSize(const rtl::Reference<::chart::ChartModel > &xModel)
ShapeController * getShapeController()
This guard calls lockControllers at the given Model in the CTOR and unlockControllers in the DTOR.
static bool switchDiagramPositioningToExcludingPositioning(ChartModel &rModel, bool bResetModifiedState, bool bConvertAlsoFromAutoPositioning)
const rtl::Reference< SvxDrawPage > & getMainDrawPage()
static SdrObject * getSdrObject(const css::uno::Reference< css::drawing::XShape > &xShape)
static rtl::Reference< ::chart::Legend > getLegend(ChartModel &rModel, const css::uno::Reference< css::uno::XComponentContext > &xContext=nullptr, bool bCreate=false)
bool isAutoGeneratedObject() const
static rtl::Reference< ::chart::DataSeries > getDataSeriesForCID(std::u16string_view rObjectCID, const rtl::Reference<::chart::ChartModel > &xChartModel)
const OUString & getObjectCID() const
static TitleHelper::eTitleType getTitleTypeForCID(std::u16string_view rCID)
bool isAdditionalShape() const
const css::uno::Reference< css::drawing::XShape > & getAdditionalShape() const
static css::uno::Reference< css::beans::XPropertySet > getObjectPropertySet(std::u16string_view rObjectCID, const rtl::Reference< ::chart::ChartModel > &xChartDocument)
static std::u16string_view getFullParentParticle(std::u16string_view rCID)
ObjectType getObjectType() const
static OUString getName(ObjectType eObjectType, bool bPlural=false)
bool hasSelection() const
bool isAdditionalShapeSelected() const
const ObjectIdentifier & getSelectedOID() const
OUString const & getSelectedCID() const
void applySelection(DrawViewWrapper *pDrawViewWrapper)
bool setSelection(const OUString &rCID)
static void removeTitle(eTitleType nTitleIndex, const rtl::Reference< ::chart::ChartModel > &xModel)
static rtl::Reference< ::chart::Title > getTitle(eTitleType nTitleIndex, ChartModel &rModel)
A guard which does nothing, unless you explicitly call commitAction.
#define DBG_TESTSOLARMUTEX()
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
SVXCORE_DLLPUBLIC OUString SvxResId(TranslateId aId)
Reference< XDispatch > xDispatch
OOO_DLLPUBLIC_CHARTTOOLS void setPropertyAlsoToAllAttributedDataPoints(const rtl::Reference< ::chart::DataSeries > &xSeries, const OUString &rPropertyName, const css::uno::Any &rPropertyValue)
OOO_DLLPUBLIC_CHARTTOOLS void deleteSeries(const rtl::Reference< ::chart::DataSeries > &xSeries, const rtl::Reference< ::chart::ChartType > &xChartType)
OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference< ::chart::ChartType > getChartTypeOfSeries(const rtl::Reference< ::chart::DataSeries > &xSeries, const rtl::Reference< ::chart::Diagram > &xDiagram)
OOO_DLLPUBLIC_CHARTTOOLS OUString addGradientUniqueNameToTable(const css::uno::Any &rValue, const css::uno::Reference< css::lang::XMultiServiceFactory > &xFact, const OUString &rPreferredName)
adds a gradient with a unique name to the gradient obtained by the given factory.
OOO_DLLPUBLIC_CHARTTOOLS void resetEquationPosition(const css::uno::Reference< css::chart2::XRegressionCurve > &xCurve)
OOO_DLLPUBLIC_CHARTTOOLS void removeMeanValueLine(css::uno::Reference< css::chart2::XRegressionCurveContainer > const &xRegCnt)
@ OBJECTTYPE_LEGEND_ENTRY
@ OBJECTTYPE_DATA_ERRORS_X
@ OBJECTTYPE_DATA_ERRORS_Y
@ OBJECTTYPE_DATA_CURVE_EQUATION
@ OBJECTTYPE_DATA_AVERAGE_LINE
@ OBJECTTYPE_DATA_ERRORS_Z
OUString OOO_DLLPUBLIC_CHARTTOOLS SchResId(TranslateId aId)
UNDERLYING_TYPE get() const
Reference< XModel > xModel
SVXCORE_DLLPUBLIC SdrPage * GetSdrPageFromXDrawPage(const css::uno::Reference< css::drawing::XDrawPage > &xDrawPage) noexcept
SVXCORE_DLLPUBLIC bool SvxDrawingLayerImport(SdrModel *pModel, const css::uno::Reference< css::io::XInputStream > &xInputStream)
constexpr OUStringLiteral CHART_UNONAME_CUSTOM_LABEL_FIELDS
constexpr OUStringLiteral CHART_UNONAME_LABEL