bump product version to 5.0.4.1
[LibreOffice.git] / forms / source / xforms / enumeration.cxx
blob50f9f3c972a8941d0b0da6e10dccf2b81b5b3a7e
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::Reference;
36 using com::sun::star::uno::RuntimeException;
39 Enumeration::Enumeration( XIndexAccess* pContainer )
40 : mxContainer( pContainer ),
41 mnIndex( 0 )
43 OSL_ENSURE( mxContainer.is(), "no container?" );
46 sal_Bool Enumeration::hasMoreElements()
47 throw( RuntimeException, std::exception )
49 if( ! mxContainer.is() )
50 throw RuntimeException();
52 return mnIndex < mxContainer->getCount();
55 Any Enumeration::nextElement()
56 throw( NoSuchElementException,
57 WrappedTargetException,
58 RuntimeException, std::exception )
60 if( ! mxContainer.is() )
61 throw RuntimeException();
62 if( mnIndex >= mxContainer->getCount() )
63 throw NoSuchElementException();
65 return mxContainer->getByIndex( mnIndex++ );
68 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */