[Libreoffice-commits] core.git: include/sfx2 sfx2/source sw/inc sw/source

Samuel Mehrbrodt (via logerrit) logerrit at kemper.freedesktop.org
Fri Dec 6 17:36:56 UTC 2019


 include/sfx2/infobar.hxx       |   10 ++++++++++
 include/sfx2/objsh.hxx         |    9 +++++++++
 sfx2/source/doc/objmisc.cxx    |   19 +++++++++++++++++++
 sfx2/source/doc/objxtor.cxx    |    1 +
 sfx2/source/inc/objshimp.hxx   |    3 +++
 sfx2/source/view/viewfrm.cxx   |   14 ++++++++++++++
 sw/inc/strings.hrc             |    2 ++
 sw/source/core/text/inftxt.cxx |   15 ++++++++++++---
 8 files changed, 70 insertions(+), 3 deletions(-)

New commits:
commit 506d8f1792cd004d97c6d3e84c21da10e68adf08
Author:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Tue Nov 19 09:18:11 2019 +0100
Commit:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Fri Dec 6 18:34:57 2019 +0100

    tdf#128191 Show infobar when hyphenation info for text language is missing
    
    During doc loading it's too early to add infobars,
    thus add a mechanism to display infobars once view is ready
    
    Change-Id: Ie963a304d2101a5bbdd59130c354d581ff7d2e9b
    Reviewed-on: https://gerrit.libreoffice.org/83161
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/include/sfx2/infobar.hxx b/include/sfx2/infobar.hxx
index a0dcdbd00f1d..80f4c0a0506c 100644
--- a/include/sfx2/infobar.hxx
+++ b/include/sfx2/infobar.hxx
@@ -26,6 +26,16 @@ enum class InfobarType {
     DANGER = 3
 };
 
+class InfobarData
+{
+    public:
+    OUString msId;
+    OUString msPrimaryMessage;
+    OUString msSecondaryMessage;
+    InfobarType maInfobarType;
+    bool mbShowCloseButton;
+};
+
 /** SfxChildWindow for positioning the InfoBar in the view.
   */
 class SFX2_DLLPUBLIC SfxInfoBarContainerChild final : public SfxChildWindow
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index d9d184383430..0352f2f1ac2a 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -62,9 +62,11 @@ class OutputDevice;
 class Color;
 class Fraction;
 class SvGlobalName;
+class InfobarData;
 
 enum class SfxModelFlags;
 enum class SfxEventHintId;
+enum class InfobarType;
 
 // These values presumably must match exactly the corresponding
 // css::embed::Aspects ones (in offapi/com/sun/star/embed/Aspects.idl)
@@ -651,6 +653,13 @@ public:
 
     static bool IsOwnStorageFormat(const SfxMedium &);
 
+    /** Append Infobar once the frame is ready.
+        Useful when you want to register an Infobar before the doc/frame is fully loaded. */
+    void AppendInfoBarWhenReady(const OUString& sId, const OUString& sPrimaryMessage,
+                                const OUString& sSecondaryMessage, InfobarType aInfobarType,
+                                bool bShowCloseButton = true);
+    std::vector<InfobarData>& getPendingInfobars();
+
     SAL_DLLPRIVATE std::shared_ptr<GDIMetaFile> CreatePreviewMetaFile_Impl(bool bFullContent) const;
 
     SAL_DLLPRIVATE static bool IsPackageStorageFormat_Impl(const SfxMedium &);
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index 4333b024d426..60bff6d9a0cd 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -113,6 +113,7 @@
 #include <sfx2/strings.hrc>
 #include <workwin.hxx>
 #include <sfx2/sfxdlg.hxx>
+#include <sfx2/infobar.hxx>
 #include <appbaslib.hxx>
 #include <openflag.hxx>
 #include "objstor.hxx"
@@ -206,6 +207,24 @@ void SfxObjectShell::FlushDocInfo()
                  (delay > 0) || !url.isEmpty() );
 }
 
+void SfxObjectShell::AppendInfoBarWhenReady(const OUString& sId, const OUString& sPrimaryMessage,
+                                          const OUString& sSecondaryMessage,
+                                          InfobarType aInfobarType, bool bShowCloseButton)
+{
+    InfobarData aInfobarData;
+    aInfobarData.msId = sId;
+    aInfobarData.msPrimaryMessage = sPrimaryMessage;
+    aInfobarData.msSecondaryMessage = sSecondaryMessage;
+    aInfobarData.maInfobarType = aInfobarType;
+    aInfobarData.mbShowCloseButton = bShowCloseButton;
+    Get_Impl()->m_aPendingInfobars.emplace_back(aInfobarData);
+}
+
+std::vector<InfobarData>& SfxObjectShell::getPendingInfobars()
+{
+    return Get_Impl()->m_aPendingInfobars;
+}
+
 void SfxObjectShell::SetError(ErrCode lErr)
 {
     if (pImpl->lErr==ERRCODE_NONE)
diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx
index d004c7a69e91..0632d1c6305a 100644
--- a/sfx2/source/doc/objxtor.cxx
+++ b/sfx2/source/doc/objxtor.cxx
@@ -99,6 +99,7 @@
 #include <sfx2/sfxuno.hxx>
 #include <shellimpl.hxx>
 #include <sfx2/notebookbar/SfxNotebookBar.hxx>
+#include <sfx2/infobar.hxx>
 
 #include <basic/basicmanagerrepository.hxx>
 
diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx
index 0492e26ed489..9ffb447bd272 100644
--- a/sfx2/source/inc/objshimp.hxx
+++ b/sfx2/source/inc/objshimp.hxx
@@ -130,6 +130,9 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess
     bool m_bSavingForSigning;
     bool m_bAllowModifiedBackAfterSigning;
 
+    /// Holds Infobars until View is fully loaded
+    std::vector<InfobarData> m_aPendingInfobars;
+
     SfxObjectShell_Impl( SfxObjectShell& _rDocShell );
     virtual ~SfxObjectShell_Impl();
 
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 8678b1ffeca7..223a02a7a8ab 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -1432,6 +1432,17 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
                     aHelper.UpdateInfobar(*this);
                 }
 
+                // Add pending infobars
+                std::vector<InfobarData>& aPendingInfobars = m_xObjSh->getPendingInfobars();
+                while (!aPendingInfobars.empty())
+                {
+                    InfobarData& aInfobarData = aPendingInfobars.back();
+                    AppendInfoBar(aInfobarData.msId, aInfobarData.msPrimaryMessage,
+                                  aInfobarData.msSecondaryMessage, aInfobarData.maInfobarType,
+                                  aInfobarData.mbShowCloseButton);
+                    aPendingInfobars.pop_back();
+                }
+
                 break;
             }
             default: break;
@@ -3292,6 +3303,9 @@ VclPtr<SfxInfoBarWindow> SfxViewFrame::AppendInfoBar(const OUString& sId,
     if (!pChild)
         return nullptr;
 
+    if (HasInfoBarWithID(sId))
+        return nullptr;
+
     SfxInfoBarContainerWindow* pInfoBarContainer = static_cast<SfxInfoBarContainerWindow*>(pChild->GetWindow());
     auto pInfoBar = pInfoBarContainer->appendInfoBar(sId, sPrimaryMessage, sSecondaryMessage,
                                                      aInfobarType, WB_LEFT | WB_VCENTER, bShowCloseButton);
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 1ef224407aa5..cc421939d2e2 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -385,6 +385,8 @@
 #define RID_STR_SYSTEM                          NC_("RID_STR_SYSTEM", "[System]")
 #define STR_MULT_INTERACT_HYPH_WARN             NC_("STR_MULT_INTERACT_HYPH_WARN", "The interactive hyphenation is already active\nin a different document")
 #define STR_HYPH_TITLE                          NC_("STR_HYPH_TITLE", "Hyphenation")
+#define STR_HYPH_MISSING                        NC_("STR_HYPH_MISSING", "Missing hyphenation info")
+#define STR_HYPH_MISSING_DETAIL                 NC_("STR_HYPH_MISSING", "Please install the hyphenation package for locale “%1”.")
 
 // Undo
 #define STR_CANT_UNDO                           NC_("STR_CANT_UNDO", "not possible")
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index f0933284feaa..9fc9116fe1e4 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -23,6 +23,7 @@
 #include <unotools/lingucfg.hxx>
 #include <hintids.hxx>
 #include <svl/ctloptions.hxx>
+#include <sfx2/infobar.hxx>
 #include <sfx2/printer.hxx>
 #include <sal/log.hxx>
 #include <editeng/hyphenzoneitem.hxx>
@@ -61,6 +62,8 @@
 #include <pam.hxx>
 #include <numrule.hxx>
 #include <EnhancedPDFExportHelper.hxx>
+#include <docsh.hxx>
+#include <strings.hrc>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::linguistic2;
@@ -1450,9 +1453,15 @@ bool SwTextFormatInfo::IsHyphenate() const
 
     if (!xHyph->hasLocale(g_pBreakIt->GetLocale(eTmp)))
     {
-        // TODO: Add an infobar for this case, tdf#128191
-        SAL_WARN("sw", "missing hyphenation package for locale: "
-                           << g_pBreakIt->GetLocale(eTmp).Language);
+        SfxObjectShell* pShell = m_pFrame->GetDoc().GetDocShell();
+        if (pShell)
+        {
+            pShell->AppendInfoBarWhenReady(
+                "hyphenationmissing", SwResId(STR_HYPH_MISSING),
+                SwResId(STR_HYPH_MISSING_DETAIL)
+                    .replaceFirst("%1", g_pBreakIt->GetLocale(eTmp).Language),
+                InfobarType::WARNING);
+        }
     }
 
     return xHyph->hasLocale( g_pBreakIt->GetLocale(eTmp) );


More information about the Libreoffice-commits mailing list