1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 #include "sal/config.h"
28 
29 #include "cppuhelper/implbase1.hxx"
30 
31 #include "com/sun/star/uno/XComponentContext.hpp"
32 #include "com/sun/star/office/XAnnotationEnumeration.hpp"
33 
34 #include "sdpage.hxx"
35 namespace css = ::com::sun::star;
36 
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::office;
39 using namespace ::com::sun::star::container;
40 using namespace ::com::sun::star::lang;
41 
42 namespace sd {
43 
44 class AnnotationEnumeration: public ::cppu::WeakImplHelper1< css::office::XAnnotationEnumeration >
45 {
46 public:
47     AnnotationEnumeration( const AnnotationVector& rAnnotations );
48 
49     // ::com::sun::star::office::XAnnotationEnumeration:
50     virtual ::sal_Bool SAL_CALL hasMoreElements() throw (css::uno::RuntimeException);
51     virtual css::uno::Reference< css::office::XAnnotation > SAL_CALL nextElement() throw (css::uno::RuntimeException, css::container::NoSuchElementException);
52 
53 private:
54     AnnotationEnumeration(const AnnotationEnumeration &); // not defined
55     AnnotationEnumeration& operator=(const AnnotationEnumeration &); // not defined
56 
57     // destructor is private and will be called indirectly by the release call    virtual ~AnnotationEnumeration() {}
58 
59     AnnotationVector maAnnotations;
60 	AnnotationVector::iterator maIter;
61 };
62 
createAnnotationEnumeration(const sd::AnnotationVector & rAnnotations)63 Reference< XAnnotationEnumeration > createAnnotationEnumeration( const sd::AnnotationVector& rAnnotations )
64 {
65 	return new AnnotationEnumeration( rAnnotations );
66 }
67 
AnnotationEnumeration(const AnnotationVector & rAnnotations)68 AnnotationEnumeration::AnnotationEnumeration( const AnnotationVector& rAnnotations )
69 : maAnnotations(rAnnotations)
70 {
71 	maIter = maAnnotations.begin();
72 }
73 
74 // ::com::sun::star::office::XAnnotationEnumeration:
hasMoreElements()75 ::sal_Bool SAL_CALL AnnotationEnumeration::hasMoreElements() throw (css::uno::RuntimeException)
76 {
77 	return maIter != maAnnotations.end() ? sal_True : sal_False;
78 }
79 
nextElement()80 css::uno::Reference< css::office::XAnnotation > SAL_CALL AnnotationEnumeration::nextElement() throw (css::uno::RuntimeException, css::container::NoSuchElementException)
81 {
82 	if( maIter == maAnnotations.end() )
83 		throw css::container::NoSuchElementException();
84 
85 	return (*maIter++);
86 }
87 
88 } // namespace sd
89 
90