Date: prev next · Thread: first prev next last
2010 Archives by date, by thread · List index



Source in question: sfx2/source/doc/doctemplates.cxx

The code looks like this:

//-----------------------------------------------------------------------------

struct NamePair_Impl
{
    OUString maShortName;
    OUString maLongName;
};

DECLARE_LIST( NameList_Impl, NamePair_Impl* )

class SfxDocTplService_Impl
{
        ...
    NameList_Impl                               maNames;
        ...
    void                                                readFolderList();
    OUString                                    getLongName( const OUString& rShortName );
        ...
}

void SfxDocTplService_Impl::readFolderList()
{
    SolarMutexGuard aGuard;

    ResStringArray  aShortNames( SfxResId( TEMPLATE_SHORT_NAMES_ARY ) );
    ResStringArray  aLongNames( SfxResId( TEMPLATE_LONG_NAMES_ARY ) );

    NamePair_Impl*  pPair;

    USHORT nCount = (USHORT)( Min( aShortNames.Count(), aLongNames.Count() ) );

    for ( USHORT i=0; i<nCount; i++ )
    {
        pPair = new NamePair_Impl;
        pPair->maShortName  = aShortNames.GetString( i );
        pPair->maLongName   = aLongNames.GetString( i );

        maNames.Insert( pPair, LIST_APPEND );
    }
}

OUString SfxDocTplService_Impl::getLongName( const OUString& rShortName )
{
    OUString         aRet;
    NamePair_Impl   *pPair = maNames.First();

    while ( pPair )
    {
        if ( pPair->maShortName == rShortName )
        {
            aRet = pPair->maLongName;
            break;
        }
        else
            pPair = maNames.Next();
    }

    if ( !aRet.getLength() )
        aRet = rShortName;

    return aRet;
}

//-----------------------------------------------------------------------------

No where in the code can I see where maNames gets cleanup up. The only destructor is in the base 
class which just cleans up the list memory and doesn't free the NamePair_Impl memory.

Container::~Container()
{
    DBG_DTOR( Container, DbgCheckContainer );

    // Alle Bloecke loeschen
    CBlock* pBlock = pFirstBlock;
    while ( pBlock )
    {
        CBlock* pTemp = pBlock->GetNextBlock();
        delete pBlock;
        pBlock = pTemp;
    }
}

I'm thinking of just adding code to ~SfxDocTplService_Impl() to free the NamePair_Impl items.

What I'd like to know is the following:

1. Am I reading this correctly?
2. Where is this uses, so I can test my changes? (I'm converting the above code to use a vector<>)

The use path is:
        NamePair_Impl
        SfxDocTplService_Impl
        Updater_Impl
        SfxDocTplService_Impl (yes, it's a circular definition)
        SfxDocTplService

        SfxDocTplService is registered as com.sun.star.frame.DocumentTemplates

        which gets used in:
                svtools/source/contnr/templwin.cxx
                sd/source/ui/dlg/TemplateScanner.cxx

Joe P.

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.