1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #include <sal/config.h>
22 #include <cppuhelper/implbase.hxx>
23 #include <com/sun/star/container/NoSuchElementException.hpp>
24 #include <com/sun/star/office/XAnnotationEnumeration.hpp>
26 #include <AnnotationEnumeration.hxx>
29 using namespace ::com::sun::star::uno
;
30 using namespace ::com::sun::star::office
;
31 using namespace ::com::sun::star::container
;
32 using namespace ::com::sun::star::lang
;
38 class AnnotationEnumeration
: public ::cppu::WeakImplHelper
< css::office::XAnnotationEnumeration
>
41 explicit AnnotationEnumeration( AnnotationVector
&& rAnnotations
);
42 AnnotationEnumeration(const AnnotationEnumeration
&) = delete;
43 AnnotationEnumeration
& operator=(const AnnotationEnumeration
&) = delete;
45 // css::office::XAnnotationEnumeration:
46 virtual sal_Bool SAL_CALL
hasMoreElements() override
;
47 virtual css::uno::Reference
< css::office::XAnnotation
> SAL_CALL
nextElement() override
;
50 // destructor is private and will be called indirectly by the release call virtual ~AnnotationEnumeration() {}
52 AnnotationVector maAnnotations
;
53 AnnotationVector::iterator maIter
;
58 Reference
< XAnnotationEnumeration
> createAnnotationEnumeration( sd::AnnotationVector
&& rAnnotations
)
60 return new AnnotationEnumeration( std::move(rAnnotations
) );
63 AnnotationEnumeration::AnnotationEnumeration( AnnotationVector
&& rAnnotations
)
64 : maAnnotations(std::move(rAnnotations
))
66 maIter
= maAnnotations
.begin();
69 // css::office::XAnnotationEnumeration:
70 sal_Bool SAL_CALL
AnnotationEnumeration::hasMoreElements()
72 return maIter
!= maAnnotations
.end();
75 css::uno::Reference
< css::office::XAnnotation
> SAL_CALL
AnnotationEnumeration::nextElement()
77 if( maIter
== maAnnotations
.end() )
78 throw css::container::NoSuchElementException();
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */