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

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Tue Apr 27 14:27:53 UTC 2021


 sw/source/ui/index/swuiidxmrk.cxx |   34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

New commits:
commit f6b419b8946c5fc2dafa8f4201a4c7379148f306
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Apr 27 11:29:18 2021 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Apr 27 16:27:10 2021 +0200

    sw bibliography, refer to a page: save edited page number
    
    This is the writing side of commit
    e920406994dd2b880d4b752e3ea4e09e4a8f97cc (sw bibliography, refer to a
    page: add dedicate widget to show the page number, 2021-04-21).
    
    Change-Id: If47932eedd689ca474bfdf44613d0c30087053b7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114664
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx
index 483fe01cf3aa..58cd9e0e2bc3 100644
--- a/sw/source/ui/index/swuiidxmrk.cxx
+++ b/sw/source/ui/index/swuiidxmrk.cxx
@@ -99,6 +99,31 @@ bool SplitUrlAndPage(const OUString& rText, OUString& rUrl, int& nPageNumber)
     rUrl = xUriRef->getUriReference();
     return true;
 }
+
+OUString MergeUrlAndPage(const OUString& rUrl, const std::unique_ptr<weld::SpinButton>& xPageSB)
+{
+    if (!xPageSB->get_sensitive())
+    {
+        return rUrl;
+    }
+
+    uno::Reference<uri::XUriReferenceFactory> xUriReferenceFactory
+        = uri::UriReferenceFactory::create(comphelper::getProcessComponentContext());
+    uno::Reference<uri::XUriReference> xUriRef;
+    try
+    {
+        xUriRef = xUriReferenceFactory->parse(rUrl);
+    }
+    catch (const uno::Exception& rException)
+    {
+        SAL_WARN("sw.ui", "MergeUrlAndPage: failed to parse url: " << rException.Message);
+        return rUrl;
+    }
+
+    OUString aFragment("page=" + OUString::number(xPageSB->get_value()));
+    xUriRef->setFragment(aFragment);
+    return xUriRef->getUriReference();
+}
 }
 
 // dialog to insert a directory selection
@@ -1732,7 +1757,14 @@ OUString  SwCreateAuthEntryDlg_Impl::GetEntryText(ToxAuthorityField eField) cons
         const TextInfo aCurInfo = aTextInfoArr[nIndex];
         if(aCurInfo.nToxField == eField)
         {
-            return pEdits[nIndex]->get_text();
+            if (aCurInfo.nToxField != AUTH_FIELD_URL)
+            {
+                return pEdits[nIndex]->get_text();
+            }
+            else
+            {
+                return MergeUrlAndPage(pEdits[nIndex]->get_text(), m_xPageSB);
+            }
         }
     }
 


More information about the Libreoffice-commits mailing list