inline InitGuard

since it is only used in one place

Change-Id: Ie541a255ddbe71105f6b58f02f372f4f45667d7a
This commit is contained in:
Noel Grandin
2017-01-13 11:58:14 +02:00
parent 53a3e0cd48
commit 978ff8f55c
3 changed files with 14 additions and 62 deletions

View File

@@ -211,8 +211,6 @@ bool containsXInterfaceSubclass(const Type* pType0) {
|| dc.Class("mem_fun_t").StdNamespace() || dc.Class("mem_fun_t").StdNamespace()
|| dc.Class("mem_fun1_t").StdNamespace() || dc.Class("mem_fun1_t").StdNamespace()
|| dc.Class("SwIterator").GlobalNamespace() || dc.Class("SwIterator").GlobalNamespace()
|| (dc.Class("InitGuard").Namespace("toolkit")
.GlobalNamespace())
|| (dc.Class("SharedUNOComponent").Namespace("utl") || (dc.Class("SharedUNOComponent").Namespace("utl")
.GlobalNamespace()) .GlobalNamespace())
|| (dc.Class("OAutoRegistration").Namespace("utl") || (dc.Class("OAutoRegistration").Namespace("utl")

View File

@@ -1,56 +0,0 @@
/* -*- 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_TOOLKIT_SOURCE_CONTROLS_GRID_INITGUARD_HXX
#define INCLUDED_TOOLKIT_SOURCE_CONTROLS_GRID_INITGUARD_HXX
#include <com/sun/star/lang/NotInitializedException.hpp>
#include <comphelper/componentguard.hxx>
namespace toolkit
{
//= InitGuard
template < class IMPL >
class InitGuard : public ::comphelper::ComponentGuard
{
public:
InitGuard( IMPL& i_component, ::cppu::OBroadcastHelper & i_broadcastHelper )
:comphelper::ComponentGuard( i_component, i_broadcastHelper )
{
if ( !i_component.isInitialized() )
throw css::lang::NotInitializedException( OUString(), *&i_component );
}
~InitGuard()
{
}
};
} // namespace toolkit
#endif // INCLUDED_TOOLKIT_SOURCE_CONTROLS_GRID_INITGUARD_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -17,13 +17,12 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include "initguard.hxx"
#include <com/sun/star/i18n/Collator.hpp> #include <com/sun/star/i18n/Collator.hpp>
#include <com/sun/star/i18n/XCollator.hpp> #include <com/sun/star/i18n/XCollator.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/NotInitializedException.hpp>
#include <com/sun/star/ucb/AlreadyInitializedException.hpp> #include <com/sun/star/ucb/AlreadyInitializedException.hpp>
#include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/awt/grid/XGridDataListener.hpp> #include <com/sun/star/awt/grid/XGridDataListener.hpp>
@@ -33,6 +32,7 @@
#include <cppuhelper/compbase.hxx> #include <cppuhelper/compbase.hxx>
#include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase1.hxx>
#include <comphelper/anycompare.hxx> #include <comphelper/anycompare.hxx>
#include <comphelper/componentguard.hxx>
#include <cppuhelper/supportsservice.hxx> #include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/typeprovider.hxx> #include <cppuhelper/typeprovider.hxx>
#include <tools/diagnose_ex.h> #include <tools/diagnose_ex.h>
@@ -45,12 +45,11 @@ using namespace css::i18n;
using namespace css::lang; using namespace css::lang;
using namespace css::ucb; using namespace css::ucb;
using namespace css::uno; using namespace css::uno;
using namespace toolkit;
namespace { namespace {
class SortableGridDataModel; class SortableGridDataModel;
typedef InitGuard< SortableGridDataModel > MethodGuard; class MethodGuard;
typedef ::cppu::WeakComponentImplHelper < css::awt::grid::XSortableMutableGridDataModel typedef ::cppu::WeakComponentImplHelper < css::awt::grid::XSortableMutableGridDataModel
, css::lang::XServiceInfo , css::lang::XServiceInfo
@@ -197,6 +196,17 @@ private:
::std::vector< ::sal_Int32 > m_privateToPublicRowIndex; ::std::vector< ::sal_Int32 > m_privateToPublicRowIndex;
}; };
class MethodGuard : public ::comphelper::ComponentGuard
{
public:
MethodGuard( SortableGridDataModel& i_component, ::cppu::OBroadcastHelper & i_broadcastHelper )
:comphelper::ComponentGuard( i_component, i_broadcastHelper )
{
if ( !i_component.isInitialized() )
throw css::lang::NotInitializedException( OUString(), *&i_component );
}
};
namespace namespace
{ {
template< class STLCONTAINER > template< class STLCONTAINER >