[Libreoffice-commits] core.git: 2 commits - sw/inc sw/source
Michael Stahl (via logerrit)
logerrit at kemper.freedesktop.org
Fri Oct 4 10:12:21 UTC 2019
sw/inc/IDocumentMarkAccess.hxx | 2 ++
sw/inc/hintids.hxx | 1 +
sw/source/core/doc/docbm.cxx | 18 +++++++++++++++++-
sw/source/core/inc/MarkManager.hxx | 1 +
sw/source/core/text/itratr.cxx | 16 +++++++++-------
sw/source/core/text/itrform2.cxx | 4 ++++
sw/source/core/text/portxt.cxx | 4 ++--
sw/source/core/txtnode/ndtxt.cxx | 1 +
sw/source/core/undo/undel.cxx | 2 ++
sw/source/core/unocore/unoportenum.cxx | 6 +++---
sw/source/filter/ascii/ascatr.cxx | 1 +
sw/source/filter/html/wrthtml.cxx | 2 +-
sw/source/filter/ww8/writerhelper.cxx | 2 +-
sw/source/filter/ww8/wrtw8nds.cxx | 6 +++---
14 files changed, 48 insertions(+), 18 deletions(-)
New commits:
commit 080eb8544ab65f757b0dc6c95328d3b9b47a5e64
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Tue Sep 24 18:06:53 2019 +0200
Commit: Michael Stahl <michael.stahl at cib.de>
CommitDate: Fri Oct 4 12:11:43 2019 +0200
sw: add CH_TXT_ATR_FIELDSEP
... and handle it in obvious places.
Change-Id: I7e9668994be0bd246f89ecc60fd0a42c240cce0c
Reviewed-on: https://gerrit.libreoffice.org/80051
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl at cib.de>
diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx
index 6e818b03349b..dcbc5f4247ff 100644
--- a/sw/inc/hintids.hxx
+++ b/sw/inc/hintids.hxx
@@ -50,6 +50,7 @@ class SvxLRSpaceItem;
#define CH_TXT_ATR_FORMELEMENT u'\x0006'
#define CH_TXT_ATR_FIELDSTART u'\x0007'
+#define CH_TXT_ATR_FIELDSEP u'\x0003'
#define CH_TXT_ATR_FIELDEND u'\x0008'
#define CH_TXT_ATR_SUBST_FIELDSTART ("[")
#define CH_TXT_ATR_SUBST_FIELDEND ("]")
diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index 59b7277ff849..02f44d5cc74e 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -707,16 +707,18 @@ static sal_Int32 GetNextAttrImpl(SwTextNode const*const pTextNode,
while (p < l)
{
sal_Unicode aChar = pStr[p];
- if (aChar < CH_TXT_ATR_FORMELEMENT
- || aChar > CH_TXT_ATR_FIELDEND)
+ switch (aChar)
{
- ++p;
- }
- else
- {
- break;
+ case CH_TXT_ATR_FORMELEMENT:
+ case CH_TXT_ATR_FIELDSTART:
+ case CH_TXT_ATR_FIELDSEP:
+ case CH_TXT_ATR_FIELDEND:
+ goto break_; // sigh...
+ default:
+ ++p;
}
}
+break_:
assert(p <= nNext);
if (p < l)
{
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index c273d32f0009..395fcc23ce2c 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -889,11 +889,15 @@ SwTextPortion *SwTextFormatter::WhichTextPor( SwTextFormatInfo &rInf ) const
{
if (ch == CH_TXT_ATR_FIELDSTART)
pPor = new SwFieldFormDatePortion(pBM, true);
+ else if (ch == CH_TXT_ATR_FIELDSEP)
+ pPor = new SwFieldMarkPortion(); // it's added in DateFieldmark?
else if (ch == CH_TXT_ATR_FIELDEND)
pPor = new SwFieldFormDatePortion(pBM, false);
}
else if (ch == CH_TXT_ATR_FIELDSTART)
pPor = new SwFieldMarkPortion();
+ else if (ch == CH_TXT_ATR_FIELDSEP)
+ pPor = new SwFieldMarkPortion();
else if (ch == CH_TXT_ATR_FIELDEND)
pPor = new SwFieldMarkPortion();
else if (ch == CH_TXT_ATR_FORMELEMENT)
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 062343808edd..8d321ddd9b45 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -3575,6 +3575,7 @@ bool SwTextNode::CopyExpandText(SwTextNode& rDestNd, const SwIndex* pDestIdx,
sal_Unicode const cur(rDestNd.GetText()[aDestIdx.GetIndex()]);
if ( (cChar == cur) // filter substituted hidden text
|| (CH_TXT_ATR_FIELDSTART == cur) // filter all fieldmarks
+ || (CH_TXT_ATR_FIELDSEP == cur)
|| (CH_TXT_ATR_FIELDEND == cur)
|| (CH_TXT_ATR_FORMELEMENT == cur))
{
diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx
index a1a8ca52f841..e23382e5f0a3 100644
--- a/sw/source/core/undo/undel.cxx
+++ b/sw/source/core/undo/undel.cxx
@@ -641,6 +641,7 @@ static bool lcl_IsSpecialCharacter(sal_Unicode nChar)
case CH_TXT_ATR_INPUTFIELDEND:
case CH_TXT_ATR_FORMELEMENT:
case CH_TXT_ATR_FIELDSTART:
+ case CH_TXT_ATR_FIELDSEP:
case CH_TXT_ATR_FIELDEND:
return true;
@@ -681,6 +682,7 @@ static OUString lcl_DenotedPortion(const OUString& rStr, sal_Int32 nStart, sal_I
case CH_TXT_ATR_INPUTFIELDEND:
case CH_TXT_ATR_FORMELEMENT:
case CH_TXT_ATR_FIELDSTART:
+ case CH_TXT_ATR_FIELDSEP:
case CH_TXT_ATR_FIELDEND:
break; // nothing?
diff --git a/sw/source/filter/ascii/ascatr.cxx b/sw/source/filter/ascii/ascatr.cxx
index 5058b45c5c00..3da9c5a2117b 100644
--- a/sw/source/filter/ascii/ascatr.cxx
+++ b/sw/source/filter/ascii/ascatr.cxx
@@ -348,6 +348,7 @@ static Writer& OutASC_SwTextNode( Writer& rWrt, SwContentNode& rNode )
CH_TXT_ATR_INPUTFIELDEND,
CH_TXT_ATR_FORMELEMENT,
CH_TXT_ATR_FIELDSTART,
+ CH_TXT_ATR_FIELDSEP,
CH_TXT_ATR_FIELDEND,
0
};
commit 7ade17fd46c986ad2a624982c5737d7c667b8c89
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Tue Sep 24 18:07:44 2019 +0200
Commit: Michael Stahl <michael.stahl at cib.de>
CommitDate: Fri Oct 4 12:11:31 2019 +0200
sw: add IDocumentMarkAccess::getFieldmarkAt()
... and use it where the mark for a given CH_TXT_ATR_FIELD* is
retrieved.
Change-Id: Id58ac2967ab66be8a07586ef31cfe9e18a5f073d
Reviewed-on: https://gerrit.libreoffice.org/80050
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl at cib.de>
diff --git a/sw/inc/IDocumentMarkAccess.hxx b/sw/inc/IDocumentMarkAccess.hxx
index 4d12a236a4f1..a8dacbcbd7e4 100644
--- a/sw/inc/IDocumentMarkAccess.hxx
+++ b/sw/inc/IDocumentMarkAccess.hxx
@@ -307,6 +307,8 @@ class IDocumentMarkAccess
// Fieldmarks
+ /// get Fieldmark for CH_TXT_ATR_FIELDSTART/CH_TXT_ATR_FIELDEND at rPos
+ virtual ::sw::mark::IFieldmark* getFieldmarkAt(const SwPosition& rPos) const =0;
virtual ::sw::mark::IFieldmark* getFieldmarkFor(const SwPosition& pos) const =0;
virtual ::sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& pos) const =0;
virtual ::sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& pos) const =0;
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 6f2a38b0be5a..1d61f2ac65e7 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1255,6 +1255,22 @@ namespace sw { namespace mark
CompareIMarkStartsAfter());
}
+ IFieldmark* MarkManager::getFieldmarkAt(const SwPosition& rPos) const
+ {
+ auto const pFieldmark = find_if(
+ m_vFieldmarks.begin(),
+ m_vFieldmarks.end(),
+ [&rPos] (::sw::mark::MarkBase const*const pMark) {
+ return pMark->GetMarkStart() == rPos
+ // end position includes the CH_TXT_ATR_FIELDEND
+ || (pMark->GetMarkEnd().nContent.GetIndex() == rPos.nContent.GetIndex() + 1
+ && pMark->GetMarkEnd().nNode == rPos.nNode);
+ } );
+ return (pFieldmark == m_vFieldmarks.end())
+ ? nullptr
+ : dynamic_cast<IFieldmark*>(*pFieldmark);
+ }
+
IFieldmark* MarkManager::getFieldmarkFor(const SwPosition& rPos) const
{
auto const pFieldmark = find_if(
@@ -1377,7 +1393,7 @@ namespace sw { namespace mark
IFieldmark* MarkManager::getDropDownFor(const SwPosition& rPos) const
{
- IFieldmark *pMark = getFieldmarkFor(rPos);
+ IFieldmark *pMark = getFieldmarkAt(rPos);
if (!pMark || pMark->GetFieldname() != ODF_FORMDROPDOWN)
return nullptr;
return pMark;
diff --git a/sw/source/core/inc/MarkManager.hxx b/sw/source/core/inc/MarkManager.hxx
index 512cd4de9d6d..a97f28c21b53 100644
--- a/sw/source/core/inc/MarkManager.hxx
+++ b/sw/source/core/inc/MarkManager.hxx
@@ -83,6 +83,7 @@ namespace sw {
virtual const_iterator_t findFirstBookmarkStartsAfter(const SwPosition& rPos) const override;
// Fieldmarks
+ virtual ::sw::mark::IFieldmark* getFieldmarkAt(const SwPosition& rPos) const override;
virtual ::sw::mark::IFieldmark* getFieldmarkFor(const SwPosition& rPos) const override;
virtual ::sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& rPos) const override;
virtual ::sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& rPos) const override;
diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx
index f9aed8c08c6c..0460cb343dd3 100644
--- a/sw/source/core/text/portxt.cxx
+++ b/sw/source/core/text/portxt.cxx
@@ -794,7 +794,7 @@ void SwFieldFormCheckboxPortion::Paint( const SwTextPaintInfo& rInf ) const
{
SwPosition const aPosition(rInf.GetTextFrame()->MapViewToModelPos(rInf.GetIdx()));
- IFieldmark const*const pBM = rInf.GetTextFrame()->GetDoc().getIDocumentMarkAccess()->getFieldmarkFor( aPosition );
+ IFieldmark const*const pBM = rInf.GetTextFrame()->GetDoc().getIDocumentMarkAccess()->getFieldmarkAt(aPosition);
OSL_ENSURE(pBM && pBM->GetFieldname( ) == ODF_FORMCHECKBOX,
"Where is my form field bookmark???");
@@ -810,7 +810,7 @@ void SwFieldFormCheckboxPortion::Paint( const SwTextPaintInfo& rInf ) const
bool SwFieldFormCheckboxPortion::Format( SwTextFormatInfo & rInf )
{
SwPosition const aPosition(rInf.GetTextFrame()->MapViewToModelPos(rInf.GetIdx()));
- IFieldmark const*const pBM = rInf.GetTextFrame()->GetDoc().getIDocumentMarkAccess()->getFieldmarkFor( aPosition );
+ IFieldmark const*const pBM = rInf.GetTextFrame()->GetDoc().getIDocumentMarkAccess()->getFieldmarkAt(aPosition);
OSL_ENSURE(pBM && pBM->GetFieldname( ) == ODF_FORMCHECKBOX, "Where is my form field bookmark???");
if (pBM && pBM->GetFieldname( ) == ODF_FORMCHECKBOX)
{
diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx
index 26a00c334746..f7ad846313d4 100644
--- a/sw/source/core/unocore/unoportenum.cxx
+++ b/sw/source/core/unocore/unoportenum.cxx
@@ -432,7 +432,7 @@ lcl_ExportFieldMark(
if (pDoc)
{
pFieldmark = pDoc->getIDocumentMarkAccess()->
- getFieldmarkFor(*pUnoCursor->GetMark());
+ getFieldmarkAt(*pUnoCursor->GetMark());
}
SwXTextPortion* pPortion = new SwXTextPortion(
pUnoCursor, i_xParentText, PORTION_FIELD_START);
@@ -449,7 +449,7 @@ lcl_ExportFieldMark(
if (pDoc)
{
pFieldmark = pDoc->getIDocumentMarkAccess()->
- getFieldmarkFor(*pUnoCursor->GetMark());
+ getFieldmarkAt(*pUnoCursor->GetMark());
}
SwXTextPortion* pPortion = new SwXTextPortion(
pUnoCursor, i_xParentText, PORTION_FIELD_END);
@@ -465,7 +465,7 @@ lcl_ExportFieldMark(
::sw::mark::IFieldmark* pFieldmark = nullptr;
if (pDoc)
{
- pFieldmark = pDoc->getIDocumentMarkAccess()->getFieldmarkFor(*pUnoCursor->GetMark());
+ pFieldmark = pDoc->getIDocumentMarkAccess()->getFieldmarkAt(*pUnoCursor->GetMark());
}
SwXTextPortion* pPortion = new SwXTextPortion(
pUnoCursor, i_xParentText, PORTION_FIELD_START_END);
diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx
index 7375f911d476..f86ab2004dc2 100644
--- a/sw/source/filter/html/wrthtml.cxx
+++ b/sw/source/filter/html/wrthtml.cxx
@@ -1171,7 +1171,7 @@ void SwHTMLWriter::OutPointFieldmarks( const SwPosition& rPos )
if (!pMarkAccess)
return;
- const sw::mark::IFieldmark* pMark = pMarkAccess->getFieldmarkFor(rPos);
+ const sw::mark::IFieldmark* pMark = pMarkAccess->getFieldmarkAt(rPos);
if (!pMark)
return;
diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx
index 520283dc5fe1..fa56ce68878e 100644
--- a/sw/source/filter/ww8/writerhelper.cxx
+++ b/sw/source/filter/ww8/writerhelper.cxx
@@ -718,7 +718,7 @@ namespace sw
SwPosition const end(*rPos.nNode.GetNode().GetTextNode(),
nIndex - 1);
sw::mark::IFieldmark *const pFieldMark(
- rPos.GetDoc()->getIDocumentMarkAccess()->getFieldmarkFor(end));
+ rPos.GetDoc()->getIDocumentMarkAccess()->getFieldmarkAt(end));
SAL_WARN_IF(!pFieldMark, "sw.ww8", "expected a field mark");
if (pFieldMark && pFieldMark->GetMarkPos().nNode.GetIndex() == (*aResult)->m_aMkPos.m_nNode.GetIndex()+1
&& pFieldMark->GetMarkPos().nContent.GetIndex() < (*aResult)->m_aMkPos.m_nContent)
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index b722b22621d3..fd0f55dc7063 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -2314,7 +2314,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
if ( ch == CH_TXT_ATR_FIELDSTART )
{
SwPosition aPosition( rNode, SwIndex( &rNode, nCurrentPos ) );
- ::sw::mark::IFieldmark const * const pFieldmark = pMarkAccess->getFieldmarkFor( aPosition );
+ ::sw::mark::IFieldmark const*const pFieldmark = pMarkAccess->getFieldmarkAt(aPosition);
OSL_ENSURE( pFieldmark, "Looks like this doc is broken...; where is the Fieldmark for the FIELDSTART??" );
// Date field is exported as content control, not as a simple field
@@ -2381,7 +2381,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
else if ( ch == CH_TXT_ATR_FIELDEND )
{
SwPosition aPosition( rNode, SwIndex( &rNode, nCurrentPos ) );
- ::sw::mark::IFieldmark const * const pFieldmark = pMarkAccess->getFieldmarkFor( aPosition );
+ ::sw::mark::IFieldmark const*const pFieldmark = pMarkAccess->getFieldmarkAt(aPosition);
OSL_ENSURE( pFieldmark, "Looks like this doc is broken...; where is the Fieldmark for the FIELDEND??" );
@@ -2418,7 +2418,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
else if ( ch == CH_TXT_ATR_FORMELEMENT )
{
SwPosition aPosition( rNode, SwIndex( &rNode, nCurrentPos ) );
- ::sw::mark::IFieldmark const * const pFieldmark = pMarkAccess->getFieldmarkFor( aPosition );
+ ::sw::mark::IFieldmark const*const pFieldmark = pMarkAccess->getFieldmarkAt(aPosition);
bool isDropdownOrCheckbox = pFieldmark && (pFieldmark->GetFieldname( ) == ODF_FORMDROPDOWN ||
pFieldmark->GetFieldname( ) == ODF_FORMCHECKBOX );
More information about the Libreoffice-commits
mailing list