20#ifdef SC_DLLIMPLEMENTATION
21#undef SC_DLLIMPLEMENTATION
24#include <com/sun/star/sheet/TableValidationVisibility.hpp>
38#include <compiler.hxx>
49#define IS_MOBILE (comphelper::LibreOfficeKit::isActive() && SfxViewShell::Current() && SfxViewShell::Current()->isLOKMobilePhone())
54#define SC_VALIDDLG_ALLOW_ANY 0
55#define SC_VALIDDLG_ALLOW_WHOLE 1
56#define SC_VALIDDLG_ALLOW_DECIMAL 2
57#define SC_VALIDDLG_ALLOW_DATE 3
58#define SC_VALIDDLG_ALLOW_TIME 4
59#define SC_VALIDDLG_ALLOW_RANGE 5
60#define SC_VALIDDLG_ALLOW_LIST 6
61#define SC_VALIDDLG_ALLOW_TEXTLEN 7
62#define SC_VALIDDLG_ALLOW_CUSTOM 8
67#define SC_VALIDDLG_DATA_EQUAL 0
68#define SC_VALIDDLG_DATA_LESS 1
69#define SC_VALIDDLG_DATA_GREATER 2
70#define SC_VALIDDLG_DATA_EQLESS 3
71#define SC_VALIDDLG_DATA_EQGREATER 4
72#define SC_VALIDDLG_DATA_NOTEQUAL 5
73#define SC_VALIDDLG_DATA_VALIDRANGE 6
74#define SC_VALIDDLG_DATA_INVALIDRANGE 7
75#define SC_VALIDDLG_DATA_DIRECT 8
77namespace ValidListType = css::sheet::TableValidationVisibility;
80 FID_VALID_LISTTYPE, FID_VALID_LISTTYPE,
81 FID_VALID_MODE, FID_VALID_ERRTEXT
87 "modules/scalc/ui/validationdialog.ui",
"ValidationDialog", pArgSet, nullptr)
88 , m_pTabVwSh(pTabViewSh)
89 , m_sValuePageId(
"criteria")
90 , m_bOwnRefHdlr(false)
91 , m_bRefInputting(false)
92 , m_xHBox(m_xBuilder->weld_container(
"refinputbox"))
100 m_xBuilder->weld_button(
"cancel")->hide();
101 m_xBuilder->weld_button(
"help")->hide();
140 pValidationDlg->RefInputDone();
175 weld::Container* pOldParent = pValidationDlg->get_refinput_shrink_parent();
191 ScViewData& rViewData = pValidationDlg->GetTabViewShell()->GetViewData();
196 if ( nCurTab != nRefTab )
222 default: OSL_FAIL(
"lclGetPosFromValMode - unknown validity mode" );
242 default: OSL_FAIL(
"lclGetValModeFromPos - invalid list box position" );
263 default: OSL_FAIL(
"lclGetPosFromCondMode - unknown condition mode" );
283 default: OSL_FAIL(
"lclGetCondModeFromPos - invalid list box position" );
292void lclGetFormulaFromStringList( OUString& rFmlaStr, std::u16string_view rStringList,
sal_Unicode cFmlaSep )
295 if (!rStringList.empty())
306 if( rFmlaStr.isEmpty() )
315bool lclGetStringListFromFormula( OUString& rStringList,
const OUString& rFmlaStr,
sal_Unicode cFmlaSep )
317 static const OUStringLiteral aQuotes( u
"\"\"" );
320 bool bIsStringList = !rFmlaStr.isEmpty();
321 bool bTokenAdded =
false;
323 for ( sal_Int32 nStringIx = 0; bIsStringList && nStringIx>=0; )
327 if( !aToken.isEmpty() )
339 return bIsStringList;
345 :
SfxTabPage(pPage, pController,
"modules/scalc/ui/validationcriteriapage.ui",
346 "ValidationCriteriaPage", &rArgSet)
347 , maStrMin(
ScResId(SCSTR_VALID_MINIMUM))
348 , maStrMax(
ScResId(SCSTR_VALID_MAXIMUM))
349 , maStrValue(
ScResId(SCSTR_VALID_VALUE))
350 , maStrFormula(
ScResId(SCSTR_VALID_FORMULA))
351 , maStrRange(
ScResId(SCSTR_VALID_RANGE))
352 , maStrList(
ScResId(SCSTR_VALID_LIST))
353 , m_pRefEdit(nullptr)
354 , m_xLbAllow(m_xBuilder->weld_combo_box(
"allow"))
355 , m_xCbAllow(m_xBuilder->weld_check_button(
"allowempty"))
356 , m_xCbShow(m_xBuilder->weld_check_button(
"showlist"))
357 , m_xCbSort(m_xBuilder->weld_check_button(
"sortascend"))
358 , m_xFtValue(m_xBuilder->weld_label(
"valueft"))
359 , m_xLbValue(m_xBuilder->weld_combo_box(
"data"))
360 , m_xFtMin(m_xBuilder->weld_label(
"minft"))
361 , m_xMinGrid(m_xBuilder->weld_widget(
"mingrid"))
362 , m_xEdMin(new
formula::RefEdit(m_xBuilder->weld_entry(
"min")))
363 , m_xEdList(m_xBuilder->weld_text_view(
"minlist"))
364 , m_xFtMax(m_xBuilder->weld_label(
"maxft"))
365 , m_xEdMax(new
formula::RefEdit(m_xBuilder->weld_entry(
"max")))
366 , m_xFtHint(m_xBuilder->weld_label(
"hintft"))
367 , m_xBtnRef(new
formula::RefButton(m_xBuilder->weld_button(
"validref")))
368 , m_xRefGrid(m_xBuilder->weld_container(
"refgrid"))
369 , m_pRefEditParent(m_xRefGrid.
get())
370 , m_pBtnRefParent(m_xRefGrid.
get())
389 OSL_ENSURE( aListSep.getLength() == 1,
"ScTPValidationValue::ScTPValidationValue - list separator error" );
390 mcFmlaSep = aListSep.getLength() ? aListSep[0] :
';';
423 return std::make_unique<ScTPValidationValue>(pPage, pController, *rArgSet);
430 nLbPos = lclGetPosFromValMode(
static_cast< ScValidationMode >( pItem->GetValue() ) );
435 nLbPos = lclGetPosFromCondMode(
static_cast< ScConditionMode >( pItem->GetValue() ) );
441 bCheck = pItem->GetValue();
444 sal_Int32 nListType = ValidListType::UNSORTED;
446 nListType = pItem->GetValue();
447 m_xCbShow->set_active( nListType != ValidListType::INVISIBLE );
448 m_xCbSort->set_active( nListType == ValidListType::SORTEDASCENDING );
453 aFmlaStr = pItem->GetValue();
458 aFmlaStr = pItem->GetValue();
467 sal_Int16 nListType =
m_xCbShow->get_active() ?
468 (
m_xCbSort->get_active() ? ValidListType::SORTEDASCENDING : ValidListType::UNSORTED) :
469 ValidListType::INVISIBLE;
471 const sal_Int32 nLbPos =
m_xLbAllow->get_active();
476 rArgSet->
Put(
SfxUInt16Item( FID_VALID_MODE, sal::static_int_cast<sal_uInt16>(
477 lclGetValModeFromPos( nLbPos ) ) ) );
478 rArgSet->
Put(
SfxUInt16Item( FID_VALID_CONDMODE, sal::static_int_cast<sal_uInt16>( eCondMode ) ) );
533 if( !pValidationDlg )
547 if (
m_xEdMax->GetWidget()->get_visible())
552 else if (
m_xEdMin->GetWidget()->get_visible())
570 if( !pValidationDlg )
586 m_xBtnRef->SetReferences(
nullptr,
nullptr );
591 const sal_Int32
nPos = m_xLbAllow->get_active();
601 if (&rWnd != m_pRefEdit)
605 if (pValidationDlg->IsChildFocus() && !pValidationDlg->IsRefInputting())
607 if( ( !m_pRefEdit || !m_pRefEdit->GetWidget()->has_focus()) && !m_xBtnRef->GetWidget()->has_focus() )
617 if( &rWnd != m_xBtnRef.get())
620 if (pValidationDlg->IsChildFocus() && !pValidationDlg->IsRefInputting())
621 if( ( !m_pRefEdit || !m_pRefEdit->GetWidget()->has_focus()) && !m_xBtnRef->GetWidget()->has_focus() )
629 const sal_Int32 nLbPos = m_xLbAllow->get_active();
635 m_xCbAllow->set_sensitive( bEnable );
636 m_xFtValue->set_sensitive( bEnable );
637 m_xLbValue->set_sensitive( bEnable );
638 m_xFtMin->set_sensitive( bEnable );
639 m_xEdMin->GetWidget()->set_sensitive( bEnable );
640 m_xEdList->set_sensitive( bEnable );
641 m_xFtMax->set_sensitive( bEnable );
642 m_xEdMax->GetWidget()->set_sensitive( bEnable );
644 bool bShowMax =
false;
647 m_xFtMin->set_label( maStrRange );
649 m_xFtMin->set_label( maStrList );
651 m_xFtMin->set_label( maStrFormula );
654 switch( m_xLbValue->get_active() )
669 OSL_FAIL(
"ScTPValidationValue::SelectHdl - unknown condition mode" );
673 m_xCbShow->set_visible( bRange || bList );
674 m_xCbSort->set_visible( bRange || bList );
675 m_xFtValue->set_visible( !bRange && !bList && !bCustom);
676 m_xLbValue->set_visible( !bRange && !bList && !bCustom );
677 m_xEdMin->GetWidget()->set_visible( !bList );
678 m_xEdList->set_visible( bList );
679 m_xMinGrid->set_vexpand( bList );
680 m_xFtMax->set_visible( bShowMax );
681 m_xEdMax->GetWidget()->set_visible( bShowMax );
682 m_xFtHint->set_visible( bRange );
683 m_xBtnRef->GetWidget()->set_visible( bRange );
688 m_xCbSort->set_sensitive( m_xCbShow->get_active() );
694 :
SfxTabPage(pPage, pController,
IS_MOBILE ? OUString(
"modules/scalc/ui/validationhelptabpage-mobile.ui")
695 : OUString(
"modules/scalc/ui/validationhelptabpage.ui"),
"ValidationHelpTabPage", &rArgSet)
696 , m_xTsbHelp(m_xBuilder->weld_check_button(
"tsbhelp"))
697 , m_xEdtTitle(m_xBuilder->weld_entry(
"title"))
698 , m_xEdInputHelp(m_xBuilder->weld_text_view(
"inputhelp"))
710 return std::make_unique<ScTPValidationHelp>(pPage, pController, *rArgSet);
746 IS_MOBILE ? OUString(
"modules/scalc/ui/erroralerttabpage-mobile.ui")
747 : OUString(
"modules/scalc/ui/erroralerttabpage.ui"),
"ErrorAlertTabPage",
749 , m_xTsbShow(m_xBuilder->weld_check_button(
"tsbshow"))
750 , m_xLbAction(m_xBuilder->weld_combo_box(
"actionCB"))
751 , m_xBtnSearch(m_xBuilder->weld_button(
"browseBtn"))
752 , m_xEdtTitle(m_xBuilder->weld_entry(
"erroralert_title"))
753 , m_xFtError(m_xBuilder->weld_label(
"errormsg_label"))
754 , m_xEdError(m_xBuilder->weld_text_view(
"errorMsg"))
777 return std::make_unique<ScTPValidationError>(pPage, pController, *rArgSet);
820 m_xBtnSearch->set_sensitive( bMacro );
821 m_xFtError->set_sensitive( !bMacro );
822 m_xEdError->set_sensitive( !bMacro );
831 if ( !aScriptURL.isEmpty() )
833 m_xEdtTitle->set_text( aScriptURL );
841 if( !pTabViewShell )
return false;
847 if (pWnd && pWnd->
GetController().get() !=
this) pWnd =
nullptr;
849 SC_MOD()->SetRefDialog(
nId, pWnd ==
nullptr );
858 if( !pTabViewShell )
return false;
884 bool bVisLock =
false;
885 bool bFreeWindowLock =
false;
889 if( !pTabVwSh )
return false;
Reference< XExecutableDialog > m_xDialog
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
static SC_DLLPUBLIC bool IsQuoted(std::u16string_view rString, sal_Unicode cQuote)
Returns true, if the first and last character of the string is cQuote.
static SC_DLLPUBLIC void EraseQuotes(OUString &rString, sal_Unicode cQuote, bool bUnescapeEmbedded=true)
Erases the character cQuote from rString, if it exists at beginning AND end.
static SC_DLLPUBLIC OUString addToken(std::u16string_view rTokenList, std::u16string_view rToken, sal_Unicode cSep, sal_Int32 nSepCount=1, bool bForceSep=false)
Adds the string rToken to rTokenList, using a list separator character.
static SC_DLLPUBLIC void AddQuotes(OUString &rString, sal_Unicode cQuote, bool bEscapeEmbedded=true)
Inserts the character cQuote at beginning and end of rString.
OUString Format(const ScDocument &rDocument, ScRefFlags nFlags=ScRefFlags::ZERO, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1, bool bFullAddressNotation=false) const
Returns string with formatted cell range from aStart to aEnd, according to provided address conventio...
void(ScRefHandlerCaller::* PINPUTSTARTDLTYPE)(formula::RefEdit *pEdit, const formula::RefButton *pButton)
void SetRefInputDonePostHdl(void(ScRefHandlerCaller::*pNewHdl)())
void SetSetActHdl(PCOMMONHDLTYPE pNewHdl)
void SetRefInputStartPreHdl(PINPUTSTARTDLTYPE pNewHdl)
void(ScRefHandlerCaller::* PFUNCSETREFHDLTYPE)(const ScRange &, const ScDocument &)
void(ScRefHandlerCaller::* PCOMMONHDLTYPE)()
void SetHandler(ScRefHandlerCaller *pNewHandler)
void SetSetRefHdl(PFUNCSETREFHDLTYPE pNewHdl)
bool DoClose(sal_uInt16 nId)
static OUString SC_DLLPUBLIC GetQuotedToken(const OUString &rIn, sal_Int32 nToken, const OUString &rQuotedPairs, sal_Unicode cTok, sal_Int32 &rIndex)
std::unique_ptr< weld::Button > m_xBtnSearch
virtual void Reset(const SfxItemSet *rArgSet) override
std::unique_ptr< weld::ComboBox > m_xLbAction
virtual ~ScTPValidationError() override
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rArgSet)
virtual bool FillItemSet(SfxItemSet *rArgSet) override
std::unique_ptr< weld::TextView > m_xEdError
ScTPValidationError(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rArgSet)
std::unique_ptr< weld::CheckButton > m_xTsbShow
std::unique_ptr< weld::Entry > m_xEdtTitle
std::unique_ptr< weld::TextView > m_xEdInputHelp
virtual ~ScTPValidationHelp() override
std::unique_ptr< weld::CheckButton > m_xTsbHelp
virtual bool FillItemSet(SfxItemSet *rArgSet) override
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rArgSet)
std::unique_ptr< weld::Entry > m_xEdtTitle
ScTPValidationHelp(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rArgSet)
virtual void Reset(const SfxItemSet *rArgSet) override
The tab page "Criteria" from the Validation dialog.
virtual bool FillItemSet(SfxItemSet *rArgSet) override
void SetFirstFormula(const OUString &rFmlaStr)
ScTPValidationValue(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rArgSet)
formula::RefEdit * m_pRefEdit
void RefInputDonePostHdl()
std::unique_ptr< weld::Container > m_xRefGrid
virtual void Reset(const SfxItemSet *rArgSet) override
std::unique_ptr< formula::RefEdit > m_xEdMin
std::unique_ptr< weld::CheckButton > m_xCbAllow
weld::Container * m_pBtnRefParent
std::unique_ptr< formula::RefButton > m_xBtnRef
Hint text for cell range validity.
virtual ~ScTPValidationValue() override
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rArgSet)
void SetReferenceHdl(const ScRange &, const ScDocument &)
std::unique_ptr< formula::RefEdit > m_xEdMax
weld::Container * m_pRefEditParent
std::unique_ptr< weld::CheckButton > m_xCbShow
Allow blank cells.
void RefInputStartPreHdl(formula::RefEdit *pEdit, const formula::RefButton *pButton)
std::unique_ptr< weld::CheckButton > m_xCbSort
Show selection list in cell.
void SetSecondFormula(const OUString &rFmlaStr)
OUString GetFirstFormula() const
std::unique_ptr< weld::Label > m_xFtMin
std::unique_ptr< weld::Label > m_xFtMax
Entries for explicit list.
ScValidationDlg * GetValidationDlg()
std::unique_ptr< weld::ComboBox > m_xLbValue
static const WhichRangesContainer pValueRanges
OUString GetSecondFormula() const
void RemoveRefDlg(bool bRestoreModal)
std::unique_ptr< weld::TextView > m_xEdList
std::unique_ptr< weld::ComboBox > m_xLbAllow
SC_DLLPUBLIC void SetTabNo(SCTAB nTab, bool bNew=false, bool bExtendSelection=false, bool bSameTabButMoved=false)
The "Validity" tab dialog.
ScTabViewShell * GetTabViewShell()
bool RemoveRefDlg(bool bRestoreModal)
virtual ~ScValidationDlg() override
virtual void EndDialog(int nResponse) override
bool IsChildFocus() const
ScValidationDlg(weld::Window *pParent, const SfxItemSet *pArgSet, ScTabViewShell *pTabViewSh)
void SetModal(bool bModal)
weld::Container * get_refinput_shrink_parent()
ScTabViewShell * GetViewShell() const
SCTAB GetRefTabNo() const
static OUString ChooseScript(weld::Window *pParent)
std::shared_ptr< SfxDialogController > & GetController()
virtual void EndDialog(int nResponse)
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void AddTabPage(const OString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
SfxOkDialogController * GetDialogController() const
SfxChildWindow * GetChildWindow(sal_uInt16)
SfxViewFrame & GetViewFrame() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
virtual void move(weld::Widget *pWidget, weld::Container *pNewParent)=0
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
#define LINK(Instance, Class, Member)
OString strip(const OString &rIn, char c)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
static constexpr auto Items
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
Reference< XNameAccess > m_xContainer
OUString ScResId(TranslateId aId)
#define SC_VALIDDLG_DATA_LESS
#define SC_VALIDDLG_ALLOW_TIME
#define SC_VALIDDLG_DATA_VALIDRANGE
#define SC_VALIDDLG_DATA_NOTEQUAL
#define SC_VALIDDLG_DATA_EQLESS
#define SC_VALIDDLG_DATA_DIRECT
#define SC_VALIDDLG_ALLOW_DATE
#define SC_VALIDDLG_ALLOW_DECIMAL
#define SC_VALIDDLG_ALLOW_RANGE
#define SC_VALIDDLG_DATA_INVALIDRANGE
#define SC_VALIDDLG_ALLOW_TEXTLEN
#define SC_VALIDDLG_ALLOW_ANY
IMPL_LINK(ScTPValidationValue, KillEditFocusHdl, formula::RefEdit &, rWnd, void)
IMPL_LINK_NOARG(ScTPValidationValue, EditSetFocusHdl, formula::RefEdit &, void)
#define SC_VALIDDLG_DATA_GREATER
#define SC_VALIDDLG_ALLOW_WHOLE
#define SC_VALIDDLG_DATA_EQGREATER
#define SC_VALIDDLG_ALLOW_LIST
#define SC_VALIDDLG_DATA_EQUAL
#define SC_VALIDDLG_ALLOW_CUSTOM
const std::u16string_view aStringList[]