22 #include <string_view>
59 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
63 #include <inputwin.hxx>
67 #include <uiitems.hxx>
70 #include <globstr.hrc>
74 #include <document.hxx>
83 #include <compiler.hxx>
87 #include <tokenarray.hxx>
93 #define RANGEFIND_MAX 128
105 const sal_Unicode cParenthesesReplacement = 0x0001;
107 ScTypedCaseStrSet::const_iterator findText(
108 const ScTypedCaseStrSet& rDataSet, ScTypedCaseStrSet::const_iterator
const & itPos,
109 const OUString& rStart, OUString& rResult,
bool bBack)
116 ScTypedCaseStrSet::const_reverse_iterator it = rDataSet.rbegin(), itEnd = rDataSet.rend();
117 if (itPos != rDataSet.end())
119 size_t nPos = std::distance(rDataSet.begin(), itPos);
120 size_t nRPos = rDataSet.size() - 1 - nPos;
121 std::advance(it, nRPos);
125 it = std::find_if(it, itEnd, lIsMatch);
128 rResult = it->GetString();
129 return (++it).base();
134 ScTypedCaseStrSet::const_iterator it = rDataSet.begin(), itEnd = rDataSet.end();
137 it = std::next(itPos);
140 it = std::find_if(it, itEnd, lIsMatch);
143 rResult = it->GetString();
148 return rDataSet.end();
151 OUString getExactMatch(
const ScTypedCaseStrSet& rDataSet,
const OUString& rString)
153 auto it = std::find_if(rDataSet.begin(), rDataSet.end(),
158 if (it != rDataSet.end())
159 return it->GetString();
163 ScTypedCaseStrSet::const_iterator findTextAll(
164 const ScTypedCaseStrSet& rDataSet, ScTypedCaseStrSet::const_iterator
const & itPos,
165 const OUString& rStart, ::std::vector< OUString > &rResultVec,
bool bBack)
170 ScTypedCaseStrSet::const_iterator retit;
173 ScTypedCaseStrSet::const_reverse_iterator it, itEnd;
174 if ( itPos == rDataSet.end() )
176 it = rDataSet.rend();
182 it = rDataSet.rbegin();
183 size_t nPos = std::distance(rDataSet.begin(), itPos);
184 size_t nRPos = rDataSet.size() - 1 - nPos;
185 std::advance(it, nRPos);
186 if ( it == rDataSet.rend() )
187 it = rDataSet.rbegin();
190 bool bFirstTime =
true;
192 while ( it != itEnd || bFirstTime )
195 if ( it == rDataSet.rend() )
196 it = rDataSet.rbegin();
213 retit = rDataSet.begin();
214 size_t nRPos = std::distance(rDataSet.rbegin(), it);
215 size_t nPos = rDataSet.size() - 1 - nRPos;
216 std::advance(retit, nPos);
223 ScTypedCaseStrSet::const_iterator it, itEnd;
225 if ( it == rDataSet.end() )
226 it = rDataSet.begin();
228 bool bFirstTime =
true;
230 while ( it != itEnd || bFirstTime )
233 if ( it == rDataSet.end() )
234 it = rDataSet.begin();
256 return rDataSet.end();
262 const std::vector<ReferenceMark>& rReferenceMarks )
269 std::stringstream ss;
271 ss <<
"{ \"marks\": [ ";
273 for (
size_t i = 0;
i < rReferenceMarks.size();
i++ )
275 if ( rReferenceMarks[
i].Is() )
280 ss <<
"{ \"rectangle\": \""
281 << rReferenceMarks[
i].nX <<
", "
282 << rReferenceMarks[
i].nY <<
", "
283 << rReferenceMarks[
i].nWidth <<
", "
284 << rReferenceMarks[
i].nHeight <<
"\", "
285 "\"color\": \"" << rReferenceMarks[
i].aColor.AsRGBHexString() <<
"\", "
286 "\"part\": \"" << rReferenceMarks[
i].nTab <<
"\" } ";
294 OString aPayload = ss.str().c_str();
296 LOK_CALLBACK_REFERENCE_MARKS, aPayload.getStr() );
302 if ( !pActiveViewSh || !
SC_MOD()->GetInputOptions().GetRangeFinder() )
313 sal_Int32 nColon = aDelimiters.indexOf(
':' );
315 aDelimiters = aDelimiters.replaceAt( nColon, 1,
"");
316 sal_Int32 nDot = aDelimiters.indexOf(cSheetSep);
318 aDelimiters = aDelimiters.replaceAt( nDot, 1 ,
"");
321 sal_Int32 nLen = rFormula.getLength();
323 sal_Int32 nStart = 0;
331 if ( pChar[nPos] ==
'"' )
334 while (nPos<nLen && pChar[nPos] !=
'"')
344 bool bSingleQuoted =
false;
349 if (pChar[nPos] ==
'\'')
351 bSingleQuoted = !bSingleQuoted;
353 else if (!bSingleQuoted)
365 if( nPos < nLen && nPos > 0 &&
366 '-' == pChar[nPos] &&
'[' == pChar[nPos-1] &&
375 OUString aTest = rFormula.copy( nStart, nPos-nStart );
382 aRange.
aStart.
SetTab( pActiveViewSh->GetViewData().GetTabNo() );
397 mpEditEngine->SetUpdateMode(
false );
404 SfxItemSet aSet( mpEditEngine->GetEmptyItemSet() );
406 mpEditEngine->QuickSetAttribs( aSet, aSel );
414 UpdateLokReferenceMarks();
418 mpEditEngine->SetUpdateMode(
true );
420 pDocSh->Broadcast(
SfxHint( SfxHintId::ScShowRangeFinder ) );
432 comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs))
434 SCCOL nCol1 = nX1, nCol2 = nX2;
435 SCROW nRow1 = nY1, nRow2 = nY2;
438 if (nCol1 == nCol2 && nRow1 == nRow2)
443 tools::Long nSizeX = aBottomRight.X() - aTopLeft.X() - 1;
444 tools::Long nSizeY = aBottomRight.Y() - aTopLeft.Y() - 1;
446 return ReferenceMark(aTopLeft.X(), aTopLeft.Y(), nSizeX, nSizeY, nTab, rColor);
461 nTab, nPPTX, nPPTY,
false,
false );
489 if ( !pRangeFinder && !rViewData.
IsRefMode() )
492 sal_uInt16 nAdditionalMarks = 0;
493 std::vector<ReferenceMark> aReferenceMarks( 1 );
497 nAdditionalMarks = 1;
515 sal_uInt16
nCount = pRangeFinder ?
516 (
static_cast<sal_uInt16
>( pRangeFinder->
Count() ) + nAdditionalMarks ) : nAdditionalMarks;
517 aReferenceMarks.resize( nCount );
519 if ( nCount && pRangeFinder && !pRangeFinder->
IsHidden() &&
522 for (sal_uInt16
i = 0;
i < nCount - nAdditionalMarks;
i++)
548 aReferenceMarks.clear();
555 mbDocumentDisposing = b;
582 ScTabViewShell* pDocView = pRefViewSh ? pRefViewSh : pActiveViewSh;
583 if ( pDocView && pRangeFindList && nIndex < pRangeFindList->
Count() )
587 sal_Int32 nOldEnd = rData.
nSelEnd;
588 Color nNewColor = pRangeFindList->FindColor( rNew, nIndex );
594 OUString aNewStr(aJustified.
Format(rDoc, rData.
nFlags, aAddrDetails));
595 ESelection aOldSel( 0, nOldStart, 0, nOldEnd );
596 SfxItemSet aSet( mpEditEngine->GetEmptyItemSet() );
603 mpEditEngine->QuickSetAttribs( aSet, aOldSel );
605 bInRangeUpdate =
true;
607 bInRangeUpdate =
false;
615 sal_uInt16
nCount =
static_cast<sal_uInt16
>(pRangeFindList->Count());
616 for (sal_uInt16
i=nIndex+1;
i<nCount;
i++)
623 EditView* pActiveView = pTopView ? pTopView : pTableView;
628 OSL_FAIL(
"UpdateRange: we're missing something");
634 ScTabViewShell* pPaintView = pRefViewSh ? pRefViewSh : pActiveViewSh;
635 if ( pRangeFindList && pPaintView )
638 pRangeFindList->SetHidden(
true);
639 pDocSh->Broadcast(
SfxHint( SfxHintId::ScShowRangeFinder ) );
640 pRangeFindList.reset();
651 rStr = rStr.replace(
'\t',
' ');
657 rStr = rStr.replace(
'\n',
' ');
704 sal_Int32 nLen = rStr.getLength();
708 sal_uInt16 nQuotes = 0;
709 if ( nPos < nLen / 2 )
725 bool bLookInString = ((nQuotes % 2) != 0);
726 bool bInString = bLookInString;
728 p1 = (nDir < 0 ? p0 : p0 + nLen) ;
729 sal_uInt16 nLevel = 1;
730 while ( p != p1 && nLevel )
735 bInString = !bInString;
736 if ( bLookInString && !bInString )
739 else if ( bInString == bLookInString )
749 return static_cast<sal_Int32
>(p - p0);
753 : pInputWin( nullptr ),
754 pTableView( nullptr ),
756 pTipVisibleParent( nullptr ),
757 nTipVisible( nullptr ),
758 pTipVisibleSecParent( nullptr ),
759 nTipVisibleSec( nullptr ),
762 nCellPercentFormatDecSep( 0 ),
769 bFormulaMode( false ),
770 bInRangeUpdate( false ),
771 bParenthesisShown( false ),
772 bCreatingFuncView( false ),
773 bInEnterHandler( false ),
774 bCommandErrorShown( false ),
775 bInOwnChange( false ),
777 bLastIsSymbol( false ),
778 mbDocumentDisposing(false),
783 pRefViewSh( nullptr ),
784 pLastPattern( nullptr ),
811 if (
SC_MOD()->GetRefInputHdl() ==
this)
812 SC_MOD()->SetRefInputHdl(
nullptr);
837 bool bTextWysiwyg =
SC_MOD()->GetInputOptions().GetTextWysiwyg();
840 if ( bTextWysiwyg || bInPlace )
841 nCtrl |= EEControlBits::FORMAT100;
880 mpEditEngine->SetReplaceLeadingSingleQuotationMark(
false );
894 nCntrl |= EEControlBits::AUTOCORRECT;
896 if ( nCntrl != nOld )
922 nCntrl |= EEControlBits::ONLINESPELLING;
927 nCntrl &= ~EEControlBits::AUTOCORRECT;
929 nCntrl |= EEControlBits::AUTOCORRECT;
930 if ( nCntrl != nOld )
941 if ( bOnlineSpell ) {
975 const OUString aParenthesesReplacement( cParenthesesReplacement);
977 sal_uInt32 nListCount = pFuncList->
GetCount();
978 for(sal_uInt32
i=0;
i<nListCount;
i++)
984 const sal_Int32 nLen = pDesc->
mxFuncName->getLength();
986 for ( sal_Int32 j = 0; j < nLen; j++ )
991 OUString aFuncName = *pDesc->
mxFuncName + aParenthesesReplacement;
1005 if (rEvent.GetId() == VclEventId::ObjectDying || rEvent.GetId() == VclEventId::WindowHide
1006 || rEvent.GetId() == VclEventId::WindowLoseFocus)
1012 if (rEvent.GetId() == VclEventId::ObjectDying || rEvent.GetId() == VclEventId::WindowHide
1013 || rEvent.GetId() == VclEventId::WindowLoseFocus)
1043 bool lcl_hasSingleToken(
const OUString& s,
sal_Unicode c)
1045 return !s.isEmpty() && s.indexOf(c)<0;
1061 bool bFound =
false;
1066 if( nLeftParentPos != -1 )
1068 sal_Int32 nNextFStart = aHelper.
GetFunctionStart( rSelText, nLeftParentPos,
true);
1070 ::std::vector< OUString> aArgs;
1071 if( aHelper.
GetNextFunc( rSelText,
false, nNextFStart,
nullptr, &ppFDesc, &aArgs ) )
1075 sal_Int32 nArgPos = aHelper.
GetArgStart( rSelText, nNextFStart, 0 );
1079 ScTypedCaseStrSet::const_iterator it =
1084 sal_uInt16 nActive = 0;
1085 for( sal_uInt16
i=0;
i < nArgs;
i++ )
1087 sal_Int32
nLength = aArgs[
i].getLength();
1088 if( nArgPos <= rSelText.getLength()-1 )
1097 sal_Int32 nStartPosition = 0;
1098 sal_Int32 nEndPosition = 0;
1100 if( lcl_hasSingleToken(aNew, cSep) )
1102 for (sal_Int32
i = 0;
i < aNew.getLength(); ++
i)
1107 nStartPosition =
i+1;
1111 else if( lcl_hasSingleToken(aNew, cSheetSep) )
1114 for (sal_Int32
i = 0;
i < aNew.getLength(); ++
i)
1119 nStartPosition =
i+1;
1121 else if( cNext == cSep )
1125 if( nCount == nActive )
1129 nStartPosition = nEndPosition+1;
1136 for (sal_Int32
i = 0;
i < aNew.getLength(); ++
i)
1141 nStartPosition =
i+1;
1143 else if( cNext == cSep )
1147 if( nCount == nActive )
1151 nStartPosition = nEndPosition+1;
1153 else if( cNext == cSheetSep )
1160 if (nStartPosition > 0)
1162 OUStringBuffer
aBuf;
1163 aBuf.append(std::u16string_view(aNew).substr(0, nStartPosition));
1164 aBuf.append(
u'\x25BA');
1165 aBuf.append(std::u16string_view(aNew).substr(nStartPosition));
1167 sal_Int16 nVarArgsSet = 0;
1178 if ( nVarArgsSet > 0 && nActive > nArgs )
1179 nActive = nArgs - (nActive - nArgs) % nVarArgsSet;
1180 aBuf.append(
" : " );
1182 aNew = aBuf.makeStringAndClear();
1223 if ( aParagraph.getLength() < aSel.
nEndPos )
1228 OUString aSelText( aParagraph.copy( 0, aSel.
nEndPos ));
1260 QuickHelpFlags const nAlign = QuickHelpFlags::Left|QuickHelpFlags::Bottom;
1284 Point aLogicPos = pCur->GetPos();
1285 aLogicPos.AdjustY(pCur->GetHeight() );
1292 QuickHelpFlags const nAlign = QuickHelpFlags::Left | QuickHelpFlags::Top | QuickHelpFlags::NoEvadePointer;
1299 if ( aStart.isEmpty() )
1303 sal_Int32
nPos = aStart.getLength() - 1;
1306 ::std::set< sal_Unicode >::const_iterator
p =
maFormulaChar.find( c );
1310 ::std::vector<sal_Unicode> aTemp;
1311 aTemp.push_back( c );
1312 for(sal_Int32
i = nPos - 1;
i >= 0; --
i)
1320 aTemp.push_back( c );
1323 ::std::vector<sal_Unicode>::reverse_iterator rIt = aTemp.rbegin();
1324 aResult = OUString( *rIt++ );
1325 while ( rIt != aTemp.rend() )
1326 aResult += OUStringChar( *rIt++ );
1333 OString escapeJSON(
const OUString &aStr)
1335 OUString aEscaped = aStr;
1336 aEscaped = aEscaped.replaceAll(
"\n",
" ");
1337 aEscaped = aEscaped.replaceAll(
"\"",
"'");
1348 if (rFuncStrVec.size())
1354 OUString aFuncNameStr;
1355 OUString aDescFuncNameStr;
1356 OStringBuffer aPayload;
1357 aPayload.append(
"[ ");
1358 for (
const OUString& rFunc : rFuncStrVec)
1360 if ( rFunc[rFunc.getLength()-1] == cParenthesesReplacement )
1362 aFuncNameStr = rFunc.copy(0, rFunc.getLength()-1);
1366 aFuncNameStr = rFunc;
1370 aDescFuncNameStr = aFuncNameStr +
"()";
1371 sal_Int32 nNextFStart = 0;
1373 ::std::vector< OUString > aArgs;
1374 OUString eqPlusFuncName =
"=" + aDescFuncNameStr;
1375 if ( aHelper.
GetNextFunc( eqPlusFuncName,
false, nNextFStart,
nullptr, &ppFDesc, &aArgs ) )
1379 aPayload.append(
"{");
1380 aPayload.append(
"\"index\": ");
1381 aPayload.append(OString::number(nCurIndex));
1382 aPayload.append(
", ");
1383 aPayload.append(
"\"signature\": \"");
1385 aPayload.append(
"\", ");
1386 aPayload.append(
"\"description\": \"");
1388 aPayload.append(
"\"}, ");
1392 if (nCurIndex == nSize)
1395 sal_Int32 nLen = aPayload.getLength();
1396 aPayload[nLen - 2] =
' ';
1397 aPayload[nLen - 1] =
']';
1399 OString s = aPayload.makeStringAndClear();
1405 OUStringBuffer aTipStr;
1406 OUString aFuncNameStr;
1407 OUString aDescFuncNameStr;
1408 ::std::vector<OUString>::const_iterator itStr = rFuncStrVec.begin();
1409 sal_Int32 nMaxFindNumber = 3;
1410 sal_Int32 nRemainFindNumber = nMaxFindNumber;
1411 for ( ; itStr != rFuncStrVec.end(); ++itStr )
1413 const OUString& rFunc = *itStr;
1414 if ( rFunc[rFunc.getLength()-1] == cParenthesesReplacement )
1416 aFuncNameStr = rFunc.copy(0, rFunc.getLength()-1);
1420 aFuncNameStr = rFunc;
1422 if ( itStr == rFuncStrVec.begin() )
1425 aDescFuncNameStr = aFuncNameStr +
"()";
1429 aTipStr.append(
", ");
1431 aTipStr.append(aFuncNameStr);
1432 if ( itStr == rFuncStrVec.begin() )
1433 aTipStr.append(
"]");
1434 if ( --nRemainFindNumber <= 0 )
1437 sal_Int32 nRemainNumber = rFuncStrVec.size() - nMaxFindNumber;
1438 if ( nRemainFindNumber == 0 && nRemainNumber > 0 )
1440 OUString aMessage(
ScResId( STR_FUNCTIONS_FOUND ) );
1441 aMessage = aMessage.replaceFirst(
"%2", OUString::number(nRemainNumber));
1442 aMessage = aMessage.replaceFirst(
"%1", aTipStr.makeStringAndClear());
1446 sal_Int32 nNextFStart = 0;
1448 ::std::vector< OUString > aArgs;
1449 OUString eqPlusFuncName =
"=" + aDescFuncNameStr;
1450 if ( aHelper.
GetNextFunc( eqPlusFuncName,
false, nNextFStart,
nullptr, &ppFDesc, &aArgs ) )
1457 ShowTip( aTipStr.makeStringAndClear() );
1475 if ( aSel.
nEndPos > aParagraph.getLength() )
1478 if ( aParagraph.getLength() > aSel.
nEndPos &&
1480 aParagraph[ aSel.
nEndPos ] ==
'_' ||
1481 aParagraph[ aSel.
nEndPos ] ==
'.' ||
1482 aParagraph[ aSel.
nEndPos ] ==
'$' ) )
1489 OUString aSelText( aParagraph.copy( 0, aSel.
nEndPos ));
1496 ::std::vector<OUString> aNewVec;
1503 for (
int n = 0;
n < aSelText.getLength();
n++ )
1507 if (aSelText[
n] == cBetweenQuotes)
1510 else if ( aSelText[
n ] ==
'"' )
1511 cBetweenQuotes =
'"';
1512 else if ( aSelText[
n ] ==
'\'' )
1513 cBetweenQuotes =
'\'';
1515 if ( cBetweenQuotes )
1534 ::std::vector<OUString> aNewVec;
1550 void completeFunction(
EditView* pView,
const OUString& rInsert,
bool& rParInserted )
1557 bool bNoInitialLetter =
false;
1570 bNoInitialLetter =
true;
1577 bNoInitialLetter =
true;
1584 if(!bNoInitialLetter)
1586 const sal_Int32 nMinLen = std::max(aSel.
nEndPos - aSel.
nStartPos, sal_Int32(1));
1598 for (sal_Int32 n = aAll.getLength();
n >= nMinLen && aMatch.isEmpty(); --
n)
1600 const OUString aTest = aAll.copy(aAll.getLength() -
n);
1609 OUString aInsStr = rInsert;
1610 sal_Int32 nInsLen = aInsStr.getLength();
1611 bool bDoParen = ( nInsLen > 1 && aInsStr[nInsLen-2] ==
'('
1612 && aInsStr[nInsLen-1] ==
')' );
1620 if (aWordSel.
nEndPos < aOld.getLength())
1626 aInsStr = aInsStr.copy( 0, nInsLen - 2 );
1640 rParInserted =
true;
1652 if (aInsert[aInsert.getLength()-1] == cParenthesesReplacement)
1653 aInsert = OUString::Concat(aInsert.subView( 0, aInsert.getLength()-1)) +
"()";
1654 bool bParInserted =
false;
1657 completeFunction(
pTopView, aInsert, bParInserted );
1658 completeFunction(
pTableView, aInsert, bParInserted );
1684 aFormula = pEditEngine->
GetText(0);
1685 bEdit = aFormula.getLength() > 1 && (aFormula[0] ==
'=' || aFormula[0] ==
'+' || aFormula[0] ==
'-');
1690 OUString aNewFormula(
'=');
1691 if ( aFormula.startsWith(
"=") )
1692 aNewFormula = aFormula;
1700 ScTypedCaseStrSet::const_iterator aPos = findText(*
pFormulaData,
pFormulaData->begin(), rFunctionName, aNew,
false);
1716 if(rFormula.isEmpty())
1723 bool bColRowName = pCalc->HasColRowName();
1727 if ( pCalc->GetCode()->GetCodeLen() <= 1 )
1730 OUString aBraced =
"(" + rFormula +
")";
1734 bColRowName =
false;
1738 if ( nErrCode != FormulaError::NONE )
1743 if ( pCalc->IsValue() )
1745 double n = pCalc->GetValue();
1753 OUString aStr = pCalc->GetString().getString();
1757 const Color* pColor;
1762 aValue =
"\"" + aValue +
"\"";
1780 if (aPart.isEmpty())
1786 if (!aValue.isEmpty())
1802 sal_uInt32
const nTipLen2(sal::static_int_cast<sal_uInt32>(nTipLen));
1803 if ( nTipLen && ( nTipLen < 3 ||
aManualTip.subView( nTipLen2-3 ) !=
u"..." ) )
1828 if ( aInsert[0] ==
'"' )
1829 aInsert = aInsert.copy(1);
1830 sal_Int32 nInsLen = aInsert.getLength();
1831 if ( aInsert.endsWith(
"\"") )
1832 aInsert = aInsert.copy( 0, nInsLen-1 );
1876 if ( nPos < aFormula.getLength() && aFormula[nPos] ==
')' )
1903 OSL_ENSURE(
nAutoPar,
"SkipClosingPar: count is wrong");
1921 std::vector<ScTypedStrData>
aEntries;
1924 if (!aEntries.empty())
1925 pColumnData->insert(aEntries.begin(), aEntries.end());
1945 if ( aSel.
nEndPos != nParLen )
1949 if (aText.isEmpty())
1966 sal_Int32 nEdLen =
mpEditEngine->GetTextLen() + nParCnt - 1;
1967 OUString aIns = aNew.copy(nEdLen);
1988 if (aText.getLength() == aNew.getLength())
1992 ScTypedCaseStrSet::const_iterator itNextPos =
2016 if ( aSel.
nEndPos == nParLen && aText.getLength() ==
aAutoSearch.getLength() + nSelLen )
2019 ScTypedCaseStrSet::const_iterator itNew =
2029 OUString aIns = aNew.copy(
aAutoSearch.getLength());
2066 bool bFound =
false;
2078 if ( c ==
'(' || c ==
')' )
2091 for (sal_Int32
i=0;
i<nCount;
i++)
2097 ESelection aSelOther( 0,nOther, 0,nOther+1 );
2117 for (sal_Int32
i=0;
i<nCount;
i++)
2140 SC_MOD()->SetRefInputHdl(
nullptr);
2150 OSL_FAIL(
"pActiveViewSh is gone");
2154 if (
SC_MOD()->GetInputOptions().GetTextWysiwyg() )
2175 for (sal_uInt16
i=1;
i<nCount;
i++)
2179 if ( pWin==pShellWin )
2240 case SvxCellHorJustify::Standard:
2242 bool bNumber =
false;
2244 bNumber = (cTyped>=
'0' && cTyped<=
'9');
2250 eSvxAdjust = bNumber ? SvxAdjust::Right : SvxAdjust::Left;
2253 case SvxCellHorJustify::Block:
2254 eSvxAdjust = SvxAdjust::Block;
2256 case SvxCellHorJustify::Center:
2257 eSvxAdjust = SvxAdjust::Center;
2259 case SvxCellHorJustify::Right:
2260 eSvxAdjust = SvxAdjust::Right;
2263 eSvxAdjust = SvxAdjust::Left;
2270 if ( bAsianVertical )
2273 eSvxAdjust = SvxAdjust::Left;
2307 for (sal_Int32
i=0;
i<nCount;
i++)
2320 bool bNewTable =
false;
2345 bool bStartInputMode =
true;
2354 bool bShowError = (!bInputActivated || !aTester.
GetMessageId() || strcmp(aTester.
GetMessageId(), STR_PROTECTIONERR) != 0) &&
2373 bStartInputMode =
false;
2377 if (bStartInputMode)
2405 nValidation = static_cast<const SfxUInt32Item*>(pItem)->GetValue();
2466 if (aStr.startsWith(
"{=") && aStr.endsWith(
"}") )
2468 aStr = aStr.copy(1, aStr.getLength() -2);
2479 if ( !aStr.isEmpty() && ( aStr[0] ==
'=' || aStr[0] ==
'+' || aStr[0] ==
'-' ) &&
2535 bool bSelectionForTopView =
false;
2537 bSelectionForTopView =
true;
2538 bool bSelectionForTableView =
false;
2540 bSelectionForTableView =
true;
2541 if (bSelectionForTopView || bSelectionForTableView)
2544 if (bSelectionForTopView)
2546 if (bSelectionForTableView)
2561 mpEditEngine && mpEditEngine->GetUpdateMode() && pInputWin )
2567 pInputWin->SetTextString(aText);
2581 return StartTable( cTyped, bFromCommand,
false,
nullptr );
2646 bool bNeedGrow = ( rViewData.
GetEditAdjust() != SvxAdjust::Left );
2679 bIsFormula = !rText.isEmpty() &&
2680 (rText[0] ==
'=' || rText[0] ==
'+' || rText[0] ==
'-');
2689 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScRefModeChanged ) );
2690 SC_MOD()->SetRefInputHdl(
this);
2708 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScRefModeChanged ) );
2709 SC_MOD()->SetRefInputHdl(
nullptr);
2726 bool bFound =
false;
2729 while ( pOneFrame && !bFound )
2731 if ( pOneFrame == pRefFrame )
2746 OSL_FAIL(
"ViewFrame for reference input is not here anymore");
2774 rBindings.
Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
2777 rBindings.
Invalidate( SID_ATTR_CHAR_WEIGHT );
2778 rBindings.
Invalidate( SID_ATTR_CHAR_POSTURE );
2779 rBindings.
Invalidate( SID_ATTR_CHAR_UNDERLINE );
2780 rBindings.
Invalidate( SID_ATTR_CHAR_OVERLINE );
2782 rBindings.
Invalidate( SID_ULINE_VAL_SINGLE );
2783 rBindings.
Invalidate( SID_ULINE_VAL_DOUBLE );
2784 rBindings.
Invalidate( SID_ULINE_VAL_DOTTED );
2786 rBindings.
Invalidate( SID_HYPERLINK_GETLINK );
2788 rBindings.
Invalidate( SID_ATTR_CHAR_KERNING );
2789 rBindings.
Invalidate( SID_SET_SUPER_SCRIPT );
2791 rBindings.
Invalidate( SID_ATTR_CHAR_STRIKEOUT );
2792 rBindings.
Invalidate( SID_ATTR_CHAR_SHADOWED );
2802 if (
eMode == eNewMode )
2845 sal_Int32 nLen =
mpEditEngine->GetText(nPara).getLength();
2848 for (sal_uInt16
i=0;
i<nCount;
i++)
2857 SetSelection(
ESelection( nPara, nLen, nPara, nLen ) );
2875 if (eNewMode != eOldMode)
2886 sal_Int32 nLen = rString.getLength();
2887 for (sal_Int32
i=0;
i<nLen;
i++)
2890 if ( c < '0' || c >
'9' )
2926 std::unique_ptr<EditTextObject>
pObject;
2927 std::unique_ptr<ScPatternAttr> pCellAttrs;
2928 bool bForget =
false;
2931 OUString aPreAutoCorrectString(aString);
2987 pSelEngine->ReleaseMouse();
3017 std::vector<editeng::MisspellRanges> aMisspellRanges;
3037 bSpellErrors =
false;
3054 bool bUniformAttribs =
true;
3056 for (sal_Int32 nPara = 1; nPara < nParCnt; ++nPara)
3059 if (!(aPara1Attribs == aPara2Attribs))
3062 bUniformAttribs =
false;
3074 std::unique_ptr<SfxItemSet> pCommonAttrs;
3078 if ( eState == SfxItemState::SET &&
3083 if ( !pCommonAttrs )
3085 pCommonAttrs->Put( *pItem );
3092 pCellAttrs = std::make_unique<ScPatternAttr>(rDoc.
GetPool());
3093 pCellAttrs->GetFromEditItemSet( pCommonAttrs.get() );
3100 bool bAttrib =
false;
3110 if (eState == SfxItemState::DONTCARE)
3112 else if (eState == SfxItemState::SET)
3126 if ( eFieldState == SfxItemState::DONTCARE || eFieldState == SfxItemState::SET )
3131 if ( eConvState == SfxItemState::DONTCARE || eConvState == SfxItemState::SET )
3173 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScRefModeChanged ) );
3174 SC_MOD()->SetRefInputHdl(
nullptr);
3196 bool bInsertPreCorrectedString =
true;
3198 if (aString.startsWith(
"="))
3203 bInsertPreCorrectedString =
false;
3205 if( aReplace.isEmpty() )
3207 if( aReplace !=
"\"" )
3208 aString = aString.replaceAll( aReplace,
"\"" );
3211 if( aReplace.isEmpty() )
3213 if( aReplace !=
"\"" )
3214 aString = aString.replaceAll( aReplace,
"\"" );
3217 if( aReplace.isEmpty() )
3219 if( aReplace !=
"'" )
3220 aString = aString.replaceAll( aReplace,
"'" );
3223 if( aReplace.isEmpty() )
3225 if( aReplace !=
"'" )
3226 aString = aString.replaceAll( aReplace,
"'");
3230 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScKillEditViewNoPaint ) );
3236 sal_uInt16
nId = FID_INPUTLINE_ENTER;
3238 nId = FID_INPUTLINE_BLOCK;
3240 nId = FID_INPUTLINE_MATRIX;
3245 if ( bInsertPreCorrectedString && aString != aPreAutoCorrectString )
3249 aPreAutoCorrectString, pObject.get());
3251 rBindings.
Execute(nId, aArgs);
3256 aString, pObject.get());
3257 if ( !aMisspellRanges.empty() )
3260 aArgs[0] = &aItemCorrected;
3261 rBindings.
Execute(nId, aArgs);
3267 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScKillEditView ) );
3269 if ( bOldMod && pExecuteSh && pCellAttrs && !bForget )
3309 SC_MOD()->SetRefInputHdl(
nullptr);
3339 std::vector<ReferenceMark> aReferenceMarks;
3364 sal_Int32
nPos = aText.getLength() - 1;
3367 cLastChar = aText[nPos];
3368 if (cLastChar !=
' ')
3373 bool bAppendSeparator = (cLastChar !=
'(' && cLastChar != cSep && cLastChar !=
'=');
3374 if (bAppendSeparator)
3392 bool bOtherDoc = (pThisDoc != &rDoc);
3450 switch(aAddrDetails.
eConv)
3455 aRefStr =
"[\'" + aFileName +
"']";
3459 aRefStr =
"\'" + aFileName +
"'#";
3491 OSL_FAIL(
"InsertFunction, not during input mode");
3501 OUString aText = rFuncName;
3538 OSL_FAIL(
"ClearText, not during input mode");
3572 bool bShift = aCode.
IsShift();
3573 bool bControl = aCode.
IsMod1();
3574 bool bAlt = aCode.
IsMod2();
3578 if (bAlt && !bControl && nCode !=
KEY_RETURN)
3582 if (!bControl && nCode ==
KEY_TAB)
3596 bool bDoEnter =
false;
3603 if ((
pInputWin && bInputLine && bControl != bShift) || (!bInputLine && bControl && !bShift))
3620 if ( bShift && bControl )
3633 if (bControl && !bAlt)
3680 bool bInsKey = ( nCode ==
KEY_INSERT && !nModi );
3719 if ( !aStrLoP.isEmpty() )
3728 if ( !aStrLoP.isEmpty() )
3783 if ( nChar && nChar != 8 && nChar != 127 &&
3784 KeyFuncType::CUT != eFunc)
3795 if ( bUsed && nChar ==
'(' )
3816 bool bSetModified = !bCursorKey;
3886 if ( rCEvt.
GetCommand() == CommandEventId::CursorPos )
3902 else if ( rCEvt.
GetCommand() == CommandEventId::QueryCharPosition )
3967 if ( rCEvt.
GetCommand() == CommandEventId::EndExtTextInput )
4004 if (bRepeat && !bForce)
4038 bool bIgnore =
false;
4056 bool bTxtMod =
false;
4064 else if ( bHadObject )
4071 if ( bTxtMod || bForce )
4106 GetRangeAtBlock(
ScRange( rSPos, rEPos ), &aPosStr );
4108 if ( aPosStr.isEmpty() )
4113 if ( rSPos != rEPos )
4145 if ( nCntrl & EEControlBits::ONLINESPELLING )
4146 mpEditEngine->SetControlWord( nCntrl & ~EEControlBits::ONLINESPELLING );
4205 if ( !(
nullptr == pLastState ||
SC_MOD()->IsFormulaMode() ||
SC_MOD()->IsRefDialogOpen()))
4210 if ( pViewFrm && pViewFrm->
GetChildWindow( SID_OPENDLG_FUNCTION ) )
4214 pInputWin->EnableButtons(
false );
4215 pInputWin->Disable();
4218 else if ( !bFormulaMode )
4220 bInOwnChange =
true;
4222 pActiveViewSh =
nullptr;
4228 pInputWin->Disable();
4231 bInOwnChange =
false;
4250 bool bFromTopNotify = ( bFromNotify && pView ==
pTopView );
4300 if ( eFieldState == SfxItemState::DONTCARE || eFieldState == SfxItemState::SET )
4303 std::unique_ptr<EditTextObject> pObj =
mpEditEngine->CreateTextObject();
4308 for (sal_Int32
i=0;
i<nParCnt;
i++)
4312 while ( nParCnt > 1 )
4314 sal_Int32 nLen = rDestEngine.
GetTextLen( 0 );
4364 if ( nStart <= nEnd )
4390 sal_Int32 nNewLen = rStr.getLength();
4394 aBuf.remove(nFormSelStart, nOldLen);
4396 aBuf.insert(nFormSelStart, rStr);
4433 const OUString& rString,
4435 : aCursorPos ( rCurPos ),
4436 aStartPos ( rStartPos ),
4437 aEndPos ( rEndPos ),
4438 aString ( rString ),
4439 pEditData ( pData ? pData->
Clone() : nullptr )
ScMarkData & GetMarkData()
SC_DLLPUBLIC ScRefFlags ParseAny(const OUString &, const ScDocument &, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1)
void FindNextUnprot(bool bShift, bool bInSelection)
SfxViewFrame * GetViewFrame() const
#define LINK(Instance, Class, Member)
sal_Unicode GetEndDoubleQuote() const
SC_DLLPUBLIC ScDPObject * GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const
List of spreadsheet functions.
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)
void SetControlWord(EVControlBits nWord)
OUString GetText(LineEnd eEnd=LINEEND_LF) const
bool IsDataValid(const OUString &rTest, const ScPatternAttr &rPattern, const ScAddress &rPos) const
SC_DLLPUBLIC void Format(OStringBuffer &r, ScRefFlags nFlags, const ScDocument *pDocument=nullptr, const Details &rDetails=detailsOOOa1) const
ScDocShell * GetDocShell() const
void SetEditAdjust(SvxAdjust eNewEditAdjust)
void DataPilotInput(const ScAddress &rPos, const OUString &rString)
constexpr TypedWhichId< SvxAutoKernItem > EE_CHAR_PAIRKERNING(EE_CHAR_START+11)
TOOLS_DLLPUBLIC OString convertLineEnd(const OString &rIn, LineEnd eLineEnd)
bool AdjustBlockHeight(bool bPaint=true, ScMarkData *pMarkData=nullptr)
static SvxAutoCorrCfg & Get()
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
SfxChildWindow * GetChildWindow(sal_uInt16)
constexpr TypedWhichId< SvxKerningItem > EE_CHAR_KERNING(EE_CHAR_START+12)
void TestSelection(const ScDocument &rDoc, const ScMarkData &rMark)
bool isLOKMobilePhone() const
void PostEditView(ScEditEngineDefaulter *pEditEngine, const ScAddress &rCursorPos)
void SetAccessibilityEventsSuppressed(bool bSuppressed)
static bool EETextObjEqual(const EditTextObject *pObj1, const EditTextObject *pObj2)
OUString GetTitle(sal_uInt16 nMaxLen=0) const
bool Command(const CommandEvent &rCEvt)
static SC_DLLPUBLIC::utl::TransliterationWrapper * GetpTransliteration()
std::unique_ptr< ContentProperties > pData
const Fraction & GetZoomX() const
void CompleteAutoCorrect(vcl::Window const *pFrameWin=nullptr)
bool IsTransparent() const
constexpr TypedWhichId< SfxBoolItem > ATTR_VERTICAL_ASIAN(137)
static vcl::Window * GetDefDialogParent()
Point GetPrintTwipsPos(SCCOL nCol, SCROW nRow) const
returns the position (top-left corner) of the requested cell in print twips coordinates.
bool IsDataValidCustom(const OUString &rTest, const ScPatternAttr &rPattern, const ScAddress &rPos, const CustomValidationPrivateAccess &) const
SCROW GetRefStartY() const
void SetPasteMode(ScPasteFlags nFlags)
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
svtools::ColorConfig & GetColorConfig()
void ShowCursor(bool bGotoCursor=true, bool bForceVisCursor=true, bool bActivate=false)
vcl::Window * GetFrameWin() const
bool HasSelection() const
const SfxItemSet & GetItemSet() const
SC_DLLPUBLIC sal_Unicode GetSheetSeparator() const
Obtain the sheet separator corresponding to the document's grammar.
SvxAdjust GetEditAdjust() const
const ContentProperties & rData
sal_uInt16 GetCode() const
ScSplitPos GetActivePart() const
ScDocument & GetDocument() const
Selection GetSurroundingTextSelection() const
void EditGrowY(bool bInitial=false)
Extend the output area for the edit engine view in a vertical direction as needed.
constexpr TypedWhichId< SvxAdjustItem > EE_PARA_JUST(EE_PARA_START+15)
const OUString & getQuotationMarkStart() const
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE_CJK(EE_CHAR_START+15)
constexpr TypedWhichId< ScLineBreakCell > ATTR_LINEBREAK(139)
OUString GetSurroundingText() const
void Invalidate(sal_uInt16 nId)
void SelectCurrentWord(sal_Int16 nWordType=css::i18n::WordType::ANYWORD_IGNOREWHITESPACES)
void ApplyAsianEditSettings(ScEditEngineDefaulter &rEngine)
EmbeddedObjectRef * pObject
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
void SetEditEngineUpdateMode(bool bUpdate)
ReferenceMark FillReferenceMark(SCCOL nRefStartX, SCROW nRefStartY, SCCOL nRefEndX, SCROW nRefEndY, const Color &rColor)
const OUString & getQuotationMarkEnd() const
void TestSelectedBlock(const ScDocument &rDoc, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, const ScMarkData &rMark)
SfxApplication * SfxGetpApp()
SC_DLLPUBLIC ScDocumentPool * GetPool()
SC_DLLPUBLIC const ScValidationData * GetValidationEntry(sal_uLong nIndex) const
weld::Window * GetFrameWeld() const
SfxPrinter * GetPrinter(bool bCreateIfNotExist=true)
bool isLetterNumeric(const OUString &rStr, sal_Int32 nPos) const
vcl::Window & GetWindow() const
void Enable(bool bEnable=true, bool bChild=true)
bool IsSymbolFont() const
If font is an old symbol font StarBats/StarMath with text encoding RTL_TEXTENC_SYMBOL.
void SetText(const OUString &rStr)
sal_Unicode GetStartSingleQuote() const
formula::FormulaGrammar::AddressConvention eConv
vcl::Cursor * GetCursor() const
bool IsMultiMarked() const
void EditGrowX()
Extend the output area for the edit engine view in a horizontal direction as needed.
SfxFrame & GetFrame() const
static SfxViewShell * Current()
bool isCompatFlagSet(Compat flag)
constexpr sal_uInt16 KEY_F2
void libreOfficeKitViewCallback(int nType, const char *pPayload) const override
static void * ShowPopover(vcl::Window *pParent, const tools::Rectangle &rScreenRect, const OUString &rText, QuickHelpFlags nStyle)
bool GetHighContrastMode() const
void UpdateInputHandler(bool bForce=false, bool bStopEditing=true)
sal_uInt16 GetModifier() const
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
bool Execute(sal_uInt16 nSlot, const SfxPoolItem **pArgs=nullptr, SfxCallMode nCall=SfxCallMode::SLOT)
const Fraction & GetZoomY() const
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
ScViewData & GetViewData()