Rebased ref, commits from common ancestor:
commit 6cb37078ac90242d5715bb2a1af98d168845cc1f
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Fri May 6 16:04:47 2022 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Fri May 6 18:26:24 2022 +0900
chart2: add initial code for rendering the Data Table
Change-Id: I07d282c0b5e8df6b843516c8bdad538862d6575e
diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk
index 2f1a1a9587f8..3d3806e14c27 100644
--- a/chart2/Library_chartcore.mk
+++ b/chart2/Library_chartcore.mk
@@ -97,6 +97,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcore,\
chart2/source/view/main/ChartView \
chart2/source/view/main/Clipping \
chart2/source/view/main/DataPointSymbolSupplier \
+ chart2/source/view/main/DataTableView \
chart2/source/view/main/DrawModelWrapper \
chart2/source/view/main/ExplicitValueProvider \
chart2/source/view/main/LabelPositionHelper \
diff --git a/chart2/source/view/axes/VAxisBase.cxx
b/chart2/source/view/axes/VAxisBase.cxx
index ace362a9b964..95125beed1cf 100644
--- a/chart2/source/view/axes/VAxisBase.cxx
+++ b/chart2/source/view/axes/VAxisBase.cxx
@@ -22,6 +22,7 @@
#include <ExplicitCategoriesProvider.hxx>
#include "Tickmarks.hxx"
#include <Axis.hxx>
+#include <VSeriesPlotter.hxx>
#include <com/sun/star/chart2/AxisType.hpp>
#include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
@@ -183,8 +184,10 @@ bool VAxisBase::prepareShapeCreation()
//create named group shape
m_xGroupShape_Shapes = createGroupShape( m_xLogicTarget, m_nDimension==2 ?
m_aCID : "");
- if( m_aAxisProperties.m_bDisplayLabels )
+ if (m_aAxisProperties.m_bDisplayLabels)
m_xTextTarget = ShapeFactory::createGroup2D( m_xFinalTarget, m_aCID );
+ if (m_aAxisProperties.m_bDisplayDataTable)
+ m_xDataTableTarget = ShapeFactory::createGroup2D(m_xFinalTarget,
m_aCID);
return true;
}
@@ -239,6 +242,11 @@ void VAxisBase::updateUnscaledValuesAtTicks( TickIter&
rIter )
}
}
+void
VAxisBase::createDataTableView(std::vector<std::unique_ptr<VSeriesPlotter>>&
/*rSeriesPlotterList*/,
+
uno::Reference<util::XNumberFormatsSupplier> const& /*xNumberFormatsSupplier*/)
+{
+}
+
} //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/axes/VAxisBase.hxx
b/chart2/source/view/axes/VAxisBase.hxx
index 31badb749c9d..4da1936a452b 100644
--- a/chart2/source/view/axes/VAxisBase.hxx
+++ b/chart2/source/view/axes/VAxisBase.hxx
@@ -27,6 +27,9 @@ namespace com::sun::star::util { class
XNumberFormatsSupplier; }
namespace chart
{
+class VSeriesPlotter;
+class DataTableView;
+
class VAxisBase : public VAxisOrGridBase
{
public:
@@ -59,6 +62,11 @@ public:
void setExtraLinePositionAtOtherAxis( double fCrossingAt );
+ virtual void
createDataTableView(std::vector<std::unique_ptr<VSeriesPlotter>>&
rSeriesPlotterList,
+
css::uno::Reference<css::util::XNumberFormatsSupplier> const&
xNumberFormatsSupplier);
+
+ std::shared_ptr<DataTableView> getDataTableView() { return
m_pDataTableView; }
+
protected: //methods
static size_t getIndexOfLongestLabel( const css::uno::Sequence<OUString>&
rLabels );
void removeTextShapesFromTicks();
@@ -79,6 +87,9 @@ protected: //member
rtl::Reference< SvxShapeGroupAnyD > m_xGroupShape_Shapes;
rtl::Reference< SvxShapeGroupAnyD > m_xTextTarget;
+ rtl::Reference< SvxShapeGroupAnyD > m_xDataTableTarget;
+
+ std::shared_ptr<DataTableView> m_pDataTableView;
/**
* This typically consists of 2 TickInfo vectors (i.e. the outer vector
diff --git a/chart2/source/view/axes/VAxisProperties.cxx
b/chart2/source/view/axes/VAxisProperties.cxx
index f8f177936e1d..8bbcb490fa2a 100644
--- a/chart2/source/view/axes/VAxisProperties.cxx
+++ b/chart2/source/view/axes/VAxisProperties.cxx
@@ -163,6 +163,7 @@ AxisProperties::AxisProperties( const rtl::Reference< Axis
>& xAxisModel
, m_eTickmarkPos( css::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS )
, m_bCrossingAxisHasReverseDirection(false)
, m_bCrossingAxisIsCategoryAxes(false)
+ , m_bDisplayDataTable(false)
, m_bDisplayLabels( true )
, m_bTryStaggeringFirst( false )
, m_nNumberFormatKey(0)
@@ -253,6 +254,9 @@ void AxisProperties::init( bool bCartesian )
if( bCartesian )
{
+ if (m_nDimensionIndex == 0)
+ m_bDisplayDataTable = true;
+
if( m_nDimensionIndex == 0 && m_nAxisType == AxisType::CATEGORY
&& m_pExplicitCategoriesProvider &&
m_pExplicitCategoriesProvider->hasComplexCategories() )
m_bComplexCategories = true;
diff --git a/chart2/source/view/axes/VAxisProperties.hxx
b/chart2/source/view/axes/VAxisProperties.hxx
index 4370ccbb6e65..78dbb7e3718d 100644
--- a/chart2/source/view/axes/VAxisProperties.hxx
+++ b/chart2/source/view/axes/VAxisProperties.hxx
@@ -110,7 +110,8 @@ struct AxisProperties final
AxisLabelAlignment maLabelAlignment;
- bool m_bDisplayLabels;
+ bool m_bDisplayDataTable;
+ bool m_bDisplayLabels;
// Compatibility option: starting from LibreOffice 5.1 the rotated
// layout is preferred to staggering for axis labels.
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx
b/chart2/source/view/axes/VCartesianAxis.cxx
index 95a86fe377c2..3d5ef9d05fcb 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -34,6 +34,8 @@
#include <tools/color.hxx>
#include <svx/unoshape.hxx>
#include <svx/unoshtxt.hxx>
+#include <VSeriesPlotter.hxx>
+#include <DataTableView.hxx>
#include <comphelper/scopeguard.hxx>
@@ -1665,11 +1667,21 @@ void VCartesianAxis::createLabels()
if( !prepareShapeCreation() )
return;
+ std::unique_ptr<TickFactory2D> apTickFactory2D(createTickFactory2D()); //
throws on failure
+
+ if (m_pDataTableView && m_aAxisProperties.m_bDisplayDataTable)
+ {
+ m_pDataTableView->initializeShapes(m_xDataTableTarget);
+ basegfx::B2DVector aStart = apTickFactory2D->getXaxisStartPos();
+ basegfx::B2DVector aEnd = apTickFactory2D->getXaxisEndPos();
+ m_pDataTableView->createShapes(aStart, aEnd);
+ return;
+ }
+
//create labels
if (!m_aAxisProperties.m_bDisplayLabels)
return;
- std::unique_ptr<TickFactory2D> apTickFactory2D(createTickFactory2D()); //
throws on failure
TickFactory2D* pTickFactory2D = apTickFactory2D.get();
//get the transformed screen values for all tickmarks in aAllTickInfos
@@ -1965,6 +1977,18 @@ void VCartesianAxis::createShapes()
createLabels();
}
+void
VCartesianAxis::createDataTableView(std::vector<std::unique_ptr<VSeriesPlotter>>&
rSeriesPlotterList,
+
Reference<util::XNumberFormatsSupplier> const& xNumberFormatsSupplier)
+{
+ if (m_aAxisProperties.m_bDisplayDataTable)
+ {
+ m_pDataTableView.reset(new DataTableView);
+ m_pDataTableView->initializeValues(rSeriesPlotterList);
+ m_xNumberFormatsSupplier = xNumberFormatsSupplier;
+ }
+}
+
+
} //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/axes/VCartesianAxis.hxx
b/chart2/source/view/axes/VCartesianAxis.hxx
index 94e9b2ab967a..9f396fef43b8 100644
--- a/chart2/source/view/axes/VCartesianAxis.hxx
+++ b/chart2/source/view/axes/VCartesianAxis.hxx
@@ -99,6 +99,8 @@ public:
::basegfx::B2DVector aScreenPos;
};
+ void createDataTableView(std::vector<std::unique_ptr<VSeriesPlotter>>&
rSeriesPlotterList,
+
css::uno::Reference<css::util::XNumberFormatsSupplier> const&
xNumberFormatsSupplier) override;
private: //methods
/**
* Go through all tick label positions and decide which labels to display
diff --git a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
index 1257ff6f4e77..e1a2ba5046e3 100644
--- a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
@@ -98,11 +98,11 @@ void VCartesianCoordinateSystem::createGridShapes()
}
void VCartesianCoordinateSystem::createVAxisList(
- const rtl::Reference<::chart::ChartModel> & xChartDoc
- , const awt::Size& rFontReferenceSize
- , const awt::Rectangle& rMaximumSpaceForLabels
- , bool bLimitSpaceForLabels
- )
+ const rtl::Reference<::chart::ChartModel> & xChartDoc,
+ const awt::Size& rFontReferenceSize,
+ const awt::Rectangle& rMaximumSpaceForLabels,
+ bool bLimitSpaceForLabels,
+ std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList)
{
// note: using xChartDoc itself as XNumberFormatsSupplier would cause
// a leak from VCartesianAxis due to cyclic reference
@@ -163,6 +163,7 @@ void VCartesianCoordinateSystem::createVAxisList(
apVAxis->set3DWallPositions( m_eLeftWallPos, m_eBackWallPos,
m_eBottomPos );
apVAxis->initAxisLabelProperties(rFontReferenceSize,rMaximumSpaceForLabels);
+ apVAxis->createDataTableView(rSeriesPlotterList,
xNumberFormatsSupplier);
}
}
}
diff --git a/chart2/source/view/axes/VCartesianCoordinateSystem.hxx
b/chart2/source/view/axes/VCartesianCoordinateSystem.hxx
index e9d684821445..4b7acf227867 100644
--- a/chart2/source/view/axes/VCartesianCoordinateSystem.hxx
+++ b/chart2/source/view/axes/VCartesianCoordinateSystem.hxx
@@ -31,10 +31,11 @@ public:
virtual ~VCartesianCoordinateSystem() override;
virtual void createVAxisList(
- const rtl::Reference<::chart::ChartModel> &ChartDoc
- , const css::awt::Size& rFontReferenceSize
- , const css::awt::Rectangle& rMaximumSpaceForLabels
- , bool bLimitSpaceForLabels ) override;
+ const rtl::Reference<::chart::ChartModel> &ChartDoc,
+ const css::awt::Size& rFontReferenceSize,
+ const css::awt::Rectangle& rMaximumSpaceForLabels,
+ bool bLimitSpaceForLabels,
+ std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList)
override;
virtual void initVAxisInList() override;
virtual void updateScalesAndIncrementsOnAxes() override;
diff --git a/chart2/source/view/axes/VCoordinateSystem.cxx
b/chart2/source/view/axes/VCoordinateSystem.cxx
index 7860fd7de1c5..142d646010e2 100644
--- a/chart2/source/view/axes/VCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCoordinateSystem.cxx
@@ -322,11 +322,11 @@ sal_Int32
VCoordinateSystem::getMaximumAxisIndexByDimension( sal_Int32 nDimensio
}
void VCoordinateSystem::createVAxisList(
- const rtl::Reference<::chart::ChartModel> & /* xChartDoc */
- , const awt::Size& /* rFontReferenceSize */
- , const awt::Rectangle& /* rMaximumSpaceForLabels */
- , bool /* bLimitSpaceForLabels */
- )
+ const rtl::Reference<::chart::ChartModel> & /* xChartDoc */,
+ const awt::Size& /* rFontReferenceSize */,
+ const awt::Rectangle& /* rMaximumSpaceForLabels */,
+ bool /* bLimitSpaceForLabels */,
+ std::vector<std::unique_ptr<VSeriesPlotter>>&
/*rSeriesPlotterList*/)
{
}
diff --git a/chart2/source/view/axes/VPolarCoordinateSystem.cxx
b/chart2/source/view/axes/VPolarCoordinateSystem.cxx
index e287120f965e..3a3351a54fc3 100644
--- a/chart2/source/view/axes/VPolarCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VPolarCoordinateSystem.cxx
@@ -66,11 +66,11 @@ uno::Sequence< sal_Int32 >
VPolarCoordinateSystem::getCoordinateSystemResolution
}
void VPolarCoordinateSystem::createVAxisList(
- const rtl::Reference<::chart::ChartModel> & xChartDoc
- , const awt::Size& rFontReferenceSize
- , const awt::Rectangle& rMaximumSpaceForLabels
- , bool //bLimitSpaceForLabels
- )
+ const rtl::Reference<::chart::ChartModel> & xChartDoc,
+ const awt::Size& rFontReferenceSize,
+ const awt::Rectangle& rMaximumSpaceForLabels,
+ bool /*bLimitSpaceForLabels*/,
+ std::vector<std::unique_ptr<VSeriesPlotter>>&
/*rSeriesPlotterList*/)
{
// note: using xChartDoc itself as XNumberFormatsSupplier would cause
// a leak from VPolarAxis due to cyclic reference
diff --git a/chart2/source/view/axes/VPolarCoordinateSystem.hxx
b/chart2/source/view/axes/VPolarCoordinateSystem.hxx
index 9659660a5e8c..ecfb2ce4d19d 100644
--- a/chart2/source/view/axes/VPolarCoordinateSystem.hxx
+++ b/chart2/source/view/axes/VPolarCoordinateSystem.hxx
@@ -35,10 +35,11 @@ public:
, const css::awt::Size& rPageResolution )
override;
virtual void createVAxisList(
- const rtl::Reference<::chart::ChartModel> & xChartDoc
- , const css::awt::Size& rFontReferenceSize
- , const css::awt::Rectangle& rMaximumSpaceForLabels
- , bool bLimitSpaceForLabels ) override;
+ const rtl::Reference<::chart::ChartModel> &ChartDoc,
+ const css::awt::Size& rFontReferenceSize,
+ const css::awt::Rectangle& rMaximumSpaceForLabels,
+ bool bLimitSpaceForLabels,
+ std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList)
override;
virtual void initVAxisInList() override;
virtual void updateScalesAndIncrementsOnAxes() override;
diff --git a/chart2/source/view/inc/DataTableView.hxx
b/chart2/source/view/inc/DataTableView.hxx
new file mode 100644
index 000000000000..2710a4152c1e
--- /dev/null
+++ b/chart2/source/view/inc/DataTableView.hxx
@@ -0,0 +1,39 @@
+/* -*- 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/.
+ *
+ */
+#pragma once
+
+#include <svx/unoshape.hxx>
+#include <svx/unodraw/SvxTableShape.hxx>
+#include <com/sun/star/awt/Rectangle.hpp>
+
+namespace chart
+{
+class VSeriesPlotter;
+
+class DataTableView final
+{
+ rtl::Reference<SvxShapeGroupAnyD> m_xTarget;
+ rtl::Reference<SvxShapeGroupAnyD> m_xGroup;
+ rtl::Reference<SvxTableShape> m_xTableShape;
+
+ std::vector<OUString> m_aDataSeriesNames;
+ std::vector<OUString> m_aXValues;
+ std::vector<std::vector<OUString>> m_pDataSeriesValues;
+
+public:
+ DataTableView();
+ void initializeShapes(const rtl::Reference<SvxShapeGroupAnyD>& xTarget);
+ void initializeValues(std::vector<std::unique_ptr<VSeriesPlotter>>&
rSeriesPlotterList);
+ void createShapes(basegfx::B2DVector const& rStart, basegfx::B2DVector
const& rEnd);
+};
+
+} //namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/inc/VCoordinateSystem.hxx
b/chart2/source/view/inc/VCoordinateSystem.hxx
index 0664a5462996..3fef60df6f72 100644
--- a/chart2/source/view/inc/VCoordinateSystem.hxx
+++ b/chart2/source/view/inc/VCoordinateSystem.hxx
@@ -25,14 +25,12 @@
#include <com/sun/star/uno/Sequence.h>
#include <rtl/ref.hxx>
#include <svx/unoshape.hxx>
+#include <DataTableView.hxx>
#include <map>
#include <memory>
#include <vector>
-namespace chart { class ExplicitCategoriesProvider; }
-namespace chart { class ScaleAutomatism; }
-namespace chart { class ChartModel; }
namespace com::sun::star::awt { struct Rectangle; }
namespace com::sun::star::awt { struct Size; }
namespace com::sun::star::beans { class XPropertySet; }
@@ -42,9 +40,11 @@ namespace com::sun::star::chart2 { class XCoordinateSystem; }
namespace com::sun::star::drawing { class XShapes; }
namespace com::sun::star::lang { class XMultiServiceFactory; }
-
namespace chart
{
+class ExplicitCategoriesProvider;
+class ScaleAutomatism;
+class ChartModel;
class Axis;
class BaseCoordinateSystem;
class VAxisBase;
@@ -116,10 +116,11 @@ public:
* Create "view" axis objects 'VAxis' from the coordinate system model.
*/
virtual void createVAxisList(
- const rtl::Reference<::chart::ChartModel> & xChartDoc
- , const css::awt::Size& rFontReferenceSize
- , const css::awt::Rectangle& rMaximumSpaceForLabels
- , bool bLimitSpaceForLabels );
+ const rtl::Reference<::chart::ChartModel> & xChartDoc,
+ const css::awt::Size& rFontReferenceSize,
+ const css::awt::Rectangle& rMaximumSpaceForLabels,
+ bool bLimitSpaceForLabels,
+ std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList);
virtual void initVAxisInList();
virtual void updateScalesAndIncrementsOnAxes();
diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx
b/chart2/source/view/inc/VSeriesPlotter.hxx
index 90a73f1ee504..eefa602caf4d 100644
--- a/chart2/source/view/inc/VSeriesPlotter.hxx
+++ b/chart2/source/view/inc/VSeriesPlotter.hxx
@@ -234,6 +234,8 @@ public:
void setExplicitCategoriesProvider( ExplicitCategoriesProvider*
pExplicitCategoriesProvider );
+ ExplicitCategoriesProvider* getExplicitCategoriesProvider() { return
m_pExplicitCategoriesProvider; }
+
//get series names for the z axis labels
css::uno::Sequence< OUString > getSeriesNames() const;
@@ -254,6 +256,11 @@ public:
bool WantToPlotInFrontOfAxisLine();
virtual bool shouldSnapRectToUsedArea();
+ /// This method returns a text string representation of the passed numeric
+ /// value by exploiting a NumberFormatterWrapper object.
+ OUString getLabelTextForValue(VDataSeries const & rDataSeries, sal_Int32
nPointIndex,
+ double fValue, bool bAsPercentage);
+
protected:
VSeriesPlotter( const rtl::Reference< ::chart::ChartType >& xChartTypeModel
@@ -322,13 +329,6 @@ protected:
, sal_Int32 nOffset=0
, sal_Int32 nTextWidth = 0 );
- /// This method returns a text string representation of the passed numeric
- /// value by exploiting a NumberFormatterWrapper object.
- OUString getLabelTextForValue( VDataSeries const & rDataSeries
- , sal_Int32 nPointIndex
- , double fValue
- , bool bAsPercentage );
-
/** creates two T-shaped error bars in both directions (up/down or
left/right depending on the bVertical parameter)
diff --git a/chart2/source/view/main/ChartView.cxx
b/chart2/source/view/main/ChartView.cxx
index 3f96a68b2612..40b5afa15ffb 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -536,7 +536,7 @@ awt::Rectangle ChartView::impl_createDiagramAndContent(
const CreateShapeParam2D
rpVCooSys->set3DWallPositions( eLeftWallPos, eBackWallPos,
eBottomPos );
}
- rpVCooSys->createVAxisList(&mrChartModel, rPageSize,
rParam.maRemainingSpace, rParam.mbUseFixedInnerSize);
+ rpVCooSys->createVAxisList(&mrChartModel, rPageSize,
rParam.maRemainingSpace, rParam.mbUseFixedInnerSize, rSeriesPlotterList);
}
// - prepare list of all axis and how they are used
diff --git a/chart2/source/view/main/DataTableView.cxx
b/chart2/source/view/main/DataTableView.cxx
new file mode 100644
index 000000000000..3c4b6ff8e523
--- /dev/null
+++ b/chart2/source/view/main/DataTableView.cxx
@@ -0,0 +1,203 @@
+/* -*- 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/.
+ *
+ */
+
+#include <DataTableView.hxx>
+#include <VSeriesPlotter.hxx>
+#include <ShapeFactory.hxx>
+#include <ExplicitCategoriesProvider.hxx>
+
+#include <svx/svdotable.hxx>
+
+#include <com/sun/star/table/XTable.hpp>
+#include <com/sun/star/table/BorderLine.hpp>
+#include <com/sun/star/table/BorderLine2.hpp>
+#include <com/sun/star/table/TableBorder.hpp>
+#include <com/sun/star/style/ParagraphAdjust.hpp>
+#include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
+#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
+
+#include <o3tl/unit_conversion.hxx>
+
+using namespace css;
+
+namespace chart
+{
+DataTableView::DataTableView() = default;
+
+namespace
+{
+void setCellDefaults(uno::Reference<beans::XPropertySet>& xPropertySet)
+{
+ xPropertySet->setPropertyValue("FillColor", uno::Any(Color(0xFFFFFF)));
+ xPropertySet->setPropertyValue("TextVerticalAdjust",
uno::Any(drawing::TextVerticalAdjust_TOP));
+ xPropertySet->setPropertyValue("ParaAdjust",
uno::Any(css::style::ParagraphAdjust_CENTER));
+
+ table::BorderLine2 aBorderLine;
+ aBorderLine.LineWidth = o3tl::convert(0.5, o3tl::Length::pt,
o3tl::Length::mm100);
+ aBorderLine.Color = 0x000000;
+
+ xPropertySet->setPropertyValue("TopBorder", uno::Any(aBorderLine));
+ xPropertySet->setPropertyValue("BottomBorder", uno::Any(aBorderLine));
+ xPropertySet->setPropertyValue("LeftBorder", uno::Any(aBorderLine));
+ xPropertySet->setPropertyValue("RightBorder", uno::Any(aBorderLine));
+}
+
+void setTopCell(uno::Reference<beans::XPropertySet>& xPropertySet)
+{
+ xPropertySet->setPropertyValue("FillColor", uno::Any(Color(0xFFFFFF)));
+ xPropertySet->setPropertyValue("TextVerticalAdjust",
uno::Any(drawing::TextVerticalAdjust_TOP));
+ xPropertySet->setPropertyValue("ParaAdjust",
uno::Any(css::style::ParagraphAdjust_CENTER));
+
+ table::BorderLine2 aBorderLine;
+ aBorderLine.LineWidth = 0;
+ aBorderLine.Color = 0x000000;
+
+ xPropertySet->setPropertyValue("TopBorder", uno::Any(aBorderLine));
+ xPropertySet->setPropertyValue("LeftBorder", uno::Any(aBorderLine));
+}
+}
+void DataTableView::createShapes(basegfx::B2DVector const& rStart,
basegfx::B2DVector const& rEnd)
+{
+ if (!m_xTarget.is())
+ return;
+
+ if (m_xGroup.is())
+ ShapeFactory::removeSubShapes(m_xGroup);
+
+ m_xGroup = ShapeFactory::createGroup2D(m_xTarget, u"GRGG");
+ m_xTableShape = ShapeFactory::createTable(m_xGroup);
+
+ auto* pTableObject =
static_cast<sdr::table::SdrTableObj*>(m_xTableShape->GetSdrObject());
+ css::uno::Reference<css::table::XTable> xTable;
+ try
+ {
+ auto rDelta = rEnd - rStart;
+ m_xGroup->setSize({ rDelta.getX(), 0 });
+
+ m_xTableShape->getPropertyValue("Model") >>= xTable;
+ }
+ catch (const uno::Exception&)
+ {
+ return;
+ }
+
+ if (xTable.is())
+ {
+ css::uno::Reference<css::table::XTableColumns> xTableColumns =
xTable->getColumns();
+ xTableColumns->insertByIndex(0, m_aXValues.size());
+
+ css::uno::Reference<css::table::XTableRows> xTableRows =
xTable->getRows();
+ xTableRows->insertByIndex(0, m_aDataSeriesNames.size());
+
+ {
+ uno::Reference<table::XCell> xCell = xTable->getCellByPosition(0,
0);
+ uno::Reference<beans::XPropertySet> xPropertySet(xCell,
uno::UNO_QUERY);
+ if (xPropertySet.is())
+ {
+ setTopCell(xPropertySet);
+ }
+ }
+
+ sal_Int32 nColumn;
+ sal_Int32 nRow;
+
+ nColumn = 1;
+ for (auto const& rString : m_aXValues)
+ {
+ uno::Reference<table::XCell> xCell =
xTable->getCellByPosition(nColumn, 0);
+ uno::Reference<beans::XPropertySet> xPropertySet(xCell,
uno::UNO_QUERY);
+ css::uno::Reference<css::text::XTextRange> xCellTextRange(xCell,
uno::UNO_QUERY);
+ if (xCellTextRange.is())
+ {
+ xCellTextRange->setString(rString);
+ setCellDefaults(xPropertySet);
+ }
+ nColumn++;
+ }
+
+ nRow = 1;
+ for (auto const& rSeriesName : m_aDataSeriesNames)
+ {
+ uno::Reference<table::XCell> xCell = xTable->getCellByPosition(0,
nRow);
+ uno::Reference<beans::XPropertySet> xPropertySet(xCell,
uno::UNO_QUERY);
+ css::uno::Reference<css::text::XTextRange> xCellTextRange(xCell,
uno::UNO_QUERY);
+ if (xCellTextRange.is())
+ {
+ xCellTextRange->setString(rSeriesName);
+ setCellDefaults(xPropertySet);
+ }
+ nRow++;
+ }
+
+ nRow = 1;
+ for (auto const& rSeries : m_pDataSeriesValues)
+ {
+ nColumn = 1;
+ for (auto const& rValue : rSeries)
+ {
+ uno::Reference<table::XCell> xCell =
xTable->getCellByPosition(nColumn, nRow);
+ uno::Reference<beans::XPropertySet> xPropertySet(xCell,
uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xCellTextRange(xCell,
uno::UNO_QUERY);
+ if (xCellTextRange.is())
+ {
+ xCellTextRange->setString(rValue);
+ setCellDefaults(xPropertySet);
+ }
+ nColumn++;
+ }
+ nRow++;
+ }
+
+ pTableObject->DistributeColumns(0, pTableObject->getColumnCount() - 1,
true, false);
+
+ uno::Reference<beans::XPropertySet>
xPropSet(xTableColumns->getByIndex(0), uno::UNO_QUERY);
+ sal_Int32 nWidth = 0;
+ xPropSet->getPropertyValue("Width") >>= nWidth;
+
+ m_xGroup->setPosition({ rStart.getX() - nWidth, rStart.getY() });
+ }
+}
+
+void DataTableView::initializeShapes(const rtl::Reference<SvxShapeGroupAnyD>&
xTarget)
+{
+ m_xTarget = xTarget;
+}
+
+void DataTableView::initializeValues(
+ std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList)
+{
+ for (auto& rSeriesPlotter : rSeriesPlotterList)
+ {
+ for (auto const& rCategory :
+
rSeriesPlotter->getExplicitCategoriesProvider()->getSimpleCategories())
+ {
+ m_aXValues.push_back(rCategory);
+ }
+
+ for (auto const& rString : rSeriesPlotter->getSeriesNames())
+ {
+ m_aDataSeriesNames.push_back(rString);
+ }
+
+ for (VDataSeries* pSeries : rSeriesPlotter->getAllSeries())
+ {
+ auto& rValues = m_pDataSeriesValues.emplace_back();
+ for (int i = 0; i < pSeries->getTotalPointCount(); i++)
+ {
+ double nValue = pSeries->getYValue(i);
+
rValues.push_back(rSeriesPlotter->getLabelTextForValue(*pSeries, i, nValue,
false));
+ }
+ }
+ }
+}
+
+} //namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit ccfa9ad98166a6ef8febf36d2073d939b71232c4
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Fri May 6 15:46:43 2022 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Fri May 6 18:26:24 2022 +0900
chart2: remove code duplication in VSeriesPlotter::getSeriesNames
Change-Id: Ib7b96e6fe0037a141efe696252ff2aa4a38ec327
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx
b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index 26e462e82c32..eaa7f0743f03 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -2286,6 +2286,34 @@ OUString VSeriesPlotter::getCategoryName( sal_Int32
nPointIndex ) const
return OUString();
}
+std::vector<VDataSeries const*> VSeriesPlotter::getAllSeries() const
+{
+ std::vector<VDataSeries const*> aAllSeries;
+ for (std::vector<VDataSeriesGroup> const & rXSlot : m_aZSlots)
+ {
+ for(VDataSeriesGroup const & rGroup : rXSlot)
+ {
+ for (std::unique_ptr<VDataSeries> const & p :
rGroup.m_aSeriesVector)
+ aAllSeries.push_back(p.get());
+ }
+ }
+ return aAllSeries;
+}
+
+std::vector<VDataSeries*> VSeriesPlotter::getAllSeries()
+{
+ std::vector<VDataSeries*> aAllSeries;
+ for (std::vector<VDataSeriesGroup> const & rXSlot : m_aZSlots)
+ {
+ for(VDataSeriesGroup const & rGroup : rXSlot)
+ {
+ for (std::unique_ptr<VDataSeries> const & p :
rGroup.m_aSeriesVector)
+ aAllSeries.push_back(p.get());
+ }
+ }
+ return aAllSeries;
+}
+
uno::Sequence< OUString > VSeriesPlotter::getSeriesNames() const
{
std::vector<OUString> aRetVector;
@@ -2294,21 +2322,12 @@ uno::Sequence< OUString >
VSeriesPlotter::getSeriesNames() const
if( m_xChartTypeModel.is() )
aRole = m_xChartTypeModel->getRoleOfSequenceForSeriesLabel();
- for (auto const& rGroup : m_aZSlots)
+ for (VDataSeries const* pSeries : getAllSeries())
{
- if (!rGroup.empty())
+ if (pSeries)
{
- VDataSeriesGroup const & rSeriesGroup(rGroup[0]);
- if (!rSeriesGroup.m_aSeriesVector.empty())
- {
- VDataSeries const * pSeries =
rSeriesGroup.m_aSeriesVector[0].get();
- rtl::Reference< DataSeries > xSeries( pSeries ?
pSeries->getModel() : nullptr );
- if( xSeries.is() )
- {
- OUString aSeriesName(
DataSeriesHelper::getDataSeriesLabel( xSeries, aRole ) );
- aRetVector.push_back( aSeriesName );
- }
- }
+ OUString aSeriesName( DataSeriesHelper::getDataSeriesLabel(
pSeries->getModel(), aRole ) );
+ aRetVector.push_back( aSeriesName );
}
}
return comphelper::containerToSequence( aRetVector );
@@ -2431,20 +2450,6 @@ std::vector< ViewLegendEntry >
VSeriesPlotter::createLegendEntries(
return aResult;
}
-std::vector<VDataSeries*> VSeriesPlotter::getAllSeries()
-{
- std::vector<VDataSeries*> aAllSeries;
- for (std::vector<VDataSeriesGroup> const & rXSlot : m_aZSlots)
- {
- for(VDataSeriesGroup const & rGroup : rXSlot)
- {
- for (std::unique_ptr<VDataSeries> const & p :
rGroup.m_aSeriesVector)
- aAllSeries.push_back(p.get());
- }
- }
- return aAllSeries;
-}
-
namespace
{
bool lcl_HasVisibleLine( const uno::Reference< beans::XPropertySet >& xProps,
bool& rbHasDashedLine )
diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx
b/chart2/source/view/inc/VSeriesPlotter.hxx
index 2182be97dcdb..90a73f1ee504 100644
--- a/chart2/source/view/inc/VSeriesPlotter.hxx
+++ b/chart2/source/view/inc/VSeriesPlotter.hxx
@@ -216,7 +216,8 @@ public:
const css::uno::Reference< css::uno::XComponentContext >& xContext
);
- std::vector< VDataSeries* > getAllSeries();
+ std::vector<VDataSeries*> getAllSeries();
+ std::vector<VDataSeries const*> getAllSeries() const;
// This method creates a series plotter of the requested type; e.g. :
return new PieChart...
static VSeriesPlotter* createSeriesPlotter( const rtl::Reference<
::chart::ChartType >& xChartTypeModel
commit 9efb8d4f62bacc093fe1429c44713f9e39da9fb4
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Fri May 6 15:41:23 2022 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Fri May 6 18:26:24 2022 +0900
chart2: simplify with structured binding decl. and some cleanup
- use structured binding declaration to simplify the code
- use cend() instead of end()
- use std::clamp to bound a value
Change-Id: I83b9ba926e70d173cc161db713c53940df422241
diff --git a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
index 866c8fdd89bb..1257ff6f4e77 100644
--- a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
@@ -175,16 +175,13 @@ void VCartesianCoordinateSystem::initVAxisInList()
sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
bool bSwapXAndY = getPropertySwapXAndYAxis();
- for (auto const& elem : m_aAxisMap)
+ for (auto const& [nIndexPair, pVAxis] : m_aAxisMap)
{
- VAxisBase* pVAxis = elem.second.get();
- if( pVAxis )
+ if (pVAxis)
{
- sal_Int32 nDimensionIndex = elem.first.first;
- sal_Int32 nAxisIndex = elem.first.second;
+ auto [nDimensionIndex, nAxisIndex] = nIndexPair;
pVAxis->setExplicitScaleAndIncrement( getExplicitScale(
nDimensionIndex, nAxisIndex ), getExplicitIncrement( nDimensionIndex,
nAxisIndex ) );
- pVAxis->initPlotter(m_xLogicTargetForAxes,m_xFinalTarget
- , createCIDForAxis( nDimensionIndex, nAxisIndex ) );
+ pVAxis->initPlotter(m_xLogicTargetForAxes, m_xFinalTarget,
createCIDForAxis( nDimensionIndex, nAxisIndex ) );
if(nDimensionCount==2)
pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen
);
pVAxis->setScales( getExplicitScales(nDimensionIndex,nAxisIndex),
bSwapXAndY );
@@ -200,13 +197,12 @@ void
VCartesianCoordinateSystem::updateScalesAndIncrementsOnAxes()
sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
bool bSwapXAndY = getPropertySwapXAndYAxis();
- for (auto const& elem : m_aAxisMap)
+ for (auto const& [nIndexPair, pVAxis] : m_aAxisMap)
{
- VAxisBase* pVAxis = elem.second.get();
- if( pVAxis )
+ if (pVAxis)
{
- sal_Int32 nDimensionIndex = elem.first.first;
- sal_Int32 nAxisIndex = elem.first.second;
+ auto [nDimensionIndex, nAxisIndex] = nIndexPair;
+
pVAxis->setExplicitScaleAndIncrement( getExplicitScale(
nDimensionIndex, nAxisIndex ), getExplicitIncrement( nDimensionIndex,
nAxisIndex ) );
if(nDimensionCount==2)
pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen
);
diff --git a/chart2/source/view/axes/VCoordinateSystem.cxx
b/chart2/source/view/axes/VCoordinateSystem.cxx
index 7819a916e039..7860fd7de1c5 100644
--- a/chart2/source/view/axes/VCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCoordinateSystem.cxx
@@ -208,10 +208,7 @@ std::vector< Reference< beans::XPropertySet > >
VCoordinateSystem::getGridListFr
void VCoordinateSystem::impl_adjustDimension( sal_Int32& rDimensionIndex )
{
- if( rDimensionIndex<0 )
- rDimensionIndex=0;
- if( rDimensionIndex>2 )
- rDimensionIndex=2;
+ rDimensionIndex = std::clamp(rDimensionIndex, 0, 2);
}
void VCoordinateSystem::impl_adjustDimensionAndIndex( sal_Int32&
rDimensionIndex, sal_Int32& rAxisIndex ) const
@@ -419,7 +416,7 @@ VAxisBase* VCoordinateSystem::getVAxis( sal_Int32
nDimensionIndex, sal_Int32 nAx
tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex );
tVAxisMap::const_iterator aIt = m_aAxisMap.find( aFullAxisIndex );
- if( aIt != m_aAxisMap.end() )
+ if (aIt != m_aAxisMap.cend())
pRet = aIt->second.get();
return pRet;
@@ -455,26 +452,24 @@ void VCoordinateSystem::set3DWallPositions(
CuboidPlanePosition eLeftWallPos, Cu
void VCoordinateSystem::createMaximumAxesLabels()
{
- for (auto const& elem : m_aAxisMap)
+ for (auto const&[aFullAxisIndex, pVAxis] : m_aAxisMap)
{
- VAxisBase* pVAxis = elem.second.get();
- if( pVAxis )
+ if (pVAxis)
{
- if(pVAxis->getDimensionCount()==2)
- pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen
);
+ if (pVAxis->getDimensionCount() == 2)
+ pVAxis->setTransformationSceneToScreen(m_aMatrixSceneToScreen);
pVAxis->createMaximumLabels();
}
}
}
void VCoordinateSystem::createAxesLabels()
{
- for (auto const& elem : m_aAxisMap)
+ for (auto const&[aFullAxisIndex, pVAxis] : m_aAxisMap)
{
- VAxisBase* pVAxis = elem.second.get();
- if( pVAxis )
+ if (pVAxis)
{
- if(pVAxis->getDimensionCount()==2)
- pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen
);
+ if (pVAxis->getDimensionCount() == 2)
+ pVAxis->setTransformationSceneToScreen(m_aMatrixSceneToScreen);
pVAxis->createLabels();
}
}
@@ -482,12 +477,11 @@ void VCoordinateSystem::createAxesLabels()
void VCoordinateSystem::updatePositions()
{
- for (auto const& elem : m_aAxisMap)
+ for (auto const&[aFullAxisIndex, pVAxis] : m_aAxisMap)
{
- VAxisBase* pVAxis = elem.second.get();
- if( pVAxis )
+ if (pVAxis)
{
- if(pVAxis->getDimensionCount()==2)
+ if (pVAxis->getDimensionCount() == 2)
pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen
);
pVAxis->updatePositions();
}
@@ -496,24 +490,24 @@ void VCoordinateSystem::updatePositions()
void VCoordinateSystem::createAxesShapes()
{
- for (auto const& elem : m_aAxisMap)
+ for (auto const&[aFullAxisIndex, pVAxis] : m_aAxisMap)
{
- VAxisBase* pVAxis = elem.second.get();
- if( pVAxis )
+ if (pVAxis)
{
- if(pVAxis->getDimensionCount()==2)
+ auto const&[nDimensionIndex, nAxisIndex] = aFullAxisIndex;
+
+ if (pVAxis->getDimensionCount() == 2)
pVAxis->setTransformationSceneToScreen( m_aMatrixSceneToScreen
);
- tFullAxisIndex aFullAxisIndex = elem.first;
- if( aFullAxisIndex.second == 0 )
+ if (nAxisIndex == 0)
{
- if( aFullAxisIndex.first == 0 )
+ if (nDimensionIndex == 0)
{
if( m_aExplicitScales[1].AxisType!=AxisType::CATEGORY )
pVAxis->setExtraLinePositionAtOtherAxis(
m_aExplicitScales[1].Origin );
}
- else if( aFullAxisIndex.first == 1 )
+ else if (nDimensionIndex == 1)
{
if( m_aExplicitScales[0].AxisType!=AxisType::CATEGORY )
pVAxis->setExtraLinePositionAtOtherAxis(
diff --git a/chart2/source/view/main/SeriesPlotterContainer.cxx
b/chart2/source/view/main/SeriesPlotterContainer.cxx
index 427c9c169b11..6bbf8739f919 100644
--- a/chart2/source/view/main/SeriesPlotterContainer.cxx
+++ b/chart2/source/view/main/SeriesPlotterContainer.cxx
@@ -498,10 +498,8 @@ void SeriesPlotterContainer::doAutoScaling(ChartModel&
rChartModel)
for (sal_Int32 nAxisIndex = 0; nAxisIndex <= m_nMaxAxisIndex; ++nAxisIndex)
{
// - first do autoscale for all x and z scales (because they are
treated independent)
- for (auto& axisUsage : m_aAxisUsageList)
+ for (auto & [ rAxis, rAxisUsage ] : m_aAxisUsageList)
{
- AxisUsage& rAxisUsage = axisUsage.second;
-
rAxisUsage.prepareAutomaticAxisScaling(rAxisUsage.aAutoScaling, 0,
nAxisIndex);
rAxisUsage.prepareAutomaticAxisScaling(rAxisUsage.aAutoScaling, 2,
nAxisIndex);
@@ -517,10 +515,8 @@ void SeriesPlotterContainer::doAutoScaling(ChartModel&
rChartModel)
}
// - second do autoscale for the dependent y scales (the coordinate
systems are prepared with x and z scales already )
- for (auto& axisUsage : m_aAxisUsageList)
+ for (auto & [ rAxis, rAxisUsage ] : m_aAxisUsageList)
{
- AxisUsage& rAxisUsage = axisUsage.second;
-
rAxisUsage.prepareAutomaticAxisScaling(rAxisUsage.aAutoScaling, 1,
nAxisIndex);
ExplicitScaleData aExplicitScale;
@@ -544,9 +540,8 @@ void
SeriesPlotterContainer::AdaptScaleOfYAxisWithoutAttachedSeries(ChartModel&
//issue #i80518#
for (sal_Int32 nAxisIndex = 0; nAxisIndex <= m_nMaxAxisIndex; nAxisIndex++)
{
- for (auto& axisUsage : m_aAxisUsageList)
+ for (auto & [ rAxis, rAxisUsage ] : m_aAxisUsageList)
{
- AxisUsage& rAxisUsage = axisUsage.second;
std::vector<VCoordinateSystem*> aVCooSysList_Y
= rAxisUsage.getCoordinateSystems(1, nAxisIndex);
if (aVCooSysList_Y.empty())
@@ -648,9 +643,8 @@ void
SeriesPlotterContainer::AdaptScaleOfYAxisWithoutAttachedSeries(ChartModel&
//correct origin for y main axis (the origin is where the other main axis
crosses)
sal_Int32 nAxisIndex = 0;
sal_Int32 nDimensionIndex = 1;
- for (auto& axisUsage : m_aAxisUsageList)
+ for (auto & [ rAxis, rAxisUsage ] : m_aAxisUsageList)
{
- AxisUsage& rAxisUsage = axisUsage.second;
std::vector<VCoordinateSystem*> aVCooSysList
= rAxisUsage.getCoordinateSystems(nDimensionIndex, nAxisIndex);
size_t nC;
commit f6a029bdc39e0e6341c5352e69d0ddc3c8bdc48d
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Fri May 6 15:31:37 2022 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Fri May 6 18:26:24 2022 +0900
chart2: add func. to convert from css::awt and B2IRectangle
Change-Id: I6da70d4559d1536b788228bcae64f5e43462d8e3
diff --git a/chart2/source/inc/BaseGFXHelper.hxx
b/chart2/source/inc/BaseGFXHelper.hxx
index fd24fa2b45b6..18481031e2ef 100644
--- a/chart2/source/inc/BaseGFXHelper.hxx
+++ b/chart2/source/inc/BaseGFXHelper.hxx
@@ -52,6 +52,8 @@ OOO_DLLPUBLIC_CHARTTOOLS css::awt::Point
B2IRectangleToAWTPoint(
OOO_DLLPUBLIC_CHARTTOOLS css::awt::Size B2IRectangleToAWTSize(
const ::basegfx::B2IRectangle& rB2IRectangle );
+OOO_DLLPUBLIC_CHARTTOOLS css::awt::Rectangle toAwtRectangle(const
basegfx::B2IRectangle& rB2IRectangle);
+
::basegfx::B3DVector Direction3DToB3DVector(
const css::drawing::Direction3D& rDirection );
diff --git a/chart2/source/tools/BaseGFXHelper.cxx
b/chart2/source/tools/BaseGFXHelper.cxx
index b518e7dd8b8c..17bd4f5e1809 100644
--- a/chart2/source/tools/BaseGFXHelper.cxx
+++ b/chart2/source/tools/BaseGFXHelper.cxx
@@ -113,6 +113,12 @@ awt::Size B2IRectangleToAWTSize( const
::basegfx::B2IRectangle& rB2IRectangle )
static_cast< sal_Int32 >( rB2IRectangle.getHeight()));
}
+awt::Rectangle toAwtRectangle(const basegfx::B2IRectangle& rRectangle)
+{
+ return awt::Rectangle(rRectangle.getMinX(), rRectangle.getMinY(),
+ rRectangle.getWidth(), rRectangle.getHeight());
+}
+
B3DVector Direction3DToB3DVector( const Direction3D& rDirection )
{
return B3DVector(
diff --git a/chart2/source/view/main/ChartView.cxx
b/chart2/source/view/main/ChartView.cxx
index cfed056234ae..3f96a68b2612 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -751,7 +751,7 @@ awt::Rectangle ChartView::impl_createDiagramAndContent(
const CreateShapeParam2D
else
{
::basegfx::B2IRectangle aConsumedInnerRect =
aVDiagram.getCurrentRectangle();
- m_aResultingDiagramRectangleExcludingAxes = awt::Rectangle(
aConsumedInnerRect.getMinX(), aConsumedInnerRect.getMinY(),
aConsumedInnerRect.getWidth(), aConsumedInnerRect.getHeight() );
+ m_aResultingDiagramRectangleExcludingAxes =
BaseGFXHelper::toAwtRectangle(aConsumedInnerRect);
}
}
else
@@ -761,7 +761,7 @@ awt::Rectangle ChartView::impl_createDiagramAndContent(
const CreateShapeParam2D
else
{
::basegfx::B2IRectangle aConsumedInnerRect =
aVDiagram.getCurrentRectangle();
- m_aResultingDiagramRectangleExcludingAxes = awt::Rectangle(
aConsumedInnerRect.getMinX(), aConsumedInnerRect.getMinY(),
aConsumedInnerRect.getWidth(), aConsumedInnerRect.getHeight() );
+ m_aResultingDiagramRectangleExcludingAxes =
BaseGFXHelper::toAwtRectangle(aConsumedInnerRect);
}
}
commit bdbbce254688bfae786ff82232c064936ae906ae
Author: Chris Sherlock <[email protected]>
AuthorDate: Fri Jul 19 23:47:32 2019 +1000
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Fri May 6 18:26:24 2022 +0900
vcl: add some basic Animation unit tests
Change-Id: Ib8e33fe5f4360b298d2be02fcb5777c21e71fd0c
diff --git a/vcl/CppunitTest_vcl_animation.mk b/vcl/CppunitTest_vcl_animation.mk
index 3ff256daa7b2..659fdbe819ce 100644
--- a/vcl/CppunitTest_vcl_animation.mk
+++ b/vcl/CppunitTest_vcl_animation.mk
@@ -16,6 +16,7 @@ $(eval $(call gb_CppunitTest_set_include,vcl_animation,\
$(eval $(call gb_CppunitTest_add_exception_objects,vcl_animation, \
vcl/qa/cppunit/implanimview \
+ vcl/qa/cppunit/animation \
))
$(eval $(call gb_CppunitTest_use_libraries,vcl_animation, \
diff --git a/vcl/qa/cppunit/animation.cxx b/vcl/qa/cppunit/animation.cxx
new file mode 100644
index 000000000000..e9e308ff7190
--- /dev/null
+++ b/vcl/qa/cppunit/animation.cxx
@@ -0,0 +1,69 @@
+/* -*- 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/.
+ */
+
+#include <test/bootstrapfixture.hxx>
+#include <cppunit/TestAssert.h>
+
+#include <vcl/animate/Animation.hxx>
+
+class VclAnimationTest : public test::BootstrapFixture
+{
+public:
+ VclAnimationTest()
+ : BootstrapFixture(true, false)
+ {
+ }
+
+ void testFrameCount();
+ void testDisplaySize();
+
+ CPPUNIT_TEST_SUITE(VclAnimationTest);
+ CPPUNIT_TEST(testFrameCount);
+ CPPUNIT_TEST(testDisplaySize);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+void VclAnimationTest::testFrameCount()
+{
+ Animation aAnimation;
+
+ CPPUNIT_ASSERT_EQUAL(size_t(0), aAnimation.Count());
+
+ aAnimation.Insert(
+ AnimationBitmap(BitmapEx(Size(3, 4), vcl::PixelFormat::N24_BPP),
Point(0, 0), Size(3, 4)));
+ CPPUNIT_ASSERT_EQUAL(size_t(1), aAnimation.Count());
+
+ aAnimation.Insert(AnimationBitmap(BitmapEx(Size(3, 3),
vcl::PixelFormat::N24_BPP), Point(0, 0),
+ Size(10, 10)));
+ CPPUNIT_ASSERT_EQUAL(size_t(2), aAnimation.Count());
+
+ aAnimation.Clear();
+ CPPUNIT_ASSERT_EQUAL(size_t(0), aAnimation.Count());
+}
+
+void VclAnimationTest::testDisplaySize()
+{
+ Animation aAnimation;
+ CPPUNIT_ASSERT_EQUAL(Size(0, 0), aAnimation.GetDisplaySizePixel());
+
+ aAnimation.Insert(
+ AnimationBitmap(BitmapEx(Size(3, 4), vcl::PixelFormat::N24_BPP),
Point(0, 0), Size(3, 4)));
+ CPPUNIT_ASSERT_EQUAL(Size(3, 4), aAnimation.GetDisplaySizePixel());
+
+ aAnimation.Insert(AnimationBitmap(BitmapEx(Size(10, 10),
vcl::PixelFormat::N24_BPP),
+ Point(0, 0), Size(10, 10)));
+ CPPUNIT_ASSERT_EQUAL(Size(10, 10), aAnimation.GetDisplaySizePixel());
+
+ aAnimation.Clear();
+ CPPUNIT_ASSERT_EQUAL(Size(0, 0), aAnimation.GetDisplaySizePixel());
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(VclAnimationTest);
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit b17562eff39038e5d7f7d839d9675fe19e25d3e1
Author: Chris Sherlock <[email protected]>
AuthorDate: Sun Jul 28 19:16:53 2019 +1000
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Fri May 6 18:26:24 2022 +0900
vcl: test ImplAnimView
Change-Id: I1f17dce097810e4507a9feae1675ff486260657a
diff --git a/vcl/CppunitTest_vcl_animation.mk b/vcl/CppunitTest_vcl_animation.mk
new file mode 100644
index 000000000000..3ff256daa7b2
--- /dev/null
+++ b/vcl/CppunitTest_vcl_animation.mk
@@ -0,0 +1,43 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_CppunitTest_CppunitTest,vcl_animation))
+
+$(eval $(call gb_CppunitTest_set_include,vcl_animation,\
+ -I$(SRCDIR)/vcl/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,vcl_animation, \
+ vcl/qa/cppunit/implanimview \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,vcl_animation, \
+ test \
+ unotest \
+ vcl \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,vcl_animation, \
+ boost_headers \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,vcl_animation))
+
+$(eval $(call gb_CppunitTest_use_ure,vcl_animation))
+$(eval $(call gb_CppunitTest_use_vcl,vcl_animation))
+
+$(eval $(call gb_CppunitTest_use_components,vcl_animation,\
+ configmgr/source/configmgr \
+ i18npool/util/i18npool \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,vcl_animation))
+
+# vim: set noet sw=4 ts=4:
diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk
index 33485fefa52a..62660b718ec1 100644
--- a/vcl/Module_vcl.mk
+++ b/vcl/Module_vcl.mk
@@ -218,6 +218,7 @@ $(eval $(call gb_Module_add_check_targets,vcl,\
CppunitTest_vcl_backend_test \
CppunitTest_vcl_blocklistparser_test \
CppunitTest_vcl_type_serializer_test \
+ CppunitTest_vcl_animation \
$(call gb_Helper_optional, PDFIUM, \
CppunitTest_vcl_pdfium_library_test) \
$(if $(filter SKIA,$(BUILD_TYPE)), \
diff --git a/vcl/inc/impanmvw.hxx b/vcl/inc/impanmvw.hxx
index 99bd7cd5dff2..be48421f5abd 100644
--- a/vcl/inc/impanmvw.hxx
+++ b/vcl/inc/impanmvw.hxx
@@ -20,6 +20,7 @@
#ifndef INCLUDED_VCL_SOURCE_GDI_IMPANMVW_HXX
#define INCLUDED_VCL_SOURCE_GDI_IMPANMVW_HXX
+#include <vcl/dllapi.h>
#include <vcl/animate/Animation.hxx>
#include <vcl/vclptr.hxx>
@@ -41,7 +42,7 @@ struct AInfo
};
-class ImplAnimView
+class VCL_DLLPUBLIC ImplAnimView
{
private:
@@ -68,11 +69,10 @@ private:
bool mbIsMirroredVertically;
public:
- ~ImplAnimView();
-private:
ImplAnimView( Animation* pParent, OutputDevice* pOut,
const Point& rPt, const Size& rSz, sal_uLong
nExtraData,
OutputDevice* pFirstFrameOutDev = nullptr );
+ ~ImplAnimView();
bool matches(const OutputDevice* pOut, tools::Long nExtraData)
const;
void drawToPos( sal_uLong nPos );
diff --git a/vcl/qa/cppunit/implanimview.cxx b/vcl/qa/cppunit/implanimview.cxx
new file mode 100644
index 000000000000..01386fac048d
--- /dev/null
+++ b/vcl/qa/cppunit/implanimview.cxx
@@ -0,0 +1,121 @@
+/* -*- 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/.
+ */
+
+#include <test/bootstrapfixture.hxx>
+#include <cppunit/TestAssert.h>
+
+#include <vcl/animate/Animation.hxx>
+#include <vcl/outdev.hxx>
+#include <vcl/virdev.hxx>
+
+#include <impanmvw.hxx>
+
+namespace
+{
+class TestRenderingContext : public OutputDevice
+{
+public:
+ TestRenderingContext()
+ : OutputDevice(OutDevType::OUTDEV_VIRDEV)
+ {
+ }
+
+ void SaveBackground(VirtualDevice&, const Point&, const Size&, const
Size&) const override {}
+ bool AcquireGraphics() const override { return true; }
+ void ReleaseGraphics(bool) override {}
+ bool UsePolyPolygonForComplexGradient() override { return false; }
+};
+}
+
+class VclImplAnimViewTest : public test::BootstrapFixture
+{
+public:
+ VclImplAnimViewTest()
+ : BootstrapFixture(true, false)
+ {
+ }
+
+ void testMatching();
+ void testDrawToPos();
+ void testGetPosSizeWindow();
+
+ CPPUNIT_TEST_SUITE(VclImplAnimViewTest);
+ CPPUNIT_TEST(testMatching);
+ CPPUNIT_TEST(testDrawToPos);
+ CPPUNIT_TEST(testGetPosSizeWindow);
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+ Animation createAnimation();
+};
+
+void VclImplAnimViewTest::testMatching()
+{
+ Animation aTestAnim = createAnimation();
+ ScopedVclPtrInstance<TestRenderingContext> pTestRC;
+
+ ImplAnimView* pImplAnimView
+ = new ImplAnimView(&aTestAnim, pTestRC, Point(0, 0), Size(10, 10), 5);
+ CPPUNIT_ASSERT(pImplAnimView->matches(pTestRC, 5));
+ CPPUNIT_ASSERT(!pImplAnimView->matches(pTestRC, 10));
+
+ // caller ID of 0 only matches the OutputDevice
+ CPPUNIT_ASSERT(pImplAnimView->matches(pTestRC, 0));
+}
+
+void VclImplAnimViewTest::testDrawToPos()
+{
+ Animation aTestAnim = createAnimation();
+ ScopedVclPtrInstance<VirtualDevice> pTestRC;
+
+ ImplAnimView* pImplAnimView
+ = new ImplAnimView(&aTestAnim, pTestRC.get(), Point(0, 0), Size(10,
10), 5);
+ pImplAnimView->drawToPos(0);
+ pImplAnimView->drawToPos(1);
+ pImplAnimView->drawToPos(2);
+ pImplAnimView->drawToPos(10);
+
+ CPPUNIT_ASSERT_EQUAL(Size(1, 1), pTestRC->GetOutputSizePixel());
+}
+
+void VclImplAnimViewTest::testGetPosSizeWindow()
+{
+ Animation aTestAnim = createAnimation();
+ ScopedVclPtrInstance<TestRenderingContext> pTestRC;
+
+ ImplAnimView* pImplAnimView
+ = new ImplAnimView(&aTestAnim, pTestRC, Point(0, 0), Size(10, 10), 5);
+ AnimationBitmap aAnimBmp(BitmapEx(Size(3, 4), vcl::PixelFormat::N24_BPP),
Point(0, 0),
+ Size(10, 10));
+ Point aPos;
+ Size aSize;
+
+ pImplAnimView->getPosSize(aAnimBmp, aPos, aSize);
+
+ CPPUNIT_ASSERT_EQUAL(Point(0, 0), aPos);
+ CPPUNIT_ASSERT_EQUAL(Size(10, 10), aSize);
+}
+
+Animation VclImplAnimViewTest::createAnimation()
+{
+ Animation aAnimation;
+
+ aAnimation.Insert(AnimationBitmap(BitmapEx(Size(3, 4),
vcl::PixelFormat::N24_BPP), Point(0, 0),
+ Size(10, 10)));
+ aAnimation.Insert(AnimationBitmap(BitmapEx(Size(3, 3),
vcl::PixelFormat::N24_BPP), Point(0, 0),
+ Size(10, 10)));
+
+ return aAnimation;
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(VclImplAnimViewTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit ed883b92efa9ca8e3006290eb2c28485e9052575
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Thu May 5 21:10:25 2022 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Fri May 6 11:23:37 2022 +0200
chart2: add function to create a table shape to ShapeFactory
Change-Id: I18f76c3372504c1d660aa168ee0387f61817f30a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133921
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <[email protected]>
diff --git a/chart2/source/view/inc/ShapeFactory.hxx
b/chart2/source/view/inc/ShapeFactory.hxx
index 89991afaf1b0..d6c05af04d18 100644
--- a/chart2/source/view/inc/ShapeFactory.hxx
+++ b/chart2/source/view/inc/ShapeFactory.hxx
@@ -27,6 +27,7 @@
#include <rtl/ref.hxx>
#include <rtl/ustring.hxx>
#include <svx/unoshape.hxx>
+#include <svx/unodraw/SvxTableShape.hxx>
#include <svx/unopage.hxx>
namespace chart { struct VLineProperties; }
@@ -216,6 +217,8 @@ public:
const css::uno::Reference< css::beans::XPropertySet > &
xTextProperties,
double nRotation, const OUString& aName, sal_Int32
nTextMaxWidth );
+ static rtl::Reference<SvxTableShape>
createTable(rtl::Reference<SvxShapeGroupAnyD> const& xTarget);
+
static rtl::Reference<SvxShapeRect>
createInvisibleRectangle(
const rtl::Reference<SvxShapeGroupAnyD>& xTarget
diff --git a/chart2/source/view/main/ShapeFactory.cxx
b/chart2/source/view/main/ShapeFactory.cxx
index 86e93fc44394..d145feabbda9 100644
--- a/chart2/source/view/main/ShapeFactory.cxx
+++ b/chart2/source/view/main/ShapeFactory.cxx
@@ -2531,6 +2531,20 @@ void ShapeFactory::removeSubShapes( const
rtl::Reference<SvxShapeGroupAnyD>& xSh
}
}
+rtl::Reference<SvxTableShape>
+ShapeFactory::createTable(rtl::Reference<SvxShapeGroupAnyD> const& xTarget)
+{
+ if( !xTarget.is() )
+ return nullptr;
+
+ //create table shape
+ rtl::Reference<SvxTableShape> xShape = new SvxTableShape(nullptr);
+ xShape->setShapeKind(SdrObjKind::Table);
+ xTarget->addShape(*xShape);
+
+ return xShape;
+}
+
} //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 71dee51995d46d0c820c83790d521fbd6bdd568d
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Thu Apr 28 23:10:17 2022 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Fri May 6 11:23:19 2022 +0200
chart2: use range for loop to iterate rVCooSysList in ChartView
We always just iterate the rVCooSysList and don't need the index,
so change the code to use a range for loop.
Change-Id: I3148d5d251c27d8d8f457446508e3152ae86dcc6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133920
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <[email protected]>
diff --git a/chart2/source/view/main/ChartView.cxx
b/chart2/source/view/main/ChartView.cxx
index 6f22d5f438ae..cfed056234ae 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -525,19 +525,18 @@ awt::Rectangle ChartView::impl_createDiagramAndContent(
const CreateShapeParam2D
//create VAxis, so they can give necessary information for automatic
scaling
uno::Reference<util::XNumberFormatsSupplier> const xNumberFormatsSupplier(
mrChartModel.getNumberFormatsSupplier());
- size_t nC = 0;
- for( nC=0; nC < rVCooSysList.size(); nC++)
+
+ for (auto& rpVCooSys : rVCooSysList)
{
- VCoordinateSystem* pVCooSys = rVCooSysList[nC].get();
- if(nDimensionCount==3)
+ if (nDimensionCount == 3)
{
CuboidPlanePosition eLeftWallPos(
ThreeDHelper::getAutomaticCuboidPlanePositionForStandardLeftWall( xDiagram ) );
CuboidPlanePosition eBackWallPos(
ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBackWall( xDiagram ) );
CuboidPlanePosition eBottomPos(
ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBottom( xDiagram ) );
- pVCooSys->set3DWallPositions( eLeftWallPos, eBackWallPos,
eBottomPos );
+ rpVCooSys->set3DWallPositions( eLeftWallPos, eBackWallPos,
eBottomPos );
}
- pVCooSys->createVAxisList(&mrChartModel, rPageSize,
rParam.maRemainingSpace, rParam.mbUseFixedInnerSize);
+ rpVCooSys->createVAxisList(&mrChartModel, rPageSize,
rParam.maRemainingSpace, rParam.mbUseFixedInnerSize);
}
// - prepare list of all axis and how they are used
@@ -574,15 +573,14 @@ awt::Rectangle ChartView::impl_createDiagramAndContent(
const CreateShapeParam2D
// - create axis and grids for all coordinate systems
//init all coordinate systems
- for( nC=0; nC < rVCooSysList.size(); nC++)
+ for (auto& rpVCooSys : rVCooSysList)
{
- VCoordinateSystem* pVCooSys = rVCooSysList[nC].get();
-
pVCooSys->initPlottingTargets(xSeriesTargetInFrontOfAxis,xTextTargetShapes,xSeriesTargetBehindAxis);
+ rpVCooSys->initPlottingTargets(xSeriesTargetInFrontOfAxis,
xTextTargetShapes, xSeriesTargetBehindAxis);
- pVCooSys->setTransformationSceneToScreen( B3DHomMatrixToHomogenMatrix(
+ rpVCooSys->setTransformationSceneToScreen( B3DHomMatrixToHomogenMatrix(
createTransformationSceneToScreen( aVDiagram.getCurrentRectangle()
) ));
- pVCooSys->initVAxisInList();
+ rpVCooSys->initVAxisInList();
}
//calculate resulting size respecting axis label layout and fontscaling
@@ -645,15 +643,13 @@ awt::Rectangle ChartView::impl_createDiagramAndContent(
const CreateShapeParam2D
}
//create axes and grids for the final size
- for( nC=0; nC < rVCooSysList.size(); nC++)
+ for (auto& rpVCooSys : rVCooSysList)
{
- VCoordinateSystem* pVCooSys = rVCooSysList[nC].get();
-
- pVCooSys->setTransformationSceneToScreen( B3DHomMatrixToHomogenMatrix(
+ rpVCooSys->setTransformationSceneToScreen( B3DHomMatrixToHomogenMatrix(
createTransformationSceneToScreen( aVDiagram.getCurrentRectangle()
) ));
- pVCooSys->createAxesShapes();
- pVCooSys->createGridShapes();
+ rpVCooSys->createAxesShapes();
+ rpVCooSys->createGridShapes();
}
// - create data series for all charttypes
@@ -712,11 +708,10 @@ awt::Rectangle ChartView::impl_createDiagramAndContent(
const CreateShapeParam2D
ShapeFactory::removeSubShapes( xTextTargetShapes );
//set new transformation
- for( nC=0; nC < rVCooSysList.size(); nC++)
+ for (auto& rpVCooSys : rVCooSysList)
{
- VCoordinateSystem* pVCooSys = rVCooSysList[nC].get();
- pVCooSys->setTransformationSceneToScreen(
B3DHomMatrixToHomogenMatrix(
- createTransformationSceneToScreen( aNewInnerRect ) ));
+ auto aMatrix = createTransformationSceneToScreen(aNewInnerRect);
+
rpVCooSys->setTransformationSceneToScreen(B3DHomMatrixToHomogenMatrix(aMatrix));
}
// - create data series for all charttypes
commit 92f93f300371d2011b53d48d3491870b24cff0b4
Author: Noel Grandin <[email protected]>
AuthorDate: Thu Mar 24 12:46:44 2022 +0200
Commit: Noel Grandin <[email protected]>
CommitDate: Fri May 6 11:04:33 2022 +0200
output error code when SymFromAddr fails
instead of random data
Change-Id: Iba020ea3a2386e3ad940cc85aac18047c3773967
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132066
Tested-by: Jenkins
Reviewed-by: Noel Grandin <[email protected]>
diff --git a/sal/cppunittester/cppunittester.cxx
b/sal/cppunittester/cppunittester.cxx
index fec62c261260..4a1c050a4662 100644
--- a/sal/cppunittester/cppunittester.cxx
+++ b/sal/cppunittester/cppunittester.cxx
@@ -488,116 +488,90 @@ static bool main2()
#if defined(_WIN32) && defined(_DEBUG)
//Prints stack trace based on exception context record
-static void printStack( CONTEXT* ctx )
+static void printStack( PCONTEXT ctx )
{
constexpr int MaxNameLen = 256;
- bool result;
- HANDLE process;
- HANDLE thread;
- HMODULE hModule;
-#ifdef _M_AMD64
- STACKFRAME64 stack;
-#else
- STACKFRAME stack;
-#endif
- DWORD64 displacement;
- DWORD disp;
- char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)];
- char module[MaxNameLen];
- PSYMBOL_INFO pSymbol = reinterpret_cast<PSYMBOL_INFO>(buffer);
+ HANDLE process = GetCurrentProcess();
+ HANDLE thread = GetCurrentThread();
-#ifdef _M_AMD64
- memset( &stack, 0, sizeof( STACKFRAME64 ) );
-#else
- memset( &stack, 0, sizeof( STACKFRAME ) );
-#endif
-
- process = GetCurrentProcess();
- thread = GetCurrentThread();
- displacement = 0;
-#if !defined(_M_AMD64)
- stack.AddrPC.Offset = (*ctx).Eip;
+ STACKFRAME64 stack {};
stack.AddrPC.Mode = AddrModeFlat;
- stack.AddrStack.Offset = (*ctx).Esp;
stack.AddrStack.Mode = AddrModeFlat;
- stack.AddrFrame.Offset = (*ctx).Ebp;
stack.AddrFrame.Mode = AddrModeFlat;
+#ifdef _M_AMD64
+ stack.AddrPC.Offset = ctx->Rip;
+ stack.AddrStack.Offset = ctx->Rsp;
+ stack.AddrFrame.Offset = ctx->Rsp;
+#else
+ stack.AddrPC.Offset = ctx->Eip;
+ stack.AddrStack.Offset = ctx->Esp;
+ stack.AddrFrame.Offset = ctx->Ebp;
#endif
+ DWORD symOptions = SymGetOptions();
+ symOptions |= SYMOPT_LOAD_LINES;
+ symOptions |= SYMOPT_FAIL_CRITICAL_ERRORS;
+ symOptions = SymSetOptions(symOptions);
+
SymInitialize( process, nullptr, TRUE ); //load symbols
-#ifdef _M_AMD64
- std::unique_ptr<IMAGEHLP_LINE64> line(new IMAGEHLP_LINE64);
- line->SizeOfStruct = sizeof(IMAGEHLP_LINE64);
-#else
- std::unique_ptr<IMAGEHLP_LINE> line(new IMAGEHLP_LINE);
- line->SizeOfStruct = sizeof(IMAGEHLP_LINE);
-#endif
+ IMAGEHLP_LINE64 line{};
+ line.SizeOfStruct = sizeof(line);
+
+ char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)];
+ PSYMBOL_INFO pSymbol = reinterpret_cast<PSYMBOL_INFO>(buffer);
- for( ; ; )
+ for (;;)
{
//get next call from stack
-#ifdef _M_AMD64
- result = StackWalk64
+ bool result = StackWalk64
(
+#ifdef _M_AMD64
IMAGE_FILE_MACHINE_AMD64,
- process,
- thread,
- &stack,
- ctx,
- nullptr,
- SymFunctionTableAccess64,
- SymGetModuleBase64,
- nullptr
- );
#else
- result = StackWalk
- (
IMAGE_FILE_MACHINE_I386,
+#endif
process,
thread,
&stack,
ctx,
nullptr,
- SymFunctionTableAccess,
- SymGetModuleBase,
+ SymFunctionTableAccess64,
+ SymGetModuleBase64,
nullptr
);
-#endif
if( !result )
break;
//get symbol name for address
pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO);
- pSymbol->MaxNameLen = MAX_SYM_NAME;
-#ifdef _M_AMD64
- SymFromAddr(process, static_cast< ULONG64 >(stack.AddrPC.Offset),
&displacement, pSymbol);
-#else
- SymFromAddr(process, static_cast< ULONG >(stack.AddrPC.Offset),
&displacement, pSymbol);
-#endif
+ pSymbol->MaxNameLen = MAX_SYM_NAME + 1;
+ if (SymFromAddr(process, stack.AddrPC.Offset, nullptr, pSymbol))
+ printf("\tat %s", pSymbol->Name);
+ else
+ printf("\tat unknown (Error in SymFromAddr=%#08x)",
GetLastError());
+
+ DWORD disp;
//try to get line
-#ifdef _M_AMD64
- if (SymGetLineFromAddr64(process, stack.AddrPC.Offset, &disp,
line.get()))
-#else
- if (SymGetLineFromAddr(process, stack.AddrPC.Offset, &disp,
line.get()))
-#endif
+ if (SymGetLineFromAddr64(process, stack.AddrPC.Offset, &disp, &line))
{
- printf("\tat %s in %s: line: %lu: address: 0x%0I64X\n",
pSymbol->Name, line->FileName, line->LineNumber, pSymbol->Address);
+ printf(" in %s: line: %lu:\n", line.FileName, line.LineNumber);
}
else
{
//failed to get line
- printf("\tat %s, address 0x%0I64X.\n", pSymbol->Name,
pSymbol->Address);
- hModule = nullptr;
- lstrcpyA(module,"");
+ printf(", address 0x%0I64X", stack.AddrPC.Offset);
+ HMODULE hModule = nullptr;
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
reinterpret_cast<LPCTSTR>(stack.AddrPC.Offset), &hModule);
+ char sModule[256];
//at least print module name
- if(hModule !=
nullptr)GetModuleFileNameA(hModule,module,MaxNameLen);
+ if (hModule != nullptr)
+ GetModuleFileNameA(hModule, sModule, std::size(sModule));
- printf ("in %s\n",module);
+ printf (" in %s\n", sModule);
}
}
}
commit 7aa0730d6cdf1b2e74e1d8c9adb666cfb51d8fc6
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Thu Apr 28 23:07:57 2022 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Fri May 6 10:51:50 2022 +0200
chart2: typedef SeriesPlottersType is not needed
Change-Id: I457bfa5eab8b403c4b00a72068e427082709995c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133919
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <[email protected]>
diff --git a/chart2/source/view/main/ChartView.cxx
b/chart2/source/view/main/ChartView.cxx
index 56d53a78aa25..6f22d5f438ae 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -520,7 +520,7 @@ awt::Rectangle ChartView::impl_createDiagramAndContent(
const CreateShapeParam2D
basegfx::B2IRectangle aAvailableOuterRect =
BaseGFXHelper::makeRectangle(rParam.maRemainingSpace);
const std::vector< std::unique_ptr<VCoordinateSystem> >& rVCooSysList(
rParam.mpSeriesPlotterContainer->getCooSysList() );
- SeriesPlottersType& rSeriesPlotterList =
rParam.mpSeriesPlotterContainer->getSeriesPlotterList();
+ auto& rSeriesPlotterList =
rParam.mpSeriesPlotterContainer->getSeriesPlotterList();
//create VAxis, so they can give necessary information for automatic
scaling
uno::Reference<util::XNumberFormatsSupplier> const xNumberFormatsSupplier(
@@ -1897,7 +1897,7 @@ void ChartView::createShapes2D( const awt::Size&
rPageSize )
aParam.mpSeriesPlotterContainer->initializeCooSysAndSeriesPlotter(
mrChartModel );
if(maTimeBased.bTimeBased && maTimeBased.nFrame != 0)
{
- SeriesPlottersType& rSeriesPlotter =
aParam.mpSeriesPlotterContainer->getSeriesPlotterList();
+ auto& rSeriesPlotter =
aParam.mpSeriesPlotterContainer->getSeriesPlotterList();
size_t n = rSeriesPlotter.size();
for(size_t i = 0; i < n; ++i)
{
@@ -1957,7 +1957,7 @@ void ChartView::createShapes2D( const awt::Size&
rPageSize )
if(maTimeBased.bTimeBased && maTimeBased.nFrame % 60 == 0)
{
// create copy of the data for next frame
- SeriesPlottersType& rSeriesPlotter =
aParam.mpSeriesPlotterContainer->getSeriesPlotterList();
+ auto& rSeriesPlotter =
aParam.mpSeriesPlotterContainer->getSeriesPlotterList();
size_t n = rSeriesPlotter.size();
maTimeBased.m_aDataSeriesList.clear();
maTimeBased.m_aDataSeriesList.resize(n);
diff --git a/chart2/source/view/main/SeriesPlotterContainer.hxx
b/chart2/source/view/main/SeriesPlotterContainer.hxx
index 07677f2aca28..e34d07a962ff 100644
--- a/chart2/source/view/main/SeriesPlotterContainer.hxx
+++ b/chart2/source/view/main/SeriesPlotterContainer.hxx
@@ -24,8 +24,6 @@
namespace chart
{
-typedef std::vector<std::unique_ptr<VSeriesPlotter>> SeriesPlottersType;
-
/** This class is a container of `SeriesPlotter` objects (such as `PieChart`
* instances). It is used for initializing coordinate systems, axes and scales
* of all series plotters which belongs to the container.
@@ -108,7 +106,10 @@ public:
void setNumberFormatsFromAxes();
css::drawing::Direction3D getPreferredAspectRatio();
- SeriesPlottersType& getSeriesPlotterList() { return m_aSeriesPlotterList; }
+ std::vector<std::unique_ptr<VSeriesPlotter>>& getSeriesPlotterList()
+ {
+ return m_aSeriesPlotterList;
+ }
std::vector<std::unique_ptr<VCoordinateSystem>>& getCooSysList() { return
m_rVCooSysList; }
std::vector<LegendEntryProvider*> getLegendEntryProviderList();
@@ -130,7 +131,7 @@ public:
private:
/** A vector of series plotters.
*/
- SeriesPlottersType m_aSeriesPlotterList;
+ std::vector<std::unique_ptr<VSeriesPlotter>> m_aSeriesPlotterList;
/** A vector of coordinate systems.
*/
commit cc1be7312d9f6bd4a4ea742c6d1e3cb9293631cc
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Fri Apr 22 16:53:32 2022 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Fri May 6 10:51:18 2022 +0200
svx: move SvxTableShape into own file and externalize
Change-Id: I0c4b37ebafa56ed50286bdcec1f2a8d5e1362f8d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133918
Tested-by: Tomaž Vajngerl <[email protected]>
Reviewed-by: Tomaž Vajngerl <[email protected]>
diff --git a/include/svx/unodraw/SvxTableShape.hxx
b/include/svx/unodraw/SvxTableShape.hxx
new file mode 100644
index 000000000000..518d3ac2c06a
--- /dev/null
+++ b/include/svx/unodraw/SvxTableShape.hxx
@@ -0,0 +1,44 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include <svx/svxdllapi.h>
+#include <svx/unoshape.hxx>
+
+class SVXCORE_DLLPUBLIC SvxTableShape : public SvxShape
+{
+protected:
+ // override these for special property handling in subcasses. Return true
if property is handled
+ virtual bool setPropertyValueImpl(const OUString& rName,
+ const SfxItemPropertyMapEntry* pProperty,
+ const css::uno::Any& rValue) override;
+ virtual bool getPropertyValueImpl(const OUString& rName,
+ const SfxItemPropertyMapEntry* pProperty,
+ css::uno::Any& rValue) override;
+
+ virtual void lock() override;
+ virtual void unlock() override;
+
+public:
+ explicit SvxTableShape(SdrObject* pObj);
+ virtual ~SvxTableShape() noexcept override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/shapeimpl.hxx b/svx/source/unodraw/shapeimpl.hxx
index 0ccf22071194..44b3bcdea0e2 100644
--- a/svx/source/unodraw/shapeimpl.hxx
+++ b/svx/source/unodraw/shapeimpl.hxx
@@ -84,23 +84,6 @@ public:
virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage ) override;
};
-
-class SvxTableShape : public SvxShape
-{
-protected:
- // override these for special property handling in subcasses. Return true
if property is handled
- virtual bool setPropertyValueImpl( const OUString& rName, const
SfxItemPropertyMapEntry* pProperty, const css::uno::Any& rValue ) override;
- virtual bool getPropertyValueImpl( const OUString& rName, const
SfxItemPropertyMapEntry* pProperty, css::uno::Any& rValue ) override;
-
- virtual void lock() override;
- virtual void unlock() override;
-
-public:
-
- explicit SvxTableShape(SdrObject* pObj);
- virtual ~SvxTableShape() noexcept override;
-};
-
SvxUnoPropertyMapProvider& getSvxMapProvider();
#endif
diff --git a/svx/source/unodraw/tableshape.cxx
b/svx/source/unodraw/tableshape.cxx
index 69823ea3043b..b9220516411a 100644
--- a/svx/source/unodraw/tableshape.cxx
+++ b/svx/source/unodraw/tableshape.cxx
@@ -21,6 +21,7 @@
#include "UnoGraphicExporter.hxx"
#include "shapeimpl.hxx"
+#include <svx/unodraw/SvxTableShape.hxx>
#include <svx/unoshprp.hxx>
#include <svx/svdotable.hxx>
#include <svx/svdpool.hxx>
diff --git a/svx/source/unodraw/unopage.cxx b/svx/source/unodraw/unopage.cxx
index f676e743e548..ee91c36c9afe 100644
--- a/svx/source/unodraw/unopage.cxx
+++ b/svx/source/unodraw/unopage.cxx
@@ -41,6 +41,7 @@
#include <svx/svdundo.hxx>
#include <svx/unopage.hxx>
#include "shapeimpl.hxx"
+#include <svx/unodraw/SvxTableShape.hxx>
#include <svx/dialmgr.hxx>
#include <svx/svdobjkind.hxx>
#include <svx/unoprov.hxx>
commit 1ad2fe68308b556bb95d1c1620a3d5e55982260e
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Tue Apr 19 15:24:08 2022 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Fri May 6 10:50:25 2022 +0200
comphelper: cleanup test_guards, add test for ValueRestorationGuard
Move each test case into its own test function. Also add the
missing test for ValueRestorationGuard.
Change-Id: I588ab67f82ba82ef67939dac3d22438e8799ce11
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133917
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <[email protected]>
diff --git a/comphelper/qa/unit/test_guards.cxx
b/comphelper/qa/unit/test_guards.cxx
index 02daffaa521b..83034a2dcc6a 100644
--- a/comphelper/qa/unit/test_guards.cxx
+++ b/comphelper/qa/unit/test_guards.cxx
@@ -10,42 +10,50 @@
#include <comphelper/flagguard.hxx>
#include <unotest/bootstrapfixturebase.hxx>
-CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, test_comphelperGuards)
+CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testScopeGuard)
{
+ // Test that comphelper::ScopeGuard executes its parameter on destruction
+
+ // initial value "true", out-of-scope ScopeGuard function executes and
changes the value to "false"
bool bFlag = true;
{
- // Test that comphelper::ScopeGuard executes its parameter on
destruction
comphelper::ScopeGuard aGuard([&bFlag] { bFlag = false; });
CPPUNIT_ASSERT(bFlag);
}
CPPUNIT_ASSERT(!bFlag);
+}
+
+CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testFlagGuard)
+{
+ // Test that comphelper::FlagGuard properly sets and resets the flag
+ // initial value "false", change to "true", out-of-scope change to "false"
+ bool bFlag = false;
{
- // Test that comphelper::FlagGuard properly sets and resets the flag
comphelper::FlagGuard aGuard(bFlag);
CPPUNIT_ASSERT(bFlag);
}
+ // comphelper::FlagGuard must reset flag to false on destruction
unconditionally
CPPUNIT_ASSERT(!bFlag);
+ // initial value "true", retain the value at "true", out-of-scope change
to "false"
bFlag = true;
{
- // Test that comphelper::FlagGuard properly sets and resets the flag
comphelper::FlagGuard aGuard(bFlag);
CPPUNIT_ASSERT(bFlag);
}
// comphelper::FlagGuard must reset flag to false on destruction
unconditionally
CPPUNIT_ASSERT(!bFlag);
+}
- {
- // Test that comphelper::FlagRestorationGuard properly sets and resets
the flag
- comphelper::FlagRestorationGuard aGuard(bFlag, true);
- CPPUNIT_ASSERT(bFlag);
- }
- CPPUNIT_ASSERT(!bFlag);
+CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testFlagRestorationGuard)
+{
+ // Test that comphelper::FlagRestorationGuard properly sets and resets the
flag
- bFlag = true;
+ // initial value "true", change to "false", out-of-scope change to "true"
+
+ bool bFlag = true;
{
- // Test that comphelper::FlagRestorationGuard properly sets and resets
the flag
comphelper::FlagRestorationGuard aGuard(bFlag, false);
CPPUNIT_ASSERT(!bFlag);
}
@@ -53,4 +61,28 @@ CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture,
test_comphelperGuards)
CPPUNIT_ASSERT(bFlag);
}
+CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testValueRestorationGuard)
+{
+ // Test that comphelper::ValueRestorationGuard properly sets and resets
the (int) value
+
+ int value = 199;
+
+ // set value and restore after scope ends
+ {
+ CPPUNIT_ASSERT_EQUAL(199, value);
+ comphelper::ValueRestorationGuard aGuard(value, 100);
+ CPPUNIT_ASSERT_EQUAL(100, value);
+ }
+ CPPUNIT_ASSERT_EQUAL(199, value);
+
+ // set value, manually setto another value and restore after scope ends
+ {
+ CPPUNIT_ASSERT_EQUAL(199, value);
+ comphelper::ValueRestorationGuard aGuard(value, 100);
+ CPPUNIT_ASSERT_EQUAL(100, value);
+ value = 200;
+ }
+ CPPUNIT_ASSERT_EQUAL(199, value);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 927561e4662ca2a04daa09914400fa72738531d3
Author: Julien Nabet <[email protected]>
AuthorDate: Fri May 6 08:44:23 2022 +0200
Commit: Julien Nabet <[email protected]>
CommitDate: Fri May 6 10:18:10 2022 +0200
Fix for callgrind TB
/home/buildslave/lode/jenkins/workspace/lo_callgrind_linux/sc/qa/perf/scperfobj.cxx:
In member function ‘void sc_apitest::ScPerfObj::testSheetFindAll()’:
/home/buildslave/lode/jenkins/workspace/lo_callgrind_linux/sc/qa/perf/scperfobj.cxx:169:51:
error: ‘makeAny’ was not declared in this scope
xSearchProp->setPropertyValue("SearchStyles", makeAny(true));
Change-Id: I484a17fb80c86694d0221670afbcba80fbe14c4f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133916
Tested-by: Jenkins
Reviewed-by: Julien Nabet <[email protected]>
diff --git a/sc/qa/perf/scperfobj.cxx b/sc/qa/perf/scperfobj.cxx
index 575327e7eab0..33ddee7e2f38 100644
--- a/sc/qa/perf/scperfobj.cxx
+++ b/sc/qa/perf/scperfobj.cxx
@@ -166,7 +166,7 @@ void ScPerfObj::testSheetFindAll()
xSearchDescr = xSearchableStyle->createSearchDescriptor();
uno::Reference< beans::XPropertySet >
xSearchProp(xSearchDescr,UNO_QUERY_THROW);
- xSearchProp->setPropertyValue("SearchStyles", makeAny(true));
+ xSearchProp->setPropertyValue("SearchStyles", Any(true));
xSearchDescr->setSearchString("aCellStyle");
commit f82644fed3e9266ab21114a2266277059cd5ccb9
Author: Justin Luth <[email protected]>
AuthorDate: Thu May 5 21:03:35 2022 +0200
Commit: Mike Kaganski <[email protected]>
CommitDate: Fri May 6 09:36:51 2022 +0200
tdf#148920 sw page-style UI: make conditional filter usable
In windows, and SAL_USE_VCLPLUGIN=gen ./instdir/program/soffice
the style filter on the conditional tab was disabled.
It worked fine in gtk3 though.
This fixes a 7.2 regression from tdf#82802's
commit 1f066313218449cac494a887eb209311efbaa405
Change-Id: I1e6bb8d589224e4ad51ae0057d5278e3888cc3b0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133910
Tested-by: Justin Luth <[email protected]>
Tested-by: Jenkins
Reviewed-by: Justin Luth <[email protected]>
diff --git a/sw/uiconfig/swriter/ui/conditionpage.ui
b/sw/uiconfig/swriter/ui/conditionpage.ui
index 64e70ce81951..47e6b414e5fb 100644
--- a/sw/uiconfig/swriter/ui/conditionpage.ui
+++ b/sw/uiconfig/swriter/ui/conditionpage.ui
@@ -219,7 +219,7 @@
<child>
<object class="GtkComboBoxText" id="filter">
<property name="visible">True</property>
- <property name="sensitive">False</property>
+ <property name="sensitive">True</property>
<property name="can-focus">False</property>
<items>
<item translatable="yes"
context="conditionpage|filter">Table Header</item>