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();
146 pValidationDlg->RefInputDone();
181 weld::Container* pOldParent = pValidationDlg->get_refinput_shrink_parent();
197 ScViewData& rViewData = pValidationDlg->GetTabViewShell()->GetViewData();
202 if ( nCurTab != nRefTab )
228 default: OSL_FAIL(
"lclGetPosFromValMode - unknown validity mode" );
248 default: OSL_FAIL(
"lclGetValModeFromPos - invalid list box position" );
269 default: OSL_FAIL(
"lclGetPosFromCondMode - unknown condition mode" );
289 default: OSL_FAIL(
"lclGetCondModeFromPos - invalid list box position" );
298void lclGetFormulaFromStringList( OUString& rFmlaStr, std::u16string_view rStringList,
sal_Unicode cFmlaSep )
301 if (!rStringList.empty())
312 if( rFmlaStr.isEmpty() )
321bool lclGetStringListFromFormula( OUString& rStringList,
const OUString& rFmlaStr,
sal_Unicode cFmlaSep )
323 static constexpr OUStringLiteral aQuotes( u
"\"\"" );
326 bool bIsStringList = !rFmlaStr.isEmpty();
327 bool bTokenAdded =
false;
329 for ( sal_Int32 nStringIx = 0; bIsStringList && nStringIx>=0; )
333 if( !aToken.isEmpty() )
345 return bIsStringList;
351 :
SfxTabPage(pPage, pController,
"modules/scalc/ui/validationcriteriapage.ui",
352 "ValidationCriteriaPage", &rArgSet)
353 , maStrMin(
ScResId(SCSTR_VALID_MINIMUM))
354 , maStrMax(
ScResId(SCSTR_VALID_MAXIMUM))
355 , maStrValue(
ScResId(SCSTR_VALID_VALUE))
356 , maStrFormula(
ScResId(SCSTR_VALID_FORMULA))
357 , maStrRange(
ScResId(SCSTR_VALID_RANGE))
358 , maStrList(
ScResId(SCSTR_VALID_LIST))
359 , m_pRefEdit(nullptr)
360 , m_xLbAllow(m_xBuilder->weld_combo_box(
"allow"))
361 , m_xCbAllow(m_xBuilder->weld_check_button(
"allowempty"))
362 , m_xCbShow(m_xBuilder->weld_check_button(
"showlist"))
363 , m_xCbSort(m_xBuilder->weld_check_button(
"sortascend"))
364 , m_xFtValue(m_xBuilder->weld_label(
"valueft"))
365 , m_xLbValue(m_xBuilder->weld_combo_box(
"data"))
366 , m_xFtMin(m_xBuilder->weld_label(
"minft"))
367 , m_xMinGrid(m_xBuilder->weld_widget(
"mingrid"))
368 , m_xEdMin(new
formula::RefEdit(m_xBuilder->weld_entry(
"min")))
369 , m_xEdList(m_xBuilder->weld_text_view(
"minlist"))
370 , m_xFtMax(m_xBuilder->weld_label(
"maxft"))
371 , m_xEdMax(new
formula::RefEdit(m_xBuilder->weld_entry(
"max")))
372 , m_xFtHint(m_xBuilder->weld_label(
"hintft"))
373 , m_xBtnRef(new
formula::RefButton(m_xBuilder->weld_button(
"validref")))
374 , m_xRefGrid(m_xBuilder->weld_container(
"refgrid"))
375 , m_pRefEditParent(m_xRefGrid.
get())
376 , m_pBtnRefParent(m_xRefGrid.
get())
395 OSL_ENSURE( aListSep.getLength() == 1,
"ScTPValidationValue::ScTPValidationValue - list separator error" );
396 mcFmlaSep = aListSep.getLength() ? aListSep[0] :
';';
429 return std::make_unique<ScTPValidationValue>(pPage, pController, *rArgSet);
436 nLbPos = lclGetPosFromValMode(
static_cast< ScValidationMode >( pItem->GetValue() ) );
441 nLbPos = lclGetPosFromCondMode(
static_cast< ScConditionMode >( pItem->GetValue() ) );
447 bCheck = pItem->GetValue();
450 sal_Int32 nListType = ValidListType::UNSORTED;
452 nListType = pItem->GetValue();
453 m_xCbShow->set_active( nListType != ValidListType::INVISIBLE );
454 m_xCbSort->set_active( nListType == ValidListType::SORTEDASCENDING );
459 aFmlaStr = pItem->GetValue();
464 aFmlaStr = pItem->GetValue();
473 sal_Int16 nListType =
m_xCbShow->get_active() ?
474 (
m_xCbSort->get_active() ? ValidListType::SORTEDASCENDING : ValidListType::UNSORTED) :
475 ValidListType::INVISIBLE;
477 const sal_Int32 nLbPos =
m_xLbAllow->get_active();
482 rArgSet->
Put(
SfxUInt16Item( FID_VALID_MODE, sal::static_int_cast<sal_uInt16>(
483 lclGetValModeFromPos( nLbPos ) ) ) );
484 rArgSet->
Put(
SfxUInt16Item( FID_VALID_CONDMODE, sal::static_int_cast<sal_uInt16>( eCondMode ) ) );
539 if( !pValidationDlg )
553 if (
m_xEdMax->GetWidget()->get_visible())
558 else if (
m_xEdMin->GetWidget()->get_visible())
576 if( !pValidationDlg )
592 m_xBtnRef->SetReferences(
nullptr,
nullptr );
597 const sal_Int32
nPos = m_xLbAllow->get_active();
607 if (&rWnd != m_pRefEdit)
611 if (pValidationDlg->IsChildFocus() && !pValidationDlg->IsRefInputting())
613 if( ( !m_pRefEdit || !m_pRefEdit->GetWidget()->has_focus()) && !m_xBtnRef->GetWidget()->has_focus() )
623 if( &rWnd != m_xBtnRef.get())
626 if (pValidationDlg->IsChildFocus() && !pValidationDlg->IsRefInputting())
627 if( ( !m_pRefEdit || !m_pRefEdit->GetWidget()->has_focus()) && !m_xBtnRef->GetWidget()->has_focus() )
635 const sal_Int32 nLbPos = m_xLbAllow->get_active();
641 m_xCbAllow->set_sensitive( bEnable );
642 m_xFtValue->set_sensitive( bEnable );
643 m_xLbValue->set_sensitive( bEnable );
644 m_xFtMin->set_sensitive( bEnable );
645 m_xEdMin->GetWidget()->set_sensitive( bEnable );
646 m_xEdList->set_sensitive( bEnable );
647 m_xFtMax->set_sensitive( bEnable );
648 m_xEdMax->GetWidget()->set_sensitive( bEnable );
650 bool bShowMax =
false;
653 m_xFtMin->set_label( maStrRange );
655 m_xFtMin->set_label( maStrList );
657 m_xFtMin->set_label( maStrFormula );
660 switch( m_xLbValue->get_active() )
675 OSL_FAIL(
"ScTPValidationValue::SelectHdl - unknown condition mode" );
679 m_xCbShow->set_visible( bRange || bList );
680 m_xCbSort->set_visible( bRange || bList );
681 m_xFtValue->set_visible( !bRange && !bList && !bCustom);
682 m_xLbValue->set_visible( !bRange && !bList && !bCustom );
683 m_xEdMin->GetWidget()->set_visible( !bList );
684 m_xEdList->set_visible( bList );
685 m_xMinGrid->set_vexpand( bList );
686 m_xFtMax->set_visible( bShowMax );
687 m_xEdMax->GetWidget()->set_visible( bShowMax );
688 m_xFtHint->set_visible( bRange );
689 m_xBtnRef->GetWidget()->set_visible( bRange );
694 m_xCbSort->set_sensitive( m_xCbShow->get_active() );
700 :
SfxTabPage(pPage, pController,
"modules/scalc/ui/validationhelptabpage.ui",
"ValidationHelpTabPage", &rArgSet)
701 , m_xTsbHelp(m_xBuilder->weld_check_button(
"tsbhelp"))
702 , m_xEdtTitle(m_xBuilder->weld_entry(
"title"))
703 , m_xEdInputHelp(m_xBuilder->weld_text_view(
"inputhelp_text"))
715 return std::make_unique<ScTPValidationHelp>(pPage, pController, *rArgSet);
751 "modules/scalc/ui/erroralerttabpage.ui",
"ErrorAlertTabPage",
753 , m_xTsbShow(m_xBuilder->weld_check_button(
"tsbshow"))
754 , m_xLbAction(m_xBuilder->weld_combo_box(
"actionCB"))
755 , m_xBtnSearch(m_xBuilder->weld_button(
"browseBtn"))
756 , m_xEdtTitle(m_xBuilder->weld_entry(
"erroralert_title"))
757 , m_xFtError(m_xBuilder->weld_label(
"errormsg_label"))
758 , m_xEdError(m_xBuilder->weld_text_view(
"errorMsg"))
781 return std::make_unique<ScTPValidationError>(pPage, pController, *rArgSet);
824 m_xBtnSearch->set_sensitive( bMacro );
825 m_xFtError->set_sensitive( !bMacro );
826 m_xEdError->set_sensitive( !bMacro );
835 if ( !aScriptURL.isEmpty() )
837 m_xEdtTitle->set_text( aScriptURL );
845 if( !pTabViewShell )
return false;
851 if (pWnd && pWnd->
GetController().get() !=
this) pWnd =
nullptr;
853 SC_MOD()->SetRefDialog(
nId, pWnd ==
nullptr );
862 if( !pTabViewShell )
return false;
888 bool bVisLock =
false;
889 bool bFreeWindowLock =
false;
893 if( !pTabVwSh )
return false;
Reference< XExecutableDialog > m_xDialog
const int nCloseResponseToJustHide
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 OUString &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[]