tdf#131725 use first page directionality for x-reference dialog TreeView

Change-Id: Ib827f4e73266f6416ba8459214263545291c4727
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133779
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx
index 5392df8..1fbd69c 100644
--- a/sw/source/ui/fldui/fldref.cxx
+++ b/sw/source/ui/fldui/fldref.cxx
@@ -22,6 +22,7 @@
#include <expfld.hxx>
#include <swmodule.hxx>
#include "fldref.hxx"
#include <frmatr.hxx>
#include <reffld.hxx>
#include <wrtsh.hxx>

@@ -34,8 +35,10 @@
#include <osl/diagnose.h>

#include <comphelper/string.hxx>
#include <editeng/frmdiritem.hxx>
#include <o3tl/safeint.hxx>
#include <o3tl/string_view.hxx>
#include <vcl/settings.hxx>

#define REFFLDFLAG          0x4000
#define REFFLDFLAG_BOOKMARK 0x4800
@@ -197,6 +200,15 @@ void SwFieldRefPage::Reset(const SfxItemSet* )
    if (!pSh)
        return;

    // tdf#148432 in LTR UI override the navigator treeview direction based on
    // the first page directionality
    if (!AllSettings::GetLayoutRTL())
    {
        const SwPageDesc& rDesc = pSh->GetPageDesc(0);
        const SvxFrameDirectionItem& rFrameDir = rDesc.GetMaster().GetFrameDir();
        m_xSelectionToolTipLB->set_direction(rFrameDir.GetValue() == SvxFrameDirection::Horizontal_RL_TB);
    }

    const size_t nFieldTypeCnt = pSh->GetFieldTypeCount(SwFieldIds::SetExp);

    OSL_ENSURE( nFieldTypeCnt < o3tl::make_unsigned(REFFLDFLAG), "<SwFieldRefPage::Reset> - Item index will overlap flags!" );