xref: /aoo41x/main/uui/source/getcontinuations.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef INCLUDED_UUI_GETCONTINUATIONS_HXX
29 #define INCLUDED_UUI_GETCONTINUATIONS_HXX
30 
31 #include "com/sun/star/uno/Reference.hxx"
32 #include "com/sun/star/uno/Sequence.hxx"
33 
34 namespace com { namespace sun { namespace star {
35     namespace task {
36         class XInteractionContinuation;
37     }
38 } } }
39 
40 template< class t1 >
41 bool setContinuation(
42     com::sun::star::uno::Reference<
43         com::sun::star::task::XInteractionContinuation > const & rContinuation,
44     com::sun::star::uno::Reference< t1 > * pContinuation)
45 {
46     if (pContinuation && !pContinuation->is())
47     {
48         pContinuation->set(rContinuation, com::sun::star::uno::UNO_QUERY);
49         if (pContinuation->is())
50             return true;
51     }
52     return false;
53 }
54 
55 template< class t1, class t2 >
56 void getContinuations(
57     com::sun::star::uno::Sequence<
58         com::sun::star::uno::Reference<
59             com::sun::star::task::XInteractionContinuation > > const &
60                 rContinuations,
61     com::sun::star::uno::Reference< t1 > * pContinuation1,
62     com::sun::star::uno::Reference< t2 > * pContinuation2)
63 {
64     for (sal_Int32 i = 0; i < rContinuations.getLength(); ++i)
65     {
66         if (setContinuation(rContinuations[i], pContinuation1))
67             continue;
68         if (setContinuation(rContinuations[i], pContinuation2))
69             continue;
70     }
71 }
72 
73 template< class t1, class t2, class t3 >
74 void getContinuations(
75     com::sun::star::uno::Sequence<
76         com::sun::star::uno::Reference<
77             com::sun::star::task::XInteractionContinuation > > const &
78                 rContinuations,
79     com::sun::star::uno::Reference< t1 > * pContinuation1,
80     com::sun::star::uno::Reference< t2 > * pContinuation2,
81     com::sun::star::uno::Reference< t3 > * pContinuation3)
82 {
83     for (sal_Int32 i = 0; i < rContinuations.getLength(); ++i)
84     {
85         if (setContinuation(rContinuations[i], pContinuation1))
86             continue;
87         if (setContinuation(rContinuations[i], pContinuation2))
88             continue;
89         if (setContinuation(rContinuations[i], pContinuation3))
90             continue;
91     }
92 }
93 
94 template< class t1, class t2, class t3, class t4 >
95 void getContinuations(
96     com::sun::star::uno::Sequence<
97         com::sun::star::uno::Reference<
98             com::sun::star::task::XInteractionContinuation > > const &
99                 rContinuations,
100     com::sun::star::uno::Reference< t1 > * pContinuation1,
101     com::sun::star::uno::Reference< t2 > * pContinuation2,
102     com::sun::star::uno::Reference< t3 > * pContinuation3,
103     com::sun::star::uno::Reference< t4 > * pContinuation4)
104 {
105     for (sal_Int32 i = 0; i < rContinuations.getLength(); ++i)
106     {
107         if (setContinuation(rContinuations[i], pContinuation1))
108             continue;
109         if (setContinuation(rContinuations[i], pContinuation2))
110             continue;
111         if (setContinuation(rContinuations[i], pContinuation3))
112             continue;
113         if (setContinuation(rContinuations[i], pContinuation4))
114             continue;
115     }
116 }
117 
118 #endif /* INCLUDED_UUI_GETCONTINUATIONS_HXX */
119