22#include <com/sun/star/beans/PropertyAttribute.hpp>
23#include <com/sun/star/beans/XPropertySet.hpp>
24#include <com/sun/star/beans/XPropertyContainer.hpp>
25#include <com/sun/star/document/XDocumentProperties.hpp>
26#include <com/sun/star/document/XCompatWriterDocProperties.hpp>
27#include <com/sun/star/uno/Exception.hpp>
28#include <rtl/ustring.hxx>
50 const uno::Reference< document::XDocumentProperties>& i_xDocProps,
66 util::DateTime aDateTime;
68 if( xGlobSect->GetStringValue( aStrValue,
PROPID_TITLE ) )
69 i_xDocProps->setTitle( aStrValue );
71 i_xDocProps->setSubject( aStrValue );
73 i_xDocProps->setKeywords(
74 ::comphelper::string::convertCommaSeparated(aStrValue) );
77 i_xDocProps->setTemplateName( aStrValue );
79 i_xDocProps->setDescription( aStrValue );
81 util::DateTime aInvalid;
83 i_xDocProps->setAuthor( aStrValue );
85 i_xDocProps->setAuthor( OUString() );
87 i_xDocProps->setCreationDate( aDateTime );
89 i_xDocProps->setCreationDate( aInvalid );
92 i_xDocProps->setModifiedBy( aStrValue );
94 i_xDocProps->setModifiedBy( OUString() );
96 i_xDocProps->setModificationDate( aDateTime );
98 i_xDocProps->setModificationDate( aInvalid );
100 i_xDocProps->setPrintedBy( OUString() );
102 i_xDocProps->setPrintDate( aDateTime );
104 i_xDocProps->setPrintDate( aInvalid );
108 sal_Int16 nRevision =
static_cast< sal_Int16
>( aStrValue.toInt32() );
110 i_xDocProps->setEditingCycles( nRevision );
114 && !(aDateTime.NanoSeconds == 0 && aDateTime.Seconds == 0
115 && aDateTime.Minutes == 0 && aDateTime.Hours == 0
116 && aDateTime.Day == 0 && aDateTime.Month == 0
117 && aDateTime.Year == 0) )
120 aDateTime.Year -= 1601;
121 aDateTime.Month -= 1;
125 i_xDocProps->setEditingDuration(
126 aDateTime.Day * 60*60*24 +
127 aDateTime.Hours * 60*60 +
128 aDateTime.Minutes * 60 +
131 catch (
const lang::IllegalArgumentException &)
149 uno::Reference < beans::XPropertyContainer > xUserDefined(
150 i_xDocProps->getUserDefinedProperties(), uno::UNO_SET_THROW);
151 ::std::vector< sal_Int32 > aPropIds;
152 xCustomSect->GetPropertyIds( aPropIds );
153 for(
const auto& rPropId : aPropIds )
155 const OUString
aPropName = xCustomSect->GetPropertyName( rPropId );
156 uno::Any aPropValue = xCustomSect->GetAnyValue( rPropId );
162 beans::PropertyAttribute::REMOVABLE, aPropValue );
164 catch (
const uno::Exception&)
172 uno::Reference< document::XCompatWriterDocProperties > xWriterProps( i_xDocProps, uno::UNO_QUERY );
173 if ( xWriterProps.is() )
182 xWriterProps->setManager( aStrValue );
184 xWriterProps->setCategory( aStrValue );
186 xWriterProps->setCompany( aStrValue );
188 catch (
const uno::Exception&)
195 return (nGlobError !=
ERRCODE_NONE) ? nGlobError : nDocError;
199 const uno::Reference< document::XDocumentProperties>& i_xDocProps,
201 const uno::Sequence<sal_Int8> * i_pThumb,
202 const uno::Sequence<sal_Int8> * i_pGuid,
203 const uno::Sequence<sal_Int8> * i_pHyperlinks)
213 const OUString
aStr = ::comphelper::string::convertCommaSeparated(
214 i_xDocProps->getKeywords() );
222 i_xDocProps->getModificationDate() );
226 sal_Int32 dur = i_xDocProps->getEditingDuration();
227 util::DateTime aEditTime;
229 aEditTime.Year = 1601;
232 aEditTime.Hours =
static_cast<sal_Int16
>(dur / 3600);
233 aEditTime.Minutes =
static_cast<sal_Int16
>((dur % 3600) / 60);
234 aEditTime.Seconds =
static_cast<sal_Int16
>(dur % 60);
238 OUString::number( i_xDocProps->getEditingCycles() ) );
239 if ( i_pThumb && i_pThumb->hasElements() )
272 uno::Reference<beans::XPropertySet> xUserDefinedProps(
273 i_xDocProps->getUserDefinedProperties(), uno::UNO_QUERY_THROW);
274 uno::Reference<beans::XPropertySetInfo> xPropInfo =
275 xUserDefinedProps->getPropertySetInfo();
276 DBG_ASSERT(xPropInfo.is(),
"UserDefinedProperties Info is null");
277 const uno::Sequence<beans::Property>
props = xPropInfo->getProperties();
278 for (
const auto& rProp :
props)
283 if (~rProp.Attributes & beans::PropertyAttribute::TRANSIENT)
285 const OUString
name = rProp.Name;
288 xUserDefinedProps->getPropertyValue(
name))) {
293 catch (
const uno::Exception &)
296 SAL_INFO(
"sfx",
"SavePropertySet: exception");
319 return uno::Sequence<sal_Int8>();
Bitmap GetBitmap(Color aTransparentReplaceColor) const
Represents a complete property set, may consist of several property sections.
SfxOleSection & AddSection(SfxOleSectionType eSection)
Creates and returns the specified section, or just returns it if it already exists.
ErrCode const & LoadPropertySet(SotStorage *pStrg, const OUString &rStrmName)
Loads this object from the passed storage.
ErrCode const & SavePropertySet(SotStorage *pStrg, const OUString &rStrmName)
Saves this object to the passed storage.
SfxOleSectionRef GetSection(SfxOleSectionType eSection) const
Returns the specified section, or an empty reference, if nothing found.
A section in a property set.
void SetPropertyName(sal_Int32 nPropId, const OUString &rPropName)
Sets a custom name for the passed property ID.
void SetFileTimeValue(sal_Int32 nPropId, const css::util::DateTime &rValue)
Inserts a time stamp property with the passed value.
sal_Int32 GetFreePropertyId() const
Returns a property identifier not used in this section.
void SetThumbnailValue(sal_Int32 nPropId, const css::uno::Sequence< sal_Int8 > &i_rData)
Inserts a thumbnail property from the passed meta file.
bool SetStringValue(sal_Int32 nPropId, const OUString &rValue)
Inserts a string property with the passed value.
void SetBlobValue(sal_Int32 nPropId, const css::uno::Sequence< sal_Int8 > &i_rData)
Inserts a BLOB property with the passed data.
bool SetAnyValue(sal_Int32 nPropId, const css::uno::Any &rValue)
Inserts a property created from the passed any.
virtual sal_uInt64 TellEnd() override
#define DBG_ASSERT(sCon, aError)
constexpr OUStringLiteral STREAM_DOCSUMMARYINFO
constexpr OUStringLiteral STREAM_SUMMARYINFO
#define SAL_INFO(area, stream)
ErrCode LoadOlePropertySet(const uno::Reference< document::XDocumentProperties > &i_xDocProps, SotStorage *i_pStorage)
uno::Sequence< sal_Int8 > convertMetaFile(GDIMetaFile const *i_pThumb)
bool SaveOlePropertySet(const uno::Reference< document::XDocumentProperties > &i_xDocProps, SotStorage *i_pStorage, const uno::Sequence< sal_Int8 > *i_pThumb, const uno::Sequence< sal_Int8 > *i_pGuid, const uno::Sequence< sal_Int8 > *i_pHyperlinks)
@ SECTION_BUILTIN
Globally defined properties.
@ SECTION_CUSTOM
Properties built into MS Office.
const sal_Int32 PROPID_THUMBNAIL
const sal_Int32 PROPID_AUTHOR
const sal_Int32 PROPID_MANAGER
const sal_Int32 PROPID_EDITTIME
const sal_Int32 PROPID_CATEGORY
const sal_Int32 PROPID_REVNUMBER
const sal_Int32 PROPID_COMPANY
const sal_Int32 PROPID_COMMENTS
const sal_Int32 PROPID_TEMPLATE
const sal_Int32 PROPID_SUBJECT
std::shared_ptr< SfxOleSection > SfxOleSectionRef
const sal_Int32 PROPID_KEYWORDS
const sal_Int32 PROPID_CREATED
const sal_Int32 PROPID_LASTSAVED
const sal_Int32 PROPID_TITLE
const sal_Int32 PROPID_LASTPRINTED
const sal_Int32 PROPID_LASTAUTHOR