nss: upgrade to release 3.73
[LibreOffice.git] / chart2 / source / inc / CloneHelper.hxx
blobd9771a2681f28a37f660567975efb71a5fb3f46b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #pragma once
21 #include <com/sun/star/util/XCloneable.hpp>
23 #include <algorithm>
24 #include <iterator>
25 #include <vector>
27 namespace chart::CloneHelper
30 /// functor that clones a UNO-Reference
31 template< class Interface >
32 struct CreateRefClone
34 css::uno::Reference<Interface> operator() ( const css::uno::Reference<Interface> & xOther )
36 css::uno::Reference<Interface> xResult;
37 css::uno::Reference< css::util::XCloneable >
38 xCloneable( xOther, css::uno::UNO_QUERY );
39 if( xCloneable.is())
40 xResult.set( xCloneable->createClone(), css::uno::UNO_QUERY );
42 return xResult;
46 /// clones a vector of UNO-References
47 template< class Interface >
48 void CloneRefVector(
49 const std::vector< css::uno::Reference< Interface > > & rSource,
50 std::vector< css::uno::Reference< Interface > > & rDestination )
52 std::transform( rSource.begin(), rSource.end(),
53 std::back_inserter( rDestination ),
54 CreateRefClone< Interface >());
57 /// clones a UNO-sequence of UNO-References
58 template< class Interface >
59 void CloneRefSequence(
60 const css::uno::Sequence< css::uno::Reference<Interface> > & rSource,
61 css::uno::Sequence< css::uno::Reference<Interface> > & rDestination )
63 rDestination.realloc( rSource.getLength());
64 std::transform( rSource.begin(), rSource.end(),
65 rDestination.getArray(),
66 CreateRefClone< Interface >());
69 } // namespace chart::CloneHelper
71 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */