From 9fab1ba8ddc59924c633aa17c65f7330a4762726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=BCnde=20T=C3=B3th?= Date: Mon, 2 Mar 2020 08:56:11 +0100 Subject: [PATCH] tdf#75330 add a new overlay/no-overlay feature for the legend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement "Show the legend without overlapping the chart" option for chart legend. Change-Id: Ifbba4c81136e13995d276434dc17a97b0675428c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89810 Tested-by: Jenkins Tested-by: László Németh Reviewed-by: László Németh --- .../controller/dialogs/res_LegendPosition.cxx | 7 +- .../controller/dialogs/tp_LegendPosition.cxx | 11 ++ .../controller/dialogs/tp_LegendPosition.hxx | 1 + .../itemsetwrapper/LegendItemConverter.cxx | 24 ++++ .../controller/sidebar/ChartElementsPanel.cxx | 69 +++++++-- .../controller/sidebar/ChartElementsPanel.hxx | 1 + .../source/inc/chartview/ChartSfxItemIds.hxx | 3 +- chart2/source/model/main/Legend.cxx | 9 ++ chart2/source/view/main/ChartItemPool.cxx | 1 + chart2/source/view/main/VLegend.cxx | 23 +-- chart2/uiconfig/ui/sidebarelements.ui | 132 +++++++++++------- chart2/uiconfig/ui/tp_LegendPosition.ui | 55 ++++++++ offapi/com/sun/star/chart2/Legend.idl | 6 + oox/source/drawingml/chart/titleconverter.cxx | 5 +- sc/source/filter/excel/xechart.cxx | 2 +- sc/source/filter/excel/xichart.cxx | 4 +- 16 files changed, 263 insertions(+), 90 deletions(-) diff --git a/chart2/source/controller/dialogs/res_LegendPosition.cxx b/chart2/source/controller/dialogs/res_LegendPosition.cxx index 494538ab4ede..50ac0602baef 100644 --- a/chart2/source/controller/dialogs/res_LegendPosition.cxx +++ b/chart2/source/controller/dialogs/res_LegendPosition.cxx @@ -95,16 +95,13 @@ void LegendPositionResources::writeToResources( const uno::Reference< frame::XMo case chart2::LegendPosition_LINE_START: m_xRbtLeft->set_active(true); break; - case chart2::LegendPosition_LINE_END: - m_xRbtRight->set_active(true); - break; case chart2::LegendPosition_PAGE_START: m_xRbtTop->set_active(true); break; case chart2::LegendPosition_PAGE_END: m_xRbtBottom->set_active(true); break; - case chart2::LegendPosition_CUSTOM: + case chart2::LegendPosition_LINE_END: default: m_xRbtRight->set_active(true); break; @@ -207,7 +204,7 @@ void LegendPositionResources::initFromItemSet( const SfxItemSet& rInAttrs ) void LegendPositionResources::writeToItemSet( SfxItemSet& rOutAttrs ) const { - chart2::LegendPosition nLegendPosition = chart2::LegendPosition_CUSTOM; + chart2::LegendPosition nLegendPosition = chart2::LegendPosition_LINE_END; if( m_xRbtLeft->get_active() ) nLegendPosition = chart2::LegendPosition_LINE_START; else if( m_xRbtTop->get_active() ) diff --git a/chart2/source/controller/dialogs/tp_LegendPosition.cxx b/chart2/source/controller/dialogs/tp_LegendPosition.cxx index 87275ce999ce..04697e75efc9 100644 --- a/chart2/source/controller/dialogs/tp_LegendPosition.cxx +++ b/chart2/source/controller/dialogs/tp_LegendPosition.cxx @@ -20,6 +20,7 @@ #include "tp_LegendPosition.hxx" #include #include +#include #include #include @@ -30,6 +31,7 @@ SchLegendPosTabPage::SchLegendPosTabPage(weld::Container* pPage, weld::DialogCon : SfxTabPage(pPage, pController, "modules/schart/ui/tp_LegendPosition.ui", "tp_LegendPosition", &rInAttrs) , m_aLegendPositionResources(*m_xBuilder) , m_xLbTextDirection(new TextDirectionListBox(m_xBuilder->weld_combo_box("LB_LEGEND_TEXTDIR"))) + , m_xCBLegendNoOverlay(m_xBuilder->weld_check_button("CB_NO_OVERLAY")) { } @@ -50,6 +52,9 @@ bool SchLegendPosTabPage::FillItemSet(SfxItemSet* rOutAttrs) if (m_xLbTextDirection->get_active() != -1) rOutAttrs->Put(SvxFrameDirectionItem(m_xLbTextDirection->get_active_id(), EE_PARA_WRITINGDIR)); + if (m_xCBLegendNoOverlay->get_visible()) + rOutAttrs->Put(SfxBoolItem(SCHATTR_LEGEND_NO_OVERLAY, m_xCBLegendNoOverlay->get_active())); + return true; } @@ -60,6 +65,12 @@ void SchLegendPosTabPage::Reset(const SfxItemSet* rInAttrs) const SfxPoolItem* pPoolItem = nullptr; if( rInAttrs->GetItemState( EE_PARA_WRITINGDIR, true, &pPoolItem ) == SfxItemState::SET ) m_xLbTextDirection->set_active_id( static_cast(pPoolItem)->GetValue() ); + + if (rInAttrs->GetItemState(SCHATTR_LEGEND_NO_OVERLAY, true, &pPoolItem) == SfxItemState::SET) + { + bool bVal = static_cast(pPoolItem)->GetValue(); + m_xCBLegendNoOverlay->set_active(bVal); + } } } //namespace chart diff --git a/chart2/source/controller/dialogs/tp_LegendPosition.hxx b/chart2/source/controller/dialogs/tp_LegendPosition.hxx index 178c91ddf717..61e4c8929786 100644 --- a/chart2/source/controller/dialogs/tp_LegendPosition.hxx +++ b/chart2/source/controller/dialogs/tp_LegendPosition.hxx @@ -34,6 +34,7 @@ private: LegendPositionResources m_aLegendPositionResources; std::unique_ptr m_xLbTextDirection; + std::unique_ptr m_xCBLegendNoOverlay; public: SchLegendPosTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs); diff --git a/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx index e767b40b15a7..9ae14be68a21 100644 --- a/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx @@ -152,6 +152,23 @@ bool LegendItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSe } } break; + case SCHATTR_LEGEND_NO_OVERLAY: + { + const SfxPoolItem* pPoolItem = nullptr; + if(rInItemSet.GetItemState(SCHATTR_LEGEND_NO_OVERLAY, true, &pPoolItem) == SfxItemState::SET) + { + bool bOverlay = !static_cast(pPoolItem)->GetValue(); + bool bOldOverlay = false; + if(!(GetPropertySet()->getPropertyValue("Overlay") >>= bOldOverlay) || + (bOldOverlay != bOverlay)) + { + GetPropertySet()->setPropertyValue("Overlay", uno::Any(bOverlay)); + bChanged = true; + } + } + + } + break; } return bChanged; @@ -176,6 +193,13 @@ void LegendItemConverter::FillSpecialItem( rOutItemSet.Put( SfxInt32Item(SCHATTR_LEGEND_POS, static_cast(eLegendPos) ) ); } break; + case SCHATTR_LEGEND_NO_OVERLAY: + { + bool bOverlay = false; + GetPropertySet()->getPropertyValue("Overlay") >>= bOverlay; + rOutItemSet.Put(SfxBoolItem(SCHATTR_LEGEND_NO_OVERLAY, !bOverlay)); + } + break; } } diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.cxx b/chart2/source/controller/sidebar/ChartElementsPanel.cxx index 28c86f4a8926..63df9483b8c8 100644 --- a/chart2/source/controller/sidebar/ChartElementsPanel.cxx +++ b/chart2/source/controller/sidebar/ChartElementsPanel.cxx @@ -105,6 +105,44 @@ void setLegendVisible(const css::uno::Reference& xModel, boo LegendHelper::hideLegend(*pModel); } +bool isLegendOverlay(const css::uno::Reference& xModel) +{ + ChartModel* pModel = getChartModel(xModel); + if (!pModel) + return false; + + Reference< beans::XPropertySet > xLegendProp(LegendHelper::getLegend(*pModel), uno::UNO_QUERY); + if( xLegendProp.is()) + { + try + { + bool bOverlay = false; + if(xLegendProp->getPropertyValue("Overlay") >>= bOverlay) + { + return bOverlay; + } + } + catch(const uno::Exception &) + { + } + } + + return false; +} + +void setLegendOverlay(const css::uno::Reference& xModel, bool bOverlay) +{ + ChartModel* pModel = getChartModel(xModel); + if (!pModel) + return; + + Reference xLegendProp(LegendHelper::getLegend(*pModel), uno::UNO_QUERY); + if (!xLegendProp.is()) + return; + + xLegendProp->setPropertyValue("Overlay", css::uno::Any(bOverlay)); +} + bool isTitleVisisble(const css::uno::Reference& xModel, TitleHelper::eTitleType eTitle) { css::uno::Reference xTitle = TitleHelper::getTitle(eTitle, xModel); @@ -197,13 +235,13 @@ sal_Int32 getLegendPos(const css::uno::Reference& xModel) { ChartModel* pModel = getChartModel(xModel); if (!pModel) - return 4; + return -1; Reference< beans::XPropertySet > xLegendProp( LegendHelper::getLegend(*pModel), uno::UNO_QUERY ); if (!xLegendProp.is()) - return 4; + return -1; - chart2::LegendPosition eLegendPos = chart2::LegendPosition_CUSTOM; + chart2::LegendPosition eLegendPos = chart2::LegendPosition_LINE_END; xLegendProp->getPropertyValue("AnchorPosition") >>= eLegendPos; switch(eLegendPos) { @@ -216,7 +254,7 @@ sal_Int32 getLegendPos(const css::uno::Reference& xModel) case chart2::LegendPosition_PAGE_END: return 2; default: - return 4; + return -1; } } @@ -230,7 +268,7 @@ void setLegendPos(const css::uno::Reference& xModel, sal_Int if (!xLegendProp.is()) return; - chart2::LegendPosition eLegendPos = chart2::LegendPosition_CUSTOM; + chart2::LegendPosition eLegendPos = chart2::LegendPosition_LINE_END; css::chart::ChartLegendExpansion eExpansion = css::chart::ChartLegendExpansion_HIGH; switch(nPos) { @@ -248,20 +286,13 @@ void setLegendPos(const css::uno::Reference& xModel, sal_Int eLegendPos = chart2::LegendPosition_PAGE_END; eExpansion = css::chart::ChartLegendExpansion_WIDE; break; - case 4: - eLegendPos = chart2::LegendPosition_CUSTOM; - break; default: assert(false); } xLegendProp->setPropertyValue("AnchorPosition", css::uno::Any(eLegendPos)); xLegendProp->setPropertyValue("Expansion", css::uno::Any(eExpansion)); - - if (eLegendPos != chart2::LegendPosition_CUSTOM) - { - xLegendProp->setPropertyValue("RelativePosition", uno::Any()); - } + xLegendProp->setPropertyValue("RelativePosition", uno::Any()); } } @@ -283,6 +314,7 @@ ChartElementsPanel::ChartElementsPanel( , mxCB2ndYAxis(m_xBuilder->weld_check_button("checkbutton_2nd_y_axis")) , mxCB2ndYAxisTitle(m_xBuilder->weld_check_button("checkbutton_2nd_y_axis_title")) , mxCBLegend(m_xBuilder->weld_check_button("checkbutton_legend")) + , mxCBLegendNoOverlay(m_xBuilder->weld_check_button("checkbutton_no_overlay")) , mxCBGridVerticalMajor(m_xBuilder->weld_check_button("checkbutton_gridline_vertical_major")) , mxCBGridHorizontalMajor(m_xBuilder->weld_check_button("checkbutton_gridline_horizontal_major")) , mxCBGridVerticalMinor(m_xBuilder->weld_check_button("checkbutton_gridline_vertical_minor")) @@ -326,6 +358,7 @@ void ChartElementsPanel::dispose() mxCB2ndYAxis.reset(); mxCB2ndYAxisTitle.reset(); mxCBLegend.reset(); + mxCBLegendNoOverlay.reset(); mxCBGridVerticalMajor.reset(); mxCBGridHorizontalMajor.reset(); mxCBGridVerticalMinor.reset(); @@ -363,6 +396,7 @@ void ChartElementsPanel::Initialize() mxCB2ndYAxis->connect_toggled(aLink); mxCB2ndYAxisTitle->connect_toggled(aLink); mxCBLegend->connect_toggled(aLink); + mxCBLegendNoOverlay->connect_toggled(aLink); mxCBGridVerticalMajor->connect_toggled(aLink); mxCBGridHorizontalMajor->connect_toggled(aLink); mxCBGridVerticalMinor->connect_toggled(aLink); @@ -410,7 +444,9 @@ void ChartElementsPanel::updateData() SolarMutexGuard aGuard; mxCBLegend->set_active(isLegendVisible(mxModel)); - mxBoxLegend->set_sensitive( isLegendVisible(mxModel) ); + mxCBLegendNoOverlay->set_sensitive(isLegendVisible(mxModel)); + mxCBLegendNoOverlay->set_active(!isLegendOverlay(mxModel)); + mxBoxLegend->set_sensitive(isLegendVisible(mxModel)); mxCBTitle->set_active(isTitleVisisble(mxModel, TitleHelper::MAIN_TITLE)); mxCBSubtitle->set_active(isTitleVisisble(mxModel, TitleHelper::SUB_TITLE)); mxCBXAxisTitle->set_active(isTitleVisisble(mxModel, TitleHelper::X_AXIS_TITLE)); @@ -558,9 +594,12 @@ IMPL_LINK(ChartElementsPanel, CheckBoxHdl, weld::ToggleButton&, rCheckBox, void) setTitleVisible(TitleHelper::SECONDARY_Y_AXIS_TITLE, bChecked); else if (&rCheckBox == mxCBLegend.get()) { - mxBoxLegend->set_sensitive( bChecked ); + mxBoxLegend->set_sensitive(bChecked); + mxCBLegendNoOverlay->set_sensitive(bChecked); setLegendVisible(mxModel, bChecked); } + else if (&rCheckBox == mxCBLegendNoOverlay.get()) + setLegendOverlay(mxModel, !bChecked); else if (&rCheckBox == mxCBGridVerticalMajor.get()) setGridVisible(mxModel, GridType::VERT_MAJOR, bChecked); else if (&rCheckBox == mxCBGridHorizontalMajor.get()) diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.hxx b/chart2/source/controller/sidebar/ChartElementsPanel.hxx index 9c145f5b078a..9671fc75334e 100644 --- a/chart2/source/controller/sidebar/ChartElementsPanel.hxx +++ b/chart2/source/controller/sidebar/ChartElementsPanel.hxx @@ -80,6 +80,7 @@ private: std::unique_ptr mxCB2ndYAxis; std::unique_ptr mxCB2ndYAxisTitle; std::unique_ptr mxCBLegend; + std::unique_ptr mxCBLegendNoOverlay; std::unique_ptr mxCBGridVerticalMajor; std::unique_ptr mxCBGridHorizontalMajor; std::unique_ptr mxCBGridVerticalMinor; diff --git a/chart2/source/inc/chartview/ChartSfxItemIds.hxx b/chart2/source/inc/chartview/ChartSfxItemIds.hxx index 8b1e4064639c..82e3f0a535f4 100644 --- a/chart2/source/inc/chartview/ChartSfxItemIds.hxx +++ b/chart2/source/inc/chartview/ChartSfxItemIds.hxx @@ -52,7 +52,8 @@ class SvxBrushItem; #define SCHATTR_LEGEND_START (SCHATTR_DATADESCR_END + 1) #define SCHATTR_LEGEND_POS TypedWhichId(SCHATTR_LEGEND_START) #define SCHATTR_LEGEND_SHOW TypedWhichId(SCHATTR_LEGEND_START + 1) -#define SCHATTR_LEGEND_END SCHATTR_LEGEND_SHOW +#define SCHATTR_LEGEND_NO_OVERLAY TypedWhichId(SCHATTR_LEGEND_START + 2) +#define SCHATTR_LEGEND_END SCHATTR_LEGEND_NO_OVERLAY //text #define SCHATTR_TEXT_START (SCHATTR_LEGEND_END + 1) diff --git a/chart2/source/model/main/Legend.cxx b/chart2/source/model/main/Legend.cxx index 6381d232e31d..4c3b9f0e5167 100644 --- a/chart2/source/model/main/Legend.cxx +++ b/chart2/source/model/main/Legend.cxx @@ -53,6 +53,7 @@ enum PROP_LEGEND_ANCHOR_POSITION, PROP_LEGEND_EXPANSION, PROP_LEGEND_SHOW, + PROP_LEGEND_OVERLAY, PROP_LEGEND_REF_PAGE_SIZE, PROP_LEGEND_REL_POS, PROP_LEGEND_REL_SIZE @@ -78,6 +79,13 @@ void lcl_AddPropertiesToVector( cppu::UnoType::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT ); + + rOutProperties.emplace_back( "Overlay", + PROP_LEGEND_OVERLAY, + cppu::UnoType::get(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT ); + rOutProperties.emplace_back( "ReferencePageSize", PROP_LEGEND_REF_PAGE_SIZE, cppu::UnoType::get(), @@ -116,6 +124,7 @@ private: ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_ANCHOR_POSITION, chart2::LegendPosition_LINE_END ); ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_EXPANSION, css::chart::ChartLegendExpansion_HIGH ); ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_SHOW, true ); + ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_OVERLAY, false ); float fDefaultCharHeight = 10.0; ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight ); diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx index 9b1f66df5bb1..8ca22b635d23 100644 --- a/chart2/source/view/main/ChartItemPool.cxx +++ b/chart2/source/view/main/ChartItemPool.cxx @@ -58,6 +58,7 @@ ChartItemPool::ChartItemPool(): //legend rPoolDefaults[SCHATTR_LEGEND_POS - SCHATTR_START] = new SfxInt32Item(SCHATTR_LEGEND_POS, sal_Int32(css::chart2::LegendPosition_LINE_END) ); rPoolDefaults[SCHATTR_LEGEND_SHOW - SCHATTR_START] = new SfxBoolItem(SCHATTR_LEGEND_SHOW, true); + rPoolDefaults[SCHATTR_LEGEND_NO_OVERLAY - SCHATTR_START] = new SfxBoolItem(SCHATTR_LEGEND_NO_OVERLAY, true); //text rPoolDefaults[SCHATTR_TEXT_DEGREES - SCHATTR_START] = new SfxInt32Item(SCHATTR_TEXT_DEGREES, 0); diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx index 54958c11281e..919dc57ddbf3 100644 --- a/chart2/source/view/main/VLegend.cxx +++ b/chart2/source/view/main/VLegend.cxx @@ -664,10 +664,8 @@ chart2::RelativePosition lcl_getDefaultPosition( LegendPosition ePos, const awt: 0.5, 1.0 - fDistance, drawing::Alignment_BOTTOM ); } break; - - case LegendPosition_CUSTOM: - // to avoid warning case LegendPosition::LegendPosition_MAKE_FIXED_SIZE: + default: // nothing to be set break; } @@ -684,7 +682,8 @@ awt::Point lcl_calculatePositionAndRemainingSpace( const awt::Size & rPageSize, const chart2::RelativePosition& rRelPos, LegendPosition ePos, - const awt::Size& aLegendSize ) + const awt::Size& aLegendSize, + bool bOverlay ) { // calculate position awt::Point aResult( @@ -698,7 +697,7 @@ awt::Point lcl_calculatePositionAndRemainingSpace( // #i109336# Improve auto positioning in chart sal_Int32 nXDistance = lcl_getLegendLeftRightMargin(); sal_Int32 nYDistance = lcl_getLegendTopBottomMargin(); - switch( ePos ) + if (!bOverlay) switch( ePos ) { case LegendPosition_LINE_START: { @@ -899,7 +898,7 @@ void VLegend::createShapes( awt::Size aLegendSize( rAvailableSpace ); bool bCustom = false; - LegendPosition eLegendPosition = LegendPosition_CUSTOM; + LegendPosition eLegendPosition = LegendPosition_LINE_END; if (xLegendProp.is()) { // get Expansion property @@ -1027,16 +1026,18 @@ void VLegend::changePosition( bool bAutoPosition = ! (xLegendProp->getPropertyValue( "RelativePosition") >>= aRelativePosition); - LegendPosition ePos = LegendPosition_CUSTOM; + LegendPosition ePos = LegendPosition_LINE_END; xLegendProp->getPropertyValue( "AnchorPosition") >>= ePos; + bool bOverlay = false; + xLegendProp->getPropertyValue("Overlay") >>= bOverlay; //calculate position if( bAutoPosition ) { // auto position: relative to remaining space aRelativePosition = lcl_getDefaultPosition( ePos, rOutAvailableSpace, rPageSize ); awt::Point aPos = lcl_calculatePositionAndRemainingSpace( - rOutAvailableSpace, rPageSize, aRelativePosition, ePos, aLegendSize ); + rOutAvailableSpace, rPageSize, aRelativePosition, ePos, aLegendSize, bOverlay ); m_xShape->setPosition( aPos ); } else @@ -1044,15 +1045,15 @@ void VLegend::changePosition( // manual position: relative to whole page awt::Rectangle aAvailableSpace( 0, 0, rPageSize.Width, rPageSize.Height ); awt::Point aPos = lcl_calculatePositionAndRemainingSpace( - aAvailableSpace, rPageSize, aRelativePosition, ePos, aLegendSize ); + aAvailableSpace, rPageSize, aRelativePosition, ePos, aLegendSize, bOverlay ); m_xShape->setPosition( aPos ); - if( ePos != LegendPosition_CUSTOM ) + if (!bOverlay) { // calculate remaining space as if having autoposition: aRelativePosition = lcl_getDefaultPosition( ePos, rOutAvailableSpace, rPageSize ); lcl_calculatePositionAndRemainingSpace( - rOutAvailableSpace, rPageSize, aRelativePosition, ePos, aLegendSize ); + rOutAvailableSpace, rPageSize, aRelativePosition, ePos, aLegendSize, bOverlay ); } } } diff --git a/chart2/uiconfig/ui/sidebarelements.ui b/chart2/uiconfig/ui/sidebarelements.ui index 75b25d41ba6d..22b1ff60c87e 100644 --- a/chart2/uiconfig/ui/sidebarelements.ui +++ b/chart2/uiconfig/ui/sidebarelements.ui @@ -94,68 +94,96 @@ 6 12 - + True False + vertical + 6 - + True - True + False + + + True + True + False + Show Legend + 5 + True + 0 + True + + + 0 + 0 + + + + + True + False + 6 + + + True + False + end + _Placement: + True + end + + + False + True + 0 + + + + + 100 + True + False + + Right + Top + Bottom + Left + + + + False + True + 3 + + + + + 1 + 0 + + + + + False + True + 0 + + + + + Show the legend without overlapping the chart + True + False False - Show Legend - 5 True 0 True - 0 - 0 - - - - - True - False - 6 - - - True - False - end - _Placement: - True - end - - - False - True - 0 - - - - - 100 - True - False - - Right - Top - Bottom - Left - Manual - - - - False - True - 3 - - - - - 1 - 0 + False + True + 1 diff --git a/chart2/uiconfig/ui/tp_LegendPosition.ui b/chart2/uiconfig/ui/tp_LegendPosition.ui index 5ea8d662fbf6..993c040962f3 100644 --- a/chart2/uiconfig/ui/tp_LegendPosition.ui +++ b/chart2/uiconfig/ui/tp_LegendPosition.ui @@ -174,5 +174,60 @@ 1 + + + True + False + 0 + none + + + True + False + 6 + 12 + + + True + False + 12 + + + Show the legend without overlapping the chart + True + False + False + True + 0 + True + + + False + True + 0 + + + + + + + + + True + False + Overlay + 0 + + + + + + + + False + True + 2 + + diff --git a/offapi/com/sun/star/chart2/Legend.idl b/offapi/com/sun/star/chart2/Legend.idl index aad5606a9c02..805e90da6a60 100644 --- a/offapi/com/sun/star/chart2/Legend.idl +++ b/offapi/com/sun/star/chart2/Legend.idl @@ -67,6 +67,12 @@ service Legend */ [property] boolean Show; + /** Determines, whether the legend should overlay the chart. + + @since LibreOffice 7.0 + */ + [property] boolean Overlay; + /** contains the size of the page at the time when properties were set (e.g. the CharHeight). diff --git a/oox/source/drawingml/chart/titleconverter.cxx b/oox/source/drawingml/chart/titleconverter.cxx index a6623aa1ed49..c0de3919571e 100644 --- a/oox/source/drawingml/chart/titleconverter.cxx +++ b/oox/source/drawingml/chart/titleconverter.cxx @@ -201,7 +201,7 @@ void LegendConverter::convertFromModel( const Reference< XDiagram >& rxDiagram ) getFormatter().convertFormatting( aPropSet, mrModel.mxShapeProp, mrModel.mxTextProp, OBJECTTYPE_LEGEND ); // predefined legend position and expansion - cssc2::LegendPosition eLegendPos = cssc2::LegendPosition_CUSTOM; + cssc2::LegendPosition eLegendPos = cssc2::LegendPosition_LINE_END; cssc::ChartLegendExpansion eLegendExpand = cssc::ChartLegendExpansion_CUSTOM; RelativePosition eRelPos; bool bTopRight=false; @@ -216,7 +216,6 @@ void LegendConverter::convertFromModel( const Reference< XDiagram >& rxDiagram ) eLegendExpand = cssc::ChartLegendExpansion_HIGH; break; case XML_tr: // top-right not supported - eLegendPos = LegendPosition_CUSTOM; eRelPos.Primary = 1; eRelPos.Secondary =0; eRelPos.Anchor = Alignment_TOP_RIGHT; @@ -248,7 +247,7 @@ void LegendConverter::convertFromModel( const Reference< XDiagram >& rxDiagram ) aPropSet.setProperty( PROP_AnchorPosition, eLegendPos ); aPropSet.setProperty( PROP_Expansion, eLegendExpand ); - if(eLegendPos == LegendPosition_CUSTOM && bTopRight && !bManualLayout) + if (bTopRight && !bManualLayout) aPropSet.setProperty( PROP_RelativePosition , makeAny(eRelPos)); if (mrModel.maLegendEntries.size() > 0) legendEntriesFormatting(rxDiagram); diff --git a/sc/source/filter/excel/xechart.cxx b/sc/source/filter/excel/xechart.cxx index 9c801579b728..c3cc1b38190e 100644 --- a/sc/source/filter/excel/xechart.cxx +++ b/sc/source/filter/excel/xechart.cxx @@ -2324,7 +2324,7 @@ void XclExpChLegend::Convert( const ScfPropertySet& rPropSet ) } else { - cssc2::LegendPosition eApiPos = cssc2::LegendPosition_CUSTOM; + cssc2::LegendPosition eApiPos = cssc2::LegendPosition_LINE_END; rPropSet.GetProperty( eApiPos, EXC_CHPROP_ANCHORPOSITION ); switch( eApiPos ) { diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx index e8c1af46abc3..fa5e5a25834d 100644 --- a/sc/source/filter/excel/xichart.cxx +++ b/sc/source/filter/excel/xichart.cxx @@ -2562,7 +2562,7 @@ Reference< XLegend > XclImpChLegend::CreateLegend() const plot area is positioned automatically (Excel sets the plot area to manual mode, if the legend is moved or resized). With manual plot areas, Excel ignores the value in maData.mnDockMode completely. */ - cssc2::LegendPosition eApiPos = cssc2::LegendPosition_CUSTOM; + cssc2::LegendPosition eApiPos = cssc2::LegendPosition_LINE_END; cssc::ChartLegendExpansion eApiExpand = cssc::ChartLegendExpansion_CUSTOM; if( !GetChartData().IsManualPlotArea() ) switch( maData.mnDockMode ) { @@ -2587,7 +2587,7 @@ Reference< XLegend > XclImpChLegend::CreateLegend() const } // no automatic position/size: try to find the correct position and size - if( eApiPos == cssc2::LegendPosition_CUSTOM ) + if( GetChartData().IsManualPlotArea() || maData.mnDockMode == EXC_CHLEGEND_NOTDOCKED ) { const XclChFramePos* pFramePos = mxFramePos ? &mxFramePos->GetFramePosData() : nullptr;