Hi Noel
On 31/01/12 14:24, Noel Grandin wrote:
sorry, that should be "converted to std::vector"
you mean boost::ptr_vector I think :-)
Hope I didn't miss anything this time, I made some minor changes ( see
attached patch )
e.g. I removed the maLayoutNames.clear() from :~SdPresLayoutDlg() as the
vector will go out of scope here anyway and delete the container
contents. Also I changed slightly the code in IMPL_LINK(SdPresLayoutDlg,
ClickLoadHdl, void *, EMPTYARG) and got rid of a String copy and
slightly changed the calculation of 'nId' for maVS.SelectItem
I am currently running make check on it this time ;-) assuming it works
and no other objection to the patch I will commit to master
thanks again for the patch.
Noel
diff --git a/sd/source/ui/dlg/sdpreslt.cxx b/sd/source/ui/dlg/sdpreslt.cxx
index 98f2df5..db30dff 100644
--- a/sd/source/ui/dlg/sdpreslt.cxx
+++ b/sd/source/ui/dlg/sdpreslt.cxx
@@ -76,8 +76,6 @@ SdPresLayoutDlg::SdPresLayoutDlg(
{
FreeResource();
- mpLayoutNames = new List;
-
maVS.SetDoubleClickHdl(LINK(this, SdPresLayoutDlg, ClickLayoutHdl));
maBtnLoad.SetClickHdl(LINK(this, SdPresLayoutDlg, ClickLoadHdl));
@@ -92,14 +90,6 @@ SdPresLayoutDlg::SdPresLayoutDlg(
SdPresLayoutDlg::~SdPresLayoutDlg()
{
- String* pName = (String*)mpLayoutNames->First();
- while (pName)
- {
- delete pName;
- pName = (String*)mpLayoutNames->Next();
- }
-
- delete mpLayoutNames;
}
/*************************************************************************
@@ -131,10 +121,10 @@ void SdPresLayoutDlg::Reset()
FillValueSet();
- mnLayoutCount = mpLayoutNames->Count();
+ mnLayoutCount = maLayoutNames.size();
for( nName = 0; nName < mnLayoutCount; nName++ )
{
- if (*((String*)mpLayoutNames->GetObject(nName)) == maName)
+ if (maLayoutNames[nName] == maName)
break;
}
DBG_ASSERT(nName < mnLayoutCount, "Layout nicht gefunden");
@@ -161,11 +151,11 @@ void SdPresLayoutDlg::GetAttr(SfxItemSet& rOutAttrs)
{
aLayoutName = maName;
aLayoutName.Append( DOCUMENT_TOKEN );
- aLayoutName.Append( *(String*)mpLayoutNames->GetObject( nId - 1 ) );
+ aLayoutName.Append( maLayoutNames[ nId - 1 ] );
}
else
{
- aLayoutName = *(String*)mpLayoutNames->GetObject( nId - 1 );
+ aLayoutName = maLayoutNames[ nId - 1 ];
if( aLayoutName == maStrNone )
aLayoutName.Erase(); // so wird "- keine -" codiert (s.u.)
}
@@ -202,10 +192,10 @@ void SdPresLayoutDlg::FillValueSet()
{
String aLayoutName(pMaster->GetLayoutName());
aLayoutName.Erase( aLayoutName.SearchAscii( SD_LT_SEPARATOR ) );
- mpLayoutNames->Insert(new String(aLayoutName), LIST_APPEND);
+ maLayoutNames.push_back(new String(aLayoutName));
Bitmap aBitmap(mpDocSh->GetPagePreviewBitmap(pMaster, 90));
- maVS.InsertItem((sal_uInt16)mpLayoutNames->Count(), aBitmap, aLayoutName);
+ maVS.InsertItem((sal_uInt16)maLayoutNames.size(), aBitmap, aLayoutName);
}
}
@@ -274,21 +264,20 @@ IMPL_LINK(SdPresLayoutDlg, ClickLoadHdl, void *, EMPTYARG)
{
// Pruefen, ob Vorlage schon vorhanden
sal_Bool bExists = sal_False;
- String* pName = (String*)mpLayoutNames->First();
String aCompareStr( maName );
if( maName.Len() == 0 )
aCompareStr = maStrNone;
- while( pName && !bExists )
+ sal_uInt16 aPos = 0;
+ for (boost::ptr_vector<String>::iterator it = maLayoutNames.begin();
+ it != maLayoutNames.end() && !bExists; ++it, ++aPos)
{
- if( aCompareStr == *pName )
+ if( aCompareStr == *it )
{
bExists = sal_True;
// Vorlage selektieren
- sal_uInt16 nId = (sal_uInt16) mpLayoutNames->GetCurPos() + 1;
- maVS.SelectItem( nId );
+ maVS.SelectItem( aPos + 1 );
}
- pName = (String*)mpLayoutNames->Next();
}
if( !bExists )
@@ -313,10 +302,10 @@ IMPL_LINK(SdPresLayoutDlg, ClickLoadHdl, void *, EMPTYARG)
{
String aLayoutName(pMaster->GetLayoutName());
aLayoutName.Erase( aLayoutName.SearchAscii( SD_LT_SEPARATOR ) );
- mpLayoutNames->Insert(new String(aLayoutName), LIST_APPEND);
+ maLayoutNames.push_back(new String(aLayoutName));
Bitmap aBitmap(pTemplDocSh->GetPagePreviewBitmap(pMaster, 90));
- maVS.InsertItem((sal_uInt16)mpLayoutNames->Count(), aBitmap,
aLayoutName);
+ maVS.InsertItem((sal_uInt16)maLayoutNames.size(), aBitmap,
aLayoutName);
}
}
}
@@ -330,15 +319,15 @@ IMPL_LINK(SdPresLayoutDlg, ClickLoadHdl, void *, EMPTYARG)
else
{
// leeres Layout
- mpLayoutNames->Insert( new String( maStrNone ), LIST_APPEND );
- maVS.InsertItem( (sal_uInt16) mpLayoutNames->Count(),
+ maLayoutNames.push_back( new String( maStrNone ) );
+ maVS.InsertItem( (sal_uInt16) maLayoutNames.size(),
Bitmap( SdResId( BMP_FOIL_NONE ) ), maStrNone );
}
if (!bCancel)
{
// Vorlage selektieren
- maVS.SelectItem( (sal_uInt16) mpLayoutNames->Count() );
+ maVS.SelectItem( (sal_uInt16) maLayoutNames.size() );
}
}
}
diff --git a/sd/source/ui/inc/sdpreslt.hxx b/sd/source/ui/inc/sdpreslt.hxx
index d0a62d5..db74471 100644
--- a/sd/source/ui/inc/sdpreslt.hxx
+++ b/sd/source/ui/inc/sdpreslt.hxx
@@ -29,10 +29,11 @@
#ifndef SD_PRES_LAYOUT_DLG_HXX
#define SD_PRES_LAYOUT_DLG_HXX
+#include <boost/ptr_container/ptr_vector.hpp>
+
#include <vcl/dialog.hxx>
#include <vcl/button.hxx>
#include <vcl/fixed.hxx>
-#include <tools/list.hxx>
#include <svtools/valueset.hxx>
class SfxItemSet;
@@ -75,7 +76,7 @@ private:
const SfxItemSet& mrOutAttrs;
- List* mpLayoutNames;
+ boost::ptr_vector<String> maLayoutNames;
String maName; // Layoutname oder Dateiname
long mnLayoutCount; // Anzahl, der im Dokument vorhandenen MasterPages
Context
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.