diff options
author | Tünde Tóth <tundeth@gmail.com> | 2020-05-06 14:08:37 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-05-13 13:02:01 +0200 |
commit | 8027cc622f8bd5260a59c360db359557cd287100 (patch) | |
tree | 7ae8b47f36abedae61d67ac595040a6fe0061a51 | |
parent | ef1b75a60466dda61a9d28b03262f6db357142a5 (diff) |
tdf#132757 UI: option to set Position Axis property of charts
Follow-up of commit 40d83914d43f60a196dfabddea0b52e2046b333a
(tdf#127792 implement UNO chart attribute MajorOrigin).
Change-Id: I68c35a4552a3915c045036d1f0f38804a00b7093
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93566
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r-- | chart2/source/controller/dialogs/dlg_ObjectProperties.cxx | 44 | ||||
-rw-r--r-- | chart2/source/controller/dialogs/tp_AxisPositions.cxx | 24 | ||||
-rw-r--r-- | chart2/source/controller/dialogs/tp_AxisPositions.hxx | 6 | ||||
-rw-r--r-- | chart2/source/controller/inc/dlg_ObjectProperties.hxx | 2 | ||||
-rw-r--r-- | chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx | 16 | ||||
-rw-r--r-- | chart2/source/inc/ChartTypeHelper.hxx | 1 | ||||
-rw-r--r-- | chart2/source/inc/chartview/ChartSfxItemIds.hxx | 5 | ||||
-rw-r--r-- | chart2/source/tools/ChartTypeHelper.cxx | 16 | ||||
-rw-r--r-- | chart2/source/view/main/ChartItemPool.cxx | 1 | ||||
-rw-r--r-- | chart2/uiconfig/ui/tp_AxisPositions.ui | 76 |
10 files changed, 166 insertions, 25 deletions
diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx index f0ad64bb2526..57375c33bfee 100644 --- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx @@ -98,6 +98,7 @@ ObjectPropertiesDialogParameter::ObjectPropertiesDialogParameter( const OUString , m_bSupportingAxisPositioning(false) , m_bShowAxisOrigin(false) , m_bIsCrossingAxisIsCategoryAxis(false) + , m_bSupportingCategoryPositioning(false) , m_aCategories() , m_bComplexCategoriesAxis( false ) , m_nNbPoints( 0 ) @@ -162,20 +163,6 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel if( aData.AxisType != chart2::AxisType::SERIES ) m_bHasNumberProperties = true; - sal_Int32 nCooSysIndex=0; - sal_Int32 nDimensionIndex=0; - sal_Int32 nAxisIndex=0; - if( AxisHelper::getIndicesForAxis( xAxis, xDiagram, nCooSysIndex, nDimensionIndex, nAxisIndex ) ) - { - xChartType = AxisHelper::getFirstChartTypeWithSeriesAttachedToAxisIndex( xDiagram, nAxisIndex ); - //show positioning controls only if they make sense - m_bSupportingAxisPositioning = ChartTypeHelper::isSupportingAxisPositioning( xChartType, nDimensionCount, nDimensionIndex ); - - //show axis origin only for secondary y axis - if( nDimensionIndex==1 && nAxisIndex==1 && ChartTypeHelper::isSupportingBaseValue( xChartType ) ) - m_bShowAxisOrigin = true; - } - //is the crossing main axis a category axes?: uno::Reference< XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( xAxis, xDiagram ) ); uno::Reference< XAxis > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( xAxis, xCooSys ) ); @@ -191,14 +178,30 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel } } - m_bComplexCategoriesAxis = false; - if ( nDimensionIndex == 0 && aData.AxisType == chart2::AxisType::CATEGORY ) + sal_Int32 nCooSysIndex=0; + sal_Int32 nDimensionIndex=0; + sal_Int32 nAxisIndex=0; + if( AxisHelper::getIndicesForAxis( xAxis, xDiagram, nCooSysIndex, nDimensionIndex, nAxisIndex ) ) { - ChartModel* pModel = dynamic_cast<ChartModel*>(xChartModel.get()); - if (pModel) + xChartType = AxisHelper::getFirstChartTypeWithSeriesAttachedToAxisIndex( xDiagram, nAxisIndex ); + //show positioning controls only if they make sense + m_bSupportingAxisPositioning = ChartTypeHelper::isSupportingAxisPositioning( xChartType, nDimensionCount, nDimensionIndex ); + + //show axis origin only for secondary y axis + if( nDimensionIndex==1 && nAxisIndex==1 && ChartTypeHelper::isSupportingBaseValue( xChartType ) ) + m_bShowAxisOrigin = true; + + if ( nDimensionIndex == 0 && aData.AxisType == chart2::AxisType::CATEGORY ) { - ExplicitCategoriesProvider aExplicitCategoriesProvider( xCooSys, *pModel ); - m_bComplexCategoriesAxis = aExplicitCategoriesProvider.hasComplexCategories(); + ChartModel* pModel = dynamic_cast<ChartModel*>(xChartModel.get()); + if (pModel) + { + ExplicitCategoriesProvider aExplicitCategoriesProvider( xCooSys, *pModel ); + m_bComplexCategoriesAxis = aExplicitCategoriesProvider.hasComplexCategories(); + } + + if (!m_bComplexCategoriesAxis) + m_bSupportingCategoryPositioning = ChartTypeHelper::isSupportingCategoryPositioning( xChartType, nDimensionCount ); } } } @@ -547,6 +550,7 @@ void SchAttribTabDlg::PageCreated(const OString& rId, SfxTabPage &rPage) pPage->SetCategories( m_pParameter->GetCategories() ); } pPage->SupportAxisPositioning( m_pParameter->IsSupportingAxisPositioning() ); + pPage->SupportCategoryPositioning( m_pParameter->IsSupportingCategoryPositioning() ); } } else if (rId == "scale") diff --git a/chart2/source/controller/dialogs/tp_AxisPositions.cxx b/chart2/source/controller/dialogs/tp_AxisPositions.cxx index 5cc4b41a099f..eeb8e19a96be 100644 --- a/chart2/source/controller/dialogs/tp_AxisPositions.cxx +++ b/chart2/source/controller/dialogs/tp_AxisPositions.cxx @@ -37,11 +37,15 @@ AxisPositionsTabPage::AxisPositionsTabPage(weld::Container* pPage, weld::DialogC , m_bCrossingAxisIsCategoryAxis(false) , m_aCategories() , m_bSupportAxisPositioning(false) + , m_bSupportCategoryPositioning(false) , m_xFL_AxisLine(m_xBuilder->weld_frame("FL_AXIS_LINE")) , m_xLB_CrossesAt(m_xBuilder->weld_combo_box("LB_CROSSES_OTHER_AXIS_AT")) , m_xED_CrossesAt(m_xBuilder->weld_formatted_spin_button("EDT_CROSSES_OTHER_AXIS_AT")) , m_xED_CrossesAtCategory(m_xBuilder->weld_combo_box( "EDT_CROSSES_OTHER_AXIS_AT_CATEGORY")) , m_xCB_AxisBetweenCategories(m_xBuilder->weld_check_button("CB_AXIS_BETWEEN_CATEGORIES")) + , m_xFL_Position(m_xBuilder->weld_frame("FL_POSITION")) + , m_xRB_On(m_xBuilder->weld_radio_button("RB_ON")) + , m_xRB_Between(m_xBuilder->weld_radio_button("RB_BETWEEN")) , m_xFL_Labels(m_xBuilder->weld_frame("FL_LABELS")) , m_xLB_PlaceLabels(m_xBuilder->weld_combo_box("LB_PLACE_LABELS")) , m_xED_LabelDistance(m_xBuilder->weld_formatted_spin_button("EDT_AXIS_LABEL_DISTANCE")) @@ -83,6 +87,10 @@ bool AxisPositionsTabPage::FillItemSet(SfxItemSet* rOutAttrs) rOutAttrs->Put(SvxDoubleItem(fCrossover,SCHATTR_AXIS_POSITION_VALUE)); } + // shifted category position + if (m_xFL_Position->get_visible()) + rOutAttrs->Put(SfxBoolItem(SCHATTR_AXIS_SHIFTED_CATEGORY_POSITION, m_xRB_Between->get_active())); + // labels sal_Int32 nLabelPos = m_xLB_PlaceLabels->get_active(); if (nLabelPos != -1) @@ -173,6 +181,17 @@ void AxisPositionsTabPage::Reset(const SfxItemSet* rInAttrs) m_xED_CrossesAt->set_sensitive( false ); } + // shifted category position + if (m_bSupportCategoryPositioning && rInAttrs->GetItemState(SCHATTR_AXIS_SHIFTED_CATEGORY_POSITION, true, &pPoolItem) == SfxItemState::SET) + { + if (static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()) + m_xRB_Between->set_active(true); + else + m_xRB_On->set_active(true); + } + else + m_xFL_Position->hide(); + // Labels if( rInAttrs->GetItemState( SCHATTR_AXIS_LABEL_POSITION, false, &pPoolItem ) == SfxItemState::SET ) { @@ -257,6 +276,11 @@ void AxisPositionsTabPage::SupportAxisPositioning( bool bSupportAxisPositioning m_bSupportAxisPositioning = bSupportAxisPositioning; } +void AxisPositionsTabPage::SupportCategoryPositioning( bool bSupportCategoryPositioning ) +{ + m_bSupportCategoryPositioning = bSupportCategoryPositioning; +} + IMPL_LINK_NOARG(AxisPositionsTabPage, CrossesAtSelectHdl, weld::ComboBox&, void) { sal_Int32 nPos = m_xLB_CrossesAt->get_active(); diff --git a/chart2/source/controller/dialogs/tp_AxisPositions.hxx b/chart2/source/controller/dialogs/tp_AxisPositions.hxx index fc5164b895cc..6be65c9dec48 100644 --- a/chart2/source/controller/dialogs/tp_AxisPositions.hxx +++ b/chart2/source/controller/dialogs/tp_AxisPositions.hxx @@ -41,6 +41,7 @@ public: void SetCategories( const css::uno::Sequence< OUString >& rCategories ); void SupportAxisPositioning( bool bSupportAxisPositioning ); + void SupportCategoryPositioning( bool bSupportCategoryPositioning ); private: //methods: DECL_LINK(CrossesAtSelectHdl, weld::ComboBox&, void); @@ -53,6 +54,7 @@ private: //member: css::uno::Sequence< OUString > m_aCategories; bool m_bSupportAxisPositioning; + bool m_bSupportCategoryPositioning; std::unique_ptr<weld::Frame> m_xFL_AxisLine; std::unique_ptr<weld::ComboBox> m_xLB_CrossesAt; @@ -60,6 +62,10 @@ private: //member: std::unique_ptr<weld::ComboBox> m_xED_CrossesAtCategory; std::unique_ptr<weld::CheckButton> m_xCB_AxisBetweenCategories; + std::unique_ptr<weld::Frame> m_xFL_Position; + std::unique_ptr<weld::RadioButton> m_xRB_On; + std::unique_ptr<weld::RadioButton> m_xRB_Between; + std::unique_ptr<weld::Frame> m_xFL_Labels; std::unique_ptr<weld::ComboBox> m_xLB_PlaceLabels; std::unique_ptr<weld::FormattedSpinButton> m_xED_LabelDistance; diff --git a/chart2/source/controller/inc/dlg_ObjectProperties.hxx b/chart2/source/controller/inc/dlg_ObjectProperties.hxx index fe9114443508..78a13838b9c6 100644 --- a/chart2/source/controller/inc/dlg_ObjectProperties.hxx +++ b/chart2/source/controller/inc/dlg_ObjectProperties.hxx @@ -55,6 +55,7 @@ public: bool IsSupportingAxisPositioning() const { return m_bSupportingAxisPositioning;} bool ShowAxisOrigin() const { return m_bShowAxisOrigin;} bool IsCrossingAxisIsCategoryAxis() const { return m_bIsCrossingAxisIsCategoryAxis;} + bool IsSupportingCategoryPositioning() const { return m_bSupportingCategoryPositioning;} const css::uno::Sequence< OUString >& GetCategories() const { return m_aCategories;} const css::uno::Reference< css::chart2::XChartDocument >& @@ -89,6 +90,7 @@ private: bool m_bSupportingAxisPositioning; bool m_bShowAxisOrigin; bool m_bIsCrossingAxisIsCategoryAxis; + bool m_bSupportingCategoryPositioning; css::uno::Sequence< OUString > m_aCategories; css::uno::Reference< css::chart2::XChartDocument > m_xChartDocument; diff --git a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx index da0a880626b0..62078d4a877a 100644 --- a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx @@ -364,6 +364,10 @@ void AxisItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutI } break; + case SCHATTR_AXIS_SHIFTED_CATEGORY_POSITION: + rOutItemSet.Put(SfxBoolItem(nWhichId, rScale.ShiftedCategoryPosition)); + break; + case SCHATTR_AXIS_LABEL_POSITION: { css::chart::ChartAxisLabelPosition ePos( css::chart::ChartAxisLabelPosition_NEAR_AXIS ); @@ -806,6 +810,18 @@ bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet } break; + case SCHATTR_AXIS_SHIFTED_CATEGORY_POSITION: + { + bool bNewValue = static_cast<const SfxBoolItem &> (rItemSet.Get(nWhichId)).GetValue(); + bool bOldValue = aScale.ShiftedCategoryPosition; + if (bOldValue != bNewValue) + { + aScale.ShiftedCategoryPosition = bNewValue; + bSetScale = true; + } + } + break; + case SCHATTR_AXIS_LABEL_POSITION: { css::chart::ChartAxisLabelPosition ePos = diff --git a/chart2/source/inc/ChartTypeHelper.hxx b/chart2/source/inc/ChartTypeHelper.hxx index 1a4fc2f8d012..e749dd5b4f75 100644 --- a/chart2/source/inc/ChartTypeHelper.hxx +++ b/chart2/source/inc/ChartTypeHelper.hxx @@ -49,6 +49,7 @@ public: static bool isSupportingAxisPositioning( const css::uno::Reference< css::chart2::XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex ); static bool isSupportingDateAxis( const css::uno::Reference< css::chart2::XChartType >& xChartType, sal_Int32 nDimensionIndex ); static bool isSupportingComplexCategory( const css::uno::Reference< css::chart2::XChartType >& xChartType ); + static bool isSupportingCategoryPositioning( const css::uno::Reference< css::chart2::XChartType >& xChartType, sal_Int32 nDimensionCount ); //returns sequence of css::chart::DataLabelPlacement static css::uno::Sequence < sal_Int32 > getSupportedLabelPlacements( diff --git a/chart2/source/inc/chartview/ChartSfxItemIds.hxx b/chart2/source/inc/chartview/ChartSfxItemIds.hxx index 7c0e5555f374..2d02f2f8bd2b 100644 --- a/chart2/source/inc/chartview/ChartSfxItemIds.hxx +++ b/chart2/source/inc/chartview/ChartSfxItemIds.hxx @@ -131,8 +131,9 @@ constexpr TypedWhichId<SfxInt32Item> SCHATTR_AXIS_HELPTICKS constexpr TypedWhichId<SfxInt32Item> SCHATTR_AXIS_POSITION (SCHATTR_AXIS_POSITION_START + 2); constexpr TypedWhichId<SvxDoubleItem> SCHATTR_AXIS_POSITION_VALUE (SCHATTR_AXIS_POSITION_START + 3); constexpr TypedWhichId<SfxUInt32Item> SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT (SCHATTR_AXIS_POSITION_START + 4); -constexpr TypedWhichId<SfxInt32Item> SCHATTR_AXIS_LABEL_POSITION (SCHATTR_AXIS_POSITION_START + 5); -constexpr TypedWhichId<SfxInt32Item> SCHATTR_AXIS_MARK_POSITION (SCHATTR_AXIS_POSITION_START + 6); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_AXIS_SHIFTED_CATEGORY_POSITION (SCHATTR_AXIS_POSITION_START + 5); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_AXIS_LABEL_POSITION (SCHATTR_AXIS_POSITION_START + 6); +constexpr TypedWhichId<SfxInt32Item> SCHATTR_AXIS_MARK_POSITION (SCHATTR_AXIS_POSITION_START + 7); //axis label constexpr sal_uInt16 SCHATTR_AXIS_LABEL_START (SCHATTR_AXIS_MARK_POSITION + 1); constexpr TypedWhichId<SfxBoolItem> SCHATTR_AXIS_SHOWDESCR (SCHATTR_AXIS_LABEL_START); diff --git a/chart2/source/tools/ChartTypeHelper.cxx b/chart2/source/tools/ChartTypeHelper.cxx index a8efdeecd8ec..236d066f77d3 100644 --- a/chart2/source/tools/ChartTypeHelper.cxx +++ b/chart2/source/tools/ChartTypeHelper.cxx @@ -447,6 +447,22 @@ bool ChartTypeHelper::isSupportingComplexCategory( const uno::Reference< chart2: return true; } +bool ChartTypeHelper::isSupportingCategoryPositioning( const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 nDimensionCount ) +{ + if( xChartType.is() ) + { + OUString aChartTypeName = xChartType->getChartType(); + if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA) || + aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) || + aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK)) + return true; + else if (nDimensionCount == 2 && + (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR))) + return true; + } + return false; +} + bool ChartTypeHelper::noBordersForSimpleScheme( const uno::Reference< chart2::XChartType >& xChartType ) { if(xChartType.is()) diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx index 8ca22b635d23..7e428942f0db 100644 --- a/chart2/source/view/main/ChartItemPool.cxx +++ b/chart2/source/view/main/ChartItemPool.cxx @@ -116,6 +116,7 @@ ChartItemPool::ChartItemPool(): rPoolDefaults[SCHATTR_AXIS_POSITION - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_POSITION,0); rPoolDefaults[SCHATTR_AXIS_POSITION_VALUE - SCHATTR_START] = new SvxDoubleItem(0.0, SCHATTR_AXIS_POSITION_VALUE); rPoolDefaults[SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT - SCHATTR_START] = new SfxUInt32Item(SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT,0); + rPoolDefaults[SCHATTR_AXIS_SHIFTED_CATEGORY_POSITION - SCHATTR_START] = new SfxBoolItem(SCHATTR_AXIS_SHIFTED_CATEGORY_POSITION,false); rPoolDefaults[SCHATTR_AXIS_LABEL_POSITION - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_LABEL_POSITION,0); rPoolDefaults[SCHATTR_AXIS_MARK_POSITION - SCHATTR_START] = new SfxInt32Item(SCHATTR_AXIS_MARK_POSITION,0); diff --git a/chart2/uiconfig/ui/tp_AxisPositions.ui b/chart2/uiconfig/ui/tp_AxisPositions.ui index 16fcff3ffe06..98aa603cb10a 100644 --- a/chart2/uiconfig/ui/tp_AxisPositions.ui +++ b/chart2/uiconfig/ui/tp_AxisPositions.ui @@ -149,6 +149,76 @@ </packing> </child> <child> + <object class="GtkFrame" id="FL_POSITION"> + <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="alignment6"> + <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="GtkGrid" id="grid3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="row_spacing">6</property> + <child> + <object class="GtkRadioButton" id="RB_ON"> + <property name="label" translatable="yes" context="tp_AxisPositions|RB_ON">_On tick marks</property> + <property name="visible">True</property> + <property name="can_focus">True</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="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="RB_BETWEEN"> + <property name="label" translatable="yes" context="tp_AxisPositions|RB_BETWEEN">_Between tick marks</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <property name="group">RB_ON</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="TXT_POSITION"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes" context="tp_AxisPositions|TXT_POSITION">Position Axis</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">1</property> + </packing> + </child> + <child> <object class="GtkFrame" id="FL_LABELS"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -267,7 +337,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> <child> @@ -467,7 +537,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">2</property> + <property name="position">3</property> </packing> </child> <child> @@ -564,7 +634,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">3</property> + <property name="position">4</property> </packing> </child> </object> |