Line data Source code
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 : #include "vbadocumentproperties.hxx"
20 : #include <cppuhelper/implbase1.hxx>
21 : #include <cppuhelper/implbase3.hxx>
22 : #include <com/sun/star/document/XDocumentProperties.hpp>
23 : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
24 : #include <com/sun/star/beans/NamedValue.hpp>
25 : #include <com/sun/star/beans/XPropertyContainer.hpp>
26 : #include <ooo/vba/word/WdBuiltInProperty.hpp>
27 : #include <ooo/vba/office/MsoDocProperties.hpp>
28 : #include <boost/shared_ptr.hpp>
29 : #include "wordvbahelper.hxx"
30 : #include "fesh.hxx"
31 : #include "docsh.hxx"
32 : using namespace ::ooo::vba;
33 : using namespace css;
34 :
35 0 : static sal_Int8 lcl_toMSOPropType( const uno::Type& aType ) throw ( lang::IllegalArgumentException )
36 : {
37 0 : sal_Int16 msoType = office::MsoDocProperties::msoPropertyTypeString;
38 :
39 0 : switch ( aType.getTypeClass() )
40 : {
41 : case uno::TypeClass_BOOLEAN:
42 0 : msoType = office::MsoDocProperties::msoPropertyTypeBoolean;
43 0 : break;
44 : case uno::TypeClass_FLOAT:
45 0 : msoType = office::MsoDocProperties::msoPropertyTypeFloat;
46 0 : break;
47 : case uno::TypeClass_STRUCT: // Assume date
48 0 : msoType = office::MsoDocProperties::msoPropertyTypeDate;
49 0 : break;
50 : case uno::TypeClass_BYTE:
51 : case uno::TypeClass_SHORT:
52 : case uno::TypeClass_LONG:
53 : case uno::TypeClass_HYPER:
54 0 : msoType = office::MsoDocProperties::msoPropertyTypeNumber;
55 0 : break;
56 : default:
57 0 : throw lang::IllegalArgumentException();
58 : }
59 0 : return msoType;
60 : }
61 :
62 : class PropertGetSetHelper
63 : {
64 : protected:
65 : uno::Reference< frame::XModel > m_xModel;
66 : uno::Reference<document::XDocumentProperties> m_xDocProps;
67 : public:
68 0 : PropertGetSetHelper( const uno::Reference< frame::XModel >& xModel ):m_xModel( xModel )
69 : {
70 : uno::Reference<document::XDocumentPropertiesSupplier> const
71 0 : xDocPropSupp(m_xModel, uno::UNO_QUERY_THROW);
72 0 : m_xDocProps.set(xDocPropSupp->getDocumentProperties(),
73 0 : uno::UNO_SET_THROW);
74 0 : }
75 0 : virtual ~PropertGetSetHelper() {}
76 : virtual uno::Any getPropertyValue( const OUString& rPropName ) = 0;
77 : virtual void setPropertyValue( const OUString& rPropName, const uno::Any& aValue ) = 0;
78 0 : virtual uno::Reference< beans::XPropertySet > getUserDefinedProperties() {
79 : return uno::Reference<beans::XPropertySet>(
80 0 : m_xDocProps->getUserDefinedProperties(), uno::UNO_QUERY_THROW);
81 : }
82 :
83 : };
84 :
85 0 : class BuiltinPropertyGetSetHelper : public PropertGetSetHelper
86 : {
87 : public:
88 0 : BuiltinPropertyGetSetHelper( const uno::Reference< frame::XModel >& xModel ) :PropertGetSetHelper( xModel )
89 : {
90 0 : }
91 0 : virtual uno::Any getPropertyValue( const OUString& rPropName ) SAL_OVERRIDE
92 : {
93 0 : if ( rPropName == "EditingDuration" )
94 : {
95 0 : sal_Int32 const nSecs = m_xDocProps->getEditingDuration();
96 0 : return uno::makeAny( nSecs/60 ); // minutes
97 : }
98 0 : else if ("Title" == rPropName)
99 : {
100 0 : return uno::makeAny(m_xDocProps->getTitle());
101 : }
102 0 : else if ("Subject" == rPropName)
103 : {
104 0 : return uno::makeAny(m_xDocProps->getSubject());
105 : }
106 0 : else if ("Author" == rPropName)
107 : {
108 0 : return uno::makeAny(m_xDocProps->getAuthor());
109 : }
110 0 : else if ("Keywords" == rPropName)
111 : {
112 0 : return uno::makeAny(m_xDocProps->getKeywords());
113 : }
114 0 : else if ("Description" == rPropName)
115 : {
116 0 : return uno::makeAny(m_xDocProps->getDescription());
117 : }
118 0 : else if ("Template" == rPropName)
119 : {
120 0 : return uno::makeAny(m_xDocProps->getTemplateName());
121 : }
122 0 : else if ("ModifiedBy" == rPropName)
123 : {
124 0 : return uno::makeAny(m_xDocProps->getModifiedBy());
125 : }
126 0 : else if ("Generator" == rPropName)
127 : {
128 0 : return uno::makeAny(m_xDocProps->getGenerator());
129 : }
130 0 : else if ("PrintDate" == rPropName)
131 : {
132 0 : return uno::makeAny(m_xDocProps->getPrintDate());
133 : }
134 0 : else if ("CreationDate" == rPropName)
135 : {
136 0 : return uno::makeAny(m_xDocProps->getCreationDate());
137 : }
138 0 : else if ("ModifyDate" == rPropName)
139 : {
140 0 : return uno::makeAny(m_xDocProps->getModificationDate());
141 : }
142 0 : else if ("AutoloadURL" == rPropName)
143 : {
144 0 : return uno::makeAny(m_xDocProps->getAutoloadURL());
145 : }
146 : else
147 : {
148 : // fall back to user-defined properties
149 0 : return getUserDefinedProperties()->getPropertyValue(rPropName);
150 : }
151 : }
152 0 : virtual void setPropertyValue( const OUString& rPropName, const uno::Any& aValue ) SAL_OVERRIDE
153 : {
154 0 : if ("EditingDuration" == rPropName)
155 : {
156 0 : sal_Int32 nMins = 0;
157 0 : if (aValue >>= nMins)
158 : {
159 0 : m_xDocProps->setEditingDuration(nMins * 60); // convert minutes
160 : }
161 : }
162 0 : else if ("Title" == rPropName)
163 : {
164 0 : OUString str;
165 0 : if (aValue >>= str)
166 : {
167 0 : m_xDocProps->setTitle(str);
168 0 : }
169 : }
170 0 : else if ("Subject" == rPropName)
171 : {
172 0 : OUString str;
173 0 : if (aValue >>= str)
174 : {
175 0 : m_xDocProps->setSubject(str);
176 0 : }
177 : }
178 0 : else if ("Author" == rPropName)
179 : {
180 0 : OUString str;
181 0 : if (aValue >>= str)
182 : {
183 0 : m_xDocProps->setAuthor(str);
184 0 : }
185 : }
186 0 : else if ("Keywords" == rPropName)
187 : {
188 0 : uno::Sequence<OUString> keywords;
189 0 : if (aValue >>= keywords)
190 : {
191 0 : m_xDocProps->setKeywords(keywords);
192 0 : }
193 : }
194 0 : else if ("Description" == rPropName)
195 : {
196 0 : OUString str;
197 0 : if (aValue >>= str)
198 : {
199 0 : m_xDocProps->setDescription(str);
200 0 : }
201 : }
202 0 : else if ("Template" == rPropName)
203 : {
204 0 : OUString str;
205 0 : if (aValue >>= str)
206 : {
207 0 : m_xDocProps->setTemplateName(str);
208 0 : }
209 : }
210 0 : else if ("ModifiedBy" == rPropName)
211 : {
212 0 : OUString str;
213 0 : if (aValue >>= str)
214 : {
215 0 : m_xDocProps->setModifiedBy(str);
216 0 : }
217 : }
218 0 : else if ("Generator" == rPropName)
219 : {
220 0 : OUString str;
221 0 : if (aValue >>= str)
222 : {
223 0 : return m_xDocProps->setGenerator(str);
224 0 : }
225 : }
226 0 : else if ("PrintDate" == rPropName)
227 : {
228 0 : util::DateTime dt;
229 0 : if (aValue >>= dt)
230 : {
231 0 : m_xDocProps->setPrintDate(dt);
232 : }
233 : }
234 0 : else if ("CreationDate" == rPropName)
235 : {
236 0 : util::DateTime dt;
237 0 : if (aValue >>= dt)
238 : {
239 0 : m_xDocProps->setCreationDate(dt);
240 : }
241 : }
242 0 : else if ("ModifyDate" == rPropName)
243 : {
244 0 : util::DateTime dt;
245 0 : if (aValue >>= dt)
246 : {
247 0 : m_xDocProps->setModificationDate(dt);
248 : }
249 : }
250 0 : else if ("AutoloadURL" == rPropName)
251 : {
252 0 : OUString str;
253 0 : if (aValue >>= str)
254 : {
255 0 : m_xDocProps->setAutoloadURL(str);
256 0 : }
257 : }
258 : else
259 : {
260 : // fall back to user-defined properties
261 0 : getUserDefinedProperties()->setPropertyValue(rPropName, aValue);
262 : }
263 : }
264 : };
265 :
266 0 : class CustomPropertyGetSetHelper : public BuiltinPropertyGetSetHelper
267 : {
268 : public:
269 0 : CustomPropertyGetSetHelper( const uno::Reference< frame::XModel >& xModel ) :BuiltinPropertyGetSetHelper( xModel )
270 : {
271 0 : }
272 0 : virtual uno::Any getPropertyValue( const OUString& rPropName ) SAL_OVERRIDE
273 : {
274 0 : return getUserDefinedProperties()->getPropertyValue(rPropName);
275 : }
276 0 : virtual void setPropertyValue(
277 : const OUString& rPropName, const uno::Any& rValue) SAL_OVERRIDE
278 : {
279 0 : return getUserDefinedProperties()->setPropertyValue(rPropName, rValue);
280 : }
281 : };
282 :
283 0 : class StatisticPropertyGetSetHelper : public PropertGetSetHelper
284 : {
285 : SwDocShell* mpDocShell;
286 : uno::Reference< beans::XPropertySet > mxModelProps;
287 : public:
288 0 : StatisticPropertyGetSetHelper( const uno::Reference< frame::XModel >& xModel ) :PropertGetSetHelper( xModel ) , mpDocShell( NULL )
289 : {
290 0 : mxModelProps.set( m_xModel, uno::UNO_QUERY_THROW );
291 0 : mpDocShell = word::getDocShell( xModel );
292 0 : }
293 0 : virtual uno::Any getPropertyValue( const OUString& rPropName ) SAL_OVERRIDE
294 : {
295 : try
296 : {
297 : // Characters, ParagraphCount & WordCount are available from
298 : // the model ( and additionally these also update the statics object )
299 0 : return mxModelProps->getPropertyValue( rPropName );
300 : }
301 0 : catch (const uno::Exception&)
302 : {
303 : OSL_TRACE("Got exception");
304 : }
305 0 : uno::Any aReturn;
306 0 : if ( rPropName == "LineCount" ) // special processing needed
307 : {
308 0 : if ( mpDocShell )
309 : {
310 0 : SwFEShell* pFEShell = mpDocShell->GetFEShell();
311 0 : if(pFEShell)
312 : {
313 0 : aReturn <<= pFEShell->GetLineCount(false);
314 : }
315 : }
316 : }
317 : else
318 : {
319 : uno::Sequence< beans::NamedValue > const stats(
320 0 : m_xDocProps->getDocumentStatistics());
321 :
322 0 : sal_Int32 nLen = stats.getLength();
323 0 : bool bFound = false;
324 0 : for ( sal_Int32 index = 0; index < nLen && !bFound ; ++index )
325 : {
326 0 : if ( rPropName.equals( stats[ index ].Name ) )
327 : {
328 0 : aReturn = stats[ index ].Value;
329 0 : bFound = true;
330 : }
331 : }
332 0 : if ( !bFound )
333 0 : throw uno::RuntimeException(); // bad Property
334 : }
335 0 : return aReturn;
336 : }
337 :
338 0 : virtual void setPropertyValue( const OUString& rPropName, const uno::Any& aValue ) SAL_OVERRIDE
339 : {
340 : uno::Sequence< beans::NamedValue > stats(
341 0 : m_xDocProps->getDocumentStatistics());
342 :
343 0 : sal_Int32 nLen = stats.getLength();
344 0 : for ( sal_Int32 index = 0; index < nLen; ++index )
345 : {
346 0 : if ( rPropName.equals( stats[ index ].Name ) )
347 : {
348 0 : stats[ index ].Value = aValue;
349 0 : m_xDocProps->setDocumentStatistics(stats);
350 0 : break;
351 : }
352 0 : }
353 0 : }
354 : };
355 :
356 0 : class DocPropInfo
357 : {
358 : public:
359 : OUString msMSODesc;
360 : OUString msOOOPropName;
361 : boost::shared_ptr< PropertGetSetHelper > mpPropGetSetHelper;
362 :
363 0 : static DocPropInfo createDocPropInfo( const OUString& sDesc, const OUString& sPropName, boost::shared_ptr< PropertGetSetHelper >& rHelper )
364 : {
365 0 : DocPropInfo aItem;
366 0 : aItem.msMSODesc = sDesc;
367 0 : aItem.msOOOPropName = sPropName;
368 0 : aItem.mpPropGetSetHelper = rHelper;
369 0 : return aItem;
370 : }
371 :
372 0 : static DocPropInfo createDocPropInfo( const sal_Char* sDesc, const sal_Char* sPropName, boost::shared_ptr< PropertGetSetHelper >& rHelper )
373 : {
374 0 : return createDocPropInfo( OUString::createFromAscii( sDesc ), OUString::createFromAscii( sPropName ), rHelper );
375 : }
376 0 : uno::Any getValue()
377 : {
378 0 : if ( mpPropGetSetHelper.get() )
379 0 : return mpPropGetSetHelper->getPropertyValue( msOOOPropName );
380 0 : return uno::Any();
381 : }
382 0 : void setValue( const uno::Any& rValue )
383 : {
384 0 : if ( mpPropGetSetHelper.get() )
385 0 : mpPropGetSetHelper->setPropertyValue( msOOOPropName, rValue );
386 0 : }
387 0 : uno::Reference< beans::XPropertySet > getUserDefinedProperties()
388 : {
389 0 : uno::Reference< beans::XPropertySet > xProps;
390 0 : if ( mpPropGetSetHelper.get() )
391 0 : return mpPropGetSetHelper->getUserDefinedProperties();
392 0 : return xProps;
393 : }
394 : };
395 :
396 : typedef boost::unordered_map< sal_Int32, DocPropInfo > MSOIndexToOODocPropInfo;
397 :
398 0 : class BuiltInIndexHelper
399 : {
400 : MSOIndexToOODocPropInfo m_docPropInfoMap;
401 :
402 : public:
403 0 : BuiltInIndexHelper( const uno::Reference< frame::XModel >& xModel )
404 0 : {
405 0 : boost::shared_ptr< PropertGetSetHelper > aStandardHelper( new BuiltinPropertyGetSetHelper( xModel ) );
406 0 : boost::shared_ptr< PropertGetSetHelper > aUsingStatsHelper( new StatisticPropertyGetSetHelper( xModel ) );
407 :
408 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTitle ] = DocPropInfo::createDocPropInfo( "Title", "Title", aStandardHelper );
409 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertySubject ] = DocPropInfo::createDocPropInfo( "Subject", "Subject", aStandardHelper );
410 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyAuthor ] = DocPropInfo::createDocPropInfo( "Author", "Author", aStandardHelper );
411 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyKeywords ] = DocPropInfo::createDocPropInfo( "Keywords", "Keywords", aStandardHelper );
412 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyComments ] = DocPropInfo::createDocPropInfo( "Comments", "Description", aStandardHelper );
413 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTemplate ] = DocPropInfo::createDocPropInfo( "Template", "Template", aStandardHelper );
414 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyLastAuthor ] = DocPropInfo::createDocPropInfo( "Last author", "ModifiedBy", aStandardHelper ); // doesn't seem to exist - throw or return nothing ?
415 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyRevision ] = DocPropInfo::createDocPropInfo( "Revision number", "EditingCycles", aStandardHelper ); // doesn't seem to exist - throw or return nothing ?
416 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyAppName ] = DocPropInfo::createDocPropInfo( "Application name", "Generator", aStandardHelper ); // doesn't seem to exist - throw or return nothing ?
417 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTimeLastPrinted ] = DocPropInfo::createDocPropInfo( "Last print date", "PrintDate", aStandardHelper ); // doesn't seem to exist - throw or return nothing ?
418 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTimeCreated ] = DocPropInfo::createDocPropInfo( "Creation date", "CreationDate", aStandardHelper );
419 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTimeLastSaved ] = DocPropInfo::createDocPropInfo( "Last save time", "ModifyDate", aStandardHelper );
420 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyVBATotalEdit ] = DocPropInfo::createDocPropInfo( "Total editing time", "EditingDuration", aStandardHelper ); // Not sure if this is correct
421 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyPages ] = DocPropInfo::createDocPropInfo( "Number of pages", "PageCount", aUsingStatsHelper ); // special handling required ?
422 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyWords ] = DocPropInfo::createDocPropInfo( "Number of words", "WordCount", aUsingStatsHelper ); // special handling require ?
423 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCharacters ] = DocPropInfo::createDocPropInfo( "Number of characters", "CharacterCount", aUsingStatsHelper ); // special handling required ?
424 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertySecurity ] = DocPropInfo::createDocPropInfo( "Security", "", aStandardHelper ); // doesn't seem to exist
425 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCategory ] = DocPropInfo::createDocPropInfo( "Category", "Category", aStandardHelper ); // hacked in
426 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyFormat ] = DocPropInfo::createDocPropInfo( "Format", "", aStandardHelper ); // doesn't seem to exist
427 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyManager ] = DocPropInfo::createDocPropInfo( "Manager", "Manager", aStandardHelper ); // hacked in
428 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCompany ] = DocPropInfo::createDocPropInfo( "Company", "Company", aStandardHelper ); // hacked in
429 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyBytes ] = DocPropInfo::createDocPropInfo( "Number of bytes", "", aStandardHelper ); // doesn't seem to exist - size on disk exists ( for an already saved document ) perhaps it will do ( or we need something else )
430 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyLines ] = DocPropInfo::createDocPropInfo( "Number of lines", "LineCount", aUsingStatsHelper ); // special handling
431 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyParas ] = DocPropInfo::createDocPropInfo( "Number of paragraphs", "ParagraphCount", aUsingStatsHelper ); // special handling
432 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertySlides ] = DocPropInfo::createDocPropInfo( "Number of slides", "" , aStandardHelper ); // doesn't seem to exist
433 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyNotes ] = DocPropInfo::createDocPropInfo( "Number of notes", "", aStandardHelper ); // doesn't seem to exist
434 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyHiddenSlides ] = DocPropInfo::createDocPropInfo("Number of hidden Slides", "", aStandardHelper ); // doesn't seem to exist
435 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyMMClips ] = DocPropInfo::createDocPropInfo( "Number of multimedia clips", "", aStandardHelper ); // doesn't seem to exist
436 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyHyperlinkBase ] = DocPropInfo::createDocPropInfo( "Hyperlink base", "AutoloadURL", aStandardHelper );
437 0 : m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCharsWSpaces ] = DocPropInfo::createDocPropInfo( "Number of characters (with spaces)", "", aStandardHelper ); // doesn't seem to be supported
438 0 : }
439 :
440 0 : MSOIndexToOODocPropInfo& getDocPropInfoMap() { return m_docPropInfoMap; }
441 : };
442 :
443 : typedef InheritedHelperInterfaceImpl1< ooo::vba::XDocumentProperty > SwVbaDocumentProperty_BASE;
444 :
445 0 : class SwVbaBuiltInDocumentProperty : public SwVbaDocumentProperty_BASE
446 : {
447 : protected:
448 : DocPropInfo mPropInfo;
449 : public:
450 : SwVbaBuiltInDocumentProperty( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const DocPropInfo& rInfo );
451 : // XDocumentProperty
452 : virtual void SAL_CALL Delete( ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
453 : virtual OUString SAL_CALL getName( ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
454 : virtual void SAL_CALL setName( const OUString& Name ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
455 : virtual ::sal_Int8 SAL_CALL getType( ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
456 : virtual void SAL_CALL setType( ::sal_Int8 Type ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
457 : virtual sal_Bool SAL_CALL getLinkToContent( ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
458 : virtual void SAL_CALL setLinkToContent( sal_Bool LinkToContent ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
459 : virtual uno::Any SAL_CALL getValue( ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
460 : virtual void SAL_CALL setValue( const uno::Any& Value ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
461 : virtual OUString SAL_CALL getLinkSource( ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
462 : virtual void SAL_CALL setLinkSource( const OUString& LinkSource ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
463 : //XDefaultProperty
464 0 : virtual OUString SAL_CALL getDefaultPropertyName( ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE { return OUString("Value"); }
465 : // XHelperInterface
466 : virtual OUString getServiceImplName() SAL_OVERRIDE;
467 : virtual uno::Sequence<OUString> getServiceNames() SAL_OVERRIDE;
468 : };
469 :
470 0 : class SwVbaCustomDocumentProperty : public SwVbaBuiltInDocumentProperty
471 : {
472 : public:
473 :
474 : SwVbaCustomDocumentProperty( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const DocPropInfo& rInfo );
475 :
476 : virtual sal_Bool SAL_CALL getLinkToContent( ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
477 : virtual void SAL_CALL setLinkToContent( sal_Bool LinkToContent ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
478 :
479 : virtual OUString SAL_CALL getLinkSource( ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
480 : virtual void SAL_CALL setLinkSource( const OUString& LinkSource ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
481 : virtual void SAL_CALL Delete( ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
482 : virtual void SAL_CALL setName( const OUString& Name ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
483 : virtual void SAL_CALL setType( ::sal_Int8 Type ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
484 :
485 : };
486 :
487 0 : SwVbaCustomDocumentProperty::SwVbaCustomDocumentProperty( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const DocPropInfo& rInfo ) : SwVbaBuiltInDocumentProperty( xParent, xContext, rInfo )
488 : {
489 0 : }
490 :
491 : sal_Bool
492 0 : SwVbaCustomDocumentProperty::getLinkToContent( ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
493 : {
494 : // #FIXME we need to store the link content somewhere
495 0 : return sal_False;
496 : }
497 :
498 : void
499 0 : SwVbaCustomDocumentProperty::setLinkToContent( sal_Bool /*bLinkContent*/ ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
500 : {
501 0 : }
502 :
503 : OUString
504 0 : SwVbaCustomDocumentProperty::getLinkSource( ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
505 : {
506 : // #FIXME we need to store the link content somewhere
507 0 : return OUString();
508 : }
509 :
510 : void
511 0 : SwVbaCustomDocumentProperty::setLinkSource( const OUString& /*rsLinkContent*/ ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
512 : {
513 : // #FIXME we need to store the link source somewhere
514 0 : }
515 :
516 : void SAL_CALL
517 0 : SwVbaCustomDocumentProperty::setName( const OUString& /*Name*/ ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
518 : {
519 : // setName on existing property ?
520 : // #FIXME
521 : // do we need to delete existing property and create a new one?
522 0 : }
523 :
524 : void SAL_CALL
525 0 : SwVbaCustomDocumentProperty::setType( ::sal_Int8 /*Type*/ ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
526 : {
527 : // setType, do we need to do a conversion?
528 : // #FIXME the underlying value needs to be changed to the new type
529 0 : }
530 :
531 : void SAL_CALL
532 0 : SwVbaCustomDocumentProperty::Delete( ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
533 : {
534 : uno::Reference< beans::XPropertyContainer > xContainer(
535 0 : mPropInfo.getUserDefinedProperties(), uno::UNO_QUERY_THROW);
536 0 : xContainer->removeProperty( getName() );
537 0 : }
538 :
539 0 : SwVbaBuiltInDocumentProperty::SwVbaBuiltInDocumentProperty( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const DocPropInfo& rInfo ) : SwVbaDocumentProperty_BASE( xParent, xContext ), mPropInfo( rInfo )
540 : {
541 0 : }
542 :
543 : void SAL_CALL
544 0 : SwVbaBuiltInDocumentProperty::Delete( ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
545 : {
546 : // not valid for Builtin
547 0 : throw uno::RuntimeException();
548 : }
549 :
550 : OUString SAL_CALL
551 0 : SwVbaBuiltInDocumentProperty::getName( ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
552 : {
553 0 : return mPropInfo.msMSODesc;
554 : }
555 :
556 : void SAL_CALL
557 0 : SwVbaBuiltInDocumentProperty::setName( const OUString& ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
558 : {
559 : // not valid for Builtin
560 0 : throw uno::RuntimeException();
561 : }
562 :
563 : ::sal_Int8 SAL_CALL
564 0 : SwVbaBuiltInDocumentProperty::getType( ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
565 : {
566 0 : return lcl_toMSOPropType( getValue().getValueType() );
567 : }
568 :
569 : void SAL_CALL
570 0 : SwVbaBuiltInDocumentProperty::setType( ::sal_Int8 /*Type*/ ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
571 : {
572 : // not valid for Builtin
573 0 : throw uno::RuntimeException();
574 : }
575 :
576 : sal_Bool SAL_CALL
577 0 : SwVbaBuiltInDocumentProperty::getLinkToContent( ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
578 : {
579 0 : return sal_False; // built-in always false
580 : }
581 :
582 : void SAL_CALL
583 0 : SwVbaBuiltInDocumentProperty::setLinkToContent( sal_Bool /*LinkToContent*/ ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
584 : {
585 : // not valid for Builtin
586 0 : throw uno::RuntimeException();
587 : }
588 :
589 : uno::Any SAL_CALL
590 0 : SwVbaBuiltInDocumentProperty::getValue( ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
591 : {
592 0 : uno::Any aRet = mPropInfo.getValue();
593 0 : if ( !aRet.hasValue() )
594 0 : throw uno::RuntimeException();
595 0 : return aRet;
596 : }
597 :
598 : void SAL_CALL
599 0 : SwVbaBuiltInDocumentProperty::setValue( const uno::Any& Value ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
600 : {
601 0 : mPropInfo.setValue( Value );
602 0 : }
603 :
604 : OUString SAL_CALL
605 0 : SwVbaBuiltInDocumentProperty::getLinkSource( ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
606 : {
607 : // not valid for Builtin
608 0 : throw uno::RuntimeException();
609 : }
610 :
611 : void SAL_CALL
612 0 : SwVbaBuiltInDocumentProperty::setLinkSource( const OUString& /*LinkSource*/ ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
613 : {
614 : // not valid for Builtin
615 0 : throw uno::RuntimeException();
616 : }
617 :
618 : OUString
619 0 : SwVbaBuiltInDocumentProperty::getServiceImplName()
620 : {
621 0 : return OUString("SwVbaBuiltinDocumentProperty");
622 : }
623 :
624 : uno::Sequence<OUString>
625 0 : SwVbaBuiltInDocumentProperty::getServiceNames()
626 : {
627 0 : static uno::Sequence< OUString > aServiceNames;
628 0 : if ( aServiceNames.getLength() == 0 )
629 : {
630 0 : aServiceNames.realloc( 1 );
631 0 : aServiceNames[ 0 ] = "ooo.vba.word.DocumentProperty";
632 : }
633 0 : return aServiceNames;
634 : }
635 : typedef ::cppu::WeakImplHelper3< com::sun::star::container::XIndexAccess
636 : ,com::sun::star::container::XNameAccess
637 : ,com::sun::star::container::XEnumerationAccess
638 : > PropertiesImpl_BASE;
639 :
640 : typedef boost::unordered_map< sal_Int32, uno::Reference< XDocumentProperty > > DocProps;
641 :
642 : typedef ::cppu::WeakImplHelper1< com::sun::star::container::XEnumeration > DocPropEnumeration_BASE;
643 0 : class DocPropEnumeration : public DocPropEnumeration_BASE
644 : {
645 : DocProps mDocProps;
646 : DocProps::iterator mIt;
647 : public:
648 :
649 0 : DocPropEnumeration( const DocProps& rProps ) : mDocProps( rProps ), mIt( mDocProps.begin() ) {}
650 0 : virtual sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
651 : {
652 0 : return mIt != mDocProps.end();
653 : }
654 0 : virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE
655 : {
656 0 : if ( !hasMoreElements() )
657 0 : throw container::NoSuchElementException();
658 0 : return uno::makeAny( mIt++->second );
659 : }
660 : };
661 :
662 : typedef boost::unordered_map< OUString, uno::Reference< XDocumentProperty >, OUStringHash, ::std::equal_to< OUString > > DocPropsByName;
663 :
664 0 : class BuiltInPropertiesImpl : public PropertiesImpl_BASE
665 : {
666 : protected:
667 :
668 : uno::Reference< XHelperInterface > m_xParent;
669 : uno::Reference< uno::XComponentContext > m_xContext;
670 : uno::Reference< frame::XModel > m_xModel;
671 :
672 : DocProps mDocProps;
673 : DocPropsByName mNamedDocProps;
674 :
675 : public:
676 0 : BuiltInPropertiesImpl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : m_xParent( xParent ), m_xContext( xContext ), m_xModel( xModel )
677 : {
678 0 : BuiltInIndexHelper builtIns( m_xModel );
679 0 : for ( sal_Int32 index = word::WdBuiltInProperty::wdPropertyTitle; index <= word::WdBuiltInProperty::wdPropertyCharsWSpaces; ++index )
680 : {
681 0 : mDocProps[ index ] = new SwVbaBuiltInDocumentProperty( xParent, xContext, builtIns.getDocPropInfoMap()[ index ] );
682 0 : mNamedDocProps[ mDocProps[ index ]->getName() ] = mDocProps[ index ];
683 0 : }
684 0 : }
685 : // XIndexAccess
686 0 : virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
687 : {
688 0 : return mDocProps.size();
689 : }
690 0 : virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, std::exception ) SAL_OVERRIDE
691 : {
692 : // correct the correct by the base class for 1 based indices
693 0 : DocProps::iterator it = mDocProps.find( ++Index );
694 0 : if ( it == mDocProps.end() )
695 0 : throw lang::IndexOutOfBoundsException();
696 0 : return uno::makeAny( it->second );
697 : }
698 0 : virtual uno::Any SAL_CALL getByName( const OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE
699 : {
700 0 : if ( !hasByName( aName ) )
701 0 : throw container::NoSuchElementException();
702 0 : DocPropsByName::iterator it = mNamedDocProps.find( aName );
703 0 : return uno::Any( it->second );
704 :
705 : }
706 0 : virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
707 : {
708 0 : uno::Sequence< OUString > aNames( getCount() );
709 0 : OUString* pName = aNames.getArray();
710 0 : DocPropsByName::iterator it_end = mNamedDocProps.end();
711 0 : for( DocPropsByName::iterator it = mNamedDocProps.begin(); it != it_end; ++it, ++pName )
712 0 : *pName = it->first;
713 0 : return aNames;
714 : }
715 :
716 0 : virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
717 : {
718 0 : DocPropsByName::iterator it = mNamedDocProps.find( aName );
719 0 : if ( it == mNamedDocProps.end() )
720 0 : return sal_False;
721 0 : return sal_True;
722 : }
723 : // XElementAccess
724 0 : virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
725 : {
726 0 : return cppu::UnoType<XDocumentProperty>::get();
727 : }
728 0 : virtual sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
729 : {
730 0 : return mDocProps.size() > 0;
731 : }
732 0 : virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
733 : {
734 0 : return new DocPropEnumeration( mDocProps );
735 : }
736 : };
737 :
738 0 : SwVbaBuiltinDocumentProperties::SwVbaBuiltinDocumentProperties( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : SwVbaDocumentproperties_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new BuiltInPropertiesImpl( xParent, xContext, xModel ) ) ), m_xModel( xModel )
739 : {
740 0 : }
741 :
742 : uno::Reference< XDocumentProperty > SAL_CALL
743 0 : SwVbaBuiltinDocumentProperties::Add( const OUString& /*Name*/, sal_Bool /*LinkToContent*/, ::sal_Int8 /*Type*/, const uno::Any& /*value*/, const uno::Any& /*LinkSource*/ ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
744 : {
745 0 : throw uno::RuntimeException( "not supported for Builtin properties" );
746 : }
747 :
748 : // XEnumerationAccess
749 : uno::Type SAL_CALL
750 0 : SwVbaBuiltinDocumentProperties::getElementType() throw (uno::RuntimeException)
751 : {
752 0 : return cppu::UnoType<XDocumentProperty>::get();
753 : }
754 :
755 : uno::Reference< container::XEnumeration > SAL_CALL
756 0 : SwVbaBuiltinDocumentProperties::createEnumeration() throw (uno::RuntimeException)
757 : {
758 0 : uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
759 0 : return xEnumAccess->createEnumeration();
760 : }
761 :
762 : // ScVbaCollectionBaseImpl
763 : uno::Any
764 0 : SwVbaBuiltinDocumentProperties::createCollectionObject( const uno::Any& aSource )
765 : {
766 : // pass through
767 0 : return aSource;
768 : }
769 :
770 : // XHelperInterface
771 : OUString
772 0 : SwVbaBuiltinDocumentProperties::getServiceImplName()
773 : {
774 0 : return OUString("SwVbaBuiltinDocumentProperties");
775 : }
776 :
777 : uno::Sequence<OUString>
778 0 : SwVbaBuiltinDocumentProperties::getServiceNames()
779 : {
780 0 : static uno::Sequence< OUString > aServiceNames;
781 0 : if ( aServiceNames.getLength() == 0 )
782 : {
783 0 : aServiceNames.realloc( 1 );
784 0 : aServiceNames[ 0 ] = "ooo.vba.word.DocumentProperties";
785 : }
786 0 : return aServiceNames;
787 : }
788 :
789 0 : class CustomPropertiesImpl : public PropertiesImpl_BASE
790 : {
791 : uno::Reference< XHelperInterface > m_xParent;
792 : uno::Reference< uno::XComponentContext > m_xContext;
793 : uno::Reference< frame::XModel > m_xModel;
794 : uno::Reference< beans::XPropertySet > mxUserDefinedProp;
795 : boost::shared_ptr< PropertGetSetHelper > mpPropGetSetHelper;
796 : public:
797 0 : CustomPropertiesImpl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : m_xParent( xParent ), m_xContext( xContext ), m_xModel( xModel )
798 : {
799 : // suck in the document( custom ) properties
800 0 : mpPropGetSetHelper.reset( new CustomPropertyGetSetHelper( m_xModel ) );
801 0 : mxUserDefinedProp.set(mpPropGetSetHelper->getUserDefinedProperties(),
802 0 : uno::UNO_SET_THROW);
803 0 : };
804 : // XIndexAccess
805 0 : virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
806 : {
807 0 : return mxUserDefinedProp->getPropertySetInfo()->getProperties().getLength();
808 : }
809 :
810 0 : virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, std::exception ) SAL_OVERRIDE
811 : {
812 0 : uno::Sequence< beans::Property > aProps = mxUserDefinedProp->getPropertySetInfo()->getProperties();
813 0 : if ( Index >= aProps.getLength() )
814 0 : throw lang::IndexOutOfBoundsException();
815 : // How to determine type e.g Date? ( com.sun.star.util.DateTime )
816 0 : DocPropInfo aPropInfo = DocPropInfo::createDocPropInfo( aProps[ Index ].Name, aProps[ Index ].Name, mpPropGetSetHelper );
817 0 : return uno::makeAny( uno::Reference< XDocumentProperty >( new SwVbaCustomDocumentProperty( m_xParent, m_xContext, aPropInfo ) ) );
818 : }
819 :
820 0 : virtual uno::Any SAL_CALL getByName( const OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE
821 : {
822 0 : if ( !hasByName( aName ) )
823 0 : throw container::NoSuchElementException();
824 :
825 0 : DocPropInfo aPropInfo = DocPropInfo::createDocPropInfo( aName, aName, mpPropGetSetHelper );
826 0 : return uno::makeAny( uno::Reference< XDocumentProperty >( new SwVbaCustomDocumentProperty( m_xParent, m_xContext, aPropInfo ) ) );
827 : }
828 :
829 0 : virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
830 : {
831 0 : uno::Sequence< beans::Property > aProps = mxUserDefinedProp->getPropertySetInfo()->getProperties();
832 0 : uno::Sequence< OUString > aNames( aProps.getLength() );
833 0 : OUString* pString = aNames.getArray();
834 0 : OUString* pEnd = ( pString + aNames.getLength() );
835 0 : beans::Property* pProp = aProps.getArray();
836 0 : for ( ; pString != pEnd; ++pString, ++pProp )
837 0 : *pString = pProp->Name;
838 0 : return aNames;
839 : }
840 :
841 0 : virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
842 : {
843 : OSL_TRACE("hasByName(%s) returns %d", OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr(), mxUserDefinedProp->getPropertySetInfo()->hasPropertyByName( aName ) );
844 0 : return mxUserDefinedProp->getPropertySetInfo()->hasPropertyByName( aName );
845 : }
846 :
847 : // XElementAccess
848 0 : virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
849 : {
850 0 : return cppu::UnoType<XDocumentProperty>::get();
851 : }
852 :
853 0 : virtual sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
854 : {
855 0 : return getCount() > 0;
856 : }
857 :
858 0 : virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
859 : {
860 : // create a map of properties ( the key doesn't matter )
861 : OSL_TRACE("Creating an enumeration");
862 0 : sal_Int32 key = 0;
863 0 : sal_Int32 nElem = getCount();
864 0 : DocProps simpleDocPropSnapShot;
865 0 : for ( ; key < nElem; ++key )
866 0 : simpleDocPropSnapShot[ key ].set( getByIndex( key ), uno::UNO_QUERY_THROW );
867 : OSL_TRACE("After creating the enumeration");
868 0 : return new DocPropEnumeration( simpleDocPropSnapShot );
869 : }
870 :
871 0 : void addProp( const OUString& Name, ::sal_Int8 /*Type*/, const uno::Any& Value )
872 : {
873 0 : sal_Int16 attributes = 128;
874 0 : uno::Reference< beans::XPropertyContainer > xContainer( mxUserDefinedProp, uno::UNO_QUERY_THROW );
875 : // TODO fixme, perform the necessary Type Value conversions
876 0 : xContainer->addProperty( Name, attributes, Value );
877 0 : }
878 :
879 : };
880 :
881 0 : SwVbaCustomDocumentProperties::SwVbaCustomDocumentProperties( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : SwVbaBuiltinDocumentProperties( xParent, xContext, xModel )
882 : {
883 : // replace the m_xIndexAccess implementation ( we need a virtual init )
884 0 : m_xIndexAccess.set( new CustomPropertiesImpl( xParent, xContext, xModel ) );
885 0 : m_xNameAccess.set( m_xIndexAccess, uno::UNO_QUERY_THROW );
886 0 : }
887 :
888 : uno::Reference< XDocumentProperty > SAL_CALL
889 0 : SwVbaCustomDocumentProperties::Add( const OUString& Name, sal_Bool LinkToContent, ::sal_Int8 Type, const uno::Any& Value, const uno::Any& LinkSource ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
890 : {
891 0 : CustomPropertiesImpl* pCustomProps = dynamic_cast< CustomPropertiesImpl* > ( m_xIndexAccess.get() );
892 0 : uno::Reference< XDocumentProperty > xDocProp;
893 0 : if ( pCustomProps )
894 : {
895 0 : OUString sLinkSource;
896 0 : pCustomProps->addProp( Name, Type, Value );
897 :
898 0 : xDocProp.set( m_xNameAccess->getByName( Name ), uno::UNO_QUERY_THROW );
899 0 : xDocProp->setLinkToContent( LinkToContent );
900 :
901 0 : if ( LinkSource >>= sLinkSource )
902 0 : xDocProp->setLinkSource( sLinkSource );
903 : }
904 0 : return xDocProp;
905 : }
906 :
907 : // XHelperInterface
908 : OUString
909 0 : SwVbaCustomDocumentProperties::getServiceImplName()
910 : {
911 0 : return OUString("SwVbaCustomDocumentProperties");
912 6 : }
913 :
914 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|