[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - sw/source
Jan-Marek Glogowski
glogow at fbihome.de
Wed Oct 8 08:51:26 PDT 2014
sw/source/core/doc/doc.cxx | 49 ++++++++++++++++++++++++++++++++++-----------
1 file changed, 38 insertions(+), 11 deletions(-)
New commits:
commit 35166b42fdefd18a0d06b8053bae549466457c08
Author: Jan-Marek Glogowski <glogow at 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.
Reviewed-on: https://gerrit.libreoffice.org/10834
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at 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 at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 1c419fe..3079d8e 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;
More information about the Libreoffice-commits
mailing list