tdf#151144 add opencl controls to calc > calculate tab page
Change-Id: If2e42ba1a10fe289b691d4973ff524ded8f00daa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187559 Reviewed-by: Sahil Gautam <sahil.gautam@collabora.com> Tested-by: Jenkins
This commit is contained in:
@@ -180,7 +180,7 @@ const std::tuple<TranslateId, OUString, OUString, tipModule> TIPOFTHEDAY_STRINGA
|
||||
{ NC_("RID_CUI_TIPOFTHEDAY", "Use your Android or iPhone to remotely control your Impress presentation."), "https://help.libreoffice.org/%PRODUCTVERSION/he/text/simpress/guide/impress_remote.html", "", simpress}, //local help missing
|
||||
{ NC_("RID_CUI_TIPOFTHEDAY", "Want to know how many days there are in the current month? Use the DAYSINMONTH(TODAY()) function."), "", "", scalc},
|
||||
{ NC_("RID_CUI_TIPOFTHEDAY", "Your numbers are displayed as ### in your spreadsheet? The column is too narrow to display all digits."), "", "", scalc},
|
||||
{ NC_("RID_CUI_TIPOFTHEDAY", "Enable massive parallel calculations of formula cells via Tools ▸ Options ▸ %PRODUCTNAME ▸ OpenCL."), "cui/ui/optopenclpage/OptOpenCLPage", "", scalc}, //https://help.libreoffice.org/%PRODUCTVERSION/%LANGUAGENAME/text/shared/optionen/opencl.html
|
||||
{ NC_("RID_CUI_TIPOFTHEDAY", "Enable massive parallel calculations of formula cells via Tools ▸ Options ▸ %PRODUCTNAME Calc ▸ Calculate ▸ OpenCL Options."), "cui/ui/optcalculatepage/OptOpenCLPage", "", scalc}, //https://help.libreoffice.org/%PRODUCTVERSION/%LANGUAGENAME/text/shared/optionen/opencl.html
|
||||
{ NC_("RID_CUI_TIPOFTHEDAY", "Use the Connector tool from the Drawing toolbar in Draw/Impress to create nice flow charts and optionally copy/paste the object into Writer."), "", "", sdraw},
|
||||
{ NC_("RID_CUI_TIPOFTHEDAY", "Your donations support our worldwide community."), "https://www.libreoffice.org/donate/", "", soffice},
|
||||
{ NC_("RID_CUI_TIPOFTHEDAY", "You want to add x months to a date? Use =EDATE(date;months)."), "https://help.libreoffice.org/%PRODUCTVERSION/%LANGUAGENAME/text/scalc/01/func_edate.html", "", scalc}, //local help missing
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
|
||||
#include <sfx2/tabdlg.hxx>
|
||||
#include "editfield.hxx"
|
||||
#include <config_feature_opencl.h>
|
||||
#if HAVE_FEATURE_OPENCL
|
||||
#include <opencl/openclconfig.hxx>
|
||||
#endif
|
||||
#include <com/sun/star/configuration/ReadWriteAccess.hpp>
|
||||
#include <com/sun/star/beans/PropertyAttribute.hpp>
|
||||
|
||||
@@ -59,6 +63,12 @@ private:
|
||||
std::unique_ptr<weld::RadioButton> m_xBtnDate1904;
|
||||
std::unique_ptr<weld::Widget> m_xDateImg;
|
||||
|
||||
#if HAVE_FEATURE_OPENCL
|
||||
OpenCLConfig maConfig;
|
||||
std::unique_ptr<weld::CheckButton> m_xAllowOpenCL;
|
||||
#endif
|
||||
std::unique_ptr<weld::Frame> m_xOpenCLFrame;
|
||||
|
||||
std::unique_ptr<weld::CheckButton> m_xBtnCase;
|
||||
std::unique_ptr<weld::Widget> m_xBtnCaseImg;
|
||||
std::unique_ptr<weld::CheckButton> m_xBtnCalc;
|
||||
@@ -83,6 +93,7 @@ private:
|
||||
|
||||
private:
|
||||
void Init();
|
||||
void InitOpenCL();
|
||||
|
||||
// Handler:
|
||||
DECL_LINK( RadioClickHdl, weld::Toggleable&, void );
|
||||
|
||||
@@ -28,9 +28,13 @@
|
||||
#include <docoptio.hxx>
|
||||
#include <sc.hrc>
|
||||
#include <officecfg/Office/Calc.hxx>
|
||||
#include <officecfg/Office/Common.hxx>
|
||||
#include <svtools/restartdialog.hxx>
|
||||
|
||||
#include <tpcalc.hxx>
|
||||
#if HAVE_FEATURE_OPENCL
|
||||
#include <opencl/openclwrapper.hxx>
|
||||
#endif
|
||||
|
||||
ScTpCalcOptions::ScTpCalcOptions(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs)
|
||||
: SfxTabPage(pPage, pController, u"modules/scalc/ui/optcalculatepage.ui"_ustr, u"OptCalculatePage"_ustr, &rCoreAttrs)
|
||||
@@ -49,6 +53,11 @@ ScTpCalcOptions::ScTpCalcOptions(weld::Container* pPage, weld::DialogController*
|
||||
, m_xBtnDateSc10(m_xBuilder->weld_radio_button(u"datesc10"_ustr))
|
||||
, m_xBtnDate1904(m_xBuilder->weld_radio_button(u"date1904"_ustr))
|
||||
, m_xDateImg(m_xBuilder->weld_widget(u"lockdate"_ustr))
|
||||
#if HAVE_FEATURE_OPENCL
|
||||
, maConfig(OpenCLConfig::get())
|
||||
, m_xAllowOpenCL(m_xBuilder->weld_check_button(u"allowopencl"_ustr))
|
||||
#endif
|
||||
, m_xOpenCLFrame(m_xBuilder->weld_frame(u"OptOpenCLPage"_ustr))
|
||||
, m_xBtnCase(m_xBuilder->weld_check_button(u"case"_ustr))
|
||||
, m_xBtnCaseImg(m_xBuilder->weld_widget(u"lockcase"_ustr))
|
||||
, m_xBtnCalc(m_xBuilder->weld_check_button(u"calc"_ustr))
|
||||
@@ -70,6 +79,7 @@ ScTpCalcOptions::ScTpCalcOptions(weld::Container* pPage, weld::DialogController*
|
||||
, m_xBtnThreadImg(m_xBuilder->weld_widget(u"lockthreadingenabled"_ustr))
|
||||
{
|
||||
Init();
|
||||
InitOpenCL();
|
||||
SetExchangeSupport();
|
||||
|
||||
const css::uno::Reference < css::uno::XComponentContext >& xContext(::comphelper::getProcessComponentContext());
|
||||
@@ -90,6 +100,16 @@ void ScTpCalcOptions::Init()
|
||||
m_xBtnThread->connect_toggled( LINK( this, ScTpCalcOptions, CheckClickHdl ) );
|
||||
}
|
||||
|
||||
void ScTpCalcOptions::InitOpenCL()
|
||||
{
|
||||
#if HAVE_FEATURE_OPENCL
|
||||
m_xAllowOpenCL->set_active(maConfig.mbUseOpenCL);
|
||||
m_xAllowOpenCL->set_sensitive(!officecfg::Office::Common::Misc::UseOpenCL::isReadOnly()
|
||||
&& openclwrapper::GPUEnv::isOpenCLEnabled());
|
||||
#endif
|
||||
m_xOpenCLFrame->set_visible(HAVE_FEATURE_OPENCL);
|
||||
}
|
||||
|
||||
std::unique_ptr<SfxTabPage> ScTpCalcOptions::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet )
|
||||
{
|
||||
return std::make_unique<ScTpCalcOptions>( pPage, pController, *rAttrSet );
|
||||
@@ -243,13 +263,20 @@ void ScTpCalcOptions::Reset(const SfxItemSet* rCoreAttrs)
|
||||
m_xBtnThread->set_active( officecfg::Office::Calc::Formula::Calculation::UseThreadedCalculationForFormulaGroups::get() );
|
||||
|
||||
CheckClickHdl(*m_xBtnIterate);
|
||||
|
||||
#if HAVE_FEATURE_OPENCL
|
||||
maConfig = OpenCLConfig::get();
|
||||
m_xAllowOpenCL->set_active(maConfig.mbUseOpenCL);
|
||||
m_xAllowOpenCL->save_state();
|
||||
#endif
|
||||
}
|
||||
|
||||
OUString ScTpCalcOptions::GetAllStrings()
|
||||
{
|
||||
OUString sAllStrings;
|
||||
OUString labels[]
|
||||
= { u"label5"_ustr, u"label1"_ustr, u"precft"_ustr, u"label2"_ustr, u"stepsft"_ustr, u"minchangeft"_ustr, u"label4"_ustr, u"label3"_ustr };
|
||||
OUString labels[] = { u"label5"_ustr, u"label1"_ustr, u"precft"_ustr,
|
||||
u"label2"_ustr, u"stepsft"_ustr, u"minchangeft"_ustr,
|
||||
u"label4"_ustr, u"label3"_ustr, u"openclframe"_ustr };
|
||||
|
||||
for (const auto& label : labels)
|
||||
{
|
||||
@@ -295,25 +322,46 @@ bool ScTpCalcOptions::FillItemSet( SfxItemSet* rCoreAttrs )
|
||||
else
|
||||
pLocalOptions->SetStdPrecision( SvNumberFormatter::UNLIMITED_PRECISION );
|
||||
|
||||
bool bRestartRequired = false;
|
||||
bool bShouldEnableThreading = m_xBtnThread->get_active();
|
||||
if (bShouldEnableThreading != officecfg::Office::Calc::Formula::Calculation::UseThreadedCalculationForFormulaGroups::get())
|
||||
{
|
||||
std::shared_ptr<comphelper::ConfigurationChanges> xBatch(comphelper::ConfigurationChanges::create());
|
||||
officecfg::Office::Calc::Formula::Calculation::UseThreadedCalculationForFormulaGroups::set(bShouldEnableThreading, xBatch);
|
||||
xBatch->commit();
|
||||
bRestartRequired = true;
|
||||
}
|
||||
|
||||
#if HAVE_FEATURE_OPENCL
|
||||
std::shared_ptr<comphelper::ConfigurationChanges> batch(
|
||||
comphelper::ConfigurationChanges::create());
|
||||
|
||||
if (m_xAllowOpenCL->get_state_changed_from_saved())
|
||||
maConfig.mbUseOpenCL = m_xAllowOpenCL->get_active();
|
||||
|
||||
if (maConfig != OpenCLConfig::get())
|
||||
{
|
||||
maConfig.set();
|
||||
bRestartRequired = true;
|
||||
batch->commit();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (bRestartRequired)
|
||||
{
|
||||
SolarMutexGuard aGuard;
|
||||
if (svtools::executeRestartDialog(
|
||||
comphelper::getProcessComponentContext(), GetFrameWeld(),
|
||||
svtools::RESTART_REASON_CALCULATION))
|
||||
if (svtools::executeRestartDialog(comphelper::getProcessComponentContext(), nullptr,
|
||||
svtools::RESTART_REASON_CALCULATION))
|
||||
GetDialogController()->response(RET_OK);
|
||||
}
|
||||
|
||||
if ( *pLocalOptions != *pOldOptions )
|
||||
{
|
||||
rCoreAttrs->Put( ScTpCalcItem( SID_SCDOCOPTIONS, *pLocalOptions ) );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
DeactivateRC ScTpCalcOptions::DeactivatePage( SfxItemSet* pSetP )
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
<object class="GtkGrid" id="OptCalculatePage">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="border-width">6</property>
|
||||
<property name="row-spacing">12</property>
|
||||
<property name="column-spacing">24</property>
|
||||
@@ -335,7 +337,6 @@
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">1</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
@@ -745,5 +746,52 @@
|
||||
<property name="top-attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame" id="OptOpenCLPage">
|
||||
<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="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="margin-start">12</property>
|
||||
<property name="margin-top">6</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="allowopencl">
|
||||
<property name="label" translatable="yes" context="optcalculatepage|allowopencl">Allow use of OpenCL</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">False</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>
|
||||
<child type="label">
|
||||
<object class="GtkLabel" id="openclframe">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes" context="optcalculatepage|openclframe">OpenCL Options</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
</attributes>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
||||
Reference in New Issue
Block a user