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

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Fri Mar 26 16:59:59 UTC 2021


 sw/inc/strings.hrc                |    1 +
 sw/source/ui/index/swuiidxmrk.cxx |   32 ++++++++++++++++++++++++++++----
 2 files changed, 29 insertions(+), 4 deletions(-)

New commits:
commit 8136620ff432bf17815bef1f88c7531edb839d23
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Mar 26 16:58:44 2021 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Mar 26 17:59:14 2021 +0100

    sw define bibliography entry dialog: recognize file:// URLs
    
    Give them a separate type at a UI level, so later a file picker can be
    shown for the local file case.
    
    Change-Id: If0ed639ea3d196da70fded6d1eb606f1ef4f2082
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113161
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index 2ed7893eeda9..e234e3162949 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -759,6 +759,7 @@
 #define STR_AUTH_TYPE_CUSTOM3                   NC_("STR_AUTH_TYPE_CUSTOM3", "User-defined3")
 #define STR_AUTH_TYPE_CUSTOM4                   NC_("STR_AUTH_TYPE_CUSTOM4", "User-defined4")
 #define STR_AUTH_TYPE_CUSTOM5                   NC_("STR_AUTH_TYPE_CUSTOM5", "User-defined5")
+#define STR_AUTH_TYPE_LOCAL_FILE                NC_("STR_AUTH_TYPE_LOCAL_FILE", "Local file")
 #define STR_AUTH_FIELD_IDENTIFIER               NC_("STR_AUTH_FIELD_IDENTIFIER", "Short name")
 #define STR_AUTH_FIELD_AUTHORITY_TYPE           NC_("STR_AUTH_FIELD_AUTHORITY_TYPE", "Type")
 #define STR_AUTH_FIELD_ADDRESS                  NC_("STR_AUTH_FIELD_ADDRESS", "Address")
diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx
index 9ea9b3cf5e93..3a0805e3ebaa 100644
--- a/sw/source/ui/index/swuiidxmrk.cxx
+++ b/sw/source/ui/index/swuiidxmrk.cxx
@@ -47,6 +47,7 @@
 #include <fldbas.hxx>
 #include <strings.hrc>
 #include <svl/cjkoptions.hxx>
+#include <comphelper/fileurl.hxx>
 #include <ndtxt.hxx>
 #include <SwRewriter.hxx>
 
@@ -1530,11 +1531,28 @@ SwCreateAuthEntryDlg_Impl::SwCreateAuthEntryDlg_Impl(weld::Window* pParent,
             else
                 m_aOrigContainers.back()->move(m_xTypeListBox.get(), m_xRight.get());
 
-            for (int j = 0; j < AUTH_TYPE_END; j++)
-                m_xTypeListBox->append_text(SwAuthorityFieldType::GetAuthTypeName(static_cast<ToxAuthorityType>(j)));
+            for (int j = 0; j <= AUTH_TYPE_END; j++)
+            {
+                if (j < AUTH_TYPE_END)
+                {
+                    m_xTypeListBox->append_text(
+                        SwAuthorityFieldType::GetAuthTypeName(static_cast<ToxAuthorityType>(j)));
+                }
+                else
+                {
+                    // UI-only type: local file.
+                    m_xTypeListBox->append_text(SwResId(STR_AUTH_TYPE_LOCAL_FILE));
+                }
+            }
             if(!pFields[aCurInfo.nToxField].isEmpty())
             {
-                m_xTypeListBox->set_active(pFields[aCurInfo.nToxField].toInt32());
+                int nPos = pFields[aCurInfo.nToxField].toInt32();
+                if (nPos == AUTH_TYPE_WWW && comphelper::isFileUrl(pFields[AUTH_FIELD_URL]))
+                {
+                    // Map file URL to local file.
+                    nPos = AUTH_TYPE_END;
+                }
+                m_xTypeListBox->set_active(nPos);
             }
             m_xTypeListBox->set_grid_left_attach(1);
             m_xTypeListBox->set_grid_top_attach(bLeft ? nLeftRow : nRightRow);
@@ -1612,7 +1630,13 @@ OUString  SwCreateAuthEntryDlg_Impl::GetEntryText(ToxAuthorityField eField) cons
     if( AUTH_FIELD_AUTHORITY_TYPE == eField )
     {
         OSL_ENSURE(m_xTypeListBox, "No ListBox");
-        return OUString::number(m_xTypeListBox->get_active());
+        int nActive = m_xTypeListBox->get_active();
+        if (nActive == AUTH_TYPE_END)
+        {
+            // Map local file to file URL.
+            nActive = AUTH_TYPE_WWW;
+        }
+        return OUString::number(nActive);
     }
 
     if( AUTH_FIELD_IDENTIFIER == eField && !m_bNewEntryMode)


More information about the Libreoffice-commits mailing list