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