summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashodnakashian@yahoo.com>2017-10-30 15:08:44 -0400
committerAshod Nakashian <ashnakash@gmail.com>2017-11-03 12:05:43 +0100
commit4bba85e04cda1cb5769114be5ad771de55d56d14 (patch)
tree5f2cb56434d73558d3071239c346faa97fcaa15f
parent3f2e84b4bd0bbd936e0af845ba7cbf68cb2803d6 (diff)
TSCP: don't export metadata field text in DOCX
Change-Id: I28ae3e57d3766497077af091fe4721fe653def4b Reviewed-on: https://gerrit.libreoffice.org/44118 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx39
-rw-r--r--sw/source/filter/ww8/wrtww8.hxx3
2 files changed, 40 insertions, 2 deletions
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index de71bd55e618..87c27db44c89 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -658,7 +658,7 @@ FlyProcessingState SwWW8AttrIter::OutFlys(sal_Int32 nSwPos)
return ( m_rExport.AttrOutput().IsFlyProcessingPostponed() ? FLY_POSTPONED : FLY_PROCESSED ) ;
}
-bool SwWW8AttrIter::IsTextAttr( sal_Int32 nSwPos )
+bool SwWW8AttrIter::IsTextAttr( sal_Int32 nSwPos ) const
{
// search for attrs with dummy character or content
if (const SwpHints* pTextAttrs = rNd.GetpSwpHints())
@@ -683,6 +683,32 @@ bool SwWW8AttrIter::IsTextAttr( sal_Int32 nSwPos )
return false;
}
+bool SwWW8AttrIter::IsExportableAttr(sal_Int32 nSwPos) const
+{
+ if (const SwpHints* pTextAttrs = rNd.GetpSwpHints())
+ {
+ for (size_t i = 0; i < pTextAttrs->Count(); ++i)
+ {
+ const SwTextAttr* pHt = pTextAttrs->GetSortedByEnd(i);
+ const sal_Int32 nStart = pHt->GetStart();
+ const sal_Int32 nEnd = pHt->End() ? *pHt->End() : INT_MAX;
+ if (nSwPos >= nStart && nSwPos < nEnd)
+ {
+ switch (pHt->GetAttr().Which())
+ {
+ // Metadata fields should be dynamically generated, not dumped as text.
+ case RES_TXTATR_METAFIELD:
+ return false;
+ }
+ }
+ else if (nSwPos > nEnd)
+ break;
+ }
+ }
+
+ return true;
+}
+
bool SwWW8AttrIter::IsDropCap( int nSwPos )
{
// see if the current position falls on a DropCap
@@ -2151,12 +2177,23 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
}
do {
+
const SwRedlineData* pRedlineData = aAttrIter.GetRunLevelRedline( nAktPos );
FlyProcessingState nStateOfFlyFrame = FLY_PROCESSED;
bool bPostponeWritingText = false ;
OUString aSavedSnippet ;
sal_Int32 nNextAttr = GetNextPos( &aAttrIter, rNode, nAktPos );
+
+ // Skip un-exportable attributes.
+ if (!aAttrIter.IsExportableAttr(nAktPos))
+ {
+ nAktPos = nNextAttr;
+ UpdatePosition(&aAttrIter, nAktPos);
+ eChrSet = aAttrIter.GetCharSet();
+ continue;
+ }
+
// Is this the only run in this paragraph and it's empty?
bool bSingleEmptyRun = nAktPos == 0 && nNextAttr == 0;
AttrOutput().StartRun( pRedlineData, bSingleEmptyRun );
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index e995f61cf140..c3f05caad3c9 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -1482,7 +1482,8 @@ private:
public:
SwWW8AttrIter( MSWordExportBase& rWr, const SwTextNode& rNd );
- bool IsTextAttr( sal_Int32 nSwPos );
+ bool IsTextAttr( sal_Int32 nSwPos ) const;
+ bool IsExportableAttr(sal_Int32 nSwPos) const;
bool IncludeEndOfParaCRInRedlineProperties(sal_Int32 nPos) const;
bool IsDropCap( int nSwPos );
bool RequiresImplicitBookmark();