22#include <editeng/editeng.hxx>
36#include <document.hxx>
49#include <LibreOfficeKit/LibreOfficeKitEnums.h>
50#include <inputwin.hxx>
59OString escapeJSON(
const OUString &aStr)
61 OUString aEscaped =
aStr;
62 aEscaped = aEscaped.replaceAll(
"\n",
" ");
63 aEscaped = aEscaped.replaceAll(
"\"",
"'");
67void lcl_lokGetWholeFunctionList()
75 sal_uInt32 nListCount = pFuncList->
GetCount();
76 std::set<OUString> aFuncNameOrderedSet;
77 for(sal_uInt32 i = 0;
i < nListCount; ++
i)
82 aFuncNameOrderedSet.insert(*pDesc->
mxFuncName);
86 if (!(pFuncManager && aFuncNameOrderedSet.size()))
89 OStringBuffer aPayload;
90 aPayload.append(
"{ \"wholeList\": true, ");
91 aPayload.append(
"\"categories\": [ ");
94 sal_uInt32 nCategoryCount = pFuncManager->
getCount();
95 for (sal_uInt32 i = 0;
i < nCategoryCount; ++
i)
99 aPayload.append(
"\"name\": \"");
100 aPayload.append(escapeJSON(sCategoryName));
101 aPayload.append(
"\"}, ");
103 sal_Int32 nLen = aPayload.getLength();
104 aPayload[nLen - 2] =
' ';
105 aPayload[nLen - 1] =
']';
106 aPayload.append(
", ");
108 OUString aDescFuncNameStr;
109 aPayload.append(
"\"functions\": [ ");
110 sal_uInt32 nCurIndex = 0;
111 for (
const OUString& aFuncNameStr : aFuncNameOrderedSet)
113 aDescFuncNameStr = aFuncNameStr +
"()";
114 sal_Int32 nNextFStart = 0;
116 ::std::vector< OUString > aArgs;
117 OUString eqPlusFuncName =
"=" + aDescFuncNameStr;
118 if (
aHelper.GetNextFunc( eqPlusFuncName,
false, nNextFStart,
nullptr, &ppFDesc, &aArgs ) )
124 aPayload.append(
"{");
125 aPayload.append(
"\"index\": ");
126 aPayload.append(
static_cast<sal_Int64
>(nCurIndex));
127 aPayload.append(
", ");
128 aPayload.append(
"\"category\": ");
130 aPayload.append(
", ");
131 aPayload.append(
"\"signature\": \"");
133 aPayload.append(
"\", ");
134 aPayload.append(
"\"description\": \"");
136 aPayload.append(
"\"}, ");
142 nLen = aPayload.getLength();
143 aPayload[nLen - 2] =
' ';
144 aPayload[nLen - 1] =
']';
145 aPayload.append(
" }");
147 OString s = aPayload.makeStringAndClear();
159 sal_uInt16 nSlot = rReq.
GetSlot();
161 if (nSlot != SID_CURRENTCELL)
170 case SID_OPENDLG_FUNCTION:
177 case FID_CELL_FORMAT:
178 case SID_ENABLE_HYPHENATION:
179 case SID_DATA_SELECT:
180 case SID_OPENDLG_CONSOLIDATE:
181 case SID_OPENDLG_SOLVE:
182 case SID_OPENDLG_OPTSOLVER:
198 case SID_STATUS_SELMODE:
224 switch ( nModifiers )
227 case KEY_MOD1: nModifiers = 0;
break;
239 case SID_STATUS_SELMODE_NORM:
246 case SID_STATUS_SELMODE_ERG:
254 case SID_STATUS_SELMODE_ERW:
262 case SID_ENTER_STRING:
283 if (pReqArgs->
HasItem(FN_PARAM_1, &pDontCommitItem))
325 case SID_INSERT_MATRIX:
338 case FID_INPUTLINE_ENTER:
339 case FID_INPUTLINE_BLOCK:
340 case FID_INPUTLINE_MATRIX:
342 if( pReqArgs ==
nullptr )
347 Get( FID_INPUTLINE_STATUS ));
350 const OUString& aString = pStatusItem->
GetString();
355 if (nSlot == FID_INPUTLINE_BLOCK)
359 else if ( !aString.isEmpty() && ( aString[0] ==
'=' || aString[0] ==
'+' || aString[0] ==
'-' ) )
362 aString,
pData,
true );
371 if (nSlot == FID_INPUTLINE_ENTER)
384 rBindings.
Execute( SID_ENTER_STRING, aArgs );
396 else if (nSlot == FID_INPUTLINE_BLOCK)
398 pTabViewShell->
EnterBlock( aString,
nullptr );
418 case SID_OPENDLG_FUNCTION:
427 lcl_lokGetWholeFunctionList();
431 sal_uInt16
nId = SID_OPENDLG_FUNCTION;
441 case SID_OPENDLG_CONSOLIDATE:
443 sal_uInt16
nId = ScConsolidateDlgWrapper::GetChildWindowId();
451 case FID_CELL_FORMAT:
453 if ( pReqArgs !=
nullptr )
463 sal_uInt16 nWhich = 0;
466 if ( pReqArgs->
GetItemState( nWhich,
true, &pAttr ) == SfxItemState::SET )
467 aNewSet.
Put( *pAttr );
480 case SID_ENABLE_HYPHENATION:
484 case SID_PROPERTY_PANEL_CELLTEXT_DLG:
488 case SID_CELL_FORMAT_BORDER:
492 case SID_CHAR_DLG_EFFECT:
496 case SID_OPENDLG_SOLVE:
498 sal_uInt16
nId = ScSolverDlgWrapper::GetChildWindowId();
506 case SID_OPENDLG_OPTSOLVER:
508 sal_uInt16
nId = ScOptSolverDlgWrapper::GetChildWindowId();
516 case SID_OPENDLG_TABOP:
518 sal_uInt16
nId = ScTabOpDlgWrapper::GetChildWindowId();
538 bool bExtend = rReq.
IsAPI();
542 VclMessageType::Question, VclButtonsType::YesNo,
543 ScResId(STR_UPDATE_SCENARIO)));
544 xQueryBox->set_default_response(
RET_YES);
545 bExtend = xQueryBox->run() ==
RET_YES;
554 else if( ! rReq.
IsAPI() )
557 VclMessageType::Warning, VclButtonsType::Ok,
575 aBaseName = aTmp +
"_" +
ScResId(STR_SCENARIO) +
"_";
580 OSL_ENSURE(bPrefix,
"invalid sheet name");
589 aName = aBaseName + OUString::number(
i );
596 while ( !bValid &&
i <=
MAXTAB + 2 );
598 if ( pReqArgs !=
nullptr )
601 OUString aArgComment;
603 aArgName = pItem->GetValue();
605 aArgComment = pItem->GetValue();
610 pTabViewShell->
MakeScenario( aArgName, aArgComment, aColor, nFlags );
620 if ( pNewDlg->Execute() ==
RET_OK )
623 pNewDlg->GetScenarioData(
aName, aComment, aColor, nFlags );
632 else if( ! rReq.
IsAPI() )
653 if ( pReqArgs && (pHeight = pReqArgs->
GetItemIfSet( FID_ROW_HEIGHT )) &&
654 pReqArgs->
HasItem( FN_PARAM_1, &pRow ) )
656 std::vector<sc::ColRowSpan> aRanges;
667 aRanges.emplace_back(nRow, nRow);
672 else if ( pReqArgs && (pHeight = pReqArgs->
GetItemIfSet( FID_ROW_HEIGHT )) )
695 pDlg->StartExecuteAsync([pDlg, pTabViewShell](sal_Int32 nResult){
712 case FID_ROW_OPT_HEIGHT:
732 pTabViewShell->
GetFrameWeld(),
"OptimalRowHeightDialog",
735 pDlg->StartExecuteAsync([pDlg, pTabViewShell](sal_Int32 nResult){
759 if ( pReqArgs && (pWidth = pReqArgs->
GetItemIfSet( FID_COL_WIDTH )) &&
760 pReqArgs->
HasItem( FN_PARAM_1, &pColumn ) )
762 std::vector<sc::ColRowSpan> aRanges;
773 aRanges.emplace_back(nColumn, nColumn);
778 else if ( pReqArgs && (pWidth = pReqArgs->
GetItemIfSet( FID_COL_WIDTH )) )
797 pTabViewShell->
GetFrameWeld(),
"ColWidthDialog", nCurHeight,
800 pDlg->StartExecuteAsync([pDlg, pTabViewShell](sal_Int32 nResult){
817 case FID_COL_OPT_WIDTH:
840 pDlg->StartExecuteAsync([pDlg, pTabViewShell](sal_Int32 nResult){
858 case FID_COL_OPT_DIRECT:
880 case SID_CELL_FORMAT_RESET:
889 case FID_MERGE_TOGGLE:
895 bool bCenter =
false;
904 case FID_MERGE_TOGGLE:
907 std::unique_ptr<SfxPoolItem> pItem;
908 if( rBindings.
QueryState( nSlot, pItem ) >= SfxItemState::DEFAULT )
917 bool bMoveContents =
false;
918 bool bApi = rReq.
IsAPI();
921 pReqArgs->
GetItemState(nSlot,
true, &pItem) == SfxItemState::SET )
923 assert(
dynamic_cast<const SfxBoolItem*
>( pItem) &&
"wrong item");
927 if (pTabViewShell->
MergeCells( bApi, bMoveContents, bCenter ))
929 if (!bApi && bMoveContents)
964 nEndCol,nEndRow,nEndTab );
966 if ( ( std::abs(nEndCol-nStartCol) > 1 )
967 && ( std::abs(nEndRow-nStartRow) > 1 ) )
975 size_t nIndex = std::distance(itBeg, it);
990 if ( pDlg->Execute() ==
RET_OK )
999 pTabViewShell->
AutoFormat( pDlg->GetIndex() );
1010 VclMessageType::Warning, VclButtonsType::Ok,
1011 ScResId(STR_INVALID_AFAREA)));
1035 case SID_ACCEPT_FORMULA:
1042 case SID_START_FORMULA:
1050 case SID_DATA_SELECT:
1054 case SID_DETECTIVE_FILLMODE:
1062 case FID_INPUTLINE_STATUS:
1063 OSL_FAIL(
"Execute from InputLine status");
1066 case SID_STATUS_DOCPOS:
1069 SID_NAVIGATOR, SfxCallMode::SYNCHRON|SfxCallMode::RECORD );
1074 OSL_FAIL(
"old slot SID_MARKAREA");
1078 OSL_FAIL(
"ScCellShell::Execute: unknown slot");
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
sal_uInt16 GetValue() const
const OUString & GetValue() const
void SetText(const OUString &rStr)
EditEngine * GetEditEngine() const
virtual VclPtr< AbstractScAutoFormatDlg > CreateScAutoFormatDlg(weld::Window *pParent, ScAutoFormat *pAutoFormat, const ScAutoFormatData *pSelFormatData, ScViewData &rViewData)=0
virtual VclPtr< AbstractScNewScenarioDlg > CreateScNewScenarioDlg(weld::Window *pParent, const OUString &rName, bool bEdit, bool bSheetProtected)=0
virtual VclPtr< AbstractScMetricInputDlg > CreateScMetricInputDlg(weld::Window *pParent, const OString &sDialogName, tools::Long nCurrent, tools::Long nDefault, FieldUnit eFUnit, sal_uInt16 nDecimals, tools::Long nMaximum, tools::Long nMinimum=0)=0
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
void Execute(SfxRequest &)
virtual void SetModified(bool=true) override
SC_DLLPUBLIC bool IsScenario(SCTAB nTab) const
SC_DLLPUBLIC bool GetTable(const OUString &rName, SCTAB &rTab) const
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
SC_DLLPUBLIC bool ValidNewTabName(const OUString &rName) const
static SC_DLLPUBLIC bool ValidTabName(const OUString &rName)
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
ScChangeTrack * GetChangeTrack() const
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
TranslateId GetMessageId() const
Stores and generates human readable descriptions for spreadsheet-functions, e.g. functions used in fo...
std::optional< OUString > mxFuncName
Function name.
List of spreadsheet functions.
const ScFuncDesc * GetFunction(sal_uInt32 nIndex) const
sal_uInt32 GetCount() const
Stores spreadsheet functions in categories, including a cumulative ('All') category and makes them ac...
virtual sal_uInt32 getCount() const override
static OUString GetCategoryName(sal_uInt32 _nCategoryNumber)
Returns name of category.
static SC_DLLPUBLIC sal_uInt16 nStdRowHeight
::tools::Long nLastColWidthExtra
static SC_DLLPUBLIC ScAutoFormat * GetOrCreateAutoFormat()
static ScFunctionList * GetStarCalcFunctionList()
static ScFunctionMgr * GetStarCalcFunctionMgr()
static SC_DLLPUBLIC ::tools::Long nLastRowHeightExtra
static void ClearAutoFormat()
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
bool IsMultiMarked() const
bool IsColumnMarked(SCCOL nCol) const
bool IsRowMarked(SCROW nRow) const
std::vector< sc::ColRowSpan > GetMarkedColSpans() const
std::vector< sc::ColRowSpan > GetMarkedRowSpans() const
ScInputHandler * GetInputHdl(ScTabViewShell *pViewSh=nullptr, bool bUseRef=true)
Input-Handler.
SC_DLLPUBLIC void SetRefDialog(sal_uInt16 nId, bool bVis, SfxViewFrame *pViewFrm=nullptr)
Reference dialogs.
SC_DLLPUBLIC void InputEnterHandler(ScEnterMode nBlockMode=ScEnterMode::NORMAL, bool bBeforeSavingInLOK=false)
void InputCancelHandler()
void SetAuditShell(bool bActive)
bool IsAuditShell() const
void UpdateInputHandler(bool bForce=false, bool bStopEditing=true)
void ExecuteCellFormatDlg(SfxRequest &rReq, const OString &rTabPage)
void SetDontSwitch(bool bFlag)
void LockModifiers(sal_uInt16 nModifiers)
sal_uInt16 GetLockedModifiers() const
void ResetBrushDocument()
void MarkDataArea(bool bIncludeCursor=true)
void ErrorMessage(TranslateId pGlobStrId)
void SetAutoSpellData(SCCOL nPosX, SCROW nPosY, const std::vector< editeng::MisspellRanges > *pRanges)
void SelectAll(bool bContinue=false)
bool HasHintWindow() const
bool HasPaintBrush() const
SfxDispatcher & GetDispatcher()
ScMarkData & GetMarkData()
ScDocument & GetDocument() const
ScDocShell * GetDocShell() const
ScTabViewShell * GetViewShell() const
ScMarkType GetSimpleArea(SCCOL &rStartCol, SCROW &rStartRow, SCTAB &rStartTab, SCCOL &rEndCol, SCROW &rEndRow, SCTAB &rEndTab) const
void SetMarkedWidthOrHeight(bool bWidth, ScSizeMode eMode, sal_uInt16 nSizeTwips)
void EnterData(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const EditTextObject *pData=nullptr, bool bMatrixExpand=false)
void SetWidthOrHeight(bool bWidth, const std::vector< sc::ColRowSpan > &rRanges, ScSizeMode eMode, sal_uInt16 nSizeTwips, bool bRecord=true, const ScMarkData *pMarkData=nullptr)
void DeleteContents(InsertDeleteFlags nFlags)
void MakeScenario(const OUString &rName, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags)
ScAutoFormatData * CreateAutoFormatData()
bool MergeCells(bool bApi, bool &rDoContents, bool bCenter)
void AutoFormat(sal_uInt16 nFormatNo)
void EnterMatrix(const OUString &rString, ::formula::FormulaGrammar::Grammar eGram)
void EnterBlock(const OUString &rString, const EditTextObject *pData)
void ApplyAttributes(const SfxItemSet *pDialogSet, const SfxItemSet *pOldSet, bool bAdjustBlockHeight=true)
static void SetFullScreen(const SfxViewShell &rViewShell, bool bSet)
Enters or leaves full screen mode at the passed view shell.
static bool IsFullScreen(const SfxViewShell &rViewShell)
Returns true, if the passed view shell is in full screen mode.
SfxItemState QueryState(sal_uInt16 nSID, std::unique_ptr< SfxPoolItem > &rpState)
bool Execute(sal_uInt16 nSlot, const SfxPoolItem **pArgs=nullptr, SfxCallMode nCall=SfxCallMode::SLOT)
void Invalidate(sal_uInt16 nId)
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
SfxItemPool * GetPool() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
bool HasItem(sal_uInt16 nWhich, const SfxPoolItem **ppItem=nullptr) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
void AppendItem(const SfxPoolItem &)
void Done(bool bRemove=false)
virtual void Invalidate(sal_uInt16 nId=0)
SfxBindings & GetBindings()
SfxChildWindow * GetChildWindow(sal_uInt16)
SfxFrame & GetFrame() const
bool isLOKMobilePhone() const
weld::Window * GetFrameWeld() const
SfxViewFrame & GetViewFrame() const
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
virtual void libreOfficeKitViewCallback(int nType, const char *pPayload) const override
constexpr ::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
constexpr sal_Int32 MAX_COL_WIDTH
@ EDITATTR
Drawing objects.
constexpr sal_Int32 MAX_EXTRA_WIDTH
constexpr sal_Int32 STD_EXTRA_WIDTH
constexpr sal_Int32 MAX_ROW_HEIGHT
constexpr sal_Int32 STD_COL_WIDTH
constexpr sal_Int32 MAX_EXTRA_HEIGHT
constexpr sal_uInt16 KEY_MOD1
constexpr sal_uInt16 KEY_SHIFT
std::unique_ptr< sal_Int32[]> pData
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
constexpr auto toTwips(N number, Length from)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
constexpr ::tools::Long TwipsToEvenHMM(::tools::Long nTwips)
OUString ScResId(TranslateId aId)
constexpr sal_uInt16 ATTR_PATTERN_START(100)
constexpr sal_uInt16 ATTR_PATTERN_END(155)
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW