cui/source/customize/CustomNotebookbarGenerator.cxx |    6 +++++-
 cui/source/customize/SvxNotebookbarConfigPage.cxx   |   13 +++++++++----
 2 files changed, 14 insertions(+), 5 deletions(-)

New commits:
commit 24e02d55b7602f0f3bc74656ecec54635ab09f96
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Sat Jul 8 11:29:11 2023 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Wed Jul 12 21:17:11 2023 +0200

    related tdf#148121 no custom notebookbar.ui file unless modified
    
    Copying the default notebookbar.ui into the user folder
    means that any future changes in future versions of LO
    will not be seen by the user until they again reset the notebookbar.
    
    Only if the user actually makes a modification
    should the file be created in the user's config folder.
    
    Certainly just opening tools - customize - notebookbar
    should not condemn the user to be stuck on some old
    configuration of the notebookbar.
    
    Change-Id: I888867a8df452ddce0b2b75ec28f2698ab7d443f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154220
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>

diff --git a/cui/source/customize/CustomNotebookbarGenerator.cxx 
b/cui/source/customize/CustomNotebookbarGenerator.cxx
index bae85525ebd6..ba5d881822fd 100644
--- a/cui/source/customize/CustomNotebookbarGenerator.cxx
+++ b/cui/source/customize/CustomNotebookbarGenerator.cxx
@@ -184,7 +184,11 @@ static xmlDocPtr notebookbarXMLParser(const OString& 
rDocName, const OString& rU
 
 void CustomNotebookbarGenerator::modifyCustomizedUIFile(const 
Sequence<OUString>& sUIItemProperties)
 {
-    OString sCustomizedUIPath = getSystemPath(getCustomizedUIPath());
+    const OUString sUIPath = getCustomizedUIPath();
+    if (osl::File(sUIPath).open(osl_File_OpenFlag_Read) != 
osl::FileBase::E_None)
+        createCustomizedUIFile();
+
+    const OString sCustomizedUIPath = getSystemPath(sUIPath);
     for (auto const& aValue : sUIItemProperties)
     {
         std::vector<OString> aProperties(aUIPropertiesCount);
diff --git a/cui/source/customize/SvxNotebookbarConfigPage.cxx 
b/cui/source/customize/SvxNotebookbarConfigPage.cxx
index 74e2e8009192..f44bc70d3dc0 100644
--- a/cui/source/customize/SvxNotebookbarConfigPage.cxx
+++ b/cui/source/customize/SvxNotebookbarConfigPage.cxx
@@ -142,7 +142,6 @@ void SvxNotebookbarConfigPage::Init()
     m_xTopLevelListBox->clear();
     m_xContentsListBox->clear();
     m_xSaveInListBox->clear();
-    CustomNotebookbarGenerator::createCustomizedUIFile();
     OUString sNotebookbarInterface = getFileName(m_sFileName);
 
     OUString sScopeName
@@ -181,9 +180,8 @@ short SvxNotebookbarConfigPage::QueryReset()
     int nValue = xQueryBox->run();
     if (nValue == RET_YES)
     {
-        OUString sOriginalUIPath = 
CustomNotebookbarGenerator::getOriginalUIPath();
-        OUString sCustomizedUIPath = 
CustomNotebookbarGenerator::getCustomizedUIPath();
-        osl::File::copy(sOriginalUIPath, sCustomizedUIPath);
+        osl::File::remove(CustomNotebookbarGenerator::getCustomizedUIPath());
+
         OUString sNotebookbarInterface = getFileName(m_sFileName);
         Sequence<OUString> sSequenceEntries;
         CustomNotebookbarGenerator::setCustomizedUIItem(sSequenceEntries, 
sNotebookbarInterface);
@@ -396,6 +394,13 @@ void SvxNotebookbarConfigPage::SelectElement()
     OString sUIFileUIPath = CustomNotebookbarGenerator::getSystemPath(
         CustomNotebookbarGenerator::getCustomizedUIPath());
     xmlDocPtr pDoc = xmlParseFile(sUIFileUIPath.getStr());
+    if (!pDoc)
+    {
+        sUIFileUIPath = CustomNotebookbarGenerator::getSystemPath(
+            CustomNotebookbarGenerator::getOriginalUIPath());
+        pDoc = xmlParseFile(sUIFileUIPath.getStr());
+    }
+
     if (!pDoc)
         return;
     xmlNodePtr pNodePtr = xmlDocGetRootElement(pDoc);

Reply via email to