Kaydet (Commit) f8ac4e2c authored tarafından Takeshi Abe's avatar Takeshi Abe Kaydeden (comit) Caolán McNamara

fdo#75757: remove inheritance to std::vector

from SwLabRecs, by typedef'ing it as boost::ptr_vector<SwLabRec>.

This is also a supposed fix for possible memory leaks in
SwLabDlg::_ReplaceGroup(), since erasing elements did not
delete pointers in the original code.

Change-Id: I1c8a0393cb5bdcfca3408e9c8dc770d306f6d334
Reviewed-on: https://gerrit.libreoffice.org/11597Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst e16c8534
......@@ -139,8 +139,8 @@ SwLabDlg::SwLabDlg(vcl::Window* pParent, const SfxItemSet& rSet,
for (size_t nRecPos = 0; nRecPos < pRecs->size(); ++nRecPos)
{
if (pRec->aMake == (*pRecs)[nRecPos]->aMake &&
pRec->aType == (*pRecs)[nRecPos]->aType)
if (pRec->aMake == (*pRecs)[nRecPos].aMake &&
pRec->aType == (*pRecs)[nRecPos].aType)
{
bDouble = true;
break;
......@@ -203,7 +203,7 @@ SwLabRec* SwLabDlg::GetRecord(const OUString &rRecName, bool bCont)
const size_t nCount = Recs().size();
for (size_t i = 0; i < nCount; ++i)
{
pRec = Recs()[i];
pRec = &Recs()[i];
if (pRec->aType != sCustom &&
rRecName == pRec->aType && bCont == pRec->bCont)
{
......@@ -212,7 +212,7 @@ SwLabRec* SwLabDlg::GetRecord(const OUString &rRecName, bool bCont)
}
}
if (!bFound) // User defined
pRec = Recs()[0];
pRec = &Recs()[0];
return(pRec);
}
......@@ -362,14 +362,14 @@ IMPL_LINK_NOARG(SwLabPage, MakeHdl)
//insert the entries into the sorted list box
for ( size_t i = 0; i < nCount; ++i )
{
const OUString aType ( GetParentSwLabDlg()->Recs()[i]->aType );
const OUString aType ( GetParentSwLabDlg()->Recs()[i].aType );
bool bInsert = false;
if ( GetParentSwLabDlg()->Recs()[i]->aType == sCustom )
if ( GetParentSwLabDlg()->Recs()[i].aType == sCustom )
{
bInsert = true;
m_pTypeBox->InsertEntry(aType );
}
else if ( GetParentSwLabDlg()->Recs()[i]->bCont == bCont )
else if ( GetParentSwLabDlg()->Recs()[i].bCont == bCont )
{
if ( m_pHiddenSortTypeBox->GetEntryPos(aType) == LISTBOX_ENTRY_NOTFOUND )
{
......
......@@ -489,7 +489,7 @@ void SwLabFmtPage::FillItem(SwLabItem& rItem)
{
rItem.aMake = rItem.aType = SW_RESSTR(STR_CUSTOM);
SwLabRec& rRec = *GetParentSwLabDlg()->Recs()[0];
SwLabRec& rRec = GetParentSwLabDlg()->Recs()[0];
rItem.lHDist = rRec.lHDist = static_cast< long >(GETFLDVAL(*m_pHDistField ));
rItem.lVDist = rRec.lVDist = static_cast< long >(GETFLDVAL(*m_pVDistField ));
rItem.lWidth = rRec.lWidth = static_cast< long >(GETFLDVAL(*m_pWidthField ));
......
......@@ -72,43 +72,10 @@
#include <svtools/treelistbox.hxx>
#include <label.hxx>
#include <labimg.hxx>
#include <vector>
#define GETFLDVAL(rField) (rField).Denormalize((rField).GetValue(FUNIT_TWIP))
#define SETFLDVAL(rField, lValue) (rField).SetValue((rField).Normalize(lValue), FUNIT_TWIP)
class SwLabRec
{
public:
SwLabRec(): lHDist(0), lVDist(0), lWidth(0), lHeight(0), lLeft(0), lUpper(0), lPWidth(0), lPHeight(0), nCols(0), nRows(0), bCont(false) {}
void SetFromItem( const SwLabItem& rItem );
void FillItem( SwLabItem& rItem ) const;
OUString aMake;
OUString aType;
long lHDist;
long lVDist;
long lWidth;
long lHeight;
long lLeft;
long lUpper;
long lPWidth;
long lPHeight;
sal_Int32 nCols;
sal_Int32 nRows;
bool bCont;
};
class SwLabRecs : public std::vector<SwLabRec*> {
public:
~SwLabRecs()
{
for(const_iterator it = begin(); it != end(); ++it)
delete *it;
}
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -24,8 +24,6 @@
#include <labelcfg.hxx>
#include <vector>
class SwLabRec;
class SwLabRecs;
class SwLabItem;
class SwLabPrtPage;
class SwDBManager;
......
......@@ -21,13 +21,11 @@
#include <unotools/configitem.hxx>
#include "swdllapi.h"
#include "labrec.hxx"
#include <map>
#include <vector>
class SwLabRecs;
class SwLabRec;
struct SwLabelMeasure
{
OUString m_aMeasure; // string contains the label dimensions
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_LABREC_HXX
#define INCLUDED_SW_SOURCE_UIBASE_INC_LABREC_HXX
#include <boost/ptr_container/ptr_vector.hpp>
class SwLabItem;
class SwLabRec
{
public:
SwLabRec(): lHDist(0), lVDist(0), lWidth(0), lHeight(0), lLeft(0), lUpper(0), lPWidth(0), lPHeight(0), nCols(0), nRows(0), bCont(false) {}
void SetFromItem( const SwLabItem& rItem );
void FillItem( SwLabItem& rItem ) const;
OUString aMake;
OUString aType;
long lHDist;
long lVDist;
long lWidth;
long lHeight;
long lLeft;
long lUpper;
long lPWidth;
long lPHeight;
sal_Int32 nCols;
sal_Int32 nRows;
bool bCont;
};
typedef boost::ptr_vector<SwLabRec> SwLabRecs;
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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