[Libreoffice-commits] core.git: Branch 'feature/pivotcharts' - 4 commits - chart2/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Tue Mar 7 16:01:16 UTC 2017
chart2/source/controller/dialogs/dlg_CreationWizard.cxx | 61 ++++++++--------
chart2/source/controller/inc/dlg_CreationWizard.hxx | 37 ++++-----
chart2/source/model/main/ChartModel_Persistence.cxx | 8 +-
chart2/source/view/main/ChartView.cxx | 36 ++++-----
chart2/source/view/main/VLegend.cxx | 14 +--
5 files changed, 78 insertions(+), 78 deletions(-)
New commits:
commit 5ca8bce9a3df730155f53133bba65f2b1bd50134
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Tue Mar 7 16:53:27 2017 +0100
charts: add field buttons if we have the pivot table data
In ChartView (and VLegend) check if the data provider is a pivot
chart data provider and get the pivot table field names to create
the buttons on the UI.
Change-Id: I08faaa17c953f0f40180e1ac1b0cb1dc6471607e
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 12fc658..54b1297 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -113,6 +113,8 @@
#include <comphelper/classids.hxx>
#include "servicenames_charttypes.hxx"
+#include <com/sun/star/chart2/data/XPivotChartDataProvider.hpp>
+
#include <rtl/strbuf.hxx>
#include <rtl/ustring.hxx>
@@ -2489,35 +2491,29 @@ void lcl_createButtons(const uno::Reference< drawing::XShapes>& xPageShapes,
ChartModel& rModel,
awt::Rectangle& rRemainingSpace)
{
- uno::Reference<beans::XPropertySet> xModelPage(rModel.getPageBackground());
+ uno::Reference<chart2::data::XPivotChartDataProvider> xPivotChartDataProvider(rModel.getDataProvider(), uno::UNO_QUERY);
-// TODO: Get this from the PivotTable
- std::vector<OUString> aPageFields {
-// "Subdivision", "Subdivision2"
- };
- std::vector<OUString> aDataFields {
-// "Sum - Revenue", "Sum - Expenses"
- };
- std::vector<OUString> aColumnFields {
-// "Group Segment", "Group Segment 2"
- };
+ uno::Sequence<OUString> aRowFields = xPivotChartDataProvider->getRowFields();
+ uno::Sequence<OUString> aPageFields = xPivotChartDataProvider->getPageFields();
+ uno::Sequence<OUString> aDataFields = xPivotChartDataProvider->getDataFields();
+ uno::Reference<beans::XPropertySet> xModelPage(rModel.getPageBackground());
awt::Size aSize(3000, 700); // size of the button
long x = 0;
int nCIDIndex = 0;
- if (!aPageFields.empty())
+ if (aPageFields.hasElements())
{
x = 0;
nCIDIndex = 0;
- for (OUString const & aPageField : aPageFields)
+ for (OUString const & rPageField : aPageFields)
{
std::unique_ptr<VButton> pButton(new VButton);
pButton->init(xPageShapes, xShapeFactory);
awt::Point aNewPosition = awt::Point(rRemainingSpace.X + x + 100, rRemainingSpace.Y + 100);
- pButton->setLabel(aPageField);
+ pButton->setLabel(rPageField);
pButton->setCID("PageFieldButton." + OUString::number(nCIDIndex));
pButton->createShapes(aNewPosition, aSize, xModelPage);
x += aSize.Width + 100;
@@ -2527,16 +2523,16 @@ void lcl_createButtons(const uno::Reference< drawing::XShapes>& xPageShapes,
rRemainingSpace.Height -= (aSize.Height + 100 + 100);
}
- if (!aDataFields.empty())
+ if (aDataFields.hasElements())
{
x = 200;
nCIDIndex = 0;
- for (OUString const & aDataField : aDataFields)
+ for (OUString const & rDataField : aDataFields)
{
std::unique_ptr<VButton> pButton(new VButton);
pButton->init(xPageShapes, xShapeFactory);
awt::Point aNewPosition = awt::Point(rRemainingSpace.X + x + 100, rRemainingSpace.Y + 100);
- pButton->setLabel(aDataField);
+ pButton->setLabel(rDataField);
pButton->setCID("DataFieldButton." + OUString::number(nCIDIndex));
pButton->createShapes(aNewPosition, aSize, xModelPage);
x += aSize.Width + 100;
@@ -2546,17 +2542,17 @@ void lcl_createButtons(const uno::Reference< drawing::XShapes>& xPageShapes,
rRemainingSpace.Height -= (aSize.Height + 100 + 100);
}
- if (!aColumnFields.empty())
+ if (aRowFields.hasElements())
{
x = 200;
nCIDIndex = 0;
- for (OUString const & aColumnField : aColumnFields)
+ for (OUString const & rRowField : aRowFields)
{
std::unique_ptr<VButton> pButton(new VButton);
pButton->init(xPageShapes, xShapeFactory);
awt::Point aNewPosition = awt::Point(rRemainingSpace.X + x + 100,
rRemainingSpace.Y + rRemainingSpace.Height - aSize.Height - 100);
- pButton->setLabel(aColumnField);
+ pButton->setLabel(rRowField);
pButton->setCID("ColumnFieldButton." + OUString::number(nCIDIndex));
pButton->createShapes(aNewPosition, aSize, xModelPage);
x += aSize.Width + 100;
diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx
index 5cddb57..b79c95a 100644
--- a/chart2/source/view/main/VLegend.cxx
+++ b/chart2/source/view/main/VLegend.cxx
@@ -40,6 +40,8 @@
#include <rtl/ustrbuf.hxx>
#include <svl/languageoptions.hxx>
+#include <com/sun/star/chart2/data/XPivotChartDataProvider.hpp>
+
#include <vector>
#include <algorithm>
@@ -766,14 +768,12 @@ std::vector<std::shared_ptr<VButton>> lcl_createButtons(
const uno::Reference< lang::XMultiServiceFactory>& xShapeFactory,
ChartModel& rModel, long& nUsedHeight)
{
-// TODO: get this info from the Pivot Table
- std::vector<OUString> aRowFields {
-// "Service Months"
- };
+ uno::Reference<chart2::data::XPivotChartDataProvider> xPivotChartDataProvider(rModel.getDataProvider(), uno::UNO_QUERY);
+ uno::Sequence<OUString> aColumnFields = xPivotChartDataProvider->getColumnFields();
std::vector<std::shared_ptr<VButton>> aButtons;
- if (aRowFields.empty())
+ if (!aColumnFields.hasElements())
return aButtons;
uno::Reference<beans::XPropertySet> xModelPage(rModel.getPageBackground());
@@ -781,13 +781,13 @@ std::vector<std::shared_ptr<VButton>> lcl_createButtons(
int nCIDIndex = 0;
awt::Size aSize(2000, 700);
- for (OUString const & sRowField : aRowFields)
+ for (OUString const & sColumnField : aColumnFields)
{
std::shared_ptr<VButton> pButton(new VButton);
aButtons.push_back(pButton);
pButton->init(xLegendContainer, xShapeFactory);
awt::Point aNewPosition = awt::Point(100, 100);
- pButton->setLabel(sRowField);
+ pButton->setLabel(sColumnField);
pButton->setCID("RowFieldButton." + OUString::number(nCIDIndex));
pButton->createShapes(aNewPosition, aSize, xModelPage);
nCIDIndex += 1;
commit 3a5c80f1fad3be09773fe251fc9df4f4ecd9c9be
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Tue Mar 7 16:50:48 2017 +0100
charts: use isDataFromSpreadsheet check in creation wizard
Change-Id: I6f4ee2639a3102f4390c6d97491244ede67abc59
diff --git a/chart2/source/controller/dialogs/dlg_CreationWizard.cxx b/chart2/source/controller/dialogs/dlg_CreationWizard.cxx
index 07a03b0..b4beb73 100644
--- a/chart2/source/controller/dialogs/dlg_CreationWizard.cxx
+++ b/chart2/source/controller/dialogs/dlg_CreationWizard.cxx
@@ -77,10 +77,7 @@ CreationWizard::CreationWizard(vcl::Window* pParent, const uno::Reference<frame:
aSize.Width() += aAdditionalRoadmapSize.Width();
this->SetSizePixel(aSize);
- uno::Reference<chart2::XChartDocument> xChartDoc(m_xChartModel, uno::UNO_QUERY);
- bool bHasOwnData = (xChartDoc.is() && xChartDoc->hasInternalDataProvider());
-
- if(bHasOwnData)
+ if (!m_pDialogModel->getModel().isDataFromSpreadsheet())
{
enableState(STATE_SIMPLE_RANGE, false);
enableState(STATE_DATA_SERIES, false);
commit 069c1da48f42af1905f7e49a1b41581f53261aeb
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Tue Mar 7 16:48:24 2017 +0100
clean-up code in chart creation wizard
Change-Id: I990dba44d4ce3d3f0538b6038133c289980fa315
diff --git a/chart2/source/controller/dialogs/dlg_CreationWizard.cxx b/chart2/source/controller/dialogs/dlg_CreationWizard.cxx
index 501272f..07a03b0 100644
--- a/chart2/source/controller/dialogs/dlg_CreationWizard.cxx
+++ b/chart2/source/controller/dialogs/dlg_CreationWizard.cxx
@@ -33,10 +33,10 @@
#define CHART_WIZARD_PAGEWIDTH 250
#define CHART_WIZARD_PAGEHEIGHT 170
+using namespace css;
+
namespace chart
{
-using namespace ::com::sun::star;
-
#define PATH_FULL 1
#define STATE_FIRST 0
#define STATE_CHARTTYPE STATE_FIRST
@@ -45,41 +45,45 @@ using namespace ::com::sun::star;
#define STATE_OBJECTS 3
#define STATE_LAST STATE_OBJECTS
-CreationWizard::CreationWizard( vcl::Window* pParent, const uno::Reference< frame::XModel >& xChartModel
- , const uno::Reference< uno::XComponentContext >& xContext )
- : svt::RoadmapWizard( pParent )
+CreationWizard::CreationWizard(vcl::Window* pParent, const uno::Reference<frame::XModel>& xChartModel,
+ const uno::Reference<uno::XComponentContext>& xContext)
+ : svt::RoadmapWizard(pParent)
, m_xChartModel(xChartModel,uno::UNO_QUERY)
- , m_xCC( xContext )
+ , m_xComponentContext(xContext)
, m_pTemplateProvider(nullptr)
, m_nLastState(STATE_LAST)
- , m_aTimerTriggeredControllerLock( xChartModel )
- , m_bCanTravel( true )
+ , m_aTimerTriggeredControllerLock(xChartModel)
+ , m_bCanTravel(true)
{
- m_pDialogModel.reset( new DialogModel( m_xChartModel, m_xCC ));
- defaultButton( WizardButtonFlags::FINISH );
+ m_pDialogModel.reset(new DialogModel(m_xChartModel, m_xComponentContext));
+ defaultButton(WizardButtonFlags::FINISH);
this->setTitleBase(SCH_RESSTR(STR_DLG_CHART_WIZARD));
- declarePath( PATH_FULL
- , {STATE_CHARTTYPE
- , STATE_SIMPLE_RANGE
- , STATE_DATA_SERIES
- , STATE_OBJECTS}
- );
- this->SetRoadmapHelpId( HID_SCH_WIZARD_ROADMAP );
- this->SetRoadmapInteractive( true );
- Size aAdditionalRoadmapSize( LogicToPixel( Size( 85, 0 ), MapUnit::MapAppFont ) );
+ WizardPath aPath = {
+ STATE_CHARTTYPE,
+ STATE_SIMPLE_RANGE,
+ STATE_DATA_SERIES,
+ STATE_OBJECTS
+ };
+
+ declarePath(PATH_FULL, aPath);
+
+ this->SetRoadmapHelpId(HID_SCH_WIZARD_ROADMAP);
+ this->SetRoadmapInteractive(true);
+
+ Size aAdditionalRoadmapSize(LogicToPixel(Size(85, 0), MapUnit::MapAppFont));
Size aSize(LogicToPixel(Size(CHART_WIZARD_PAGEWIDTH, CHART_WIZARD_PAGEHEIGHT), MapUnit::MapAppFont));
aSize.Width() += aAdditionalRoadmapSize.Width();
- this->SetSizePixel( aSize );
+ this->SetSizePixel(aSize);
- uno::Reference< chart2::XChartDocument > xChartDoc( m_xChartModel, uno::UNO_QUERY );
+ uno::Reference<chart2::XChartDocument> xChartDoc(m_xChartModel, uno::UNO_QUERY);
bool bHasOwnData = (xChartDoc.is() && xChartDoc->hasInternalDataProvider());
- if( bHasOwnData )
+ if(bHasOwnData)
{
- this->enableState( STATE_SIMPLE_RANGE, false );
- this->enableState( STATE_DATA_SERIES, false );
+ enableState(STATE_SIMPLE_RANGE, false);
+ enableState(STATE_DATA_SERIES, false);
}
// Call ActivatePage, to create and activate the first page
@@ -117,15 +121,17 @@ VclPtr<TabPage> CreationWizard::createPage(WizardState nState)
break;
case STATE_OBJECTS:
{
- pRet = VclPtr<TitlesAndObjectsTabPage>::Create(this,m_xChartModel,m_xCC);
+ pRet = VclPtr<TitlesAndObjectsTabPage>::Create(this,m_xChartModel, m_xComponentContext);
m_aTimerTriggeredControllerLock.startTimer();
}
break;
default:
break;
}
- if(pRet)
- pRet->SetText(OUString());//remove title of pages to not get them in the wizard title
+
+ if (pRet)
+ pRet->SetText(OUString()); //remove title of pages to not get them in the wizard title
+
return pRet;
}
diff --git a/chart2/source/controller/inc/dlg_CreationWizard.hxx b/chart2/source/controller/inc/dlg_CreationWizard.hxx
index fed0190..a1fed3c 100644
--- a/chart2/source/controller/inc/dlg_CreationWizard.hxx
+++ b/chart2/source/controller/inc/dlg_CreationWizard.hxx
@@ -24,57 +24,56 @@
#include "TabPageNotifiable.hxx"
#include <com/sun/star/chart2/XChartDocument.hpp>
-#include <svtools/roadmapwizard.hxx>
#include <com/sun/star/uno/XComponentContext.hpp>
+#include <svtools/roadmapwizard.hxx>
+
#include <memory>
namespace chart
{
-class RangeChooserTabPage;
-class DataSourceTabPage;
class DialogModel;
class ChartTypeTemplateProvider;
class CreationWizard : public svt::RoadmapWizard, public TabPageNotifiable
{
public:
- CreationWizard( vcl::Window* pParent,
- const css::uno::Reference< css::frame::XModel >& xChartModel
- , const css::uno::Reference< css::uno::XComponentContext >& xContext );
+ CreationWizard(vcl::Window* pParent,
+ const css::uno::Reference<css::frame::XModel>& xChartModel,
+ const css::uno::Reference<css::uno::XComponentContext>& xContext);
CreationWizard() = delete;
virtual ~CreationWizard() override;
// TabPageNotifiable
- virtual void setInvalidPage( TabPage * pTabPage ) override;
- virtual void setValidPage( TabPage * pTabPage ) override;
+ virtual void setInvalidPage(TabPage * pTabPage) override;
+ virtual void setValidPage(TabPage * pTabPage) override;
protected:
- virtual bool leaveState( WizardState _nState ) override;
- virtual WizardState determineNextState(WizardState nCurrentState) const override;
- virtual void enterState(WizardState nState) override;
+ virtual bool leaveState( WizardState _nState ) override;
+ virtual WizardState determineNextState(WizardState nCurrentState) const override;
+ virtual void enterState(WizardState nState) override;
- virtual OUString getStateDisplayName( WizardState nState ) const override;
+ virtual OUString getStateDisplayName(WizardState nState) const override;
private:
virtual VclPtr<TabPage> createPage(WizardState nState) override;
- css::uno::Reference< css::chart2::XChartDocument > m_xChartModel;
- css::uno::Reference< css::uno::XComponentContext> m_xCC;
- ChartTypeTemplateProvider* m_pTemplateProvider;
+ css::uno::Reference<css::chart2::XChartDocument> m_xChartModel;
+ css::uno::Reference<css::uno::XComponentContext> m_xComponentContext;
+ ChartTypeTemplateProvider* m_pTemplateProvider;
std::unique_ptr<DialogModel> m_pDialogModel;
WizardState m_nLastState;
- TimerTriggeredControllerLock m_aTimerTriggeredControllerLock;
+ TimerTriggeredControllerLock m_aTimerTriggeredControllerLock;
-// RangeChooserTabPage * m_pRangeChooserTabPage;
-// DataSourceTabPage * m_pDataSourceTabPage;
- bool m_bCanTravel;
+ bool m_bCanTravel;
};
+
} //namespace chart
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit eec93edad1cf3600b41c050b729f1075e9295e30
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Tue Mar 7 16:42:24 2017 +0100
pivotcharts: Check the data provider on pivot table update
Change-Id: I8ae0756357c18c9fc0b0af64e8e3acb36e1a8564
diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx
index da7ba9c..945bd39 100644
--- a/chart2/source/model/main/ChartModel_Persistence.cxx
+++ b/chart2/source/model/main/ChartModel_Persistence.cxx
@@ -46,6 +46,8 @@
#include <com/sun/star/io/XSeekable.hpp>
#include <com/sun/star/ucb/CommandFailedException.hpp>
+#include <com/sun/star/chart2/data/XPivotChartDataProvider.hpp>
+
#include <ucbhelper/content.hxx>
#include <unotools/ucbstreamhelper.hxx>
#include <vcl/cvtgrf.hxx>
@@ -709,11 +711,11 @@ void SAL_CALL ChartModel::removeModifyListener(
// util::XModifyListener
void SAL_CALL ChartModel::modified( const lang::EventObject& rEvenObject)
{
- uno::Reference<chart2::data::XDataProvider> xDataProvider(rEvenObject.Source, uno::UNO_QUERY);
- if (xDataProvider.is())
+ uno::Reference<chart2::data::XPivotChartDataProvider> xPivotChartDataProvider(rEvenObject.Source, uno::UNO_QUERY);
+ if (xPivotChartDataProvider.is())
{
lockControllers();
- Reference<frame::XModel> xModel(this);
+ uno::Reference<chart2::data::XDataProvider> xDataProvider(xPivotChartDataProvider, uno::UNO_QUERY);
try
{
uno::Sequence<beans::PropertyValue> aArguments =
More information about the Libreoffice-commits
mailing list