summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2019-10-11 14:57:04 +0200
committerMichael Stahl <michael.stahl@cib.de>2019-10-23 13:00:51 +0200
commitbc5e4104e281b89c08df102851e5693f35772c40 (patch)
tree45370b9e55cabb3a3563d45a69663655b4898c04
parent7f2e61f884949ab27bcb7e1a02ece9a5cb4354b9 (diff)
sw: DateFieldmark separator position: hack to put it at the start
DateFieldmark isn't created for an actual field with a command but for a SDT (Date Picker Content Control), so it's somewhat pointless to insert a separator for it in the first place; but better have an invariant that every pair of FIELDSTART/FIELDEND has a FIELDSEP. TODO: maybe add another pair of distinct START/END for this thing. Change-Id: I37301b578c668ecbf9408a48c227db5991c33f9e Reviewed-on: https://gerrit.libreoffice.org/80675 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
-rw-r--r--sw/qa/extras/globalfilter/globalfilter.cxx8
-rw-r--r--sw/source/core/crsr/bookmrk.cxx10
-rw-r--r--sw/source/core/doc/docbm.cxx5
-rw-r--r--sw/source/uibase/shells/textfld.cxx10
4 files changed, 14 insertions, 19 deletions
diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx
index 4c47c284fc59..a97b204aff71 100644
--- a/sw/qa/extras/globalfilter/globalfilter.cxx
+++ b/sw/qa/extras/globalfilter/globalfilter.cxx
@@ -1399,10 +1399,10 @@ void Test::testDateFormFieldCharacterFormatting()
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(11), pFieldmark->GetMarkEnd().nContent.GetIndex());
// We have one date field, first half of the field has bold character weight and second part has red character color
- CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), awt::FontWeight::BOLD, getProperty<float>(getRun(getParagraph(1), 2), "CharWeight"));
- CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(COL_AUTO), getProperty<sal_Int32>(getRun(getParagraph(1), 2), "CharColor"));
- CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), awt::FontWeight::NORMAL, getProperty<float>(getRun(getParagraph(1), 3), "CharWeight"));
- CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(0xff0000), getProperty<sal_Int32>(getRun(getParagraph(1), 3), "CharColor"));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), awt::FontWeight::BOLD, getProperty<float>(getRun(getParagraph(1), 3), "CharWeight"));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(COL_AUTO), getProperty<sal_Int32>(getRun(getParagraph(1), 3), "CharColor"));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), awt::FontWeight::NORMAL, getProperty<float>(getRun(getParagraph(1), 4), "CharWeight"));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(0xff0000), getProperty<sal_Int32>(getRun(getParagraph(1), 4), "CharColor"));
}
}
diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index ba43b2158bd4..713d36d2d63d 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -704,13 +704,8 @@ namespace sw { namespace mark
{
const SwTextNode* const pTextNode = GetMarkEnd().nNode.GetNode().GetTextNode();
SwPosition const sepPos(sw::mark::FindFieldSep(*this));
-#if 0
const sal_Int32 nStart(sepPos.nContent.GetIndex());
const sal_Int32 nEnd (GetMarkEnd().nContent.GetIndex());
-#else
- const sal_Int32 nStart(GetMarkStart().nContent.GetIndex());
- const sal_Int32 nEnd (sepPos.nContent.GetIndex() + 1);
-#endif
OUString sContent;
if(nStart + 1 < pTextNode->GetText().getLength() && nEnd <= pTextNode->GetText().getLength() &&
@@ -726,13 +721,8 @@ namespace sw { namespace mark
const SwTextNode* const pTextNode = GetMarkEnd().nNode.GetNode().GetTextNode();
SwPosition const sepPos(sw::mark::FindFieldSep(*this));
-#if 0
const sal_Int32 nStart(sepPos.nContent.GetIndex());
const sal_Int32 nEnd (GetMarkEnd().nContent.GetIndex());
-#else
- const sal_Int32 nStart(GetMarkStart().nContent.GetIndex());
- const sal_Int32 nEnd (sepPos.nContent.GetIndex() + 1);
-#endif
if(nStart + 1 < pTextNode->GetText().getLength() && nEnd <= pTextNode->GetText().getLength() &&
nEnd > nStart + 2)
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 4f13bea2d79f..88a6019251b4 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1341,7 +1341,10 @@ namespace sw { namespace mark
SwPosition aPos (aPaM.GetPoint()->nNode, aPaM.GetPoint()->nContent);
SwPaM aNewPaM(pFieldmark->GetMarkStart(), pFieldmark->GetMarkEnd());
deleteFieldmarkAt(aPos);
- return makeFieldBookmark(aNewPaM, sName, rNewType);
+ // HACK: hard-code the separator position here at the start because
+ // writerfilter put it in the wrong place (at the end) on attach()
+ SwPosition const sepPos(*aNewPaM.Start());
+ return makeFieldBookmark(aNewPaM, sName, rNewType, &sepPos);
}
return nullptr;
}
diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx
index ea78347f73a9..c65d5d65da6a 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -691,9 +691,10 @@ FIELD_INSERT:
if(bSuccess)
{
IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess();
- SwPaM aFieldPam(pCursorPos->GetPoint()->nNode, pCursorPos->GetPoint()->nContent.GetIndex()-5,
+ SwPaM aFieldPam(pCursorPos->GetPoint()->nNode, pCursorPos->GetPoint()->nContent.GetIndex() - ODF_FORMFIELD_DEFAULT_LENGTH,
pCursorPos->GetPoint()->nNode, pCursorPos->GetPoint()->nContent.GetIndex());
- pMarksAccess->makeFieldBookmark(aFieldPam, OUString(), ODF_FORMTEXT);
+ pMarksAccess->makeFieldBookmark(aFieldPam, OUString(), ODF_FORMTEXT,
+ aFieldPam.Start());
}
}
@@ -744,9 +745,10 @@ FIELD_INSERT:
if(bSuccess)
{
IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess();
- SwPaM aFieldPam(pCursorPos->GetPoint()->nNode, pCursorPos->GetPoint()->nContent.GetIndex()-5,
+ SwPaM aFieldPam(pCursorPos->GetPoint()->nNode, pCursorPos->GetPoint()->nContent.GetIndex() - ODF_FORMFIELD_DEFAULT_LENGTH,
pCursorPos->GetPoint()->nNode, pCursorPos->GetPoint()->nContent.GetIndex());
- sw::mark::IFieldmark* pFieldBM = pMarksAccess->makeFieldBookmark(aFieldPam, OUString(), ODF_FORMDATE);
+ sw::mark::IFieldmark* pFieldBM = pMarksAccess->makeFieldBookmark(aFieldPam, OUString(), ODF_FORMDATE,
+ aFieldPam.Start());
// Use a default date format and language
sw::mark::IFieldmark::parameter_map_t* pParameters = pFieldBM->GetParameters();