summaryrefslogtreecommitdiff
path: root/hwpfilter/source/hpara.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-04-08 21:04:45 +0100
committerMichael Stahl <mstahl@redhat.com>2017-04-12 15:54:22 +0200
commit4e175b7aee7c00c6d0d8449a19b26ebf25446b9d (patch)
treebea6bccdc858cd77aa6d9b5ee2d29d1cfcc45cb5 /hwpfilter/source/hpara.cxx
parent3e4e13300db6a0c2c60dbe733d96ff5a7b0d32e5 (diff)
ofz#1062 ensure cshape lifecycle matches expectations
Change-Id: I586e9b3546516a0f05d86b2f7dd93e7c292a6795 Reviewed-on: https://gerrit.libreoffice.org/36300 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'hwpfilter/source/hpara.cxx')
-rw-r--r--hwpfilter/source/hpara.cxx34
1 files changed, 13 insertions, 21 deletions
diff --git a/hwpfilter/source/hpara.cxx b/hwpfilter/source/hpara.cxx
index 84294c59ed3c..3149d65acf0a 100644
--- a/hwpfilter/source/hpara.cxx
+++ b/hwpfilter/source/hpara.cxx
@@ -75,17 +75,16 @@ HWPPara::HWPPara()
, etcflag(0)
, ctrlflag(0)
, pstyno(0)
+ , cshape(new CharShape)
, linfo(nullptr)
- , cshapep(nullptr)
{
- memset(&cshape, 0, sizeof(cshape));
+ memset(cshape.get(), 0, sizeof(cshape));
memset(&pshape, 0, sizeof(pshape));
}
HWPPara::~HWPPara()
{
delete[] linfo;
- delete[] cshapep;
}
bool HWPPara::Read(HWPFile & hwpf, unsigned char flag)
@@ -102,18 +101,17 @@ bool HWPPara::Read(HWPFile & hwpf, unsigned char flag)
hwpf.Read4b(&ctrlflag, 1);
hwpf.Read1b(&pstyno, 1);
-
/* Paragraph representative character */
- cshape.Read(hwpf);
+ cshape->Read(hwpf);
if (nch > 0)
- hwpf.AddCharShape(&cshape);
+ hwpf.AddCharShape(cshape);
/* Paragraph paragraphs shape */
if (nch && !reuse_shape)
{
pshape.Read(hwpf);
- pshape.cshape = &cshape;
- pshape.pagebreak = etcflag;
+ pshape.cshape = cshape.get();
+ pshape.pagebreak = etcflag;
}
linfo = ::comphelper::newArray_null<LineInfo>(nline);
@@ -144,23 +142,19 @@ bool HWPPara::Read(HWPFile & hwpf, unsigned char flag)
if (contain_cshape)
{
- cshapep = ::comphelper::newArray_null<CharShape>(nch);
- if (!cshapep)
- {
- perror("Memory Allocation: cshape\n");
- return false;
- }
- memset(cshapep, 0, nch * sizeof(CharShape));
+ cshapep.resize(nch);
for (ii = 0; ii < nch; ii++)
{
+ cshapep[ii].reset(new CharShape);
+ memset(cshapep[ii].get(), 0, sizeof(CharShape));
hwpf.Read1b(&same_cshape, 1);
if (!same_cshape)
{
- cshapep[ii].Read(hwpf);
+ cshapep[ii]->Read(hwpf);
if (nch > 1)
- hwpf.AddCharShape(&cshapep[ii]);
+ hwpf.AddCharShape(cshapep[ii]);
}
else if (ii == 0)
cshapep[ii] = cshape;
@@ -185,15 +179,13 @@ bool HWPPara::Read(HWPFile & hwpf, unsigned char flag)
return nch && !hwpf.State();
}
-
CharShape *HWPPara::GetCharShape(int pos)
{
if (contain_cshape == 0)
- return &cshape;
- return cshapep + pos;
+ return cshape.get();
+ return cshapep[pos].get();
}
-
std::unique_ptr<HBox> HWPPara::readHBox(HWPFile & hwpf)
{
std::unique_ptr<HBox> hbox;