diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-07-24 23:02:12 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-07-25 08:07:55 +0000 |
commit | 4d1a2b16e2421e93f2a0de6632607e69e6fbb2a2 (patch) | |
tree | f9e41a3f5171707622f7e6ef38e3ec130c50b22d | |
parent | e0a7557e97de0bad7ff8510c768bdbed6cdae6f5 (diff) |
fdo#81502: sw: fix spurious "[" being painted for field marks
There is a special SwFieldMarkPortion sub-class that is supposed to be
created for these, which overrides Paint() to do nothing; unfortunately
at least for the CH_TXT_ATR_FIELDSTART at beginning of a paragraph
a plain SwTxtPortion is created, because the check of rInf.Len() is
checking the length of the _previous_ text portion; the call to
rInf.SetLen() only happens after creation, in last line of
SwTxtFormatter::NewTxtPortion().
This problem affects RTF and DOCX files since commit
c6b99eedda03461202f9bf012a422dfd81da72ec.
(cherry picked from commit c3916303ebe63f9910cd2a4a38ac6a8d6ccee3e0)
Conflicts:
sw/source/core/text/itrform2.cxx
Change-Id: I447b21e841d22558d689f0f244d811c32e4923ec
Reviewed-on: https://gerrit.libreoffice.org/10525
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sw/source/core/text/itrform2.cxx | 47 | ||||
-rw-r--r-- | sw/source/core/text/portxt.cxx | 2 |
2 files changed, 24 insertions, 25 deletions
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index ac3afd1a28eb..2738b9b88363 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -874,34 +874,31 @@ SwTxtPortion *SwTxtFormatter::WhichTxtPor( SwTxtFormatInfo &rInf ) const // Only at the End! // If pCurr does not have a width, it can however aready have content. // E.g. for non-displayable characters - if( rInf.GetLen() > 0 ) + if (rInf.GetTxt()[rInf.GetIdx()]==CH_TXT_ATR_FIELDSTART) + pPor = new SwFieldMarkPortion(); + else if (rInf.GetTxt()[rInf.GetIdx()]==CH_TXT_ATR_FIELDEND) + pPor = new SwFieldMarkPortion(); + else if (rInf.GetTxt()[rInf.GetIdx()]==CH_TXT_ATR_FORMELEMENT) { - if( rInf.GetTxt()[rInf.GetIdx()]==CH_TXT_ATR_FIELDSTART ) - pPor = new SwFieldMarkPortion(); - else if( rInf.GetTxt()[rInf.GetIdx()]==CH_TXT_ATR_FIELDEND ) - pPor = new SwFieldMarkPortion(); - else if( rInf.GetTxt()[rInf.GetIdx()]==CH_TXT_ATR_FORMELEMENT ) + SwTxtNode *pNd = const_cast<SwTxtNode *>(rInf.GetTxtFrm()->GetTxtNode()); + const SwDoc *doc = pNd->GetDoc(); + SwIndex aIndex(pNd, rInf.GetIdx()); + SwPosition aPosition(*pNd, aIndex); + sw::mark::IFieldmark *pBM = doc->getIDocumentMarkAccess()->getFieldmarkFor(aPosition); + OSL_ENSURE(pBM != NULL, "Where is my form field bookmark???"); + if (pBM != NULL) { - SwTxtNode *pNd = const_cast<SwTxtNode *>(rInf.GetTxtFrm()->GetTxtNode()); - const SwDoc *doc = pNd->GetDoc(); - SwIndex aIndex(pNd, rInf.GetIdx()); - SwPosition aPosition(*pNd, aIndex); - sw::mark::IFieldmark *pBM = doc->getIDocumentMarkAccess()->getFieldmarkFor(aPosition); - OSL_ENSURE(pBM != NULL, "Where is my form field bookmark???"); - if (pBM != NULL) + if (pBM->GetFieldname( ) == ODF_FORMCHECKBOX) { - if (pBM->GetFieldname( ) == ODF_FORMCHECKBOX) - { - pPor = new SwFieldFormCheckboxPortion(); - } - else if (pBM->GetFieldname( ) == ODF_FORMDROPDOWN) - { - pPor = new SwFieldFormDropDownPortion(sw::mark::ExpandFieldmark(pBM)); - } - else - { - assert( false ); // unknown type... - } + pPor = new SwFieldFormCheckboxPortion(); + } + else if (pBM->GetFieldname( ) == ODF_FORMDROPDOWN) + { + pPor = new SwFieldFormDropDownPortion(sw::mark::ExpandFieldmark(pBM)); + } + else + { + assert( false ); // unknown type... } } } diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx index 420403e6ef7d..6303cb192ebc 100644 --- a/sw/source/core/text/portxt.cxx +++ b/sw/source/core/text/portxt.cxx @@ -517,12 +517,14 @@ void SwTxtPortion::Paint( const SwTxtPaintInfo &rInf ) const { if (rInf.OnWin() && 1==rInf.GetLen() && CH_TXT_ATR_FIELDEND==rInf.GetTxt()[rInf.GetIdx()]) { + assert(false); // this is some debugging only code rInf.DrawBackBrush( *this ); const OUString aTxt(CH_TXT_ATR_SUBST_FIELDEND); rInf.DrawText( aTxt, *this, 0, aTxt.getLength(), false ); } else if (rInf.OnWin() && 1==rInf.GetLen() && CH_TXT_ATR_FIELDSTART==rInf.GetTxt()[rInf.GetIdx()]) { + assert(false); // this is some debugging only code rInf.DrawBackBrush( *this ); const OUString aTxt(CH_TXT_ATR_SUBST_FIELDSTART); rInf.DrawText( aTxt, *this, 0, aTxt.getLength(), false ); |