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@numbertext.org> Tested-by: László Németh <nemeth@numbertext.org>
This commit is contained in:
committed by
László Németh
parent
d416250f4f
commit
576611895e
Binary file not shown.
@@ -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: */
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
|
||||
Reference in New Issue
Block a user