LibreOffice Module chart2 (master) 1
CloneHelper.hxx
Go to the documentation of this file.
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#pragma once
20
21#include <com/sun/star/util/XCloneable.hpp>
22#include <rtl/ref.hxx>
23#include <algorithm>
24#include <iterator>
25#include <vector>
26
28{
29
31template< class Interface >
33{
34 css::uno::Reference<Interface> operator() ( const css::uno::Reference<Interface> & xOther )
35 {
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 );
41
42 return xResult;
43 }
44};
45
47template< class Interface >
49 const std::vector< css::uno::Reference< Interface > > & rSource,
50 std::vector< css::uno::Reference< Interface > > & rDestination )
51{
52 std::transform( rSource.begin(), rSource.end(),
53 std::back_inserter( rDestination ),
55}
56
57template< class T >
59 const std::vector< rtl::Reference< T > > & rSource,
60 std::vector< rtl::Reference< T > > & rDestination )
61{
62 for (const auto & rSourceItem : rSource)
63 rDestination.push_back(static_cast<T*>(rSourceItem->createClone().get()));
64}
65
67template< class Interface >
69 const css::uno::Sequence< css::uno::Reference<Interface> > & rSource,
70 css::uno::Sequence< css::uno::Reference<Interface> > & rDestination )
71{
72 rDestination.realloc( rSource.getLength());
73 std::transform( rSource.begin(), rSource.end(),
74 rDestination.getArray(),
76}
77
78} // namespace chart::CloneHelper
79
80/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void CloneRefSequence(const css::uno::Sequence< css::uno::Reference< Interface > > &rSource, css::uno::Sequence< css::uno::Reference< Interface > > &rDestination)
clones a UNO-sequence of UNO-References
Definition: CloneHelper.hxx:68
void CloneRefVector(const std::vector< css::uno::Reference< Interface > > &rSource, std::vector< css::uno::Reference< Interface > > &rDestination)
clones a vector of UNO-References
Definition: CloneHelper.hxx:48
functor that clones a UNO-Reference
Definition: CloneHelper.hxx:33
css::uno::Reference< Interface > operator()(const css::uno::Reference< Interface > &xOther)
Definition: CloneHelper.hxx:34