weld SvxJavaOptionsPage

Change-Id: Ib37f6f554a890bd6397ae7b6c56f1615cd12b6b1
Reviewed-on: https://gerrit.libreoffice.org/76604
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2019-07-30 12:59:20 +01:00
parent 4fe32e65cc
commit 1aa246a8e8
3 changed files with 275 additions and 313 deletions

View File

@@ -68,113 +68,69 @@ using namespace ::com::sun::star::ucb;
using namespace ::com::sun::star::ui::dialogs; using namespace ::com::sun::star::ui::dialogs;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
class SvxJavaListBox : public svx::SvxRadioButtonListBox
{
private:
const OUString m_sAccessibilityText;
public:
SvxJavaListBox(SvSimpleTableContainer& rParent, const OUString &rAccessibilityText)
: SvxRadioButtonListBox(rParent, 0)
, m_sAccessibilityText(rAccessibilityText)
{
}
void setColSizes()
{
HeaderBar &rBar = GetTheHeaderBar();
if (rBar.GetItemCount() < 4)
return;
long nCheckWidth = std::max(GetControlColumnWidth() + 12,
rBar.LogicToPixel(Size(15, 0), MapMode(MapUnit::MapAppFont)).Width());
long nVersionWidth = 12 +
std::max(rBar.GetTextWidth(rBar.GetItemText(3)),
GetTextWidth("0.0.0_00-icedtea"));
long nFeatureWidth = 12 +
std::max(rBar.GetTextWidth(rBar.GetItemText(4)),
GetTextWidth(m_sAccessibilityText));
long nVendorWidth =
std::max(GetSizePixel().Width() - (nCheckWidth + nVersionWidth + nFeatureWidth),
6 + std::max(rBar.GetTextWidth(rBar.GetItemText(2)),
GetTextWidth("Sun Microsystems Inc.")));
long aStaticTabs[]= { 0, 0, 0, 0 };
aStaticTabs[1] = nCheckWidth;
aStaticTabs[2] = aStaticTabs[1] + nVendorWidth;
aStaticTabs[3] = aStaticTabs[2] + nVersionWidth;
SvSimpleTable::SetTabs(SAL_N_ELEMENTS(aStaticTabs), aStaticTabs, MapUnit::MapPixel);
}
virtual void Resize() override
{
svx::SvxRadioButtonListBox::Resize();
setColSizes();
}
};
// class SvxJavaOptionsPage ---------------------------------------------- // class SvxJavaOptionsPage ----------------------------------------------
SvxJavaOptionsPage::SvxJavaOptionsPage(TabPageParent pParent, const SfxItemSet& rSet)
SvxJavaOptionsPage::SvxJavaOptionsPage( vcl::Window* pParent, const SfxItemSet& rSet ) : SfxTabPage(pParent, "cui/ui/optadvancedpage.ui", "OptAdvancedPage", &rSet)
: SfxTabPage(pParent, "OptAdvancedPage", "cui/ui/optadvancedpage.ui", &rSet)
, m_aResetIdle("cui options SvxJavaOptionsPage Reset") , m_aResetIdle("cui options SvxJavaOptionsPage Reset")
, xDialogListener(new ::svt::DialogClosedListener()) , xDialogListener(new ::svt::DialogClosedListener())
, m_xJavaEnableCB(m_xBuilder->weld_check_button("javaenabled"))
, m_xJavaList(m_xBuilder->weld_tree_view("javas"))
, m_xJavaPathText(m_xBuilder->weld_label("javapath"))
, m_xAddBtn(m_xBuilder->weld_button("add"))
, m_xParameterBtn(m_xBuilder->weld_button("parameters"))
, m_xClassPathBtn(m_xBuilder->weld_button("classpath"))
, m_xExpertConfigBtn(m_xBuilder->weld_button("expertconfig"))
, m_xExperimentalCB(m_xBuilder->weld_check_button("experimental"))
, m_xMacroCB(m_xBuilder->weld_check_button("macrorecording"))
, m_xAccessibilityText(m_xBuilder->weld_label("a11y"))
, m_xAddDialogText(m_xBuilder->weld_label("selectruntime"))
, m_xJavaFrame(m_xBuilder->weld_widget("javaframe"))
{ {
get(m_pJavaEnableCB, "javaenabled"); m_sInstallText = m_xJavaPathText->get_label();
get(m_pJavaBox, "javabox"); m_sAccessibilityText = m_xAccessibilityText->get_label();
get(m_pJavaPathText, "javapath"); m_sAddDialogText = m_xAddDialogText->get_label();
m_sInstallText = m_pJavaPathText->GetText();
get(m_pAddBtn, "add");
get(m_pParameterBtn, "parameters");
get(m_pClassPathBtn, "classpath");
get(m_pExperimentalCB, "experimental");
get(m_pMacroCB, "macrorecording");
get(m_pExpertConfigBtn, "expertconfig");
m_pParentDlg.reset( dynamic_cast<OfaTreeOptionsDialog*>(getNonLayoutParent(pParent)) );
m_sAccessibilityText = get<FixedText>("a11y")->GetText();
m_sAddDialogText = get<FixedText>("selectruntime")->GetText();
SvSimpleTableContainer *pJavaListContainer = get<SvSimpleTableContainer>("javas"); m_xJavaList->set_size_request(m_xJavaList->get_approximate_digit_width() * 30,
Size aControlSize(177, 60); m_xJavaList->get_height_rows(8));
aControlSize = LogicToPixel(aControlSize, MapMode(MapUnit::MapAppFont));
pJavaListContainer->set_width_request(aControlSize.Width());
pJavaListContainer->set_height_request(aControlSize.Height());
m_pJavaList = VclPtr<SvxJavaListBox>::Create(*pJavaListContainer, m_sAccessibilityText);
long const aStaticTabs[]= { 0, 0, 0, 0 }; std::vector<int> aWidths;
m_pJavaList->SvSimpleTable::SetTabs( SAL_N_ELEMENTS(aStaticTabs), aStaticTabs ); aWidths.push_back(m_xJavaList->get_checkbox_column_width());
aWidths.push_back(m_xJavaList->get_pixel_size("Sun Microsystems Inc.").Width());
aWidths.push_back(m_xJavaList->get_pixel_size("0.0.0_00-icedtea").Width());
m_xJavaList->set_column_fixed_widths(aWidths);
OUString sHeader ( "\t" + get<FixedText>("vendor")->GetText() + std::vector<int> aRadioColumns;
"\t" + get<FixedText>("version")->GetText() + aRadioColumns.push_back(0);
"\t" + get<FixedText>("features")->GetText() + m_xJavaList->set_toggle_columns_as_radio(aRadioColumns);
"\t" );
m_pJavaList->InsertHeaderEntry(sHeader, HEADERBAR_APPEND, HeaderBarItemBits::LEFT);
m_pJavaList->setColSizes();
m_pJavaEnableCB->SetClickHdl( LINK( this, SvxJavaOptionsPage, EnableHdl_Impl ) ); m_xJavaEnableCB->connect_clicked( LINK( this, SvxJavaOptionsPage, EnableHdl_Impl ) );
m_pJavaList->SetCheckButtonHdl( LINK( this, SvxJavaOptionsPage, CheckHdl_Impl ) ); m_xJavaList->connect_toggled( LINK( this, SvxJavaOptionsPage, CheckHdl_Impl ) );
m_pJavaList->SetSelectHdl( LINK( this, SvxJavaOptionsPage, SelectHdl_Impl ) ); m_xJavaList->connect_changed( LINK( this, SvxJavaOptionsPage, SelectHdl_Impl ) );
m_pAddBtn->SetClickHdl( LINK( this, SvxJavaOptionsPage, AddHdl_Impl ) ); m_xAddBtn->connect_clicked( LINK( this, SvxJavaOptionsPage, AddHdl_Impl ) );
m_pParameterBtn->SetClickHdl( LINK( this, SvxJavaOptionsPage, ParameterHdl_Impl ) ); m_xParameterBtn->connect_clicked( LINK( this, SvxJavaOptionsPage, ParameterHdl_Impl ) );
m_pClassPathBtn->SetClickHdl( LINK( this, SvxJavaOptionsPage, ClassPathHdl_Impl ) ); m_xClassPathBtn->connect_clicked( LINK( this, SvxJavaOptionsPage, ClassPathHdl_Impl ) );
m_aResetIdle.SetInvokeHandler( LINK( this, SvxJavaOptionsPage, ResetHdl_Impl ) ); m_aResetIdle.SetInvokeHandler( LINK( this, SvxJavaOptionsPage, ResetHdl_Impl ) );
m_pExpertConfigBtn->SetClickHdl( LINK( this, SvxJavaOptionsPage, ExpertConfigHdl_Impl) ); m_xExpertConfigBtn->connect_clicked( LINK( this, SvxJavaOptionsPage, ExpertConfigHdl_Impl) );
if (!officecfg::Office::Common::Security::EnableExpertConfiguration::get()) if (!officecfg::Office::Common::Security::EnableExpertConfiguration::get())
m_pExpertConfigBtn->Disable(); m_xExpertConfigBtn->set_sensitive(false);
if (officecfg::Office::Common::Misc::MacroRecorderMode::isReadOnly()) if (officecfg::Office::Common::Misc::MacroRecorderMode::isReadOnly())
m_pMacroCB->Disable(); m_xMacroCB->set_sensitive(false);
if (officecfg::Office::Common::Misc::ExperimentalMode::isReadOnly()) if (officecfg::Office::Common::Misc::ExperimentalMode::isReadOnly())
m_pExperimentalCB->Disable(); m_xExperimentalCB->set_sensitive(false);
xDialogListener->SetDialogClosedLink( LINK( this, SvxJavaOptionsPage, DialogClosedHdl ) ); xDialogListener->SetDialogClosedLink( LINK( this, SvxJavaOptionsPage, DialogClosedHdl ) );
EnableHdl_Impl(m_pJavaEnableCB); EnableHdl_Impl(*m_xJavaEnableCB);
#if HAVE_FEATURE_JAVA #if HAVE_FEATURE_JAVA
jfw_lock(); jfw_lock();
#else #else
get<vcl::Window>("javaframe")->Disable(); m_xJavaFrame->set_sensitive(false);
#endif #endif
} }
SvxJavaOptionsPage::~SvxJavaOptionsPage() SvxJavaOptionsPage::~SvxJavaOptionsPage()
{ {
disposeOnce(); disposeOnce();
@@ -182,63 +138,38 @@ SvxJavaOptionsPage::~SvxJavaOptionsPage()
void SvxJavaOptionsPage::dispose() void SvxJavaOptionsPage::dispose()
{ {
m_pJavaList.disposeAndClear();
m_xParamDlg.reset();
m_xPathDlg.reset();
ClearJavaInfo(); ClearJavaInfo();
#if HAVE_FEATURE_JAVA #if HAVE_FEATURE_JAVA
m_aAddedInfos.clear(); m_aAddedInfos.clear();
jfw_unlock(); jfw_unlock();
#endif #endif
m_pParentDlg.clear();
m_pJavaEnableCB.clear();
m_pJavaBox.clear();
m_pJavaPathText.clear();
m_pAddBtn.clear();
m_pParameterBtn.clear();
m_pClassPathBtn.clear();
m_pExpertConfigBtn.clear();
m_pExperimentalCB.clear();
m_pMacroCB.clear();
SfxTabPage::dispose(); SfxTabPage::dispose();
} }
IMPL_LINK_NOARG(SvxJavaOptionsPage, EnableHdl_Impl, weld::Button&, void)
IMPL_LINK_NOARG(SvxJavaOptionsPage, EnableHdl_Impl, Button*, void)
{ {
bool bEnable = m_pJavaEnableCB->IsChecked(); bool bEnable = m_xJavaEnableCB->get_active();
m_pJavaBox->Enable(bEnable); m_xJavaList->set_sensitive(bEnable);
bEnable ? m_pJavaList->EnableTable() : m_pJavaList->DisableTable();
} }
IMPL_LINK(SvxJavaOptionsPage, CheckHdl_Impl, const row_col&, rRowCol, void)
IMPL_LINK( SvxJavaOptionsPage, CheckHdl_Impl, SvTreeListBox*, pList, void )
{ {
SvTreeListEntry* pEntry = pList ? m_pJavaList->GetEntry( m_pJavaList->GetCurMousePoint() ) HandleCheckEntry(rRowCol.first);
: m_pJavaList->FirstSelected();
if ( pEntry )
m_pJavaList->HandleEntryChecked( pEntry );
} }
IMPL_LINK_NOARG(SvxJavaOptionsPage, SelectHdl_Impl, weld::TreeView&, void)
IMPL_LINK_NOARG(SvxJavaOptionsPage, SelectHdl_Impl, SvTreeListBox*, void)
{ {
// set installation directory info // set installation directory info
SvTreeListEntry* pEntry = m_pJavaList->FirstSelected(); OUString sLocation = m_xJavaList->get_selected_id();
DBG_ASSERT( pEntry, "SvxJavaOptionsPage::SelectHdl_Impl(): no entry" );
OUString* pLocation = static_cast< OUString* >( pEntry->GetUserData() );
DBG_ASSERT( pLocation, "invalid location string" );
OUString sInfo = m_sInstallText; OUString sInfo = m_sInstallText;
// tdf#80646 insert LTR mark after label // tdf#80646 insert LTR mark after label
sInfo += OUStringLiteral1(0x200E); sInfo += OUStringLiteral1(0x200E);
if ( pLocation ) sInfo += sLocation;
sInfo += *pLocation; m_xJavaPathText->set_label(sInfo);
m_pJavaPathText->SetText(sInfo);
} }
IMPL_LINK_NOARG(SvxJavaOptionsPage, AddHdl_Impl, weld::Button&, void)
IMPL_LINK_NOARG(SvxJavaOptionsPage, AddHdl_Impl, Button*, void)
{ {
try try
{ {
@@ -261,14 +192,13 @@ IMPL_LINK_NOARG(SvxJavaOptionsPage, AddHdl_Impl, Button*, void)
} }
} }
IMPL_LINK_NOARG(SvxJavaOptionsPage, ParameterHdl_Impl, weld::Button&, void)
IMPL_LINK_NOARG(SvxJavaOptionsPage, ParameterHdl_Impl, Button*, void)
{ {
#if HAVE_FEATURE_JAVA #if HAVE_FEATURE_JAVA
std::vector< OUString > aParameterList; std::vector< OUString > aParameterList;
if (!m_xParamDlg) if (!m_xParamDlg)
{ {
m_xParamDlg.reset(new SvxJavaParameterDlg(GetFrameWeld())); m_xParamDlg.reset(new SvxJavaParameterDlg(GetDialogFrameWeld()));
javaFrameworkError eErr = jfw_getVMParameters( &m_parParameters ); javaFrameworkError eErr = jfw_getVMParameters( &m_parParameters );
if ( JFW_E_NONE == eErr && !m_parParameters.empty() ) if ( JFW_E_NONE == eErr && !m_parParameters.empty() )
{ {
@@ -301,14 +231,14 @@ IMPL_LINK_NOARG(SvxJavaOptionsPage, ParameterHdl_Impl, Button*, void)
} }
IMPL_LINK_NOARG(SvxJavaOptionsPage, ClassPathHdl_Impl, Button*, void) IMPL_LINK_NOARG(SvxJavaOptionsPage, ClassPathHdl_Impl, weld::Button&, void)
{ {
#if HAVE_FEATURE_JAVA #if HAVE_FEATURE_JAVA
OUString sClassPath; OUString sClassPath;
if ( !m_xPathDlg ) if ( !m_xPathDlg )
{ {
m_xPathDlg.reset(new SvxJavaClassPathDlg(GetFrameWeld())); m_xPathDlg.reset(new SvxJavaClassPathDlg(GetDialogFrameWeld()));
javaFrameworkError eErr = jfw_getUserClassPath( &m_pClassPath ); javaFrameworkError eErr = jfw_getUserClassPath( &m_pClassPath );
if ( JFW_E_NONE == eErr ) if ( JFW_E_NONE == eErr )
{ {
@@ -373,9 +303,9 @@ IMPL_LINK( SvxJavaOptionsPage, DialogClosedHdl, DialogClosedEvent*, pEvt, void )
} }
} }
IMPL_STATIC_LINK( SvxJavaOptionsPage, ExpertConfigHdl_Impl, Button*, pButton, void ) IMPL_LINK_NOARG(SvxJavaOptionsPage, ExpertConfigHdl_Impl, weld::Button&, void)
{ {
ScopedVclPtrInstance< CuiAboutConfigTabPage > pExpertConfigDlg(pButton->GetParentDialog()); ScopedVclPtrInstance<CuiAboutConfigTabPage> pExpertConfigDlg(GetParentDialog());
pExpertConfigDlg->Reset();//initialize and reset function pExpertConfigDlg->Reset();//initialize and reset function
if( RET_OK == pExpertConfigDlg->Execute() ) if( RET_OK == pExpertConfigDlg->Execute() )
@@ -398,21 +328,14 @@ void SvxJavaOptionsPage::ClearJavaInfo()
void SvxJavaOptionsPage::ClearJavaList() void SvxJavaOptionsPage::ClearJavaList()
{ {
SvTreeListEntry* pEntry = m_pJavaList->First(); m_xJavaList->clear();
while ( pEntry )
{
OUString* pLocation = static_cast< OUString* >( pEntry->GetUserData() );
delete pLocation;
pEntry = m_pJavaList->Next( pEntry );
}
m_pJavaList->Clear();
} }
void SvxJavaOptionsPage::LoadJREs() void SvxJavaOptionsPage::LoadJREs()
{ {
#if HAVE_FEATURE_JAVA #if HAVE_FEATURE_JAVA
WaitObject aWaitObj(m_pJavaList); weld::WaitObject aWaitObj(GetDialogFrameWeld());
javaFrameworkError eErr = jfw_findAllJREs( &m_parJavaInfo ); javaFrameworkError eErr = jfw_findAllJREs( &m_parJavaInfo );
if ( JFW_E_NONE == eErr ) if ( JFW_E_NONE == eErr )
{ {
@@ -436,9 +359,7 @@ void SvxJavaOptionsPage::LoadJREs()
{ {
if ( jfw_areEqualJavaInfo( pCmpInfo.get(), pSelectedJava.get() ) ) if ( jfw_areEqualJavaInfo( pCmpInfo.get(), pSelectedJava.get() ) )
{ {
SvTreeListEntry* pEntry = m_pJavaList->GetEntry(i); HandleCheckEntry(i);
if ( pEntry )
m_pJavaList->HandleEntryChecked( pEntry );
break; break;
} }
++i; ++i;
@@ -453,41 +374,35 @@ void SvxJavaOptionsPage::LoadJREs()
void SvxJavaOptionsPage::AddJRE( JavaInfo const * _pInfo ) void SvxJavaOptionsPage::AddJRE( JavaInfo const * _pInfo )
{ {
#if HAVE_FEATURE_JAVA #if HAVE_FEATURE_JAVA
OUString sEntry = "\t" + _pInfo->sVendor + "\t" + _pInfo->sVersion + "\t"; int nPos = m_xJavaList->n_children();
if ( ( _pInfo->nFeatures & JFW_FEATURE_ACCESSBRIDGE ) == JFW_FEATURE_ACCESSBRIDGE ) m_xJavaList->append();
sEntry += m_sAccessibilityText; m_xJavaList->set_toggle(nPos, TRISTATE_FALSE, 0);
SvTreeListEntry* pEntry = m_pJavaList->InsertEntry(sEntry); m_xJavaList->set_text(nPos, _pInfo->sVendor, 1);
INetURLObject aLocObj( _pInfo->sLocation ); m_xJavaList->set_text(nPos, _pInfo->sVersion, 2);
OUString* pLocation = new OUString( aLocObj.getFSysPath( FSysStyle::Detect ) ); OUString sFeature;
pEntry->SetUserData( pLocation ); if ((_pInfo->nFeatures & JFW_FEATURE_ACCESSBRIDGE) == JFW_FEATURE_ACCESSBRIDGE)
sFeature = m_sAccessibilityText;
m_xJavaList->set_text(nPos, sFeature, 3);
INetURLObject aLocObj(_pInfo->sLocation);
OUString sLocation = aLocObj.getFSysPath(FSysStyle::Detect);
m_xJavaList->set_id(nPos, sLocation);
#else #else
(void) this; (void) this;
(void)_pInfo; (void)_pInfo;
#endif #endif
} }
void SvxJavaOptionsPage::HandleCheckEntry(int nCheckedRow)
void SvxJavaOptionsPage::HandleCheckEntry( SvTreeListEntry* _pEntry )
{ {
m_pJavaList->Select( _pEntry ); m_xJavaList->select(nCheckedRow);
SvButtonState eState = m_pJavaList->GetCheckButtonState( _pEntry ); for (int i = 0, nCount = m_xJavaList->n_children(); i < nCount; ++i)
if ( SvButtonState::Checked == eState )
{ {
// we have radio button behavior -> so uncheck the other entries // we have radio button behavior -> so uncheck the other entries
SvTreeListEntry* pEntry = m_pJavaList->First(); m_xJavaList->set_toggle(i, i == nCheckedRow ? TRISTATE_TRUE : TRISTATE_FALSE, 0);
while ( pEntry )
{
if ( pEntry != _pEntry )
m_pJavaList->SetCheckButtonState( pEntry, SvButtonState::Unchecked );
pEntry = m_pJavaList->Next( pEntry );
}
} }
else
m_pJavaList->SetCheckButtonState( _pEntry, SvButtonState::Checked );
} }
void SvxJavaOptionsPage::AddFolder( const OUString& _rFolder ) void SvxJavaOptionsPage::AddFolder( const OUString& _rFolder )
{ {
#if HAVE_FEATURE_JAVA #if HAVE_FEATURE_JAVA
@@ -526,25 +441,22 @@ void SvxJavaOptionsPage::AddFolder( const OUString& _rFolder )
jfw_addJRELocation( pInfo->sLocation ); jfw_addJRELocation( pInfo->sLocation );
AddJRE( pInfo.get() ); AddJRE( pInfo.get() );
m_aAddedInfos.push_back( std::move(pInfo) ); m_aAddedInfos.push_back( std::move(pInfo) );
nPos = m_pJavaList->GetEntryCount() - 1; nPos = m_xJavaList->n_children() - 1;
} }
SvTreeListEntry* pEntry = m_pJavaList->GetEntry( nPos ); HandleCheckEntry(nPos);
m_pJavaList->Select( pEntry );
m_pJavaList->SetCheckButtonState( pEntry, SvButtonState::Checked );
HandleCheckEntry( pEntry );
bStartAgain = false; bStartAgain = false;
} }
else if ( JFW_E_NOT_RECOGNIZED == eErr ) else if ( JFW_E_NOT_RECOGNIZED == eErr )
{ {
std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetDialogFrameWeld(),
VclMessageType::Warning, VclButtonsType::Ok, VclMessageType::Warning, VclButtonsType::Ok,
CuiResId(RID_SVXSTR_JRE_NOT_RECOGNIZED))); CuiResId(RID_SVXSTR_JRE_NOT_RECOGNIZED)));
xBox->run(); xBox->run();
} }
else if ( JFW_E_FAILED_VERSION == eErr ) else if ( JFW_E_FAILED_VERSION == eErr )
{ {
std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(), std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetDialogFrameWeld(),
VclMessageType::Warning, VclButtonsType::Ok, VclMessageType::Warning, VclButtonsType::Ok,
CuiResId(RID_SVXSTR_JRE_FAILED_VERSION))); CuiResId(RID_SVXSTR_JRE_FAILED_VERSION)));
xBox->run(); xBox->run();
@@ -561,16 +473,16 @@ void SvxJavaOptionsPage::AddFolder( const OUString& _rFolder )
#endif #endif
} }
void SvxJavaOptionsPage::RequestRestart( svtools::RestartReason eReason ) void SvxJavaOptionsPage::RequestRestart(svtools::RestartReason eReason)
{ {
if ( m_pParentDlg ) VclPtr<OfaTreeOptionsDialog> xParentDlg(static_cast<OfaTreeOptionsDialog*>(GetParentDialog()));
m_pParentDlg->SetNeedsRestart( eReason ); if (xParentDlg)
xParentDlg->SetNeedsRestart(eReason);
} }
VclPtr<SfxTabPage> SvxJavaOptionsPage::Create( TabPageParent pParent, const SfxItemSet* rAttrSet ) VclPtr<SfxTabPage> SvxJavaOptionsPage::Create( TabPageParent pParent, const SfxItemSet* rAttrSet )
{ {
return VclPtr<SvxJavaOptionsPage>::Create( pParent.pParent, *rAttrSet ); return VclPtr<SvxJavaOptionsPage>::Create( pParent, *rAttrSet );
} }
@@ -578,18 +490,18 @@ bool SvxJavaOptionsPage::FillItemSet( SfxItemSet* /*rCoreSet*/ )
{ {
bool bModified = false; bool bModified = false;
if ( m_pExperimentalCB->IsValueChangedFromSaved() ) if ( m_xExperimentalCB->get_state_changed_from_saved() )
{ {
SvtMiscOptions aMiscOpt; SvtMiscOptions aMiscOpt;
aMiscOpt.SetExperimentalMode( m_pExperimentalCB->IsChecked() ); aMiscOpt.SetExperimentalMode( m_xExperimentalCB->get_active() );
bModified = true; bModified = true;
RequestRestart( svtools::RESTART_REASON_EXP_FEATURES ); RequestRestart( svtools::RESTART_REASON_EXP_FEATURES );
} }
if ( m_pMacroCB->IsValueChangedFromSaved() ) if ( m_xMacroCB->get_state_changed_from_saved() )
{ {
SvtMiscOptions aMiscOpt; SvtMiscOptions aMiscOpt;
aMiscOpt.SetMacroRecorderMode( m_pMacroCB->IsChecked() ); aMiscOpt.SetMacroRecorderMode(m_xMacroCB->get_active());
bModified = true; bModified = true;
} }
@@ -613,10 +525,10 @@ bool SvxJavaOptionsPage::FillItemSet( SfxItemSet* /*rCoreSet*/ )
} }
} }
sal_uLong nCount = m_pJavaList->GetEntryCount(); sal_uInt32 nCount = m_xJavaList->n_children();
for ( sal_uLong i = 0; i < nCount; ++i ) for (sal_uInt32 i = 0; i < nCount; ++i)
{ {
if ( m_pJavaList->GetCheckButtonState( m_pJavaList->GetEntry(i) ) == SvButtonState::Checked ) if (m_xJavaList->get_toggle(i, 0) == TRISTATE_TRUE)
{ {
JavaInfo const * pInfo; JavaInfo const * pInfo;
if ( i < m_parJavaInfo.size() ) if ( i < m_parJavaInfo.size() )
@@ -649,9 +561,9 @@ bool SvxJavaOptionsPage::FillItemSet( SfxItemSet* /*rCoreSet*/ )
eErr = jfw_getEnabled( &bEnabled ); eErr = jfw_getEnabled( &bEnabled );
DBG_ASSERT( JFW_E_NONE == eErr, DBG_ASSERT( JFW_E_NONE == eErr,
"SvxJavaOptionsPage::FillItemSet(): error in jfw_getEnabled" ); "SvxJavaOptionsPage::FillItemSet(): error in jfw_getEnabled" );
if ( bEnabled != m_pJavaEnableCB->IsChecked() ) if ( bEnabled != m_xJavaEnableCB->get_active() )
{ {
eErr = jfw_setEnabled( m_pJavaEnableCB->IsChecked() ); eErr = jfw_setEnabled( m_xJavaEnableCB->get_active() );
DBG_ASSERT( JFW_E_NONE == eErr, DBG_ASSERT( JFW_E_NONE == eErr,
"SvxJavaOptionsPage::FillItemSet(): error in jfw_setEnabled" ); "SvxJavaOptionsPage::FillItemSet(): error in jfw_setEnabled" );
bModified = true; bModified = true;
@@ -674,17 +586,17 @@ void SvxJavaOptionsPage::Reset( const SfxItemSet* /*rSet*/ )
javaFrameworkError eErr = jfw_getEnabled( &bEnabled ); javaFrameworkError eErr = jfw_getEnabled( &bEnabled );
if ( eErr != JFW_E_NONE ) if ( eErr != JFW_E_NONE )
bEnabled = false; bEnabled = false;
m_pJavaEnableCB->Check( bEnabled ); m_xJavaEnableCB->set_active(bEnabled);
EnableHdl_Impl(m_pJavaEnableCB); EnableHdl_Impl(*m_xJavaEnableCB);
#else #else
m_pJavaEnableCB->Check( false ); m_xJavaEnableCB->set_active(false);
m_pJavaEnableCB->Disable(); m_xJavaEnableCB->set_sensitive(false);
#endif #endif
m_pExperimentalCB->Check( aMiscOpt.IsExperimentalMode() ); m_xExperimentalCB->set_active( aMiscOpt.IsExperimentalMode() );
m_pExperimentalCB->SaveValue(); m_xExperimentalCB->save_state();
m_pMacroCB->Check( aMiscOpt.IsMacroRecorderMode() ); m_xMacroCB->set_active(aMiscOpt.IsMacroRecorderMode());
m_pMacroCB->SaveValue(); m_xMacroCB->save_state();
m_aResetIdle.Start(); m_aResetIdle.Start();
} }

View File

@@ -53,19 +53,6 @@ class OfaTreeOptionsDialog;
class SvxJavaOptionsPage : public SfxTabPage class SvxJavaOptionsPage : public SfxTabPage
{ {
private: private:
VclPtr<CheckBox> m_pJavaEnableCB;
VclPtr<VclContainer> m_pJavaBox;
VclPtr<SvxJavaListBox> m_pJavaList;
VclPtr<FixedText> m_pJavaPathText;
VclPtr<PushButton> m_pAddBtn;
VclPtr<PushButton> m_pParameterBtn;
VclPtr<PushButton> m_pClassPathBtn;
VclPtr<PushButton> m_pExpertConfigBtn;
std::unique_ptr<SvxJavaParameterDlg> m_xParamDlg;
std::unique_ptr<SvxJavaClassPathDlg> m_xPathDlg;
VclPtr<OfaTreeOptionsDialog> m_pParentDlg;
#if HAVE_FEATURE_JAVA #if HAVE_FEATURE_JAVA
std::vector<std::unique_ptr<JavaInfo>> m_parJavaInfo; std::vector<std::unique_ptr<JavaInfo>> m_parJavaInfo;
std::vector<OUString> m_parParameters; std::vector<OUString> m_parParameters;
@@ -76,38 +63,54 @@ private:
OUString m_sAddDialogText; OUString m_sAddDialogText;
Idle m_aResetIdle; Idle m_aResetIdle;
VclPtr<CheckBox> m_pExperimentalCB; std::vector<std::unique_ptr<JavaInfo>> m_aAddedInfos;
VclPtr<CheckBox> m_pMacroCB;
std::vector<std::unique_ptr<JavaInfo>>
m_aAddedInfos;
rtl::Reference< ::svt::DialogClosedListener > xDialogListener; rtl::Reference< ::svt::DialogClosedListener > xDialogListener;
css::uno::Reference< css::ui::dialogs::XFolderPicker2 > xFolderPicker; css::uno::Reference< css::ui::dialogs::XFolderPicker2 > xFolderPicker;
DECL_LINK( EnableHdl_Impl, Button*, void); std::unique_ptr<weld::CheckButton> m_xJavaEnableCB;
DECL_LINK( CheckHdl_Impl, SvTreeListBox*, void ); std::unique_ptr<weld::TreeView> m_xJavaList;
DECL_LINK( SelectHdl_Impl, SvTreeListBox*, void); std::unique_ptr<weld::Label> m_xJavaPathText;
DECL_LINK( AddHdl_Impl, Button*, void); std::unique_ptr<weld::Button> m_xAddBtn;
DECL_LINK( ParameterHdl_Impl, Button*, void); std::unique_ptr<weld::Button> m_xParameterBtn;
DECL_LINK( ClassPathHdl_Impl, Button*, void); std::unique_ptr<weld::Button> m_xClassPathBtn;
DECL_LINK( ResetHdl_Impl, Timer *, void); std::unique_ptr<weld::Button> m_xExpertConfigBtn;
DECL_LINK( StartFolderPickerHdl, void *, void ); std::unique_ptr<SvxJavaParameterDlg> m_xParamDlg;
DECL_LINK( DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void ); std::unique_ptr<SvxJavaClassPathDlg> m_xPathDlg;
DECL_STATIC_LINK(SvxJavaOptionsPage, ExpertConfigHdl_Impl, Button*, void); std::unique_ptr<weld::CheckButton> m_xExperimentalCB;
std::unique_ptr<weld::CheckButton> m_xMacroCB;
std::unique_ptr<weld::Label> m_xAccessibilityText;
std::unique_ptr<weld::Label> m_xAddDialogText;
std::unique_ptr<weld::Widget> m_xJavaFrame;
DECL_LINK(EnableHdl_Impl, weld::Button&, void);
typedef std::pair<int, int> row_col;
DECL_LINK(CheckHdl_Impl, const row_col&, void);
DECL_LINK(SelectHdl_Impl, weld::TreeView&, void);
DECL_LINK(AddHdl_Impl, weld::Button&, void);
DECL_LINK(ParameterHdl_Impl, weld::Button&, void);
DECL_LINK(ClassPathHdl_Impl, weld::Button&, void);
DECL_LINK(ResetHdl_Impl, Timer *, void);
DECL_LINK(StartFolderPickerHdl, void *, void);
DECL_LINK(DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void);
DECL_LINK(ExpertConfigHdl_Impl, weld::Button&, void);
void ClearJavaInfo(); void ClearJavaInfo();
void ClearJavaList(); void ClearJavaList();
void LoadJREs(); void LoadJREs();
void AddJRE( JavaInfo const * _pInfo ); void AddJRE( JavaInfo const * _pInfo );
void HandleCheckEntry( SvTreeListEntry* _pEntry ); void HandleCheckEntry(int nCheckedRow);
void AddFolder( const OUString& _rFolder ); void AddFolder( const OUString& _rFolder );
void RequestRestart( svtools::RestartReason eReason ); void RequestRestart( svtools::RestartReason eReason );
public: public:
SvxJavaOptionsPage( vcl::Window* pParent, const SfxItemSet& rSet ); SvxJavaOptionsPage(TabPageParent pParent, const SfxItemSet& rSet);
virtual ~SvxJavaOptionsPage() override; virtual ~SvxJavaOptionsPage() override;
virtual void dispose() override; virtual void dispose() override;

View File

@@ -1,11 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.19.0 --> <!-- Generated with glade 3.22.1 -->
<interface domain="cui"> <interface domain="cui">
<requires lib="gtk+" version="3.18"/> <requires lib="gtk+" version="3.18"/>
<requires lib="LibreOffice" version="1.0"/> <object class="GtkTreeStore" id="liststore1">
<columns>
<!-- column-name check1 -->
<column type="gboolean"/>
<!-- column-name text -->
<column type="gchararray"/>
<!-- column-name text2 -->
<column type="gchararray"/>
<!-- column-name text3 -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
<!-- column-name checkvis1 -->
<column type="gboolean"/>
<!-- column-name checktri1 -->
<column type="gboolean"/>
</columns>
</object>
<object class="GtkBox" id="OptAdvancedPage"> <object class="GtkBox" id="OptAdvancedPage">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">18</property> <property name="spacing">18</property>
@@ -57,13 +76,13 @@
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="left_padding">12</property> <property name="left_padding">12</property>
<child> <child>
<object class="GtkBox" id="javabox"> <object class="GtkGrid" id="javabox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">12</property> <property name="row_spacing">12</property>
<child> <child>
<object class="GtkLabel" id="label2"> <object class="GtkLabel" id="label2">
<property name="visible">True</property> <property name="visible">True</property>
@@ -74,9 +93,8 @@
<property name="mnemonic_widget">javas</property> <property name="mnemonic_widget">javas</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="left_attach">0</property>
<property name="fill">True</property> <property name="top_attach">0</property>
<property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -142,96 +160,94 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkGrid" id="grid2"> <object class="GtkBox" id="box">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="orientation">vertical</property>
<child> <child>
<object class="GtkGrid" id="grid3"> <object class="GtkScrolledWindow" id="javasscroll">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="column_spacing">6</property>
<child>
<object class="GtkLabel" id="vendor">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="optadvancedpage|vendor">Vendor</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="version">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="optadvancedpage|version">Version</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="features">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="optadvancedpage|features">Features</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="a11y">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="optadvancedpage|a11y">with accessibility support</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="selectruntime">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="optadvancedpage|selectruntime">Select a Java Runtime Environment</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="svtlo-SvSimpleTableContainer" id="javas">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<child internal-child="selection"> <property name="shadow_type">in</property>
<object class="GtkTreeSelection" id="Simple Table Container-selection1"/> <child>
<object class="GtkTreeView" id="javas">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="model">liststore1</property>
<property name="search_column">0</property>
<property name="show_expanders">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="Macro Library List-selection2"/>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn4">
<property name="resizable">True</property>
<property name="spacing">6</property>
<property name="alignment">0.5</property>
<child>
<object class="GtkCellRendererToggle" id="cellrenderer5">
<property name="radio">True</property>
</object>
<attributes>
<attribute name="visible">4</attribute>
<attribute name="active">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn5">
<property name="resizable">True</property>
<property name="spacing">6</property>
<property name="title" translatable="yes" context="optadvancedpage|vendor">Vendor</property>
<child>
<object class="GtkCellRendererText" id="cellrenderer4"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<property name="resizable">True</property>
<property name="spacing">6</property>
<property name="title" translatable="yes" context="optadvancedpage|version">Version</property>
<child>
<object class="GtkCellRendererText" id="cellrenderer1"/>
<attributes>
<attribute name="text">2</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
<property name="resizable">True</property>
<property name="spacing">6</property>
<property name="title" translatable="yes" context="optadvancedpage|features">Features</property>
<child>
<object class="GtkCellRendererText" id="cellrenderer2"/>
<attributes>
<attribute name="text">3</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child> </child>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="expand">False</property>
<property name="top_attach">1</property> <property name="fill">True</property>
<property name="position">0</property>
</packing> </packing>
</child> </child>
</object> </object>
@@ -242,9 +258,8 @@
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="left_attach">0</property>
<property name="fill">True</property> <property name="top_attach">1</property>
<property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -255,16 +270,48 @@
<property name="xalign">0</property> <property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="left_attach">0</property>
<property name="fill">True</property> <property name="top_attach">2</property>
<property name="position">2</property> </packing>
</child>
<child>
<object class="GtkGrid" id="grid3">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="column_spacing">6</property>
<child>
<object class="GtkLabel" id="a11y">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="optadvancedpage|a11y">with accessibility support</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="selectruntime">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="optadvancedpage|selectruntime">Select a Java Runtime Environment</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
</packing> </packing>
</child> </child>
</object> </object>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
@@ -331,8 +378,8 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
</object> </object>
<packing> <packing>