include/unotools/VersionConfig.hxx                 |    4 +
 officecfg/registry/schema/org/openoffice/Setup.xcs |    8 +-
 sfx2/source/view/viewfrm.cxx                       |   62 +++++++++------------
 unotools/source/misc/VersionConfig.cxx             |    7 ++
 4 files changed, 41 insertions(+), 40 deletions(-)

New commits:
commit aadde5364767445a3ff539d6673a0201912d49db
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed May 28 17:17:59 2025 +0200
Commit:     Heiko Tietze <heiko.tie...@documentfoundation.org>
CommitDate: Thu May 29 07:49:29 2025 +0200

    Related tdf#166733 - Show Welcome dialog on the very first start only
    
    Product updates should trigger the WhatsNew flavor of the welcome
    dialog and only new installations the Welcome mode.
    
    Change-Id: I6071ec748d735b92dd0169772dcbddceffad4760
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185976
    Tested-by: Jenkins
    Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org>
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/include/unotools/VersionConfig.hxx 
b/include/unotools/VersionConfig.hxx
index 57aebd7c9ec1..2a935943a68b 100644
--- a/include/unotools/VersionConfig.hxx
+++ b/include/unotools/VersionConfig.hxx
@@ -19,4 +19,8 @@ namespace utl
  * current version of LibreOffice has been upgraded to a newer one.
  */
 bool UNOTOOLS_DLLPUBLIC isProductVersionUpgraded();
+/** This method is called to detect if the program is started the
+ *  very first time after a clean installation or a profile reset.
+ */
+bool UNOTOOLS_DLLPUBLIC isProductVersionNew();
 }
diff --git a/officecfg/registry/schema/org/openoffice/Setup.xcs 
b/officecfg/registry/schema/org/openoffice/Setup.xcs
index 4bbaa1c1ea56..de6740bdbf2f 100644
--- a/officecfg/registry/schema/org/openoffice/Setup.xcs
+++ b/officecfg/registry/schema/org/openoffice/Setup.xcs
@@ -307,13 +307,11 @@
         </info>
         <value>true</value>
       </prop>
-      <prop oor:name="WhatsNewDialog" oor:type="xs:boolean">
+      <prop oor:name="WhatsNewDialog" oor:type="xs:boolean" 
oor:nillable="false">
         <info>
-            <desc>Set to false to not show the WhatsNew dialog but the infobar.
-            Initial nil value is evaluated at the first start to show the
-            welcome dialog, and set to true in order to show the Whatsnew
-            information as a dialog rather than the simple infobar in case of 
false.</desc>
+            <desc>Set to false to not show the WhatsNew dialog but the 
infobar.</desc>
         </info>
+        <value>true</value>
       </prop>
     </group>
     <group oor:name="Office">
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 588b5fb3a7e2..c8b088b378a5 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -1648,49 +1648,41 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, 
const SfxHint& rHint )
                     bool bIsWhatsNewShown = false; //suppress tipoftheday if 
whatsnew was shown
 
                     static const bool bRunningUnitTest = 
o3tl::IsRunningUnitTest() || o3tl::IsRunningUITest();
-                    std::optional<bool> bShowWelcome = 
officecfg::Setup::Product::WhatsNewDialog::get(); // nil at first start = 
welcome dialog
-                    if (!bShowWelcome.has_value() && !IsInModalMode() && 
!bRunningUnitTest)
-                    {
-                        SfxAbstractDialogFactory* pFact = 
SfxAbstractDialogFactory::Create();
-                        ScopedVclPtr<SfxAbstractTabDialog> pDlg(
-                            
pFact->CreateWelcomeDialog(GetWindow().GetFrameWeld(), true));
-                        pDlg->Execute();
-
-                        std::shared_ptr<comphelper::ConfigurationChanges> 
batch(comphelper::ConfigurationChanges::create());
-                        officecfg::Setup::Product::WhatsNewDialog::set(true, 
batch); // true after first start = whatsnew dialog
-                        batch->commit();
-
-                        bIsWhatsNewShown = true;
-                    }
-
                     //what's new dialog
-                    static bool wantsWhatsNew = 
utl::isProductVersionUpgraded() && !IsInModalMode() && bShowWelcome.has_value();
+                    static bool wantsWhatsNew = 
officecfg::Setup::Product::WhatsNew::get()
+                                                && !IsInModalMode() && 
!bRunningUnitTest
+                                                && 
utl::isProductVersionUpgraded(); //sets isProductVersionNew
                     if (wantsWhatsNew)
                     {
                         wantsWhatsNew = false;
-                        if (officecfg::Setup::Product::WhatsNew::get())
+
+                        if (utl::isProductVersionNew()) //welcome dialog
                         {
-                            if (bShowWelcome)
-                            {
-                                SfxAbstractDialogFactory* pFact = 
SfxAbstractDialogFactory::Create();
-                                ScopedVclPtr<SfxAbstractTabDialog> pDlg(
-                                    
pFact->CreateWelcomeDialog(GetWindow().GetFrameWeld(), false));
-                                pDlg->Execute();
-                            }
-                            else
+                            SfxAbstractDialogFactory* pFact = 
SfxAbstractDialogFactory::Create();
+                            ScopedVclPtr<SfxAbstractTabDialog> pDlg(
+                                
pFact->CreateWelcomeDialog(GetWindow().GetFrameWeld(), true));
+                            pDlg->Execute();
+                        }
+                        else if 
(officecfg::Setup::Product::WhatsNewDialog::get()) //whatsnew dialog
+                        {
+                            SfxAbstractDialogFactory* pFact = 
SfxAbstractDialogFactory::Create();
+                            ScopedVclPtr<SfxAbstractTabDialog> pDlg(
+                                
pFact->CreateWelcomeDialog(GetWindow().GetFrameWeld(), false));
+                            pDlg->Execute();
+                        }
+                        else //whatsnew infobar
+                        {
+                            OUString sText(SfxResId(STR_WHATSNEW_TEXT));
+                            VclPtr<SfxInfoBarWindow> pInfoBar = 
AppendInfoBar(u"whatsnew"_ustr, u""_ustr, sText.replaceAll("
",""), InfobarType::INFO);
+                            if (pInfoBar)
                             {
-                                OUString sText(SfxResId(STR_WHATSNEW_TEXT));
-                                VclPtr<SfxInfoBarWindow> pInfoBar = 
AppendInfoBar(u"whatsnew"_ustr, u""_ustr, sText.replaceAll("
",""), InfobarType::INFO);
-                                if (pInfoBar)
-                                {
-                                    weld::Button& rWhatsNewButton = 
pInfoBar->addButton();
-                                    
rWhatsNewButton.set_label(SfxResId(STR_WHATSNEW_BUTTON));
-                                    rWhatsNewButton.connect_clicked(LINK(this, 
SfxViewFrame, WhatsNewHandler));
-                                }
+                                weld::Button& rWhatsNewButton = 
pInfoBar->addButton();
+                                
rWhatsNewButton.set_label(SfxResId(STR_WHATSNEW_BUTTON));
+                                rWhatsNewButton.connect_clicked(LINK(this, 
SfxViewFrame, WhatsNewHandler));
                             }
-                            bIsInfobarShown = true;
-                            bIsWhatsNewShown = true;
                         }
+                        bIsInfobarShown = true;
+                        bIsWhatsNewShown = true;
                     }
 
                     // show tip-of-the-day dialog if it due, but not if there 
is the impress modal template dialog
diff --git a/unotools/source/misc/VersionConfig.cxx 
b/unotools/source/misc/VersionConfig.cxx
index 80373ce73430..8b3887447ee7 100644
--- a/unotools/source/misc/VersionConfig.cxx
+++ b/unotools/source/misc/VersionConfig.cxx
@@ -21,9 +21,16 @@
 
 namespace utl
 {
+bool isProductVersionNew()
+{
+    static const bool bIsNew = 
!officecfg::Setup::Product::ooSetupLastVersion::get().has_value();
+    return bIsNew;
+}
+
 bool isProductVersionUpgraded()
 {
     static const bool bUpgraded = []() {
+        (void)isProductVersionNew(); //set variable above
         OUString sSetupVersion = utl::ConfigManager::getProductVersion();
         sal_Int32 iCurrent = o3tl::toInt32(o3tl::getToken(sSetupVersion, 0, 
'.')) * 10
                              + o3tl::toInt32(o3tl::getToken(sSetupVersion, 1, 
'.'));

Reply via email to