LibreOffice Module xmloff (master) 1
propertyexport.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 "propertyexport.hxx"
21
22#include <memory>
23
24#include <xmloff/xmlexp.hxx>
25#include "strings.hxx"
27#include <xmloff/xmluconv.hxx>
28#include <xmloff/xmlexppr.hxx>
29#include <xmloff/xmlprmap.hxx>
31#include <sal/log.hxx>
33#include <com/sun/star/beans/PropertyAttribute.hpp>
34#include <com/sun/star/util/Date.hpp>
35#include <com/sun/star/graphic/XGraphic.hpp>
36#include <com/sun/star/util/Time.hpp>
37#include <com/sun/star/util/DateTime.hpp>
39#include <comphelper/types.hxx>
40#include "callbacks.hxx"
41#include <unotools/datetime.hxx>
42#include <tools/date.hxx>
43#include <tools/datetime.hxx>
44
45namespace xmloff
46{
47
48 using namespace css;
49 using namespace ::com::sun::star::uno;
50 using namespace ::com::sun::star::lang;
51 using namespace ::com::sun::star::beans;
52
53 // NO using namespace ...util !!!
54 // need a tools Date/Time/DateTime below, which would conflict with the uno types then
55
56 using namespace ::comphelper;
57
58 //= OPropertyExport
59 OPropertyExport::OPropertyExport(IFormsExportContext& _rContext, const Reference< XPropertySet >& _rxProps)
60 :m_rContext(_rContext)
61 ,m_xProps(_rxProps)
62 ,m_xPropertyInfo( m_xProps->getPropertySetInfo() )
63 ,m_xPropertyState( _rxProps, UNO_QUERY )
64 {
65 // caching
66 OUStringBuffer aBuffer;
68 m_sValueTrue = aBuffer.makeStringAndClear();
70 m_sValueFalse = aBuffer.makeStringAndClear();
71
72 OSL_ENSURE(m_xPropertyInfo.is(), "OPropertyExport::OPropertyExport: need an XPropertySetInfo!");
73
74 // collect the properties which need to be exported
76 }
77
78 bool OPropertyExport::shouldExportProperty( const OUString& i_propertyName ) const
79 {
80 // if the property state is DEFAULT, it does not need to be written - at least
81 // if it's a built-in property, and not a dynamically-added one.
82 bool bIsDefaultValue = m_xPropertyState.is()
83 && ( PropertyState_DEFAULT_VALUE == m_xPropertyState->getPropertyState( i_propertyName ) );
84 bool bIsDynamicProperty = m_xPropertyInfo.is()
85 && ( ( m_xPropertyInfo->getPropertyByName( i_propertyName ).Attributes & PropertyAttribute::REMOVABLE ) != 0 );
86 return ( !bIsDefaultValue || bIsDynamicProperty );
87 }
88
89 template< typename T > void
91 Any const & value, token::XMLTokenEnum eValueAttName)
92 {
93 css::uno::Sequence<T> anySeq;
94 bool bSuccess = value >>= anySeq;
95 assert(bSuccess); (void)bSuccess;
96 for (T const & i : std::as_const(anySeq))
97 {
98 OUString sValue(implConvertAny(Any(i)));
99 AddAttribute(XML_NAMESPACE_OFFICE, eValueAttName, sValue );
100 SvXMLElementExport aValueTag(
102 token::XML_LIST_VALUE, true, false);
103 }
104 }
105
107 {
108 // the properties tag (will be created if we have at least one no-default property)
109 std::unique_ptr<SvXMLElementExport> pPropertiesTag;
110
111 Any aValue;
112 OUString sValue;
113
114 // loop through all the properties which are yet to be exported
115 for ( const auto& rProperty : m_aRemainingProps )
116 {
118
119 if ( !shouldExportProperty( rProperty ) )
120 continue;
121
122 // now that we have the first sub-tag we need the form:properties element
123 if (!pPropertiesTag)
124 pPropertiesTag = std::make_unique<SvXMLElementExport>(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, token::XML_PROPERTIES, true, true);
125
126 // add the name attribute
128
129 // get the value
130 aValue = m_xProps->getPropertyValue(rProperty);
131
132 // the type to export
133 Type aExportType;
134
135 // is it a sequence
136 bool bIsSequence = TypeClass_SEQUENCE == aValue.getValueTypeClass();
137 // the type of the property, maybe reduced to the element type of a sequence
138 if (bIsSequence)
139 aExportType = getSequenceElementType( aValue.getValueType() );
140 else
141 aExportType = aValue.getValueType();
142
143 // the type attribute
144
145 bool bIsEmptyValue = TypeClass_VOID == aValue.getValueType().getTypeClass();
146 if ( bIsEmptyValue )
147 {
148 css::beans::Property aPropDesc = m_xPropertyInfo->getPropertyByName( rProperty );
149 aExportType = aPropDesc.Type;
150 }
151 token::XMLTokenEnum eValueType = implGetPropertyXMLType( aExportType );
152
153 if ( bIsEmptyValue )
155 else
157
158 token::XMLTokenEnum eValueAttName( token::XML_VALUE );
159 switch ( eValueType )
160 {
161 case token::XML_BOOLEAN: eValueAttName = token::XML_BOOLEAN_VALUE; break;
162 case token::XML_STRING: eValueAttName = token::XML_STRING_VALUE; break;
163 default: break;
164 }
165
166 if( !bIsSequence && !bIsEmptyValue )
167 { // the simple case
168
169 sValue = implConvertAny(aValue);
170 AddAttribute(XML_NAMESPACE_OFFICE, eValueAttName, sValue );
171 }
172
173 // start the property tag
176 bIsSequence ? token::XML_LIST_PROPERTY
177 : token::XML_PROPERTY, true, true);
178
179 if (!bIsSequence)
180 continue;
181
182 // the not-that-simple case, we need to iterate through the sequence elements
183 switch ( aExportType.getTypeClass() )
184 {
185 case TypeClass_STRING:
186 exportRemainingPropertiesSequence< OUString >(
187 aValue, eValueAttName);
188 break;
189 case TypeClass_DOUBLE:
190 exportRemainingPropertiesSequence< double >(
191 aValue, eValueAttName);
192 break;
193 case TypeClass_BOOLEAN:
194 exportRemainingPropertiesSequence< sal_Bool >(
195 aValue, eValueAttName);
196 break;
197 case TypeClass_BYTE:
198 exportRemainingPropertiesSequence< sal_Int8 >(
199 aValue, eValueAttName);
200 break;
201 case TypeClass_SHORT:
202 exportRemainingPropertiesSequence< sal_Int16 >(
203 aValue, eValueAttName);
204 break;
205 case TypeClass_LONG:
206 exportRemainingPropertiesSequence< sal_Int32 >(
207 aValue, eValueAttName);
208 break;
209 case TypeClass_HYPER:
210 exportRemainingPropertiesSequence< sal_Int64 >(
211 aValue, eValueAttName);
212 break;
213 default:
214 OSL_FAIL("OPropertyExport::exportRemainingProperties: unsupported sequence type !");
215 break;
216 }
217 }
218 }
219
221 {
222 m_aRemainingProps.clear();
223 const Sequence< Property > aProperties = m_xPropertyInfo->getProperties();
224 for (const auto& rProp : aProperties)
225 {
226 // no transient props
227 if ( rProp.Attributes & PropertyAttribute::TRANSIENT )
228 continue;
229 // no read-only props
230 if ( ( rProp.Attributes & PropertyAttribute::READONLY ) != 0 )
231 // except they're dynamically added
232 if ( ( rProp.Attributes & PropertyAttribute::REMOVABLE ) == 0 )
233 continue;
234 m_aRemainingProps.insert(rProp.Name);
235 }
236 }
237
238 void OPropertyExport::exportStringPropertyAttribute( const sal_uInt16 _nNamespaceKey, const OUString& _pAttributeName,
239 const OUString& _rPropertyName )
240 {
241 DBG_CHECK_PROPERTY( _rPropertyName, OUString );
242
243 // no try-catch here, this would be too expensive. The outer scope has to handle exceptions (which should not
244 // happen if we're used correctly :)
245
246 // this is way simple, as we don't need to convert anything (the property already is a string)
247
248 // get the string
249 OUString sPropValue;
250 m_xProps->getPropertyValue( _rPropertyName ) >>= sPropValue;
251
252 // add the attribute
253 if ( !sPropValue.isEmpty() )
254 AddAttribute( _nNamespaceKey, _pAttributeName, sPropValue );
255
256 // the property does not need to be handled anymore
257 exportedProperty( _rPropertyName );
258 }
259
260 void OPropertyExport::exportBooleanPropertyAttribute(const sal_uInt16 _nNamespaceKey, const OUString& _pAttributeName,
261 const OUString& _rPropertyName, const BoolAttrFlags _nBooleanAttributeFlags)
262 {
263 DBG_CHECK_PROPERTY_NO_TYPE( _rPropertyName );
264 // no check of the property value type: this method is allowed to be called with any integer properties
265 // (e.g. sal_Int32, sal_uInt16 etc)
266
267 bool bDefault(BoolAttrFlags::DefaultTrue & _nBooleanAttributeFlags);
268 bool bDefaultVoid(BoolAttrFlags::DefaultVoid & _nBooleanAttributeFlags);
269
270 // get the value
271 bool bCurrentValue = bDefault;
272 Any aCurrentValue = m_xProps->getPropertyValue( _rPropertyName );
273 if (aCurrentValue.hasValue())
274 {
275 bCurrentValue = ::cppu::any2bool(aCurrentValue);
276 // this will extract a boolean value even if the Any contains a int or short or something like that ...
277
278 if (_nBooleanAttributeFlags & BoolAttrFlags::InverseSemantics)
279 bCurrentValue = !bCurrentValue;
280
281 // we have a non-void current value
282 if (bDefaultVoid || (bDefault != bCurrentValue))
283 // and (the default is void, or the non-void default does not equal the current value)
284 // -> write the attribute
285 AddAttribute(_nNamespaceKey, _pAttributeName, bCurrentValue ? m_sValueTrue : m_sValueFalse);
286 }
287 else
288 // we have a void current value
289 if (!bDefaultVoid)
290 // and we have a non-void default
291 // -> write the attribute
292 AddAttribute(_nNamespaceKey, _pAttributeName, bCurrentValue ? m_sValueTrue : m_sValueFalse);
293
294 // the property does not need to be handled anymore
295 exportedProperty( _rPropertyName );
296 }
297
298 void OPropertyExport::exportInt16PropertyAttribute(const sal_uInt16 _nNamespaceKey, const OUString& _pAttributeName,
299 const OUString& _rPropertyName, const sal_Int16 _nDefault, bool force)
300 {
301 DBG_CHECK_PROPERTY( _rPropertyName, sal_Int16 );
302
303 // get the value
304 sal_Int16 nCurrentValue(_nDefault);
305 m_xProps->getPropertyValue( _rPropertyName ) >>= nCurrentValue;
306
307 // add the attribute
308 if (force || _nDefault != nCurrentValue)
309 {
310 // let the formatter of the export context build a string
311 AddAttribute(_nNamespaceKey, _pAttributeName, OUString::number(nCurrentValue));
312 }
313
314 // the property does not need to be handled anymore
315 exportedProperty( _rPropertyName );
316 }
317
318 void OPropertyExport::exportInt32PropertyAttribute( const sal_uInt16 _nNamespaceKey, const OUString& _pAttributeName,
319 const OUString& _rPropertyName, const sal_Int32 _nDefault )
320 {
321 DBG_CHECK_PROPERTY( _rPropertyName, sal_Int32 );
322
323 // get the value
324 sal_Int32 nCurrentValue( _nDefault );
325 m_xProps->getPropertyValue( _rPropertyName ) >>= nCurrentValue;
326
327 // add the attribute
328 if ( _nDefault != nCurrentValue )
329 {
330 // let the formatter of the export context build a string
331 AddAttribute( _nNamespaceKey, _pAttributeName, OUString::number(nCurrentValue) );
332 }
333
334 // the property does not need to be handled anymore
335 exportedProperty( _rPropertyName );
336 }
337
339 const sal_uInt16 _nNamespaceKey, const OUString& _pAttributeName,
340 const OUString &rPropertyName, const SvXMLEnumMapEntry<sal_uInt16>* _pValueMap,
341 const sal_uInt16 _nDefault, const bool _bVoidDefault)
342 {
343 // get the value
344 Any aValue = m_xProps->getPropertyValue(rPropertyName);
345
346 if (aValue.hasValue())
347 { // we have a non-void current value
348 sal_Int32 nCurrentValue(_nDefault);
349 ::cppu::enum2int(nCurrentValue, aValue);
350
351 // add the attribute
352 if ((_nDefault != nCurrentValue) || _bVoidDefault)
353 { // the default does not equal the value, or the default is void and the value isn't
354
355 // let the formatter of the export context build a string
356 OUStringBuffer sBuffer;
357 SvXMLUnitConverter::convertEnum(sBuffer, static_cast<sal_uInt16>(nCurrentValue), _pValueMap);
358
359 AddAttribute(_nNamespaceKey, _pAttributeName, sBuffer.makeStringAndClear());
360 }
361 }
362 else
363 {
364 if (!_bVoidDefault)
365 AddAttribute(_nNamespaceKey, _pAttributeName, OUString());
366 }
367
368 // the property does not need to be handled anymore
369 exportedProperty(rPropertyName);
370 }
371
373 {
375
376 OUString sTargetFrame = comphelper::getString(m_xProps->getPropertyValue(PROPERTY_TARGETFRAME));
377 if( sTargetFrame != "_blank" )
378 { // an empty string and "_blank" have the same meaning and don't have to be written
381 ,sTargetFrame);
382 }
383
385 }
386
387 void OPropertyExport::exportRelativeTargetLocation(const OUString& _sPropertyName,CCAFlags _nProperty,bool _bAddType)
388 {
389 Any aAny = m_xProps->getPropertyValue(_sPropertyName);
390
391 OUString sTargetLocation;
392 if (aAny.has<uno::Reference<graphic::XGraphic>>())
393 {
394 auto xGraphic = aAny.get<uno::Reference<graphic::XGraphic>>();
395 OUString sOutMimeType;
396 sTargetLocation = m_rContext.getGlobalContext().AddEmbeddedXGraphic(xGraphic, sOutMimeType);
397 }
398 else if (aAny.has<OUString>())
399 {
400 auto sURL = aAny.get<OUString>();
401 sTargetLocation = m_rContext.getGlobalContext().AddEmbeddedObject(sURL);
402 }
403 else
404 {
405 SAL_WARN("xmloff.forms", "OPropertyExport::exportRelativeTargetLocation: "
406 "Value of " << _sPropertyName << " not found!");
407 }
408
409 if (!sTargetLocation.isEmpty())
410 {
413 , sTargetLocation);
414
415 // #i110911# add xlink:type="simple" if required
416 if (_bAddType)
418
419 exportedProperty(_sPropertyName);
420 }
421 }
423 {
424 // flag all the properties which are part of the style as "handled"
425 rtl::Reference< XMLPropertySetMapper > xStylePropertiesSupplier = m_rContext.getStylePropertyMapper()->getPropertySetMapper();
426 for (sal_Int32 i=0; i<xStylePropertiesSupplier->GetEntryCount(); ++i)
427 exportedProperty(xStylePropertiesSupplier->GetEntryAPIName(i));
428
429 // the font properties are exported as single properties, but there is a FontDescriptor property which
430 // collects them all-in-one, this has been exported implicitly
432
433 // for the DateFormat and TimeFormat, there exist wrapper properties which has been exported as
434 // style, too
437
438 // the following properties should have been exported at the shape already:
439 exportedProperty( "VerticalAlign" );
440 exportedProperty( "WritingMode" );
441 exportedProperty( "ScaleMode" );
442 // ditto the TextWritingMode
443 exportedProperty( "WritingMode" );
444 }
445
447 const sal_uInt16 _nAttributeNamespaceKey, const OUString& _pAttributeName, const OUString& sPropertyName)
448 {
449 DBG_CHECK_PROPERTY_NO_TYPE( sPropertyName );
450
451 exportedProperty(sPropertyName);
452
453 Any aCurrentValue = m_xProps->getPropertyValue(sPropertyName);
454 if (!aCurrentValue.hasValue())
455 // nothing to do without a concrete value
456 return;
457
458 OUString sValue = implConvertAny(aCurrentValue);
459 if (sValue.isEmpty() && (TypeClass_STRING == aCurrentValue.getValueTypeClass()))
460 {
461 // check whether or not the property is allowed to be VOID
462 Property aProperty = m_xPropertyInfo->getPropertyByName(sPropertyName);
463 if ((aProperty.Attributes & PropertyAttribute::MAYBEVOID) == 0)
464 // the string is empty, and the property is not allowed to be void
465 // -> don't need to write the attribute, 'cause missing it is unambiguous
466 return;
467 }
468
469 // finally add the attribute to the context
470 AddAttribute(_nAttributeNamespaceKey, _pAttributeName, sValue);
471 }
472
473 void OPropertyExport::exportStringSequenceAttribute(const sal_uInt16 _nAttributeNamespaceKey, const OUString& _pAttributeName,
474 const OUString& _rPropertyName)
475 {
476 const sal_Unicode _aListSeparator = ',';
477 const sal_Unicode _aQuoteCharacter = '"';
478 DBG_CHECK_PROPERTY( _rPropertyName, Sequence< OUString > );
479
480 Sequence< OUString > aItems;
481 m_xProps->getPropertyValue( _rPropertyName ) >>= aItems;
482
483 OUStringBuffer sFinalList;
484
485 // unfortunately the OUString can't append single sal_Unicode characters ...
486 const OUString sQuote(&_aQuoteCharacter, 1);
487 const OUString sSeparator(&_aListSeparator, 1);
488 const bool bQuote = !sQuote.isEmpty();
489
490 // concatenate the string items
491 const OUString* pItems = aItems.getConstArray();
492 const OUString* pEnd = pItems + aItems.getLength();
493 const OUString* pLastElement = pEnd - 1;
494 for ( ;
495 pItems != pEnd;
496 ++pItems
497 )
498 {
499 OSL_ENSURE(-1 == pItems->indexOf(_aQuoteCharacter),
500 "OPropertyExport::exportStringSequenceAttribute: there is an item which contains the quote character!");
501
502 if (bQuote)
503 sFinalList.append(sQuote);
504 sFinalList.append(*pItems);
505 if (bQuote)
506 sFinalList.append(sQuote);
507
508 if (pItems != pLastElement)
509 sFinalList.append(sSeparator);
510 }
511
512 if (!sFinalList.isEmpty())
513 AddAttribute(_nAttributeNamespaceKey, _pAttributeName, sFinalList.makeStringAndClear());
514
515 exportedProperty( _rPropertyName );
516 }
517
518 OUString OPropertyExport::implConvertAny(const Any& _rValue)
519 {
520 OUStringBuffer aBuffer;
521 switch (_rValue.getValueTypeClass())
522 {
523 case TypeClass_STRING:
524 { // extract the string
525 OUString sCurrentValue;
526 _rValue >>= sCurrentValue;
527 aBuffer.append(sCurrentValue);
528 }
529 break;
530 case TypeClass_DOUBLE:
531 // let the unit converter format is as string
533 break;
534 case TypeClass_BOOLEAN:
536 break;
537 case TypeClass_BYTE:
538 case TypeClass_UNSIGNED_SHORT:
539 case TypeClass_SHORT:
540 case TypeClass_LONG:
541 // let the unit converter format is as string
542 aBuffer.append(getINT32(_rValue));
543 break;
544 case TypeClass_UNSIGNED_LONG:
545 case TypeClass_HYPER:
546 aBuffer.append(getINT64(_rValue));
547 break;
548 case TypeClass_UNSIGNED_HYPER:
549 aBuffer.append(static_cast<sal_Int64>(_rValue.get<sal_uInt64>()));
550 break;
551 case TypeClass_ENUM:
552 {
553 // convert it into an int32
554 sal_Int32 nValue = 0;
555 ::cppu::enum2int(nValue, _rValue);
556 aBuffer.append(nValue);
557 }
558 break;
559 default:
560 { // hmmm... what else do we know?
561 double fValue = 0;
562 css::util::Date aDate;
563 css::util::Time aTime;
564 css::util::DateTime aDateTime;
565 if (_rValue >>= aDate)
566 {
567 Date aToolsDate( Date::EMPTY );
568 ::utl::typeConvert(aDate, aToolsDate);
569 fValue = aToolsDate.GetDate();
570 }
571 else if (_rValue >>= aTime)
572 {
573 fValue = aTime.Hours / static_cast<double>(::tools::Time::hourPerDay) +
574 aTime.Minutes / static_cast<double>(::tools::Time::minutePerDay) +
575 aTime.Seconds / static_cast<double>(::tools::Time::secondPerDay) +
576 aTime.NanoSeconds / static_cast<double>(::tools::Time::nanoSecPerDay);
577 }
578 else if (_rValue >>= aDateTime)
579 {
580 DateTime aToolsDateTime( DateTime::EMPTY );
581 ::utl::typeConvert(aDateTime, aToolsDateTime);
582 // the time part (the digits behind the comma)
583 fValue = aTime.Hours / static_cast<double>(::tools::Time::hourPerDay) +
584 aTime.Minutes / static_cast<double>(::tools::Time::minutePerDay) +
585 aTime.Seconds / static_cast<double>(::tools::Time::secondPerDay) +
586 aTime.NanoSeconds / static_cast<double>(::tools::Time::nanoSecPerDay);
587 // plus the data part (the digits in front of the comma)
588 fValue += aToolsDateTime.GetDate();
589 }
590 else
591 {
592 // if any other types are added here, please remember to adjust implGetPropertyXMLType accordingly
593
594 // no more options ...
595 OSL_FAIL("OPropertyExport::implConvertAny: unsupported value type!");
596 break;
597 }
598 // let the unit converter format is as string
600 }
601 break;
602 }
603
604 return aBuffer.makeStringAndClear();
605 }
606
608 {
609 // handle the type description
610 switch (_rType.getTypeClass())
611 {
612 case TypeClass_STRING:
613 return token::XML_STRING;
614 case TypeClass_DOUBLE:
615 case TypeClass_BYTE:
616 case TypeClass_SHORT:
617 case TypeClass_LONG:
618 case TypeClass_HYPER:
619 case TypeClass_ENUM:
620 return token::XML_FLOAT;
621 case TypeClass_BOOLEAN:
622 return token::XML_BOOLEAN;
623
624 default:
625 return token::XML_FLOAT;
626 }
627 }
628
629#ifdef DBG_UTIL
630 void OPropertyExport::AddAttribute( sal_uInt16 _nPrefix, const OUString& _rName, const OUString& _rValue )
631 {
632 OSL_ENSURE(m_rContext.getGlobalContext().GetXAttrList()->getValueByName( _rName ).isEmpty(),
633 "OPropertyExport::AddAttribute: already have such an attribute");
634
635 m_rContext.getGlobalContext().AddAttribute( _nPrefix, _rName, _rValue );
636 }
637
638 void OPropertyExport::AddAttribute(sal_uInt16 _nPrefix, ::xmloff::token::XMLTokenEnum _eName, const OUString& _rValue)
639 {
640 OSL_ENSURE(m_rContext.getGlobalContext().GetXAttrList()->getValueByName(::xmloff::token::GetXMLToken(_eName)).isEmpty(),
641 "OPropertyExport::AddAttribute: already have such an attribute");
642
643 m_rContext.getGlobalContext().AddAttribute(_nPrefix, _eName, _rValue);
644 }
645
647 {
648 OSL_ENSURE(m_rContext.getGlobalContext().GetXAttrList()->getValueByName(::xmloff::token::GetXMLToken(_eName)).isEmpty(),
649 "OPropertyExport::AddAttribute: already have such an attribute");
650
651 m_rContext.getGlobalContext().AddAttribute(_nPrefix, _eName, _eValue);
652 }
653
654 void OPropertyExport::dbg_implCheckProperty(const OUString& _rPropertyName, const Type* _pType)
655 {
656 try
657 {
658 // the property must exist
659 if (!m_xPropertyInfo->hasPropertyByName(_rPropertyName))
660 {
661 SAL_WARN("xmloff.forms", "OPropertyExport: "
662 "no property with the name " + _rPropertyName + "!");
663 return;
664 }
665
666 if (_pType)
667 {
668 // and it must have the correct type
669 Property aPropertyDescription = m_xPropertyInfo->getPropertyByName(_rPropertyName);
670 OSL_ENSURE(aPropertyDescription.Type.equals(*_pType), "OPropertyExport::dbg_implCheckProperty: invalid property type!");
671 }
672 }
673 catch(Exception&)
674 {
675 TOOLS_WARN_EXCEPTION("xmloff.forms", "could not check the property!");
676 }
677 }
678#endif // DBG_UTIL - dbg_implCheckProperty
679
680} // namespace xmloff
681
682/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XPropertySet > m_xProps
PropertiesInfo aProperties
sal_Int32 GetDate() const
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
Definition: xmlexp.cxx:907
OUString AddEmbeddedObject(const OUString &rEmbeddedObjectURL)
Definition: xmlexp.cxx:1895
css::uno::Reference< css::xml::sax::XAttributeList > GetXAttrList() const
Definition: xmlexp.hxx:375
OUString AddEmbeddedXGraphic(css::uno::Reference< css::graphic::XGraphic > const &rxGraphic, OUString &rOutMimeType, OUString const &rRequestedName=OUString())
Definition: xmlexp.cxx:1838
static bool convertEnum(EnumT &rEnum, std::u16string_view rValue, const SvXMLEnumMapEntry< EnumT > *pMap)
convert string to enum using given enum map, if the enum is not found in the map, this method will re...
Definition: xmluconv.hxx:145
static void convertDouble(OUStringBuffer &rBuffer, double fNumber, bool bWriteUnits, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit)
static bool convertBool(bool &rBool, std::u16string_view rString)
static const sal_Int64 nanoSecPerDay
static const sal_Int64 minutePerDay
static const sal_Int64 hourPerDay
static const sal_Int64 secondPerDay
virtual SvXMLExport & getGlobalContext()=0
virtual ::rtl::Reference< SvXMLExportPropertyMapper > getStylePropertyMapper()=0
static OUString getCommonControlAttributeName(CCAFlags _nId)
calculates the xml attribute representation of a common control attribute.
static sal_uInt16 getCommonControlAttributeNamespace(CCAFlags _nId)
calculates the xml namespace key to use for a common control attribute
void exportStringSequenceAttribute(const sal_uInt16 _nAttributeNamespaceKey, const OUString &_pAttributeName, const OUString &_rPropertyName)
exports a property value, which is a string sequence, as attribute
OPropertyExport(IFormsExportContext &_rContext, const css::uno::Reference< css::beans::XPropertySet > &_rxProps)
constructs an object capable of handling attributes for export
void examinePersistence()
examines a property set given for all properties which's value are to made persistent
IFormsExportContext & m_rContext
void exportInt32PropertyAttribute(const sal_uInt16 _nNamespaceKey, const OUString &_pAttributeName, const OUString &_rPropertyName, const sal_Int32 _nDefault)
add an attribute which is represented by a sal_Int32 property to the export context
void exportedProperty(const OUString &_rPropertyName)
indicates that a property has been handled by a derived class, without using the helper methods of th...
bool shouldExportProperty(const OUString &i_propertyName) const
determines whether the given property is to be exported
void flagStyleProperties()
flag the style properties as 'already exported'
std::set< OUString > m_aRemainingProps
void exportInt16PropertyAttribute(const sal_uInt16 _nNamespaceKey, const OUString &_pAttributeName, const OUString &_rPropertyName, const sal_Int16 _nDefault, const bool force=false)
add an attribute which is represented by a sal_Int16 property to the export context
const css::uno::Reference< css::beans::XPropertySet > m_xProps
const css::uno::Reference< css::beans::XPropertyState > m_xPropertyState
::xmloff::token::XMLTokenEnum implGetPropertyXMLType(const css::uno::Type &_rType)
void exportBooleanPropertyAttribute(const sal_uInt16 _nNamespaceKey, const OUString &_pAttributeName, const OUString &_rPropertyName, const BoolAttrFlags _nBooleanAttributeFlags)
add an attribute which is represented by a boolean property to the export context
void exportGenericPropertyAttribute(const sal_uInt16 _nAttributeNamespaceKey, const OUString &_pAttributeName, const OUString &_pPropertyName)
add an arbitrary attribute extracted from an arbitrary property to the export context
void exportEnumPropertyAttributeImpl(const sal_uInt16 _nNamespaceKey, const OUString &_pAttributeName, const OUString &_rPropertyName, const SvXMLEnumMapEntry< sal_uInt16 > *_pValueMap, const sal_uInt16 _nDefault, const bool _bVoidDefault)
OUString implConvertAny(const css::uno::Any &_rValue)
tries to convert an arbitrary <type scope="com.sun:star.uno">Any</type> into an string
void exportRelativeTargetLocation(const OUString &_sPropertyName, CCAFlags _nProperty, bool _bAddType)
void exportRemainingPropertiesSequence(css::uno::Any const &value, token::XMLTokenEnum eValueAttName)
void exportStringPropertyAttribute(const sal_uInt16 _nNamespaceKey, const OUString &_pAttributeName, const OUString &_rPropertyName)
add an attribute which is represented by a string property to the export context
const css::uno::Reference< css::beans::XPropertySetInfo > m_xPropertyInfo
void dbg_implCheckProperty(const OUString &_rPropertyName, const css::uno::Type *_pType)
check a given property set for the existence and type correctness of a given property
void AddAttribute(sal_uInt16 _nPrefix, const OUString &_rName, const OUString &_rValue)
void exportTargetFrameAttribute()
add the hlink:target-frame attribute to the export context.
Any value
#define TOOLS_WARN_EXCEPTION(area, stream)
const char sQuote[]
sal_Int16 nValue
CCAFlags
#define SAL_WARN(area, stream)
@ Exception
bool getBOOL(const Any &_rAny)
sal_Int64 getINT64(const Any &_rAny)
Type getSequenceElementType(const Type &_rSequenceType)
double getDouble(const Any &_rAny)
sal_Int32 getINT32(const Any &_rAny)
OUString getString(const Any &_rAny)
Type
int i
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:50
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3541
constexpr OUStringLiteral PROPERTY_TARGETFRAME
Definition: strings.hxx:34
constexpr OUStringLiteral PROPERTY_FONT
Definition: strings.hxx:102
constexpr OUStringLiteral PROPERTY_DATEFORMAT
Definition: strings.hxx:115
constexpr OUStringLiteral PROPERTY_TIMEFORMAT
Definition: strings.hxx:116
#define DBG_CHECK_PROPERTY_NO_TYPE(name)
BoolAttrFlags
#define DBG_CHECK_PROPERTY(name, type)
const Reference< XComponentContext > & m_rContext
sal_uInt16 sal_Unicode
std::unique_ptr< char[]> aBuffer
constexpr sal_uInt16 XML_NAMESPACE_XLINK
constexpr sal_uInt16 XML_NAMESPACE_FORM
constexpr sal_uInt16 XML_NAMESPACE_OFFICE