Line data Source code
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 :
21 : #include "sal/config.h"
22 :
23 : #include "cppuhelper/implbase1.hxx"
24 :
25 : #include "com/sun/star/uno/XComponentContext.hpp"
26 : #include "com/sun/star/office/XAnnotationEnumeration.hpp"
27 :
28 : #include "sdpage.hxx"
29 :
30 : using namespace ::com::sun::star::uno;
31 : using namespace ::com::sun::star::office;
32 : using namespace ::com::sun::star::container;
33 : using namespace ::com::sun::star::lang;
34 :
35 : namespace sd {
36 :
37 0 : class AnnotationEnumeration: public ::cppu::WeakImplHelper1< css::office::XAnnotationEnumeration >
38 : {
39 : public:
40 : AnnotationEnumeration( const AnnotationVector& rAnnotations );
41 :
42 : // ::com::sun::star::office::XAnnotationEnumeration:
43 : virtual sal_Bool SAL_CALL hasMoreElements() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
44 : virtual css::uno::Reference< css::office::XAnnotation > SAL_CALL nextElement() throw (css::uno::RuntimeException, css::container::NoSuchElementException, std::exception) SAL_OVERRIDE;
45 :
46 : private:
47 : AnnotationEnumeration(const AnnotationEnumeration &); // not defined
48 : AnnotationEnumeration& operator=(const AnnotationEnumeration &); // not defined
49 :
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 0 : Reference< XAnnotationEnumeration > createAnnotationEnumeration( const sd::AnnotationVector& rAnnotations )
57 : {
58 0 : return new AnnotationEnumeration( rAnnotations );
59 : }
60 :
61 0 : AnnotationEnumeration::AnnotationEnumeration( const AnnotationVector& rAnnotations )
62 0 : : maAnnotations(rAnnotations)
63 : {
64 0 : maIter = maAnnotations.begin();
65 0 : }
66 :
67 : // ::com::sun::star::office::XAnnotationEnumeration:
68 0 : sal_Bool SAL_CALL AnnotationEnumeration::hasMoreElements() throw (css::uno::RuntimeException, std::exception)
69 : {
70 0 : return maIter != maAnnotations.end() ? sal_True : sal_False;
71 : }
72 :
73 0 : css::uno::Reference< css::office::XAnnotation > SAL_CALL AnnotationEnumeration::nextElement() throw (css::uno::RuntimeException, css::container::NoSuchElementException, std::exception)
74 : {
75 0 : if( maIter == maAnnotations.end() )
76 0 : throw css::container::NoSuchElementException();
77 :
78 0 : return (*maIter++);
79 : }
80 :
81 : } // namespace sd
82 :
83 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|