Kaydet (Commit) 8fe8bd6c authored tarafından Miklos Vajna's avatar Miklos Vajna

Related: fdo#61594 SwWW8ImplReader::StartApo: don't always start a frame

Word supports floating tables, Writer does not. We can map floating
tables to fly frames, containing just a table, but then those can't span
over multiple pages. We could avoid creating frames in case the table is
of multiple pages, but that's hard to determine.

One easy case is when the table width is >= the text area with, in that
case we can be sure that no wrapping would be performed anyway, so we
can avoid putting the table to a frame.

Two more related problems:

1) When we need to decide if a frame should be created or not, we
typically don't know yet the table width. That's why TestApo() has to
always succeed (in case the paragraphs are wrapped), and then we always
enter StartApo(), where we can avoid creating the frame, if necessary.

2) Even if we decide that we don't create a frame, floating and
non-floating table rows are different, so a separate table should be
created for such rows. By doing all the StartApo() / StopApo(), we are
safe here.

Change-Id: Ifc0e0e2f7320c3784698d0ff278031b46864e2e5
üst 6618d076
......@@ -2164,6 +2164,8 @@ SwTwips SwWW8ImplReader::MoveOutsideFly(SwFrmFmt *pFlyFmt,
const SwPosition &rPos, bool bTableJoin)
{
SwTwips nRetWidth = 0;
if (!pFlyFmt)
return nRetWidth;
// Alle Attribute schliessen, da sonst Attribute entstehen koennen,
// die aus Flys rausragen
WW8DupProperties aDup(rDoc,pCtrlStck);
......@@ -2314,10 +2316,15 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo,
WW8FlySet aFlySet(*this, pWFlyPara, pSFlyPara, false);
pSFlyPara->pFlyFmt = rDoc.MakeFlySection( pSFlyPara->eAnchor,
pPaM->GetPoint(), &aFlySet );
OSL_ENSURE(pSFlyPara->pFlyFmt->GetAnchor().GetAnchorId() ==
pSFlyPara->eAnchor, "Not the anchor type requested!");
if (pTabPos && pTabPos->bNoFly)
pSFlyPara->pFlyFmt = 0;
else
{
pSFlyPara->pFlyFmt = rDoc.MakeFlySection( pSFlyPara->eAnchor,
pPaM->GetPoint(), &aFlySet );
OSL_ENSURE(pSFlyPara->pFlyFmt->GetAnchor().GetAnchorId() ==
pSFlyPara->eAnchor, "Not the anchor type requested!");
}
if (pSFlyPara->pFlyFmt)
{
......@@ -2328,7 +2335,7 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo,
pWWZOrder->InsertTextLayerObject(pOurNewObject);
}
if (FLY_AS_CHAR != pSFlyPara->eAnchor)
if (FLY_AS_CHAR != pSFlyPara->eAnchor && pSFlyPara->pFlyFmt)
{
pAnchorStck->AddAnchor(*pPaM->GetPoint(),pSFlyPara->pFlyFmt);
}
......@@ -2342,7 +2349,8 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo,
pSFlyPara->pOldAnchorStck = pAnchorStck;
pAnchorStck = new SwWW8FltAnchorStack(&rDoc, nFieldFlags);
MoveInsideFly(pSFlyPara->pFlyFmt);
if (pSFlyPara->pFlyFmt)
MoveInsideFly(pSFlyPara->pFlyFmt);
// 1) ReadText() wird nicht wie beim W4W-Reader rekursiv aufgerufen,
// da die Laenge des Apo zu diesen Zeitpunkt noch nicht feststeht,
......@@ -2445,7 +2453,8 @@ void SwWW8ImplReader::StopApo()
pNd->JoinNext();
}
pSFlyPara->pFlyFmt->SetFmtAttr(SvxBrushItem(aBg, RES_BACKGROUND));
if (pSFlyPara->pFlyFmt)
pSFlyPara->pFlyFmt->SetFmtAttr(SvxBrushItem(aBg, RES_BACKGROUND));
DeleteAnchorStk();
pAnchorStck = pSFlyPara->pOldAnchorStck;
......@@ -2469,7 +2478,7 @@ void SwWW8ImplReader::StopApo()
#i27204# Added AutoWidth setting. Left the old CalculateFlySize in place
so that if the user unselects autowidth, the width doesn't max out
*/
else if( !pWFlyPara->nSp28 )
else if( !pWFlyPara->nSp28 && pSFlyPara->pFlyFmt)
{
using namespace sw::util;
SfxItemSet aFlySet( pSFlyPara->pFlyFmt->GetAttrSet() );
......@@ -4812,6 +4821,17 @@ bool SwWW8ImplReader::ParseTabPos(WW8_TablePos *pTabPos, WW8PLCFx_Cp_FKP* pPap)
pTabPos->nLoMgn = SVBT16ToShort(pRes);
bRet = true;
}
if (0 != (pRes = pPap->HasSprm(NS_sprm::LN_TDefTable)))
{
WW8TabBandDesc aDesc;
aDesc.ReadDef(false, pRes);
int nTableWidth = aDesc.nCenter[aDesc.nWwCols] - aDesc.nCenter[0];
int nTextAreaWidth = maSectionManager.GetTextAreaWidth();
// If the table is wider than the text area, then don't create a fly
// for the table: no wrapping will be performed anyway, but multi-page
// tables will be broken.
pTabPos->bNoFly = nTableWidth >= nTextAreaWidth;
}
return bRet;
}
......
......@@ -794,6 +794,7 @@ struct WW8_TablePos
sal_Int16 nLoMgn;
sal_uInt8 nSp29;
sal_uInt8 nSp37;
bool bNoFly;
};
struct WW8_FSPA
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment