2007-01-23 06:07:54 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
|
|
*
|
|
|
|
* $RCSfile: lazydelete.cxx,v $
|
|
|
|
*
|
2007-07-24 09:16:06 +00:00
|
|
|
* $Revision: 1.5 $
|
2007-01-23 06:07:54 +00:00
|
|
|
*
|
2007-07-24 09:16:06 +00:00
|
|
|
* last change: $Author: rt $ $Date: 2007-07-24 10:16:06 $
|
2007-01-23 06:07:54 +00:00
|
|
|
*
|
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
************************************************************************/
|
2007-01-26 06:27:40 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_vcl.hxx"
|
2007-01-23 06:07:54 +00:00
|
|
|
|
|
|
|
#ifndef LAZYDELETE_CXX
|
|
|
|
#define LAZYDELETE_CXX
|
|
|
|
|
2007-06-27 19:26:42 +00:00
|
|
|
#include <vcl/window.hxx>
|
|
|
|
#include <vcl/menu.hxx>
|
2007-07-24 09:16:06 +00:00
|
|
|
#include <vcl/lazydelete.hxx>
|
2007-01-23 06:07:54 +00:00
|
|
|
|
|
|
|
namespace vcl {
|
|
|
|
|
|
|
|
LazyDeletorBase::LazyDeletorBase()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
LazyDeletorBase::~LazyDeletorBase()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// instantiate instance pointers for LazyDeletor<Window,Menu>
|
|
|
|
template<> LazyDeletor<Window>* LazyDeletor<Window>::s_pOneInstance = NULL;
|
|
|
|
template<> LazyDeletor<Menu>* LazyDeletor<Menu>::s_pOneInstance = NULL;
|
|
|
|
|
|
|
|
// a list for all LazyeDeletor<T> singletons
|
|
|
|
static std::vector< LazyDeletorBase* > lcl_aDeletors;
|
|
|
|
|
|
|
|
void LazyDelete::addDeletor( LazyDeletorBase* i_pDel )
|
|
|
|
{
|
|
|
|
lcl_aDeletors.push_back( i_pDel );
|
|
|
|
}
|
|
|
|
|
|
|
|
void LazyDelete::flush()
|
|
|
|
{
|
|
|
|
unsigned int nCount = lcl_aDeletors.size();
|
|
|
|
for( unsigned int i = 0; i < nCount; i++ )
|
|
|
|
delete lcl_aDeletors[i];
|
|
|
|
lcl_aDeletors.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
// specialized is_less function for Window
|
|
|
|
template<> bool LazyDeletor<Window>::is_less( Window* left, Window* right )
|
|
|
|
{
|
|
|
|
return (left != right && right->IsChild( left, TRUE )) ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// specialized is_less function for Menu
|
|
|
|
template<> bool LazyDeletor<Menu>::is_less( Menu* left, Menu* right )
|
|
|
|
{
|
|
|
|
while( left && left != right )
|
|
|
|
left = left->ImplGetStartedFrom();
|
|
|
|
return left != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|