[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - editeng/source

Muhammet Kara (via logerrit) logerrit at kemper.freedesktop.org
Thu Dec 19 06:37:34 UTC 2019


 editeng/source/editeng/impedit.cxx |   44 +++++++++++++++++++++++++++++++------
 1 file changed, 37 insertions(+), 7 deletions(-)

New commits:
commit dc456be2f315bacea4e65d63d3765a54b126cb86
Author:     Muhammet Kara <muhammet.kara at collabora.com>
AuthorDate: Thu Dec 19 08:32:57 2019 +0300
Commit:     Muhammet Kara <muhammet.kara at collabora.com>
CommitDate: Thu Dec 19 07:36:58 2019 +0100

    lok: Resolves: Calc - selecting a hyperlink doesn't show link in dialog
    
    Change-Id: Ic4264fad8035029ba6593c91fa57efa772d394ca
    Reviewed-on: https://gerrit.libreoffice.org/85468
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>

diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 384c44ea93b1..7b920638537c 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -867,6 +867,23 @@ void ImpEditView::CalcAnchorPoint()
     }
 }
 
+namespace
+{
+
+// Build JSON message to be sent to Online
+OString buildHyperlinkJSON(const OUString& sText, const OUString& sLink)
+{
+    boost::property_tree::ptree aTree;
+    aTree.put("text", sText);
+    aTree.put("link", sLink);
+    std::stringstream aStream;
+    boost::property_tree::write_json(aStream, aTree, false);
+
+    return OString(aStream.str().c_str()).trim();
+}
+
+} // End of anon namespace
+
 void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
 {
     // No ShowCursor in an empty View ...
@@ -1121,21 +1138,34 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
             }
             else
             {
+
                 // is cursor at a mispelled word ?
                 Reference< linguistic2::XSpellChecker1 >  xSpeller( pEditEngine->pImpEditEngine->GetSpeller() );
                 bool bIsWrong = xSpeller.is() && IsWrongSpelledWord(aPaM, /*bMarkIfWrong*/ false);
-
                 OString sHyperlink;
+
                 if (const SvxFieldItem* pFld = GetField(aPos, nullptr, nullptr))
                 {
                     if (auto pUrlField = dynamic_cast<const SvxURLField*>(pFld->GetField()))
                     {
-                        boost::property_tree::ptree aTree;
-                        aTree.put("text", pUrlField->GetRepresentation());
-                        aTree.put("link", pUrlField->GetURL());
-                        std::stringstream aStream;
-                        boost::property_tree::write_json(aStream, aTree, false);
-                        sHyperlink = OString(aStream.str().c_str()).trim();
+                        sHyperlink = buildHyperlinkJSON(pUrlField->GetRepresentation(), pUrlField->GetURL());
+                    }
+                }
+                else if (GetEditSelection().HasRange())
+                {
+                    EditView* pActiveView = GetEditViewPtr();
+
+                    if (pActiveView)
+                    {
+                        const SvxFieldItem* pFieldItem = pActiveView->GetFieldAtSelection();
+                        if (pFieldItem)
+                        {
+                            const SvxFieldData* pField = pFieldItem->GetField();
+                            if ( auto pUrlField = dynamic_cast<const SvxURLField*>( pField) )
+                            {
+                                sHyperlink = buildHyperlinkJSON(pUrlField->GetRepresentation(), pUrlField->GetURL());
+                            }
+                        }
                     }
                 }
 


More information about the Libreoffice-commits mailing list