[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - oox/inc oox/source
Sarper Akdemir (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jun 23 21:29:55 UTC 2021
oox/inc/drawingml/textbody.hxx | 6 +++
oox/inc/drawingml/textcharacterproperties.hxx | 4 ++
oox/inc/drawingml/textparagraph.hxx | 6 +++
oox/inc/drawingml/textrun.hxx | 6 +++
oox/source/drawingml/textbody.cxx | 10 ++++++
oox/source/drawingml/textcharacterpropertiescontext.cxx | 26 +++++++++++++++-
oox/source/drawingml/textparagraph.cxx | 10 ++++++
7 files changed, 67 insertions(+), 1 deletion(-)
New commits:
commit 089fd68f1974908675d6a0b084fbab7db314d44a
Author: Sarper Akdemir <sarper.akdemir at collabora.com>
AuthorDate: Sun May 9 20:17:20 2021 +0300
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Wed Jun 23 23:29:12 2021 +0200
tdf#59323: ooxml import: hasVisualRunProperties
Introduces helper functions to determine whether a shape has non inherited run
properties that change it visually.
mbHasVisualRunProperties is set on import if there was a run property that
alters visual appearance.
Change-Id: Ie1e8e22d2757dc8594e7c6c3b8fc1dd7973c92af
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117004
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117531
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/oox/inc/drawingml/textbody.hxx b/oox/inc/drawingml/textbody.hxx
index 8cc3a70b254a..f09380d632a1 100644
--- a/oox/inc/drawingml/textbody.hxx
+++ b/oox/inc/drawingml/textbody.hxx
@@ -68,6 +68,12 @@ public:
bool isEmpty() const;
OUString toString() const;
+ /** Returns whether the textbody had a rPr tag in it that alters it visually
+ *
+ * For instance _lang_ doesn't have a visual effect.
+ */
+ bool hasVisualRunProperties() const;
+
void ApplyStyleEmpty(
const ::oox::core::XmlFilterBase& rFilterBase,
const css::uno::Reference < css::text::XText > & xText,
diff --git a/oox/inc/drawingml/textcharacterproperties.hxx b/oox/inc/drawingml/textcharacterproperties.hxx
index a034121e47d0..147a9847781d 100644
--- a/oox/inc/drawingml/textcharacterproperties.hxx
+++ b/oox/inc/drawingml/textcharacterproperties.hxx
@@ -59,6 +59,8 @@ struct TextCharacterProperties
OptValue< bool > moUnderlineLineFollowText;
OptValue< bool > moUnderlineFillFollowText;
FillProperties maFillProperties;
+ /// Set if there was a property set that alters run visually during import
+ bool mbHasVisualRunProperties;
std::vector<css::beans::PropertyValue> maTextEffectsProperties;
@@ -79,6 +81,8 @@ struct TextCharacterProperties
void pushToPropSet(
PropertySet& rPropSet,
const ::oox::core::XmlFilterBase& rFilter ) const;
+
+ TextCharacterProperties() : mbHasVisualRunProperties(false) {}
};
diff --git a/oox/inc/drawingml/textparagraph.hxx b/oox/inc/drawingml/textparagraph.hxx
index ec0d57686e1b..4e3abab18a90 100644
--- a/oox/inc/drawingml/textparagraph.hxx
+++ b/oox/inc/drawingml/textparagraph.hxx
@@ -78,6 +78,12 @@ public:
}
formulaimport::XmlStreamBuilder & GetMathXml();
+ /** Returns whether textparagraph had a rPr tag in it that alters it visually
+ *
+ * For instance _lang_ doesn't have a visual effect.
+ */
+ bool hasVisualRunProperties() const;
+
private:
TextParagraphProperties maProperties;
TextCharacterProperties maEndProperties;
diff --git a/oox/inc/drawingml/textrun.hxx b/oox/inc/drawingml/textrun.hxx
index 8d3e2c499bc6..4df18764ea08 100644
--- a/oox/inc/drawingml/textrun.hxx
+++ b/oox/inc/drawingml/textrun.hxx
@@ -43,6 +43,12 @@ public:
void setLineBreak() { mbIsLineBreak = true; }
bool isLineBreak() const { return mbIsLineBreak; }
+ /** Returns whether the textrun had properties that alter it visually in its rPr tag
+ *
+ * For instance _lang_ doesn't have a visual effect.
+ */
+ bool hasVisualRunProperties() const { return maTextCharacterProperties.mbHasVisualRunProperties; }
+
virtual sal_Int32 insertAt(
const ::oox::core::XmlFilterBase& rFilterBase,
const css::uno::Reference < css::text::XText >& xText,
diff --git a/oox/source/drawingml/textbody.cxx b/oox/source/drawingml/textbody.cxx
index 80ebb4d2287d..2a4d89de4030 100644
--- a/oox/source/drawingml/textbody.cxx
+++ b/oox/source/drawingml/textbody.cxx
@@ -104,6 +104,16 @@ OUString TextBody::toString() const
return OUString();
}
+bool TextBody::hasVisualRunProperties() const
+{
+ for ( auto& pTextParagraph : getParagraphs() )
+ {
+ if ( pTextParagraph->hasVisualRunProperties() )
+ return true;
+ }
+ return false;
+}
+
void TextBody::ApplyStyleEmpty(
const ::oox::core::XmlFilterBase& rFilterBase,
const Reference < XText > & xText,
diff --git a/oox/source/drawingml/textcharacterpropertiescontext.cxx b/oox/source/drawingml/textcharacterpropertiescontext.cxx
index 236219d844cf..2bc7be3633c1 100644
--- a/oox/source/drawingml/textcharacterpropertiescontext.cxx
+++ b/oox/source/drawingml/textcharacterpropertiescontext.cxx
@@ -29,6 +29,8 @@
#include "hyperlinkcontext.hxx"
#include <oox/token/namespaces.hxx>
#include <oox/token/tokens.hxx>
+#include <sax/fastattribs.hxx>
+#include <sax/fastparser.hxx>
#include <sal/log.hxx>
@@ -47,8 +49,16 @@ TextCharacterPropertiesContext::TextCharacterPropertiesContext(
: ContextHandler2( rParent )
, mrTextCharacterProperties( rTextCharacterProperties )
{
- if ( rAttribs.hasAttribute( XML_lang ) )
+ int nVisualTokenAmount = sax_fastparser::FastAttributeList::castToFastAttributeList(
+ rAttribs.getFastAttributeList() )->getFastAttributeTokens().size();
+
+ if ( rAttribs.hasAttribute( XML_lang ) ){
mrTextCharacterProperties.moLang = rAttribs.getString( XML_lang );
+ --nVisualTokenAmount; // Not a visual attribute
+ }
+ if ( rAttribs.hasAttribute( XML_altLang )){
+ --nVisualTokenAmount; // Not a visual attribute
+ }
if ( rAttribs.hasAttribute( XML_sz ) )
mrTextCharacterProperties.moHeight = rAttribs.getInteger( XML_sz );
if ( rAttribs.hasAttribute( XML_spc ) )
@@ -66,6 +76,17 @@ TextCharacterPropertiesContext::TextCharacterPropertiesContext(
mrTextCharacterProperties.moItalic = rAttribs.getBool( XML_i );
if( rAttribs.hasAttribute( XML_cap ) )
mrTextCharacterProperties.moCaseMap = rAttribs.getToken( XML_cap );
+ if ( rAttribs.hasAttribute( XML_dirty ) )
+ {
+ --nVisualTokenAmount; // Not a visual attribute
+ }
+ if ( rAttribs.hasAttribute( XML_smtClean ) )
+ {
+ --nVisualTokenAmount; // Not a visual attribute
+ }
+
+ if ( nVisualTokenAmount > 0 )
+ mrTextCharacterProperties.mbHasVisualRunProperties = true;
/* TODO / unhandled so far:
A_TOKEN( kern )
@@ -87,6 +108,9 @@ TextCharacterPropertiesContext::~TextCharacterPropertiesContext()
ContextHandlerRef TextCharacterPropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
{
+ if( aElementToken != A_TOKEN(lang) )
+ mrTextCharacterProperties.mbHasVisualRunProperties = true;
+
switch( aElementToken )
{
// TODO unsupported yet
diff --git a/oox/source/drawingml/textparagraph.cxx b/oox/source/drawingml/textparagraph.cxx
index b5635b58f2e9..6de9c1417a8c 100644
--- a/oox/source/drawingml/textparagraph.cxx
+++ b/oox/source/drawingml/textparagraph.cxx
@@ -195,6 +195,16 @@ formulaimport::XmlStreamBuilder & TextParagraph::GetMathXml()
return *m_pMathXml;
}
+bool TextParagraph::hasVisualRunProperties() const
+{
+ for ( auto& pTextRun : getRuns() )
+ {
+ if ( pTextRun->hasVisualRunProperties() )
+ return true;
+ }
+ return false;
+}
+
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list