22 #include <editeng/editeng.hxx>
31 #include <globstr.hrc>
36 #include <document.hxx>
39 #include <uiitems.hxx>
49 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
50 #include <inputwin.hxx>
59 OString escapeJSON(
const OUString &aStr)
61 OUString aEscaped = aStr;
62 aEscaped = aEscaped.replaceAll(
"\n",
" ");
63 aEscaped = aEscaped.replaceAll(
"\"",
"'");
67 void 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:
279 OUString aStr( static_cast<const SfxStringItem&>(pReqArgs->
283 if (pReqArgs->
HasItem(FN_PARAM_1, &pDontCommitItem))
284 bCommit = !(static_cast<const SfxBoolItem*>(pDontCommitItem)->GetValue());
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] ==
'-' ) )
360 pTabViewShell->
EnterData( aCursorPos.
Col(), aCursorPos.
Row(), aCursorPos.
Tab(), aString, pData );
364 pTabViewShell->
EnterData(aCursorPos.
Col(), aCursorPos.
Row(), aCursorPos.
Tab(), *pData);
369 if (nSlot == FID_INPUTLINE_ENTER)
382 rBindings.
Execute( SID_ENTER_STRING, aArgs );
393 else if (nSlot == FID_INPUTLINE_BLOCK)
395 pTabViewShell->
EnterBlock( aString,
nullptr );
415 case SID_OPENDLG_FUNCTION:
424 lcl_lokGetWholeFunctionList();
428 sal_uInt16
nId = SID_OPENDLG_FUNCTION;
438 case SID_OPENDLG_CONSOLIDATE:
440 sal_uInt16
nId = ScConsolidateDlgWrapper::GetChildWindowId();
448 case FID_CELL_FORMAT:
450 if ( pReqArgs !=
nullptr )
460 sal_uInt16 nWhich = 0;
463 if ( pReqArgs->
GetItemState( nWhich,
true, &pAttr ) == SfxItemState::SET )
464 aNewSet.Put( *pAttr );
477 case SID_ENABLE_HYPHENATION:
481 case SID_PROPERTY_PANEL_CELLTEXT_DLG:
485 case SID_CELL_FORMAT_BORDER:
489 case SID_CHAR_DLG_EFFECT:
493 case SID_OPENDLG_SOLVE:
495 sal_uInt16
nId = ScSolverDlgWrapper::GetChildWindowId();
503 case SID_OPENDLG_OPTSOLVER:
505 sal_uInt16
nId = ScOptSolverDlgWrapper::GetChildWindowId();
513 case SID_OPENDLG_TABOP:
515 sal_uInt16
nId = ScTabOpDlgWrapper::GetChildWindowId();
535 bool bExtend = rReq.
IsAPI();
539 VclMessageType::Question, VclButtonsType::YesNo,
540 ScResId(STR_UPDATE_SCENARIO)));
541 xQueryBox->set_default_response(
RET_YES);
542 bExtend = xQueryBox->run() ==
RET_YES;
551 else if( ! rReq.
IsAPI() )
554 VclMessageType::Warning, VclButtonsType::Ok,
572 aBaseName = aTmp +
"_" +
ScResId(STR_SCENARIO) +
"_";
577 OSL_ENSURE(bPrefix,
"invalid sheet name");
586 aName = aBaseName + OUString::number( i );
590 bValid = !rDoc.
GetTable( aName, nDummy );
593 while ( !bValid && i <=
MAXTAB + 2 );
595 if ( pReqArgs !=
nullptr )
598 OUString aArgComment;
600 aArgName = pItem->GetValue();
602 aArgComment = pItem->GetValue();
607 pTabViewShell->
MakeScenario( aArgName, aArgComment, aColor, nFlags );
621 pTabViewShell->
MakeScenario( aName, aComment, aColor, nFlags );
629 else if( ! rReq.
IsAPI() )
650 if ( pReqArgs && (pHeight = pReqArgs->
GetItemIfSet( FID_ROW_HEIGHT )) &&
651 pReqArgs->
HasItem( FN_PARAM_1, &pRow ) )
653 std::vector<sc::ColRowSpan> aRanges;
658 if ( rMark.
IsRowMarked( static_cast<SCROW>(nRow) ) )
664 aRanges.emplace_back(nRow, nRow);
669 else if ( pReqArgs && (pHeight = pReqArgs->
GetItemIfSet( FID_ROW_HEIGHT )) )
706 case FID_ROW_OPT_HEIGHT:
726 pTabViewShell->
GetFrameWeld(),
"OptimalRowHeightDialog",
749 if ( pReqArgs && (pWidth = pReqArgs->
GetItemIfSet( FID_COL_WIDTH )) &&
750 pReqArgs->
HasItem( FN_PARAM_1, &pColumn ) )
752 std::vector<sc::ColRowSpan> aRanges;
763 aRanges.emplace_back(nColumn, nColumn);
768 else if ( pReqArgs && (pWidth = pReqArgs->
GetItemIfSet( FID_COL_WIDTH )) )
787 pTabViewShell->
GetFrameWeld(),
"ColWidthDialog", nCurHeight,
803 case FID_COL_OPT_WIDTH:
839 case FID_COL_OPT_DIRECT:
861 case SID_CELL_FORMAT_RESET:
870 case FID_MERGE_TOGGLE:
872 if ( !
GetViewData().GetDocument().GetChangeTrack() )
876 bool bCenter =
false;
885 case FID_MERGE_TOGGLE:
888 std::unique_ptr<SfxPoolItem> pItem;
889 if( rBindings.
QueryState( nSlot, pItem ) >= SfxItemState::DEFAULT )
890 bMerge = !static_cast< SfxBoolItem* >( pItem.get() )->
GetValue();
898 bool bMoveContents =
false;
899 bool bApi = rReq.
IsAPI();
902 pReqArgs->
GetItemState(nSlot,
true, &pItem) == SfxItemState::SET )
904 assert(dynamic_cast<const SfxBoolItem*>( pItem) &&
"wrong item");
908 if (pTabViewShell->
MergeCells( bApi, bMoveContents, bCenter ))
910 if (!bApi && bMoveContents)
945 nEndCol,nEndRow,nEndTab );
947 if ( ( std::abs(nEndCol-nStartCol) > 1 )
948 && ( std::abs(nEndRow-nStartRow) > 1 ) )
956 size_t nIndex = std::distance(itBeg, it);
991 VclMessageType::Warning, VclButtonsType::Ok,
1016 case SID_ACCEPT_FORMULA:
1023 case SID_START_FORMULA:
1031 case SID_DATA_SELECT:
1035 case SID_DETECTIVE_FILLMODE:
1043 case FID_INPUTLINE_STATUS:
1044 OSL_FAIL(
"Execute from InputLine status");
1047 case SID_STATUS_DOCPOS:
1050 SID_NAVIGATOR, SfxCallMode::SYNCHRON|SfxCallMode::RECORD );
1055 OSL_FAIL(
"old slot SID_MARKAREA");
1059 OSL_FAIL(
"ScCellShell::Execute: unknown slot");
constexpr sal_Int32 STD_COL_WIDTH
ScMarkData & GetMarkData()
virtual sal_uInt32 getCount() const override
SfxViewFrame * GetViewFrame() const
List of spreadsheet functions.
constexpr sal_Int32 STD_EXTRA_WIDTH
void DeleteContents(InsertDeleteFlags nFlags)
void SelectAll(bool bContinue=false)
void MarkDataArea(bool bIncludeCursor=true)
void ResetBrushDocument()
ScDocShell * GetDocShell() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
SfxChildWindow * GetChildWindow(sal_uInt16)
constexpr sal_uInt16 KEY_MOD1
OUString ScResId(TranslateId aId)
bool isLOKMobilePhone() const
void ErrorMessage(TranslateId pGlobStrId)
constexpr auto toTwips(N number, Length from)
constexpr sal_uInt16 ATTR_PATTERN_START(100)
std::unique_ptr< sal_Int32[]> pData
SC_DLLPUBLIC bool ValidNewTabName(const OUString &rName) const
std::vector< sc::ColRowSpan > GetMarkedRowSpans() const
sal_uInt16 GetValue() const
const ContentProperties & rData
void EnterBlock(const OUString &rString, const EditTextObject *pData)
sal_uInt16 GetLockedModifiers() const
void SetAuditShell(bool bActive)
void Done(bool bRemove=false)
ScDocument & GetDocument() const
void SetAutoSpellData(SCCOL nPosX, SCROW nPosY, const std::vector< editeng::MisspellRanges > *pRanges)
static bool IsFullScreen(const SfxViewShell &rViewShell)
Returns true, if the passed view shell is in full screen mode.
constexpr::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
constexpr sal_Int32 MAX_EXTRA_HEIGHT
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
virtual short Execute()=0
void LockModifiers(sal_uInt16 nModifiers)
void SetDontSwitch(bool bFlag)
Stores spreadsheet functions in categories, including a cumulative ('All') category and makes them ac...
static void SetFullScreen(const SfxViewShell &rViewShell, bool bSet)
Enters or leaves full screen mode at the passed view shell.
void SetText(const OUString &rStr)
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
bool IsMultiMarked() const
SC_DLLPUBLIC void InputEnterHandler(ScEnterMode nBlockMode=ScEnterMode::NORMAL, bool bBeforeSavingInLOK=false)
SfxFrame & GetFrame() const
SC_DLLPUBLIC void SetRefDialog(sal_uInt16 nId, bool bVis, SfxViewFrame *pViewFrm=nullptr)
Reference dialogs.
static SfxViewShell * Current()
virtual void libreOfficeKitViewCallback(int nType, const char *pPayload) const override
SC_DLLPUBLIC bool GetTable(const OUString &rName, SCTAB &rTab) const
void AutoFormat(sal_uInt16 nFormatNo)
void UpdateInputHandler(bool bForce=false, bool bStopEditing=true)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
bool Execute(sal_uInt16 nSlot, const SfxPoolItem **pArgs=nullptr, SfxCallMode nCall=SfxCallMode::SLOT)
bool HasHintWindow() const
bool IsRowMarked(SCROW nRow) const
constexpr sal_Int32 MAX_COL_WIDTH
constexpr sal_Int32 MAX_EXTRA_WIDTH
ScTabViewShell * GetViewShell() const
static SC_DLLPUBLIC sal_uInt16 nStdRowHeight
static void ClearAutoFormat()
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
bool IsColumnMarked(SCCOL nCol) const
EditEngine * GetEditEngine() const
SfxBindings & GetBindings()
void ExecuteCellFormatDlg(SfxRequest &rReq, const OString &rTabPage)
const OUString & GetValue() const
::tools::Long nLastColWidthExtra
static ScFunctionMgr * GetStarCalcFunctionMgr()
ScMarkType GetSimpleArea(SCCOL &rStartCol, SCROW &rStartRow, SCTAB &rStartTab, SCCOL &rEndCol, SCROW &rEndRow, SCTAB &rEndTab) const
SfxItemState QueryState(sal_uInt16 nSID, std::unique_ptr< SfxPoolItem > &rpState)
static OUString GetCategoryName(sal_uInt32 _nCategoryNumber)
Returns name of category.
SfxItemPool * GetPool() const
TranslateId GetMessageId() const
constexpr sal_Int32 MAX_ROW_HEIGHT
const ScFuncDesc * GetFunction(sal_uInt32 nIndex) const
virtual VclPtr< AbstractScNewScenarioDlg > CreateScNewScenarioDlg(weld::Window *pParent, const OUString &rName, bool bEdit, bool bSheetProtected)=0
static ScFunctionList * GetStarCalcFunctionList()
constexpr::tools::Long TwipsToEvenHMM(::tools::Long nTwips)
bool IsAuditShell() const
bool HasPaintBrush() const
void EnterMatrix(const OUString &rString,::formula::FormulaGrammar::Grammar eGram)
sal_uInt16 GetSlot() const
std::optional< OUString > mxFuncName
Function name.
bool MergeCells(bool bApi, bool &rDoContents, bool bCenter)
weld::Window * GetFrameWeld() const
SC_DLLPUBLIC bool IsScenario(SCTAB nTab) const
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
static SC_DLLPUBLIC bool ValidTabName(const OUString &rName)
virtual void Invalidate(sal_uInt16 nId=0)
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
SfxDispatcher & GetDispatcher()
bool HasItem(sal_uInt16 nWhich, const SfxPoolItem **ppItem=nullptr) const
constexpr sal_uInt16 ATTR_PATTERN_END(155)
void SetWidthOrHeight(bool bWidth, const std::vector< sc::ColRowSpan > &rRanges, ScSizeMode eMode, sal_uInt16 nSizeTwips, bool bRecord=true, const ScMarkData *pMarkData=nullptr)
sal_uInt32 GetCount() const
virtual void GetScenarioData(OUString &rName, OUString &rComment, Color &rColor, ScScenarioFlags &rFlags) const =0
void InputCancelHandler()
virtual void SetModified(bool=true) override
void AppendItem(const SfxPoolItem &)
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
void SetMarkedWidthOrHeight(bool bWidth, ScSizeMode eMode, sal_uInt16 nSizeTwips)
void ApplyAttributes(const SfxItemSet *pDialogSet, const SfxItemSet *pOldSet, bool bAdjustBlockHeight=true)
ScInputHandler * GetInputHdl(ScTabViewShell *pViewSh=nullptr, bool bUseRef=true)
Input-Handler.
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
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
constexpr sal_uInt16 KEY_SHIFT
static SC_DLLPUBLIC ScAutoFormat * GetOrCreateAutoFormat()
static SC_DLLPUBLIC::tools::Long nLastRowHeightExtra
ScAutoFormatData * CreateAutoFormatData()
std::vector< sc::ColRowSpan > GetMarkedColSpans() const
Stores and generates human readable descriptions for spreadsheet-functions, e.g. functions used in fo...
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
void Execute(SfxRequest &)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
void EnterData(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const EditTextObject *pData=nullptr)
void MakeScenario(const OUString &rName, const OUString &rComment, const Color &rColor, ScScenarioFlags nFlags)