tdf#75330 add a new overlay/no-overlay feature for the legend
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 <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
This commit is contained in:
parent
d264170ebb
commit
9fab1ba8dd
16 changed files with 263 additions and 90 deletions
|
@ -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() )
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "tp_LegendPosition.hxx"
|
||||
#include <res_LegendPosition.hxx>
|
||||
#include <TextDirectionListBox.hxx>
|
||||
#include <chartview/ChartSfxItemIds.hxx>
|
||||
#include <editeng/eeitem.hxx>
|
||||
#include <editeng/frmdiritem.hxx>
|
||||
|
||||
|
@ -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<const SvxFrameDirectionItem*>(pPoolItem)->GetValue() );
|
||||
|
||||
if (rInAttrs->GetItemState(SCHATTR_LEGEND_NO_OVERLAY, true, &pPoolItem) == SfxItemState::SET)
|
||||
{
|
||||
bool bVal = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue();
|
||||
m_xCBLegendNoOverlay->set_active(bVal);
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace chart
|
||||
|
|
|
@ -34,6 +34,7 @@ private:
|
|||
|
||||
LegendPositionResources m_aLegendPositionResources;
|
||||
std::unique_ptr<TextDirectionListBox> m_xLbTextDirection;
|
||||
std::unique_ptr<weld::CheckButton> m_xCBLegendNoOverlay;
|
||||
|
||||
public:
|
||||
SchLegendPosTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs);
|
||||
|
|
|
@ -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<const SfxBoolItem *>(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<sal_Int32>(eLegendPos) ) );
|
||||
}
|
||||
break;
|
||||
case SCHATTR_LEGEND_NO_OVERLAY:
|
||||
{
|
||||
bool bOverlay = false;
|
||||
GetPropertySet()->getPropertyValue("Overlay") >>= bOverlay;
|
||||
rOutItemSet.Put(SfxBoolItem(SCHATTR_LEGEND_NO_OVERLAY, !bOverlay));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,6 +105,44 @@ void setLegendVisible(const css::uno::Reference<css::frame::XModel>& xModel, boo
|
|||
LegendHelper::hideLegend(*pModel);
|
||||
}
|
||||
|
||||
bool isLegendOverlay(const css::uno::Reference<css::frame::XModel>& 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<css::frame::XModel>& xModel, bool bOverlay)
|
||||
{
|
||||
ChartModel* pModel = getChartModel(xModel);
|
||||
if (!pModel)
|
||||
return;
|
||||
|
||||
Reference<beans::XPropertySet> xLegendProp(LegendHelper::getLegend(*pModel), uno::UNO_QUERY);
|
||||
if (!xLegendProp.is())
|
||||
return;
|
||||
|
||||
xLegendProp->setPropertyValue("Overlay", css::uno::Any(bOverlay));
|
||||
}
|
||||
|
||||
bool isTitleVisisble(const css::uno::Reference<css::frame::XModel>& xModel, TitleHelper::eTitleType eTitle)
|
||||
{
|
||||
css::uno::Reference<css::uno::XInterface> xTitle = TitleHelper::getTitle(eTitle, xModel);
|
||||
|
@ -197,13 +235,13 @@ sal_Int32 getLegendPos(const css::uno::Reference<css::frame::XModel>& 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<css::frame::XModel>& xModel)
|
|||
case chart2::LegendPosition_PAGE_END:
|
||||
return 2;
|
||||
default:
|
||||
return 4;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -230,7 +268,7 @@ void setLegendPos(const css::uno::Reference<css::frame::XModel>& 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<css::frame::XModel>& 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())
|
||||
|
|
|
@ -80,6 +80,7 @@ private:
|
|||
std::unique_ptr<weld::CheckButton> mxCB2ndYAxis;
|
||||
std::unique_ptr<weld::CheckButton> mxCB2ndYAxisTitle;
|
||||
std::unique_ptr<weld::CheckButton> mxCBLegend;
|
||||
std::unique_ptr<weld::CheckButton> mxCBLegendNoOverlay;
|
||||
std::unique_ptr<weld::CheckButton> mxCBGridVerticalMajor;
|
||||
std::unique_ptr<weld::CheckButton> mxCBGridHorizontalMajor;
|
||||
std::unique_ptr<weld::CheckButton> mxCBGridVerticalMinor;
|
||||
|
|
|
@ -52,7 +52,8 @@ class SvxBrushItem;
|
|||
#define SCHATTR_LEGEND_START (SCHATTR_DATADESCR_END + 1)
|
||||
#define SCHATTR_LEGEND_POS TypedWhichId<SfxInt32Item>(SCHATTR_LEGEND_START)
|
||||
#define SCHATTR_LEGEND_SHOW TypedWhichId<SfxBoolItem>(SCHATTR_LEGEND_START + 1)
|
||||
#define SCHATTR_LEGEND_END SCHATTR_LEGEND_SHOW
|
||||
#define SCHATTR_LEGEND_NO_OVERLAY TypedWhichId<SfxBoolItem>(SCHATTR_LEGEND_START + 2)
|
||||
#define SCHATTR_LEGEND_END SCHATTR_LEGEND_NO_OVERLAY
|
||||
|
||||
//text
|
||||
#define SCHATTR_TEXT_START (SCHATTR_LEGEND_END + 1)
|
||||
|
|
|
@ -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<bool>::get(),
|
||||
beans::PropertyAttribute::BOUND
|
||||
| beans::PropertyAttribute::MAYBEDEFAULT );
|
||||
|
||||
rOutProperties.emplace_back( "Overlay",
|
||||
PROP_LEGEND_OVERLAY,
|
||||
cppu::UnoType<bool>::get(),
|
||||
beans::PropertyAttribute::BOUND
|
||||
| beans::PropertyAttribute::MAYBEDEFAULT );
|
||||
|
||||
rOutProperties.emplace_back( "ReferencePageSize",
|
||||
PROP_LEGEND_REF_PAGE_SIZE,
|
||||
cppu::UnoType<awt::Size>::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 );
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,68 +94,96 @@
|
|||
<property name="top_padding">6</property>
|
||||
<property name="left_padding">12</property>
|
||||
<child>
|
||||
<object class="GtkGrid" id="grid5">
|
||||
<object class="GtkBox" id="box_legend2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="checkbutton_legend">
|
||||
<object class="GtkGrid" id="grid5">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="checkbutton_legend">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="tooltip_text" translatable="yes" context="sidebarelements|checkbutton_legend|tooltip_text">Show Legend</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box_legend">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="placement_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="label" translatable="yes" context="sidebarelements|placement_label">_Placement:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="ellipsize">end</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="comboboxtext_legend">
|
||||
<property name="width_request">100</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<items>
|
||||
<item translatable="yes" context="sidebarelements|comboboxtext_legend">Right</item>
|
||||
<item translatable="yes" context="sidebarelements|comboboxtext_legend">Top</item>
|
||||
<item translatable="yes" context="sidebarelements|comboboxtext_legend">Bottom</item>
|
||||
<item translatable="yes" context="sidebarelements|comboboxtext_legend">Left</item>
|
||||
</items>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="checkbutton_no_overlay">
|
||||
<property name="label" translatable="yes" context="sidebarelements|checkbutton_no_overlay">Show the legend without overlapping the chart</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="tooltip_text" translatable="yes" context="sidebarelements|checkbutton_legend|tooltip_text">Show Legend</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box_legend">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="placement_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="label" translatable="yes" context="sidebarelements|placement_label">_Placement:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="ellipsize">end</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="comboboxtext_legend">
|
||||
<property name="width_request">100</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<items>
|
||||
<item translatable="yes" context="sidebarelements|comboboxtext_legend">Right</item>
|
||||
<item translatable="yes" context="sidebarelements|comboboxtext_legend">Top</item>
|
||||
<item translatable="yes" context="sidebarelements|comboboxtext_legend">Bottom</item>
|
||||
<item translatable="yes" context="sidebarelements|comboboxtext_legend">Left</item>
|
||||
<item translatable="yes" context="sidebarelements|comboboxtext_legend">Manual</item>
|
||||
</items>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
|
|
|
@ -174,5 +174,60 @@
|
|||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame" id="frameOVERLAY">
|
||||
<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" id="alignment3">
|
||||
<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" id="box2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="CB_NO_OVERLAY">
|
||||
<property name="label" translatable="yes" context="tp_LegendPosition|CB_NO_OVERLAY">Show the legend without overlapping the chart</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</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="TXT_OVERLAY">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes" context="tp_LegendPosition|TXT_OVERLAY">Overlay</property>
|
||||
<property name="xalign">0</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">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
|
|
@ -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).
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue