diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-09-28 09:37:10 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-09-28 10:27:20 +0200 |
commit | 05f863844d9a5613250e8d787e32752b270ec4d3 (patch) | |
tree | 8c8c0d5db30d3390346b586dd6ac4a91e3a34058 /xmloff | |
parent | 4dd6af856d574ad66ebb4b822a36ba70af9945e2 (diff) |
sw: paragraph styles: add ODT filter for a linked character style
And the same in the other direction: link a para style from a char
style.
With this, the ODT filter is on par with the DOCX one for this feature.
Change-Id: Idd994b933672ab47a5f87a75c92abc137d3c73b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122753
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/core/xmltoken.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/style/prstylei.cxx | 24 | ||||
-rw-r--r-- | xmloff/source/style/styleexp.cxx | 13 | ||||
-rw-r--r-- | xmloff/source/style/xmlstyle.cxx | 3 | ||||
-rw-r--r-- | xmloff/source/token/tokens.txt | 1 |
5 files changed, 43 insertions, 0 deletions
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index 1e682a39fcb1..52ecd9038cbb 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -3440,6 +3440,8 @@ namespace xmloff::token { TOKEN("rtl", XML_RTL ), TOKEN("symmetric", XML_SYMMETRIC ), + TOKEN("linked-style-name", XML_LINKED_STYLE_NAME ), + #if OSL_DEBUG_LEVEL > 0 { 0, nullptr, std::nullopt, XML_TOKEN_END } diff --git a/xmloff/source/style/prstylei.cxx b/xmloff/source/style/prstylei.cxx index e9ca87595f2b..5cd856b209e8 100644 --- a/xmloff/source/style/prstylei.cxx +++ b/xmloff/source/style/prstylei.cxx @@ -509,6 +509,30 @@ void XMLPropStyleContext::Finish( bool bOverwrite ) } } + // Connect linked style. + OUString aLinked(GetLinked()); + if (!aLinked.isEmpty()) + { + if (GetFamily() == XmlStyleFamily::TEXT_PARAGRAPH) + { + aLinked = GetImport().GetStyleDisplayName(XmlStyleFamily::TEXT_TEXT, aLinked); + } + else if (GetFamily() == XmlStyleFamily::TEXT_TEXT) + { + aLinked = GetImport().GetStyleDisplayName(XmlStyleFamily::TEXT_PARAGRAPH, aLinked); + } + } + if (!aLinked.isEmpty() && xPropSetInfo->hasPropertyByName("LinkStyle")) + { + uno::Any aAny = xPropSet->getPropertyValue("LinkStyle"); + OUString aCurrentLinked; + aAny >>= aCurrentLinked; + if (aCurrentLinked != aLinked) + { + xPropSet->setPropertyValue("LinkStyle", uno::Any(aLinked)); + } + } + if ( xPropSetInfo->hasPropertyByName( "Hidden" ) ) { xPropSet->setPropertyValue( "Hidden", uno::makeAny( IsHidden( ) ) ); diff --git a/xmloff/source/style/styleexp.cxx b/xmloff/source/style/styleexp.cxx index 2c628ffbda4d..1a3a81f10c95 100644 --- a/xmloff/source/style/styleexp.cxx +++ b/xmloff/source/style/styleexp.cxx @@ -237,6 +237,19 @@ bool XMLStyleExport::exportStyle( } } + // style:linked-style-name="..." (SW paragraph and character styles only) + if (xPropSetInfo->hasPropertyByName("LinkStyle")) + { + aAny = xPropSet->getPropertyValue("LinkStyle"); + OUString sLinkName; + aAny >>= sLinkName; + if (!sLinkName.isEmpty()) + { + GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_LINKED_STYLE_NAME, + GetExport().EncodeStyleName(sLinkName)); + } + } + // style:auto-update="..." (SW only) if( xPropSetInfo->hasPropertyByName( gsIsAutoUpdate ) ) { diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx index 38ec932fe132..00afedf82a39 100644 --- a/xmloff/source/style/xmlstyle.cxx +++ b/xmloff/source/style/xmlstyle.cxx @@ -88,6 +88,9 @@ void SvXMLStyleContext::SetAttribute( sal_Int32 nElement, case XML_ELEMENT(STYLE, XML_NEXT_STYLE_NAME): maFollow = rValue; break; + case XML_ELEMENT(LO_EXT, XML_LINKED_STYLE_NAME): + maLinked = rValue; + break; case XML_ELEMENT(STYLE, XML_HIDDEN): mbHidden = rValue.toBoolean(); break; diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt index f52e9c492db9..395dffe62cf1 100644 --- a/xmloff/source/token/tokens.txt +++ b/xmloff/source/token/tokens.txt @@ -3185,4 +3185,5 @@ movablelimits rspace rtl symmetric +linked-style-name TOKEN_END_DUMMY |