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>
40 sal_Int16 msoType = office::MsoDocProperties::msoPropertyTypeString;
42 switch ( aType.getTypeClass() )
44 case uno::TypeClass_BOOLEAN:
45 msoType = office::MsoDocProperties::msoPropertyTypeBoolean;
47 case uno::TypeClass_FLOAT:
48 msoType = office::MsoDocProperties::msoPropertyTypeFloat;
50 case uno::TypeClass_STRUCT:
51 msoType = office::MsoDocProperties::msoPropertyTypeDate;
53 case uno::TypeClass_BYTE:
54 case uno::TypeClass_SHORT:
55 case uno::TypeClass_LONG:
56 case uno::TypeClass_HYPER:
57 msoType = office::MsoDocProperties::msoPropertyTypeNumber;
60 throw lang::IllegalArgumentException();
67class PropertGetSetHelper
70 uno::Reference< frame::XModel >
m_xModel;
71 uno::Reference<document::XDocumentProperties> m_xDocProps;
73 explicit PropertGetSetHelper( uno::Reference< frame::XModel > xModel ):
m_xModel(
std::move(
xModel ))
75 uno::Reference<document::XDocumentPropertiesSupplier>
const
76 xDocPropSupp(m_xModel, uno::UNO_QUERY_THROW);
77 m_xDocProps.set(xDocPropSupp->getDocumentProperties(),
80 virtual ~PropertGetSetHelper() {}
83 uno::Reference< beans::XPropertySet > getUserDefinedProperties() {
84 return uno::Reference<beans::XPropertySet>(
85 m_xDocProps->getUserDefinedProperties(), uno::UNO_QUERY_THROW);
90class BuiltinPropertyGetSetHelper :
public PropertGetSetHelper
93 explicit BuiltinPropertyGetSetHelper(
const uno::Reference< frame::XModel >& xModel ) :PropertGetSetHelper(
xModel )
98 if ( rPropName ==
"EditingDuration" )
100 sal_Int32
const nSecs = m_xDocProps->getEditingDuration();
103 else if (
"Title" == rPropName)
105 return uno::Any(m_xDocProps->getTitle());
107 else if (
"Subject" == rPropName)
109 return uno::Any(m_xDocProps->getSubject());
111 else if (
"Author" == rPropName)
113 return uno::Any(m_xDocProps->getAuthor());
115 else if (
"Keywords" == rPropName)
117 return uno::Any(m_xDocProps->getKeywords());
119 else if (
"Description" == rPropName)
121 return uno::Any(m_xDocProps->getDescription());
123 else if (
"Template" == rPropName)
125 return uno::Any(m_xDocProps->getTemplateName());
127 else if (
"ModifiedBy" == rPropName)
129 return uno::Any(m_xDocProps->getModifiedBy());
131 else if (
"Generator" == rPropName)
133 return uno::Any(m_xDocProps->getGenerator());
135 else if (
"PrintDate" == rPropName)
137 return uno::Any(m_xDocProps->getPrintDate());
139 else if (
"CreationDate" == rPropName)
141 return uno::Any(m_xDocProps->getCreationDate());
143 else if (
"ModifyDate" == rPropName)
145 return uno::Any(m_xDocProps->getModificationDate());
147 else if (
"AutoloadURL" == rPropName)
149 return uno::Any(m_xDocProps->getAutoloadURL());
154 return getUserDefinedProperties()->getPropertyValue(rPropName);
159 if (
"EditingDuration" == rPropName)
162 if (aValue >>= nMins)
164 m_xDocProps->setEditingDuration(nMins * 60);
167 else if (
"Title" == rPropName)
172 m_xDocProps->setTitle(str);
175 else if (
"Subject" == rPropName)
180 m_xDocProps->setSubject(str);
183 else if (
"Author" == rPropName)
188 m_xDocProps->setAuthor(str);
191 else if (
"Keywords" == rPropName)
193 uno::Sequence<OUString> keywords;
194 if (aValue >>= keywords)
196 m_xDocProps->setKeywords(keywords);
199 else if (
"Description" == rPropName)
204 m_xDocProps->setDescription(str);
207 else if (
"Template" == rPropName)
212 m_xDocProps->setTemplateName(str);
215 else if (
"ModifiedBy" == rPropName)
220 m_xDocProps->setModifiedBy(str);
223 else if (
"Generator" == rPropName)
228 return m_xDocProps->setGenerator(str);
231 else if (
"PrintDate" == rPropName)
236 m_xDocProps->setPrintDate(dt);
239 else if (
"CreationDate" == rPropName)
244 m_xDocProps->setCreationDate(dt);
247 else if (
"ModifyDate" == rPropName)
252 m_xDocProps->setModificationDate(dt);
255 else if (
"AutoloadURL" == rPropName)
260 m_xDocProps->setAutoloadURL(str);
266 getUserDefinedProperties()->setPropertyValue(rPropName, aValue);
271class CustomPropertyGetSetHelper :
public BuiltinPropertyGetSetHelper
274 explicit CustomPropertyGetSetHelper(
const uno::Reference< frame::XModel >& xModel ) :BuiltinPropertyGetSetHelper(
xModel )
279 return getUserDefinedProperties()->getPropertyValue(rPropName);
282 const OUString& rPropName,
const uno::Any& rValue)
override
284 return getUserDefinedProperties()->setPropertyValue(rPropName, rValue);
288class StatisticPropertyGetSetHelper :
public PropertGetSetHelper
291 uno::Reference< beans::XPropertySet > mxModelProps;
293 explicit StatisticPropertyGetSetHelper(
const uno::Reference< frame::XModel >& xModel ) :PropertGetSetHelper(
xModel ) , mpDocShell( nullptr )
295 mxModelProps.set( m_xModel, uno::UNO_QUERY_THROW );
304 return mxModelProps->getPropertyValue( rPropName );
306 catch (
const uno::Exception&)
311 if ( rPropName ==
"LineCount" )
316 aReturn <<= pFEShell->GetLineCount();
321 uno::Sequence< beans::NamedValue >
const stats(
322 m_xDocProps->getDocumentStatistics());
324 auto pStat = std::find_if(stats.begin(), stats.end(),
325 [&rPropName](
const beans::NamedValue& rStat) { return rPropName == rStat.Name; });
326 if (pStat == stats.end())
327 throw uno::RuntimeException();
329 aReturn = pStat->
Value;
336 uno::Sequence< beans::NamedValue > stats(
337 m_xDocProps->getDocumentStatistics());
339 auto [
begin,
end] = asNonConstRange(stats);
340 auto pStat = std::find_if(begin, end,
341 [&rPropName](
const beans::NamedValue& rStat) {
return rPropName == rStat.Name; });
344 pStat->Value = aValue;
345 m_xDocProps->setDocumentStatistics(stats);
354 OUString msOOOPropName;
355 std::shared_ptr< PropertGetSetHelper > mpPropGetSetHelper;
357 static DocPropInfo createDocPropInfo(
const OUString& sDesc,
const OUString& sPropName, std::shared_ptr< PropertGetSetHelper >
const & rHelper )
360 aItem.msMSODesc = sDesc;
361 aItem.msOOOPropName = sPropName;
362 aItem.mpPropGetSetHelper = rHelper;
366 static DocPropInfo createDocPropInfo(
const char* sDesc,
const char* sPropName, std::shared_ptr< PropertGetSetHelper >
const & rHelper )
368 return createDocPropInfo( OUString::createFromAscii( sDesc ), OUString::createFromAscii( sPropName ), rHelper );
372 if ( mpPropGetSetHelper )
373 return mpPropGetSetHelper->getPropertyValue( msOOOPropName );
378 if ( mpPropGetSetHelper )
379 mpPropGetSetHelper->setPropertyValue( msOOOPropName, rValue );
381 uno::Reference< beans::XPropertySet > getUserDefinedProperties()
383 uno::Reference< beans::XPropertySet > xProps;
384 if ( mpPropGetSetHelper )
385 return mpPropGetSetHelper->getUserDefinedProperties();
396class BuiltInIndexHelper
401 explicit BuiltInIndexHelper(
const uno::Reference< frame::XModel >&
xModel )
403 auto aStandardHelper = std::make_shared<BuiltinPropertyGetSetHelper>(
xModel );
404 auto aUsingStatsHelper = std::make_shared<StatisticPropertyGetSetHelper>(
xModel );
406 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTitle ] = DocPropInfo::createDocPropInfo(
"Title",
"Title", aStandardHelper );
407 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertySubject ] = DocPropInfo::createDocPropInfo(
"Subject",
"Subject", aStandardHelper );
408 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyAuthor ] = DocPropInfo::createDocPropInfo(
"Author",
"Author", aStandardHelper );
409 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyKeywords ] = DocPropInfo::createDocPropInfo(
"Keywords",
"Keywords", aStandardHelper );
410 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyComments ] = DocPropInfo::createDocPropInfo(
"Comments",
"Description", aStandardHelper );
411 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTemplate ] = DocPropInfo::createDocPropInfo(
"Template",
"Template", aStandardHelper );
412 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyLastAuthor ] = DocPropInfo::createDocPropInfo(
"Last author",
"ModifiedBy", aStandardHelper );
413 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyRevision ] = DocPropInfo::createDocPropInfo(
"Revision number",
"EditingCycles", aStandardHelper );
414 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyAppName ] = DocPropInfo::createDocPropInfo(
"Application name",
"Generator", aStandardHelper );
415 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTimeLastPrinted ] = DocPropInfo::createDocPropInfo(
"Last print date",
"PrintDate", aStandardHelper );
416 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTimeCreated ] = DocPropInfo::createDocPropInfo(
"Creation date",
"CreationDate", aStandardHelper );
417 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTimeLastSaved ] = DocPropInfo::createDocPropInfo(
"Last save time",
"ModifyDate", aStandardHelper );
418 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyVBATotalEdit ] = DocPropInfo::createDocPropInfo(
"Total editing time",
"EditingDuration", aStandardHelper );
419 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyPages ] = DocPropInfo::createDocPropInfo(
"Number of pages",
"PageCount", aUsingStatsHelper );
420 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyWords ] = DocPropInfo::createDocPropInfo(
"Number of words",
"WordCount", aUsingStatsHelper );
421 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCharacters ] = DocPropInfo::createDocPropInfo(
"Number of characters",
"CharacterCount", aUsingStatsHelper );
422 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertySecurity ] = DocPropInfo::createDocPropInfo(
"Security",
"", aStandardHelper );
423 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCategory ] = DocPropInfo::createDocPropInfo(
"Category",
"Category", aStandardHelper );
424 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyFormat ] = DocPropInfo::createDocPropInfo(
"Format",
"", aStandardHelper );
425 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyManager ] = DocPropInfo::createDocPropInfo(
"Manager",
"Manager", aStandardHelper );
426 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCompany ] = DocPropInfo::createDocPropInfo(
"Company",
"Company", aStandardHelper );
427 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyBytes ] = DocPropInfo::createDocPropInfo(
"Number of bytes",
"", aStandardHelper );
428 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyLines ] = DocPropInfo::createDocPropInfo(
"Number of lines",
"LineCount", aUsingStatsHelper );
429 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyParas ] = DocPropInfo::createDocPropInfo(
"Number of paragraphs",
"ParagraphCount", aUsingStatsHelper );
430 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertySlides ] = DocPropInfo::createDocPropInfo(
"Number of slides",
"" , aStandardHelper );
431 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyNotes ] = DocPropInfo::createDocPropInfo(
"Number of notes",
"", aStandardHelper );
432 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyHiddenSlides ] = DocPropInfo::createDocPropInfo(
"Number of hidden Slides",
"", aStandardHelper );
433 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyMMClips ] = DocPropInfo::createDocPropInfo(
"Number of multimedia clips",
"", aStandardHelper );
434 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyHyperlinkBase ] = DocPropInfo::createDocPropInfo(
"Hyperlink base",
"AutoloadURL", aStandardHelper );
435 m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCharsWSpaces ] = DocPropInfo::createDocPropInfo(
"Number of characters (with spaces)",
"", aStandardHelper );
450 DocPropInfo mPropInfo;
452 SwVbaBuiltInDocumentProperty(
const uno::Reference< ov::XHelperInterface >& xParent,
const uno::Reference< uno::XComponentContext >& xContext, DocPropInfo rInfo );
454 virtual void SAL_CALL
Delete( )
override;
455 virtual OUString SAL_CALL getName( )
override;
456 virtual void SAL_CALL setName(
const OUString&
Name )
override;
457 virtual ::sal_Int8 SAL_CALL
getType( )
override;
459 virtual sal_Bool SAL_CALL getLinkToContent( )
override;
460 virtual void SAL_CALL setLinkToContent(
sal_Bool LinkToContent )
override;
463 virtual OUString SAL_CALL getLinkSource( )
override;
464 virtual void SAL_CALL setLinkSource(
const OUString& LinkSource )
override;
466 virtual OUString SAL_CALL getDefaultPropertyName( )
override {
return "Value"; }
472class SwVbaCustomDocumentProperty :
public SwVbaBuiltInDocumentProperty
476 SwVbaCustomDocumentProperty(
const uno::Reference< ov::XHelperInterface >& xParent,
const uno::Reference< uno::XComponentContext >& xContext,
const DocPropInfo& rInfo );
478 virtual sal_Bool SAL_CALL getLinkToContent( )
override;
479 virtual void SAL_CALL setLinkToContent(
sal_Bool LinkToContent )
override;
481 virtual OUString SAL_CALL getLinkSource( )
override;
482 virtual void SAL_CALL setLinkSource(
const OUString& LinkSource )
override;
483 virtual void SAL_CALL
Delete( )
override;
484 virtual void SAL_CALL setName(
const OUString&
Name )
override;
491SwVbaCustomDocumentProperty::SwVbaCustomDocumentProperty(
const uno::Reference< ov::XHelperInterface >& xParent,
const uno::Reference< uno::XComponentContext >& xContext,
const DocPropInfo& rInfo ) : SwVbaBuiltInDocumentProperty( xParent, xContext, rInfo )
496SwVbaCustomDocumentProperty::getLinkToContent( )
503SwVbaCustomDocumentProperty::setLinkToContent(
sal_Bool )
508SwVbaCustomDocumentProperty::getLinkSource( )
515SwVbaCustomDocumentProperty::setLinkSource(
const OUString& )
521SwVbaCustomDocumentProperty::setName(
const OUString& )
529SwVbaCustomDocumentProperty::setType(
::sal_Int8 )
536SwVbaCustomDocumentProperty::Delete( )
538 uno::Reference< beans::XPropertyContainer > xContainer(
539 mPropInfo.getUserDefinedProperties(), uno::UNO_QUERY_THROW);
540 xContainer->removeProperty( getName() );
543SwVbaBuiltInDocumentProperty::SwVbaBuiltInDocumentProperty(
const uno::Reference< ov::XHelperInterface >& xParent,
const uno::Reference< uno::XComponentContext >& xContext, DocPropInfo rInfo ) :
SwVbaDocumentProperty_BASE( xParent, xContext ), mPropInfo(
std::move( rInfo ))
548SwVbaBuiltInDocumentProperty::Delete( )
551 throw uno::RuntimeException();
555SwVbaBuiltInDocumentProperty::getName( )
557 return mPropInfo.msMSODesc;
561SwVbaBuiltInDocumentProperty::setName(
const OUString& )
564 throw uno::RuntimeException();
568SwVbaBuiltInDocumentProperty::getType( )
574SwVbaBuiltInDocumentProperty::setType(
::sal_Int8 )
577 throw uno::RuntimeException();
581SwVbaBuiltInDocumentProperty::getLinkToContent( )
587SwVbaBuiltInDocumentProperty::setLinkToContent(
sal_Bool )
590 throw uno::RuntimeException();
594SwVbaBuiltInDocumentProperty::getValue( )
596 uno::Any aRet = mPropInfo.getValue();
598 throw uno::RuntimeException();
603SwVbaBuiltInDocumentProperty::setValue(
const uno::Any& Value )
609SwVbaBuiltInDocumentProperty::getLinkSource( )
612 throw uno::RuntimeException();
616SwVbaBuiltInDocumentProperty::setLinkSource(
const OUString& )
619 throw uno::RuntimeException();
623SwVbaBuiltInDocumentProperty::getServiceImplName()
625 return "SwVbaBuiltinDocumentProperty";
628uno::Sequence<OUString>
629SwVbaBuiltInDocumentProperty::getServiceNames()
633 "ooo.vba.word.DocumentProperty"
637typedef ::cppu::WeakImplHelper< css::container::XIndexAccess
638 ,css::container::XNameAccess
639 ,css::container::XEnumerationAccess
642typedef std::unordered_map< sal_Int32, uno::Reference< XDocumentProperty > >
DocProps;
646class DocPropEnumeration :
public ::cppu::WeakImplHelper< css::container::XEnumeration >
649 DocProps::iterator mIt;
652 explicit DocPropEnumeration(
DocProps&& rProps ) : mDocProps( std::move(rProps) ), mIt( mDocProps.begin() ) {}
653 virtual sal_Bool SAL_CALL hasMoreElements( )
override
655 return mIt != mDocProps.end();
657 virtual uno::Any SAL_CALL nextElement( )
override
659 if ( !hasMoreElements() )
660 throw container::NoSuchElementException();
667typedef std::unordered_map< OUString, uno::Reference< XDocumentProperty > >
DocPropsByName;
675 uno::Reference< frame::XModel >
m_xModel;
681 BuiltInPropertiesImpl(
const uno::Reference< XHelperInterface >& xParent,
const uno::Reference< uno::XComponentContext >& xContext, uno::Reference< frame::XModel >
xModel ) :
m_xModel(std::move(
xModel ))
683 BuiltInIndexHelper builtIns(
m_xModel );
684 for ( sal_Int32
index = word::WdBuiltInProperty::wdPropertyTitle;
index <= word::WdBuiltInProperty::wdPropertyCharsWSpaces; ++
index )
686 mDocProps[
index ] =
new SwVbaBuiltInDocumentProperty( xParent, xContext, builtIns.getDocPropInfoMap()[
index ] );
687 mNamedDocProps[ mDocProps[
index ]->getName() ] = mDocProps[
index ];
691 virtual ::sal_Int32 SAL_CALL getCount( )
override
693 return mDocProps.size();
695 virtual uno::Any SAL_CALL getByIndex( ::sal_Int32
Index )
override
698 DocProps::iterator it = mDocProps.find( ++
Index );
699 if ( it == mDocProps.end() )
700 throw lang::IndexOutOfBoundsException();
703 virtual uno::Any SAL_CALL getByName(
const OUString&
aName )
override
705 if ( !hasByName(
aName ) )
706 throw container::NoSuchElementException();
707 DocPropsByName::iterator it = mNamedDocProps.find(
aName );
711 virtual uno::Sequence< OUString > SAL_CALL getElementNames( )
override
713 uno::Sequence< OUString > aNames( getCount() );
714 OUString*
pName = aNames.getArray();
715 for (
const auto& rEntry : mNamedDocProps)
717 *
pName = rEntry.first;
723 virtual sal_Bool SAL_CALL hasByName(
const OUString&
aName )
override
725 DocPropsByName::iterator it = mNamedDocProps.find(
aName );
726 if ( it == mNamedDocProps.end() )
731 virtual uno::Type SAL_CALL getElementType( )
override
735 virtual sal_Bool SAL_CALL hasElements( )
override
737 return !mDocProps.empty();
739 virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( )
override
741 return new DocPropEnumeration( std::unordered_map(mDocProps) );
751uno::Reference< XDocumentProperty > SAL_CALL
754 throw uno::RuntimeException(
"not supported for Builtin properties" );
764uno::Reference< container::XEnumeration > SAL_CALL
767 uno::Reference< container::XEnumerationAccess > xEnumAccess(
m_xIndexAccess, uno::UNO_QUERY_THROW );
768 return xEnumAccess->createEnumeration();
783 return "SwVbaBuiltinDocumentProperties";
786uno::Sequence<OUString>
791 "ooo.vba.word.DocumentProperties"
800 uno::Reference< XHelperInterface > m_xParent;
801 uno::Reference< uno::XComponentContext >
m_xContext;
802 uno::Reference< frame::XModel >
m_xModel;
803 uno::Reference< beans::XPropertySet > mxUserDefinedProp;
804 std::shared_ptr< PropertGetSetHelper > mpPropGetSetHelper;
806 CustomPropertiesImpl( uno::Reference< XHelperInterface > xParent, uno::Reference< uno::XComponentContext > xContext, uno::Reference< frame::XModel > xModel ) : m_xParent(
std::move( xParent )),
m_xContext(
std::move( xContext )),
m_xModel(
std::move(
xModel ))
809 mpPropGetSetHelper = std::make_shared<CustomPropertyGetSetHelper>( m_xModel );
810 mxUserDefinedProp.set(mpPropGetSetHelper->getUserDefinedProperties(),
814 virtual ::sal_Int32 SAL_CALL getCount( )
override
816 return mxUserDefinedProp->getPropertySetInfo()->getProperties().getLength();
819 virtual uno::Any SAL_CALL getByIndex( ::sal_Int32
Index )
override
821 uno::Sequence< beans::Property > aProps = mxUserDefinedProp->getPropertySetInfo()->getProperties();
822 if (
Index >= aProps.getLength() )
823 throw lang::IndexOutOfBoundsException();
825 DocPropInfo aPropInfo = DocPropInfo::createDocPropInfo( aProps[
Index ].Name, aProps[
Index ].Name, mpPropGetSetHelper );
826 return uno::Any( uno::Reference< XDocumentProperty >(
new SwVbaCustomDocumentProperty( m_xParent, m_xContext, aPropInfo ) ) );
829 virtual uno::Any SAL_CALL getByName(
const OUString& aName )
override
831 if ( !hasByName( aName ) )
832 throw container::NoSuchElementException();
834 DocPropInfo aPropInfo = DocPropInfo::createDocPropInfo( aName, aName, mpPropGetSetHelper );
835 return uno::Any( uno::Reference< XDocumentProperty >(
new SwVbaCustomDocumentProperty( m_xParent, m_xContext, aPropInfo ) ) );
838 virtual uno::Sequence< OUString > SAL_CALL getElementNames( )
override
840 const uno::Sequence< beans::Property > aProps = mxUserDefinedProp->getPropertySetInfo()->getProperties();
841 uno::Sequence< OUString > aNames( aProps.getLength() );
842 std::transform(aProps.begin(), aProps.end(), aNames.getArray(),
843 [](
const beans::Property& rProp) -> OUString { return rProp.Name; });
847 virtual sal_Bool SAL_CALL hasByName(
const OUString& aName )
override
849 SAL_INFO(
"sw.vba",
"hasByName(" << aName <<
") returns " << mxUserDefinedProp->getPropertySetInfo()->hasPropertyByName( aName ) );
850 return mxUserDefinedProp->getPropertySetInfo()->hasPropertyByName( aName );
854 virtual uno::Type SAL_CALL getElementType( )
override
859 virtual sal_Bool SAL_CALL hasElements( )
override
861 return getCount() > 0;
864 virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( )
override
867 SAL_INFO(
"sw.vba",
"Creating an enumeration");
869 sal_Int32 nElem = getCount();
871 for ( ; key < nElem; ++key )
872 simpleDocPropSnapShot[ key ].
set( getByIndex( key ), uno::UNO_QUERY_THROW );
873 SAL_INFO(
"sw.vba",
"After creating the enumeration");
874 return new DocPropEnumeration( std::move(simpleDocPropSnapShot) );
877 void addProp(
const OUString& Name,
const uno::Any& Value )
879 uno::Reference< beans::XPropertyContainer > xContainer( mxUserDefinedProp, uno::UNO_QUERY_THROW );
881 xContainer->addProperty( Name, sal_Int16(128), Value );
895uno::Reference< XDocumentProperty > SAL_CALL
898 CustomPropertiesImpl* pCustomProps =
dynamic_cast< CustomPropertiesImpl*
> (
m_xIndexAccess.get() );
899 uno::Reference< XDocumentProperty > xDocProp;
902 OUString sLinkSource;
906 xDocProp->setLinkToContent( LinkToContent );
908 if ( LinkSource >>= sLinkSource )
909 xDocProp->setLinkSource( sLinkSource );
918 return "SwVbaCustomDocumentProperties";
Reference< XComponentContext > m_xContext
virtual OUString getServiceImplName()=0
virtual css::uno::Sequence< OUString > getServiceNames()=0
css::uno::Reference< css::container::XNameAccess > m_xNameAccess
css::uno::Reference< css::container::XIndexAccess > m_xIndexAccess
SwFEShell * GetFEShell()
For Core - it knows the DocShell but not the WrtShell!
virtual css::uno::Any createCollectionObject(const css::uno::Any &aSource) override
virtual OUString getServiceImplName() override
virtual css::uno::Type SAL_CALL getElementType() override
SwVbaBuiltinDocumentProperties(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::frame::XModel > &xDocument)
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
virtual css::uno::Reference< ::ooo::vba::XDocumentProperty > SAL_CALL Add(const OUString &Name, sal_Bool LinkToContent, ::sal_Int8 Type, const css::uno::Any &Value, const css::uno::Any &LinkSource) override
virtual css::uno::Sequence< OUString > getServiceNames() override
SwVbaCustomDocumentProperties(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::frame::XModel > &xDocument)
virtual css::uno::Reference< ::ooo::vba::XDocumentProperty > SAL_CALL Add(const OUString &Name, sal_Bool LinkToContent, ::sal_Int8 Type, const css::uno::Any &Value, const css::uno::Any &LinkSource) override
virtual OUString getServiceImplName() override
css::uno::Type const & get()
#define TOOLS_WARN_EXCEPTION(area, stream)
Reference< frame::XModel > m_xModel
Sequence< OUString > aServiceNames
#define SAL_INFO(area, stream)
void set(css::uno::UnoInterfaceReference const &value)
css::beans::Optional< css::uno::Any > getValue(std::u16string_view id)
enumrange< T >::Iterator begin(enumrange< T >)
SwDocShell * getDocShell(const uno::Reference< frame::XModel > &xModel)
VBAHELPER_DLLPUBLIC bool setPropertyValue(css::uno::Sequence< css::beans::PropertyValue > &aProp, const OUString &aName, const css::uno::Any &aValue)
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
bool getType(BSTR name, Type &type)
RegError REGISTRY_CALLTYPE setValue(RegKeyHandle hKey, rtl_uString *keyName, RegValueType valueType, RegValue pData, sal_uInt32 valueSize)
void setValue(Type type, object value)
Reference< XModel > xModel
InheritedHelperInterfaceWeakImpl< ooo::vba::XDocumentProperty > SwVbaDocumentProperty_BASE
std::unordered_map< sal_Int32, DocPropInfo > MSOIndexToOODocPropInfo
::cppu::WeakImplHelper< css::container::XIndexAccess,css::container::XNameAccess,css::container::XEnumerationAccess > PropertiesImpl_BASE
static sal_Int8 lcl_toMSOPropType(const uno::Type &aType)
std::unordered_map< sal_Int32, uno::Reference< XDocumentProperty > > DocProps
std::unordered_map< OUString, uno::Reference< XDocumentProperty > > DocPropsByName