22 #include <string_view>
59 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
61 #include <osl/diagnose.h>
64 #include <inputwin.hxx>
68 #include <uiitems.hxx>
71 #include <globstr.hrc>
75 #include <document.hxx>
84 #include <compiler.hxx>
88 #include <tokenarray.hxx>
94 #define RANGEFIND_MAX 128
106 const sal_Unicode cParenthesesReplacement = 0x0001;
108 ScTypedCaseStrSet::const_iterator findText(
109 const ScTypedCaseStrSet& rDataSet, ScTypedCaseStrSet::const_iterator
const & itPos,
110 const OUString& rStart, OUString& rResult,
bool bBack)
117 ScTypedCaseStrSet::const_reverse_iterator it = rDataSet.rbegin(), itEnd = rDataSet.rend();
118 if (itPos != rDataSet.end())
120 size_t nPos = std::distance(rDataSet.begin(), itPos);
121 size_t nRPos = rDataSet.size() - 1 - nPos;
122 std::advance(it, nRPos);
126 it = std::find_if(it, itEnd, lIsMatch);
129 rResult = it->GetString();
130 return (++it).base();
135 ScTypedCaseStrSet::const_iterator it = rDataSet.begin(), itEnd = rDataSet.end();
138 it = std::next(itPos);
141 it = std::find_if(it, itEnd, lIsMatch);
144 rResult = it->GetString();
149 return rDataSet.end();
152 OUString getExactMatch(
const ScTypedCaseStrSet& rDataSet,
const OUString& rString)
154 auto it = std::find_if(rDataSet.begin(), rDataSet.end(),
159 if (it != rDataSet.end())
160 return it->GetString();
164 ScTypedCaseStrSet::const_iterator findTextAll(
165 const ScTypedCaseStrSet& rDataSet, ScTypedCaseStrSet::const_iterator
const & itPos,
166 const OUString& rStart, ::std::vector< OUString > &rResultVec,
bool bBack)
171 ScTypedCaseStrSet::const_iterator retit;
174 ScTypedCaseStrSet::const_reverse_iterator it, itEnd;
175 if ( itPos == rDataSet.end() )
177 it = rDataSet.rend();
183 it = rDataSet.rbegin();
184 size_t nPos = std::distance(rDataSet.begin(), itPos);
185 size_t nRPos = rDataSet.size() - 1 - nPos;
186 std::advance(it, nRPos);
187 if ( it == rDataSet.rend() )
188 it = rDataSet.rbegin();
191 bool bFirstTime =
true;
193 while ( it != itEnd || bFirstTime )
196 if ( it == rDataSet.rend() )
197 it = rDataSet.rbegin();
214 retit = rDataSet.begin();
215 size_t nRPos = std::distance(rDataSet.rbegin(), it);
216 size_t nPos = rDataSet.size() - 1 - nRPos;
217 std::advance(retit, nPos);
224 ScTypedCaseStrSet::const_iterator it, itEnd;
226 if ( it == rDataSet.end() )
227 it = rDataSet.begin();
229 bool bFirstTime =
true;
231 while ( it != itEnd || bFirstTime )
234 if ( it == rDataSet.end() )
235 it = rDataSet.begin();
257 return rDataSet.end();
263 const std::vector<ReferenceMark>& rReferenceMarks )
270 std::stringstream ss;
272 ss <<
"{ \"marks\": [ ";
274 for (
size_t i = 0;
i < rReferenceMarks.size();
i++ )
276 if ( rReferenceMarks[
i].Is() )
281 ss <<
"{ \"rectangle\": \""
282 << rReferenceMarks[
i].nX <<
", "
283 << rReferenceMarks[
i].nY <<
", "
284 << rReferenceMarks[
i].nWidth <<
", "
285 << rReferenceMarks[
i].nHeight <<
"\", "
286 "\"color\": \"" << rReferenceMarks[
i].aColor.AsRGBHexString() <<
"\", "
287 "\"part\": \"" << rReferenceMarks[
i].nTab <<
"\" } ";
295 OString aPayload = ss.str().c_str();
297 LOK_CALLBACK_REFERENCE_MARKS, aPayload.getStr() );
303 if ( !pActiveViewSh || !
SC_MOD()->GetInputOptions().GetRangeFinder() )
314 sal_Int32 nColon = aDelimiters.indexOf(
':' );
316 aDelimiters = aDelimiters.replaceAt( nColon, 1,
"");
317 sal_Int32 nDot = aDelimiters.indexOf(cSheetSep);
319 aDelimiters = aDelimiters.replaceAt( nDot, 1 ,
"");
322 sal_Int32 nLen = rFormula.getLength();
324 sal_Int32 nStart = 0;
332 if ( pChar[nPos] ==
'"' )
335 while (nPos<nLen && pChar[nPos] !=
'"')
345 bool bSingleQuoted =
false;
350 if (pChar[nPos] ==
'\'')
352 bSingleQuoted = !bSingleQuoted;
354 else if (!bSingleQuoted)
366 if( nPos < nLen && nPos > 0 &&
367 '-' == pChar[nPos] &&
'[' == pChar[nPos-1] &&
376 OUString aTest = rFormula.copy( nStart, nPos-nStart );
383 aRange.
aStart.
SetTab( pActiveViewSh->GetViewData().GetTabNo() );
398 mpEditEngine->SetUpdateMode(
false );
405 SfxItemSet aSet( mpEditEngine->GetEmptyItemSet() );
407 mpEditEngine->QuickSetAttribs( aSet, aSel );
415 UpdateLokReferenceMarks();
419 mpEditEngine->SetUpdateMode(
true );
421 pDocSh->Broadcast(
SfxHint( SfxHintId::ScShowRangeFinder ) );
433 comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs))
435 SCCOL nCol1 = nX1, nCol2 = nX2;
436 SCROW nRow1 = nY1, nRow2 = nY2;
439 if (nCol1 == nCol2 && nRow1 == nRow2)
444 tools::Long nSizeX = aBottomRight.X() - aTopLeft.X() - 1;
445 tools::Long nSizeY = aBottomRight.Y() - aTopLeft.Y() - 1;
447 return ReferenceMark(aTopLeft.X(), aTopLeft.Y(), nSizeX, nSizeY, nTab, rColor);
462 nTab, nPPTX, nPPTY,
false,
false );
490 if ( !pRangeFinder && !rViewData.
IsRefMode() )
493 sal_uInt16 nAdditionalMarks = 0;
494 std::vector<ReferenceMark> aReferenceMarks( 1 );
498 nAdditionalMarks = 1;
519 sal_uInt16
nCount = pRangeFinder ?
520 (
static_cast<sal_uInt16
>( pRangeFinder->
Count() ) + nAdditionalMarks ) : nAdditionalMarks;
521 aReferenceMarks.resize( nCount );
523 if ( nCount && pRangeFinder && !pRangeFinder->
IsHidden() &&
526 for (sal_uInt16
i = 0;
i < nCount - nAdditionalMarks;
i++)
552 aReferenceMarks.clear();
559 mbDocumentDisposing = b;
586 ScTabViewShell* pDocView = pRefViewSh ? pRefViewSh : pActiveViewSh;
587 if ( pDocView && pRangeFindList && nIndex < pRangeFindList->
Count() )
591 sal_Int32 nOldEnd = rData.
nSelEnd;
592 Color nNewColor = pRangeFindList->FindColor( rNew, nIndex );
598 OUString aNewStr(aJustified.
Format(rDoc, rData.
nFlags, aAddrDetails));
599 ESelection aOldSel( 0, nOldStart, 0, nOldEnd );
600 SfxItemSet aSet( mpEditEngine->GetEmptyItemSet() );
607 mpEditEngine->QuickSetAttribs( aSet, aOldSel );
609 bInRangeUpdate =
true;
611 bInRangeUpdate =
false;
619 sal_uInt16
nCount =
static_cast<sal_uInt16
>(pRangeFindList->Count());
620 for (sal_uInt16
i=nIndex+1;
i<nCount;
i++)
627 EditView* pActiveView = pTopView ? pTopView : pTableView;
632 OSL_FAIL(
"UpdateRange: we're missing something");
638 ScTabViewShell* pPaintView = pRefViewSh ? pRefViewSh : pActiveViewSh;
639 if ( pRangeFindList && pPaintView )
642 pRangeFindList->SetHidden(
true);
643 pDocSh->Broadcast(
SfxHint( SfxHintId::ScShowRangeFinder ) );
644 pRangeFindList.reset();
655 rStr = rStr.replace(
'\t',
' ');
661 rStr = rStr.replace(
'\n',
' ');
708 sal_Int32 nLen = rStr.getLength();
712 sal_uInt16 nQuotes = 0;
713 if ( nPos < nLen / 2 )
729 bool bLookInString = ((nQuotes % 2) != 0);
730 bool bInString = bLookInString;
732 p1 = (nDir < 0 ? p0 : p0 + nLen) ;
733 sal_uInt16 nLevel = 1;
734 while ( p != p1 && nLevel )
739 bInString = !bInString;
740 if ( bLookInString && !bInString )
743 else if ( bInString == bLookInString )
753 return static_cast<sal_Int32
>(p - p0);
757 : pInputWin( nullptr ),
758 pTableView( nullptr ),
760 pTipVisibleParent( nullptr ),
761 nTipVisible( nullptr ),
762 pTipVisibleSecParent( nullptr ),
763 nTipVisibleSec( nullptr ),
766 nCellPercentFormatDecSep( 0 ),
773 bFormulaMode( false ),
774 bInRangeUpdate( false ),
775 bParenthesisShown( false ),
776 bCreatingFuncView( false ),
777 bInEnterHandler( false ),
778 bCommandErrorShown( false ),
779 bInOwnChange( false ),
781 bLastIsSymbol( false ),
782 mbDocumentDisposing(false),
787 pRefViewSh( nullptr ),
788 pLastPattern( nullptr ),
815 if (
SC_MOD()->GetRefInputHdl() ==
this)
816 SC_MOD()->SetRefInputHdl(
nullptr);
841 bool bTextWysiwyg =
SC_MOD()->GetInputOptions().GetTextWysiwyg();
844 if ( bTextWysiwyg || bInPlace )
845 nCtrl |= EEControlBits::FORMAT100;
884 mpEditEngine->SetReplaceLeadingSingleQuotationMark(
false );
898 nCntrl |= EEControlBits::AUTOCORRECT;
900 if ( nCntrl != nOld )
926 nCntrl |= EEControlBits::ONLINESPELLING;
931 nCntrl &= ~EEControlBits::AUTOCORRECT;
933 nCntrl |= EEControlBits::AUTOCORRECT;
934 if ( nCntrl != nOld )
945 if ( bOnlineSpell ) {
979 const OUString aParenthesesReplacement( cParenthesesReplacement);
981 sal_uInt32 nListCount = pFuncList->
GetCount();
982 for(sal_uInt32
i=0;
i<nListCount;
i++)
988 const sal_Int32 nLen = pDesc->
mxFuncName->getLength();
990 for ( sal_Int32 j = 0; j < nLen; j++ )
995 OUString aFuncName = *pDesc->
mxFuncName + aParenthesesReplacement;
1009 if (rEvent.GetId() == VclEventId::ObjectDying || rEvent.GetId() == VclEventId::WindowHide
1010 || rEvent.GetId() == VclEventId::WindowLoseFocus)
1016 if (rEvent.GetId() == VclEventId::ObjectDying || rEvent.GetId() == VclEventId::WindowHide
1017 || rEvent.GetId() == VclEventId::WindowLoseFocus)
1047 bool lcl_hasSingleToken(
const OUString& s,
sal_Unicode c)
1049 return !s.isEmpty() && s.indexOf(c)<0;
1065 bool bFound =
false;
1070 if( nLeftParentPos != -1 )
1072 sal_Int32 nNextFStart = aHelper.
GetFunctionStart( rSelText, nLeftParentPos,
true);
1074 ::std::vector< OUString> aArgs;
1075 if( aHelper.
GetNextFunc( rSelText,
false, nNextFStart,
nullptr, &ppFDesc, &aArgs ) )
1079 sal_Int32 nArgPos = aHelper.
GetArgStart( rSelText, nNextFStart, 0 );
1083 ScTypedCaseStrSet::const_iterator it =
1088 sal_uInt16 nActive = 0;
1089 for( sal_uInt16
i=0;
i < nArgs;
i++ )
1091 sal_Int32
nLength = aArgs[
i].getLength();
1092 if( nArgPos <= rSelText.getLength()-1 )
1101 sal_Int32 nStartPosition = 0;
1102 sal_Int32 nEndPosition = 0;
1104 if( lcl_hasSingleToken(aNew, cSep) )
1106 for (sal_Int32
i = 0;
i < aNew.getLength(); ++
i)
1111 nStartPosition =
i+1;
1115 else if( lcl_hasSingleToken(aNew, cSheetSep) )
1118 for (sal_Int32
i = 0;
i < aNew.getLength(); ++
i)
1123 nStartPosition =
i+1;
1125 else if( cNext == cSep )
1129 if( nCount == nActive )
1133 nStartPosition = nEndPosition+1;
1140 for (sal_Int32
i = 0;
i < aNew.getLength(); ++
i)
1145 nStartPosition =
i+1;
1147 else if( cNext == cSep )
1151 if( nCount == nActive )
1155 nStartPosition = nEndPosition+1;
1157 else if( cNext == cSheetSep )
1164 if (nStartPosition > 0)
1166 OUStringBuffer
aBuf;
1167 aBuf.append(aNew.subView(0, nStartPosition));
1168 aBuf.append(
u'\x25BA');
1169 aBuf.append(aNew.subView(nStartPosition));
1171 sal_Int16 nVarArgsSet = 0;
1182 if ( nVarArgsSet > 0 && nActive > nArgs )
1183 nActive = nArgs - (nActive - nArgs) % nVarArgsSet;
1184 aBuf.append(
" : " );
1186 aNew = aBuf.makeStringAndClear();
1227 if ( aParagraph.getLength() < aSel.
nEndPos )
1232 OUString aSelText( aParagraph.copy( 0, aSel.
nEndPos ));
1264 QuickHelpFlags const nAlign = QuickHelpFlags::Left|QuickHelpFlags::Bottom;
1288 Point aLogicPos = pCur->GetPos();
1289 aLogicPos.AdjustY(pCur->GetHeight() );
1296 QuickHelpFlags const nAlign = QuickHelpFlags::Left | QuickHelpFlags::Top | QuickHelpFlags::NoEvadePointer;
1303 if ( aStart.isEmpty() )
1307 sal_Int32
nPos = aStart.getLength() - 1;
1310 ::std::set< sal_Unicode >::const_iterator
p =
maFormulaChar.find( c );
1314 ::std::vector<sal_Unicode> aTemp;
1315 aTemp.push_back( c );
1316 for(sal_Int32
i = nPos - 1;
i >= 0; --
i)
1324 aTemp.push_back( c );
1327 ::std::vector<sal_Unicode>::reverse_iterator rIt = aTemp.rbegin();
1328 aResult = OUString( *rIt++ );
1329 while ( rIt != aTemp.rend() )
1330 aResult += OUStringChar( *rIt++ );
1337 OString escapeJSON(
const OUString &aStr)
1339 OUString aEscaped = aStr;
1340 aEscaped = aEscaped.replaceAll(
"\n",
" ");
1341 aEscaped = aEscaped.replaceAll(
"\"",
"'");
1357 OUString aFuncNameStr;
1358 OUString aDescFuncNameStr;
1359 OStringBuffer aPayload;
1360 aPayload.append(
"[ ");
1361 for (
const OUString& rFunc : rFuncStrVec)
1363 if ( rFunc[rFunc.getLength()-1] == cParenthesesReplacement )
1365 aFuncNameStr = rFunc.copy(0, rFunc.getLength()-1);
1369 aFuncNameStr = rFunc;
1373 aDescFuncNameStr = aFuncNameStr +
"()";
1374 sal_Int32 nNextFStart = 0;
1376 ::std::vector< OUString > aArgs;
1377 OUString eqPlusFuncName =
"=" + aDescFuncNameStr;
1378 if ( aHelper.
GetNextFunc( eqPlusFuncName,
false, nNextFStart,
nullptr, &ppFDesc, &aArgs ) )
1382 aPayload.append(
"{");
1383 aPayload.append(
"\"index\": ");
1384 aPayload.append(OString::number(nCurIndex));
1385 aPayload.append(
", ");
1386 aPayload.append(
"\"signature\": \"");
1388 aPayload.append(
"\", ");
1389 aPayload.append(
"\"description\": \"");
1391 aPayload.append(
"\"}, ");
1395 if (nCurIndex == nSize)
1398 sal_Int32 nLen = aPayload.getLength();
1399 aPayload[nLen - 2] =
' ';
1400 aPayload[nLen - 1] =
']';
1402 OString s = aPayload.makeStringAndClear();
1409 OUStringBuffer aTipStr;
1410 OUString aFuncNameStr;
1411 OUString aDescFuncNameStr;
1412 ::std::vector<OUString>::const_iterator itStr = rFuncStrVec.begin();
1413 sal_Int32 nMaxFindNumber = 3;
1414 sal_Int32 nRemainFindNumber = nMaxFindNumber;
1415 for ( ; itStr != rFuncStrVec.end(); ++itStr )
1417 const OUString& rFunc = *itStr;
1418 if ( rFunc[rFunc.getLength()-1] == cParenthesesReplacement )
1420 aFuncNameStr = rFunc.copy(0, rFunc.getLength()-1);
1424 aFuncNameStr = rFunc;
1426 if ( itStr == rFuncStrVec.begin() )
1429 aDescFuncNameStr = aFuncNameStr +
"()";
1433 aTipStr.append(
", ");
1435 aTipStr.append(aFuncNameStr);
1436 if ( itStr == rFuncStrVec.begin() )
1437 aTipStr.append(
"]");
1438 if ( --nRemainFindNumber <= 0 )
1441 sal_Int32 nRemainNumber = rFuncStrVec.size() - nMaxFindNumber;
1442 if ( nRemainFindNumber == 0 && nRemainNumber > 0 )
1444 OUString aMessage(
ScResId( STR_FUNCTIONS_FOUND ) );
1445 aMessage = aMessage.replaceFirst(
"%2", OUString::number(nRemainNumber));
1446 aMessage = aMessage.replaceFirst(
"%1", aTipStr.makeStringAndClear());
1450 sal_Int32 nNextFStart = 0;
1452 ::std::vector< OUString > aArgs;
1453 OUString eqPlusFuncName =
"=" + aDescFuncNameStr;
1454 if ( aHelper.
GetNextFunc( eqPlusFuncName,
false, nNextFStart,
nullptr, &ppFDesc, &aArgs ) )
1461 ShowTip( aTipStr.makeStringAndClear() );
1479 if ( aSel.
nEndPos > aParagraph.getLength() )
1482 if ( aParagraph.getLength() > aSel.
nEndPos &&
1484 aParagraph[ aSel.
nEndPos ] ==
'_' ||
1485 aParagraph[ aSel.
nEndPos ] ==
'.' ||
1486 aParagraph[ aSel.
nEndPos ] ==
'$' ) )
1493 OUString aSelText( aParagraph.copy( 0, aSel.
nEndPos ));
1500 ::std::vector<OUString> aNewVec;
1507 for (
int n = 0;
n < aSelText.getLength();
n++ )
1511 if (aSelText[
n] == cBetweenQuotes)
1514 else if ( aSelText[
n ] ==
'"' )
1515 cBetweenQuotes =
'"';
1516 else if ( aSelText[
n ] ==
'\'' )
1517 cBetweenQuotes =
'\'';
1519 if ( cBetweenQuotes )
1538 ::std::vector<OUString> aNewVec;
1554 void completeFunction(
EditView* pView,
const OUString& rInsert,
bool& rParInserted )
1561 bool bNoInitialLetter =
false;
1574 bNoInitialLetter =
true;
1581 bNoInitialLetter =
true;
1588 if(!bNoInitialLetter)
1590 const sal_Int32 nMinLen = std::max(aSel.
nEndPos - aSel.
nStartPos, sal_Int32(1));
1602 for (sal_Int32 n = aAll.getLength();
n >= nMinLen && aMatch.isEmpty(); --
n)
1604 const OUString aTest = aAll.copy(aAll.getLength() -
n);
1613 OUString aInsStr = rInsert;
1614 sal_Int32 nInsLen = aInsStr.getLength();
1615 bool bDoParen = ( nInsLen > 1 && aInsStr[nInsLen-2] ==
'('
1616 && aInsStr[nInsLen-1] ==
')' );
1624 if (aWordSel.
nEndPos < aOld.getLength())
1630 aInsStr = aInsStr.copy( 0, nInsLen - 2 );
1644 rParInserted =
true;
1656 if (aInsert[aInsert.getLength()-1] == cParenthesesReplacement)
1657 aInsert = OUString::Concat(aInsert.subView( 0, aInsert.getLength()-1)) +
"()";
1658 bool bParInserted =
false;
1661 completeFunction(
pTopView, aInsert, bParInserted );
1662 completeFunction(
pTableView, aInsert, bParInserted );
1699 aFormula = pEditEngine->
GetText(0);
1700 bEdit = aFormula.getLength() > 1 && (aFormula[0] ==
'=' || aFormula[0] ==
'+' || aFormula[0] ==
'-');
1705 OUString aNewFormula(
'=');
1706 if ( aFormula.startsWith(
"=") )
1707 aNewFormula = aFormula;
1715 ScTypedCaseStrSet::const_iterator aPos = findText(*
pFormulaData,
pFormulaData->begin(), rFunctionName, aNew,
false);
1732 if(rFormula.isEmpty())
1739 bool bColRowName = pCalc->HasColRowName();
1743 if ( pCalc->GetCode()->GetCodeLen() <= 1 )
1746 OUString aBraced =
"(" + rFormula +
")";
1750 bColRowName =
false;
1754 if ( nErrCode != FormulaError::NONE )
1759 if ( pCalc->IsValue() )
1761 double n = pCalc->GetValue();
1769 OUString aStr = pCalc->GetString().getString();
1773 const Color* pColor;
1778 aValue =
"\"" + aValue +
"\"";
1796 if (aPart.isEmpty())
1802 if (!aValue.isEmpty())
1818 sal_uInt32
const nTipLen2(sal::static_int_cast<sal_uInt32>(nTipLen));
1819 if ( nTipLen && ( nTipLen < 3 ||
aManualTip.subView( nTipLen2-3 ) !=
u"..." ) )
1844 if ( aInsert[0] ==
'"' )
1845 aInsert = aInsert.copy(1);
1846 sal_Int32 nInsLen = aInsert.getLength();
1847 if ( aInsert.endsWith(
"\"") )
1848 aInsert = aInsert.copy( 0, nInsLen-1 );
1892 if ( nPos < aFormula.getLength() && aFormula[nPos] ==
')' )
1919 OSL_ENSURE(
nAutoPar,
"SkipClosingPar: count is wrong");
1937 std::vector<ScTypedStrData>
aEntries;
1940 if (!aEntries.empty())
1941 pColumnData->insert(aEntries.begin(), aEntries.end());
1961 if ( aSel.
nEndPos != nParLen )
1965 if (aText.isEmpty())
1982 sal_Int32 nEdLen =
mpEditEngine->GetTextLen() + nParCnt - 1;
1983 OUString aIns = aNew.copy(nEdLen);
2004 if (aText.getLength() == aNew.getLength())
2008 ScTypedCaseStrSet::const_iterator itNextPos =
2032 if ( aSel.
nEndPos == nParLen && aText.getLength() ==
aAutoSearch.getLength() + nSelLen )
2035 ScTypedCaseStrSet::const_iterator itNew =
2045 OUString aIns = aNew.copy(
aAutoSearch.getLength());
2082 bool bFound =
false;
2094 if ( c ==
'(' || c ==
')' )
2107 for (sal_Int32
i=0;
i<nCount;
i++)
2113 ESelection aSelOther( 0,nOther, 0,nOther+1 );
2133 for (sal_Int32
i=0;
i<nCount;
i++)
2156 SC_MOD()->SetRefInputHdl(
nullptr);
2166 OSL_FAIL(
"pActiveViewSh is gone");
2170 if (
SC_MOD()->GetInputOptions().GetTextWysiwyg() )
2191 for (sal_uInt16
i=1;
i<nCount;
i++)
2195 if ( pWin==pShellWin )
2256 case SvxCellHorJustify::Standard:
2258 bool bNumber =
false;
2260 bNumber = (cTyped>=
'0' && cTyped<=
'9');
2266 eSvxAdjust = bNumber ? SvxAdjust::Right : SvxAdjust::Left;
2269 case SvxCellHorJustify::Block:
2270 eSvxAdjust = SvxAdjust::Block;
2272 case SvxCellHorJustify::Center:
2273 eSvxAdjust = SvxAdjust::Center;
2275 case SvxCellHorJustify::Right:
2276 eSvxAdjust = SvxAdjust::Right;
2279 eSvxAdjust = SvxAdjust::Left;
2286 if ( bAsianVertical )
2289 eSvxAdjust = SvxAdjust::Left;
2323 for (sal_Int32
i=0;
i<nCount;
i++)
2336 bool bNewTable =
false;
2361 bool bStartInputMode =
true;
2370 bool bShowError = (!bInputActivated || !aTester.
GetMessageId() || strcmp(aTester.
GetMessageId(), STR_PROTECTIONERR) != 0) &&
2389 bStartInputMode =
false;
2393 if (bStartInputMode)
2421 nValidation = static_cast<const SfxUInt32Item*>(pItem)->GetValue();
2482 if (aStr.startsWith(
"{=") && aStr.endsWith(
"}") )
2484 aStr = aStr.copy(1, aStr.getLength() -2);
2495 if ( !aStr.isEmpty() && ( aStr[0] ==
'=' || aStr[0] ==
'+' || aStr[0] ==
'-' ) &&
2551 bool bSelectionForTopView =
false;
2553 bSelectionForTopView =
true;
2554 bool bSelectionForTableView =
false;
2556 bSelectionForTableView =
true;
2557 if (bSelectionForTopView || bSelectionForTableView)
2560 if (bSelectionForTopView)
2562 if (bSelectionForTableView)
2577 mpEditEngine && mpEditEngine->GetUpdateMode() && pInputWin )
2583 pInputWin->SetTextString(aText);
2597 return StartTable( cTyped, bFromCommand,
false,
nullptr );
2662 bool bNeedGrow = ( rViewData.
GetEditAdjust() != SvxAdjust::Left );
2695 bIsFormula = !rText.isEmpty() &&
2696 (rText[0] ==
'=' || rText[0] ==
'+' || rText[0] ==
'-');
2705 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScRefModeChanged ) );
2706 SC_MOD()->SetRefInputHdl(
this);
2724 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScRefModeChanged ) );
2725 SC_MOD()->SetRefInputHdl(
nullptr);
2742 bool bFound =
false;
2745 while ( pOneFrame && !bFound )
2747 if ( pOneFrame == pRefFrame )
2762 OSL_FAIL(
"ViewFrame for reference input is not here anymore");
2790 rBindings.
Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
2793 rBindings.
Invalidate( SID_ATTR_CHAR_WEIGHT );
2794 rBindings.
Invalidate( SID_ATTR_CHAR_POSTURE );
2795 rBindings.
Invalidate( SID_ATTR_CHAR_UNDERLINE );
2796 rBindings.
Invalidate( SID_ATTR_CHAR_OVERLINE );
2798 rBindings.
Invalidate( SID_ULINE_VAL_SINGLE );
2799 rBindings.
Invalidate( SID_ULINE_VAL_DOUBLE );
2800 rBindings.
Invalidate( SID_ULINE_VAL_DOTTED );
2802 rBindings.
Invalidate( SID_HYPERLINK_GETLINK );
2804 rBindings.
Invalidate( SID_ATTR_CHAR_KERNING );
2805 rBindings.
Invalidate( SID_SET_SUPER_SCRIPT );
2807 rBindings.
Invalidate( SID_ATTR_CHAR_STRIKEOUT );
2808 rBindings.
Invalidate( SID_ATTR_CHAR_SHADOWED );
2818 if (
eMode == eNewMode )
2861 sal_Int32 nLen =
mpEditEngine->GetText(nPara).getLength();
2864 for (sal_uInt16
i=0;
i<nCount;
i++)
2873 SetSelection(
ESelection( nPara, nLen, nPara, nLen ) );
2891 if (eNewMode != eOldMode)
2902 sal_Int32 nLen = rString.getLength();
2903 for (sal_Int32
i=0;
i<nLen;
i++)
2906 if ( c < '0' || c >
'9' )
2942 std::unique_ptr<EditTextObject>
pObject;
2943 std::unique_ptr<ScPatternAttr> pCellAttrs;
2944 bool bForget =
false;
2947 OUString aPreAutoCorrectString(aString);
3001 pSelEngine->ReleaseMouse();
3024 std::vector<editeng::MisspellRanges> aMisspellRanges;
3044 bSpellErrors =
false;
3061 bool bUniformAttribs =
true;
3063 for (sal_Int32 nPara = 1; nPara < nParCnt; ++nPara)
3066 if (!(aPara1Attribs == aPara2Attribs))
3069 bUniformAttribs =
false;
3081 std::unique_ptr<SfxItemSet> pCommonAttrs;
3085 if ( eState == SfxItemState::SET &&
3090 if ( !pCommonAttrs )
3092 pCommonAttrs->Put( *pItem );
3099 pCellAttrs = std::make_unique<ScPatternAttr>(rDoc.
GetPool());
3100 pCellAttrs->GetFromEditItemSet( pCommonAttrs.get() );
3107 bool bAttrib =
false;
3117 if (eState == SfxItemState::DONTCARE)
3119 else if (eState == SfxItemState::SET)
3133 if ( eFieldState == SfxItemState::DONTCARE || eFieldState == SfxItemState::SET )
3138 if ( eConvState == SfxItemState::DONTCARE || eConvState == SfxItemState::SET )
3180 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScRefModeChanged ) );
3181 SC_MOD()->SetRefInputHdl(
nullptr);
3203 bool bInsertPreCorrectedString =
true;
3205 if (aString.startsWith(
"="))
3210 bInsertPreCorrectedString =
false;
3212 if( aReplace.isEmpty() )
3214 if( aReplace !=
"\"" )
3215 aString = aString.replaceAll( aReplace,
"\"" );
3218 if( aReplace.isEmpty() )
3220 if( aReplace !=
"\"" )
3221 aString = aString.replaceAll( aReplace,
"\"" );
3224 if( aReplace.isEmpty() )
3226 if( aReplace !=
"'" )
3227 aString = aString.replaceAll( aReplace,
"'" );
3230 if( aReplace.isEmpty() )
3232 if( aReplace !=
"'" )
3233 aString = aString.replaceAll( aReplace,
"'");
3237 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScKillEditViewNoPaint ) );
3243 sal_uInt16
nId = FID_INPUTLINE_ENTER;
3245 nId = FID_INPUTLINE_BLOCK;
3247 nId = FID_INPUTLINE_MATRIX;
3252 if ( bInsertPreCorrectedString && aString != aPreAutoCorrectString )
3256 aPreAutoCorrectString, pObject.get());
3258 rBindings.
Execute(nId, aArgs);
3263 aString, pObject.get());
3264 if ( !aMisspellRanges.empty() )
3267 aArgs[0] = &aItemCorrected;
3268 rBindings.
Execute(nId, aArgs);
3274 pSfxApp->Broadcast(
SfxHint( SfxHintId::ScKillEditView ) );
3276 if ( bOldMod && pExecuteSh && pCellAttrs && !bForget )
3316 SC_MOD()->SetRefInputHdl(
nullptr);
3346 std::vector<ReferenceMark> aReferenceMarks;
3371 sal_Int32
nPos = aText.getLength() - 1;
3374 cLastChar = aText[nPos];
3375 if (cLastChar !=
' ')
3380 bool bAppendSeparator = (cLastChar !=
'(' && cLastChar != cSep && cLastChar !=
'=');
3381 if (bAppendSeparator)
3399 bool bOtherDoc = (pThisDoc != &rDoc);
3457 switch(aAddrDetails.
eConv)
3462 aRefStr =
"[\'" + aFileName +
"']";
3466 aRefStr =
"\'" + aFileName +
"'#";
3480 bool bLOKShowSelect =
true;
3482 bLOKShowSelect =
false;
3501 OSL_FAIL(
"InsertFunction, not during input mode");
3511 OUString aText = rFuncName;
3548 OSL_FAIL(
"ClearText, not during input mode");
3582 bool bShift = aCode.
IsShift();
3583 bool bControl = aCode.
IsMod1();
3584 bool bAlt = aCode.
IsMod2();
3588 if (bAlt && !bControl && nCode !=
KEY_RETURN)
3592 if (!bControl && nCode ==
KEY_TAB)
3606 bool bDoEnter =
false;
3613 if ((
pInputWin && bInputLine && bControl != bShift) || (!bInputLine && bControl && !bShift))
3630 if ( bShift && bControl )
3643 if (bControl && !bAlt)
3690 bool bInsKey = ( nCode ==
KEY_INSERT && !nModi );
3729 if ( !aStrLoP.isEmpty() )
3738 if ( !aStrLoP.isEmpty() )
3793 if ( nChar && nChar != 8 && nChar != 127 &&
3794 KeyFuncType::CUT != eFunc)
3805 if ( bUsed && nChar ==
'(' )
3826 bool bSetModified = !bCursorKey;
3896 if ( rCEvt.
GetCommand() == CommandEventId::CursorPos )
3912 else if ( rCEvt.
GetCommand() == CommandEventId::QueryCharPosition )
3977 if ( rCEvt.
GetCommand() == CommandEventId::EndExtTextInput )
4014 if (bRepeat && !bForce)
4048 bool bIgnore =
false;
4066 bool bTxtMod =
false;
4074 else if ( bHadObject )
4081 if ( bTxtMod || bForce )
4110 bool bSheetLocal =
false;
4117 GetRangeAtBlock(
ScRange( rSPos, rEPos ), aPosStr, &bSheetLocal);
4119 if ( aPosStr.isEmpty() )
4124 if ( rSPos != rEPos )
4133 else if (bSheetLocal)
4162 if ( nCntrl & EEControlBits::ONLINESPELLING )
4163 mpEditEngine->SetControlWord( nCntrl & ~EEControlBits::ONLINESPELLING );
4222 if ( !(
nullptr == pLastState ||
SC_MOD()->IsFormulaMode() ||
SC_MOD()->IsRefDialogOpen()))
4227 if ( pViewFrm && pViewFrm->
GetChildWindow( SID_OPENDLG_FUNCTION ) )
4231 pInputWin->EnableButtons(
false );
4232 pInputWin->Disable();
4235 else if ( !bFormulaMode )
4237 bInOwnChange =
true;
4239 pActiveViewSh =
nullptr;
4245 pInputWin->Disable();
4248 bInOwnChange =
false;
4267 bool bFromTopNotify = ( bFromNotify && pView ==
pTopView );
4317 if ( eFieldState == SfxItemState::DONTCARE || eFieldState == SfxItemState::SET )
4320 std::unique_ptr<EditTextObject> pObj =
mpEditEngine->CreateTextObject();
4325 for (sal_Int32
i=0;
i<nParCnt;
i++)
4329 while ( nParCnt > 1 )
4331 sal_Int32 nLen = rDestEngine.
GetTextLen( 0 );
4381 if ( nStart <= nEnd )
4407 sal_Int32 nNewLen = rStr.getLength();
4411 aBuf.remove(nFormSelStart, nOldLen);
4413 aBuf.insert(nFormSelStart, rStr);
4450 const OUString& rString,
4452 : aCursorPos ( rCurPos ),
4453 aStartPos ( rStartPos ),
4454 aEndPos ( rEndPos ),
4455 aString ( rString ),
4456 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)
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
SfxPrinter * GetPrinter(bool bCreateIfNotExist=true)
bool isLetterNumeric(const OUString &rStr, sal_Int32 nPos) 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)