26#include <rtl/ustring.hxx>
27#include <rtl/string.hxx>
28#include <com/sun/star/beans/XPropertySet.hpp>
29#include <com/sun/star/frame/XModel.hpp>
30#include <com/sun/star/lang/XMultiServiceFactory.hpp>
31#include <com/sun/star/text/XTextField.hpp>
75 xIface =
xFactory->createInstance(
"com.sun.star.text.TextField.Custom" );
76 aFields.emplace_back( xIface, UNO_QUERY );
81 if (eDateFormat != SvxDateFormat::AppDefault)
83 xIface =
xFactory->createInstance(
"com.sun.star.text.TextField.DateTime" );
84 aFields.emplace_back( xIface, UNO_QUERY );
85 Reference< XPropertySet > xProps( xIface, UNO_QUERY_THROW );
86 xProps->setPropertyValue(
"NumberFormat",
Any(
static_cast<sal_Int32
>(eDateFormat)));
87 xProps->setPropertyValue(
"IsDate",
Any(
true));
88 xProps->setPropertyValue(
"IsFixed",
Any(
false));
92 if (eTimeFormat != SvxTimeFormat::AppDefault)
94 xIface =
xFactory->createInstance(
"com.sun.star.text.TextField.DateTime" );
95 aFields.emplace_back( xIface, UNO_QUERY );
96 Reference< XPropertySet > xProps( xIface, UNO_QUERY_THROW );
97 xProps->setPropertyValue(
"NumberFormat",
Any(
static_cast<sal_Int32
>(eTimeFormat)));
98 xProps->setPropertyValue(
"IsDate",
Any(
false));
99 xProps->setPropertyValue(
"IsFixed",
Any(
false));
102 catch(
const Exception &)
107 else if ( sType == u
"slidenum" )
109 xIface =
xFactory->createInstance(
"com.sun.star.text.TextField.PageNumber" );
110 aFields.emplace_back( xIface, UNO_QUERY );
112 else if ( sType == u
"slidecount" )
114 xIface =
xFactory->createInstance(
"com.sun.star.text.TextField.PageCount" );
115 aFields.emplace_back( xIface, UNO_QUERY );
117 else if ( sType == u
"slidename" )
119 xIface =
xFactory->createInstance(
"com.sun.star.text.TextField.PageName" );
120 aFields.emplace_back( xIface, uno::UNO_QUERY );
125 xIface =
xFactory->createInstance(
"com.sun.star.text.TextField.FileName" );
126 aFields.emplace_back( xIface, UNO_QUERY );
127 Reference< XPropertySet > xProps( xIface, UNO_QUERY_THROW );
132 xProps->setPropertyValue(
"FileFormat",
Any(sal_Int16(1)));
135 xProps->setPropertyValue(
"FileFormat",
Any(sal_Int16(2)));
138 xProps->setPropertyValue(
"FileFormat",
Any(sal_Int16(3)));
141 xProps->setPropertyValue(
"FileFormat",
Any(sal_Int16(0)));
144 else if( sType == u
"author" )
146 xIface =
xFactory->createInstance(
"com.sun.star.text.TextField.Author" );
147 aFields.emplace_back( xIface, UNO_QUERY );
154 const ::oox::core::XmlFilterBase& rFilterBase,
160 sal_Int32 nCharHeight = 0;
172 if ( aTextCharacterProps.
moHeight.has_value() )
173 nCharHeight = aTextCharacterProps.
moHeight.value();
176 std::vector< Reference< XTextField > > fields;
177 lclCreateTextFields( fields, rFilterBase.getModel(),
msType );
178 if( !fields.empty() )
181 for (
auto const& field : fields)
192 xText->insertString( xAt,
" ",
false );
194 xText->insertTextContent( xAt, xContent,
false );
200 xText->insertString( xAt,
getText(),
false );
213 auto aDateTimeNum = rDateTimeType.substr(8);
215 if( aDateTimeNum.empty() )
216 return SvxDateFormat::StdSmall;
220 switch( nDateTimeNum )
225 return SvxDateFormat::B;
227 return SvxDateFormat::StdBig;
231 return SvxDateFormat::D;
234 return SvxDateFormat::C;
240 return SvxDateFormat::AppDefault;
246 auto aDateTimeNum = rDateTimeType.substr(8);
249 switch( nDateTimeNum )
253 return SvxTimeFormat::HH12_MM;
256 return SvxTimeFormat::HH12_MM_SS;
258 return SvxTimeFormat::HH24_MM;
260 return SvxTimeFormat::Standard;
269 return SvxTimeFormat::AppDefault;
A helper that maps property identifiers to property values.
A wrapper for a UNO property set.
TextParagraphProperties maTextParagraphProperties
static SvxDateFormat getLODateFormat(std::u16string_view rDateTimeType)
Gets the corresponding LO Date format for given OOXML datetime field type.
virtual sal_Int32 insertAt(const ::oox::core::XmlFilterBase &rFilterBase, const css::uno::Reference< css::text::XText > &xText, const css::uno::Reference< css::text::XTextCursor > &xAt, const TextCharacterProperties &rTextCharacterStyle, float nDefaultCharHeight) const override
static SvxTimeFormat getLOTimeFormat(std::u16string_view rDateTimeType)
Gets the corresponding LO Time format for given OOXML datetime field type.
TextCharacterProperties & getTextCharacterProperties()
void pushToPropSet(const ::oox::core::XmlFilterBase *pFilterBase, const css::uno::Reference< css::beans::XPropertySet > &xPropSet, PropertyMap &rioBulletList, const BulletList *pMasterBuList, bool bApplyBulletList, float fFontSize, bool bPushDefaultValues=false) const
TextCharacterProperties & getTextCharacterProperties()
#define TOOLS_WARN_EXCEPTION(area, stream)
Reference< XSingleServiceFactory > xFactory
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
void pushToPropSet(PropertySet &rPropSet, const ::oox::core::XmlFilterBase &rFilter) const
Writes the properties to the passed property set.
void assignUsed(const TextCharacterProperties &rSourceProps)
Overwrites all members that are explicitly set in rSourceProps.
std::optional< sal_Int32 > moHeight