62#include <LibreOfficeKit/LibreOfficeKitEnums.h>
64#include <osl/diagnose.h>
67#include <inputwin.hxx>
79#include <document.hxx>
88#include <compiler.hxx>
92#include <tokenarray.hxx>
98#define RANGEFIND_MAX 128
104ScTypedCaseStrSet::const_iterator findText(
105 const ScTypedCaseStrSet& rDataSet, ScTypedCaseStrSet::const_iterator
const & itPos,
106 const OUString& rStart, OUString& rResult,
bool bBack)
113 ScTypedCaseStrSet::const_reverse_iterator it = rDataSet.rbegin(), itEnd = rDataSet.rend();
114 if (itPos != rDataSet.end())
116 size_t nPos = std::distance(rDataSet.begin(), itPos);
117 size_t nRPos = rDataSet.size() - 1 -
nPos;
118 std::advance(it, nRPos);
122 it = std::find_if(it, itEnd, lIsMatch);
125 rResult = it->GetString();
126 return (++it).base();
131 ScTypedCaseStrSet::const_iterator it = rDataSet.begin(), itEnd = rDataSet.end();
134 it = std::next(itPos);
137 it = std::find_if(it, itEnd, lIsMatch);
140 rResult = it->GetString();
145 return rDataSet.end();
148OUString getExactMatch(
const ScTypedCaseStrSet& rDataSet,
const OUString& rString)
150 auto it = std::find_if(rDataSet.begin(), rDataSet.end(),
152 return (rData.GetStringType() != ScTypedStrData::Value)
153 && ScGlobal::GetTransliteration().isEqual(rData.GetString(), rString);
155 if (it != rDataSet.end())
156 return it->GetString();
162sal_Int32 getLongestCommonPrefixLength(
const std::vector<OUString>& rResults, std::u16string_view aUserEntry, sal_Int32 nRingOrigin)
164 sal_Int32 nResults = rResults.size();
169 return rResults[0].getLength();
171 sal_Int32 nMinLen = aUserEntry.size();
172 sal_Int32 nLastIdx = nRingOrigin ? nRingOrigin - 1 : nResults - 1;
173 const OUString& rFirst = rResults[nRingOrigin];
174 const OUString& rLast = rResults[nLastIdx];
175 const sal_Int32 nMaxLen = std::min(rFirst.getLength(), rLast.getLength());
177 for (sal_Int32 nLen = nMaxLen; nLen > nMinLen; --nLen)
186ScTypedCaseStrSet::const_iterator findTextAll(
187 const ScTypedCaseStrSet& rDataSet, ScTypedCaseStrSet::const_iterator
const & itPos,
188 const OUString& rStart, ::std::vector< OUString > &rResultVec,
bool bBack, sal_Int32* pLongestPrefixLen =
nullptr)
192 if (!rDataSet.size())
193 return rDataSet.end();
195 sal_Int32 nRingOrigin = 0;
197 ScTypedCaseStrSet::const_iterator retit;
200 ScTypedCaseStrSet::const_reverse_iterator it, itEnd;
201 if ( itPos == rDataSet.end() )
203 it = rDataSet.rend();
209 it = rDataSet.rbegin();
210 size_t nPos = std::distance(rDataSet.begin(), itPos);
211 size_t nRPos = rDataSet.size() - 1 -
nPos;
212 std::advance(it, nRPos);
213 if ( it == rDataSet.rend() )
214 it = rDataSet.rbegin();
217 bool bFirstTime =
true;
219 while ( it != itEnd || bFirstTime )
222 if ( it == rDataSet.rend() )
224 it = rDataSet.rbegin();
243 retit = rDataSet.begin();
244 size_t nRPos = std::distance(rDataSet.rbegin(), it);
245 size_t nPos = rDataSet.size() - 1 - nRPos;
246 std::advance(retit,
nPos);
253 ScTypedCaseStrSet::const_iterator it, itEnd;
255 if ( it == rDataSet.end() )
256 it = --rDataSet.end();
258 bool bFirstTime =
true;
260 while ( it != itEnd || bFirstTime )
263 if ( it == rDataSet.end() )
265 it = rDataSet.begin();
287 if (pLongestPrefixLen)
289 if (nRingOrigin >=
static_cast<sal_Int32
>(
nCount))
296 *pLongestPrefixLen = getLongestCommonPrefixLength(rResultVec, rStart, nRingOrigin);
301 return rDataSet.end();
307 const std::vector<ReferenceMark>& rReferenceMarks )
316 ss <<
"{ \"marks\": [ ";
318 for (
size_t i = 0;
i < rReferenceMarks.size();
i++ )
320 if ( rReferenceMarks[
i].Is() )
325 ss <<
"{ \"rectangle\": \""
326 << rReferenceMarks[
i].nX <<
", "
327 << rReferenceMarks[
i].nY <<
", "
328 << rReferenceMarks[
i].nWidth <<
", "
329 << rReferenceMarks[
i].nHeight <<
"\", "
330 "\"color\": \"" << rReferenceMarks[
i].aColor.AsRGBHexString() <<
"\", "
331 "\"part\": \"" << rReferenceMarks[
i].nTab <<
"\" } ";
339 OString aPayload = ss.str().c_str();
341 LOK_CALLBACK_REFERENCE_MARKS, aPayload.getStr() );
358 sal_Int32 nColon = aDelimiters.indexOf(
':' );
360 aDelimiters = aDelimiters.replaceAt( nColon, 1,
u"");
361 sal_Int32 nDot = aDelimiters.indexOf(cSheetSep);
363 aDelimiters = aDelimiters.replaceAt( nDot, 1 ,
u"");
366 sal_Int32 nLen = rFormula.getLength();
368 sal_Int32 nStart = 0;
389 bool bSingleQuoted =
false;
396 bSingleQuoted = !bSingleQuoted;
398 else if (!bSingleQuoted)
410 if( nPos < nLen && nPos > 0 &&
420 OUString aTest = rFormula.copy( nStart,
nPos-nStart );
465 pDocSh->Broadcast(
SfxHint( SfxHintId::ScShowRangeFinder ) );
477 comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs))
479 SCCOL nCol1 = nX1, nCol2 = nX2;
480 SCROW nRow1 = nY1, nRow2 = nY2;
483 if (nCol1 == nCol2 && nRow1 == nRow2)
488 tools::Long nSizeX = aBottomRight.X() - aTopLeft.X() - 1;
489 tools::Long nSizeY = aBottomRight.Y() - aTopLeft.Y() - 1;
491 return ReferenceMark(aTopLeft.X(), aTopLeft.Y(), nSizeX, nSizeY, nTab, rColor);
534 if ( !pRangeFinder && !rViewData.
IsRefMode() )
537 sal_uInt16 nAdditionalMarks = 0;
538 std::vector<ReferenceMark> aReferenceMarks( 1 );
542 nAdditionalMarks = 1;
563 sal_uInt16
nCount = pRangeFinder ?
564 (
static_cast<sal_uInt16
>( pRangeFinder->
Count() ) + nAdditionalMarks ) : nAdditionalMarks;
565 aReferenceMarks.resize(
nCount );
570 for (sal_uInt16
i = 0;
i <
nCount - nAdditionalMarks;
i++)
596 aReferenceMarks.clear();
635 sal_Int32 nOldEnd = rData.
nSelEnd;
642 OUString aNewStr(aJustified.
Format(rDoc, rData.
nFlags, aAddrDetails));
643 ESelection aOldSel( 0, nOldStart, 0, nOldEnd );
676 OSL_FAIL(
"UpdateRange: we're missing something");
687 pDocSh->Broadcast(
SfxHint( SfxHintId::ScShowRangeFinder ) );
699 rStr = rStr.replace(
'\t',
' ');
705 rStr = rStr.replace(
'\n',
' ');
752 sal_Int32 nLen = rStr.getLength();
756 sal_uInt16 nQuotes = 0;
757 if (
nPos < nLen / 2 )
773 bool bLookInString = ((nQuotes % 2) != 0);
774 bool bInString = bLookInString;
776 p1 = (nDir < 0 ? p0 : p0 + nLen) ;
777 sal_uInt16 nLevel = 1;
778 while (
p != p1 && nLevel )
783 bInString = !bInString;
784 if ( bLookInString && !bInString )
787 else if ( bInString == bLookInString )
797 return static_cast<sal_Int32
>(
p - p0);
801 : pInputWin( nullptr ),
802 pTableView( nullptr ),
804 pTipVisibleParent( nullptr ),
805 nTipVisible( nullptr ),
806 pTipVisibleSecParent( nullptr ),
807 nTipVisibleSec( nullptr ),
810 nCellPercentFormatDecSep( 0 ),
817 bFormulaMode( false ),
818 bInRangeUpdate( false ),
819 bParenthesisShown( false ),
820 bCreatingFuncView( false ),
821 bInEnterHandler( false ),
822 bCommandErrorShown( false ),
823 bInOwnChange( false ),
825 bLastIsSymbol( false ),
826 mbDocumentDisposing(false),
827 mbPartialPrefix(false),
828 mbEditingExistingContent(false),
833 pRefViewSh( nullptr ),
834 pLastPattern( nullptr )
854 if (
SC_MOD()->GetRefInputHdl() ==
this)
855 SC_MOD()->SetRefInputHdl(
nullptr);
880 bool bTextWysiwyg =
SC_MOD()->GetInputOptions().GetTextWysiwyg();
883 if ( bTextWysiwyg || bInPlace )
884 nCtrl |= EEControlBits::FORMAT100;
923 mpEditEngine->SetReplaceLeadingSingleQuotationMark(
false );
937 nCntrl |= EEControlBits::AUTOCORRECT;
939 if ( nCntrl != nOld )
965 nCntrl |= EEControlBits::ONLINESPELLING;
972 nCntrl |= EEControlBits::AUTOCORRECT;
973 if ( nCntrl != nOld )
984 if ( bOnlineSpell ) {
1020 const sal_uInt32 nListCount = pFuncList->
GetCount();
1030 for (sal_uInt16
i = 0;
i < nMRUCount;
i++)
1032 const sal_uInt16
nId = pMRUList[
i];
1033 for (sal_uInt32 j = 0; j < nListCount; j++)
1038 const OUString aEntry = *pDesc->
mxFuncName + aParenthesesReplacement;;
1053 for (
auto iter = aStrSet.begin(); iter != aStrSet.end(); ++iter)
1057 for (sal_Int32 j = 0; j < aFuncName.getLength(); j++)
1066 if (rEvent.GetId() == VclEventId::ObjectDying || rEvent.GetId() == VclEventId::WindowHide
1067 || rEvent.GetId() == VclEventId::WindowLoseFocus || rEvent.GetId() == VclEventId::ControlLoseFocus)
1073 if (rEvent.GetId() == VclEventId::ObjectDying || rEvent.GetId() == VclEventId::WindowHide
1074 || rEvent.GetId() == VclEventId::WindowLoseFocus || rEvent.GetId() == VclEventId::ControlLoseFocus)
1104bool lcl_hasSingleToken(std::u16string_view s,
sal_Unicode c)
1106 return !s.empty() && s.find(c) == std::u16string_view::npos;
1122 bool bFound =
false;
1127 if( nLeftParentPos != -1 )
1129 sal_Int32 nNextFStart =
aHelper.GetFunctionStart( rSelText, nLeftParentPos,
true);
1131 ::std::vector< OUString> aArgs;
1132 if(
aHelper.GetNextFunc( rSelText,
false, nNextFStart,
nullptr, &ppFDesc, &aArgs ) )
1136 sal_Int32 nArgPos =
aHelper.GetArgStart( rSelText, nNextFStart, 0 );
1140 ScTypedCaseStrSet::const_iterator it =
1145 sal_uInt16 nActive = 0;
1146 for( sal_uInt16
i=0;
i < nArgs;
i++ )
1148 sal_Int32
nLength = aArgs[
i].getLength();
1149 if( nArgPos <= rSelText.getLength()-1 )
1158 sal_Int32 nStartPosition = 0;
1159 sal_Int32 nEndPosition = 0;
1161 if( lcl_hasSingleToken(aNew, cSep) )
1163 for (sal_Int32
i = 0;
i < aNew.getLength(); ++
i)
1168 nStartPosition =
i+1;
1172 else if( lcl_hasSingleToken(aNew, cSheetSep) )
1175 for (sal_Int32
i = 0;
i < aNew.getLength(); ++
i)
1180 nStartPosition =
i+1;
1182 else if( cNext == cSep )
1190 nStartPosition = nEndPosition+1;
1197 for (sal_Int32
i = 0;
i < aNew.getLength(); ++
i)
1202 nStartPosition =
i+1;
1204 else if( cNext == cSep )
1212 nStartPosition = nEndPosition+1;
1214 else if( cNext == cSheetSep )
1221 if (nStartPosition > 0)
1224 sal_Int16 nVarArgsSet = 0;
1235 if ( nVarArgsSet > 0 && nActive > nArgs )
1236 nActive = nArgs - (nActive - nArgs) % nVarArgsSet;
1237 aNew = OUString::Concat(aNew.subView(0, nStartPosition)) +
1239 aNew.subView(nStartPosition) +
1283 if ( aParagraph.getLength() < aSel.
nEndPos )
1288 OUString aSelText( aParagraph.copy( 0, aSel.
nEndPos ));
1309 aPos =
pInputWin->GetCursorScreenPixelPos();
1320 QuickHelpFlags const nAlign = QuickHelpFlags::Left|QuickHelpFlags::Bottom;
1337 aPos =
pInputWin->GetCursorScreenPixelPos(
true);
1344 Point aLogicPos = pCur->GetPos();
1345 aLogicPos.AdjustY(pCur->GetHeight() );
1352 QuickHelpFlags const nAlign = QuickHelpFlags::Left | QuickHelpFlags::Top | QuickHelpFlags::NoEvadePointer;
1359 if ( aStart.isEmpty() )
1363 sal_Int32
nPos = aStart.getLength() - 1;
1366 ::std::set< sal_Unicode >::const_iterator
p =
maFormulaChar.find( c );
1370 ::std::vector<sal_Unicode> aTemp { c };
1371 for(sal_Int32
i =
nPos - 1;
i >= 0; --
i)
1379 aTemp.push_back( c );
1382 ::std::vector<sal_Unicode>::reverse_iterator rIt = aTemp.rbegin();
1383 aResult = OUString( *rIt++ );
1384 while ( rIt != aTemp.rend() )
1385 aResult += OUStringChar( *rIt++ );
1392 OString escapeJSON(
const OUString &aStr)
1394 OUString aEscaped =
aStr;
1395 aEscaped = aEscaped.replaceAll(
"\n",
" ");
1396 aEscaped = aEscaped.replaceAll(
"\"",
"'");
1412 OUString aFuncNameStr;
1413 OUString aDescFuncNameStr;
1414 OStringBuffer aPayload;
1415 aPayload.append(
"[ ");
1416 for (
const OUString& rFunc : rFuncStrVec)
1420 aFuncNameStr = rFunc.copy(0, rFunc.getLength()-1);
1424 aFuncNameStr = rFunc;
1428 aDescFuncNameStr = aFuncNameStr +
"()";
1429 sal_Int32 nNextFStart = 0;
1431 ::std::vector< OUString > aArgs;
1432 OUString eqPlusFuncName =
"=" + aDescFuncNameStr;
1433 if (
aHelper.GetNextFunc( eqPlusFuncName,
false, nNextFStart,
nullptr, &ppFDesc, &aArgs ) )
1437 aPayload.append(
"{");
1438 aPayload.append(
"\"index\": ");
1439 aPayload.append(
static_cast<sal_Int64
>(nCurIndex));
1440 aPayload.append(
", ");
1441 aPayload.append(
"\"signature\": \"");
1443 aPayload.append(
"\", ");
1444 aPayload.append(
"\"description\": \"");
1446 aPayload.append(
"\"}, ");
1450 if (nCurIndex == nSize)
1453 sal_Int32 nLen = aPayload.getLength();
1454 aPayload[nLen - 2] =
' ';
1455 aPayload[nLen - 1] =
']';
1457 OString s = aPayload.makeStringAndClear();
1464 OUStringBuffer aTipStr;
1465 OUString aFuncNameStr;
1466 OUString aDescFuncNameStr;
1467 ::std::vector<OUString>::const_iterator itStr = rFuncStrVec.begin();
1468 sal_Int32 nMaxFindNumber = 3;
1469 sal_Int32 nRemainFindNumber = nMaxFindNumber;
1470 for ( ; itStr != rFuncStrVec.end(); ++itStr )
1472 const OUString& rFunc = *itStr;
1475 aFuncNameStr = rFunc.copy(0, rFunc.getLength()-1);
1479 aFuncNameStr = rFunc;
1481 if ( itStr == rFuncStrVec.begin() )
1484 aDescFuncNameStr = aFuncNameStr +
"()";
1488 aTipStr.append(
", ");
1490 aTipStr.append(aFuncNameStr);
1491 if ( itStr == rFuncStrVec.begin() )
1492 aTipStr.append(
"]");
1493 if ( --nRemainFindNumber <= 0 )
1496 sal_Int32 nRemainNumber = rFuncStrVec.size() - nMaxFindNumber;
1497 if ( nRemainFindNumber == 0 && nRemainNumber > 0 )
1499 OUString aMessage(
ScResId( STR_FUNCTIONS_FOUND ) );
1500 aMessage = aMessage.replaceFirst(
"%2", OUString::number(nRemainNumber));
1501 aMessage = aMessage.replaceFirst(
"%1", aTipStr);
1505 sal_Int32 nNextFStart = 0;
1507 ::std::vector< OUString > aArgs;
1508 OUString eqPlusFuncName =
"=" + aDescFuncNameStr;
1509 if (
aHelper.GetNextFunc( eqPlusFuncName,
false, nNextFStart,
nullptr, &ppFDesc, &aArgs ) )
1516 ShowTip( aTipStr.makeStringAndClear() );
1534 if ( aSel.
nEndPos > aParagraph.getLength() )
1537 if ( aParagraph.getLength() > aSel.
nEndPos &&
1539 aParagraph[ aSel.
nEndPos ] ==
'_' ||
1540 aParagraph[ aSel.
nEndPos ] ==
'.' ||
1541 aParagraph[ aSel.
nEndPos ] ==
'$' ) )
1548 OUString aSelText( aParagraph.copy( 0, aSel.
nEndPos ));
1555 ::std::vector<OUString> aNewVec;
1562 for (
int n = 0;
n < aSelText.getLength();
n++ )
1566 if (aSelText[
n] == cBetweenQuotes)
1569 else if ( aSelText[
n ] ==
'"' )
1570 cBetweenQuotes =
'"';
1571 else if ( aSelText[
n ] ==
'\'' )
1572 cBetweenQuotes =
'\'';
1574 if ( cBetweenQuotes )
1593 ::std::vector<OUString> aNewVec;
1609void completeFunction(
EditView* pView,
const OUString& rInsert,
bool& rParInserted )
1616 bool bNoInitialLetter =
false;
1629 bNoInitialLetter =
true;
1636 bNoInitialLetter =
true;
1643 if(!bNoInitialLetter)
1645 const sal_Int32 nMinLen = std::max(aSel.
nEndPos - aSel.
nStartPos, sal_Int32(1));
1657 for (sal_Int32 n = aAll.getLength(); n >= nMinLen && aMatch.isEmpty(); --n)
1659 const OUString aTest = aAll.copy(aAll.getLength() - n);
1668 OUString aInsStr = rInsert;
1669 sal_Int32 nInsLen = aInsStr.getLength();
1670 bool bDoParen = ( nInsLen > 1 && aInsStr[nInsLen-2] ==
'('
1671 && aInsStr[nInsLen-1] ==
')' );
1679 if (aWordSel.
nEndPos < aOld.getLength())
1685 aInsStr = aInsStr.copy( 0, nInsLen - 2 );
1699 rParInserted =
true;
1712 aInsert = OUString::Concat(aInsert.subView( 0, aInsert.getLength()-1)) +
"()";
1713 bool bParInserted =
false;
1716 completeFunction(
pTopView, aInsert, bParInserted );
1717 completeFunction(
pTableView, aInsert, bParInserted );
1755 aFormula = pEditEngine->
GetText(0);
1759 bEdit = aFormula.getLength() > 1 && (aFormula[0] ==
'=' || aFormula[0] ==
'+' || aFormula[0] ==
'-');
1764 OUString aNewFormula(
'=');
1765 if ( aFormula.startsWith(
"=") )
1766 aNewFormula = aFormula;
1774 ScTypedCaseStrSet::const_iterator aPos = findText(*
pFormulaData,
pFormulaData->begin(), rFunctionName, aNew,
false);
1786 const OUString& rText,
1789 OUString aSelection;
1794 OUString::number(rSelection.
nStartPara) +
";" + OUString::number(rSelection.
nEndPara);
1798 aSelection = OUString::number(rSelection.
nStartPos) +
";" + OUString::number(rSelection.
nEndPos) +
";" +
1799 OUString::number(rSelection.
nStartPara) +
";" + OUString::number(rSelection.
nEndPara);
1802 std::unique_ptr<jsdialog::ActionDataMap>
pData = std::make_unique<jsdialog::ActionDataMap>();
1803 (*pData)[
"action_type"] =
"setText";
1804 (*pData)[
"text"] = rText;
1805 (*pData)[
"selection"] = aSelection;
1807 sal_uInt64 nCurrentShellId =
reinterpret_cast<sal_uInt64
>(
pActiveViewSh);
1808 std::string sWindowId = std::to_string(nCurrentShellId) +
"formulabar";
1818 if(rFormula.isEmpty())
1821 std::optional<ScSimpleFormulaCalculator> pCalc( std::in_place, rDoc, rPos, rFormula,
false );
1825 bool bColRowName = pCalc->HasColRowName();
1829 if ( pCalc->GetCode()->GetCodeLen() <= 1 )
1832 OUString aBraced =
"(" + rFormula +
")";
1833 pCalc.emplace( rDoc, rPos, aBraced,
false );
1836 bColRowName =
false;
1840 if ( nErrCode != FormulaError::NONE )
1845 if ( pCalc->IsValue() )
1847 double n = pCalc->GetValue();
1855 OUString
aStr = pCalc->GetString().getString();
1859 const Color* pColor;
1864 aValue =
"\"" + aValue +
"\"";
1882 if (aPart.isEmpty())
1888 if (!aValue.isEmpty())
1904 sal_uInt32
const nTipLen2(sal::static_int_cast<sal_uInt32>(nTipLen));
1905 if ( nTipLen && ( nTipLen < 3 ||
aManualTip.subView( nTipLen2-3 ) !=
u"..." ) )
1930 if ( aInsert[0] ==
'"' )
1931 aInsert = aInsert.copy(1);
1932 sal_Int32 nInsLen = aInsert.getLength();
1933 if ( aInsert.endsWith(
"\"") )
1934 aInsert = aInsert.copy( 0, nInsLen-1 );
1978 if (
nPos < aFormula.getLength() && aFormula[
nPos] ==
')' )
2005 OSL_ENSURE(
nAutoPar,
"SkipClosingPar: count is wrong");
2023 std::vector<ScTypedStrData>
aEntries;
2047 if ( aSel.
nEndPos != nParLen )
2051 if (aText.isEmpty())
2054 std::vector< OUString > aResultVec;
2056 sal_Int32 nLongestPrefixLen = 0;
2061 if (nLongestPrefixLen <= 0 || aResultVec.empty())
2064 if (aResultVec.size() > 1)
2071 aNew = aResultVec[0].copy(0, nLongestPrefixLen);
2075 aNew = aResultVec[0];
2086 sal_Int32 nEdLen =
mpEditEngine->GetTextLen() + nParCnt - 1;
2087 OUString aIns = aNew.copy(nEdLen);
2125 if ( aSel.
nEndPos == nParLen && aText.getLength() ==
aAutoSearch.getLength() + nSelLen )
2128 ScTypedCaseStrSet::const_iterator itNew =
2139 OUString aIns = aNew.copy(
aAutoSearch.getLength());
2176 bool bFound =
false;
2188 if ( c ==
'(' || c ==
')' )
2251 SC_MOD()->SetRefInputHdl(
nullptr);
2261 OSL_FAIL(
"pActiveViewSh is gone");
2265 if (
SC_MOD()->GetInputOptions().GetTextWysiwyg() )
2290 if ( pWin==pShellWin )
2351 case SvxCellHorJustify::Standard:
2353 bool bNumber =
false;
2355 bNumber = (cTyped>=
'0' && cTyped<=
'9');
2361 eSvxAdjust = bNumber ? SvxAdjust::Right : SvxAdjust::Left;
2364 case SvxCellHorJustify::Block:
2365 eSvxAdjust = SvxAdjust::Block;
2367 case SvxCellHorJustify::Center:
2368 eSvxAdjust = SvxAdjust::Center;
2370 case SvxCellHorJustify::Right:
2371 eSvxAdjust = SvxAdjust::Right;
2374 eSvxAdjust = SvxAdjust::Left;
2381 if ( bAsianVertical )
2384 eSvxAdjust = SvxAdjust::Left;
2431 bool bNewTable =
false;
2456 bool bStartInputMode =
true;
2484 bStartInputMode =
false;
2488 if (bStartInputMode)
2504 sal_uInt32 nFormat = pItem->GetValue();
2579 if (
aStr.startsWith(
"{=") &&
aStr.endsWith(
"}") )
2589 if (
SC_MOD()->GetAppOptions().GetAutoComplete() )
2647 bool bSelectionForTopView =
false;
2649 bSelectionForTopView =
true;
2650 bool bSelectionForTableView =
false;
2652 bSelectionForTableView =
true;
2653 if (bSelectionForTopView || bSelectionForTableView)
2656 if (bSelectionForTopView)
2658 if (bSelectionForTableView)
2673 mpEditEngine && mpEditEngine->IsUpdateLayout() && pInputWin )
2679 pInputWin->SetTextString(aText);
2693 return StartTable( cTyped, bFromCommand,
false,
nullptr );
2762 bool bNeedGrow = ( rViewData.
GetEditAdjust() != SvxAdjust::Left );
2822 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScRefModeChanged ) );
2844 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScRefModeChanged ) );
2845 SC_MOD()->SetRefInputHdl(
nullptr);
2862 bool bFound =
false;
2865 while ( pOneFrame && !bFound )
2867 if ( pOneFrame == &rRefFrame )
2882 OSL_FAIL(
"ViewFrame for reference input is not here anymore");
2910 rBindings.
Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
2913 rBindings.
Invalidate( SID_ATTR_CHAR_WEIGHT );
2914 rBindings.
Invalidate( SID_ATTR_CHAR_POSTURE );
2915 rBindings.
Invalidate( SID_ATTR_CHAR_UNDERLINE );
2916 rBindings.
Invalidate( SID_ATTR_CHAR_OVERLINE );
2918 rBindings.
Invalidate( SID_ULINE_VAL_SINGLE );
2919 rBindings.
Invalidate( SID_ULINE_VAL_DOUBLE );
2920 rBindings.
Invalidate( SID_ULINE_VAL_DOTTED );
2922 rBindings.
Invalidate( SID_HYPERLINK_GETLINK );
2924 rBindings.
Invalidate( SID_ATTR_CHAR_KERNING );
2925 rBindings.
Invalidate( SID_SET_SUPER_SCRIPT );
2927 rBindings.
Invalidate( SID_ATTR_CHAR_STRIKEOUT );
2928 rBindings.
Invalidate( SID_ATTR_CHAR_SHADOWED );
2938 if (
eMode == eNewMode )
2981 sal_Int32 nLen =
mpEditEngine->GetText(nPara).getLength();
2993 SetSelection(
ESelection( nPara, nLen, nPara, nLen ) );
3011 if (eNewMode != eOldMode)
3022 size_t nLen = aString.size();
3023 for (
size_t i=0;
i<nLen;
i++)
3026 if ( c < '0' || c >
'9' )
3063 std::unique_ptr<EditTextObject>
pObject;
3064 std::unique_ptr<ScPatternAttr> pCellAttrs;
3065 bool bForget =
false;
3068 OUString aPreAutoCorrectString(aString);
3122 pSelEngine->ReleaseMouse();
3125 if (bBeforeSavingInLOK)
3155 std::vector<editeng::MisspellRanges> aMisspellRanges;
3157 const bool bUpdateLayout =
mpEditEngine->SetUpdateLayout(
true );
3177 bSpellErrors =
false;
3194 bool bUniformAttribs =
true;
3196 for (sal_Int32 nPara = 1; nPara < nParCnt; ++nPara)
3199 if (!(aPara1Attribs == aPara2Attribs))
3202 bUniformAttribs =
false;
3214 std::optional<SfxItemSet> pCommonAttrs;
3218 if ( eState == SfxItemState::SET &&
3223 if ( !pCommonAttrs )
3224 pCommonAttrs.emplace(
mpEditEngine->GetEmptyItemSet() );
3225 pCommonAttrs->Put( *pItem );
3232 pCellAttrs = std::make_unique<ScPatternAttr>(rDoc.
GetPool());
3233 pCellAttrs->GetFromEditItemSet( &*pCommonAttrs );
3240 bool bAttrib =
false;
3250 if (eState == SfxItemState::DONTCARE)
3252 else if (eState == SfxItemState::SET)
3266 if ( eFieldState == SfxItemState::DONTCARE || eFieldState == SfxItemState::SET )
3271 if ( eConvState == SfxItemState::DONTCARE || eConvState == SfxItemState::SET )
3289 else if (
SC_MOD()->GetAppOptions().GetAutoComplete())
3313 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScRefModeChanged ) );
3314 SC_MOD()->SetRefInputHdl(
nullptr);
3336 bool bInsertPreCorrectedString =
true;
3338 if (aString.startsWith(
"="))
3343 bInsertPreCorrectedString =
false;
3345 if( aReplace.isEmpty() )
3347 if( aReplace !=
"\"" )
3348 aString = aString.replaceAll( aReplace,
"\"" );
3351 if( aReplace.isEmpty() )
3353 if( aReplace !=
"\"" )
3354 aString = aString.replaceAll( aReplace,
"\"" );
3357 if( aReplace.isEmpty() )
3359 if( aReplace !=
"'" )
3360 aString = aString.replaceAll( aReplace,
"'" );
3363 if( aReplace.isEmpty() )
3365 if( aReplace !=
"'" )
3366 aString = aString.replaceAll( aReplace,
"'");
3370 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScKillEditViewNoPaint ) );
3376 sal_uInt16
nId = FID_INPUTLINE_ENTER;
3378 nId = FID_INPUTLINE_BLOCK;
3380 nId = FID_INPUTLINE_MATRIX;
3385 if ( bInsertPreCorrectedString && aString != aPreAutoCorrectString )
3389 aPreAutoCorrectString,
pObject.get());
3397 if ( !aMisspellRanges.empty() )
3400 aArgs[0] = &aItemCorrected;
3407 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScKillEditView ) );
3409 if ( bOldMod && pExecuteSh && pCellAttrs && !bForget )
3454 SC_MOD()->SetRefInputHdl(
nullptr);
3488 std::vector<ReferenceMark> aReferenceMarks;
3513 sal_Int32
nPos = aText.getLength() - 1;
3516 cLastChar = aText[
nPos];
3517 if (cLastChar !=
' ')
3522 bool bAppendSeparator = (cLastChar !=
'(' && cLastChar != cSep && cLastChar !=
'=');
3523 if (bAppendSeparator)
3541 bool bOtherDoc = (pThisDoc != &rDoc);
3599 switch(aAddrDetails.
eConv)
3604 aRefStr =
"[\'" + aFileName +
"']";
3608 aRefStr =
"\'" + aFileName +
"'#";
3622 bool bLOKShowSelect =
true;
3624 bLOKShowSelect =
false;
3643 OSL_FAIL(
"InsertFunction, not during input mode");
3653 OUString aText = rFuncName;
3690 OSL_FAIL(
"ClearText, not during input mode");
3718 bool bShift = aCode.
IsShift();
3719 bool bControl = aCode.
IsMod1();
3720 bool bAlt = aCode.
IsMod2();
3758 bool bDoEnter =
false;
3765 if ((
pInputWin && bInputLine && bControl != bShift) || (!bInputLine && bControl && !bShift))
3782 if ( bShift && bControl )
3795 if (bControl && !bAlt)
3881 if ( !aStrLoP.isEmpty() )
3890 if ( !aStrLoP.isEmpty() )
3936 if ( bUsed &&
SC_MOD()->GetAppOptions().GetAutoComplete() )
3945 if ( nChar && nChar != 8 && nChar != 127 &&
3946 KeyFuncType::CUT != eFunc)
3957 if ( bUsed && nChar ==
'(' )
3978 bool bSetModified = !bCursorKey;
4048 if ( rCEvt.
GetCommand() == CommandEventId::CursorPos )
4064 else if ( rCEvt.
GetCommand() == CommandEventId::QueryCharPosition )
4123 if ( rCEvt.
GetCommand() == CommandEventId::EndExtTextInput )
4160 if (bRepeat && !bForce)
4194 bool bIgnore =
false;
4212 bool bTxtMod =
false;
4220 else if ( bHadObject )
4227 if ( bTxtMod || bForce )
4270 bool bSheetLocal =
false;
4277 GetRangeAtBlock(
ScRange( rSPos, rEPos ), aPosStr, &bSheetLocal);
4279 if ( aPosStr.isEmpty() )
4284 if ( rSPos != rEPos )
4293 else if (bSheetLocal)
4303 bool bIsSuppressed =
pInputWin->IsAccessibilityEventsSuppressed(
false);
4304 pInputWin->SetAccessibilityEventsSuppressed(
true);
4306 pInputWin->SetAccessibilityEventsSuppressed(bIsSuppressed);
4322 if ( nCntrl & EEControlBits::ONLINESPELLING )
4323 mpEditEngine->SetControlWord( nCntrl & ~EEControlBits::ONLINESPELLING );
4382 if ( !(
nullptr == pLastState ||
SC_MOD()->IsFormulaMode() ||
SC_MOD()->IsRefDialogOpen()))
4387 if ( pViewFrm && pViewFrm->
GetChildWindow( SID_OPENDLG_FUNCTION ) )
4391 pInputWin->EnableButtons(
false );
4392 pInputWin->Disable();
4395 else if ( !bFormulaMode )
4397 bInOwnChange =
true;
4399 pActiveViewSh =
nullptr;
4400 mpEditEngine->SetTextCurrentDefaults( OUString() );
4403 pInputWin->SetPosString( OUString() );
4404 pInputWin->SetTextString( OUString() );
4405 pInputWin->Disable();
4408 bInOwnChange =
false;
4437 bool bFromTopNotify = ( bFromNotify && pView ==
pTopView );
4487 if ( eFieldState == SfxItemState::DONTCARE || eFieldState == SfxItemState::SET )
4490 std::unique_ptr<EditTextObject> pObj =
mpEditEngine->CreateTextObject();
4495 for (sal_Int32
i=0;
i<nParCnt;
i++)
4499 while ( nParCnt > 1 )
4501 sal_Int32 nLen = rDestEngine.
GetTextLen( 0 );
4551 if ( nStart <= nEnd )
4577 sal_Int32 nNewLen =
aStr.size();
4622 : aCursorPos ( rCurPos ),
4623 aStartPos ( rStartPos ),
4624 aEndPos ( rEndPos ),
4625 aString (
std::move( _aString )),
void applyStartToEndFlags(ScRefFlags &target, const ScRefFlags source)
void PutInOrder(T &nStart, T &nEnd)
SfxApplication * SfxGetpApp()
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
OUString uppercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
bool isLetterNumeric(const OUString &rStr, sal_Int32 nPos) const
bool IsTransparent() const
CommandEventId GetCommand() const
void QuickFormatDoc(bool bFull=false)
OUString GetText(LineEnd eEnd=LINEEND_LF) const
void SetText(const OUString &rStr)
void RemoveCharAttribs(sal_Int32 nPara, sal_uInt16 nWhich=0, bool bRemoveFeatures=false)
sal_Int32 GetParagraphCount() const
sal_Int32 GetTextLen() const
static rtl::Reference< SfxItemPool > CreatePool()
static bool DoesKeyMoveCursor(const KeyEvent &rKeyEvent)
void QuickInsertText(const OUString &rText, const ESelection &rSel)
static bool DoesKeyChangeText(const KeyEvent &rKeyEvent)
bool DeleteSurroundingText(const Selection &rRange)
void SetControlWord(EVControlBits nWord)
OUString GetSurroundingText() const
void RemoveCharAttribs(sal_Int32 nPara, sal_uInt16 nWhich)
ESelection GetSelection() const
void SelectCurrentWord(sal_Int16 nWordType=css::i18n::WordType::ANYWORD_IGNOREWHITESPACES)
void RegisterViewShell(OutlinerViewShell *pViewShell)
Selection GetSurroundingTextSelection() const
bool HasSelection() const
void SetSelection(const ESelection &rNewSel)
void InsertText(const OUString &rNew, bool bSelect=false, bool bLOKShowSelect=true)
bool PostKeyEvent(const KeyEvent &rKeyEvent, vcl::Window const *pFrameWin=nullptr)
sal_Int32 GetPosWithField(sal_Int32 nPara, sal_Int32 nPos) const
void ShowCursor(bool bGotoCursor=true, bool bForceVisCursor=true, bool bActivate=false)
vcl::Cursor * GetCursor() const
vcl::Window * GetWindow() const
EVControlBits GetControlWord() const
void CompleteAutoCorrect(vcl::Window const *pFrameWin=nullptr)
bool Command(const CommandEvent &rCEvt)
EditEngine * GetEditEngine() const
OUString GetSelected() const
bool SetEditEngineUpdateLayout(bool bUpdate)
static void * ShowPopover(vcl::Window *pParent, const tools::Rectangle &rScreenRect, const OUString &rText, QuickHelpFlags nStyle)
static void HidePopover(vcl::Window const *pParent, void *nId)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
sal_Unicode GetCharCode() const
const vcl::KeyCode & GetKeyCode() const
static css::uno::Reference< css::linguistic2::XSpellChecker1 > GetSpellChecker()
static css::uno::Reference< css::linguistic2::XHyphenator > GetHyphenator()
const OUString & getDoubleQuotationMarkStart() const
const OUString & getQuotationMarkStart() const
const OUString & getDoubleQuotationMarkEnd() const
const OUString & getQuotationMarkEnd() const
void Set(SCCOL nCol, SCROW nRow, SCTAB nTab)
SC_DLLPUBLIC void Format(OStringBuffer &r, ScRefFlags nFlags, const ScDocument *pDocument=nullptr, const Details &rDetails=detailsOOOa1) const
sal_uInt16 GetLRUFuncListCount() const
sal_uInt16 * GetLRUFuncList() const
bool GetAutoComplete() const
void DataPilotInput(const ScAddress &rPos, const OUString &rString)
virtual void SetModified(bool=true) override
const ScDocument & GetDocument() const
void PostEditView(ScEditEngineDefaulter *pEditEngine, const ScAddress &rCursorPos)
SC_DLLPUBLIC SfxItemPool * GetEnginePool() const
SC_DLLPUBLIC bool ExtendMerge(SCCOL nStartCol, SCROW nStartRow, SCCOL &rEndCol, SCROW &rEndRow, SCTAB nTab, bool bRefresh=false)
EEHorizontalTextDirection GetEditTextDirection(SCTAB nTab) const
SC_DLLPUBLIC SCCOL MaxCol() const
SC_DLLPUBLIC const ScValidationData * GetValidationEntry(sal_uInt32 nIndex) const
SC_DLLPUBLIC ScDocumentPool * GetPool()
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
void FillInfo(ScTableInfo &rTabInfo, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCTAB nTab, double fColScale, double fRowScale, bool bPageMode, bool bFormulaMode, const ScMarkData *pMarkData=nullptr)
SC_DLLPUBLIC SfxItemPool * GetEditPool() const
void GetDataEntries(SCCOL nCol, SCROW nRow, SCTAB nTab, std::vector< ScTypedStrData > &rStrings, bool bValidation=false)
Entries for selection list listbox (no numbers/formulas)
SC_DLLPUBLIC ScDPObject * GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const
SfxObjectShell * GetDocumentShell() const
bool ValidCol(SCCOL nCol) const
void ApplyAsianEditSettings(ScEditEngineDefaulter &rEngine)
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
SC_DLLPUBLIC CellType GetCellType(SCCOL nCol, SCROW nRow, SCTAB nTab) const
SC_DLLPUBLIC bool IsLayoutRTL(SCTAB nTab) const
SfxPrinter * GetPrinter(bool bCreateIfNotExist=true)
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
SC_DLLPUBLIC sal_Unicode GetSheetSeparator() const
Obtain the sheet separator corresponding to the document's grammar.
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
SC_DLLPUBLIC const ScDocOptions & GetDocOptions() const
void GetFormulaEntries(ScTypedCaseStrSet &rStrings)
Entries for Formula auto input.
void SetTextCurrentDefaults(const EditTextObject &rTextObject)
SetText and apply defaults already set.
void SetDefaultItem(const SfxPoolItem &rItem)
Set the item in the default ItemSet which is created if it doesn't exist yet.
static OUString ModifyDelimiters(const OUString &rOld)
static OUString GetMultilineString(const EditEngine &rEngine)
Retrieves string with paragraphs delimited by new lines (' ').
void TestSelection(const ScDocument &rDoc, const ScMarkData &rMark)
TranslateId GetMessageId() const
void TestSelectedBlock(const ScDocument &rDoc, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, const ScMarkData &rMark)
Stores and generates human readable descriptions for spreadsheet-functions, e.g. functions used in fo...
sal_uInt16 nFIndex
Unique function index.
std::optional< OUString > mxFuncName
Function name.
List of spreadsheet functions.
const ScFuncDesc * GetFunction(sal_uInt32 nIndex) const
sal_uInt32 GetCount() const
static const sal_Unicode * UnicodeStrChr(const sal_Unicode *pStr, sal_Unicode c)
strchr() functionality on unicode, as long as we need it for FormulaToken etc.
static LanguageType GetEditDefaultLanguage()
static SC_DLLPUBLIC ::utl::TransliterationWrapper & GetTransliteration()
static const InputHandlerFunctionNames & GetInputHandlerFunctionNames()
static SC_DLLPUBLIC LanguageType eLnge
static bool EETextObjEqual(const EditTextObject *pObj1, const EditTextObject *pObj2)
static ScFunctionList * GetStarCalcFunctionList()
static SC_DLLPUBLIC const LocaleDataWrapper & getLocaleData()
static OUString GetErrorString(FormulaError nErrNumber)
static ScFunctionMgr * GetStarCalcFunctionMgr()
static SC_DLLPUBLIC const CharClass & getCharClass()