tdf#158426 Limit field columns for data form to 32
Previously, maximum number of field columns for data form was 256, which
was too much. But, even with that value, nothing was happening when
exceeding that threshold. With this patch, the limit is decreased to 32,
and if the user goes beyond this limit by selecting more columns, an
error message is displayed. This change is done to prevent LibreOffice
hang when excessive number of filed columns are selected and using data
form is requested.
Change-Id: Ib6189b5b3beffb26a3fd8ba8cd06e4ae213f77da
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162488
Tested-by: Jenkins
Reviewed-by: Hossein <hossein@libreoffice.org>
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 876fd23..b5badb5 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -219,6 +219,7 @@
#define STR_MATRIXFRAGMENTERR NC_("STR_MATRIXFRAGMENTERR", "You cannot change only part of an array.")
#define STR_PAGEHEADER NC_("STR_PAGEHEADER", "Header")
#define STR_PAGEFOOTER NC_("STR_PAGEFOOTER", "Footer")
#define STR_TOO_MANY_COLUMNS_DATA_FORM NC_("STR_TOO_MANY_COLUMNS_DATA_FORM", "Too many columns in the data form.")
/* BEGIN error constants and error strings. */
#define STR_ERROR_STR NC_("STR_ERROR_STR", "Err:")
diff --git a/sc/source/ui/inc/datafdlg.hxx b/sc/source/ui/inc/datafdlg.hxx
index 4a05cbf..cb61d0c 100644
--- a/sc/source/ui/inc/datafdlg.hxx
+++ b/sc/source/ui/inc/datafdlg.hxx
@@ -16,7 +16,7 @@
class ScTabViewShell;
class ScDocument;
#define MAX_DATAFORM_COLS 256
#define MAX_DATAFORM_COLS 32
#define MAX_DATAFORM_ROWS 32000
class ScDataFormDlg : public weld::GenericDialogController
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 8911cb3..5fbde9c 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -53,6 +53,7 @@
#include <validat.hxx>
#include <validate.hxx>
#include <datamapper.hxx>
#include <datafdlg.hxx>
#include <scui_def.hxx>
#include <scabstdlg.hxx>
@@ -353,6 +354,18 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
case SID_DATA_FORM:
{
ScViewData& rData = GetViewData();
ScRange aRange;
rData.GetSimpleArea( aRange );
ScAddress aStart = aRange.aStart;
ScAddress aEnd = aRange.aEnd;
if((aEnd.Col() - aStart.Col()) >= MAX_DATAFORM_COLS)
{
rData.GetDocShell()->ErrorMessage(STR_TOO_MANY_COLUMNS_DATA_FORM);
break;
}
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
VclPtr<AbstractScDataFormDlg> pDlg(pFact->CreateScDataFormDlg(