24#include <com/sun/star/util/DateTime.hpp> 
   25#include <com/sun/star/text/FilenameDisplayFormat.hpp> 
   44using namespace ::
cppu;
 
   47#define QUERYINT( xint ) \ 
   48    if( rType == cppu::UnoType<xint>::get() ) \ 
   49        aAny <<= uno::Reference< xint >(this) 
   85    static const SfxItemPropertySet aExDateTimeFieldPropertySet_Impl(aExDateTimeFieldPropertyMap_Impl);
 
   91    static const SfxItemPropertySet aDateTimeFieldPropertySet_Impl(aDateTimeFieldPropertyMap_Impl);
 
  110    static const SfxItemPropertySet aExtFileFieldPropertySet_Impl(aExtFileFieldPropertyMap_Impl);
 
  120    static const SfxItemPropertySet aAuthorFieldPropertySet_Impl(aAuthorFieldPropertyMap_Impl);
 
  126    static const SfxItemPropertySet aMeasureFieldPropertySet_Impl(aMeasureFieldPropertyMap_Impl);
 
  136    static const SfxItemPropertySet aDocInfoCustomFieldPropertySet_Impl(aDocInfoCustomFieldPropertyMap_Impl);
 
  140    case text::textfield::Type::EXTENDED_TIME:
 
  141    case text::textfield::Type::DATE:
 
  142        return &aExDateTimeFieldPropertySet_Impl;
 
  143    case text::textfield::Type::URL:
 
  144        return &aUrlFieldPropertySet_Impl;
 
  145    case text::textfield::Type::TIME:
 
  146        return &aDateTimeFieldPropertySet_Impl;
 
  147    case text::textfield::Type::EXTENDED_FILE:
 
  148        return &aExtFileFieldPropertySet_Impl;
 
  149    case text::textfield::Type::AUTHOR:
 
  150        return &aAuthorFieldPropertySet_Impl;
 
  151    case text::textfield::Type::MEASURE:
 
  152        return &aMeasureFieldPropertySet_Impl;
 
  153    case text::textfield::Type::DOCINFO_CUSTOM:
 
  154        return &aDocInfoCustomFieldPropertySet_Impl;
 
  156        return &aEmptyPropertySet_Impl;
 
  187static util::DateTime 
getDate( sal_Int32 nDate )
 
  189    util::DateTime aDate;
 
  191    Date aTempDate( nDate );
 
  193    aDate.Day = aTempDate.
GetDay();
 
  195    aDate.Year = aTempDate.
GetYear();
 
  202    return Date( rDate.Day, rDate.Month, rDate.Year );
 
  205static util::DateTime 
getTime(sal_Int64 
const nTime)
 
  207    util::DateTime aTime;
 
  212    aTime.Seconds = aTempTime.
GetSec();
 
  213    aTime.Minutes = aTempTime.
GetMin();
 
  214    aTime.Hours = aTempTime.
GetHour();
 
  227:   OComponentHelper( m_aMutex )
 
  229,   mnServiceId(nServiceId)
 
  234    mpImpl->maDateTime.NanoSeconds = 0;
 
  235    mpImpl->maDateTime.Seconds = 0;
 
  236    mpImpl->maDateTime.Minutes = 0;
 
  237    mpImpl->maDateTime.Hours = 0;
 
  238    mpImpl->maDateTime.Day = 0;
 
  239    mpImpl->maDateTime.Month = 0;
 
  240    mpImpl->maDateTime.Year = 0;
 
  241    mpImpl->maDateTime.IsUTC = 
false;
 
  245    case text::textfield::Type::DATE:
 
  246        mpImpl->mbBoolean2 = 
true;
 
  248        mpImpl->mbBoolean1 = 
false;
 
  251    case text::textfield::Type::EXTENDED_TIME:
 
  252    case text::textfield::Type::TIME:
 
  253        mpImpl->mbBoolean2 = 
false;
 
  254        mpImpl->mbBoolean1 = 
false;
 
  258    case text::textfield::Type::URL:
 
  262    case text::textfield::Type::EXTENDED_FILE:
 
  263        mpImpl->mbBoolean1 = 
false;
 
  264        mpImpl->mnInt16 = text::FilenameDisplayFormat::FULL;
 
  267    case text::textfield::Type::AUTHOR:
 
  269        mpImpl->mbBoolean1 = 
false;
 
  270        mpImpl->mbBoolean2 = 
true;
 
  273    case text::textfield::Type::MEASURE:
 
  277    case text::textfield::Type::DOCINFO_CUSTOM:
 
  278        mpImpl->mbBoolean1 = 
true;
 
  279        mpImpl->mbBoolean2 = 
true;
 
  284        mpImpl->mbBoolean1 = 
false;
 
  285        mpImpl->mbBoolean2 = 
false;
 
  293:   OComponentHelper( m_aMutex )
 
  294,   mxAnchor(std::move( xAnchor ))
 
  296,   mnServiceId(text::textfield::Type::UNSPECIFIED)
 
  299    DBG_ASSERT(pData, 
"pFieldData == NULL! [CL]" );
 
  301    mpImpl->msPresentation = rPresentation;
 
  305        mnServiceId = 
pData->GetClassId();
 
  306        DBG_ASSERT(mnServiceId != text::textfield::Type::UNSPECIFIED, 
"unknown SvxFieldData! [CL]");
 
  307        if (mnServiceId != text::textfield::Type::UNSPECIFIED)
 
  310            switch( mnServiceId )
 
  312            case text::textfield::Type::DATE:
 
  314                    mpImpl->mbBoolean2 = 
true;
 
  318                    mpImpl->maDateTime = 
getDate( bFixed ?
 
  322                    mpImpl->mbBoolean1 = bFixed;
 
  326            case text::textfield::Type::TIME:
 
  327                mpImpl->mbBoolean2 = 
false;
 
  328                mpImpl->mbBoolean1 = 
false;
 
  332            case text::textfield::Type::EXTENDED_TIME:
 
  333                mpImpl->mbBoolean2 = 
false;
 
  339            case text::textfield::Type::URL:
 
  340                mpImpl->msString1 = 
static_cast<const SvxURLField*
>(
pData)->GetRepresentation();
 
  341                mpImpl->msString2 = 
static_cast<const SvxURLField*
>(
pData)->GetTargetFrame();
 
  343                mpImpl->mnInt16 = sal::static_int_cast< sal_Int16 >(
 
  347            case text::textfield::Type::EXTENDED_FILE:
 
  353            case text::textfield::Type::AUTHOR:
 
  356                mpImpl->mnInt16    = sal::static_int_cast< sal_Int16 >(
 
  362            case text::textfield::Type::MEASURE:
 
  363                mpImpl->mnInt16     = sal::static_int_cast< sal_Int16 >(
static_cast<const SdrMeasureField*
>(pData)->GetMeasureFieldKind());
 
  366            case text::textfield::Type::DOCINFO_CUSTOM:
 
  369                mpImpl->mbBoolean1 = 
false;
 
  370                mpImpl->mbBoolean2 = 
false;
 
  375                SAL_WARN(
"editeng", 
"Id service unknown: " << mnServiceId);
 
  390    std::unique_ptr<SvxFieldData> 
pData;
 
  394    case text::textfield::Type::TIME:
 
  395    case text::textfield::Type::EXTENDED_TIME:
 
  396    case text::textfield::Type::DATE:
 
  426    case text::textfield::Type::URL:
 
  434    case text::textfield::Type::PAGE:
 
  438    case text::textfield::Type::PAGES:
 
  442    case text::textfield::Type::DOCINFO_TITLE:
 
  446    case text::textfield::Type::TABLE:
 
  450    case text::textfield::Type::EXTENDED_FILE:
 
  459    case text::textfield::Type::AUTHOR:
 
  469        if( !
mpImpl->msString1.isEmpty() )
 
  470            aContent = 
mpImpl->msString1;
 
  472            aContent = 
mpImpl->msString2;
 
  474        sal_Int32 
nPos = aContent.lastIndexOf( 
' ', 0 );
 
  477            aFirstName = aContent.copy( 0, 
nPos );
 
  478            aLastName = aContent.copy( 
nPos + 1 );
 
  482            aLastName = aContent;
 
  502    case text::textfield::Type::MEASURE:
 
  510    case text::textfield::Type::PRESENTATION_HEADER:
 
  513    case text::textfield::Type::PRESENTATION_FOOTER:
 
  516    case text::textfield::Type::PRESENTATION_DATE_TIME:
 
  519    case text::textfield::Type::PAGE_NAME:
 
  522    case text::textfield::Type::DOCINFO_CUSTOM:
 
  536    else QUERYINT( text::XTextContent );
 
  538    else QUERYINT( lang::XServiceInfo );
 
  540        return OComponentHelper::queryAggregation( rType );
 
  552            OComponentHelper::getTypes(),
 
  564    return css::uno::Sequence<sal_Int8>();
 
  569    return OComponentHelper::queryInterface(rType);
 
  574    OComponentHelper::acquire();
 
  579    OComponentHelper::release();
 
  590            case text::textfield::Type::DATE:
 
  592            case text::textfield::Type::URL:
 
  594            case text::textfield::Type::PAGE:
 
  596            case text::textfield::Type::PAGES:
 
  598            case text::textfield::Type::TIME:
 
  600            case text::textfield::Type::DOCINFO_TITLE:
 
  602            case text::textfield::Type::TABLE:
 
  604            case text::textfield::Type::EXTENDED_TIME:
 
  606            case text::textfield::Type::EXTENDED_FILE:
 
  608            case text::textfield::Type::AUTHOR:
 
  610            case text::textfield::Type::MEASURE:
 
  612            case text::textfield::Type::PRESENTATION_HEADER:
 
  614            case text::textfield::Type::PRESENTATION_FOOTER:
 
  616            case text::textfield::Type::PRESENTATION_DATE_TIME:
 
  618            case text::textfield::Type::PAGE_NAME:
 
  620            case text::textfield::Type::DOCINFO_CUSTOM:
 
  628        return mpImpl->msPresentation;
 
  635    SvxUnoTextRangeBase* pRange = comphelper::getFromUnoTunnel<SvxUnoTextRange>( xTextRange );
 
  636    if(pRange == 
nullptr)
 
  637        throw lang::IllegalArgumentException();
 
  641        pRange->attachField( std::move(
pData) );
 
  652    OComponentHelper::dispose();
 
  657    OComponentHelper::addEventListener(xListener);
 
  662    OComponentHelper::removeEventListener(aListener);
 
  678        throw uno::RuntimeException();
 
  688        throw beans::UnknownPropertyException(aPropertyName);
 
  693        if(aValue >>= 
mpImpl->maDateTime)
 
  697        if(aValue >>= 
mpImpl->mbBoolean1)
 
  701        if(aValue >>= 
mpImpl->mbBoolean2)
 
  705        if(aValue >>= 
mpImpl->mnInt16)
 
  709        if(aValue >>= 
mpImpl->mnInt32)
 
  713        if(aValue >>= 
mpImpl->msString1)
 
  717        if(aValue >>= 
mpImpl->msString2)
 
  721        if(aValue >>= 
mpImpl->msString3)
 
  726    throw lang::IllegalArgumentException();
 
  743        throw beans::UnknownPropertyException(PropertyName);
 
  748        aValue <<= 
mpImpl->maDateTime;
 
  751        aValue <<= 
mpImpl->mbBoolean1;
 
  754        aValue <<= 
mpImpl->mbBoolean2;
 
  757        aValue <<= 
mpImpl->mnInt16;
 
  760        aValue <<= 
mpImpl->mnInt32;
 
  763        aValue <<= 
mpImpl->msString1;
 
  766        aValue <<= 
mpImpl->msString2;
 
  769        aValue <<= 
mpImpl->msString3;
 
  790    return "SvxUnoTextField";
 
  795    uno::Sequence<OUString> 
aSeq(4);
 
  796    OUString* pServices = 
aSeq.getArray();
 
  797    pServices[0] = 
"com.sun.star.text.TextContent";
 
  798    pServices[1] = 
"com.sun.star.text.TextField";
 
  802        case text::textfield::Type::DATE:
 
  803            pServices[2] = 
"com.sun.star.text.TextField.DateTime";
 
  804            pServices[3] = 
"com.sun.star.text.textfield.DateTime";
 
  806        case text::textfield::Type::URL:
 
  807            pServices[2] = 
"com.sun.star.text.TextField.URL";
 
  808            pServices[3] = 
"com.sun.star.text.textfield.URL";
 
  810        case text::textfield::Type::PAGE:
 
  811            pServices[2] = 
"com.sun.star.text.TextField.PageNumber";
 
  812            pServices[3] = 
"com.sun.star.text.textfield.PageNumber";
 
  814        case text::textfield::Type::PAGES:
 
  815            pServices[2] = 
"com.sun.star.text.TextField.PageCount";
 
  816            pServices[3] = 
"com.sun.star.text.textfield.PageCount";
 
  818        case text::textfield::Type::TIME:
 
  819            pServices[2] = 
"com.sun.star.text.TextField.DateTime";
 
  820            pServices[3] = 
"com.sun.star.text.textfield.DateTime";
 
  822        case text::textfield::Type::DOCINFO_TITLE:
 
  823            pServices[2] = 
"com.sun.star.text.TextField.docinfo.Title";
 
  824            pServices[3] = 
"com.sun.star.text.textfield.docinfo.Title";
 
  826        case text::textfield::Type::TABLE:
 
  827            pServices[2] = 
"com.sun.star.text.TextField.SheetName";
 
  828            pServices[3] = 
"com.sun.star.text.textfield.SheetName";
 
  830        case text::textfield::Type::EXTENDED_TIME:
 
  831            pServices[2] = 
"com.sun.star.text.TextField.DateTime";
 
  832            pServices[3] = 
"com.sun.star.text.textfield.DateTime";
 
  834        case text::textfield::Type::EXTENDED_FILE:
 
  835            pServices[2] = 
"com.sun.star.text.TextField.FileName";
 
  836            pServices[3] = 
"com.sun.star.text.textfield.FileName";
 
  838        case text::textfield::Type::AUTHOR:
 
  839            pServices[2] = 
"com.sun.star.text.TextField.Author";
 
  840            pServices[3] = 
"com.sun.star.text.textfield.Author";
 
  842        case text::textfield::Type::MEASURE:
 
  843            pServices[2] = 
"com.sun.star.text.TextField.Measure";
 
  844            pServices[3] = 
"com.sun.star.text.textfield.Measure";
 
  846        case text::textfield::Type::PRESENTATION_HEADER:
 
  847            pServices[2] = 
"com.sun.star.presentation.TextField.Header";
 
  848            pServices[3] = 
"com.sun.star.presentation.textfield.Header";
 
  850        case text::textfield::Type::PRESENTATION_FOOTER:
 
  851            pServices[2] = 
"com.sun.star.presentation.TextField.Footer";
 
  852            pServices[3] = 
"com.sun.star.presentation.textfield.Footer";
 
  854        case text::textfield::Type::PRESENTATION_DATE_TIME:
 
  855            pServices[2] = 
"com.sun.star.presentation.TextField.DateTime";
 
  856            pServices[3] = 
"com.sun.star.presentation.textfield.DateTime";
 
  858        case text::textfield::Type::PAGE_NAME:
 
  859            pServices[2] = 
"com.sun.star.text.TextField.PageName";
 
  860            pServices[3] = 
"com.sun.star.text.textfield.PageName";
 
  862        case text::textfield::Type::DOCINFO_CUSTOM:
 
  863            pServices[2] = 
"com.sun.star.text.TextField.DocInfo.Custom";
 
  864            pServices[3] = 
"com.sun.star.text.textfield.DocInfo.Custom";
 
  880    uno::Reference< uno::XInterface > xRet;
 
  885    std::u16string_view aFieldType;
 
  886    if( (
o3tl::starts_with( ServiceSpecifier, 
u"com.sun.star.text.textfield.", &aFieldType )) ||
 
  887        (
o3tl::starts_with( ServiceSpecifier, 
u"com.sun.star.text.TextField.", &aFieldType )) )
 
  889        sal_Int32 
nId = text::textfield::Type::UNSPECIFIED;
 
  891        if ( aFieldType == 
u"DateTime" )
 
  893            nId = text::textfield::Type::DATE;
 
  895        else if ( aFieldType == 
u"URL" )
 
  897            nId = text::textfield::Type::URL;
 
  899        else if ( aFieldType == 
u"PageNumber" )
 
  901            nId = text::textfield::Type::PAGE;
 
  903        else if ( aFieldType == 
u"PageCount" )
 
  905            nId = text::textfield::Type::PAGES;
 
  907        else if ( aFieldType == 
u"SheetName" )
 
  909            nId = text::textfield::Type::TABLE;
 
  911        else if ( aFieldType == 
u"FileName" )
 
  913            nId = text::textfield::Type::EXTENDED_FILE;
 
  915        else if (aFieldType == 
u"docinfo.Title" ||
 
  916                 aFieldType == 
u"DocInfo.Title" )
 
  918            nId = text::textfield::Type::DOCINFO_TITLE;
 
  920        else if ( aFieldType == 
u"Author" )
 
  922            nId = text::textfield::Type::AUTHOR;
 
  924        else if ( aFieldType == 
u"Measure" )
 
  926            nId = text::textfield::Type::MEASURE;
 
  928        else if (aFieldType == 
u"DocInfo.Custom")
 
  930            nId = text::textfield::Type::DOCINFO_CUSTOM;
 
  933        if (
nId != text::textfield::Type::UNSPECIFIED)
 
sal_Int16 GetYear() const
 
sal_uInt16 GetDay() const
 
sal_uInt16 GetMonth() const
 
const SfxItemPropertyMapEntry * getByName(std::u16string_view rName) const
 
const SfxItemPropertyMap & getPropertyMap() const
 
css::uno::Reference< css::beans::XPropertySetInfo > const & getPropertySetInfo() const
 
this field is used as a placeholder for a header&footer in impress.
 
util::DateTime maDateTime
 
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
 
virtual void SAL_CALL disposing() override
 
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
 
std::unique_ptr< SvxUnoFieldData_Impl > mpImpl
 
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
 
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
 
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
 
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
 
virtual ~SvxUnoTextField() noexcept override
 
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
 
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
 
virtual void SAL_CALL release() noexcept override
 
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
 
std::unique_ptr< SvxFieldData > CreateFieldData() const noexcept
 
css::uno::Sequence< css::uno::Type > maTypeSequence
 
virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) override
 
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
 
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
 
SvxUnoTextField(sal_Int32 nServiceId) noexcept
 
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
 
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
 
virtual void SAL_CALL acquire() noexcept override
 
virtual OUString SAL_CALL getImplementationName() override
 
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &rType) override
 
css::uno::Reference< css::text::XTextRange > mxAnchor
 
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
 
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
 
virtual void SAL_CALL dispose() override
 
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
 
const SfxItemPropertySet * mpPropSet
 
css::uno::Type const & get()
 
#define DBG_ASSERT(sCon, aError)
 
virtual OUString GetName() const override
 
virtual OUString GetURL() const override
 
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
 
Sequence< sal_Int8 > aSeq
 
#define SAL_WARN(area, stream)
 
std::unique_ptr< sal_Int32[]> pData
 
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &... rSn)
 
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
 
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
 
static tools::Time setTime(util::DateTime const &rDate)
 
static util::DateTime getDate(sal_Int32 nDate)
 
static Date setDate(util::DateTime const &rDate)
 
uno::Reference< uno::XInterface > SvxUnoTextCreateTextField(std::u16string_view ServiceSpecifier)
 
static SvxFileFormat setFileNameDisplayFormat(sal_Int16 nFormat)
 
static sal_Int16 getFileNameDisplayFormat(SvxFileFormat nFormat)
 
static const SfxItemPropertySet * ImplGetFieldItemPropertySet(sal_Int32 mnId)
 
static util::DateTime getTime(sal_Int64 const nTime)
 
constexpr OUStringLiteral UNO_TC_PROP_NUMFORMAT
 
constexpr OUStringLiteral UNO_TC_PROP_AUTHOR_CONTENT
 
constexpr OUStringLiteral UNO_TC_PROP_DATE_TIME
 
constexpr OUStringLiteral UNO_TC_PROP_ANCHOR
 
constexpr OUStringLiteral UNO_TC_PROP_AUTHOR_FORMAT
 
constexpr OUStringLiteral UNO_TC_PROP_URL
 
constexpr OUStringLiteral UNO_TC_PROP_FILE_FORMAT
 
constexpr OUStringLiteral UNO_TC_PROP_IS_DATE
 
constexpr OUStringLiteral UNO_TC_PROP_IS_FIXED_LANGUAGE
 
constexpr OUStringLiteral UNO_TC_PROP_IS_FIXED
 
constexpr OUStringLiteral UNO_TC_PROP_URL_REPRESENTATION
 
constexpr OUStringLiteral UNO_TC_PROP_TEXTFIELD_TYPE
 
constexpr OUStringLiteral UNO_TC_PROP_URL_FORMAT
 
constexpr OUStringLiteral UNO_TC_PROP_CURRENT_PRESENTATION
 
constexpr OUStringLiteral UNO_TC_PROP_AUTHOR_FULLNAME
 
constexpr OUStringLiteral UNO_TC_PROP_NAME
 
constexpr OUStringLiteral UNO_TC_PROP_MEASURE_KIND
 
constexpr OUStringLiteral UNO_TC_PROP_URL_TARGET