LibreOffice Module ucb (master) 1
ucbprops.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 <sal/config.h>
21
22#include <com/sun/star/uno/Sequence.hxx>
23#include <com/sun/star/beans/PropertyAttribute.hpp>
24#include <com/sun/star/ucb/CrossReference.hpp>
25#include <com/sun/star/util/DateTime.hpp>
26#include <com/sun/star/ucb/DocumentHeaderField.hpp>
27#include <com/sun/star/ucb/DocumentStoreMode.hpp>
28#include <com/sun/star/ucb/Priority.hpp>
29#include <com/sun/star/ucb/RecipientInfo.hpp>
30#include <com/sun/star/ucb/RuleSet.hpp>
31#include <com/sun/star/ucb/SendInfo.hpp>
32#include <com/sun/star/ucb/SendMediaTypes.hpp>
33#include <com/sun/star/ucb/SynchronizePolicy.hpp>
34#include <com/sun/star/ucb/VerificationMode.hpp>
35#include <com/sun/star/ucb/XDataContainer.hpp>
36#include <com/sun/star/uno/XComponentContext.hpp>
38#include <cppuhelper/weak.hxx>
39
40#include "ucbprops.hxx"
41
42using namespace com::sun::star::beans;
43using namespace com::sun::star::lang;
44using namespace com::sun::star::uno;
45
46#define ATTR_DEFAULT ( PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID | PropertyAttribute::MAYBEDEFAULT )
47
49: m_pProps({
50 { "Account", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
51 { "AutoUpdateInterval", -1, cppu::UnoType<sal_Int32>::get(), ATTR_DEFAULT },
52 { "ConfirmEmpty", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
53 { "ConnectionLimit", -1, cppu::UnoType<sal_Int16>::get(), ATTR_DEFAULT },
54 { "ConnectionMode", -1, cppu::UnoType<sal_Int16>::get(), ATTR_DEFAULT },
55 { "ContentCountLimit", -1, cppu::UnoType<sal_Int16>::get(), ATTR_DEFAULT },
56 { "ContentType", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
57 { "Cookie", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
58 { "CrossReferences", -1,
61 { "DateCreated", -1, cppu::UnoType<css::util::DateTime>::get(),
63 { "DateModified", -1, cppu::UnoType<css::util::DateTime>::get(),
65 { "DeleteOnServer", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
66 { "DocumentBody", -1, cppu::UnoType<css::uno::Sequence<sal_Int8>>::get(),
68 { "DocumentCount", -1, cppu::UnoType<sal_Int32>::get(),
69 ATTR_DEFAULT | PropertyAttribute::READONLY },
70 { "DocumentCountMarked", -1, cppu::UnoType<sal_Int32>::get(),
71 ATTR_DEFAULT | PropertyAttribute::READONLY },
72 { "DocumentHeader", -1,
75 { "DocumentStoreMode", -1,
77 { "DocumentViewMode", -1, cppu::UnoType<sal_Int16>::get(), ATTR_DEFAULT },
78 { "FTPAccount", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
80 { "FolderCount", -1, cppu::UnoType<sal_Int32>::get(),
81 ATTR_DEFAULT | PropertyAttribute::READONLY },
82 { "FolderViewMode", -1, cppu::UnoType<sal_Int16>::get(), ATTR_DEFAULT },
83 { "FreeSpace", -1, cppu::UnoType<sal_Int64>::get(),
84 ATTR_DEFAULT | PropertyAttribute::READONLY },
85 { "HasDocuments", -1, cppu::UnoType<bool>::get(),
86 ATTR_DEFAULT | PropertyAttribute::READONLY },
87 { "HasFolders", -1, cppu::UnoType<bool>::get(),
88 ATTR_DEFAULT | PropertyAttribute::READONLY },
89 { "IsAutoDelete", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
90 { "IsAutoUpdate", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
91 { "IsDocument", -1, cppu::UnoType<bool>::get(),
92 ATTR_DEFAULT | PropertyAttribute::READONLY },
93 { "IsFolder", -1, cppu::UnoType<bool>::get(),
94 ATTR_DEFAULT | PropertyAttribute::READONLY },
95 { "IsKeepExpired", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
96 { "IsLimitedContentCount", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
97 { "IsMarked", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
98 { "IsRead", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
99 { "IsReadOnly", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
100 { "IsSubscribed", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
101 { "IsTimeLimitedStore", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
102 { "Keywords", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
103 { "LocalBase", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
104 { "MessageBCC", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
106 ATTR_DEFAULT },
107 { "MessageCC", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
108 { "MessageFrom", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
109 { "MessageId", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
110 { "MessageInReplyTo", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
111 { "MessageReplyTo", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
112 { "MessageTo", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
113 { "NewsGroups", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
114 { "NoCacheList", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
115 { "Origin", -1, cppu::UnoType<OUString>::get(),
116 ATTR_DEFAULT | PropertyAttribute::READONLY },
117 { "OutgoingMessageRecipients", -1,
119 ATTR_DEFAULT },
120 { "OutgoingMessageState", -1,
122 ATTR_DEFAULT | PropertyAttribute::READONLY },
123 { "OutgoingMessageViewMode", -1, cppu::UnoType<sal_Int16>::get(),
124 ATTR_DEFAULT },
125 { "Password", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
127 { "References", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
128 { "Referer", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
130 { "SearchCriteria", -1, cppu::UnoType<css::ucb::RuleSet>::get(),
131 ATTR_DEFAULT },
132 { "SearchIndirections", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
133 { "SearchLocations", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
134 { "SearchRecursive", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
135 { "SeenCount", -1, cppu::UnoType<sal_Int32>::get(),
136 ATTR_DEFAULT | PropertyAttribute::READONLY },
137 { "SendCopyTarget", -1,
139 ATTR_DEFAULT },
140 { "SendFormats", -1,
142 ATTR_DEFAULT },
143 { "SendFroms", -1,
145 ATTR_DEFAULT },
146 { "SendPasswords", -1,
148 ATTR_DEFAULT },
149 { "SendProtocolPrivate", -1, cppu::UnoType<sal_Int16>::get(),
150 ATTR_DEFAULT },
151 { "SendProtocolPublic", -1, cppu::UnoType<sal_Int16>::get(), ATTR_DEFAULT },
152 { "SendReplyTos", -1,
154 ATTR_DEFAULT },
155 { "SendServerNames", -1,
157 ATTR_DEFAULT },
158 { "SendUserNames", -1,
160 ATTR_DEFAULT },
161 { "SendVIMPostOfficePath", -1, cppu::UnoType<OUString>::get(),
162 ATTR_DEFAULT },
163 { "ServerBase", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
164 { "ServerName", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
165 { "ServerPort", -1, cppu::UnoType<sal_Int16>::get(), ATTR_DEFAULT },
166 { "Size", -1, cppu::UnoType<sal_Int64>::get(),
167 ATTR_DEFAULT | PropertyAttribute::READONLY },
168 { "SizeLimit", -1, cppu::UnoType<sal_Int64>::get(), ATTR_DEFAULT },
169 { "SubscribedCount", -1, cppu::UnoType<sal_Int32>::get(),
170 ATTR_DEFAULT | PropertyAttribute::READONLY },
171 { "SynchronizePolicy", -1,
173 { "TargetFrames", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
174 { "TargetURL", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
175 { "TimeLimitStore", -1, cppu::UnoType<sal_Int16>::get(), ATTR_DEFAULT },
176 { "Title", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
177 { "UpdateOnOpen", -1, cppu::UnoType<bool>::get(), ATTR_DEFAULT },
178 { "UseOutBoxPrivateProtocolSettings", -1, cppu::UnoType<bool>::get(),
179 ATTR_DEFAULT },
180 { "UseOutBoxPublicProtocolSettings", -1, cppu::UnoType<bool>::get(),
181 ATTR_DEFAULT },
182 { "UserName", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
183 { "UserSortCriterium", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
184 { "VIMPostOfficePath", -1, cppu::UnoType<OUString>::get(), ATTR_DEFAULT },
185 { "VerificationMode", -1, cppu::UnoType<css::ucb::VerificationMode>::get(),
186 ATTR_DEFAULT }})
187{
188}
189
190
191// virtual
193{
194}
195
196// XServiceInfo methods.
197
199{
200 return "com.sun.star.comp.ucb.UcbPropertiesManager";
201}
202sal_Bool SAL_CALL UcbPropertiesManager::supportsService( const OUString& ServiceName )
203{
204 return cppu::supportsService( this, ServiceName );
205}
206css::uno::Sequence< OUString > SAL_CALL UcbPropertiesManager::getSupportedServiceNames()
207{
208 return { "com.sun.star.ucb.PropertiesManager" };
209}
210
211
212
213// Service factory implementation.
214
215extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
217 css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&)
218{
219 return cppu::acquire(new UcbPropertiesManager());
220}
221
222// XPropertySetInfo methods.
223
224
225// virtual
227{
228 return m_pProps;
229}
230
231
232// virtual
233Property SAL_CALL UcbPropertiesManager::getPropertyByName( const OUString& aName )
234{
235 Property aProp;
236 if ( queryProperty( aName, aProp ) )
237 return aProp;
238
239 throw UnknownPropertyException(aName);
240}
241
242
243// virtual
244sal_Bool SAL_CALL UcbPropertiesManager::hasPropertyByName( const OUString& Name )
245{
246 Property aProp;
247 return queryProperty( Name, aProp );
248}
249
250
251// Non-Interface methods.
252
253
255 const OUString& rName, Property& rProp )
256{
257 auto pProp = std::find_if(std::cbegin(m_pProps), std::cend(m_pProps),
258 [&rName](const Property& rCurrProp) { return rCurrProp.Name == rName; });
259 if (pProp != std::cend(m_pProps))
260 {
261 rProp = *pProp;
262 return true;
263 }
264
265 return false;
266}
267
268/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: ucbprops.cxx:202
virtual sal_Bool SAL_CALL hasPropertyByName(const OUString &Name) override
Definition: ucbprops.cxx:244
virtual OUString SAL_CALL getImplementationName() override
Definition: ucbprops.cxx:198
bool queryProperty(const OUString &rName, css::beans::Property &rProp)
Definition: ucbprops.cxx:254
virtual css::uno::Sequence< css::beans::Property > SAL_CALL getProperties() override
Definition: ucbprops.cxx:226
css::uno::Sequence< css::beans::Property > m_pProps
Definition: ucbprops.hxx:32
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: ucbprops.cxx:206
virtual css::beans::Property SAL_CALL getPropertyByName(const OUString &aName) override
Definition: ucbprops.cxx:233
virtual ~UcbPropertiesManager() override
Definition: ucbprops.cxx:192
css::uno::Type const & get()
OUString aName
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
OUString Name
unsigned char sal_Bool
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * ucb_UcbPropertiesManager_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
Definition: ucbprops.cxx:216
#define ATTR_DEFAULT
Definition: ucbprops.cxx:46