[Libreoffice-commits] core.git: 2 commits - chart2/source reportdesign/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sat Oct 27 19:43:42 UTC 2018
chart2/source/controller/dialogs/dlg_InsertLegend.cxx | 2
chart2/source/controller/dialogs/res_LegendPosition.cxx | 169 ++--------------
chart2/source/controller/dialogs/tp_LegendPosition.hxx | 2
chart2/source/controller/inc/dlg_InsertLegend.hxx | 2
chart2/source/controller/inc/res_LegendPosition.hxx | 35 ---
reportdesign/source/ui/dlg/PageNumber.cxx | 51 ++++
reportdesign/source/ui/inc/PageNumber.hxx | 2
7 files changed, 86 insertions(+), 177 deletions(-)
New commits:
commit ecb7a18aef839056b038e9699d48c918102f389b
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sat Oct 27 19:13:59 2018 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Sat Oct 27 21:43:32 2018 +0200
merge SchLegendPositionResources/LegendPositionResources back together
Change-Id: I53b5bc65313a6f5e661c3f6804db256d18037c74
Reviewed-on: https://gerrit.libreoffice.org/62437
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/chart2/source/controller/dialogs/dlg_InsertLegend.cxx b/chart2/source/controller/dialogs/dlg_InsertLegend.cxx
index 51b95fe3f46a..65dc9010e294 100644
--- a/chart2/source/controller/dialogs/dlg_InsertLegend.cxx
+++ b/chart2/source/controller/dialogs/dlg_InsertLegend.cxx
@@ -27,7 +27,7 @@ using namespace ::com::sun::star;
SchLegendDlg::SchLegendDlg(weld::Window* pWindow, const uno::Reference< uno::XComponentContext>& xCC)
: GenericDialogController(pWindow, "modules/schart/ui/dlg_InsertLegend.ui", "dlg_InsertLegend")
- , m_xLegendPositionResources(new SchLegendPositionResources(*m_xBuilder, xCC))
+ , m_xLegendPositionResources(new LegendPositionResources(*m_xBuilder, xCC))
{
}
diff --git a/chart2/source/controller/dialogs/res_LegendPosition.cxx b/chart2/source/controller/dialogs/res_LegendPosition.cxx
index 089bec1100fd..68e64d84f34a 100644
--- a/chart2/source/controller/dialogs/res_LegendPosition.cxx
+++ b/chart2/source/controller/dialogs/res_LegendPosition.cxx
@@ -39,6 +39,15 @@ namespace chart
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
+LegendPositionResources::LegendPositionResources(weld::Builder& rBuilder)
+ : m_xRbtLeft(rBuilder.weld_radio_button("left"))
+ , m_xRbtRight(rBuilder.weld_radio_button("right"))
+ , m_xRbtTop(rBuilder.weld_radio_button("top"))
+ , m_xRbtBottom(rBuilder.weld_radio_button("bottom"))
+{
+ impl_setRadioButtonToggleHdl();
+}
+
LegendPositionResources::LegendPositionResources(weld::Builder& rBuilder,
const uno::Reference< uno::XComponentContext >& xCC)
: m_xCC(xCC)
@@ -165,147 +174,7 @@ IMPL_LINK_NOARG(LegendPositionResources, PositionEnableHdl, weld::ToggleButton&,
m_aChangeLink.Call(nullptr);
}
-IMPL_LINK (LegendPositionResources, PositionChangeHdl, weld::ToggleButton&, rRadio, void)
-{
- //for each radio click there are coming two change events
- //first uncheck of previous button -> ignore that call
- //the second call gives the check of the new button
- if( rRadio.get_active() )
- m_aChangeLink.Call(nullptr);
-}
-
-void LegendPositionResources::SetChangeHdl( const Link<LinkParamNone*,void>& rLink )
-{
- m_aChangeLink = rLink;
-}
-
-SchLegendPositionResources::SchLegendPositionResources(weld::Builder& rBuilder)
- : m_xCC() // unused in this scenario
- , m_xCbxShow() // unused in this scenario, assumed to be visible
- , m_xRbtLeft(rBuilder.weld_radio_button("left"))
- , m_xRbtRight(rBuilder.weld_radio_button("right"))
- , m_xRbtTop(rBuilder.weld_radio_button("top"))
- , m_xRbtBottom(rBuilder.weld_radio_button("bottom"))
-{
-}
-
-SchLegendPositionResources::SchLegendPositionResources(weld::Builder& rBuilder,
- const uno::Reference< uno::XComponentContext >& xCC)
- : m_xCC(xCC)
- , m_xCbxShow(rBuilder.weld_check_button("show"))
- , m_xRbtLeft(rBuilder.weld_radio_button("left"))
- , m_xRbtRight(rBuilder.weld_radio_button("right"))
- , m_xRbtTop(rBuilder.weld_radio_button("top"))
- , m_xRbtBottom(rBuilder.weld_radio_button("bottom"))
-{
- m_xCbxShow->connect_toggled(LINK(this, SchLegendPositionResources, PositionEnableHdl));
-}
-
-SchLegendPositionResources::~SchLegendPositionResources()
-{
-}
-
-void SchLegendPositionResources::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
- bool bShowLegend = false;
- xProp->getPropertyValue( "Show" ) >>= bShowLegend;
- if (m_xCbxShow)
- m_xCbxShow->set_active(bShowLegend);
- PositionEnableHdl(*m_xCbxShow);
-
- //position
- chart2::LegendPosition ePos;
- xProp->getPropertyValue( "AnchorPosition" ) >>= ePos;
- switch( ePos )
- {
- 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:
- default:
- m_xRbtRight->set_active(true);
- break;
- }
- }
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-}
-
-void SchLegendPositionResources::writeToModel( const css::uno::Reference< frame::XModel >& xChartModel ) const
-{
- try
- {
- bool bShowLegend = m_xCbxShow && m_xCbxShow->get_active();
- ChartModel& rModel = dynamic_cast<ChartModel&>(*xChartModel.get());
- uno::Reference< beans::XPropertySet > xProp(LegendHelper::getLegend(rModel, m_xCC, bShowLegend), uno::UNO_QUERY);
- if( xProp.is() )
- {
- //show
- xProp->setPropertyValue( "Show" , uno::Any( bShowLegend ));
-
- //position
- chart2::LegendPosition eNewPos;
- css::chart::ChartLegendExpansion eExp = css::chart::ChartLegendExpansion_HIGH;
-
- if( m_xRbtLeft->get_active() )
- eNewPos = chart2::LegendPosition_LINE_START;
- else if( m_xRbtRight->get_active() )
- {
- eNewPos = chart2::LegendPosition_LINE_END;
- }
- else if( m_xRbtTop->get_active() )
- {
- eNewPos = chart2::LegendPosition_PAGE_START;
- eExp = css::chart::ChartLegendExpansion_WIDE;
- }
- else if( m_xRbtBottom->get_active() )
- {
- eNewPos = chart2::LegendPosition_PAGE_END;
- eExp = css::chart::ChartLegendExpansion_WIDE;
- }
-
- xProp->setPropertyValue( "AnchorPosition" , uno::Any( eNewPos ));
- xProp->setPropertyValue( "Expansion" , uno::Any( eExp ));
- xProp->setPropertyValue( "RelativePosition" , uno::Any());
- }
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2" );
- }
-}
-
-IMPL_LINK_NOARG(SchLegendPositionResources, PositionEnableHdl, weld::ToggleButton&, void)
-{
- bool bEnable = !m_xCbxShow || m_xCbxShow->get_active();
-
- m_xRbtLeft->set_sensitive( bEnable );
- m_xRbtTop->set_sensitive( bEnable );
- m_xRbtRight->set_sensitive( bEnable );
- m_xRbtBottom->set_sensitive( bEnable );
-}
-
-void SchLegendPositionResources::initFromItemSet( const SfxItemSet& rInAttrs )
+void LegendPositionResources::initFromItemSet( const SfxItemSet& rInAttrs )
{
const SfxPoolItem* pPoolItem = nullptr;
if( rInAttrs.GetItemState( SCHATTR_LEGEND_POS, true, &pPoolItem ) == SfxItemState::SET )
@@ -330,14 +199,14 @@ void SchLegendPositionResources::initFromItemSet( const SfxItemSet& rInAttrs )
}
}
- if (m_xCbxShow && rInAttrs.GetItemState( SCHATTR_LEGEND_SHOW, true, &pPoolItem ) == SfxItemState::SET)
+ if( m_xCbxShow && rInAttrs.GetItemState( SCHATTR_LEGEND_SHOW, true, &pPoolItem ) == SfxItemState::SET )
{
bool bShow = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue();
m_xCbxShow->set_active(bShow);
}
}
-void SchLegendPositionResources::writeToItemSet( SfxItemSet& rOutAttrs ) const
+void LegendPositionResources::writeToItemSet( SfxItemSet& rOutAttrs ) const
{
chart2::LegendPosition nLegendPosition = chart2::LegendPosition_CUSTOM;
if( m_xRbtLeft->get_active() )
@@ -353,6 +222,20 @@ void SchLegendPositionResources::writeToItemSet( SfxItemSet& rOutAttrs ) const
rOutAttrs.Put( SfxBoolItem(SCHATTR_LEGEND_SHOW, !m_xCbxShow || m_xCbxShow->get_active()) );
}
+IMPL_LINK (LegendPositionResources, PositionChangeHdl, weld::ToggleButton&, rRadio, void)
+{
+ //for each radio click there are coming two change events
+ //first uncheck of previous button -> ignore that call
+ //the second call gives the check of the new button
+ if( rRadio.get_active() )
+ m_aChangeLink.Call(nullptr);
+}
+
+void LegendPositionResources::SetChangeHdl( const Link<LinkParamNone*,void>& rLink )
+{
+ m_aChangeLink = rLink;
+}
+
} //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/dialogs/tp_LegendPosition.hxx b/chart2/source/controller/dialogs/tp_LegendPosition.hxx
index 7e0491bfdb7e..b1c58effa821 100644
--- a/chart2/source/controller/dialogs/tp_LegendPosition.hxx
+++ b/chart2/source/controller/dialogs/tp_LegendPosition.hxx
@@ -31,7 +31,7 @@ class SchLegendPosTabPage : public SfxTabPage
{
private:
- SchLegendPositionResources m_aLegendPositionResources;
+ LegendPositionResources m_aLegendPositionResources;
std::unique_ptr<TextDirectionListBox> m_xLbTextDirection;
public:
diff --git a/chart2/source/controller/inc/dlg_InsertLegend.hxx b/chart2/source/controller/inc/dlg_InsertLegend.hxx
index 1b8ff7b4429f..a2c8e50d6172 100644
--- a/chart2/source/controller/inc/dlg_InsertLegend.hxx
+++ b/chart2/source/controller/inc/dlg_InsertLegend.hxx
@@ -34,7 +34,7 @@ namespace chart
class SchLegendDlg : public weld::GenericDialogController
{
private:
- std::unique_ptr<SchLegendPositionResources> m_xLegendPositionResources;
+ std::unique_ptr<LegendPositionResources> m_xLegendPositionResources;
public:
SchLegendDlg(weld::Window* pParent, const css::uno::Reference< css::uno::XComponentContext>& xCC);
diff --git a/chart2/source/controller/inc/res_LegendPosition.hxx b/chart2/source/controller/inc/res_LegendPosition.hxx
index c9105f7dd1af..f5e9ab9445b7 100644
--- a/chart2/source/controller/inc/res_LegendPosition.hxx
+++ b/chart2/source/controller/inc/res_LegendPosition.hxx
@@ -32,6 +32,8 @@ class LegendPositionResources final
{
public:
+ //constructor without Display checkbox
+ LegendPositionResources(weld::Builder& rBuilder);
//constructor inclusive Display checkbox
LegendPositionResources(weld::Builder& rBuilder, const css::uno::Reference<
css::uno::XComponentContext>& xCC );
@@ -40,6 +42,9 @@ public:
void writeToResources( const css::uno::Reference< css::frame::XModel >& xChartModel );
void writeToModel( const css::uno::Reference< css::frame::XModel >& xChartModel ) const;
+ void initFromItemSet( const SfxItemSet& rInAttrs );
+ void writeToItemSet( SfxItemSet& rOutAttrs ) const;
+
void SetChangeHdl( const Link<LinkParamNone*,void>& rLink );
DECL_LINK( PositionEnableHdl, weld::ToggleButton&, void );
@@ -59,36 +64,6 @@ private:
std::unique_ptr<weld::RadioButton> m_xRbtBottom;
};
-
-class SchLegendPositionResources final
-{
-
-public:
- //constructor without Display checkbox
- SchLegendPositionResources(weld::Builder& rBuilder);
- //constructor inclusive Display checkbox
- SchLegendPositionResources(weld::Builder& rBuilder, const css::uno::Reference<
- css::uno::XComponentContext>& xCC );
- ~SchLegendPositionResources();
-
- void writeToResources( const css::uno::Reference< css::frame::XModel >& xChartModel );
- void writeToModel( const css::uno::Reference< css::frame::XModel >& xChartModel ) const;
-
- void initFromItemSet( const SfxItemSet& rInAttrs );
- void writeToItemSet( SfxItemSet& rOutAttrs ) const;
-
- DECL_LINK(PositionEnableHdl, weld::ToggleButton&, void);
-
-private:
- css::uno::Reference< css::uno::XComponentContext> m_xCC;
-
- std::unique_ptr<weld::CheckButton> m_xCbxShow;
- std::unique_ptr<weld::RadioButton> m_xRbtLeft;
- std::unique_ptr<weld::RadioButton> m_xRbtRight;
- std::unique_ptr<weld::RadioButton> m_xRbtTop;
- std::unique_ptr<weld::RadioButton> m_xRbtBottom;
-};
-
} //namespace chart
#endif
commit 4eecab2520d432f05bf398cff9abfdd64d55a3d9
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sat Oct 27 19:17:41 2018 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Sat Oct 27 21:43:20 2018 +0200
missing OPageNumberDialog run
Change-Id: I0e21f90e9cfd4e1ee6ced6108ab6619533ab8dda
Reviewed-on: https://gerrit.libreoffice.org/62438
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/reportdesign/source/ui/dlg/PageNumber.cxx b/reportdesign/source/ui/dlg/PageNumber.cxx
index 62462180cfa6..da9faa591aae 100644
--- a/reportdesign/source/ui/dlg/PageNumber.cxx
+++ b/reportdesign/source/ui/dlg/PageNumber.cxx
@@ -38,8 +38,9 @@ using namespace ::comphelper;
OPageNumberDialog::OPageNumberDialog(weld::Window* pParent,
const uno::Reference< report::XReportDefinition >& _xHoldAlive,
- OReportController* )
+ OReportController* _pController)
: GenericDialogController(pParent, "modules/dbreport/ui/pagenumberdialog.ui", "PageNumberDialog")
+ , m_pController(_pController)
, m_xHoldAlive(_xHoldAlive)
, m_xPageN(m_xBuilder->weld_radio_button("pagen"))
, m_xPageNofM(m_xBuilder->weld_radio_button("pagenofm"))
@@ -55,6 +56,54 @@ OPageNumberDialog::~OPageNumberDialog()
{
}
+short OPageNumberDialog::run()
+{
+ short nRet = GenericDialogController::run();
+ if (nRet == RET_OK)
+ {
+ try
+ {
+ sal_Int32 nControlMaxSize = 3000;
+ sal_Int32 nPosX = 0;
+ sal_Int32 nPos2X = 0;
+ awt::Size aRptSize = getStyleProperty<awt::Size>(m_xHoldAlive,PROPERTY_PAPERSIZE);
+ switch (m_xAlignmentLst->get_active())
+ {
+ case 0: // left
+ nPosX = getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_LEFTMARGIN);
+ break;
+ case 1: // middle
+ nPosX = getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_LEFTMARGIN) + (aRptSize.Width - getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_LEFTMARGIN) - getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_RIGHTMARGIN) - nControlMaxSize) / 2;
+ break;
+ case 2: // right
+ nPosX = (aRptSize.Width - getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_RIGHTMARGIN) - nControlMaxSize);
+ break;
+ case 3: // inner
+ case 4: // outer
+ nPosX = getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_LEFTMARGIN);
+ nPos2X = (aRptSize.Width - getStyleProperty<sal_Int32>(m_xHoldAlive,PROPERTY_RIGHTMARGIN) - nControlMaxSize);
+ break;
+ default:
+ break;
+ }
+ if (m_xAlignmentLst->get_active() > 2)
+ nPosX = nPos2X;
+
+ uno::Sequence<beans::PropertyValue> aValues( comphelper::InitPropertySequence({
+ { PROPERTY_POSITION, uno::Any(awt::Point(nPosX,0)) },
+ { PROPERTY_PAGEHEADERON, uno::Any(m_xTopPage->get_active()) },
+ { PROPERTY_STATE, uno::Any(m_xPageNofM->get_active()) }
+ }));
+
+ m_pController->executeChecked(SID_INSERT_FLD_PGNUMBER,aValues);
+ }
+ catch(uno::Exception&)
+ {
+ }
+ }
+ return nRet;
+}
+
} // rptui
diff --git a/reportdesign/source/ui/inc/PageNumber.hxx b/reportdesign/source/ui/inc/PageNumber.hxx
index 92fd4cc549f8..eefa10c8b809 100644
--- a/reportdesign/source/ui/inc/PageNumber.hxx
+++ b/reportdesign/source/ui/inc/PageNumber.hxx
@@ -32,6 +32,7 @@ class OReportController;
\************************************************************************/
class OPageNumberDialog : public weld::GenericDialogController
{
+ ::rptui::OReportController* m_pController;
css::uno::Reference< css::report::XReportDefinition>
m_xHoldAlive;
std::unique_ptr<weld::RadioButton> m_xPageN;
@@ -48,6 +49,7 @@ public:
const css::uno::Reference< css::report::XReportDefinition>& _xHoldAlive,
::rptui::OReportController* _pController);
virtual ~OPageNumberDialog() override;
+ virtual short run() override;
};
} // namespace rptui
More information about the Libreoffice-commits
mailing list