Kaydet (Commit) 9143eaff authored tarafından Olivier Hallot's avatar Olivier Hallot Kaydeden (comit) Caolán McNamara

Convert chart legend dialog to widget UI

Conflicts:
	chart2/AllLangResTarget_chartcontroller.mk

Change-Id: Ibc265efe5a8bdf3e0e5fb8135fb0487de7e96764
Reviewed-on: https://gerrit.libreoffice.org/7199Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 79e7109b
...@@ -49,7 +49,6 @@ $(eval $(call gb_SrsTarget_add_nonlocalizable_files,chart2/res,\ ...@@ -49,7 +49,6 @@ $(eval $(call gb_SrsTarget_add_nonlocalizable_files,chart2/res,\
chart2/source/controller/dialogs/dlg_CreationWizard.src \ chart2/source/controller/dialogs/dlg_CreationWizard.src \
chart2/source/controller/dialogs/dlg_InsertDataLabel.src \ chart2/source/controller/dialogs/dlg_InsertDataLabel.src \
chart2/source/controller/dialogs/dlg_InsertErrorBars.src \ chart2/source/controller/dialogs/dlg_InsertErrorBars.src \
chart2/source/controller/dialogs/dlg_InsertLegend.src \
chart2/source/controller/dialogs/tp_ErrorBars.src \ chart2/source/controller/dialogs/tp_ErrorBars.src \
chart2/source/controller/dialogs/tp_PointGeometry.src \ chart2/source/controller/dialogs/tp_PointGeometry.src \
chart2/source/controller/menus/ShapeContextMenu.src \ chart2/source/controller/menus/ShapeContextMenu.src \
......
...@@ -38,6 +38,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/schart,\ ...@@ -38,6 +38,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/schart,\
chart2/uiconfig/ui/smoothlinesdlg \ chart2/uiconfig/ui/smoothlinesdlg \
chart2/uiconfig/ui/steppedlinesdlg \ chart2/uiconfig/ui/steppedlinesdlg \
chart2/uiconfig/ui/titlerotationtabpage \ chart2/uiconfig/ui/titlerotationtabpage \
chart2/uiconfig/ui/dlg_InsertLegend \
chart2/uiconfig/ui/tp_3D_SceneAppearance \ chart2/uiconfig/ui/tp_3D_SceneAppearance \
chart2/uiconfig/ui/tp_3D_SceneGeometry \ chart2/uiconfig/ui/tp_3D_SceneGeometry \
chart2/uiconfig/ui/tp_3D_SceneIllumination \ chart2/uiconfig/ui/tp_3D_SceneIllumination \
......
...@@ -18,10 +18,7 @@ ...@@ -18,10 +18,7 @@
*/ */
#include "dlg_InsertLegend.hxx" #include "dlg_InsertLegend.hxx"
#include "dlg_InsertLegend.hrc"
#include "res_LegendPosition.hxx" #include "res_LegendPosition.hxx"
#include "ObjectNameProvider.hxx"
#include "ResId.hxx"
namespace chart namespace chart
{ {
...@@ -29,14 +26,11 @@ namespace chart ...@@ -29,14 +26,11 @@ namespace chart
using namespace ::com::sun::star; using namespace ::com::sun::star;
SchLegendDlg::SchLegendDlg(Window* pWindow, const uno::Reference< uno::XComponentContext>& xCC ) SchLegendDlg::SchLegendDlg(Window* pWindow, const uno::Reference< uno::XComponentContext>& xCC )
: ModalDialog(pWindow, SchResId(DLG_LEGEND)) : ModalDialog(pWindow
, m_apLegendPositionResources( new oldLegendPositionResources(this,xCC) ) ,"dlg_InsertLegend"
, aBtnOK(this, SchResId(BTN_OK)) ,"modules/schart/ui/dlg_InsertLegend.ui")
, aBtnCancel(this, SchResId(BTN_CANCEL)) , m_apLegendPositionResources( new LegendPositionResources(*this,xCC) )
, aBtnHelp(this, SchResId(BTN_HELP))
{ {
FreeResource();
this->SetText( ObjectNameProvider::getName(OBJECTTYPE_LEGEND) );
} }
SchLegendDlg::~SchLegendDlg() SchLegendDlg::~SchLegendDlg()
......
/* -*- 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 "ResourceIds.hrc"
#define BTN_OK 1
#define BTN_CANCEL 1
#define BTN_HELP 1
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 "dlg_InsertLegend.hrc"
#include "CommonResources.hrc"
#include "res_LegendPosition.hrc"
#include <svtools/controldims.hrc>
ModalDialog DLG_LEGEND
{
HelpID = HID_INSERT_CHART_LEGEND ;
OutputSize = TRUE ;
SVLook = TRUE ;
Size = MAP_APPFONT ( 156 , 80 ) ;
Moveable = TRUE ;
BUTTONS_OK_CANCEL_HELP_STACKED( 101 )
RESOURCE_LEGENDDISPLAY( 6, 6 )
RESOURCE_LEGENDPOSITION( 15, 6 + RSC_CD_FIXEDTEXT_HEIGHT +6 )
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -18,10 +18,6 @@ ...@@ -18,10 +18,6 @@
*/ */
#include "res_LegendPosition.hxx" #include "res_LegendPosition.hxx"
#include "ResourceIds.hrc"
#include "Strings.hrc"
#include "res_LegendPosition_IDs.hrc"
#include "ResId.hxx"
#include "ChartModelHelper.hxx" #include "ChartModelHelper.hxx"
#include "macros.hxx" #include "macros.hxx"
#include "LegendHelper.hxx" #include "LegendHelper.hxx"
...@@ -254,222 +250,6 @@ void LegendPositionResources::SetAccessibleRelationMemberOf(Window* pMemberOf) ...@@ -254,222 +250,6 @@ void LegendPositionResources::SetAccessibleRelationMemberOf(Window* pMemberOf)
m_pRbtBottom->SetAccessibleRelationMemberOf(pMemberOf); m_pRbtBottom->SetAccessibleRelationMemberOf(pMemberOf);
} }
oldLegendPositionResources::oldLegendPositionResources( Window* pWindow )
: m_xCC() //unused in this scenario
, m_aCbxShow( pWindow ) //unused in this scenario
, m_aRbtLeft( pWindow, SchResId(RBT_LEFT) )
, m_aRbtRight( pWindow, SchResId(RBT_RIGHT) )
, m_aRbtTop( pWindow, SchResId(RBT_TOP) )
, m_aRbtBottom( pWindow, SchResId(RBT_BOTTOM) )
{
m_aCbxShow.Check();//legend is assumed to be visible in this scenario
impl_setRadioButtonToggleHdl();
}
oldLegendPositionResources::oldLegendPositionResources( Window* pWindow, const uno::Reference< uno::XComponentContext >& xCC )
: m_xCC( xCC )
, m_aCbxShow( pWindow, SchResId(CBX_SHOWLEGEND) )
, m_aRbtLeft( pWindow, SchResId(RBT_LEFT) )
, m_aRbtRight( pWindow, SchResId(RBT_RIGHT) )
, m_aRbtTop( pWindow, SchResId(RBT_TOP) )
, m_aRbtBottom( pWindow, SchResId(RBT_BOTTOM) )
{
m_aCbxShow.SetToggleHdl( LINK( this, oldLegendPositionResources, PositionEnableHdl ) );
impl_setRadioButtonToggleHdl();
m_aCbxShow.SetAccessibleRelationMemberOf(&m_aCbxShow);
m_aRbtLeft.SetAccessibleRelationMemberOf(&m_aCbxShow);
m_aRbtRight.SetAccessibleRelationMemberOf(&m_aCbxShow);
m_aRbtTop.SetAccessibleRelationMemberOf(&m_aCbxShow);
m_aRbtBottom.SetAccessibleRelationMemberOf(&m_aCbxShow);
}
void oldLegendPositionResources::impl_setRadioButtonToggleHdl()
{
m_aRbtLeft.SetToggleHdl( LINK( this, oldLegendPositionResources, PositionChangeHdl ) );
m_aRbtTop.SetToggleHdl( LINK( this, oldLegendPositionResources, PositionChangeHdl ) );
m_aRbtRight.SetToggleHdl( LINK( this, oldLegendPositionResources, PositionChangeHdl ) );
m_aRbtBottom.SetToggleHdl( LINK( this, oldLegendPositionResources, PositionChangeHdl ) );
}
oldLegendPositionResources::~oldLegendPositionResources()
{
}
void oldLegendPositionResources::writeToResources( const uno::Reference< frame::XModel >& xChartModel )
{
try
{
uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xChartModel );
uno::Reference< beans::XPropertySet > xProp( xDiagram->getLegend(), uno::UNO_QUERY );
if( xProp.is() )
{
//show
sal_Bool bShowLegend = sal_False;
xProp->getPropertyValue( "Show" ) >>= bShowLegend;
m_aCbxShow.Check( bShowLegend );
PositionEnableHdl(0);
//position
chart2::LegendPosition ePos;
xProp->getPropertyValue( "AnchorPosition" ) >>= ePos;
switch( ePos )
{
case chart2::LegendPosition_LINE_START:
m_aRbtLeft.Check();
break;
case chart2::LegendPosition_LINE_END:
m_aRbtRight.Check();
break;
case chart2::LegendPosition_PAGE_START:
m_aRbtTop.Check();
break;
case chart2::LegendPosition_PAGE_END:
m_aRbtBottom.Check();
break;
case chart2::LegendPosition_CUSTOM:
default:
m_aRbtRight.Check();
break;
}
}
}
catch( const uno::Exception & ex )
{
ASSERT_EXCEPTION( ex );
}
}
void oldLegendPositionResources::writeToModel( const ::com::sun::star::uno::Reference< frame::XModel >& xChartModel ) const
{
try
{
sal_Bool bShowLegend = static_cast<sal_Bool>(m_aCbxShow.IsChecked());
ChartModel* pModel = dynamic_cast<ChartModel*>(xChartModel.get());
uno::Reference< beans::XPropertySet > xProp( LegendHelper::getLegend( *pModel,m_xCC,bShowLegend ), uno::UNO_QUERY );
if( xProp.is() )
{
//show
xProp->setPropertyValue( "Show" , uno::makeAny( bShowLegend ));
//position
chart2::LegendPosition eNewPos;
::com::sun::star::chart::ChartLegendExpansion eExp = ::com::sun::star::chart::ChartLegendExpansion_HIGH;
if( m_aRbtLeft.IsChecked() )
eNewPos = chart2::LegendPosition_LINE_START;
else if( m_aRbtRight.IsChecked() )
{
eNewPos = chart2::LegendPosition_LINE_END;
}
else if( m_aRbtTop.IsChecked() )
{
eNewPos = chart2::LegendPosition_PAGE_START;
eExp = ::com::sun::star::chart::ChartLegendExpansion_WIDE;
}
else if( m_aRbtBottom.IsChecked() )
{
eNewPos = chart2::LegendPosition_PAGE_END;
eExp = ::com::sun::star::chart::ChartLegendExpansion_WIDE;
}
xProp->setPropertyValue( "AnchorPosition" , uno::makeAny( eNewPos ));
xProp->setPropertyValue( "Expansion" , uno::makeAny( eExp ));
xProp->setPropertyValue( "RelativePosition" , uno::Any());
}
}
catch( const uno::Exception & ex )
{
ASSERT_EXCEPTION( ex );
}
}
IMPL_LINK_NOARG(oldLegendPositionResources, PositionEnableHdl)
{
sal_Bool bEnable = m_aCbxShow.IsChecked();
m_aRbtLeft.Enable( bEnable );
m_aRbtTop.Enable( bEnable );
m_aRbtRight.Enable( bEnable );
m_aRbtBottom.Enable( bEnable );
m_aChangeLink.Call(NULL);
return 0;
}
void oldLegendPositionResources::initFromItemSet( const SfxItemSet& rInAttrs )
{
const SfxPoolItem* pPoolItem = NULL;
if( rInAttrs.GetItemState( SCHATTR_LEGEND_POS, sal_True, &pPoolItem ) == SFX_ITEM_SET )
{
sal_Int32 nLegendPosition = ((const SfxInt32Item*)pPoolItem)->GetValue();
switch( nLegendPosition )
{
case chart2::LegendPosition_LINE_START:
m_aRbtLeft.Check(sal_True);
break;
case chart2::LegendPosition_PAGE_START:
m_aRbtTop.Check(sal_True);
break;
case chart2::LegendPosition_LINE_END:
m_aRbtRight.Check(sal_True);
break;
case chart2::LegendPosition_PAGE_END:
m_aRbtBottom.Check(sal_True);
break;
default:
break;
}
}
if( rInAttrs.GetItemState( SCHATTR_LEGEND_SHOW, sal_True, &pPoolItem ) == SFX_ITEM_SET )
{
bool bShow = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
m_aCbxShow.Check(bShow);
}
}
void oldLegendPositionResources::writeToItemSet( SfxItemSet& rOutAttrs ) const
{
sal_Int32 nLegendPosition = chart2::LegendPosition_CUSTOM;
if( m_aRbtLeft.IsChecked() )
nLegendPosition = chart2::LegendPosition_LINE_START;
else if( m_aRbtTop.IsChecked() )
nLegendPosition = chart2::LegendPosition_PAGE_START;
else if( m_aRbtRight.IsChecked() )
nLegendPosition = chart2::LegendPosition_LINE_END;
else if( m_aRbtBottom.IsChecked() )
nLegendPosition = chart2::LegendPosition_PAGE_END;
rOutAttrs.Put(SfxInt32Item(SCHATTR_LEGEND_POS, nLegendPosition ));
rOutAttrs.Put( SfxBoolItem(SCHATTR_LEGEND_SHOW, m_aCbxShow.IsChecked()) );
}
IMPL_LINK( oldLegendPositionResources, PositionChangeHdl, RadioButton*, pRadio )
{
//for each radio click ther are coming two change events
//first uncheck of previous button -> ignore that call
//the second call gives the check of the new button
if( pRadio && pRadio->IsChecked() )
m_aChangeLink.Call(NULL);
return 0;
}
void oldLegendPositionResources::SetChangeHdl( const Link& rLink )
{
m_aChangeLink = rLink;
}
void oldLegendPositionResources::SetAccessibleRelationMemberOf(Window* pMemberOf)
{
m_aRbtLeft.SetAccessibleRelationMemberOf(pMemberOf);
m_aRbtRight.SetAccessibleRelationMemberOf(pMemberOf);
m_aRbtTop.SetAccessibleRelationMemberOf(pMemberOf);
m_aRbtBottom.SetAccessibleRelationMemberOf(pMemberOf);
}
} //namespace chart } //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -72,51 +72,6 @@ private: ...@@ -72,51 +72,6 @@ private:
Link m_aChangeLink; Link m_aChangeLink;
}; };
class oldLegendPositionResources
{
public:
//constructor without Display checkbox
oldLegendPositionResources( Window* pParent );
//constructor inclusive Display checkbox
oldLegendPositionResources( Window* pParent, const ::com::sun::star::uno::Reference<
::com::sun::star::uno::XComponentContext>& xCC );
virtual ~oldLegendPositionResources();
void writeToResources( const ::com::sun::star::uno::Reference<
::com::sun::star::frame::XModel >& xChartModel );
void writeToModel( const ::com::sun::star::uno::Reference<
::com::sun::star::frame::XModel >& xChartModel ) const;
void initFromItemSet( const SfxItemSet& rInAttrs );
void writeToItemSet( SfxItemSet& rOutAttrs ) const;
void SetChangeHdl( const Link& rLink );
DECL_LINK( PositionEnableHdl, void* );
DECL_LINK( PositionChangeHdl, RadioButton* );
void SetAccessibleRelationMemberOf(Window* pMemberOf);
private:
void impl_setRadioButtonToggleHdl();
private:
::com::sun::star::uno::Reference<
::com::sun::star::uno::XComponentContext> m_xCC;
CheckBox m_aCbxShow;
RadioButton m_aRbtLeft;
RadioButton m_aRbtRight;
RadioButton m_aRbtTop;
RadioButton m_aRbtBottom;
Link m_aChangeLink;
};
} //namespace chart } //namespace chart
#endif #endif
......
/* -*- 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 .
*/
#define CBX_SHOWLEGEND 21
#define RBT_LEFT 22
#define RBT_TOP 23
#define RBT_RIGHT 24
#define RBT_BOTTOM 25
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -99,7 +99,6 @@ ...@@ -99,7 +99,6 @@
#define HID_DIAGRAM_TYPE "CHART2_HID_DIAGRAM_TYPE" #define HID_DIAGRAM_TYPE "CHART2_HID_DIAGRAM_TYPE"
#define HID_DIAGRAM_DATA "CHART2_HID_DIAGRAM_DATA" #define HID_DIAGRAM_DATA "CHART2_HID_DIAGRAM_DATA"
#define HID_INSERT_STATISTICS "CHART2_HID_INSERT_STATISTICS" #define HID_INSERT_STATISTICS "CHART2_HID_INSERT_STATISTICS"
#define HID_INSERT_CHART_LEGEND "CHART2_HID_INSERT_CHART_LEGEND"
#define HID_INSERT_DESCRIPTION "CHART2_HID_INSERT_DESCRIPTION" #define HID_INSERT_DESCRIPTION "CHART2_HID_INSERT_DESCRIPTION"
......
...@@ -22,24 +22,21 @@ ...@@ -22,24 +22,21 @@
// header for class ModalDialog // header for class ModalDialog
#include <vcl/dialog.hxx> #include <vcl/dialog.hxx>
// header for class CheckBox // header for class CheckBox
#include <vcl/button.hxx> #include <sfx2/basedlgs.hxx>
//for auto_ptr
#include <memory> #include <boost/scoped_ptr.hpp>
#include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/uno/XComponentContext.hpp>
namespace chart namespace chart
{ {
class oldLegendPositionResources; class LegendPositionResources;
class SchLegendDlg : public ModalDialog class SchLegendDlg : public ModalDialog
{ {
private: private:
::std::auto_ptr< oldLegendPositionResources > m_apLegendPositionResources; boost::scoped_ptr < LegendPositionResources > m_apLegendPositionResources;
OKButton aBtnOK;
CancelButton aBtnCancel;
HelpButton aBtnHelp;
public: public:
SchLegendDlg( Window* pParent, const ::com::sun::star::uno::Reference< SchLegendDlg( Window* pParent, const ::com::sun::star::uno::Reference<
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment