summaryrefslogtreecommitdiff
path: root/cui/source/options/connpooloptions.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'cui/source/options/connpooloptions.cxx')
-rw-r--r--cui/source/options/connpooloptions.cxx76
1 files changed, 61 insertions, 15 deletions
diff --git a/cui/source/options/connpooloptions.cxx b/cui/source/options/connpooloptions.cxx
index 45ca5d9f3e07..f6321f2252b1 100644
--- a/cui/source/options/connpooloptions.cxx
+++ b/cui/source/options/connpooloptions.cxx
@@ -17,16 +17,16 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include "connpooloptions.hxx"
-#include <svtools/editbrowsebox.hxx>
#include "connpoolsettings.hxx"
#include <svl/eitem.hxx>
#include <svx/databaseregistrationui.hxx>
#include <strings.hrc>
#include <dialmgr.hxx>
-
-using ::svt::EditBrowseBox;
+#include <officecfg/Office/DataAccess.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
namespace offapp
{
@@ -48,28 +48,36 @@ namespace offapp
ConnectionPoolOptionsPage::ConnectionPoolOptionsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& _rAttrSet)
: SfxTabPage(pPage, pController, "cui/ui/connpooloptions.ui", "ConnPoolPage", &_rAttrSet)
- , m_sYes(CuiResId(RID_SVXSTR_YES))
- , m_sNo(CuiResId(RID_SVXSTR_NO))
+ , m_sYes(CuiResId(RID_CUISTR_YES))
+ , m_sNo(CuiResId(RID_CUISTR_NO))
, m_xEnablePooling(m_xBuilder->weld_check_button("connectionpooling"))
+ , m_xEnablePoolingImg(m_xBuilder->weld_widget("lockconnectionpooling"))
, m_xDriversLabel(m_xBuilder->weld_label("driverslabel"))
, m_xDriverList(m_xBuilder->weld_tree_view("driverlist"))
, m_xDriverLabel(m_xBuilder->weld_label("driverlabel"))
, m_xDriver(m_xBuilder->weld_label("driver"))
, m_xDriverPoolingEnabled(m_xBuilder->weld_check_button("enablepooling"))
+ , m_xDriverPoolingEnabledImg(m_xBuilder->weld_widget("lockenablepooling"))
, m_xTimeoutLabel(m_xBuilder->weld_label("timeoutlabel"))
, m_xTimeout(m_xBuilder->weld_spin_button("timeout"))
+ , m_xTimeoutImg(m_xBuilder->weld_widget("locktimeout"))
{
m_xDriverList->set_size_request(m_xDriverList->get_approximate_digit_width() * 60,
m_xDriverList->get_height_rows(15));
m_xDriverList->show();
- std::vector<int> aWidths;
- aWidths.push_back(m_xDriverList->get_approximate_digit_width() * 50);
- aWidths.push_back(m_xDriverList->get_approximate_digit_width() * 8);
+ std::vector<int> aWidths
+ {
+ o3tl::narrowing<int>(m_xDriverList->get_approximate_digit_width() * 50),
+ o3tl::narrowing<int>(m_xDriverList->get_approximate_digit_width() * 8)
+ };
m_xDriverList->set_column_fixed_widths(aWidths);
- m_xEnablePooling->connect_clicked( LINK(this, ConnectionPoolOptionsPage, OnEnabledDisabled) );
- m_xDriverPoolingEnabled->connect_clicked( LINK(this, ConnectionPoolOptionsPage, OnEnabledDisabled) );
+ css::uno::Reference < css::uno::XComponentContext > xContext(::comphelper::getProcessComponentContext());
+ m_xReadWriteAccess = css::configuration::ReadWriteAccess::create(xContext, "*");
+
+ m_xEnablePooling->connect_toggled( LINK(this, ConnectionPoolOptionsPage, OnEnabledDisabled) );
+ m_xDriverPoolingEnabled->connect_toggled( LINK(this, ConnectionPoolOptionsPage, OnEnabledDisabled) );
m_xDriverList->connect_changed(LINK(this, ConnectionPoolOptionsPage, OnDriverRowChanged));
m_xTimeout->connect_value_changed(LINK(this, ConnectionPoolOptionsPage, OnSpinValueChanged));
@@ -136,6 +144,8 @@ namespace offapp
const SfxBoolItem* pEnabled = _rSet.GetItem<SfxBoolItem>(SID_SB_POOLING_ENABLED);
OSL_ENSURE(pEnabled, "ConnectionPoolOptionsPage::implInitControls: missing the Enabled item!");
m_xEnablePooling->set_active(pEnabled == nullptr || pEnabled->GetValue());
+ m_xEnablePooling->set_sensitive(!officecfg::Office::DataAccess::ConnectionPool::EnablePooling::isReadOnly());
+ m_xEnablePoolingImg->set_visible(officecfg::Office::DataAccess::ConnectionPool::EnablePooling::isReadOnly());
m_xEnablePooling->save_state();
@@ -145,7 +155,7 @@ namespace offapp
UpdateDriverList(pDriverSettings->getSettings());
else
{
- OSL_FAIL("ConnectionPoolOptionsPage::implInitControls: missing the DriverTimeouts item!");
+ SAL_WARN("cui.options", "ConnectionPoolOptionsPage::implInitControls: missing the DriverTimeouts item!");
UpdateDriverList(DriverPoolingSettings());
}
saveDriverList();
@@ -159,6 +169,28 @@ namespace offapp
commitTimeoutField();
}
+ OUString ConnectionPoolOptionsPage::GetAllStrings()
+ {
+ OUString sAllStrings;
+ OUString labels[] = { "label1", "driverslabel", "driverlabel", "timeoutlabel", "driver" };
+
+ for (const auto& label : labels)
+ {
+ if (const auto& pString = m_xBuilder->weld_label(label))
+ sAllStrings += pString->get_label() + " ";
+ }
+
+ OUString checkButton[] = { "connectionpooling", "enablepooling" };
+
+ for (const auto& check : checkButton)
+ {
+ if (const auto& pString = m_xBuilder->weld_check_button(check))
+ sAllStrings += pString->get_label() + " ";
+ }
+
+ return sAllStrings.replaceAll("_", "");
+ }
+
bool ConnectionPoolOptionsPage::FillItemSet(SfxItemSet* _rSet)
{
commitTimeoutField();
@@ -211,6 +243,20 @@ namespace offapp
m_xDriverPoolingEnabled->set_active(currentSetting.bEnabled);
m_xTimeout->set_value(currentSetting.nTimeoutSeconds);
+ OUString aConfigPath = officecfg::Office::DataAccess::ConnectionPool::DriverSettings::path() + "/" + currentSetting.sName;
+ css::beans::Property aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName(aConfigPath + "/Enable");
+ bool bReadOnly = (aProperty.Attributes & css::beans::PropertyAttribute::READONLY) != 0;
+
+ m_xDriverPoolingEnabled->set_sensitive(!bReadOnly);
+ m_xDriverPoolingEnabledImg->set_visible(bReadOnly);
+
+ aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName(aConfigPath + "/Timeout");
+ bReadOnly = (aProperty.Attributes & css::beans::PropertyAttribute::READONLY) != 0;
+
+ m_xTimeout->set_sensitive(!bReadOnly);
+ m_xTimeoutLabel->set_sensitive(!bReadOnly);
+ m_xTimeoutImg->set_visible(bReadOnly);
+
OnEnabledDisabled(*m_xDriverPoolingEnabled);
}
}
@@ -224,7 +270,7 @@ namespace offapp
updateCurrentRow();
}
- IMPL_LINK( ConnectionPoolOptionsPage, OnEnabledDisabled, weld::Button&, rCheckBox, void )
+ IMPL_LINK( ConnectionPoolOptionsPage, OnEnabledDisabled, weld::Toggleable&, rCheckBox, void )
{
bool bGloballyEnabled = m_xEnablePooling->get_active();
bool bLocalDriverChanged = m_xDriverPoolingEnabled.get() == &rCheckBox;
@@ -237,13 +283,13 @@ namespace offapp
m_xDriverList->select(-1);
m_xDriverLabel->set_sensitive(bGloballyEnabled);
m_xDriver->set_sensitive(bGloballyEnabled);
- m_xDriverPoolingEnabled->set_sensitive(bGloballyEnabled);
+ m_xDriverPoolingEnabled->set_sensitive(bGloballyEnabled && !m_xDriverPoolingEnabledImg->get_visible());
}
else
OSL_ENSURE(bLocalDriverChanged, "ConnectionPoolOptionsPage::OnEnabledDisabled: where did this come from?");
- m_xTimeoutLabel->set_sensitive(bGloballyEnabled && m_xDriverPoolingEnabled->get_active());
- m_xTimeout->set_sensitive(bGloballyEnabled && m_xDriverPoolingEnabled->get_active());
+ m_xTimeoutLabel->set_sensitive(bGloballyEnabled && m_xDriverPoolingEnabled->get_active() && !m_xTimeoutImg->get_visible());
+ m_xTimeout->set_sensitive(bGloballyEnabled && m_xDriverPoolingEnabled->get_active() && !m_xTimeoutImg->get_visible());
if (bLocalDriverChanged)
{