tdf#129993 broken tables opening LWP file

regression from
    commit e2080e70fe
    new compilerplugin returnbyref

The parts that fix this specific bug are in lwprowlayout.cxx and
lwprowlayout.cxx, but fix the other parts I messed up but not
understanding the semantics of assigning to reference variables.

Change-Id: I064cdd108c5b05da6092da0297dc7bcf487c7702
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87686
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2020-01-29 16:04:27 +02:00
parent 41a83d3207
commit 0b113d6ebb
6 changed files with 80 additions and 80 deletions

View File

@@ -114,15 +114,15 @@ void LwpFnRowLayout::Read()
void LwpFnRowLayout::RegisterStyle()
{
// register cells' style
LwpObjectID& rCellID = GetChildHead();
LwpCellLayout * pCellLayout = dynamic_cast<LwpCellLayout *>(rCellID.obj().get());
LwpObjectID* pCellID = &GetChildHead();
LwpCellLayout * pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj().get());
while(pCellLayout)
{
pCellLayout->SetFoundry(m_pFoundry);
pCellLayout->RegisterStyle();
rCellID = pCellLayout->GetNext();
pCellLayout = dynamic_cast<LwpCellLayout *>(rCellID.obj().get());
pCellID = &pCellLayout->GetNext();
pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj().get());
}
}
@@ -194,15 +194,15 @@ void LwpEndnoteLayout::Read()
void LwpEndnoteLayout::RegisterStyle()
{
// register style of rows
LwpObjectID& rRowID = GetChildHead();
LwpRowLayout * pRowLayout = dynamic_cast<LwpRowLayout *>(rRowID.obj().get());
LwpObjectID* pRowID = &GetChildHead();
LwpRowLayout * pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj().get());
while (pRowLayout)
{
pRowLayout->SetFoundry(m_pFoundry);
pRowLayout->RegisterStyle();
rRowID = pRowLayout->GetNext();
pRowLayout = dynamic_cast<LwpRowLayout *>(rRowID.obj().get());
pRowID = &pRowLayout->GetNext();
pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj().get());
}
}
@@ -254,12 +254,12 @@ void LwpEnSuperTableLayout::XFConvert(XFContentContainer * /*pCont*/)
*/
LwpVirtualLayout* LwpEnSuperTableLayout::GetMainTableLayout()
{
LwpObjectID& rID = GetChildTail();
LwpObjectID *pID = &GetChildTail();
LwpVirtualLayout *pPrevLayout = nullptr;
while(!rID.IsNull())
while(!pID->IsNull())
{
LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(rID.obj().get());
LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(pID->obj().get());
if (!pLayout || pLayout == pPrevLayout)
{
break;
@@ -268,7 +268,7 @@ LwpVirtualLayout* LwpEnSuperTableLayout::GetMainTableLayout()
{
return pLayout;
}
rID = pLayout->GetPrevious();
pID = &pLayout->GetPrevious();
pPrevLayout = pLayout;
}
@@ -312,11 +312,11 @@ void LwpFnSuperTableLayout::XFConvert(XFContentContainer * /*pCont*/)
*/
LwpVirtualLayout* LwpFnSuperTableLayout::GetMainTableLayout()
{
LwpObjectID& rID = GetChildTail();
LwpObjectID *pID = &GetChildTail();
while(!rID.IsNull())
while(pID && !pID->IsNull())
{
LwpVirtualLayout * pLayout = dynamic_cast<LwpVirtualLayout *>(rID.obj().get());
LwpVirtualLayout * pLayout = dynamic_cast<LwpVirtualLayout *>(pID->obj().get());
if(!pLayout)
{
break;
@@ -325,7 +325,7 @@ LwpVirtualLayout* LwpFnSuperTableLayout::GetMainTableLayout()
{
return pLayout;
}
rID = pLayout->GetPrevious();
pID = &pLayout->GetPrevious();
}
return nullptr;

View File

@@ -216,15 +216,15 @@ LwpBookMark* LwpFoundry::GetBookMark(LwpObjectID objMarker)
if (!pHeadHolder)
return nullptr;
LwpObjectID& rObjID = pHeadHolder->GetHeadID();
LwpBookMark* pBookMark = dynamic_cast<LwpBookMark*>(rObjID.obj().get());
LwpObjectID* pObjID = &pHeadHolder->GetHeadID();
LwpBookMark* pBookMark = dynamic_cast<LwpBookMark*>(pObjID->obj().get());
while (pBookMark)
{
if (pBookMark->IsRightMarker(objMarker))
return pBookMark;
rObjID = pBookMark->GetNext();
pBookMark = dynamic_cast<LwpBookMark*>(rObjID.obj().get());
pObjID = &pBookMark->GetNext();
pBookMark = dynamic_cast<LwpBookMark*>(pObjID->obj().get());
}
return nullptr;
}

View File

@@ -383,12 +383,12 @@ bool LwpVirtualLayout::IsStyleLayout()
*/
LwpVirtualLayout* LwpVirtualLayout::FindChildByType(LWP_LAYOUT_TYPE eType)
{
LwpObjectID& rID = GetChildHead();
LwpObjectID *pID = &GetChildHead();
LwpVirtualLayout* pPrevLayout = nullptr;
while(!rID.IsNull())
while(pID && !pID->IsNull())
{
LwpVirtualLayout * pLayout = dynamic_cast<LwpVirtualLayout *>(rID.obj().get());
LwpVirtualLayout * pLayout = dynamic_cast<LwpVirtualLayout *>(pID->obj().get());
if (!pLayout)
break;
@@ -403,7 +403,7 @@ LwpVirtualLayout* LwpVirtualLayout::FindChildByType(LWP_LAYOUT_TYPE eType)
if (pLayout->GetLayoutType() == eType)
return pLayout;
rID = pLayout->GetNext();
pID = &pLayout->GetNext();
}
return nullptr;

View File

@@ -93,8 +93,8 @@ LwpRowLayout::~LwpRowLayout()
*/
void LwpRowLayout::SetRowMap()
{
LwpObjectID& rCellID= GetChildHead();
LwpCellLayout * pCellLayout = dynamic_cast<LwpCellLayout *>(rCellID.obj().get());
LwpObjectID *pCellID= &GetChildHead();
LwpCellLayout * pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj().get());
std::set<LwpCellLayout*> aSeen;
while(pCellLayout)
@@ -102,8 +102,8 @@ void LwpRowLayout::SetRowMap()
aSeen.insert(pCellLayout);
pCellLayout->SetCellMap();
rCellID = pCellLayout->GetNext();
pCellLayout = dynamic_cast<LwpCellLayout *>(rCellID.obj().get());
pCellID = &pCellLayout->GetNext();
pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj().get());
if (aSeen.find(pCellLayout) != aSeen.end())
throw std::runtime_error("loop in conversion");
}
@@ -137,8 +137,8 @@ void LwpRowLayout::RegisterStyle()
pTableLayout->GetTable();
}
// register cells' style
LwpObjectID& rCellID= GetChildHead();
LwpCellLayout * pCellLayout = dynamic_cast<LwpCellLayout *>(rCellID.obj().get());
LwpObjectID *pCellID= &GetChildHead();
LwpCellLayout * pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj().get());
std::set<LwpCellLayout*> aSeen;
while (pCellLayout)
@@ -147,8 +147,8 @@ void LwpRowLayout::RegisterStyle()
pCellLayout->SetFoundry(m_pFoundry);
pCellLayout->RegisterStyle();
rCellID = pCellLayout->GetNext();
pCellLayout = dynamic_cast<LwpCellLayout *>(rCellID.obj().get());
pCellID = &pCellLayout->GetNext();
pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj().get());
if (aSeen.find(pCellLayout) != aSeen.end())
throw std::runtime_error("loop in conversion");
@@ -387,8 +387,8 @@ void LwpRowLayout::ConvertCommonRow(rtl::Reference<XFTable> const & pXFTable, sa
for (sal_uInt8 i = nStartCol; i < nEndCol ; i++)
{
// add row to table
LwpObjectID& rCellID= GetChildHead();
LwpCellLayout * pCellLayout = dynamic_cast<LwpCellLayout *>(rCellID.obj().get());
LwpObjectID *pCellID= &GetChildHead();
LwpCellLayout * pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj().get());
nCellStartCol = i;//mark the begin position of cell
nCellEndCol = i;//mark the end position of cell
rtl::Reference<XFCell> xCell;
@@ -405,8 +405,8 @@ void LwpRowLayout::ConvertCommonRow(rtl::Reference<XFTable> const & pXFTable, sa
xCell = pCellLayout->DoConvertCell(pTable->GetObjectID(),crowid,i);
break;
}
rCellID = pCellLayout->GetNext();
pCellLayout = dynamic_cast<LwpCellLayout *>(rCellID.obj().get());
pCellID = &pCellLayout->GetNext();
pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj().get());
}
if (!pCellLayout)
{
@@ -436,8 +436,8 @@ void LwpRowLayout::ConvertCommonRow(rtl::Reference<XFTable> const & pXFTable, sa
*/
void LwpRowLayout::CollectMergeInfo()
{
LwpObjectID& rCellID= GetChildHead();
LwpCellLayout * pCellLayout = dynamic_cast<LwpCellLayout *>(rCellID.obj().get());
LwpObjectID *pCellID= &GetChildHead();
LwpCellLayout * pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj().get());
while(pCellLayout)
{
@@ -446,8 +446,8 @@ void LwpRowLayout::CollectMergeInfo()
LwpConnectedCellLayout* pConnCell = static_cast<LwpConnectedCellLayout*>(pCellLayout);
m_ConnCellList.push_back(pConnCell);
}
rCellID = pCellLayout->GetNext();
pCellLayout = dynamic_cast<LwpCellLayout *>(rCellID.obj().get());
pCellID = &pCellLayout->GetNext();
pCellLayout = dynamic_cast<LwpCellLayout *>(pCellID->obj().get());
}
}
/**

View File

@@ -109,11 +109,11 @@ void LwpSuperTableLayout::Read()
*/
LwpTableLayout* LwpSuperTableLayout::GetTableLayout()
{
LwpObjectID& rID = GetChildTail();
LwpObjectID *pID = &GetChildTail();
while(!rID.IsNull())
while(pID && !pID->IsNull())
{
LwpLayout* pLayout = dynamic_cast<LwpLayout*>(rID.obj().get());
LwpLayout* pLayout = dynamic_cast<LwpLayout*>(pID->obj().get());
if (!pLayout)
{
break;
@@ -122,7 +122,7 @@ LwpTableLayout* LwpSuperTableLayout::GetTableLayout()
{
return dynamic_cast<LwpTableLayout *>(pLayout);
}
rID = pLayout->GetPrevious();
pID = &pLayout->GetPrevious();
}
return nullptr;
@@ -133,11 +133,11 @@ LwpTableLayout* LwpSuperTableLayout::GetTableLayout()
*/
LwpTableHeadingLayout* LwpSuperTableLayout::GetTableHeadingLayout()
{
LwpObjectID& rID = GetChildTail();
LwpObjectID *pID = &GetChildTail();
while(!rID.IsNull())
while(pID && !pID->IsNull())
{
LwpLayout * pLayout = dynamic_cast<LwpLayout *>(rID.obj().get());
LwpLayout * pLayout = dynamic_cast<LwpLayout *>(pID->obj().get());
if (!pLayout)
{
break;
@@ -147,7 +147,7 @@ LwpTableHeadingLayout* LwpSuperTableLayout::GetTableHeadingLayout()
{
return dynamic_cast<LwpTableHeadingLayout *>(pLayout);
}
rID = pLayout->GetPrevious();
pID = &pLayout->GetPrevious();
}
return nullptr;
@@ -229,8 +229,8 @@ double LwpSuperTableLayout::GetTableWidth()
for(sal_uInt16 i =0; i< nCol; i++)
{
LwpObjectID& rColumnID = pTableLayout->GetColumnLayoutHead();
LwpColumnLayout * pColumnLayout = dynamic_cast<LwpColumnLayout *>(rColumnID.obj().get());
LwpObjectID *pColumnID = &pTableLayout->GetColumnLayoutHead();
LwpColumnLayout * pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColumnID->obj().get());
double dColumnWidth = dDefaultWidth;
std::set<LwpColumnLayout*> aSeen;
while (pColumnLayout)
@@ -241,8 +241,8 @@ double LwpSuperTableLayout::GetTableWidth()
dColumnWidth = pColumnLayout->GetWidth();
break;
}
rColumnID = pColumnLayout->GetNext();
pColumnLayout = dynamic_cast<LwpColumnLayout *>(rColumnID.obj().get());
pColumnID = &pColumnLayout->GetNext();
pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColumnID->obj().get());
if (aSeen.find(pColumnLayout) != aSeen.end())
throw std::runtime_error("loop in conversion");
}
@@ -450,8 +450,8 @@ void LwpTableLayout::TraverseTable()
m_WordProCellsMap.insert(m_WordProCellsMap.end(), nCount, m_pDefaultCellLayout);
// set value
LwpObjectID& rRowID = GetChildHead();
LwpRowLayout * pRowLayout = dynamic_cast<LwpRowLayout *>(rRowID.obj().get());
LwpObjectID* pRowID = &GetChildHead();
LwpRowLayout * pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj().get());
std::set<LwpRowLayout*> aSeen;
while (pRowLayout)
{
@@ -464,8 +464,8 @@ void LwpTableLayout::TraverseTable()
pRowLayout->CollectMergeInfo();
// end for 's analysis
rRowID = pRowLayout->GetNext();
pRowLayout = dynamic_cast<LwpRowLayout *>(rRowID.obj().get());
pRowID = &pRowLayout->GetNext();
pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj().get());
if (aSeen.find(pRowLayout) != aSeen.end())
throw std::runtime_error("loop in conversion");
}
@@ -569,8 +569,8 @@ void LwpTableLayout::RegisterColumns()
// Get total width of justifiable columns
// NOTICE: all default columns are regarded as justifiable columns
LwpObjectID& rColumnID = GetColumnLayoutHead();
LwpColumnLayout * pColumnLayout = dynamic_cast<LwpColumnLayout *>(rColumnID.obj().get());
LwpObjectID* pColumnID = &GetColumnLayoutHead();
LwpColumnLayout * pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColumnID->obj().get());
std::set<LwpColumnLayout*> aSeen;
while (pColumnLayout)
{
@@ -589,8 +589,8 @@ void LwpTableLayout::RegisterColumns()
nJustifiableColumn --;
}
rColumnID = pColumnLayout->GetNext();
pColumnLayout = dynamic_cast<LwpColumnLayout *>(rColumnID.obj().get());
pColumnID = &pColumnLayout->GetNext();
pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColumnID->obj().get());
if (aSeen.find(pColumnLayout) != aSeen.end())
throw std::runtime_error("loop in conversion");
@@ -670,15 +670,15 @@ void LwpTableLayout::RegisterRows()
m_DefaultRowStyleName = pXFStyleManager->AddStyle(std::move(xRowStyle)).m_pStyle->GetStyleName();
// register style of rows
LwpObjectID& rRowID = GetChildHead();
LwpRowLayout * pRowLayout = dynamic_cast<LwpRowLayout *>(rRowID.obj().get());
LwpObjectID * pRowID = &GetChildHead();
LwpRowLayout * pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj().get());
while (pRowLayout)
{
pRowLayout->SetFoundry(m_pFoundry);
pRowLayout->RegisterStyle();
rRowID = pRowLayout->GetNext();
pRowLayout = dynamic_cast<LwpRowLayout *>(rRowID.obj().get());
pRowID = &pRowLayout->GetNext();
pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj().get());
}
}
/**
@@ -1274,8 +1274,8 @@ void LwpTableLayout::ConvertColumn(rtl::Reference<XFTable> const & pXFTable, sal
for (sal_uInt32 iLoop = 0; iLoop < static_cast<sal_uInt32>(nEndCol)-nStartCol; ++iLoop)
{
// add row to table
LwpObjectID& rColID = GetColumnLayoutHead();
LwpColumnLayout * pColumnLayout = dynamic_cast<LwpColumnLayout *>(rColID.obj().get());
LwpObjectID *pColID = &GetColumnLayoutHead();
LwpColumnLayout * pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColID->obj().get());
while (pColumnLayout)
{
if (pColumnLayout->GetColumnID() == (iLoop+nStartCol))
@@ -1283,8 +1283,8 @@ void LwpTableLayout::ConvertColumn(rtl::Reference<XFTable> const & pXFTable, sal
pXFTable->SetColumnStyle(iLoop+1, pColumnLayout->GetStyleName());
break;
}
rColID = pColumnLayout->GetNext();
pColumnLayout = dynamic_cast<LwpColumnLayout *>(rColID.obj().get());
pColID = &pColumnLayout->GetNext();
pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColID->obj().get());
}
if (!pColumnLayout)
{
@@ -1417,15 +1417,15 @@ XFCell* LwpTableLayout::GetCellsMap(sal_uInt16 nRow,sal_uInt8 nCol)
*/
LwpRowLayout* LwpTableLayout::GetRowLayout(sal_uInt16 nRow)
{
LwpObjectID& rRowID = GetChildHead();
LwpRowLayout * pRowLayout = dynamic_cast<LwpRowLayout *>(rRowID.obj().get());
LwpObjectID *pRowID = &GetChildHead();
LwpRowLayout * pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj().get());
while (pRowLayout)
{
if(pRowLayout->GetRowID() == nRow)
return pRowLayout;
rRowID = pRowLayout->GetNext();
pRowLayout = dynamic_cast<LwpRowLayout *>(rRowID.obj().get());
pRowID = &pRowLayout->GetNext();
pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj().get());
}
return nullptr;
}

View File

@@ -393,8 +393,8 @@ sal_uInt16 LwpTocSuperLayout::GetSeparatorType(sal_uInt16 index)
*/
LwpTocLevelData * LwpTocSuperLayout::GetSearchLevelPtr(sal_uInt16 index)
{
LwpObjectID& rID = m_SearchItems.GetHead();
LwpTocLevelData * pObj = dynamic_cast<LwpTocLevelData *>(rID.obj().get());
LwpObjectID * pID = &m_SearchItems.GetHead(); // not necessary to check pID NULL or not
LwpTocLevelData * pObj = dynamic_cast<LwpTocLevelData *>(pID->obj().get());
while(pObj)
{
@@ -403,8 +403,8 @@ LwpTocLevelData * LwpTocSuperLayout::GetSearchLevelPtr(sal_uInt16 index)
return pObj;
}
rID = pObj->GetNext();
pObj = dynamic_cast<LwpTocLevelData *>(rID.obj().get());
pID = &pObj->GetNext(); // not necessary to check pID NULL or not
pObj = dynamic_cast<LwpTocLevelData *>(pID->obj().get());
}
return nullptr;
@@ -417,8 +417,8 @@ LwpTocLevelData * LwpTocSuperLayout::GetSearchLevelPtr(sal_uInt16 index)
*/
LwpTocLevelData * LwpTocSuperLayout::GetNextSearchLevelPtr(sal_uInt16 index, LwpTocLevelData * pCurData)
{
LwpObjectID& rID = pCurData->GetNext();
LwpTocLevelData * pObj = dynamic_cast<LwpTocLevelData *>(rID.obj().get());
LwpObjectID * pID = &pCurData->GetNext();
LwpTocLevelData * pObj = dynamic_cast<LwpTocLevelData *>(pID->obj().get());
while(pObj)
{
@@ -427,8 +427,8 @@ LwpTocLevelData * LwpTocSuperLayout::GetNextSearchLevelPtr(sal_uInt16 index, Lwp
return pObj;
}
rID = pObj->GetNext();
pObj = dynamic_cast<LwpTocLevelData *>(rID.obj().get());
pID = &pObj->GetNext(); // not necessary to check pID NULL or not
pObj = dynamic_cast<LwpTocLevelData *>(pID->obj().get());
}
return nullptr;