23#include <osl/diagnose.h>
26#include <officecfg/Office/Common.hxx>
41#include <inputwin.hxx>
49#include <bitmaps.hlst>
68 return ChildKeyInput(rKEvt);
75 , m_pWrtShell(nullptr)
97 if (pDispatcherView == pActiveView)
103 mxPos->set_accessible_name(
SwResId(STR_ACCESS_FORMULA_TYPE));
109 mxEdit->set_accessible_name(
SwResId(STR_ACCESS_FORMULA_TEXT));
119 if( nMaxHeight+2 > aSizeTbx.
Height() )
131 aPosPos.
setY( (aSize.
Height() - nMaxHeight)/2 + 1 );
132 aEditPos.
setY( (aSize.
Height() - nMaxHeight)/2 + 1 );
133 mxPos->SetPosSizePixel( aPosPos, aPosSize );
134 mxEdit->SetPosSizePixel( aEditPos, aEditSize );
187 mxEdit->SetSizePixel( aEditSize );
204 SelTableCellsNotify) );
210 while( (
nPos = rPos.indexOf(
':',
nPos + 1 ) ) != -1 )
211 nSrch =
static_cast<short>(
nPos);
212 mxPos->set_text( rPos.copy( ++nSrch ) );
219 OSL_ENSURE(
m_pMgr ==
nullptr,
"FieldManager not deleted");
226 sEdit +=
m_pMgr->GetCurFieldPar2();
233 "sw",
"/org.openoffice.Office.Common/Undo/Steps <= 0");
292 mxEdit->set_text( sEdit );
315 if (!command.empty())
316 mxEdit->replace_selection(OUString::Concat(command) +
" ");
326 std::unique_ptr<weld::Menu> xPopMenu(xBuilder->weld_menu(
"menu"));
329 MenuHdl(xPopMenu->popup_at_rect(pParent, aRect));
358 pView->GetViewFrame().GetDispatcher()->Execute(
FN_EDIT_FORMULA, SfxCallMode::ASYNCHRON);
370 if( !sEdit.isEmpty() &&
'=' == sEdit[0] )
371 sEdit = sEdit.copy( 1 );
393 pView->GetViewFrame().GetDispatcher()->Execute(
FN_EDIT_FORMULA, SfxCallMode::ASYNCHRON);
418 if(m_pWrtShell && m_bIsTable)
421 OUString sBoxNms( rCaller.GetBoxNms() );
423 if( pTableFormat && m_aCurrentTableName != pTableFormat->
GetName() )
424 sTableNm = pTableFormat->
GetName();
426 mxEdit->UpdateRange( sBoxNms, sTableNm );
428 OUString sNew = OUStringChar(
CH_LRE) + mxEdit->get_text()
431 if( sNew != m_sOldFormula )
436 m_pWrtShell->StartAllAction();
438 SwPaM aPam( *m_pWrtShell->GetStackCursor()->GetPoint() );
446 m_pWrtShell->EndAllAction();
447 m_sOldFormula = sNew;
457 if( !rFormula.isEmpty() )
459 if(
'=' == rFormula[0] )
464 mxEdit->set_text( sEdit );
465 mxEdit->select_region(sEdit.getLength(), sEdit.getLength());
471 if (m_pWrtShell && m_bIsTable && m_bResetUndo)
473 m_pWrtShell->StartAllAction();
475 OUString sNew = OUStringChar(
CH_LRE) + mxEdit->get_text()
477 m_pWrtShell->SwEditShell::Insert2( sNew );
478 m_pWrtShell->EndAllAction();
479 m_sOldFormula = sNew;
501 bool bHandled =
false;
512 return bHandled || ChildKeyInput(rEvent);
522 const OUString& rName )
531 OUString aPrefix = rName;
534 OUString aBoxes = aPrefix + rBoxes;
536 int nSelStartPos, nSelEndPos;
537 m_xWidget->get_selection_bounds(nSelStartPos, nSelEndPos);
539 Selection aSelection(nSelStartPos, nSelEndPos);
540 sal_uInt16 nSel = o3tl::narrowing<sal_uInt16>(aSelection.
Len());
543 if( nSel && ( nSel > 1 ||
544 m_xWidget->get_text()[ o3tl::narrowing<sal_uInt16>(aSelection.
Min()) ] != cClose ))
547 aSelection.
Max() = aSelection.
Min();
548 OUString aActText(
m_xWidget->get_text());
549 const sal_uInt16 nLen = aActText.getLength();
552 OUString
aStr = OUStringChar(cOpen) + aBoxes + OUStringChar(cClose);
554 sal_Int32
nPos =
aStr.indexOf( cClose );
555 OSL_ENSURE(
nPos != -1,
"delimiter not found");
563 sal_uInt16
nPos, nEndPos = 0, nStartPos = o3tl::narrowing<sal_uInt16>(aSelection.
Min());
567 if( cOpen == (cCh = aActText[ nStartPos ] ) ||
568 cOpenBracket == cCh )
570 bFound = cCh == cOpen;
573 }
while( nStartPos-- > 0 );
579 while( nEndPos < nLen )
581 if( cClose == aActText[ nEndPos ] )
590 o3tl::narrowing<sal_uInt16>(aSelection.
Max()) > nEndPos + 1 ))
595 nPos = ++nStartPos + 1;
596 aActText = aActText.replaceAt( nStartPos, nEndPos - nStartPos, aBoxes );
601 OUString aTmp = OUStringChar(cOpen) + aBoxes + OUStringChar(cClose);
602 nPos = o3tl::narrowing<sal_uInt16>(aSelection.
Min());
603 aActText = aActText.replaceAt(
nPos, 0, aTmp );
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
Size GetSizePixel() const override
Text operation/manipulation interface.
virtual void DeleteRange(SwPaM &)=0
Delete a range SwFlyFrameFormat.
virtual bool InsertString(const SwPaM &rRg, const OUString &, const SwInsertFlags nInsertMode=SwInsertFlags::EMPTYEXPAND)=0
Insert string into existing text node at position rRg.Point().
void setY(tools::Long nY)
bool Execute(sal_uInt16 nSlot, const SfxPoolItem **pArgs=nullptr, SfxCallMode nCall=SfxCallMode::SLOT)
SfxDispatcher * GetDispatcher() const
void SetAlignment(SfxChildAlignment eAlign)
vcl::Window * GetWindow() const
virtual SfxChildWinInfo GetInfo() const
void SetWindow(const VclPtr< vcl::Window > &p)
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
SfxViewFrame * GetFrame() const
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
SfxViewShell * GetViewShell() const
SfxBindings & GetBindings()
SfxDispatcher * GetDispatcher()
SfxViewFrame & GetViewFrame() const
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
void SetActive(bool bOn=true)
void Push()
store a copy of the current cursor on the cursor stack
OUString GetBoxNms() const
const SwTableNode * IsCursorInTable() const
Check if Point of current cursor is placed within a table.
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
bool MoveSection(SwWhichSection, SwMoveFnCollection const &)
void StartAllAction()
For all views of this document.
SwUndoId StartUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
bool Delete(bool isArtificialSelection=false)
Delete content of all ranges.
SwFrameFormat * GetTableFormat()
bool GetTableBoxFormulaAttrs(SfxItemSet &rSet) const
void Undo(sal_uInt16 const nCount=1, sal_uInt16 nOffset=0)
SwUndoId EndUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Closes parenthesis of nUndoId, not used by UI.
void DoUndo(bool bOn=true)
Undo.
void LockKeyInput(bool bSet)
Base class of the Writer document model elements.
SwTableNode * FindTableNode()
Search table node, in which it is.
PaM is Point and Mark: a selection of the document model.
SwNode & GetPointNode() const
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
SwTable is one table in the document model, containing rows (which contain cells).
const SfxItemPool & GetAttrPool() const
SwWrtShell * GetWrtShellPtr() const
Used by the UI to modify the document model.
void SelTableCells(const Link< SwWrtShell &, void > &rLink)
bool Pop(SwCursorShell::PopMode, ::std::optional< SwCallLink > &roLink)
reference_type * get() const
virtual void SetSizePixel(const Size &rNewSize)
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
void SetAccessibleName(const OUString &rName)
constexpr OUStringLiteral HID_EDIT_FORMULA
constexpr OUStringLiteral HID_TBX_FORMULA_CANCEL
constexpr OUStringLiteral HID_TBX_FORMULA_CALC
constexpr OUStringLiteral HID_TBX_FORMULA_APPLY
constexpr TypedWhichId< SwTableBoxFormula > RES_BOXATR_FORMULA(157)
SFX_IMPL_POS_CHILDWINDOW_WITHID(SfxInfoBarContainerChild, SID_INFOBAR, SFX_OBJECTBAR_OBJECT)
constexpr sal_uInt16 KEY_RETURN
constexpr sal_uInt16 KEY_F2
constexpr sal_uInt16 KEY_ESCAPE
#define LINK(Instance, Class, Member)
#define SAL_WARN_IF(condition, area, stream)
OString strip(const OString &rIn, char c)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
weld::Window * GetPopupParent(vcl::Window &rOutWin, tools::Rectangle &rRect)
bool GoInSection(SwPaM &rPam, SwMoveFnCollection const &fnMove)
bool GoCurrSection(SwPaM &rPam, SwMoveFnCollection const &fnMove)
SwMoveFnCollection const & fnSectionEnd
SwMoveFnCollection const & fnMoveBackward
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
SwMoveFnCollection const & fnSectionStart
OUString SwResId(TranslateId aId)