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(-)

New commits:
commit ce4c591f3bb9f0a7f97ce73d434991c061d1adb5
Author:     Skyler Grey <[email protected]>
AuthorDate: Fri Oct 20 13:07:12 2023 +0000
Commit:     Miklos Vajna <[email protected]>
CommitDate: Tue Oct 24 08:38:16 2023 +0200

    Enable STYLEREF flag export/import with OOXML
    
    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/+/158261
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

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
         </p>
      */
     [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 9d484371ed5f..31b032c1d59b 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -312,6 +312,7 @@ inline constexpr OUStringLiteral 
UNO_NAME_PAGE_NUMBER_OFFSET = u"PageNumberOffse
 inline constexpr OUStringLiteral UNO_NAME_PLACEHOLDER = u"PlaceHolder";
 inline constexpr OUStringLiteral UNO_NAME_PLACEHOLDER_TYPE = 
u"PlaceHolderType";
 inline constexpr OUStringLiteral UNO_NAME_PRINT = u"Print";
+inline constexpr OUStringLiteral UNO_NAME_REFERENCE_FIELD_FLAGS = 
u"ReferenceFieldFlags";
 inline constexpr OUStringLiteral UNO_NAME_REFERENCE_FIELD_PART = 
u"ReferenceFieldPart";
 inline constexpr OUStringLiteral UNO_NAME_REFERENCE_FIELD_SOURCE = 
u"ReferenceFieldSource";
 inline constexpr OUStringLiteral UNO_NAME_REFERENCE_FIELD_LANGUAGE = 
u"ReferenceFieldLanguage";
diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx
index d7e2e6ff75fd..2720550795ff 100644
--- a/sw/source/core/fields/reffld.cxx
+++ b/sw/source/core/fields/reffld.cxx
@@ -975,6 +975,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());
@@ -1077,6 +1080,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 5e74c3434190..63f614a76216 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -1055,6 +1055,7 @@ struct SwFieldProperties_Impl
     sal_Int32       nFormat;
     sal_uInt16      nUSHORT1;
     sal_uInt16      nUSHORT2;
+    sal_uInt16      nUSHORT3;
     sal_Int16       nSHORT1;
     sal_Int8        nByte1;
     bool            bFormatIsDefault;
@@ -1070,6 +1071,7 @@ struct SwFieldProperties_Impl
         nFormat(0),
         nUSHORT1(0),
         nUSHORT2(0),
+        nUSHORT3(0),
         nSHORT1(0),
         nByte1(0),
         bFormatIsDefault(true),
@@ -1538,6 +1540,8 @@ void SAL_CALL SwXTextField::attach(
                 xField->PutValue(aVal, FIELD_PROP_USHORT1 );
                 aVal <<= static_cast<sal_Int16>(m_pImpl->m_pProps->nUSHORT2);
                 xField->PutValue(aVal, FIELD_PROP_USHORT2 );
+                aVal <<= static_cast<sal_Int16>(m_pImpl->m_pProps->nUSHORT3);
+                xField->PutValue(aVal, FIELD_PROP_USHORT3 );
                 aVal <<= m_pImpl->m_pProps->nSHORT1;
                 xField->PutValue(aVal, FIELD_PROP_SHORT1 );
             }
@@ -2281,13 +2285,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:
@@ -2487,6 +2494,9 @@ uno::Any SAL_CALL SwXTextField::getPropertyValue(const 
OUString& rPropertyName)
             case FIELD_PROP_USHORT2:
                 aRet <<= static_cast<sal_Int16>(m_pImpl->m_pProps->nUSHORT2);
                 break;
+            case FIELD_PROP_USHORT3:
+                aRet <<= static_cast<sal_Int16>(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 d34599a39716..0b10d8b96764 100644
--- a/sw/source/core/unocore/unomap.cxx
+++ b/sw/source/core/unocore/unomap.cxx
@@ -852,6 +852,7 @@ o3tl::span<const SfxItemPropertyMapEntry> 
SwUnoPropertyMapProvider::GetPropertyM
                     {UNO_NAME_CURRENT_PRESENTATION, FIELD_PROP_PAR3, 
cppu::UnoType<OUString>::get(),  PROPERTY_NONE, 0},
                     {UNO_NAME_REFERENCE_FIELD_PART,FIELD_PROP_USHORT1, 
cppu::UnoType<sal_Int16>::get(),  PROPERTY_NONE,  0},
                     {UNO_NAME_REFERENCE_FIELD_SOURCE,FIELD_PROP_USHORT2, 
cppu::UnoType<sal_Int16>::get(),    PROPERTY_NONE,  0},
+                    {UNO_NAME_REFERENCE_FIELD_FLAGS, FIELD_PROP_USHORT3, 
cppu::UnoType<sal_uInt16>::get(),  PROPERTY_NONE,  0},
                     {UNO_NAME_SEQUENCE_NUMBER,    FIELD_PROP_SHORT1,  
cppu::UnoType<sal_Int16>::get(),   PROPERTY_NONE, 0},
                     {UNO_NAME_SOURCE_NAME,        FIELD_PROP_PAR1,    
cppu::UnoType<OUString>::get(),   PROPERTY_NONE, 0},
                     {UNO_NAME_REFERENCE_FIELD_LANGUAGE, FIELD_PROP_PAR4, 
cppu::UnoType<OUString>::get(),  PROPERTY_NONE, 0},
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 0258ae7f303f..62ae243168ec 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -3322,6 +3322,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 = 
((SwGetRefField*)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 144c1fa0fc83..d3e77b15a42c 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -126,6 +126,9 @@
 #include <unicode/errorcode.h>
 #include <unicode/regex.h>
 
+#define REFFLDFLAG_STYLE_FROM_BOTTOM 0xc100
+#define REFFLDFLAG_STYLE_HIDE_NON_NUMERICAL 0xc200
+
 using namespace ::com::sun::star;
 using namespace oox;
 namespace writerfilter::dmapper{
@@ -7419,6 +7422,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 551de3b27676..4f3671b4e164 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -255,6 +255,7 @@ const OUString & getPropertyName( PropertyIds eId )
         { 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 c35975cfcc6c..00e75d684d6b 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -266,6 +266,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

Reply via email to