Kaydet (Commit) ede29e57 authored tarafından Michael Stahl's avatar Michael Stahl

sw_redlinehide_2: hide redlines in ascii filter too

It's called from SwEditShell::GetSelectedText() :-/

Change-Id: Ie26c7abd1bc0714bb4c1d49eecb7c869d947c276
üst 9bda4a67
...@@ -410,6 +410,7 @@ public: ...@@ -410,6 +410,7 @@ public:
bool m_bBlock : 1; bool m_bBlock : 1;
bool m_bOrganizerMode : 1; bool m_bOrganizerMode : 1;
bool m_bHideDeleteRedlines : 1;
Writer(); Writer();
virtual ~Writer() override; virtual ~Writer() override;
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <editsh.hxx> #include <editsh.hxx>
#include <edimp.hxx> #include <edimp.hxx>
#include <frmfmt.hxx> #include <frmfmt.hxx>
#include <rootfrm.hxx>
#include <swundo.hxx> #include <swundo.hxx>
#include <ndtxt.hxx> #include <ndtxt.hxx>
#include <swtable.hxx> #include <swtable.hxx>
...@@ -304,6 +305,7 @@ bool SwEditShell::GetSelectedText( OUString &rBuf, ParaBreakType nHndlParaBrk ) ...@@ -304,6 +305,7 @@ bool SwEditShell::GetSelectedText( OUString &rBuf, ParaBreakType nHndlParaBrk )
aAsciiOpt.SetCharSet( RTL_TEXTENCODING_UCS2 ); aAsciiOpt.SetCharSet( RTL_TEXTENCODING_UCS2 );
xWrt->SetAsciiOptions( aAsciiOpt ); xWrt->SetAsciiOptions( aAsciiOpt );
xWrt->m_bUCS2_WithStartChar = false; xWrt->m_bUCS2_WithStartChar = false;
xWrt->m_bHideDeleteRedlines = GetLayout()->IsHideRedlines();
if ( ! aWriter.Write(xWrt).IsError() ) if ( ! aWriter.Write(xWrt).IsError() )
{ {
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include <pam.hxx> #include <pam.hxx>
#include <doc.hxx> #include <doc.hxx>
#include <ndtxt.hxx> #include <ndtxt.hxx>
#include <IDocumentRedlineAccess.hxx>
#include <redline.hxx>
#include "wrtasc.hxx" #include "wrtasc.hxx"
#include <txatbase.hxx> #include <txatbase.hxx>
#include <fchrfmt.hxx> #include <fchrfmt.hxx>
...@@ -166,6 +168,74 @@ bool SwASC_AttrIter::OutAttr( sal_Int32 nSwPos ) ...@@ -166,6 +168,74 @@ bool SwASC_AttrIter::OutAttr( sal_Int32 nSwPos )
return bRet; 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 // Output of the node
static Writer& OutASC_SwTextNode( Writer& rWrt, SwContentNode& rNode ) static Writer& OutASC_SwTextNode( Writer& rWrt, SwContentNode& rNode )
...@@ -182,6 +252,12 @@ 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; bool bIsOneParagraph = rWrt.m_pOrigPam->Start()->nNode == rWrt.m_pOrigPam->End()->nNode;
SwASC_AttrIter aAttrIter( static_cast<SwASCWriter&>(rWrt), rNd, nStrPos ); 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(); const SwNumRule* pNumRule = rNd.GetNumRule();
if (pNumRule && !nStrPos && rWrt.m_bExportPargraphNumbering && !bIsOneParagraph) if (pNumRule && !nStrPos && rWrt.m_bExportPargraphNumbering && !bIsOneParagraph)
...@@ -219,12 +295,49 @@ static Writer& OutASC_SwTextNode( Writer& rWrt, SwContentNode& rNode ) ...@@ -219,12 +295,49 @@ static Writer& OutASC_SwTextNode( Writer& rWrt, SwContentNode& rNode )
const bool bExportSoftHyphens = RTL_TEXTENCODING_UCS2 == rWrt.GetAsciiOptions().GetCharSet() || const bool bExportSoftHyphens = RTL_TEXTENCODING_UCS2 == rWrt.GetAsciiOptions().GetCharSet() ||
RTL_TEXTENCODING_UTF8 == rWrt.GetAsciiOptions().GetCharSet(); RTL_TEXTENCODING_UTF8 == rWrt.GetAsciiOptions().GetCharSet();
std::pair<sal_Int32, sal_Int32> curRedline(redlineIter.GetNextRedlineSkip());
for (;;) { for (;;) {
const sal_Int32 nNextAttr = std::min(aAttrIter.WhereNext(), nEnd); 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 ) if ( !bExportSoftHyphens )
aOutStr = aOutStr.replaceAll(OUStringLiteral1(CHAR_SOFTHYPHEN), ""); aOutStr = aOutStr.replaceAll(OUStringLiteral1(CHAR_SOFTHYPHEN), "");
......
...@@ -120,6 +120,7 @@ void Writer_Impl::InsertBkmk(const ::sw::mark::IMark& rBkmk) ...@@ -120,6 +120,7 @@ void Writer_Impl::InsertBkmk(const ::sw::mark::IMark& rBkmk)
Writer::Writer() Writer::Writer()
: m_pImpl(o3tl::make_unique<Writer_Impl>()) : m_pImpl(o3tl::make_unique<Writer_Impl>())
, m_pOrigFileName(nullptr), m_pDoc(nullptr), m_pOrigPam(nullptr), m_pCurrentPam(nullptr) , m_pOrigFileName(nullptr), m_pDoc(nullptr), m_pOrigPam(nullptr), m_pCurrentPam(nullptr)
, m_bHideDeleteRedlines(false)
{ {
m_bWriteAll = m_bShowProgress = m_bUCS2_WithStartChar = true; m_bWriteAll = m_bShowProgress = m_bUCS2_WithStartChar = true;
m_bASCII_NoLastLineEnd = m_bASCII_ParaAsBlank = m_bASCII_ParaAsCR = m_bASCII_NoLastLineEnd = m_bASCII_ParaAsBlank = m_bASCII_ParaAsCR =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment