LibreOffice Module svl (master) 1
ownlist.cxx
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
20#include <com/sun/star/uno/Sequence.hxx>
21#include <com/sun/star/beans/PropertyValue.hpp>
22#include <com/sun/star/beans/PropertyState.hpp>
23
24#include <svl/ownlist.hxx>
25
26using namespace com::sun::star;
27
28
34(
35 const OUString & rCommand, /* The command */
36 const OUString & rArg /* The command's argument */
37)
38{
39 aCommandList.emplace_back( rCommand, rArg );
40}
41
42void SvCommandList::FillFromSequence( const css::uno::Sequence < css::beans::PropertyValue >& aCommandSequence )
43{
44 OUString aCommand, aArg;
45 OUString aApiArg;
46 for( const auto& rCommand : aCommandSequence )
47 {
48 aCommand = rCommand.Name;
49 if( !( rCommand.Value >>= aApiArg ) )
50 return;
51 aArg = aApiArg;
52 Append( aCommand, aArg );
53 }
54}
55
56void SvCommandList::FillSequence( css::uno::Sequence < css::beans::PropertyValue >& aCommandSequence ) const
57{
58 const sal_Int32 nCount = aCommandList.size();
59 aCommandSequence.realloc( nCount );
60 auto pCommandSequence = aCommandSequence.getArray();
61 for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
62 {
63 pCommandSequence[nIndex].Name = aCommandList[ nIndex ].GetCommand();
64 pCommandSequence[nIndex].Handle = -1;
65 pCommandSequence[nIndex].Value <<= aCommandList[ nIndex ].GetArgument();
66 pCommandSequence[nIndex].State = beans::PropertyState_DIRECT_VALUE;
67 }
68}
69
70/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void FillSequence(css::uno::Sequence< css::beans::PropertyValue > &) const
Definition: ownlist.cxx:56
void FillFromSequence(const css::uno::Sequence< css::beans::PropertyValue > &)
Definition: ownlist.cxx:42
::std::vector< SvCommand > aCommandList
Definition: ownlist.hxx:57
void Append(const OUString &rCommand, const OUString &rArg)
An object of the type SvCommand is created and the list is attached.
Definition: ownlist.cxx:34
int nCount
sal_Int32 nIndex
OUString aCommand