21 #include <rtl/ustrbuf.hxx>
29 #include <com/sun/star/beans/XPropertyAccess.hpp>
30 #include <com/sun/star/beans/StringPair.hpp>
31 #include <com/sun/star/document/XDocumentProperties.hpp>
32 #include <com/sun/star/util/DateTime.hpp>
33 #include <com/sun/star/util/Duration.hpp>
34 #include <com/sun/star/xml/sax/XSAXSerializable.hpp>
57 sTmp.append( static_cast<sal_Int32>(rDateTime.Year) );
69 return sTmp.makeStringAndClear();
75 if ( !rText.isEmpty() ) {
78 mrExport.Characters( rText );
85 if (rDate.Month != 0) {
86 OUString sValue = GetISODateTimeString( rDate );
87 if ( !sValue.isEmpty() ) {
90 mrExport.Characters( sValue );
105 SimpleStringElement ( mxDocProps->getTitle(),
109 SimpleStringElement ( mxDocProps->getDescription(),
113 SimpleStringElement ( mxDocProps->getSubject(),
117 SimpleStringElement ( mxDocProps->getAuthor(),
119 SimpleDateTimeElement( mxDocProps->getCreationDate(),
123 SimpleStringElement ( mxDocProps->getModifiedBy(),
125 SimpleDateTimeElement( mxDocProps->getModificationDate(),
129 SimpleStringElement ( mxDocProps->getPrintedBy(),
131 SimpleDateTimeElement( mxDocProps->getPrintDate(),
135 const uno::Sequence< OUString > keywords = mxDocProps->getKeywords();
136 for (
const auto& rKeyword : keywords) {
139 mrExport.Characters( rKeyword );
144 OUString sValue =
LanguageTag( mxDocProps->getLanguage()).getBcp47(
false);
145 if (!sValue.isEmpty()) {
148 mrExport.Characters( sValue );
157 mrExport.Characters( OUString::number(
158 mxDocProps->getEditingCycles() ) );
164 sal_Int32 secs = mxDocProps->getEditingDuration();
170 false, 0, 0, 0, secs/3600, (secs%3600)/60, secs%60, 0));
171 mrExport.Characters(buf.makeStringAndClear());
175 const OUString sDefTarget = mxDocProps->getDefaultTarget();
176 if ( !sDefTarget.isEmpty() )
191 const OUString sReloadURL = mxDocProps->getAutoloadURL();
192 const sal_Int32 sReloadDelay = mxDocProps->getAutoloadSecs();
193 if (sReloadDelay != 0 || !sReloadURL.isEmpty())
196 mrExport.GetRelativeReference( sReloadURL ) );
200 sReloadDelay/3600, (sReloadDelay%3600)/60, sReloadDelay%60, 0));
202 buf.makeStringAndClear());
209 const OUString sTplPath = mxDocProps->getTemplateURL();
210 if ( !sTplPath.isEmpty() )
217 mrExport.GetRelativeReference(sTplPath) );
221 mxDocProps->getTemplateName() );
225 GetISODateTimeString( mxDocProps->getTemplateDate() ) );
232 uno::Reference< beans::XPropertyAccess > xUserDefined(
233 mxDocProps->getUserDefinedProperties(), uno::UNO_QUERY_THROW);
234 const uno::Sequence< beans::PropertyValue >
props =
235 xUserDefined->getPropertyValues();
236 for (
const auto& rProp : props) {
237 OUStringBuffer sValueBuffer;
238 OUStringBuffer
sType;
245 sType.makeStringAndClear() );
248 mrExport.Characters( sValueBuffer.makeStringAndClear() );
251 const uno::Sequence< beans::NamedValue > aDocStatistic =
252 mxDocProps->getDocumentStatistics();
254 if ( !aDocStatistic.hasElements() )
257 for (
const auto& rDocStat : aDocStatistic )
260 if ( rDocStat.Value >>= nValue )
262 OUString aValue = OUString::number( nValue );
263 if ( rDocStat.Name ==
"TableCount" )
264 mrExport.AddAttribute(
266 else if ( rDocStat.Name ==
"ObjectCount" )
267 mrExport.AddAttribute(
269 else if ( rDocStat.Name ==
"ImageCount" )
270 mrExport.AddAttribute(
272 else if ( rDocStat.Name ==
"PageCount" )
273 mrExport.AddAttribute(
275 else if ( rDocStat.Name ==
"ParagraphCount" )
276 mrExport.AddAttribute(
278 else if ( rDocStat.Name ==
"WordCount" )
279 mrExport.AddAttribute(
281 else if ( rDocStat.Name ==
"CharacterCount" )
282 mrExport.AddAttribute(
284 else if ( rDocStat.Name ==
"CellCount" )
285 mrExport.AddAttribute(
289 SAL_WARN(
"xmloff",
"Unknown statistic value!");
304 const uno::Reference<document::XDocumentProperties>& i_rDocProps ) :
306 mxDocProps( i_rDocProps ),
319 uno::Reference< xml::sax::XSAXSerializable> xSAXable(
mxDocProps,
322 ::std::vector< beans::StringPair >
namespaces;
324 for (sal_uInt16 key = rNsMap.GetFirstKey();
325 key !=
USHRT_MAX; key = rNsMap.GetNextKey(key)) {
326 beans::StringPair
ns;
327 const OUString attrname = rNsMap.GetAttrNameByKey(key);
328 if (!attrname.startsWith(
s_xmlns2, &ns.First)
331 assert(!
"namespace attribute not starting with xmlns unexpected");
333 ns.Second = rNsMap.GetNameByKey(key);
334 namespaces.push_back(ns);
364 const uno::Reference< xml::sax::XAttributeList > & i_xAttribs)
370 const sal_Int16
nCount = i_xAttribs->getLength();
371 for (sal_Int16
i = 0;
i < nCount; ++
i) {
372 const OUString
name(i_xAttribs->getNameByIndex(
i));
376 for (sal_uInt16 key = rNsMap.GetFirstKey();
377 key !=
USHRT_MAX; key = rNsMap.GetNextKey(key)) {
378 if (
name == rNsMap.GetAttrNameByKey(key)) {
385 i_xAttribs->getValueByIndex(
i));
397 const OUString
ns(rPreservedNS.First);
400 const sal_Int16
nCount = i_xAttribs->getLength();
401 for (sal_Int16
i = 0;
i < nCount; ++
i) {
402 const OUString
name(i_xAttribs->getNameByIndex(
i));
415 if (i_rName.startsWith(
s_meta)) {
418 const sal_Int16
nLength = i_xAttribs->getLength();
420 const OUString
name (i_xAttribs->getNameByIndex (
i));
421 OUString
value(i_xAttribs->getValueByIndex(
i));
428 const sal_Int16
nLength = i_xAttribs->getLength();
430 const OUString
name (i_xAttribs->getNameByIndex(
i));
431 const OUString
value (i_xAttribs->getValueByIndex(
i));
constexpr sal_uInt16 XML_NAMESPACE_OFFICE
constexpr sal_uInt16 XML_NAMESPACE_XLINK
static bool convertAny(OUStringBuffer &rsValue, OUStringBuffer &rsType, const css::uno::Any &rValue)
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
void AddAttribute(sal_uInt16 nPrefix, const char *pName, const OUString &rValue)
void StartElement(sal_uInt16 nPrefix, enum::xmloff::token::XMLTokenEnum eName, bool bIgnWSOutside)
static OUString GetGeneratorString()
OUString GetRelativeReference(const OUString &rValue)
XMLTokenEnum
The enumeration of all XML tokens.
static void convertDuration(OUStringBuffer &rBuffer, const double fTime)
constexpr sal_uInt16 XML_NAMESPACE_DC
const SvXMLNamespaceMap & GetNamespaceMap() const
void IgnorableWhitespace()
void EndElement(sal_uInt16 nPrefix, enum::xmloff::token::XMLTokenEnum eName, bool bIgnWSInside)
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
Handling of tokens in XML:
void Characters(const OUString &rChars)
#define SAL_WARN(area, stream)
constexpr sal_uInt16 XML_NAMESPACE_META