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 "{ \"wholeList\": true, "
91 "\"categories\": [ ");
94 sal_uInt32 nCategoryCount = pFuncManager->
getCount();
95 for (sal_uInt32 i = 0;
i < nCategoryCount; ++
i)
100 + escapeJSON(sCategoryName)
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 ) )
126 + OString::number(
static_cast<sal_Int64
>(nCurIndex))
134 "\"description\": \""
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:
279 OUString
aStr( pReqArgs->
Get( SID_ENTER_STRING ).GetValue() );
282 if (pReqArgs->
HasItem(FN_PARAM_1, &pDontCommitItem))
324 case SID_INSERT_MATRIX:
337 case FID_INPUTLINE_ENTER:
338 case FID_INPUTLINE_BLOCK:
339 case FID_INPUTLINE_MATRIX:
341 if( pReqArgs ==
nullptr )
346 Get( FID_INPUTLINE_STATUS ));
349 const OUString& aString = pStatusItem->
GetString();
354 if (nSlot == FID_INPUTLINE_BLOCK)
358 else if ( !aString.isEmpty() && ( aString[0] ==
'=' || aString[0] ==
'+' || aString[0] ==
'-' ) )
361 aString,
pData,
true );
370 if (nSlot == FID_INPUTLINE_ENTER)
383 rBindings.
Execute( SID_ENTER_STRING, aArgs );
395 else if (nSlot == FID_INPUTLINE_BLOCK)
397 pTabViewShell->
EnterBlock( aString,
nullptr );
417 case SID_OPENDLG_FUNCTION:
426 lcl_lokGetWholeFunctionList();
430 sal_uInt16
nId = SID_OPENDLG_FUNCTION;
440 case SID_OPENDLG_CONSOLIDATE:
442 sal_uInt16
nId = ScConsolidateDlgWrapper::GetChildWindowId();
450 case FID_CELL_FORMAT:
452 if ( pReqArgs !=
nullptr )
462 sal_uInt16 nWhich = 0;
465 if ( pReqArgs->
GetItemState( nWhich,
true, &pAttr ) == SfxItemState::SET )
466 aNewSet.
Put( *pAttr );
479 case SID_ENABLE_HYPHENATION:
483 case SID_PROPERTY_PANEL_CELLTEXT_DLG:
487 case SID_CELL_FORMAT_BORDER:
491 case SID_CHAR_DLG_EFFECT:
495 case SID_OPENDLG_SOLVE:
497 sal_uInt16
nId = ScSolverDlgWrapper::GetChildWindowId();
505 case SID_OPENDLG_OPTSOLVER:
507 sal_uInt16
nId = ScOptSolverDlgWrapper::GetChildWindowId();
515 case SID_OPENDLG_TABOP:
517 sal_uInt16
nId = ScTabOpDlgWrapper::GetChildWindowId();
537 bool bExtend = rReq.
IsAPI();
541 VclMessageType::Question, VclButtonsType::YesNo,
542 ScResId(STR_UPDATE_SCENARIO)));
543 xQueryBox->set_default_response(
RET_YES);
544 bExtend = xQueryBox->run() ==
RET_YES;
553 else if( ! rReq.
IsAPI() )
556 VclMessageType::Warning, VclButtonsType::Ok,
574 aBaseName = aTmp +
"_" +
ScResId(STR_SCENARIO) +
"_";
579 OSL_ENSURE(bPrefix,
"invalid sheet name");
588 aName = aBaseName + OUString::number(
i );
595 while ( !bValid &&
i <=
MAXTAB + 2 );
597 if ( pReqArgs !=
nullptr )
600 OUString aArgComment;
602 aArgName = pItem->GetValue();
604 aArgComment = pItem->GetValue();
609 pTabViewShell->
MakeScenario( aArgName, aArgComment, aColor, nFlags );
619 if ( pNewDlg->Execute() ==
RET_OK )
622 pNewDlg->GetScenarioData(
aName, aComment, aColor, nFlags );
631 else if( ! rReq.
IsAPI() )
652 if ( pReqArgs && (pHeight = pReqArgs->
GetItemIfSet( FID_ROW_HEIGHT )) &&
653 pReqArgs->
HasItem( FN_PARAM_1, &pRow ) )
655 std::vector<sc::ColRowSpan> aRanges;
666 aRanges.emplace_back(nRow, nRow);
671 else if ( pReqArgs && (pHeight = pReqArgs->
GetItemIfSet( FID_ROW_HEIGHT )) )
690 pTabViewShell->
GetFrameWeld(),
"RowHeightDialog", nCurHeight,
694 pDlg->StartExecuteAsync([pDlg, pTabViewShell](sal_Int32 nResult){
711 case FID_ROW_OPT_HEIGHT:
731 pTabViewShell->
GetFrameWeld(),
"OptimalRowHeightDialog",
734 pDlg->StartExecuteAsync([pDlg, pTabViewShell](sal_Int32 nResult){
758 if ( pReqArgs && (pWidth = pReqArgs->
GetItemIfSet( FID_COL_WIDTH )) &&
759 pReqArgs->
HasItem( FN_PARAM_1, &pColumn ) )
761 std::vector<sc::ColRowSpan> aRanges;
772 aRanges.emplace_back(nColumn, nColumn);
777 else if ( pReqArgs && (pWidth = pReqArgs->
GetItemIfSet( FID_COL_WIDTH )) )
796 pTabViewShell->
GetFrameWeld(),
"ColWidthDialog", nCurHeight,
799 pDlg->StartExecuteAsync([pDlg, pTabViewShell](sal_Int32 nResult){
816 case FID_COL_OPT_WIDTH:
839 pDlg->StartExecuteAsync([pDlg, pTabViewShell](sal_Int32 nResult){
857 case FID_COL_OPT_DIRECT:
879 case SID_CELL_FORMAT_RESET:
888 case FID_MERGE_TOGGLE:
894 bool bCenter =
false;
903 case FID_MERGE_TOGGLE:
906 std::unique_ptr<SfxPoolItem> pItem;
907 if( rBindings.
QueryState( nSlot, pItem ) >= SfxItemState::DEFAULT )
916 bool bMoveContents =
false;
917 bool bApi = rReq.
IsAPI();
920 pReqArgs->
GetItemState(nSlot,
true, &pItem) == SfxItemState::SET )
922 assert(
dynamic_cast<const SfxBoolItem*
>( pItem) &&
"wrong item");
926 if (pTabViewShell->
MergeCells( bApi, bMoveContents, bCenter ))
928 if (!bApi && bMoveContents)
963 nEndCol,nEndRow,nEndTab );
965 if ( ( std::abs(nEndCol-nStartCol) > 1 )
966 && ( std::abs(nEndRow-nStartRow) > 1 ) )
974 size_t nIndex = std::distance(itBeg, it);
989 if ( pDlg->Execute() ==
RET_OK )
998 pTabViewShell->
AutoFormat( pDlg->GetIndex() );
1009 VclMessageType::Warning, VclButtonsType::Ok,
1010 ScResId(STR_INVALID_AFAREA)));
1034 case SID_ACCEPT_FORMULA:
1041 case SID_START_FORMULA:
1049 case SID_DATA_SELECT:
1053 case SID_DETECTIVE_FILLMODE:
1061 case FID_INPUTLINE_STATUS:
1062 OSL_FAIL(
"Execute from InputLine status");
1065 case SID_STATUS_DOCPOS:
1068 SID_NAVIGATOR, SfxCallMode::SYNCHRON|SfxCallMode::RECORD );
1073 OSL_FAIL(
"old slot SID_MARKAREA");
1077 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< AbstractScMetricInputDlg > CreateScMetricInputDlg(weld::Window *pParent, const OUString &sDialogName, tools::Long nCurrent, tools::Long nDefault, FieldUnit eFUnit, sal_uInt16 nDecimals, tools::Long nMaximum, tools::Long nMinimum=0)=0
virtual VclPtr< AbstractScNewScenarioDlg > CreateScNewScenarioDlg(weld::Window *pParent, const OUString &rName, bool bEdit, bool bSheetProtected)=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)
sal_uInt16 GetSheetOptimalMinRowHeight(SCTAB nTab) const
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.
::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 OUString &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
virtual void libreOfficeKitViewCallback(int nType, const OString &pPayload) const override
SfxViewFrame & GetViewFrame() const
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
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