Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / forms / source / xforms / enumeration.cxx
blobace7e3f5ae2b6f1ed0685a13fa8e0dba3191a334
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "enumeration.hxx"
23 #include <osl/diagnose.h>
25 #include <com/sun/star/container/NoSuchElementException.hpp>
26 #include <com/sun/star/container/XIndexAccess.hpp>
27 #include <com/sun/star/lang/WrappedTargetException.hpp>
28 #include <com/sun/star/uno/Any.hxx>
29 #include <com/sun/star/uno/RuntimeException.hpp>
31 using com::sun::star::container::NoSuchElementException;
32 using com::sun::star::container::XIndexAccess;
33 using com::sun::star::lang::WrappedTargetException;
34 using com::sun::star::uno::Any;
35 using com::sun::star::uno::RuntimeException;
38 Enumeration::Enumeration( XIndexAccess* pContainer )
39 : mxContainer( pContainer ),
40 mnIndex( 0 )
42 OSL_ENSURE( mxContainer.is(), "no container?" );
45 sal_Bool Enumeration::hasMoreElements()
47 if( ! mxContainer.is() )
48 throw RuntimeException();
50 return mnIndex < mxContainer->getCount();
53 Any Enumeration::nextElement()
55 if( ! mxContainer.is() )
56 throw RuntimeException();
57 if( mnIndex >= mxContainer->getCount() )
58 throw NoSuchElementException();
60 return mxContainer->getByIndex( mnIndex++ );
63 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */