diff options
author | Vasily Melenchuk <Vasily.Melenchuk@cib.de> | 2017-08-18 22:14:08 +0300 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2017-11-10 02:20:31 +0100 |
commit | aad3a938f9bb929869ed50482c9e747079bbc69e (patch) | |
tree | 9858f1562c032e551784a5193a11eeca4fe4def5 /writerfilter | |
parent | 7d9938e315447629061dc1dbe057233e66579f91 (diff) |
tdf#43017: Support for DOCX hyperlinks character properties
Here goes a bunch of related changes:
1. Create new character style based on current character properties
2. Apply created style to hyperlink object
3. Fixes to predefined style names usage in w:rPr
4. Disable style usage for hyperlinks in TOC: they will receive later
anoter styles
Reviewed-on: https://gerrit.libreoffice.org/41784
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
(cherry picked from commit eaa9cf6a3069fba3d82c046f0041bfb537d9e648)
Conflicts:
sw/qa/extras/ooxmlimport/ooxmlimport.cxx
writerfilter/source/dmapper/DomainMapper_Impl.hxx
Change-Id: I1a228992eb7c1e259a6a811aa7f959debaae4f35
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 8 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 21 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.hxx | 17 |
3 files changed, 38 insertions, 8 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 46aef6bf81c7..eec33d46246f 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -2155,11 +2155,11 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) { OUString sConvertedName( m_pImpl->GetStyleSheetTable()->ConvertStyleName( sStringValue, true ) ); // First check if the style exists in the document. - StyleSheetEntryPtr pEntry = m_pImpl->GetStyleSheetTable( )->FindStyleSheetByStyleName( sConvertedName ); + StyleSheetEntryPtr pEntry = m_pImpl->GetStyleSheetTable( )->FindStyleSheetByConvertedStyleName( sConvertedName ); bool bExists = pEntry.get( ) && ( pEntry->nStyleTypeCode == STYLE_TYPE_CHAR ); - - // Add the property if the style exists - if ( bExists && m_pImpl->GetTopContext() ) + // Add the property if the style exists, but do not add it elements in TOC: + // they will receive later another style references from TOC + if ( bExists && m_pImpl->GetTopContext() && !m_pImpl->IsInTOC()) m_pImpl->GetTopContext()->Insert( PROP_CHAR_STYLE_NAME, uno::makeAny( sConvertedName ) ); } break; diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 19d6f1a82985..c5ca29a02510 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1283,7 +1283,18 @@ 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); + } + xTextRange = xTextAppend->appendTextPortion(rString, aValues); + } } CheckRedline( xTextRange ); @@ -3572,6 +3583,8 @@ void DomainMapper_Impl::CloseFieldCommand() aFieldConversionMap.find(std::get<0>(field)); if(aIt != aFieldConversionMap.end()) { + pContext->SetFieldId(aIt->second.eFieldId); + bool bCreateEnhancedField = false; uno::Reference< beans::XPropertySet > xFieldProperties; bool bCreateField = true; @@ -4547,6 +4560,14 @@ void DomainMapper_Impl::PopFieldContext() xCrsrProperties->setPropertyValue("VisitedCharStyleName",uno::makeAny(sDisplayName)); xCrsrProperties->setPropertyValue("UnvisitedCharStyleName",uno::makeAny(sDisplayName)); } + else + { + if (!pContext->GetHyperlinkStyle().isEmpty()) + { + xCrsrProperties->setPropertyValue("VisitedCharStyleName", uno::makeAny(pContext->GetHyperlinkStyle())); + xCrsrProperties->setPropertyValue("UnvisitedCharStyleName", uno::makeAny(pContext->GetHyperlinkStyle())); + } + } } else if(m_bStartGenericField) { diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index ad96d4c77ef9..49b61d261b61 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -137,19 +137,21 @@ public: * --------------------------------------------------*/ class FieldContext { - bool m_bFieldCommandCompleted; + bool m_bFieldCommandCompleted; css::uno::Reference<css::text::XTextRange> m_xStartRange; - OUString m_sCommand; + OUString m_sCommand; OUString m_sResult; + boost::optional<FieldId> m_eFieldId; bool m_bFieldLocked; css::uno::Reference<css::text::XTextField> m_xTextField; - css::uno::Reference<css::text::XFormField> m_xFormField; + css::uno::Reference<css::text::XFormField> m_xFormField; css::uno::Reference<css::beans::XPropertySet> m_xTOC; css::uno::Reference<css::beans::XPropertySet> m_xTC; // TOX entry css::uno::Reference<css::beans::XPropertySet> m_xCustomField; OUString m_sHyperlinkURL; + OUString m_sHyperlinkStyle; FFDataHandler::Pointer_t m_pFFDataHandler; FormControlHelper::Pointer_t m_pFormControlHelper; /// (Character) properties of the field itself. @@ -164,6 +166,9 @@ public: void AppendCommand(const OUString& rPart); const OUString& GetCommand() const {return m_sCommand; } + void SetFieldId(FieldId eFieldId ) { m_eFieldId = eFieldId; } + boost::optional<FieldId> GetFieldId() const { return m_eFieldId; } + void AppendResult(OUString const& rResult) { m_sResult += rResult; } const OUString& GetResult() const { return m_sResult; } @@ -188,6 +193,8 @@ public: void SetHyperlinkURL( const OUString& rURL ) { m_sHyperlinkURL = rURL; } const OUString& GetHyperlinkURL() { return m_sHyperlinkURL; } + void SetHyperlinkStyle(const OUString& rStyle) { m_sHyperlinkStyle = rStyle; } + const OUString& GetHyperlinkStyle() { return m_sHyperlinkStyle; } void setFFDataHandler(FFDataHandler::Pointer_t pFFDataHandler) { m_pFFDataHandler = pFFDataHandler; } const FFDataHandler::Pointer_t& getFFDataHandler() const { return m_pFFDataHandler; } @@ -204,7 +211,7 @@ struct TextAppendContext css::uno::Reference<css::text::XTextAppend> xTextAppend; css::uno::Reference<css::text::XTextRange> xInsertPosition; css::uno::Reference<css::text::XParagraphCursor> xCursor; - ParagraphPropertiesPtr pLastParagraphProperties; + ParagraphPropertiesPtr pLastParagraphProperties; TextAppendContext(const css::uno::Reference<css::text::XTextAppend>& xAppend, const css::uno::Reference<css::text::XTextCursor>& xCur) : xTextAppend(xAppend) @@ -679,6 +686,8 @@ public: void PopPageHeaderFooter(); bool IsInHeaderFooter() const { return m_bInHeaderFooterImport; } + bool IsInTOC() const { return m_bStartTOC; } + void PushFootOrEndnote( bool bIsFootnote ); void PopFootOrEndnote(); bool IsInFootOrEndnote() const { return m_bInFootOrEndnote; } |