summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2018-09-14 18:06:12 +0200
committerMichael Stahl <Michael.Stahl@cib.de>2018-09-19 10:18:33 +0200
commitede29e57cd14946c8668ca7d2b84dbc3afa90fd5 (patch)
treecbde5be30ce82bc9f7bd5599a738d377dd64251d /sw/source
parent9bda4a67565817f0a26f48c4a4b9723894a385f5 (diff)
sw_redlinehide_2: hide redlines in ascii filter too
It's called from SwEditShell::GetSelectedText() :-/ Change-Id: Ie26c7abd1bc0714bb4c1d49eecb7c869d947c276
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/edit/edglss.cxx2
-rw-r--r--sw/source/filter/ascii/ascatr.cxx117
-rw-r--r--sw/source/filter/writer/writer.cxx1
3 files changed, 118 insertions, 2 deletions
diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx
index 8dc8d0a2a226..2949a095f592 100644
--- a/sw/source/core/edit/edglss.cxx
+++ b/sw/source/core/edit/edglss.cxx
@@ -28,6 +28,7 @@
#include <editsh.hxx>
#include <edimp.hxx>
#include <frmfmt.hxx>
+#include <rootfrm.hxx>
#include <swundo.hxx>
#include <ndtxt.hxx>
#include <swtable.hxx>
@@ -304,6 +305,7 @@ bool SwEditShell::GetSelectedText( OUString &rBuf, ParaBreakType nHndlParaBrk )
aAsciiOpt.SetCharSet( RTL_TEXTENCODING_UCS2 );
xWrt->SetAsciiOptions( aAsciiOpt );
xWrt->m_bUCS2_WithStartChar = false;
+ xWrt->m_bHideDeleteRedlines = GetLayout()->IsHideRedlines();
if ( ! aWriter.Write(xWrt).IsError() )
{
diff --git a/sw/source/filter/ascii/ascatr.cxx b/sw/source/filter/ascii/ascatr.cxx
index c0e6eb1c2c62..ae581f0eeb3e 100644
--- a/sw/source/filter/ascii/ascatr.cxx
+++ b/sw/source/filter/ascii/ascatr.cxx
@@ -24,6 +24,8 @@
#include <pam.hxx>
#include <doc.hxx>
#include <ndtxt.hxx>
+#include <IDocumentRedlineAccess.hxx>
+#include <redline.hxx>
#include "wrtasc.hxx"
#include <txatbase.hxx>
#include <fchrfmt.hxx>
@@ -166,6 +168,74 @@ bool SwASC_AttrIter::OutAttr( sal_Int32 nSwPos )
return bRet;
}
+class SwASC_RedlineIter
+{
+private:
+ SwTextNode const& m_rNode;
+ IDocumentRedlineAccess const& m_rIDRA;
+ SwRedlineTable::size_type m_nextRedline;
+
+public:
+ SwASC_RedlineIter(SwASCWriter const& rWriter, SwTextNode const& rNode)
+ : m_rNode(rNode)
+ , m_rIDRA(rNode.GetDoc()->getIDocumentRedlineAccess())
+ , m_nextRedline(rWriter.m_bHideDeleteRedlines
+ ? m_rIDRA.GetRedlinePos(m_rNode, nsRedlineType_t::REDLINE_DELETE)
+ : SwRedlineTable::npos)
+ {
+ }
+
+ bool CheckNodeDeleted()
+ {
+ if (m_nextRedline == SwRedlineTable::npos)
+ {
+ return false;
+ }
+ SwRangeRedline const*const pRedline(m_rIDRA.GetRedlineTable()[m_nextRedline]);
+ return pRedline->Start()->nNode.GetIndex() < m_rNode.GetIndex()
+ && m_rNode.GetIndex() < pRedline->End()->nNode.GetIndex();
+ }
+
+ std::pair<sal_Int32, sal_Int32> GetNextRedlineSkip()
+ {
+ sal_Int32 nRedlineStart(COMPLETE_STRING);
+ sal_Int32 nRedlineEnd(COMPLETE_STRING);
+ for ( ; m_nextRedline < m_rIDRA.GetRedlineTable().size(); ++m_nextRedline)
+ {
+ SwRangeRedline const*const pRedline(m_rIDRA.GetRedlineTable()[m_nextRedline]);
+ if (pRedline->GetType() != nsRedlineType_t::REDLINE_DELETE)
+ {
+ continue;
+ }
+ SwPosition const*const pStart(pRedline->Start());
+ SwPosition const*const pEnd(pRedline->End());
+ if (m_rNode.GetIndex() < pStart->nNode.GetIndex())
+ {
+ m_nextRedline = SwRedlineTable::npos;
+ break; // done
+ }
+ if (nRedlineStart == COMPLETE_STRING)
+ {
+ nRedlineStart = pStart->nNode.GetIndex() == m_rNode.GetIndex()
+ ? pStart->nContent.GetIndex()
+ : 0;
+ }
+ else
+ {
+ if (pStart->nContent.GetIndex() != nRedlineEnd)
+ {
+ assert(nRedlineEnd < pStart->nContent.GetIndex());
+ break; // no increment, revisit it next call
+ }
+ }
+ nRedlineEnd = pEnd->nNode.GetIndex() == m_rNode.GetIndex()
+ ? pEnd->nContent.GetIndex()
+ : COMPLETE_STRING;
+ }
+ return std::make_pair(nRedlineStart, nRedlineEnd);
+ }
+};
+
// Output of the node
static Writer& OutASC_SwTextNode( Writer& rWrt, SwContentNode& rNode )
@@ -182,6 +252,12 @@ static Writer& OutASC_SwTextNode( Writer& rWrt, SwContentNode& rNode )
bool bIsOneParagraph = rWrt.m_pOrigPam->Start()->nNode == rWrt.m_pOrigPam->End()->nNode;
SwASC_AttrIter aAttrIter( static_cast<SwASCWriter&>(rWrt), rNd, nStrPos );
+ SwASC_RedlineIter redlineIter(static_cast<SwASCWriter&>(rWrt), rNd);
+
+ if (redlineIter.CheckNodeDeleted())
+ {
+ return rWrt;
+ }
const SwNumRule* pNumRule = rNd.GetNumRule();
if (pNumRule && !nStrPos && rWrt.m_bExportPargraphNumbering && !bIsOneParagraph)
@@ -219,12 +295,49 @@ static Writer& OutASC_SwTextNode( Writer& rWrt, SwContentNode& rNode )
const bool bExportSoftHyphens = RTL_TEXTENCODING_UCS2 == rWrt.GetAsciiOptions().GetCharSet() ||
RTL_TEXTENCODING_UTF8 == rWrt.GetAsciiOptions().GetCharSet();
+ std::pair<sal_Int32, sal_Int32> curRedline(redlineIter.GetNextRedlineSkip());
for (;;) {
const sal_Int32 nNextAttr = std::min(aAttrIter.WhereNext(), nEnd);
- if( !aAttrIter.OutAttr( nStrPos ))
+ bool isOutAttr(false);
+ if (nStrPos < curRedline.first || curRedline.second <= nStrPos)
{
- OUString aOutStr( aStr.copy( nStrPos, nNextAttr - nStrPos ) );
+ isOutAttr = aAttrIter.OutAttr(nStrPos);
+ }
+
+ if (!isOutAttr)
+ {
+ OUStringBuffer buf;
+ while (true)
+ {
+ if (nNextAttr <= curRedline.first)
+ {
+ buf.append(aStr.copy(nStrPos, nNextAttr - nStrPos));
+ break;
+ }
+ else if (nStrPos < curRedline.second)
+ {
+ if (nStrPos < curRedline.first)
+ {
+ buf.append(aStr.copy(nStrPos, curRedline.first - nStrPos));
+ }
+ if (curRedline.second <= nNextAttr)
+ {
+ nStrPos = curRedline.second;
+ curRedline = redlineIter.GetNextRedlineSkip();
+ }
+ else
+ {
+ nStrPos = nNextAttr;
+ break;
+ }
+ }
+ else
+ {
+ curRedline = redlineIter.GetNextRedlineSkip();
+ }
+ }
+ OUString aOutStr(buf.makeStringAndClear());
if ( !bExportSoftHyphens )
aOutStr = aOutStr.replaceAll(OUStringLiteral1(CHAR_SOFTHYPHEN), "");
diff --git a/sw/source/filter/writer/writer.cxx b/sw/source/filter/writer/writer.cxx
index cd8450fbe033..e86a01d70f3b 100644
--- a/sw/source/filter/writer/writer.cxx
+++ b/sw/source/filter/writer/writer.cxx
@@ -120,6 +120,7 @@ void Writer_Impl::InsertBkmk(const ::sw::mark::IMark& rBkmk)
Writer::Writer()
: m_pImpl(o3tl::make_unique<Writer_Impl>())
, m_pOrigFileName(nullptr), m_pDoc(nullptr), m_pOrigPam(nullptr), m_pCurrentPam(nullptr)
+ , m_bHideDeleteRedlines(false)
{
m_bWriteAll = m_bShowProgress = m_bUCS2_WithStartChar = true;
m_bASCII_NoLastLineEnd = m_bASCII_ParaAsBlank = m_bASCII_ParaAsCR =