diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2014-09-23 15:40:34 +0900 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-09-24 19:59:56 +0000 |
commit | f8ac4e2c436505304df7020a86dfc202851a9cab (patch) | |
tree | 3e5ce62ac2a5b674e351f57b5ef1ed7b59da9d1a /sw/source | |
parent | e16c8534f446a7cc311d6d5026aae5457e4f8e6c (diff) |
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/11597
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/ui/envelp/label1.cxx | 14 | ||||
-rw-r--r-- | sw/source/ui/envelp/labfmt.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/envelp/labimp.hxx | 33 | ||||
-rw-r--r-- | sw/source/uibase/inc/label.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/inc/labelcfg.hxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/inc/labrec.hxx | 53 |
6 files changed, 62 insertions, 46 deletions
diff --git a/sw/source/ui/envelp/label1.cxx b/sw/source/ui/envelp/label1.cxx index e9fdf5211dfa..a44e8509bdd1 100644 --- a/sw/source/ui/envelp/label1.cxx +++ b/sw/source/ui/envelp/label1.cxx @@ -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 ) { diff --git a/sw/source/ui/envelp/labfmt.cxx b/sw/source/ui/envelp/labfmt.cxx index 19fb1c086771..51a9955e8267 100644 --- a/sw/source/ui/envelp/labfmt.cxx +++ b/sw/source/ui/envelp/labfmt.cxx @@ -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 )); diff --git a/sw/source/uibase/envelp/labimp.hxx b/sw/source/uibase/envelp/labimp.hxx index caaf6068e501..982132fd3d32 100644 --- a/sw/source/uibase/envelp/labimp.hxx +++ b/sw/source/uibase/envelp/labimp.hxx @@ -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: */ diff --git a/sw/source/uibase/inc/label.hxx b/sw/source/uibase/inc/label.hxx index 838c1016c45e..61b452d245d4 100644 --- a/sw/source/uibase/inc/label.hxx +++ b/sw/source/uibase/inc/label.hxx @@ -24,8 +24,6 @@ #include <labelcfg.hxx> #include <vector> -class SwLabRec; -class SwLabRecs; class SwLabItem; class SwLabPrtPage; class SwDBManager; diff --git a/sw/source/uibase/inc/labelcfg.hxx b/sw/source/uibase/inc/labelcfg.hxx index 40bd8cea6192..0a8a162e077a 100644 --- a/sw/source/uibase/inc/labelcfg.hxx +++ b/sw/source/uibase/inc/labelcfg.hxx @@ -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 diff --git a/sw/source/uibase/inc/labrec.hxx b/sw/source/uibase/inc/labrec.hxx new file mode 100644 index 000000000000..3e5f124b1489 --- /dev/null +++ b/sw/source/uibase/inc/labrec.hxx @@ -0,0 +1,53 @@ +/* -*- 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: */ |