summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2023-05-11 10:17:18 +0200
committerSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2023-05-15 13:31:35 +0200
commitefa965969c6d3dfe5745a535605a6b9a482a03bd (patch)
tree64b255dbdf4511393bab0b2a81df336de64c16ed /cui
parentd2756dbd9b11bdfbf1d576381b8f9846a6fb7070 (diff)
tdf#104005 Don't allow changing finalized properties
Change-Id: Ic9e42ba6aed2fadd0f28dfc6be0a639cdd16bb34 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151660 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
Diffstat (limited to 'cui')
-rw-r--r--cui/inc/strings.hrc1
-rw-r--r--cui/source/options/optaboutconfig.cxx53
-rw-r--r--cui/source/options/optaboutconfig.hxx3
-rw-r--r--cui/uiconfig/ui/aboutconfigdialog.ui21
4 files changed, 72 insertions, 6 deletions
diff --git a/cui/inc/strings.hrc b/cui/inc/strings.hrc
index 442ac515ef8c..98c6cc50b2d3 100644
--- a/cui/inc/strings.hrc
+++ b/cui/inc/strings.hrc
@@ -404,6 +404,7 @@
#define RID_CUISTR_CLICK_RESULT NC_("RID_CUISTR_CLICK_RESULT", "(Click on any test to view its resultant bitmap image)")
#define RID_CUISTR_ZIPFAIL NC_("RID_CUISTR_ZIPFAIL", "Creation of ZIP file failed.")
#define RID_CUISTR_SAVED NC_("RID_CUISTR_SAVED", "The results have been successfully saved in the file 'GraphicTestResults.zip'!")
+#define RID_CUISTR_OPT_READONLY NC_("RID_CUISTR_OPT_READONLY", "This property is locked for editing.")
#define RID_LANGUAGETOOL_LEAVE_EMPTY NC_("RID_LANGUAGETOOL_LEAVE_EMPTY", "Leave this field empty to use the free version")
diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx
index 0914310f2800..4578bc027581 100644
--- a/cui/source/options/optaboutconfig.cxx
+++ b/cui/source/options/optaboutconfig.cxx
@@ -16,8 +16,10 @@
#include <com/sun/star/configuration/theDefaultProvider.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/beans/UnknownPropertyException.hpp>
#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/configuration/ReadWriteAccess.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/container/XNameReplace.hpp>
#include <com/sun/star/container/XHierarchicalName.hpp>
@@ -35,6 +37,9 @@
#include <sal/log.hxx>
#include <comphelper/diagnose_ex.hxx>
+#include <dialmgr.hxx>
+#include <strings.hrc>
+
#include <algorithm>
#include <memory>
#include <vector>
@@ -63,18 +68,21 @@ struct Prop_Impl
struct UserData
{
bool bIsPropertyPath;
+ bool bIsReadOnly;
OUString sPropertyPath;
int aLineage;
Reference<XNameAccess> aXNameAccess;
- explicit UserData( OUString aPropertyPath )
+ explicit UserData( OUString aPropertyPath, bool isReadOnly )
: bIsPropertyPath( true )
+ , bIsReadOnly( isReadOnly )
, sPropertyPath(std::move(aPropertyPath))
, aLineage(0)
{}
explicit UserData( Reference<XNameAccess> const & rXNameAccess, int rIndex )
: bIsPropertyPath( false )
+ , bIsReadOnly( false )
, aLineage(rIndex)
, aXNameAccess( rXNameAccess )
{}
@@ -171,6 +179,19 @@ CuiAboutConfigTabPage::CuiAboutConfigTabPage(weld::Window* pParent)
o3tl::narrowing<int>(fWidth * 8)
};
m_xPrefBox->set_column_fixed_widths(aWidths);
+
+ m_xPrefBox->connect_query_tooltip(LINK(this, CuiAboutConfigTabPage, QueryTooltip));
+}
+
+IMPL_LINK(CuiAboutConfigTabPage, QueryTooltip, const weld::TreeIter&, rIter, OUString)
+{
+ UserData *pUserData = weld::fromId<UserData*>(m_xPrefBox->get_id(rIter));
+ if (pUserData && pUserData->bIsReadOnly)
+ {
+ return CuiResId(RID_CUISTR_OPT_READONLY);
+ }
+
+ return OUString();
}
IMPL_LINK(CuiAboutConfigTabPage, HeaderBarClick, int, nColumn, void)
@@ -210,9 +231,9 @@ CuiAboutConfigTabPage::~CuiAboutConfigTabPage()
void CuiAboutConfigTabPage::InsertEntry(const OUString& rPropertyPath, const OUString& rProp, const OUString& rStatus,
const OUString& rType, const OUString& rValue, const weld::TreeIter* pParentEntry,
- bool bInsertToPrefBox)
+ bool bInsertToPrefBox, bool bIsReadOnly)
{
- m_vectorUserData.push_back(std::make_unique<UserData>(rPropertyPath));
+ m_vectorUserData.push_back(std::make_unique<UserData>(rPropertyPath, bIsReadOnly));
if (bInsertToPrefBox)
{
OUString sId(weld::toId(m_vectorUserData.back().get()));
@@ -220,6 +241,7 @@ void CuiAboutConfigTabPage::InsertEntry(const OUString& rPropertyPath, const OUS
m_xPrefBox->set_text(*m_xScratchIter, rStatus, 1);
m_xPrefBox->set_text(*m_xScratchIter, rType, 2);
m_xPrefBox->set_text(*m_xScratchIter, rValue, 3);
+ m_xPrefBox->set_sensitive(*m_xScratchIter, !bIsReadOnly, -1);
}
else
{
@@ -304,6 +326,7 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces
m_xPrefBox->set_text(*m_xScratchIter, "", 1);
m_xPrefBox->set_text(*m_xScratchIter, "", 2);
m_xPrefBox->set_text(*m_xScratchIter, "", 3);
+ m_xPrefBox->set_sensitive(*m_xScratchIter, true);
}
}
else
@@ -318,6 +341,22 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces
}
);
+ css::uno::Reference<css::configuration::XReadWriteAccess> m_xReadWriteAccess;
+ m_xReadWriteAccess = css::configuration::ReadWriteAccess::create(
+ ::comphelper::getProcessComponentContext(), "*");
+ beans::Property aProperty;
+ bool bReadOnly = false;
+ try
+ {
+ aProperty = m_xReadWriteAccess->getPropertyByHierarchicalName(sPath + "/"
+ + sPropertyName);
+ bReadOnly = (aProperty.Attributes & beans::PropertyAttribute::READONLY) != 0;
+ }
+ catch (css::beans::UnknownPropertyException)
+ {
+ SAL_WARN("cui.options", "unknown property: " << sPath + "/" + sPropertyName);
+ }
+
OUString sType = aNode.getValueTypeName();
OUStringBuffer sValue;
@@ -479,7 +518,8 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces
for(int j = 1; j < lineage; ++j)
index = sPath.indexOf("/", index + 1);
- InsertEntry(sPath, sPath.copy(index+1), item, sType, sValue.makeStringAndClear(), pParentEntry, !bLoadAll);
+ InsertEntry(sPath, sPath.copy(index + 1), item, sType, sValue.makeStringAndClear(),
+ pParentEntry, !bLoadAll, bReadOnly);
}
}
}
@@ -582,7 +622,7 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl, weld::Button&, void )
return;
UserData *pUserData = weld::fromId<UserData*>(m_xPrefBox->get_id(*m_xScratchIter));
- if (!(pUserData && pUserData->bIsPropertyPath))
+ if (!pUserData || !pUserData->bIsPropertyPath || pUserData->bIsReadOnly)
return;
//if selection is a node
@@ -903,6 +943,7 @@ void CuiAboutConfigTabPage::InsertEntry(const prefBoxEntry& rEntry)
m_xPrefBox->set_text(*m_xScratchIter, rEntry.sStatus, 1);
m_xPrefBox->set_text(*m_xScratchIter, rEntry.sType, 2);
m_xPrefBox->set_text(*m_xScratchIter, rEntry.sValue, 3);
+ m_xPrefBox->set_sensitive(*m_xScratchIter, !rEntry.pUserData->bIsReadOnly);
return;
}
OUString sParentName = sPath.copy(prevIndex+1, index - prevIndex - 1);
@@ -937,6 +978,7 @@ void CuiAboutConfigTabPage::InsertEntry(const prefBoxEntry& rEntry)
m_xPrefBox->set_text(*xParentEntry, "", 1);
m_xPrefBox->set_text(*xParentEntry, "", 2);
m_xPrefBox->set_text(*xParentEntry, "", 3);
+ m_xPrefBox->set_sensitive(*xParentEntry, true);
}
xGrandParentEntry = m_xPrefBox->make_iterator(xParentEntry.get());
@@ -947,6 +989,7 @@ void CuiAboutConfigTabPage::InsertEntry(const prefBoxEntry& rEntry)
m_xPrefBox->set_text(*m_xScratchIter, rEntry.sStatus, 1);
m_xPrefBox->set_text(*m_xScratchIter, rEntry.sType, 2);
m_xPrefBox->set_text(*m_xScratchIter, rEntry.sValue, 3);
+ m_xPrefBox->set_sensitive(*m_xScratchIter, !rEntry.pUserData->bIsReadOnly);
}
IMPL_LINK(CuiAboutConfigTabPage, ExpandingHdl_Impl, const weld::TreeIter&, rEntry, bool)
diff --git a/cui/source/options/optaboutconfig.hxx b/cui/source/options/optaboutconfig.hxx
index 64443bcff8cc..6cbb76e4cbde 100644
--- a/cui/source/options/optaboutconfig.hxx
+++ b/cui/source/options/optaboutconfig.hxx
@@ -55,6 +55,7 @@ private:
static std::vector< OUString > commaStringToSequence( std::u16string_view rCommaSepString );
void InsertEntry(const prefBoxEntry& rEntry);
+ DECL_LINK(QueryTooltip, const weld::TreeIter& rIter, OUString);
DECL_LINK(StandardHdl_Impl, weld::Button&, void);
DECL_LINK(DoubleClickHdl_Impl, weld::TreeView&, bool);
DECL_LINK(ResetBtnHdl_Impl, weld::Button&, void);
@@ -66,7 +67,7 @@ public:
explicit CuiAboutConfigTabPage(weld::Window* pParent);
virtual ~CuiAboutConfigTabPage() override;
void InsertEntry(const OUString &rPropertyPath, const OUString& rProp, const OUString& rStatus, const OUString& rType, const OUString& rValue,
- const weld::TreeIter* pParentEntry, bool bInsertToPrefBox);
+ const weld::TreeIter* pParentEntry, bool bInsertToPrefBox, bool bIsReadOnly);
void Reset();
void FillItems(const css::uno::Reference<css::container::XNameAccess>& xNameAccess,
const weld::TreeIter* pParentEntry = nullptr, int lineage = 0, bool bLoadAll = false);
diff --git a/cui/uiconfig/ui/aboutconfigdialog.ui b/cui/uiconfig/ui/aboutconfigdialog.ui
index c6613a74acaa..0d930df1fcc7 100644
--- a/cui/uiconfig/ui/aboutconfigdialog.ui
+++ b/cui/uiconfig/ui/aboutconfigdialog.ui
@@ -16,6 +16,22 @@
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
+ <!-- column-name weight1 -->
+ <column type="gint"/>
+ <!-- column-name weight2 -->
+ <column type="gint"/>
+ <!-- column-name weight3 -->
+ <column type="gint"/>
+ <!-- column-name weight4 -->
+ <column type="gint"/>
+ <!-- column-name sensitive1 -->
+ <column type="gboolean"/>
+ <!-- column-name sensitive2 -->
+ <column type="gboolean"/>
+ <!-- column-name sensitive3 -->
+ <column type="gboolean"/>
+ <!-- column-name sensitive4 -->
+ <column type="gboolean"/>
</columns>
</object>
<object class="GtkDialog" id="AboutConfig">
@@ -194,6 +210,7 @@
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
+ <property name="has-tooltip">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="model">liststore1</property>
@@ -217,6 +234,7 @@
<child>
<object class="GtkCellRendererText" id="cellrenderertext2"/>
<attributes>
+ <attribute name="sensitive">10</attribute>
<attribute name="text">1</attribute>
</attributes>
</child>
@@ -231,6 +249,7 @@
<child>
<object class="GtkCellRendererText" id="cellrenderertext3"/>
<attributes>
+ <attribute name="sensitive">11</attribute>
<attribute name="text">2</attribute>
</attributes>
</child>
@@ -245,6 +264,7 @@
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
+ <attribute name="sensitive">12</attribute>
<attribute name="text">3</attribute>
</attributes>
</child>
@@ -259,6 +279,7 @@
<child>
<object class="GtkCellRendererText" id="cellrenderertext5"/>
<attributes>
+ <attribute name="sensitive">13</attribute>
<attribute name="text">4</attribute>
</attributes>
</child>