Hi,
This patch replace SV_DECL_PTRARR_DEL by a simple ptr_vector in
sw/source/filter/ww8/ww8par2.cxx. I will continue on the same way in this
folder if there is no issue with this patch.
I noticed with the RTF spec (doc file) a memory error (not due to this
patch) :
==5526== Invalid read of size 1
==5526== at 0x24F492F4: SVBT16ToShort(unsigned char const*) (solar.h:88)
==5526== by 0x24FF3547: SwWW8ImplReader::Read_UL(unsigned short,
unsigned char const*, short) (ww8par6.cxx:4180)
==5526== by 0x24FF5EEB: SwWW8ImplReader::ImportSprm(unsigned char
const*, unsigned short) (ww8par6.cxx:6140)
==5526== by 0x24FA6687: WW8RStyle::ImportSprms(unsigned char*, short,
bool) (ww8par2.cxx:3646)
==5526== by 0x24FA6736: WW8RStyle::ImportSprms(unsigned long, short,
bool) (ww8par2.cxx:3663)
==5526== by 0x24FA690A: WW8RStyle::ImportUPX(short, bool, bool)
(ww8par2.cxx:3720)
==5526== by 0x24FA69FC: WW8RStyle::ImportGrupx(short, bool, bool)
(ww8par2.cxx:3742)
==5526== by 0x24FA771A: WW8RStyle::Import1Style(unsigned short)
(ww8par2.cxx:3950)
==5526== by 0x24FA93CF: WW8RStyle::ImportNewFormatStyles()
(ww8par2.cxx:4461)
==5526== by 0x24FA9430: WW8RStyle::ImportStyles() (ww8par2.cxx:4469)
==5526== by 0x24FA94CC: WW8RStyle::Import() (ww8par2.cxx:4481)
==5526== by 0x24F77FF8: SwWW8ImplReader::CoreLoad(WW8Glossary*,
SwPosition const&) (ww8par.cxx:4474)
==5526== by 0x24F7B48D: SwWW8ImplReader::LoadThroughDecryption(SwPaM&,
WW8Glossary*) (ww8par.cxx:5144)
==5526== by 0x24F7C7CA: SwWW8ImplReader::LoadDoc(SwPaM&, WW8Glossary*)
(ww8par.cxx:5452)
==5526== by 0x24F7CBF3: WW8Reader::Read(SwDoc&, String const&, SwPaM&,
String const&) (ww8par.cxx:5541)
==5526== by 0x1EB8CD0A: SwReader::Read(Reader const&) (shellio.cxx:183)
==5526== by 0x1ECCD05B: SwDocShell::ConvertFrom(SfxMedium&)
(docsh.cxx:256)
==5526== by 0x6750747: SfxObjectShell::DoLoad(SfxMedium*)
(objstor.cxx:746)
==5526== by 0x679BEB5:
SfxBaseModel::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>
const&) (sfxbasemodel.cxx:1904)
==5526== by 0x67E83A8:
SfxFrameLoader_Impl::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>
const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame>
const&) (frmload.cxx:611)
Ps : this file need few hours on my computer to be opened with LibO +
Valgrind and have bad results, this is the only usable result I've got.
Best regards
--
Arnaud Versini
From fa661be1e6ac23712d847720b116f53a6a9dc946 Mon Sep 17 00:00:00 2001
From: Arnaud Versini <arnaud.versini@gmail.com>
Date: Sun, 18 Mar 2012 10:20:37 +0100
Subject: [PATCH] Use ptr_vector instead of SV_DECL_PTRARR_DEL for
WW8MergeGroups
---
sw/source/filter/ww8/ww8par2.cxx | 59 ++++++++++++++++----------------------
1 files changed, 25 insertions(+), 34 deletions(-)
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index b78030c..84fcfc5 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -97,8 +97,7 @@ public:
typedef WW8SelBoxInfo* WW8SelBoxInfoPtr;
-SV_DECL_PTRARR_DEL(WW8MergeGroups, WW8SelBoxInfoPtr, 16)
-SV_IMPL_PTRARR(WW8MergeGroups, WW8SelBoxInfoPtr)
+typedef boost::ptr_vector<WW8SelBoxInfo> WW8MergeGroups;
struct WW8TabBandDesc
{
@@ -186,7 +185,7 @@ class WW8TabDesc
SwTableBoxes* pTabBoxes; // Boxen-Array in akt. Zeile
SwTableBox* pTabBox; // akt. Zelle
- WW8MergeGroups* pMergeGroups; // Listen aller zu verknuepfenden Zellen
+ WW8MergeGroups aMergeGroups; // Listen aller zu verknuepfenden Zellen
WW8_TCell* pAktWWCell;
@@ -224,7 +223,7 @@ class WW8TabDesc
void InsertCells( short nIns );
void AdjustNewBand();
- // durchsucht pMergeGroups, meldet Index der ersten, passenden Gruppe bzw.
+ // durchsucht aMergeGroups, meldet Index der ersten, passenden Gruppe bzw.
// -1 Details siehe bei der Implementierung
bool FindMergeGroup(short nX1, short nWidth, bool bExact, short& nMGrIdx);
@@ -1786,7 +1785,6 @@ WW8TabDesc::WW8TabDesc(SwWW8ImplReader* pIoClass, WW8_CP nStartCp) :
pTabLine(0),
pTabBoxes(0),
pTabBox(0),
- pMergeGroups(0),
pAktWWCell(0),
nRows(0),
nDefaultSwCols(0),
@@ -2112,7 +2110,6 @@ WW8TabDesc::~WW8TabDesc()
}
delete pParentPos;
- delete pMergeGroups;
}
void WW8TabDesc::CalcDefaults()
@@ -2630,11 +2627,6 @@ void WW8TabDesc::MergeCells()
short nX1 = pActBand->nCenter[ i ];
short nWidth = pActBand->nWidth[ i ];
- // 0. falls noetig das Array fuer die Merge-Gruppen
- // anlegen
- if( !pMergeGroups )
- pMergeGroups = new WW8MergeGroups;
-
// 2. aktuelle Merge-Gruppe anlegen
pActMGroup = new WW8SelBoxInfo( nX1, nWidth );
@@ -2662,11 +2654,11 @@ void WW8TabDesc::MergeCells()
while ( FindMergeGroup( nX1, pActMGroup->nGroupWidth,
false, nMGrIdx ) )
{
- (*pMergeGroups)[ nMGrIdx ]->bGroupLocked = true;
+ aMergeGroups[ nMGrIdx ].bGroupLocked = true;
}
// 3. und in Gruppen-Array eintragen
- pMergeGroups->Insert(pActMGroup, pMergeGroups->Count());
+ aMergeGroups.push_back(pActMGroup);
}
// ggfs. akt. Box zu einer Merge-Gruppe hinzufuegen (dies
@@ -2739,22 +2731,21 @@ void WW8TabDesc::FinishSwTable()
MergeCells();
// falls noetig, zu mergende Zellen gruppenweise zusammenfassen
- if( pMergeGroups )
+ if( !aMergeGroups.empty() )
{
// bearbeite alle Merge-Gruppen nacheinander
- WW8SelBoxInfo* pActMGroup;
- sal_uInt16 nActBoxCount;
-
- for (sal_uInt16 iGr = 0; iGr < pMergeGroups->Count(); ++iGr)
+ for (
+ WW8MergeGroups::iterator groupIt = aMergeGroups.begin();
+ groupIt < aMergeGroups.end();
+ groupIt++)
{
- pActMGroup = (*pMergeGroups)[ iGr ];
- nActBoxCount = pActMGroup->size();
+ sal_uInt16 nActBoxCount = groupIt->size();
- if( ( 1 < nActBoxCount ) && pActMGroup && pActMGroup->begin()->second )
+ if( ( 1 < nActBoxCount ) && groupIt->begin()->second )
{
- const sal_uInt16 nRowSpan = pActMGroup->size();
+ const sal_uInt16 nRowSpan = groupIt->size();
sal_uInt16 n = 0;
- for( SwSelBoxes::const_iterator it = pActMGroup->begin(); it != pActMGroup->end();
++it )
+ for( SwSelBoxes::const_iterator it = groupIt->begin(); it != groupIt->end(); ++it )
{
SwTableBox* pCurrentBox = it->second;
const long nRowSpanSet = n == 0 ?
@@ -2766,12 +2757,12 @@ void WW8TabDesc::FinishSwTable()
}
}
pIo->pFmtOfJustInsertedApo = 0;
- DELETEZ( pMergeGroups );
+ aMergeGroups.clear();
}
}
-// durchsucht pMergeGroups, meldet Index der ersten, passenden Gruppe bzw. -1
+// durchsucht aMergeGroups, meldet Index der ersten, passenden Gruppe bzw. -1
//
// Parameter: nXcenter = Mittenposition der anfragenden Box
// nWidth = Breite der anfragenden Box
@@ -2782,12 +2773,12 @@ bool WW8TabDesc::FindMergeGroup(short nX1, short nWidth, bool bExact,
short& nMGrIdx)
{
nMGrIdx = -1;
- if( pMergeGroups )
+ if( !aMergeGroups.empty() )
{
// noch als gueltig angesehener Bereich in der Naehe der Grenzen
const short nToleranz = 4;
// die aktuell untersuchte Gruppe
- WW8SelBoxInfoPtr pActGroup;
+
// Boxgrenzen
short nX2 = nX1 + nWidth;
// ungefaehre Gruppengrenzen
@@ -2795,16 +2786,16 @@ bool WW8TabDesc::FindMergeGroup(short nX1, short nWidth, bool bExact,
short nGrX2;
// improvement: search backwards
- for ( short iGr = pMergeGroups->Count() - 1; iGr >= 0; --iGr )
+ for ( short iGr = aMergeGroups.size() - 1; iGr >= 0; --iGr )
{
// die aktuell untersuchte Gruppe
- pActGroup = (*pMergeGroups)[ iGr ];
- if (!pActGroup->bGroupLocked)
+ WW8SelBoxInfo& rActGroup = aMergeGroups[ iGr ];
+ if (!rActGroup.bGroupLocked)
{
// ungefaehre Gruppengrenzen mit Toleranz nach *aussen* hin
- nGrX1 = pActGroup->nGroupXStart - nToleranz;
- nGrX2 = pActGroup->nGroupXStart
- +pActGroup->nGroupWidth + nToleranz;
+ nGrX1 = rActGroup.nGroupXStart - nToleranz;
+ nGrX2 = rActGroup.nGroupXStart
+ +rActGroup.nGroupWidth + nToleranz;
//
// Falls Box reinpasst, melde auf jeden Fall den Erfolg
//
@@ -3342,7 +3333,7 @@ SwTableBox* WW8TabDesc::UpdateTableMergeGroup( WW8_TCell& rCell,
short nMGrIdx;
if( FindMergeGroup( pActBand->nCenter[ nCol ],
pActBand->nWidth[ nCol ], true, nMGrIdx ) )
- pTheMergeGroup = (*pMergeGroups)[ nMGrIdx ];
+ pTheMergeGroup = &aMergeGroups.at( nMGrIdx );
}
if( pTheMergeGroup )
{
--
1.7.5.4
Context
- [PATCH] Replace SV_DECL_PTRARR_DEL by ptr_vector in ww8par2.cxx · Arnaud Versini
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.