summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSarper Akdemir <sarper.akdemir@collabora.com>2021-05-09 20:17:20 +0300
committerMiklos Vajna <vmiklos@collabora.com>2021-06-15 09:28:55 +0200
commit4a3b9d2092ff5ce8336cc87cacbdc421f3d26ea7 (patch)
tree16c7427bca7902391e4296f4d7b851dcc03bfa36
parent21405a65c3056fe8c827f3999e5c79f6083d8229 (diff)
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@collabora.com>
-rw-r--r--oox/inc/drawingml/textbody.hxx6
-rw-r--r--oox/inc/drawingml/textcharacterproperties.hxx4
-rw-r--r--oox/inc/drawingml/textparagraph.hxx6
-rw-r--r--oox/inc/drawingml/textrun.hxx6
-rw-r--r--oox/source/drawingml/textbody.cxx10
-rw-r--r--oox/source/drawingml/textcharacterpropertiescontext.cxx26
-rw-r--r--oox/source/drawingml/textparagraph.cxx10
7 files changed, 67 insertions, 1 deletions
diff --git a/oox/inc/drawingml/textbody.hxx b/oox/inc/drawingml/textbody.hxx
index ac6c66b49515..8d0ce417f6b9 100644
--- a/oox/inc/drawingml/textbody.hxx
+++ b/oox/inc/drawingml/textbody.hxx
@@ -66,6 +66,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 90d01ec9cde1..2724af43051b 100644
--- a/oox/inc/drawingml/textcharacterproperties.hxx
+++ b/oox/inc/drawingml/textcharacterproperties.hxx
@@ -58,6 +58,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;
@@ -78,6 +80,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 df39f8841c76..4424eadf2cab 100644
--- a/oox/inc/drawingml/textparagraph.hxx
+++ b/oox/inc/drawingml/textparagraph.hxx
@@ -79,6 +79,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 355b8a684cc1..b3d1fe041ff8 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 1326c790328f..9839f755dc39 100644
--- a/oox/source/drawingml/textbody.cxx
+++ b/oox/source/drawingml/textbody.cxx
@@ -93,6 +93,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 8fecb8bd2735..9363a69673bb 100644
--- a/oox/source/drawingml/textcharacterpropertiescontext.cxx
+++ b/oox/source/drawingml/textcharacterpropertiescontext.cxx
@@ -27,6 +27,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>
@@ -45,8 +47,16 @@ TextCharacterPropertiesContext::TextCharacterPropertiesContext(
: ContextHandler2( rParent )
, mrTextCharacterProperties( rTextCharacterProperties )
{
- if ( rAttribs.hasAttribute( XML_lang ) )
+ int nVisualTokenAmount = sax_fastparser::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 ) )
@@ -64,6 +74,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 )
@@ -85,6 +106,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 88c086b0c07f..b1c57205dc26 100644
--- a/oox/source/drawingml/textparagraph.cxx
+++ b/oox/source/drawingml/textparagraph.cxx
@@ -194,6 +194,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: */