summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2014-08-07 14:49:36 +0200
committerCaolán McNamara <caolanm@redhat.com>2014-10-08 15:50:36 +0000
commit35166b42fdefd18a0d06b8053bae549466457c08 (patch)
tree01dd5a6b330fded8a9f332fa5f7a13a1820786b0 /sw
parent659194b946f3c2d31ffe715fb2232257cf0424e0 (diff)
fdo#81750 MM: correctly convert inline-edit fields
The new inline-editable input fields contain real content in the node, therefore a single SwPaM::Move isn't sufficient to select the field or move after the field. For the input fields we can directly go to the end of the field. Reviewed-on: https://gerrit.libreoffice.org/10834 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit 2579adb13188d276701b1504b4a10bed4d8d4b6f) Conflicts: sw/source/core/doc/doc.cxx Change-Id: Ic1bce415ce45e49456121b6db003ded0733e195c Reviewed-on: https://gerrit.libreoffice.org/11782 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/doc/doc.cxx49
1 files changed, 38 insertions, 11 deletions
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 1c419fe49d8f..3079d8ead9bd 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -112,6 +112,7 @@
#include <wdocsh.hxx>
#include <prtopt.hxx>
+#include <wrtsh.hxx>
#include <vector>
#include <map>
@@ -2027,21 +2028,47 @@ bool SwDoc::ConvertFieldsToText()
nWhich != RES_REFPAGESETFLD))
{
OUString sText = pField->ExpandField(true);
- //database fields should not convert their command into text
+
+ // database fields should not convert their command into text
if( RES_DBFLD == pCurType->Which() && !static_cast<const SwDBField*>(pField)->IsInitialized())
sText = "";
- //now remove the field and insert the string
- SwPaM aPam1(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart());
- aPam1.Move();
- //insert first to keep the field's attributes
+ SwPaM aInsertPam(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart());
+ aInsertPam.SetMark();
+
+ // go to the end of the field
+ const SwTxtFld *pTxtField = GetTxtFldAtPos( *aInsertPam.End() );
+ if (pTxtField && pTxtField->Which() == RES_TXTATR_INPUTFIELD)
+ {
+ SwPosition &rEndPos = *aInsertPam.GetPoint();
+ rEndPos.nContent = GetDocShell()->GetWrtShell()->EndOfInputFldAtPos( *aInsertPam.End() );
+ }
+ else
+ {
+ aInsertPam.Move();
+ }
+
+ // first insert the text after field to keep the field's attributes,
+ // then delete the field
if (!sText.isEmpty())
- InsertString( aPam1, sText );
- SwPaM aPam2(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart());
- aPam2.SetMark();
- aPam2.Move();
- DeleteAndJoin(aPam2);//remove the field
- bRet=true;
+ {
+ // to keep the position after insert
+ SwPaM aDelPam( *aInsertPam.GetMark(), *aInsertPam.GetPoint() );
+ aDelPam.Move( fnMoveBackward );
+ aInsertPam.DeleteMark();
+
+ InsertString( aInsertPam, sText );
+
+ aDelPam.Move();
+ // finally remove the field
+ DeleteAndJoin( aDelPam );
+ }
+ else
+ {
+ DeleteAndJoin( aInsertPam );
+ }
+
+ bRet = true;
}
}
++aBegin;