31 #include <com/sun/star/linguistic2/XSupportedLocales.hpp>
32 #include <com/sun/star/i18n/XForbiddenCharacters.hpp>
33 #include <com/sun/star/beans/PropertyValue.hpp>
34 #include <com/sun/star/container/XNameAccess.hpp>
35 #include <com/sun/star/container/XNameContainer.hpp>
36 #include <com/sun/star/container/XIndexContainer.hpp>
37 #include <com/sun/star/util/PathSubstitution.hpp>
38 #include <com/sun/star/util/DateTime.hpp>
39 #include <com/sun/star/formula/SymbolDescriptor.hpp>
40 #include <com/sun/star/document/PrinterIndependentLayout.hpp>
41 #include <com/sun/star/document/IndexedPropertyValues.hpp>
66 const OUString& rName)
const
71 uno::TypeClass eClass = aAny.getValueTypeClass();
74 case uno::TypeClass_VOID:
84 case uno::TypeClass_BOOLEAN:
89 case uno::TypeClass_BYTE:
94 case uno::TypeClass_SHORT:
101 case uno::TypeClass_LONG:
103 sal_Int32 nInt32 = 0;
108 case uno::TypeClass_HYPER:
110 sal_Int64 nInt64 = 0;
115 case uno::TypeClass_DOUBLE:
117 double fDouble = 0.0;
122 case uno::TypeClass_STRING:
131 const uno::Type& aType = aAny.getValueType();
132 if (aType.equals(
cppu::UnoType<uno::Sequence<beans::PropertyValue>>::
get() ) )
134 uno::Sequence< beans::PropertyValue> aProps;
138 else if( aType.equals(
cppu::UnoType<uno::Sequence<sal_Int8>>::
get() ) )
140 uno::Sequence< sal_Int8 > aProps;
147 uno::Reference< container::XNameAccess> aNamed;
154 uno::Reference<container::XIndexAccess> aIndexed;
160 util::DateTime aDateTime;
168 else if( aType.equals(
cppu::UnoType<uno::Sequence<formula::SymbolDescriptor>>::
get() ) )
170 uno::Sequence< formula::SymbolDescriptor > aProps;
175 OSL_FAIL(
"this type is not implemented now");
199 OSL_ENSURE(
false,
"XMLSettingsExportHelper::exportByte(): #i114162#:\n"
200 "config-items of type \"byte\" are not valid ODF, "
201 "so storing them is disabled!\n"
202 "Use a different type instead (e.g. \"short\").");
240 OUStringBuffer sBuffer;
252 if (!sValue.isEmpty())
262 OUStringBuffer sBuffer;
270 const uno::Sequence<beans::PropertyValue>& aProps,
271 const OUString& rName)
const
274 if(aProps.hasElements())
278 for (
const auto& rProp : aProps)
284 const uno::Sequence < formula::SymbolDescriptor > &rProps,
285 const OUString& rName)
const
289 const OUString
sName (
"Name" );
290 const OUString sExportName (
"ExportName" );
291 const OUString sSymbolSet (
"SymbolSet" );
292 const OUString sCharacter (
"Character" );
293 const OUString sFontName (
"FontName" );
294 const OUString sCharSet (
"CharSet" );
295 const OUString sFamily (
"Family" );
296 const OUString sPitch (
"Pitch" );
297 const OUString sWeight (
"Weight" );
298 const OUString sItalic (
"Italic" );
300 sal_Int32
nCount = rProps.getLength();
301 const formula::SymbolDescriptor *pDescriptor = rProps.getConstArray();
306 beans::PropertyValue *pSymbol = aSequence.getArray();
329 xBox->insertByIndex(
nIndex, uno::makeAny( aSequence ));
335 const uno::Sequence<sal_Int8>& aProps,
336 const OUString& rName)
const
342 if(aProps.hasElements())
344 OUStringBuffer sBuffer;
352 const OUString& rName,
353 const bool bNameAccess)
const
355 DBG_ASSERT((bNameAccess && !rName.isEmpty()) || !bNameAccess,
"no name");
356 uno::Sequence<beans::PropertyValue> aProps;
358 if (aProps.hasElements())
363 for (
const auto& rProp : std::as_const(aProps))
370 const uno::Reference<container::XNameAccess>& aNamed,
371 const OUString& rName)
const
375 "wrong NameAccess" );
376 if(aNamed->hasElements())
380 const uno::Sequence< OUString > aNames(aNamed->getElementNames());
381 for (
const auto& rElementName : aNames)
382 exportMapEntry(aNamed->getByName(rElementName), rElementName,
true);
388 const uno::Reference<container::XIndexAccess>& rIndexed,
389 const OUString& rName)
const
393 "wrong IndexAccess" );
394 if (rIndexed->hasElements())
398 sal_Int32
nCount = rIndexed->getCount();
399 for (sal_Int32
i = 0;
i < nCount;
i++)
409 const OUString& rName)
const
411 uno::Reference<i18n::XForbiddenCharacters> xForbChars;
412 uno::Reference<linguistic2::XSupportedLocales> xLocales;
417 SAL_WARN_IF( !(xForbChars.is() && xLocales.is()),
"xmloff",
"XMLSettingsExportHelper::exportForbiddenCharacters: got illegal forbidden characters!" );
419 if( !xForbChars.is() || !xLocales.is() )
423 const uno::Sequence< lang::Locale > aLocales( xLocales->getLocales() );
429 const OUString sLanguage (
"Language" );
430 const OUString sCountry (
"Country" );
431 const OUString sVariant (
"Variant" );
432 const OUString sBeginLine (
"BeginLine" );
433 const OUString sEndLine (
"EndLine" );
436 for(
const auto& rLocale : aLocales )
438 if( xForbChars->hasForbiddenCharacters( rLocale ) )
440 const i18n::ForbiddenCharacters aChars( xForbChars->getForbiddenCharacters( rLocale ) );
444 beans::PropertyValue *pForChar = aSequence.getArray();
456 xBox->insertByIndex(nPos++, uno::makeAny( aSequence ));
464 const uno::Sequence<beans::PropertyValue>& aProps,
465 const OUString& rName)
const
480 sal_Int16 nTmp = sal_Int16();
483 if( nTmp == document::PrinterIndependentLayout::LOW_RESOLUTION )
484 rAny <<= OUString(
"low-resolution");
485 else if( nTmp == document::PrinterIndependentLayout::DISABLED )
486 rAny <<= OUString(
"disabled");
487 else if( nTmp == document::PrinterIndependentLayout::HIGH_RESOLUTION )
488 rAny <<= OUString(
"high-resolution");
501 catch( uno::Exception& )
constexpr OUStringLiteral gsPrinterIndependentLayout(u"PrinterIndependentLayout")
constexpr OUStringLiteral gsBitmapTableURL(u"BitmapTableURL")
constexpr OUStringLiteral gsDashTableURL(u"DashTableURL")
virtual css::uno::Reference< css::uno::XComponentContext > GetComponentContext() const =0
void exportLong(const sal_Int64 nValue, const OUString &rName) const
static void convertDouble(OUStringBuffer &rBuffer, double fNumber, bool bWriteUnits, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit)
void exportDateTime(const css::util::DateTime &aValue, const OUString &rName) const
~XMLSettingsExportHelper()
virtual void EndElement(const bool i_bIgnoreWhitespace)=0
const Reference< XComponentContext > & m_rContext
void exportShort(const sal_Int16 nValue, const OUString &rName) const
void ManipulateSetting(css::uno::Any &rAny, std::u16string_view rName) const
For some settings we may want to change their API representation from their XML settings representati...
static void encode(OUStringBuffer &aStrBuffer, const css::uno::Sequence< sal_Int8 > &aPass)
#define DBG_UNHANDLED_EXCEPTION(...)
void exportInt(const sal_Int32 nValue, const OUString &rName) const
virtual void Characters(const OUString &i_rCharacters)=0
#define DBG_ASSERT(sCon, aError)
void exportbase64Binary(const css::uno::Sequence< sal_Int8 > &aProps, const OUString &rName) const
void exportString(const OUString &sValue, const OUString &rName) const
void exportDouble(const double fValue, const OUString &rName) const
void CallTypeFunction(const css::uno::Any &rAny, const OUString &rName) const
void exportSymbolDescriptors(const css::uno::Sequence< css::formula::SymbolDescriptor > &rProps, const OUString &rName) const
css::uno::Reference< css::util::XStringSubstitution > mxStringSubstitution
void exportNameAccess(const css::uno::Reference< css::container::XNameAccess > &rNamed, const OUString &rName) const
static void convertDateTime(OUStringBuffer &rBuffer, const css::util::DateTime &rDateTime, sal_Int16 const *pTimeZoneOffset, bool bAddTimeIf0AM=false)
void exportAllSettings(const css::uno::Sequence< css::beans::PropertyValue > &aProps, const OUString &rName) const
void exportBool(const bool bValue, const OUString &rName) const
constexpr OUStringLiteral gsLineEndTableURL(u"LineEndTableURL")
void exportSequencePropertyValue(const css::uno::Sequence< css::beans::PropertyValue > &aProps, const OUString &rName) const
#define SAL_WARN_IF(condition, area, stream)
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Handling of tokens in XML:
constexpr OUStringLiteral gsColorTableURL(u"ColorTableURL")
XMLSettingsExportHelper(::xmloff::XMLSettingsExportContext &i_rContext)
constexpr OUStringLiteral gsHatchTableURL(u"HatchTableURL")
::xmloff::XMLSettingsExportContext & m_rContext
virtual void AddAttribute(enum::xmloff::token::XMLTokenEnum i_eName, const OUString &i_rValue)=0
void exportForbiddenCharacters(const css::uno::Any &rAny, const OUString &rName) const
void exportMapEntry(const css::uno::Any &rAny, const OUString &rName, const bool bNameAccess) const
void exportIndexAccess(const css::uno::Reference< css::container::XIndexAccess > &rIndexed, const OUString &rName) const
constexpr OUStringLiteral gsGradientTableURL(u"GradientTableURL")
virtual void StartElement(enum::xmloff::token::XMLTokenEnum i_eName)=0
bool any2bool(const css::uno::Any &rAny)