summaryrefslogtreecommitdiff
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-08-17 16:22:35 -0500
commit2579adb13188d276701b1504b4a10bed4d8d4b6f (patch)
treeb12d618dc1b8ea39e126c432daabd1406180e6df
parent428c45fc779223371818bd11b2b846e1c13ebe47 (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. Change-Id: Ic1bce415ce45e49456121b6db003ded0733e195c Reviewed-on: https://gerrit.libreoffice.org/10834 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-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 fad297ac4f30..c4b1ccb48ffc 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -126,6 +126,7 @@
#include <wdocsh.hxx>
#include <prtopt.hxx>
+#include <wrtsh.hxx>
#include <vector>
#include <map>
@@ -1545,21 +1546,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())
- getIDocumentContentOperations().InsertString( aPam1, sText );
- SwPaM aPam2(*pTxtFld->GetpTxtNode(), pTxtFld->GetStart());
- aPam2.SetMark();
- aPam2.Move();
- getIDocumentContentOperations().DeleteAndJoin(aPam2);//remove the field
- bRet=true;
+ {
+ // to keep the position after insert
+ SwPaM aDelPam( *aInsertPam.GetMark(), *aInsertPam.GetPoint() );
+ aDelPam.Move( fnMoveBackward );
+ aInsertPam.DeleteMark();
+
+ getIDocumentContentOperations().InsertString( aInsertPam, sText );
+
+ aDelPam.Move();
+ // finally remove the field
+ getIDocumentContentOperations().DeleteAndJoin( aDelPam );
+ }
+ else
+ {
+ getIDocumentContentOperations().DeleteAndJoin( aInsertPam );
+ }
+
+ bRet = true;
}
}
++aBegin;