Kaydet (Commit) 05bd9ed4 authored tarafından Caolán McNamara's avatar Caolán McNamara

forcepoint #8 ensure ColumnDef lifetime

Change-Id: Idb0c7b1530dc57f4d7c14751f1b76caecc3b03a6
Reviewed-on: https://gerrit.libreoffice.org/50288Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 86a5c40b
...@@ -201,6 +201,7 @@ ParaShape::ParaShape() ...@@ -201,6 +201,7 @@ ParaShape::ParaShape()
, pspacing_next(0) , pspacing_next(0)
, condense(0) , condense(0)
, arrange_type(0) , arrange_type(0)
, xColdef(new ColumnDef)
, shade(0) , shade(0)
, outline(0) , outline(0)
, outline_continue(0) , outline_continue(0)
...@@ -240,17 +241,17 @@ void ParaShape::Read(HWPFile & hwpf) ...@@ -240,17 +241,17 @@ void ParaShape::Read(HWPFile & hwpf)
return; return;
tab.position = tmp16; tab.position = tmp16;
} }
hwpf.Read1b(coldef.ncols); hwpf.Read1b(xColdef->ncols);
hwpf.Read1b(coldef.separator); hwpf.Read1b(xColdef->separator);
if (!hwpf.Read2b(tmp16)) if (!hwpf.Read2b(tmp16))
return; return;
coldef.spacing = tmp16; xColdef->spacing = tmp16;
if (!hwpf.Read2b(tmp16)) if (!hwpf.Read2b(tmp16))
return; return;
coldef.columnlen = tmp16; xColdef->columnlen = tmp16;
if (!hwpf.Read2b(tmp16)) if (!hwpf.Read2b(tmp16))
return; return;
coldef.columnlen0 = tmp16; xColdef->columnlen0 = tmp16;
hwpf.Read1b(shade); hwpf.Read1b(shade);
hwpf.Read1b(outline); hwpf.Read1b(outline);
hwpf.Read1b(outline_continue); hwpf.Read1b(outline_continue);
......
...@@ -292,7 +292,7 @@ struct ParaShape ...@@ -292,7 +292,7 @@ struct ParaShape
unsigned char condense; unsigned char condense;
unsigned char arrange_type; unsigned char arrange_type;
TabSet tabs[MAXTABS]; TabSet tabs[MAXTABS];
ColumnDef coldef; std::shared_ptr<ColumnDef> xColdef;
unsigned char shade; unsigned char shade;
unsigned char outline; unsigned char outline;
unsigned char outline_continue; unsigned char outline_continue;
......
...@@ -124,8 +124,8 @@ bool HWPPara::Read(HWPFile & hwpf, unsigned char flag) ...@@ -124,8 +124,8 @@ bool HWPPara::Read(HWPFile & hwpf, unsigned char flag)
} }
if (nch && !reuse_shape){ if (nch && !reuse_shape){
if( pshape->coldef.ncols > 1 ) { if( pshape->xColdef->ncols > 1 ) {
hwpf.SetColumnDef(&(pshape->coldef)); hwpf.SetColumnDef(pshape->xColdef);
} }
} }
......
...@@ -412,7 +412,7 @@ void HWPFile::TagsRead() ...@@ -412,7 +412,7 @@ void HWPFile::TagsRead()
ColumnDef *HWPFile::GetColumnDef(int num) ColumnDef *HWPFile::GetColumnDef(int num)
{ {
if (static_cast<size_t>(num) < columnlist.size()) if (static_cast<size_t>(num) < columnlist.size())
return columnlist[num]->coldef; return columnlist[num]->xColdef.get();
else else
return nullptr; return nullptr;
} }
...@@ -569,12 +569,12 @@ void HWPFile::AddColumnInfo() ...@@ -569,12 +569,12 @@ void HWPFile::AddColumnInfo()
setMaxSettedPage(); setMaxSettedPage();
} }
void HWPFile::SetColumnDef(ColumnDef *coldef) void HWPFile::SetColumnDef(const std::shared_ptr<ColumnDef>& rColdef)
{ {
ColumnInfo *cinfo = columnlist.back().get(); ColumnInfo *cinfo = columnlist.back().get();
if( cinfo->bIsSet ) if( cinfo->bIsSet )
return; return;
cinfo->coldef = coldef; cinfo->xColdef = rColdef;
cinfo->bIsSet = true; cinfo->bIsSet = true;
} }
......
...@@ -72,11 +72,10 @@ class HStream; ...@@ -72,11 +72,10 @@ class HStream;
struct ColumnInfo{ struct ColumnInfo{
int start_page; int start_page;
bool bIsSet; bool bIsSet;
ColumnDef *coldef; std::shared_ptr<ColumnDef> xColdef;
explicit ColumnInfo(int num){ explicit ColumnInfo(int num){
start_page = num; start_page = num;
bIsSet = false; bIsSet = false;
coldef = nullptr;
} }
}; };
...@@ -211,7 +210,7 @@ class DLLEXPORT HWPFile ...@@ -211,7 +210,7 @@ class DLLEXPORT HWPFile
void AddBox(FBox *); void AddBox(FBox *);
void AddPage(){ m_nCurrentPage++;} void AddPage(){ m_nCurrentPage++;}
void AddColumnInfo(); void AddColumnInfo();
void SetColumnDef(ColumnDef *coldef); void SetColumnDef(std::shared_ptr<ColumnDef> const &);
void AddParaShape(std::shared_ptr<ParaShape> const &); void AddParaShape(std::shared_ptr<ParaShape> const &);
void AddCharShape(std::shared_ptr<CharShape> const &); void AddCharShape(std::shared_ptr<CharShape> const &);
void AddFBoxStyle(FBoxStyle *); void AddFBoxStyle(FBoxStyle *);
......
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