tdf#137741 Add ability to navigate by fields from Navigate By control

Change-Id: I3cc464a3d5097b4e0438ea22ebf6daad5a2f2a86
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112144
Tested-by: Jenkins
Reviewed-by: Jim Raykowski <raykowj@gmail.com>
diff --git a/sw/inc/bitmaps.hlst b/sw/inc/bitmaps.hlst
index 5b7d131..a486eb3 100644
--- a/sw/inc/bitmaps.hlst
+++ b/sw/inc/bitmaps.hlst
@@ -72,6 +72,8 @@
#define RID_BMP_RIBBAR_FORMULA                  "sw/res/sr20018.png"
#define RID_BMP_RIBBAR_ERROR                    "sw/res/sr20019.png"
#define RID_BMP_RIBBAR_RECENCY                  "sw/res/sc20244.png"
#define RID_BMP_RIBBAR_FIELD                    "sw/res/sc20244.png"
#define RID_BMP_RIBBAR_FIELD_BYTYPE             "sw/res/sc20244.png"

#define RID_BMP_NAVI_OUTLINE                    "sw/res/nc20000.png"
#define RID_BMP_NAVI_TABLE                      "sw/res/nc20001.png"
diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc
index f67b3ec..ade1728 100644
--- a/sw/inc/strings.hrc
+++ b/sw/inc/strings.hrc
@@ -1181,6 +1181,8 @@
#define ST_TABLE_FORMULA                        NC_("ST_TABLE_FORMULA", "Table formula")
#define ST_TABLE_FORMULA_ERROR                  NC_("ST_TABLE_FORMULA_ERROR", "Wrong table formula")
#define ST_RECENCY                              NC_("ST_RECENCY", "Recency")
#define ST_FIELD                                NC_("ST_FIELD", "Field")
#define ST_FIELD_BYTYPE                         NC_("ST_FIELD_BYTYPE", "Field by type")
// Strings for the quickhelp of the View-PgUp/Down-Buttons
#define STR_IMGBTN_TBL_DOWN                     NC_("STR_IMGBTN_TBL_DOWN", "Next table")
#define STR_IMGBTN_FRM_DOWN                     NC_("STR_IMGBTN_FRM_DOWN", "Next frame")
@@ -1220,6 +1222,10 @@
#define STR_IMGBTN_TBLFML_ERR_DOWN              NC_("STR_IMGBTN_TBLFML_ERR_DOWN", "Next faulty table formula")
#define STR_IMGBTN_RECENCY_UP                   NC_("STR_IMGBTN_RECENCY_UP", "Go back")
#define STR_IMGBTN_RECENCY_DOWN                 NC_("STR_IMGBTN_RECENCY_DOWN", "Go forward")
#define STR_IMGBTN_FIELD_UP                     NC_("STR_IMGBTN_FIELD_UP", "Previous field")
#define STR_IMGBTN_FIELD_DOWN                   NC_("STR_IMGBTN_FIELD_DOWN", "Next field")
#define STR_IMGBTN_FIELD_BYTYPE_UP              NC_("STR_IMGBTN_FIELD_BYTYPE_UP", "Previous field with current field type")
#define STR_IMGBTN_FIELD_BYTYPE_DOWN            NC_("STR_IMGBTN_FIELD_BYTYPE_DOWN", "Next field with current field type")

#define STR_REDLINE_INSERT                      NC_("STR_REDLINE_INSERT", "Inserted")
#define STR_REDLINE_DELETE                      NC_("STR_REDLINE_DELETE", "Deleted")
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index 3b2ad65..58bf0b4 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -729,10 +729,11 @@ bool SwCursorShell::MoveFieldType(
    {
        const SwFieldTypes& rFieldTypes = *mxDoc->getIDocumentFieldsAccess().GetFieldTypes();
        const size_t nSize = rFieldTypes.size();
        const bool bAllFieldTypes = nResType == SwFieldIds::Unknown;
        for( size_t i=0; i < nSize; ++i )
        {
            pFieldType = rFieldTypes[ i ].get();
            if( nResType == pFieldType->Which() )
            if (bAllFieldTypes || nResType == pFieldType->Which())
            {
                ::lcl_MakeFieldLst( aSrtLst, *pFieldType, IsReadOnlyAvailable() );
            }
diff --git a/sw/source/uibase/inc/workctrl.hxx b/sw/source/uibase/inc/workctrl.hxx
index de05fe6..7f4d93a 100644
--- a/sw/source/uibase/inc/workctrl.hxx
+++ b/sw/source/uibase/inc/workctrl.hxx
@@ -47,7 +47,9 @@ class SwView;
#define NID_TABLE_FORMULA   20016
#define NID_TABLE_FORMULA_ERROR     20017
#define NID_RECENCY 20018
#define NID_COUNT  19
#define NID_FIELD   20019
#define NID_FIELD_BYTYPE    20020
#define NID_COUNT  21

class SwTbxAutoTextCtrl : public SfxToolBoxControl
{
diff --git a/sw/source/uibase/ribbar/workctrl.cxx b/sw/source/uibase/ribbar/workctrl.cxx
index 6a88d7c..fe443c9 100644
--- a/sw/source/uibase/ribbar/workctrl.cxx
+++ b/sw/source/uibase/ribbar/workctrl.cxx
@@ -59,7 +59,7 @@
#include <sfx2/viewfrm.hxx>

// Size check
#define NAVI_ENTRIES 19
#define NAVI_ENTRIES 21

using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -179,7 +179,9 @@ static sal_uInt16 aNavigationInsertIds[ NAVI_ENTRIES ] =
    NID_INDEX_ENTRY,
    NID_TABLE_FORMULA,
    NID_TABLE_FORMULA_ERROR,
    NID_RECENCY
    NID_RECENCY,
    NID_FIELD,
    NID_FIELD_BYTYPE
};

std::u16string_view const aNavigationImgIds[ NAVI_ENTRIES ] =
@@ -202,7 +204,9 @@ std::u16string_view const aNavigationImgIds[ NAVI_ENTRIES ] =
    u"" RID_BMP_RIBBAR_ENTRY,
    u"" RID_BMP_RIBBAR_FORMULA,
    u"" RID_BMP_RIBBAR_ERROR,
    u"" RID_BMP_RIBBAR_RECENCY
    u"" RID_BMP_RIBBAR_RECENCY,
    u"" RID_BMP_RIBBAR_FIELD,
    u"" RID_BMP_RIBBAR_FIELD_BYTYPE
};

static const char* aNavigationStrIds[ NAVI_ENTRIES ] =
@@ -225,7 +229,9 @@ static const char* aNavigationStrIds[ NAVI_ENTRIES ] =
    ST_INDEX_ENTRY,
    ST_TABLE_FORMULA,
    ST_TABLE_FORMULA_ERROR,
    ST_RECENCY
    ST_RECENCY,
    ST_FIELD,
    ST_FIELD_BYTYPE
};

// these are global strings
@@ -250,6 +256,8 @@ static const char* STR_IMGBTN_ARY[] =
    STR_IMGBTN_TBLFML_DOWN,
    STR_IMGBTN_TBLFML_ERR_DOWN,
    STR_IMGBTN_RECENCY_DOWN,
    STR_IMGBTN_FIELD_DOWN,
    STR_IMGBTN_FIELD_BYTYPE_DOWN,
    STR_IMGBTN_TBL_UP,
    STR_IMGBTN_FRM_UP,
    STR_IMGBTN_PGE_UP,
@@ -268,7 +276,9 @@ static const char* STR_IMGBTN_ARY[] =
    STR_IMGBTN_INDEX_ENTRY_UP,
    STR_IMGBTN_TBLFML_UP,
    STR_IMGBTN_TBLFML_ERR_UP,
    STR_IMGBTN_RECENCY_UP
    STR_IMGBTN_RECENCY_UP,
    STR_IMGBTN_FIELD_UP,
    STR_IMGBTN_FIELD_BYTYPE_UP,
};

static OUString lcl_GetScrollToolTip(bool bNext)
diff --git a/sw/source/uibase/uiview/viewmdi.cxx b/sw/source/uibase/uiview/viewmdi.cxx
index 69bd97623..f2d3c57 100644
--- a/sw/source/uibase/uiview/viewmdi.cxx
+++ b/sw/source/uibase/uiview/viewmdi.cxx
@@ -422,6 +422,32 @@ IMPL_LINK( SwView, MoveNavigationHdl, void*, p, void )
            GetViewFrame()->GetDispatcher()->Execute(bNext ?
                                        FN_NEXT_BOOKMARK :
                                            FN_PREV_BOOKMARK);
            break;
        case NID_FIELD:
            rSh.EnterStdMode();
            rSh.MoveFieldType(nullptr, bNext, SwFieldIds::Unknown);
        break;
        case NID_FIELD_BYTYPE:
        {
            // see: SwFieldMgr::GoNextPrev
            SwField* pCurField = rSh.GetCurField(true);
            if (!pCurField)
                break;
            rSh.EnterStdMode();
            SwFieldType* pTyp = nullptr;
            const SwFieldTypesEnum nTypeId = pCurField->GetTypeId();
            if (SwFieldTypesEnum::SetInput == nTypeId || SwFieldTypesEnum::UserInput == nTypeId)
                pTyp = rSh.GetFieldType(0, SwFieldIds::Input);
            else
                pTyp = pCurField->GetTyp();
            if (pTyp)
            {
                if (pTyp->Which() == SwFieldIds::Database)
                    rSh.MoveFieldType(nullptr, bNext, SwFieldIds::Database);
                else
                    rSh.MoveFieldType(pTyp, bNext);
            }
        }
        break;
        case NID_OUTL:
            rSh.EnterStdMode();