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 : #ifndef INCLUDED_ANIMATIONS_ANIMATIONNODEHELPER_HXX
21 : #define INCLUDED_ANIMATIONS_ANIMATIONNODEHELPER_HXX
22 :
23 : #include <com/sun/star/uno/Reference.hxx>
24 : #include <com/sun/star/animations/XAnimationNode.hpp>
25 : #include <com/sun/star/container/XEnumerationAccess.hpp>
26 : #include <com/sun/star/container/XEnumeration.hpp>
27 :
28 : #include <vector>
29 :
30 : /* Declaration and definition of AnimationNode helper */
31 :
32 : namespace anim
33 : {
34 : // TODO(Q1): this could possibly be implemented with a somewhat
35 : // more lightweight template, by having the actual worker receive
36 : // only a function pointer, and a thin templated wrapper around
37 : // that which converts member functions into that.
38 :
39 : /** pushes the given node to the given vector and recursivly calls itself for each child node.
40 : */
41 0 : inline void create_deep_vector( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode,
42 : std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode > >& rVector )
43 : {
44 0 : rVector.push_back( xNode );
45 :
46 : try
47 : {
48 : // get an XEnumerationAccess to the children
49 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumerationAccess >
50 : xEnumerationAccess( xNode,
51 0 : ::com::sun::star::uno::UNO_QUERY );
52 :
53 0 : if( xEnumerationAccess.is() )
54 : {
55 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration >
56 0 : xEnumeration( xEnumerationAccess->createEnumeration(),
57 0 : ::com::sun::star::uno::UNO_QUERY );
58 :
59 0 : if( xEnumeration.is() )
60 : {
61 0 : while( xEnumeration->hasMoreElements() )
62 : {
63 : ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >
64 0 : xChildNode( xEnumeration->nextElement(),
65 0 : ::com::sun::star::uno::UNO_QUERY_THROW );
66 :
67 0 : create_deep_vector( xChildNode, rVector );
68 0 : }
69 0 : }
70 0 : }
71 : }
72 0 : catch( ::com::sun::star::uno::Exception& )
73 : {
74 : }
75 0 : }
76 : }
77 :
78 : #endif /* INCLUDED_ANIMATIONS_ANIMATIONNODEHELPER_HXX */
79 :
80 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|