summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2019-10-04 11:47:57 +0300
committerMiklos Vajna <vmiklos@collabora.com>2021-03-05 10:50:15 +0100
commita56f3177fba49f2ead26f8f5a54e6d1c626d623b (patch)
treeabaf6c2f25fa3420d6c8733d079633a05a5da9de
parentNFC writerfilter: preparation for adding CharProps to GetAnyProperty (diff)
downloadcore-a56f3177fba49f2ead26f8f5a54e6d1c626d623b.tar.gz
core-a56f3177fba49f2ead26f8f5a54e6d1c626d623b.zip
related tdf#99602 writerfilter TODO: subscript - use CharStyle fontsize
GetAnyProperty was missing a check for character style properties. This patch depends on commit 875793d841165aaaaefa2c34b855e8f0f8a8c214 related tdf#99602 writerfilter TODO: subscript - use ParaStyle fontsize and on commit 5e97d1a57717f8dbf69b987d2bda8616972eec52 NFC writerfilter: preparation for adding CharProps to GetAnyProperty (cherry picked from commit 9b8052bba91ed616de77006cd0d3dee3965caece) Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport13.cxx Change-Id: I4e28589917e41fa545d5aab05f97a67502486136
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx31
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx4
2 files changed, 30 insertions, 5 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 6df5464e436b..ceb6d3fba0f3 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -704,7 +704,7 @@ const OUString DomainMapper_Impl::GetDefaultParaStyleName()
return m_sDefaultParaStyleName;
}
-uno::Any DomainMapper_Impl::GetPropertyFromStyleSheet(PropertyIds eId, StyleSheetEntryPtr pEntry, const bool bPara)
+uno::Any DomainMapper_Impl::GetPropertyFromStyleSheet(PropertyIds eId, StyleSheetEntryPtr pEntry, const bool bDocDefaults, const bool bPara)
{
while(pEntry.get( ) )
{
@@ -730,7 +730,7 @@ uno::Any DomainMapper_Impl::GetPropertyFromStyleSheet(PropertyIds eId, StyleShee
pEntry = pNewEntry;
}
// not found in style, try the document's DocDefault properties
- if ( bPara )
+ if ( bDocDefaults && bPara )
{
const PropertyMapPtr& pDefaultParaProps = GetStyleSheetTable()->GetDefaultParaProps();
if ( pDefaultParaProps )
@@ -740,7 +740,7 @@ uno::Any DomainMapper_Impl::GetPropertyFromStyleSheet(PropertyIds eId, StyleShee
return aProperty->second;
}
}
- if ( isCharacterProperty(eId) )
+ if ( bDocDefaults && isCharacterProperty(eId) )
{
const PropertyMapPtr& pDefaultCharProps = GetStyleSheetTable()->GetDefaultCharProps();
if ( pDefaultCharProps )
@@ -760,17 +760,40 @@ uno::Any DomainMapper_Impl::GetPropertyFromParaStyleSheet(PropertyIds eId)
pEntry = GetStyleSheetTable()->GetCurrentEntry();
else
pEntry = GetStyleSheetTable()->FindStyleSheetByConvertedStyleName(GetCurrentParaStyleName());
- return GetPropertyFromStyleSheet(eId, pEntry, /*bPara=*/true);
+ return GetPropertyFromStyleSheet(eId, pEntry, /*bDocDefaults=*/true, /*bPara=*/true);
+}
+
+uno::Any DomainMapper_Impl::GetPropertyFromCharStyleSheet(PropertyIds eId, const PropertyMapPtr& rContext)
+{
+ if ( m_bInStyleSheetImport || eId == PROP_CHAR_STYLE_NAME || !isCharacterProperty(eId) )
+ return uno::Any();
+
+ StyleSheetEntryPtr pEntry;
+ OUString sCharStyleName;
+ if ( GetAnyProperty(PROP_CHAR_STYLE_NAME, rContext) >>= sCharStyleName )
+ pEntry = GetStyleSheetTable()->FindStyleSheetByConvertedStyleName(sCharStyleName);
+ return GetPropertyFromStyleSheet(eId, pEntry, /*bDocDefaults=*/false, /*bPara=*/false);
}
uno::Any DomainMapper_Impl::GetAnyProperty(PropertyIds eId, const PropertyMapPtr& rContext)
{
+ // first look in directly applied attributes
if ( rContext )
{
boost::optional<PropertyMap::Property> aProperty = rContext->getProperty(eId);
if ( aProperty )
return aProperty->second;
}
+
+ // then look whether it was inherited from a directly applied character style
+ if ( eId != PROP_CHAR_STYLE_NAME && isCharacterProperty(eId) )
+ {
+ uno::Any aRet = GetPropertyFromCharStyleSheet(eId, rContext);
+ if ( aRet.hasValue() )
+ return aRet;
+ }
+
+ // then look in current paragraph style, and docDefaults
return GetPropertyFromParaStyleSheet(eId);
}
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index c02eb216c660..258398255fb1 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -709,9 +709,11 @@ public:
const OUString GetDefaultParaStyleName();
// specified style - including inherited properties. Indicate whether paragraph defaults should be checked.
- css::uno::Any GetPropertyFromStyleSheet(PropertyIds eId, StyleSheetEntryPtr pEntry, const bool bPara);
+ css::uno::Any GetPropertyFromStyleSheet(PropertyIds eId, StyleSheetEntryPtr pEntry, const bool bDocDefaults, const bool bPara);
// current paragraph style - including inherited properties
css::uno::Any GetPropertyFromParaStyleSheet(PropertyIds eId);
+ // context's character style - including inherited properties
+ css::uno::Any GetPropertyFromCharStyleSheet(PropertyIds eId, const PropertyMapPtr& rContext);
// get property first from the given context, or secondly via inheritance from styles/docDefaults
css::uno::Any GetAnyProperty(PropertyIds eId, const PropertyMapPtr& rContext);
void SetStyleSheetImport( bool bSet ) { m_bInStyleSheetImport = bSet;}