LibreOffice Module sd (master) 1
AnnotationEnumeration.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <sal/config.h>
21
23#include <com/sun/star/container/NoSuchElementException.hpp>
24#include <com/sun/star/office/XAnnotationEnumeration.hpp>
25
27#include <sdpage.hxx>
28
29using namespace ::com::sun::star::uno;
30using namespace ::com::sun::star::office;
31using namespace ::com::sun::star::container;
32using namespace ::com::sun::star::lang;
33
34namespace sd {
35
36namespace {
37
38class AnnotationEnumeration: public ::cppu::WeakImplHelper< css::office::XAnnotationEnumeration >
39{
40public:
41 explicit AnnotationEnumeration( AnnotationVector&& rAnnotations );
42 AnnotationEnumeration(const AnnotationEnumeration&) = delete;
43 AnnotationEnumeration& operator=(const AnnotationEnumeration&) = delete;
44
45 // css::office::XAnnotationEnumeration:
46 virtual sal_Bool SAL_CALL hasMoreElements() override;
47 virtual css::uno::Reference< css::office::XAnnotation > SAL_CALL nextElement() override;
48
49private:
50 // destructor is private and will be called indirectly by the release call virtual ~AnnotationEnumeration() {}
51
52 AnnotationVector maAnnotations;
53 AnnotationVector::iterator maIter;
54};
55
56}
57
58Reference< XAnnotationEnumeration > createAnnotationEnumeration( sd::AnnotationVector&& rAnnotations )
59{
60 return new AnnotationEnumeration( std::move(rAnnotations) );
61}
62
63AnnotationEnumeration::AnnotationEnumeration( AnnotationVector&& rAnnotations )
64: maAnnotations(std::move(rAnnotations))
65{
66 maIter = maAnnotations.begin();
67}
68
69// css::office::XAnnotationEnumeration:
70sal_Bool SAL_CALL AnnotationEnumeration::hasMoreElements()
71{
72 return maIter != maAnnotations.end();
73}
74
75css::uno::Reference< css::office::XAnnotation > SAL_CALL AnnotationEnumeration::nextElement()
76{
77 if( maIter == maAnnotations.end() )
78 throw css::container::NoSuchElementException();
79
80 return (*maIter++);
81}
82
83} // namespace sd
84
85/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< Reference< XAnimationNode > >::iterator maIter
Reference< XAnnotationEnumeration > createAnnotationEnumeration(sd::AnnotationVector &&rAnnotations)
std::vector< css::uno::Reference< css::office::XAnnotation > > AnnotationVector
Definition: sdpage.hxx:82
unsigned char sal_Bool