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
c6b99eedda
.
Change-Id: I447b21e841d22558d689f0f244d811c32e4923ec
This commit is contained in:
@@ -870,41 +870,38 @@ SwTxtPortion *SwTxtFormatter::WhichTxtPor( SwTxtFormatInfo &rInf ) const
|
|||||||
// Only at the End!
|
// Only at the End!
|
||||||
// If pCurr does not have a width, it can however aready have content.
|
// If pCurr does not have a width, it can however aready have content.
|
||||||
// E.g. for non-displayable characters
|
// 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 )
|
SwTxtNode *pNd = const_cast<SwTxtNode *>(rInf.GetTxtFrm()->GetTxtNode());
|
||||||
pPor = new SwFieldMarkPortion();
|
const SwDoc *doc = pNd->GetDoc();
|
||||||
else if( rInf.GetTxt()[rInf.GetIdx()]==CH_TXT_ATR_FIELDEND )
|
SwIndex aIndex(pNd, rInf.GetIdx());
|
||||||
pPor = new SwFieldMarkPortion();
|
SwPosition aPosition(*pNd, aIndex);
|
||||||
else if( rInf.GetTxt()[rInf.GetIdx()]==CH_TXT_ATR_FORMELEMENT )
|
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());
|
if (pBM->GetFieldname( ) == ODF_FORMCHECKBOX)
|
||||||
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)
|
pPor = new SwFieldFormCheckboxPortion();
|
||||||
{
|
}
|
||||||
pPor = new SwFieldFormCheckboxPortion();
|
else if (pBM->GetFieldname( ) == ODF_FORMDROPDOWN)
|
||||||
}
|
{
|
||||||
else if (pBM->GetFieldname( ) == ODF_FORMDROPDOWN)
|
pPor = new SwFieldFormDropDownPortion(sw::mark::ExpandFieldmark(pBM));
|
||||||
{
|
}
|
||||||
pPor = new SwFieldFormDropDownPortion(sw::mark::ExpandFieldmark(pBM));
|
/* we need to check for ODF_FORMTEXT for scenario having FormFields inside FORMTEXT.
|
||||||
}
|
* Otherwise file will crash on open.
|
||||||
/* we need to check for ODF_FORMTEXT for scenario having FormFields inside FORMTEXT.
|
*/
|
||||||
* Otherwise file will crash on open.
|
else if (pBM->GetFieldname( ) == ODF_FORMTEXT)
|
||||||
*/
|
{
|
||||||
else if (pBM->GetFieldname( ) == ODF_FORMTEXT)
|
pPor = new SwFieldMarkPortion();
|
||||||
{
|
}
|
||||||
pPor = new SwFieldMarkPortion();
|
else
|
||||||
}
|
{
|
||||||
else
|
assert( false ); // unknown type...
|
||||||
{
|
|
||||||
assert( false ); // unknown type...
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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()])
|
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 );
|
rInf.DrawBackBrush( *this );
|
||||||
const OUString aTxt(CH_TXT_ATR_SUBST_FIELDEND);
|
const OUString aTxt(CH_TXT_ATR_SUBST_FIELDEND);
|
||||||
rInf.DrawText( aTxt, *this, 0, aTxt.getLength(), false );
|
rInf.DrawText( aTxt, *this, 0, aTxt.getLength(), false );
|
||||||
}
|
}
|
||||||
else if (rInf.OnWin() && 1==rInf.GetLen() && CH_TXT_ATR_FIELDSTART==rInf.GetTxt()[rInf.GetIdx()])
|
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 );
|
rInf.DrawBackBrush( *this );
|
||||||
const OUString aTxt(CH_TXT_ATR_SUBST_FIELDSTART);
|
const OUString aTxt(CH_TXT_ATR_SUBST_FIELDSTART);
|
||||||
rInf.DrawText( aTxt, *this, 0, aTxt.getLength(), false );
|
rInf.DrawText( aTxt, *this, 0, aTxt.getLength(), false );
|
||||||
|
Reference in New Issue
Block a user