From e195c22533de44cd4f6afab7836c7eb6a613d202 Mon Sep 17 00:00:00 2001 From: Skyler Grey Date: Fri, 20 Oct 2023 13:07:12 +0000 Subject: Enable STYLEREF flag export/import with OOXML MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit enables exporting the following STYLEREF flags with OOXML - Search from bottom to top - Hide non numerical After this commit, the following steps have been implemented - The document model (I7d8f455ffe90cface4f3b1acf6b9bef6a045ed19) - The layout (I7d8f455ffe90cface4f3b1acf6b9bef6a045ed19) - The UI (I7d8f455ffe90cface4f3b1acf6b9bef6a045ed19) - UNO - DOCX filter Change-Id: Ib664fec059aa1f7f130acc76c253d5d298fa59f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158350 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- offapi/com/sun/star/text/textfield/GetReference.idl | 4 ++++ sw/inc/unoprnms.hxx | 1 + sw/source/core/fields/reffld.cxx | 10 ++++++++++ sw/source/core/inc/unofldmid.h | 2 ++ sw/source/core/unocore/unofield.cxx | 12 +++++++++++- sw/source/core/unocore/unomap.cxx | 1 + sw/source/filter/ww8/ww8atr.cxx | 11 +++++++++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 18 ++++++++++++++++++ writerfilter/source/dmapper/PropertyIds.cxx | 1 + writerfilter/source/dmapper/PropertyIds.hxx | 1 + 10 files changed, 60 insertions(+), 1 deletion(-) diff --git a/offapi/com/sun/star/text/textfield/GetReference.idl b/offapi/com/sun/star/text/textfield/GetReference.idl index 11bfc92b7705..c686b00b23cf 100644 --- a/offapi/com/sun/star/text/textfield/GetReference.idl +++ b/offapi/com/sun/star/text/textfield/GetReference.idl @@ -62,6 +62,10 @@ published service GetReference

*/ [optional, property] string ReferenceFieldLanguage; + /** contains extra flags which can modify the behaviour of the field + @since LibreOffice 24.2 + */ + [optional, property] short ReferenceFieldFlags; }; diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index 1ab2395fa67d..e83b1b601ef4 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -307,6 +307,7 @@ inline constexpr OUString UNO_NAME_PAGE_NUMBER_OFFSET = u"PageNumberOffset"_ustr inline constexpr OUString UNO_NAME_PLACEHOLDER = u"PlaceHolder"_ustr; inline constexpr OUString UNO_NAME_PLACEHOLDER_TYPE = u"PlaceHolderType"_ustr; inline constexpr OUString UNO_NAME_PRINT = u"Print"_ustr; +inline constexpr OUString UNO_NAME_REFERENCE_FIELD_FLAGS = u"ReferenceFieldFlags"_ustr; inline constexpr OUString UNO_NAME_REFERENCE_FIELD_PART = u"ReferenceFieldPart"_ustr; inline constexpr OUString UNO_NAME_REFERENCE_FIELD_SOURCE = u"ReferenceFieldSource"_ustr; inline constexpr OUString UNO_NAME_REFERENCE_FIELD_LANGUAGE = u"ReferenceFieldLanguage"_ustr; diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index 96b9716f7eac..638baf0a5474 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -974,6 +974,9 @@ bool SwGetRefField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const rAny <<= nSource; } break; + case FIELD_PROP_USHORT3: + rAny <<= m_nFlags; + break; case FIELD_PROP_PAR1: { OUString sTmp(GetPar1()); @@ -1076,6 +1079,13 @@ bool SwGetRefField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) case FIELD_PROP_PAR4: rAny >>= m_sSetReferenceLanguage; break; + case FIELD_PROP_USHORT3: + { + sal_uInt16 nSetFlags = 0; + rAny >>= nSetFlags; + m_nFlags = nSetFlags; + } + break; case FIELD_PROP_SHORT1: { sal_Int16 nSetSeq = 0; diff --git a/sw/source/core/inc/unofldmid.h b/sw/source/core/inc/unofldmid.h index 59f4583f3d6f..8c1838f45636 100644 --- a/sw/source/core/inc/unofldmid.h +++ b/sw/source/core/inc/unofldmid.h @@ -51,6 +51,8 @@ #define FIELD_PROP_PAR6 36 #define FIELD_PROP_PAR7 37 +#define FIELD_PROP_USHORT3 38 + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index b5d423e8fd42..74b530ed5a28 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -1043,6 +1043,7 @@ struct SwFieldProperties_Impl sal_Int32 nFormat; sal_uInt16 nUSHORT1; sal_uInt16 nUSHORT2; + sal_uInt16 nUSHORT3; sal_Int16 nSHORT1; sal_Int8 nByte1; bool bFormatIsDefault; @@ -1058,6 +1059,7 @@ struct SwFieldProperties_Impl nFormat(0), nUSHORT1(0), nUSHORT2(0), + nUSHORT3(0), nSHORT1(0), nByte1(0), bFormatIsDefault(true), @@ -1507,6 +1509,8 @@ void SAL_CALL SwXTextField::attach( xField->PutValue(aVal, FIELD_PROP_USHORT1 ); aVal <<= static_cast(m_pImpl->m_pProps->nUSHORT2); xField->PutValue(aVal, FIELD_PROP_USHORT2 ); + aVal <<= static_cast(m_pImpl->m_pProps->nUSHORT3); + xField->PutValue(aVal, FIELD_PROP_USHORT3 ); aVal <<= m_pImpl->m_pProps->nSHORT1; xField->PutValue(aVal, FIELD_PROP_SHORT1 ); } @@ -2250,13 +2254,16 @@ SwXTextField::setPropertyValue( break; case FIELD_PROP_USHORT1: case FIELD_PROP_USHORT2: + case FIELD_PROP_USHORT3: { sal_Int16 nVal = 0; rValue >>= nVal; if( FIELD_PROP_USHORT1 == pEntry->nWID) m_pImpl->m_pProps->nUSHORT1 = nVal; - else + else if( FIELD_PROP_USHORT2 == pEntry->nWID) m_pImpl->m_pProps->nUSHORT2 = nVal; + else + m_pImpl->m_pProps->nUSHORT3 = nVal; } break; case FIELD_PROP_SHORT1: @@ -2456,6 +2463,9 @@ uno::Any SAL_CALL SwXTextField::getPropertyValue(const OUString& rPropertyName) case FIELD_PROP_USHORT2: aRet <<= static_cast(m_pImpl->m_pProps->nUSHORT2); break; + case FIELD_PROP_USHORT3: + aRet <<= static_cast(m_pImpl->m_pProps->nUSHORT3); + break; case FIELD_PROP_SHORT1: aRet <<= m_pImpl->m_pProps->nSHORT1; break; diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx index 5fd4dec86013..3004fb684e9c 100644 --- a/sw/source/core/unocore/unomap.cxx +++ b/sw/source/core/unocore/unomap.cxx @@ -853,6 +853,7 @@ std::span SwUnoPropertyMapProvider::GetPropertyMa {UNO_NAME_CURRENT_PRESENTATION, FIELD_PROP_PAR3, cppu::UnoType::get(), PROPERTY_NONE, 0}, {UNO_NAME_REFERENCE_FIELD_PART,FIELD_PROP_USHORT1, cppu::UnoType::get(), PROPERTY_NONE, 0}, {UNO_NAME_REFERENCE_FIELD_SOURCE,FIELD_PROP_USHORT2, cppu::UnoType::get(), PROPERTY_NONE, 0}, + {UNO_NAME_REFERENCE_FIELD_FLAGS, FIELD_PROP_USHORT3, cppu::UnoType::get(), PROPERTY_NONE, 0}, {UNO_NAME_SEQUENCE_NUMBER, FIELD_PROP_SHORT1, cppu::UnoType::get(), PROPERTY_NONE, 0}, {UNO_NAME_SOURCE_NAME, FIELD_PROP_PAR1, cppu::UnoType::get(), PROPERTY_NONE, 0}, {UNO_NAME_REFERENCE_FIELD_LANGUAGE, FIELD_PROP_PAR4, cppu::UnoType::get(), PROPERTY_NONE, 0}, diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index eda8e17caa53..79446939957e 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -3348,6 +3348,17 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) break; case ww::eSTYLEREF: sExtraFlags = ""; // styleref fields do not work if they have a hyperlink + + { + sal_uInt16 stylerefFlags = static_cast(pField)->GetFlags(); + if ((stylerefFlags & REFFLDFLAG_STYLE_FROM_BOTTOM) == REFFLDFLAG_STYLE_FROM_BOTTOM) { + sExtraFlags += "\\l "; + } + if ((stylerefFlags & REFFLDFLAG_STYLE_HIDE_NON_NUMERICAL) == REFFLDFLAG_STYLE_HIDE_NON_NUMERICAL) { + sExtraFlags += "\\t "; + } + } + [[fallthrough]]; default: switch (pField->GetFormat()) diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index ae121ea2b2d3..ae69b3ba5b89 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -126,6 +126,9 @@ #include #include +#define REFFLDFLAG_STYLE_FROM_BOTTOM 0xc100 +#define REFFLDFLAG_STYLE_HIDE_NON_NUMERICAL 0xc200 + using namespace ::com::sun::star; using namespace oox; namespace writerfilter::dmapper{ @@ -7600,6 +7603,21 @@ void DomainMapper_Impl::CloseFieldCommand() xFieldProperties->setPropertyValue( getPropertyName(PROP_SOURCE_NAME), aStyleDisplayName); + + sal_uInt16 nFlags = 0; + OUString sValue; + if( lcl_FindInCommand( pContext->GetCommand(), 'l', sValue )) + { + //search-below-first + nFlags |= REFFLDFLAG_STYLE_FROM_BOTTOM; + } + if( lcl_FindInCommand( pContext->GetCommand(), 't', sValue )) + { + //suppress-nondelimiter + nFlags |= REFFLDFLAG_STYLE_HIDE_NON_NUMERICAL; + } + xFieldProperties->setPropertyValue( + getPropertyName( PROP_REFERENCE_FIELD_FLAGS ), uno::Any(nFlags) ); } else { diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx index 554f7490c991..be8dd75fc8cf 100644 --- a/writerfilter/source/dmapper/PropertyIds.cxx +++ b/writerfilter/source/dmapper/PropertyIds.cxx @@ -259,6 +259,7 @@ namespace { PROP_TABS_RELATIVE_TO_INDENT, u"TabsRelativeToIndent"}, { PROP_CREATE_FROM_LEVEL_PARAGRAPH_STYLES, u"CreateFromLevelParagraphStyles"}, { PROP_DROP_CAP_FORMAT, u"DropCapFormat"}, + { PROP_REFERENCE_FIELD_FLAGS, u"ReferenceFieldFlags"}, { PROP_REFERENCE_FIELD_PART, u"ReferenceFieldPart"}, { PROP_SOURCE_NAME, u"SourceName"}, { PROP_REFERENCE_FIELD_SOURCE, u"ReferenceFieldSource"}, diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx index 581378af895a..40395cd04d8a 100644 --- a/writerfilter/source/dmapper/PropertyIds.hxx +++ b/writerfilter/source/dmapper/PropertyIds.hxx @@ -267,6 +267,7 @@ enum PropertyIds ,PROP_REDLINE_DATE_TIME ,PROP_REDLINE_TYPE ,PROP_REDLINE_REVERT_PROPERTIES + ,PROP_REFERENCE_FIELD_FLAGS ,PROP_REFERENCE_FIELD_PART ,PROP_REFERENCE_FIELD_SOURCE ,PROP_RESTART_AT_EACH_PAGE -- cgit