| 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 "filtask.hxx" |
| 21 |
#include "prov.hxx" |
| 22 |
#include "filprp.hxx" |
| 23 |
#include "filinl.hxx" |
| 24 |
|
| 25 |
using namespace fileaccess; |
| 26 |
using namespace com::sun::star; |
| 27 |
using namespace com::sun::star::uno; |
| 28 |
|
| 29 |
XPropertySetInfo_impl::XPropertySetInfo_impl( TaskManager* pMyShell,const OUString& aUnqPath ) |
| 30 |
: m_pMyShell( pMyShell ), |
| 31 |
m_seq( 0 ) |
| 32 |
{ |
| 33 |
m_pMyShell->m_pProvider->acquire(); |
| 34 |
|
| 35 |
TaskManager::ContentMap::iterator it = m_pMyShell->m_aContent.find( aUnqPath ); |
| 36 |
|
| 37 |
TaskManager::PropertySet& properties = it->second.properties; |
| 38 |
|
| 39 |
m_seq.realloc( properties.size() ); |
| 40 |
auto p_seq = m_seq.getArray(); |
| 41 |
|
| 42 |
sal_Int32 count = 0; |
| 43 |
for( const auto& rProp : properties ) |
| 44 |
{ |
| 45 |
p_seq[ count++ ] = beans::Property( rProp.getPropertyName(), |
| 46 |
rProp.getHandle(), |
| 47 |
rProp.getType(), |
| 48 |
rProp.getAttributes() ); |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
XPropertySetInfo_impl::XPropertySetInfo_impl( TaskManager* pMyShell,const Sequence< beans::Property >& seq ) |
| 54 |
: m_pMyShell( pMyShell ), |
| 55 |
m_seq( seq ) |
| 56 |
{ |
| 57 |
m_pMyShell->m_pProvider->acquire(); |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
XPropertySetInfo_impl::~XPropertySetInfo_impl() |
| 62 |
{ |
| 63 |
m_pMyShell->m_pProvider->release(); |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
beans::Property SAL_CALL |
| 68 |
XPropertySetInfo_impl::getPropertyByName( const OUString& aName ) |
| 69 |
{ |
| 70 |
auto pProp = std::find_if(std::cbegin(m_seq), std::cend(m_seq), |
| 71 |
[&aName](const beans::Property& rProp) { return rProp.Name == aName; }); |
| 72 |
if (pProp != std::cend(m_seq)) |
| 73 |
return *pProp; |
| 74 |
|
| 75 |
throw beans::UnknownPropertyException( aName ); |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
Sequence< beans::Property > SAL_CALL |
| 80 |
XPropertySetInfo_impl::getProperties() |
| 81 |
{ |
| 82 |
return m_seq; |
| 83 |
} |
| 84 |
|
| 85 |
|
| 86 |
sal_Bool SAL_CALL |
| 87 |
XPropertySetInfo_impl::hasPropertyByName( const OUString& aName ) |
| 88 |
{ |
| 89 |
return std::any_of(std::cbegin(m_seq), std::cend(m_seq), |
| 90 |
[&aName](const beans::Property& rProp) { return rProp.Name == aName; }); |
| 91 |
} |
| 92 |
|
| 93 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |