tdf#130777 UI: add Hide legend entry option for pie chart

Follow-up of the following commits related to the new UNO property
DeletedLegendEntries for pie charts:

commit a96ec04a07
(tdf#130225 implement ODF export of deleted legend entries of pie
charts)

commit 86be3422cd
(tdf#129857 Chart OOXML export: fix deleted legend entries)

commit 6e847aa817
(tdf#129859 XLSX import: don't show deleted legend entries)

Change-Id: I8b13823da745dfbfbf20f1d30f742c4baf803fc3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89456
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
This commit is contained in:
Tünde Tóth 2020-02-25 13:56:52 +01:00 committed by László Németh
parent bbb9500ebf
commit 381c9c6e5d
14 changed files with 266 additions and 7 deletions

View file

@ -127,6 +127,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcontroller,\
chart2/source/controller/dialogs/tp_AxisPositions \
chart2/source/controller/dialogs/tp_ChartType \
chart2/source/controller/dialogs/tp_DataLabel \
chart2/source/controller/dialogs/tp_DataPointOption \
chart2/source/controller/dialogs/tp_DataSource \
chart2/source/controller/dialogs/tp_ErrorBars \
chart2/source/controller/dialogs/tp_LegendPosition \

View file

@ -66,6 +66,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/schart,\
chart2/uiconfig/ui/tp_AxisPositions \
chart2/uiconfig/ui/tp_ChartType \
chart2/uiconfig/ui/tp_DataLabel \
chart2/uiconfig/ui/tp_DataPointOption \
chart2/uiconfig/ui/tp_DataSource \
chart2/uiconfig/ui/tp_ErrorBars \
chart2/uiconfig/ui/tp_LegendPosition \

View file

@ -30,6 +30,7 @@
#include "tp_SeriesToAxis.hxx"
#include "tp_TitleRotation.hxx"
#include "tp_PolarOptions.hxx"
#include "tp_DataPointOption.hxx"
#include <ResId.hxx>
#include <ViewElementListProvider.hxx>
#include <ChartModelHelper.hxx>
@ -91,6 +92,7 @@ ObjectPropertiesDialogParameter::ObjectPropertiesDialogParameter( const OUString
, m_bHasNumberProperties(false)
, m_bProvidesStartingAngle(false)
, m_bProvidesMissingValueTreatments(false)
, m_bIsPieChartDataPoint(false)
, m_bHasScaleProperties(false)
, m_bCanAxisLabelsBeStaggered(false)
, m_bSupportingAxisPositioning(false)
@ -123,6 +125,7 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel
m_bHasGeometryProperties = ChartTypeHelper::isSupportingGeometryProperties( xChartType, nDimensionCount );
m_bHasAreaProperties = ChartTypeHelper::isSupportingAreaProperties( xChartType, nDimensionCount );
m_bHasSymbolProperties = ChartTypeHelper::isSupportingSymbolProperties( xChartType, nDimensionCount );
m_bIsPieChartDataPoint = bHasDataPointproperties && ChartTypeHelper::isSupportingStartingAngle( xChartType );
if( bHasSeriesProperties )
{
@ -364,6 +367,8 @@ SchAttribTabDlg::SchAttribTabDlg(weld::Window* pParent,
AddTabPage("options", SchResId(STR_PAGE_OPTIONS),SchOptionTabPage::Create);
if( m_pParameter->ProvidesStartingAngle())
AddTabPage("polaroptions", SchResId(STR_PAGE_OPTIONS), PolarOptionsTabPage::Create);
if (m_pParameter->IsPieChartDataPoint())
AddTabPage("datapointoption", SchResId(STR_PAGE_OPTIONS), DataPointOptionTabPage::Create);
if( m_pParameter->HasGeometryProperties() )
AddTabPage("layout", SchResId(STR_PAGE_LAYOUT), SchLayoutTabPage::Create);

View file

@ -0,0 +1,68 @@
/* -*- 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 .
*/
#include "tp_DataPointOption.hxx"
#include <chartview/ChartSfxItemIds.hxx>
#include <svl/eitem.hxx>
namespace chart
{
DataPointOptionTabPage::DataPointOptionTabPage(weld::Container* pPage,
weld::DialogController* pController,
const SfxItemSet& rInAttrs)
: SfxTabPage(pPage, pController, "modules/schart/ui/tp_DataPointOption.ui",
"tp_DataPointOption", &rInAttrs)
, m_xCBHideLegendEntry(m_xBuilder->weld_check_button("CB_LEGEND_ENTRY_HIDDEN"))
{
}
DataPointOptionTabPage::~DataPointOptionTabPage() {}
std::unique_ptr<SfxTabPage> DataPointOptionTabPage::Create(weld::Container* pPage,
weld::DialogController* pController,
const SfxItemSet* rOutAttrs)
{
return std::make_unique<DataPointOptionTabPage>(pPage, pController, *rOutAttrs);
}
bool DataPointOptionTabPage::FillItemSet(SfxItemSet* rOutAttrs)
{
if (m_xCBHideLegendEntry->get_visible())
rOutAttrs->Put(
SfxBoolItem(SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY, m_xCBHideLegendEntry->get_active()));
return true;
}
void DataPointOptionTabPage::Reset(const SfxItemSet* rInAttrs)
{
const SfxPoolItem* pPoolItem = nullptr;
if (rInAttrs->GetItemState(SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY, true, &pPoolItem)
== SfxItemState::SET)
{
bool bVal = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue();
m_xCBHideLegendEntry->set_active(bVal);
}
}
} //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -0,0 +1,51 @@
/* -*- 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 .
*/
#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_TP_DATAPOINTOPTION_HXX
#define INCLUDED_CHART2_SOURCE_CONTROLLER_DIALOGS_TP_DATAPOINTOPTION_HXX
#include <sfx2/tabdlg.hxx>
namespace weld
{
class CheckButton;
}
namespace chart
{
class DataPointOptionTabPage : public SfxTabPage
{
public:
DataPointOptionTabPage(weld::Container* pPage, weld::DialogController* pController,
const SfxItemSet& rInAttrs);
virtual ~DataPointOptionTabPage() override;
static std::unique_ptr<SfxTabPage>
Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rInAttrs);
virtual bool FillItemSet(SfxItemSet* rOutAttrs) override;
virtual void Reset(const SfxItemSet* rInAttrs) override;
private:
std::unique_ptr<weld::CheckButton> m_xCBHideLegendEntry;
};
} //namespace chart
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -54,7 +54,8 @@ public:
sal_Int32 nSpecialFillColor = 0,
bool bOverwriteLabelsForAttributedDataPointsAlso = false,
sal_Int32 nNumberFormat = 0,
sal_Int32 nPercentNumberFormat = 0 );
sal_Int32 nPercentNumberFormat = 0,
sal_Int32 nPointIndex = -1 );
virtual ~DataPointItemConverter() override;
@ -78,6 +79,9 @@ private:
sal_Int32 m_nPercentNumberFormat;
css::uno::Sequence<sal_Int32> m_aAvailableLabelPlacements;
bool m_bForbidPercentValue;
bool m_bHideLegendEntry;
sal_Int32 m_nPointIndex;
css::uno::Reference<css::chart2::XDataSeries> m_xSeries;
};
}}

View file

@ -48,6 +48,7 @@ public:
bool HasNumberProperties() const { return m_bHasNumberProperties;}
bool ProvidesStartingAngle() const { return m_bProvidesStartingAngle;}
bool ProvidesMissingValueTreatments() const { return m_bProvidesMissingValueTreatments;}
bool IsPieChartDataPoint() const { return m_bIsPieChartDataPoint;}
bool HasScaleProperties() const { return m_bHasScaleProperties;}
bool CanAxisLabelsBeStaggered() const { return m_bCanAxisLabelsBeStaggered;}
@ -80,6 +81,7 @@ private:
bool m_bHasNumberProperties;
bool m_bProvidesStartingAngle;
bool m_bProvidesMissingValueTreatments;
bool m_bIsPieChartDataPoint;
bool m_bHasScaleProperties;
bool m_bCanAxisLabelsBeStaggered;

View file

@ -47,6 +47,7 @@
#include <svl/ilstitem.hxx>
#include <tools/diagnose_ex.h>
#include <vcl/graph.hxx>
#include <oox/helper/containerhelper.hxx>
#include <svx/tabline.hxx>
@ -207,7 +208,8 @@ DataPointItemConverter::DataPointItemConverter(
sal_Int32 nSpecialFillColor,
bool bOverwriteLabelsForAttributedDataPointsAlso,
sal_Int32 nNumberFormat,
sal_Int32 nPercentNumberFormat ) :
sal_Int32 nPercentNumberFormat,
sal_Int32 nPointIndex ) :
ItemConverter( rPropertySet, rItemPool ),
m_bDataSeries( bDataSeries ),
m_bOverwriteLabelsForAttributedDataPointsAlso(m_bDataSeries && bOverwriteLabelsForAttributedDataPointsAlso),
@ -216,7 +218,10 @@ DataPointItemConverter::DataPointItemConverter(
m_nNumberFormat(nNumberFormat),
m_nPercentNumberFormat(nPercentNumberFormat),
m_aAvailableLabelPlacements(),
m_bForbidPercentValue(true)
m_bForbidPercentValue(true),
m_bHideLegendEntry(false),
m_nPointIndex(nPointIndex),
m_xSeries(xSeries)
{
m_aConverters.emplace_back( new GraphicPropertyItemConverter(
rPropertySet, rItemPool, rDrawModel, xNamedPropertyContainerFactory, eMapTo ));
@ -235,6 +240,21 @@ DataPointItemConverter::DataPointItemConverter(
m_aAvailableLabelPlacements = ChartTypeHelper::getSupportedLabelPlacements( xChartType, bSwapXAndY, xSeries );
m_bForbidPercentValue = ChartTypeHelper::getAxisType( xChartType, 0 ) != AxisType::CATEGORY;
if (!bDataSeries)
{
uno::Reference<beans::XPropertySet> xSeriesProp(xSeries, uno::UNO_QUERY);
uno::Sequence<sal_Int32> deletedLegendEntriesSeq;
xSeriesProp->getPropertyValue("DeletedLegendEntries") >>= deletedLegendEntriesSeq;
for (auto& deletedLegendEntry : deletedLegendEntriesSeq)
{
if (nPointIndex == deletedLegendEntry)
{
m_bHideLegendEntry = true;
break;
}
}
}
}
DataPointItemConverter::~DataPointItemConverter()
@ -539,6 +559,27 @@ bool DataPointItemConverter::ApplySpecialItem(
}
}
break;
case SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY:
{
bool bHideLegendEntry = static_cast<const SfxBoolItem &>(rItemSet.Get(nWhichId)).GetValue();
if (bHideLegendEntry != m_bHideLegendEntry)
{
uno::Sequence<sal_Int32> deletedLegendEntriesSeq;
Reference<beans::XPropertySet> xSeriesProp(m_xSeries, uno::UNO_QUERY);
xSeriesProp->getPropertyValue("DeletedLegendEntries") >>= deletedLegendEntriesSeq;
std::vector<sal_Int32> deletedLegendEntries;
for (auto& deletedLegendEntry : deletedLegendEntriesSeq)
{
if (bHideLegendEntry || m_nPointIndex != deletedLegendEntry)
deletedLegendEntries.push_back(deletedLegendEntry);
}
if (bHideLegendEntry)
deletedLegendEntries.push_back(m_nPointIndex);
xSeriesProp->setPropertyValue("DeletedLegendEntries", uno::makeAny(oox::ContainerHelper::vectorToSequence(deletedLegendEntries)));
}
}
break;
}
return bChanged;
@ -707,6 +748,13 @@ void DataPointItemConverter::FillSpecialItem(
}
}
break;
case SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY:
{
rOutItemSet.Put(SfxBoolItem(nWhichId, m_bHideLegendEntry));
break;
}
break;
}
}

View file

@ -98,7 +98,8 @@ const sal_uInt16 nDataLabelWhichPairs[] =
SCHATTR_STYLE_START,SCHATTR_STYLE_END, /* 59 - 68 sch/schattr.hxx*/ \
SCHATTR_SYMBOL_BRUSH,SCHATTR_SYMBOL_BRUSH, /* 94 sch/schattr.hxx*/ \
SCHATTR_SYMBOL_SIZE,SCHATTR_SYMBOL_SIZE, /* 97 sch/schattr.hxx*/ \
SDRATTR_3D_FIRST, SDRATTR_3D_LAST /* 1244 - 1334 svx/svddef.hxx */
SDRATTR_3D_FIRST, SDRATTR_3D_LAST, /* 1244 - 1334 svx/svddef.hxx */ \
SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY, SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY
const sal_uInt16 nDataPointWhichPairs[] =
{

View file

@ -246,7 +246,7 @@ wrapper::ItemConverter* createItemConverter(
xObjectProperties, xSeries, rDrawModel.GetItemPool(), rDrawModel,
uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ),
eMapTo, pRefSize.get(), bDataSeries, bUseSpecialFillColor, nSpecialFillColor, true,
nNumberFormat, nPercentNumberFormat );
nNumberFormat, nPercentNumberFormat, nPointIndex );
break;
}
case OBJECTTYPE_GRID:

View file

@ -264,7 +264,7 @@ OUString getCID(const css::uno::Reference<css::frame::XModel>& xModel)
#if defined DBG_UTIL && !defined NDEBUG
ObjectType eType = ObjectIdentifier::getObjectType(aCID);
assert(eType == OBJECTTYPE_DATA_SERIES);
assert(eType == OBJECTTYPE_DATA_SERIES || eType == OBJECTTYPE_DATA_POINT);
#endif
return aCID;

View file

@ -141,9 +141,10 @@ class SvxBrushItem;
#define SCHATTR_STOCK_VOLUME TypedWhichId<SfxBoolItem>(SCHATTR_AXIS_END + 2)
#define SCHATTR_STOCK_UPDOWN TypedWhichId<SfxBoolItem>(SCHATTR_AXIS_END + 3)
#define SCHATTR_SYMBOL_SIZE TypedWhichId<SvxSizeItem>(SCHATTR_AXIS_END + 4)
#define SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY TypedWhichId<SfxBoolItem>(SCHATTR_AXIS_END + 5)
// non persistent items (binary format)
#define SCHATTR_CHARTTYPE_START (SCHATTR_SYMBOL_SIZE + 1)
#define SCHATTR_CHARTTYPE_START (SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY + 1)
// new from New Chart
#define SCHATTR_BAR_OVERLAP TypedWhichId<SfxInt32Item>(SCHATTR_CHARTTYPE_START )

View file

@ -128,6 +128,7 @@ ChartItemPool::ChartItemPool():
rPoolDefaults[SCHATTR_STOCK_VOLUME - SCHATTR_START] = new SfxBoolItem(SCHATTR_STOCK_VOLUME,false);
rPoolDefaults[SCHATTR_STOCK_UPDOWN - SCHATTR_START] = new SfxBoolItem(SCHATTR_STOCK_UPDOWN,false);
rPoolDefaults[SCHATTR_SYMBOL_SIZE - SCHATTR_START] = new SvxSizeItem(SCHATTR_SYMBOL_SIZE,Size(0,0));
rPoolDefaults[SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY - SCHATTR_START] = new SfxBoolItem(SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY, false);
// new for New Chart
rPoolDefaults[SCHATTR_BAR_OVERLAP - SCHATTR_START] = new SfxInt32Item(SCHATTR_BAR_OVERLAP,0);

View file

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.4 -->
<interface domain="chart">
<requires lib="gtk+" version="3.18"/>
<object class="GtkAdjustment" id="adjustmentGAP">
<property name="upper">600</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustmentOVERLAP">
<property name="lower">-100</property>
<property name="upper">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkBox" id="tp_DataPointOption">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkFrame" id="frameLegend">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkCheckButton" id="CB_LEGEND_ENTRY_HIDDEN">
<property name="label" translatable="yes" context="tp_DataPointOption|CB_LEGEND_ENTRY_HIDDEN">Hide legend entry</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">start</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="tp_DataPointOption|label1">Legend Entry</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
</interface>