sw/source/core/doc/doc.cxx | 49 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 11 deletions(-)
New commits: commit 2579adb13188d276701b1504b4a10bed4d8d4b6f Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Thu Aug 7 14:49:36 2014 +0200 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 <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index fad297ac..c4b1ccb 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;
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits