related tdf#79186 filter: value is more than just LayoutInCell

nGroupShapeBooleanProperties contains 16 shape properties
and 16 flags to indicate whether they are to be used or not.
Up till now, only fLayoutInCell has been used by LO,
but it handles far more than that, so lets change the code
(now that we have the documentation for it)
to make it clear that this could be useful for further
compatibility fixes.

There is no need to determine whether the setting
has been provided or not - since a zero default indicates
everything in this bit-set should be ignored.

The naming and the if clause in ww8graf.cxx suggests that
reverse engineering didn't really grasp how this worked,
so I took the liberty of removing all of that awkwardness,
and verified that at least several associated document
from the OOo Apache bugtracker still worked.

===============================================================
https://docs.microsoft.com/en-us/openspecs/office_file_formats
/ms-odraw/a0ae6aa5-16e4-4550-87a2-b8ca180c7fd7

fLayoutInCell (1 bit): A bit that specifies whether this shape
is displayed inside a table cell. If fUsefLayoutInCell equals 0x0,
this value MUST be ignored.
The default value for this property is 0x1.

Change-Id: I82f80123a7419a83737b796f253406576732b6c7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129657
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 8832617..a0ecad0 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -5158,7 +5158,7 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
                    case 0x0392:
                        pImpRec->nYRelTo = nUDData;
                        break;
                    case 0x03BF: pImpRec->nLayoutInTableCell = nUDData; break;
                    case 0x03BF: pImpRec->nGroupShapeBooleanProperties = nUDData; break;
                    case 0x0393:
                    // This seems to correspond to o:hrpct from .docx (even including
                    // the difference that it's in 0.1% even though the .docx spec
@@ -7413,7 +7413,7 @@ SvxMSDffImportRec::SvxMSDffImportRec()
      nClientDataLen(    0 ),
      nXAlign( 0 ), // position n cm from left
      nYAlign( 0 ), // position n cm below
      nLayoutInTableCell( 0 ), // element is laid out in table cell
      nGroupShapeBooleanProperties(0), // 16 settings: LayoutInCell/AllowOverlap/BehindDocument...
      nFlags( ShapeFlag::NONE ),
      nDxTextLeft( 144 ),
      nDyTextTop( 72 ),
@@ -7450,7 +7450,7 @@ SvxMSDffImportRec::SvxMSDffImportRec(const SvxMSDffImportRec& rCopy)
      nXRelTo( rCopy.nXRelTo ),
      nYAlign( rCopy.nYAlign ),
      nYRelTo( rCopy.nYRelTo ),
      nLayoutInTableCell( rCopy.nLayoutInTableCell ),
      nGroupShapeBooleanProperties(rCopy.nGroupShapeBooleanProperties),
      nFlags( rCopy.nFlags ),
      nDxTextLeft( rCopy.nDxTextLeft    ),
      nDyTextTop( rCopy.nDyTextTop ),
diff --git a/include/filter/msfilter/msdffimp.hxx b/include/filter/msfilter/msdffimp.hxx
index 581d558..f56738e 100644
--- a/include/filter/msfilter/msdffimp.hxx
+++ b/include/filter/msfilter/msdffimp.hxx
@@ -228,7 +228,7 @@ struct MSFILTER_DLLPUBLIC SvxMSDffImportRec
    std::optional<sal_uInt32> nXRelTo;
    sal_uInt32      nYAlign;
    std::optional<sal_uInt32> nYRelTo;
    sal_uInt32      nLayoutInTableCell;
    sal_uInt32      nGroupShapeBooleanProperties;
    ShapeFlag       nFlags;
    sal_Int32       nDxTextLeft;    ///< distance of text box from surrounding shape
    sal_Int32       nDyTextTop;
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index 113016d..3cb0aeb 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -2402,7 +2402,7 @@ RndStdIds SwWW8ImplReader::ProcessEscherAlign(SvxMSDffImportRec& rRecord, WW8_FS
    if (m_nInTable &&
            (eHoriRel == text::RelOrientation::FRAME || eHoriRel == text::RelOrientation::CHAR) &&
            rFSPA.nwr == 3 &&
            !IsObjectLayoutInTableCell(rRecord.nLayoutInTableCell))
            !IsObjectLayoutInTableCell(rRecord.nGroupShapeBooleanProperties))
    {
        eHoriRel = text::RelOrientation::PAGE_PRINT_AREA;
    }
@@ -2452,7 +2452,7 @@ RndStdIds SwWW8ImplReader::ProcessEscherAlign(SvxMSDffImportRec& rRecord, WW8_FS
}

// #i84783#
bool SwWW8ImplReader::IsObjectLayoutInTableCell( const sal_uInt32 nLayoutInTableCell ) const
bool SwWW8ImplReader::IsObjectLayoutInTableCell(const sal_uInt32 nGroupShapeBooleanProperties) const
{
    bool bIsObjectLayoutInTableCell = false;

@@ -2474,7 +2474,7 @@ bool SwWW8ImplReader::IsObjectLayoutInTableCell( const sal_uInt32 nLayoutInTable
            case 0x0000: // version 8 aka Microsoft Word 97
            {
                bIsObjectLayoutInTableCell = false;
                OSL_ENSURE( nLayoutInTableCell == 0xFFFFFFFF,
                OSL_ENSURE(nGroupShapeBooleanProperties == 0,
                        "no explicit object attribute layout in table cell expected." );
            }
            break;
@@ -2485,23 +2485,11 @@ bool SwWW8ImplReader::IsObjectLayoutInTableCell( const sal_uInt32 nLayoutInTable
            case 0xC000: // version 14 aka Microsoft Word 2010
            case 0xE000: // version 15 aka Microsoft Word 2013
            {
                // #i98037#
                // adjustment of conditions needed after deeper analysis of
                // certain test cases.
                if ( nLayoutInTableCell == 0xFFFFFFFF || // no explicit attribute value given
                     nLayoutInTableCell == 0x80008000 ||
                     ( nLayoutInTableCell & 0x02000000 &&
                       !(nLayoutInTableCell & 0x80000000 ) ) )
                {
                    bIsObjectLayoutInTableCell = true;
                }
                else
                {
                    // Documented in [MS-ODRAW], 2.3.4.44 "Group Shape Boolean Properties".
                    bool fUsefLayoutInCell = (nLayoutInTableCell & 0x80000000) >> 31;
                    bool fLayoutInCell = (nLayoutInTableCell & 0x8000) >> 15;
                    bIsObjectLayoutInTableCell = fUsefLayoutInCell && fLayoutInCell;
                }
                // Documented in [MS-ODRAW], 2.3.4.44 "Group Shape Boolean Properties".
                bool fUsefLayoutInCell = (nGroupShapeBooleanProperties & 0x80000000) >> 31;
                bool fLayoutInCell = (nGroupShapeBooleanProperties & 0x8000) >> 15;
                // If unspecified, defaults to true
                bIsObjectLayoutInTableCell = !fUsefLayoutInCell || fLayoutInCell;
            }
            break;
            default:
@@ -2696,7 +2684,7 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( tools::Long nGrafAnchorCp )
        return nullptr;
    }
    const bool bLayoutInTableCell =
        m_nInTable && IsObjectLayoutInTableCell( pRecord->nLayoutInTableCell );
        m_nInTable && IsObjectLayoutInTableCell(pRecord->nGroupShapeBooleanProperties);

    // #i18732# - Switch on 'follow text flow', if object is laid out
    // inside table cell
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 2e764b75..5bcf33e 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -626,9 +626,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
                    maShapeRecords.Current()->nRecLen,
                    pImpRec->pClientDataBuffer, pImpRec->nClientDataLen );

        // process user (== Winword) defined parameters in 0xF122 record
        // #i84783# - set special value to determine, if property is provided or not.
        pImpRec->nLayoutInTableCell = 0xFFFFFFFF;
        pImpRec->nGroupShapeBooleanProperties = 0;

        if(    maShapeRecords.SeekToContent( rSt,
                                             DFF_msofbtUDefProp,
@@ -660,7 +658,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
                    case 0x0392:
                        pImpRec->nYRelTo = nUDData;
                        break;
                    case 0x03BF: pImpRec->nLayoutInTableCell = nUDData; break;
                    case 0x03BF: pImpRec->nGroupShapeBooleanProperties = nUDData; break;
                    case 0x0393:
                    // This seems to correspond to o:hrpct from .docx (even including
                    // the difference that it's in 0.1% even though the .docx spec
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 4315dbc..8d05ea2 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1718,7 +1718,7 @@ private:

    // #i84783#
    // determine object attribute "Layout in Table Cell"
    bool IsObjectLayoutInTableCell( const sal_uInt32 nLayoutInTableCell ) const;
    bool IsObjectLayoutInTableCell(const sal_uInt32 nGroupShapeBooleanProperties) const;
    void ReadGlobalTemplateSettings( std::u16string_view sCreatedFrom, const css::uno::Reference< css::container::XNameContainer >& xPrjNameMap );
    SwWW8ImplReader(const SwWW8ImplReader &) = delete;
    SwWW8ImplReader& operator=(const SwWW8ImplReader&) = delete;