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

Tünde Tóth (via logerrit) logerrit at kemper.freedesktop.org
Sat Oct 12 08:01:29 UTC 2019


 sw/qa/extras/ooxmlexport/data/tdf127741.docx      |binary
 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx        |   10 +++++++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   24 +++++++++++-----------
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |    3 --
 4 files changed, 22 insertions(+), 15 deletions(-)

New commits:
commit 576611895e51186d38ddefa10ed8d66075d9de37
Author:     Tünde Tóth <tundeth at gmail.com>
AuthorDate: Tue Oct 8 13:58:44 2019 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Sat Oct 12 10:00:20 2019 +0200

    tdf#127741 DOCX import: format hyperlink with Default character style
    
    according to correct hyperlink handling, avoiding various editing
    and layout problems; "sticky" and not easily removable character style
    around the hyperlink and multiple blue hyperlink colors.
    
    Set also Visited/Unvisited link character styles when the style of
    the hyperlink is not the requested "Internet Link".
    
    Change-Id: I3d7ba8dd225c693cc9f521b37767cf1e1e09d7c0
    Reviewed-on: https://gerrit.libreoffice.org/80449
    Reviewed-by: László Németh <nemeth at numbertext.org>
    Tested-by: László Németh <nemeth at numbertext.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf127741.docx b/sw/qa/extras/ooxmlexport/data/tdf127741.docx
new file mode 100644
index 000000000000..1bedb9ade516
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf127741.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index 89028e3e7e24..59556249cfb5 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -834,6 +834,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf123628, "tdf123628.odt")
     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='InternetLink']/w:name", "val", "Hyperlink");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf127741, "tdf127741.docx")
+{
+    uno::Reference<text::XTextRange> xPara = getParagraph(1);
+    uno::Reference<beans::XPropertySet> xRun(getRun(xPara,1), uno::UNO_QUERY);
+    OUString unVisitedStyleName = getProperty<OUString>(xRun, "UnvisitedCharStyleName");
+    CPPUNIT_ASSERT(unVisitedStyleName.equalsIgnoreAsciiCase("Internet Link"));
+    OUString visitedStyleName = getProperty<OUString>(xRun, "VisitedCharStyleName");
+    CPPUNIT_ASSERT(visitedStyleName.equalsIgnoreAsciiCase("Visited Internet Link"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index f69b53fbf2fe..c2d087fe4d59 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1784,15 +1784,6 @@ void DomainMapper_Impl::appendTextPortion( const OUString& rString, const Proper
                 }
                 else
                 {
-                    if (IsOpenField() && GetTopFieldContext()->GetFieldId() == FIELD_HYPERLINK)
-                    {
-                        // It is content of hyperlink field. We need to create and remember
-                        // character style for later applying to hyperlink
-                        PropertyValueVector_t aProps = comphelper::sequenceToContainer< PropertyValueVector_t >(GetTopContext()->GetPropertyValues());
-                        OUString sHyperlinkStyleName = GetStyleSheetTable()->getOrCreateCharStyle(aProps, /*bAlwaysCreate=*/false);
-                        GetTopFieldContext()->SetHyperlinkStyle(sHyperlinkStyleName);
-                    }
-
 #if !defined(MACOSX) // TODO: check layout differences and support all platforms, if needed
                     sal_Int32 nPos;
                     OUString sDoubleSpace("  ");
@@ -5385,10 +5376,19 @@ void DomainMapper_Impl::PopFieldContext()
                                 }
                                 else
                                 {
-                                    if (!pContext->GetHyperlinkStyle().isEmpty())
+                                    uno::Any aAny = xCrsrProperties->getPropertyValue("CharStyleName");
+                                    OUString charStyle;
+                                    if (css::uno::fromAny(aAny, &charStyle))
                                     {
-                                        xCrsrProperties->setPropertyValue("VisitedCharStyleName", uno::makeAny(pContext->GetHyperlinkStyle()));
-                                        xCrsrProperties->setPropertyValue("UnvisitedCharStyleName", uno::makeAny(pContext->GetHyperlinkStyle()));
+                                        if(!charStyle.isEmpty() && charStyle.equalsIgnoreAsciiCase("Internet Link"))
+                                        {
+                                            xCrsrProperties->setPropertyValue("CharStyleName", uno::makeAny(OUString("Default Style")));
+                                        }
+                                        else
+                                        {
+                                            xCrsrProperties->setPropertyValue("VisitedCharStyleName", aAny);
+                                            xCrsrProperties->setPropertyValue("UnvisitedCharStyleName", aAny);
+                                        }
                                     }
                                 }
                             }
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index fb4fcaf03349..6f5aaedd1fed 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -149,7 +149,6 @@ class FieldContext : public virtual SvRefBase
     OUString m_sHyperlinkURL;
     /// A frame for the hyperlink when one exists.
     OUString m_sHyperlinkTarget;
-    OUString m_sHyperlinkStyle;
 
     FFDataHandler::Pointer_t m_pFFDataHandler;
     FormControlHelper::Pointer_t m_pFormControlHelper;
@@ -194,8 +193,6 @@ public:
     const OUString& GetHyperlinkURL() const { return m_sHyperlinkURL; }
     void SetHyperlinkTarget(const OUString& rTarget) { m_sHyperlinkTarget = rTarget; }
     const OUString& GetHyperlinkTarget() const { return m_sHyperlinkTarget; }
-    void  SetHyperlinkStyle(const OUString& rStyle) { m_sHyperlinkStyle = rStyle; }
-    const OUString& GetHyperlinkStyle() const { return m_sHyperlinkStyle; }
 
     void setFFDataHandler(FFDataHandler::Pointer_t pFFDataHandler) { m_pFFDataHandler = pFFDataHandler; }
     const FFDataHandler::Pointer_t& getFFDataHandler() const { return m_pFFDataHandler; }


More information about the Libreoffice-commits mailing list