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");
274 mxEdit->set_text( sEdit );
297 if (!command.empty())
298 mxEdit->replace_selection(OUString::fromUtf8(command) +
" ");
308 std::unique_ptr<weld::Menu> xPopMenu(xBuilder->weld_menu(
"menu"));
311 MenuHdl(xPopMenu->popup_at_rect(pParent, aRect));
340 pView->GetViewFrame().GetDispatcher()->Execute(
FN_EDIT_FORMULA, SfxCallMode::ASYNCHRON);
352 if( !sEdit.isEmpty() &&
'=' == sEdit[0] )
353 sEdit = sEdit.copy( 1 );
375 pView->GetViewFrame().GetDispatcher()->Execute(
FN_EDIT_FORMULA, SfxCallMode::ASYNCHRON);
400 if(m_pWrtShell && m_bIsTable)
403 OUString sBoxNms( rCaller.GetBoxNms() );
405 if( pTableFormat && m_aCurrentTableName != pTableFormat->
GetName() )
406 sTableNm = pTableFormat->
GetName();
408 mxEdit->UpdateRange( sBoxNms, sTableNm );
410 OUString sNew = OUStringChar(
CH_LRE) + mxEdit->get_text()
413 if( sNew != m_sOldFormula )
418 m_pWrtShell->StartAllAction();
420 SwPaM aPam( *m_pWrtShell->GetStackCursor()->GetPoint() );
428 m_pWrtShell->EndAllAction();
429 m_sOldFormula = sNew;
439 if( !rFormula.isEmpty() )
441 if(
'=' == rFormula[0] )
446 mxEdit->set_text( sEdit );
447 mxEdit->select_region(sEdit.getLength(), sEdit.getLength());
453 if (m_pWrtShell && m_bIsTable && m_bResetUndo)
455 m_pWrtShell->StartAllAction();
457 OUString sNew = OUStringChar(
CH_LRE) + mxEdit->get_text()
459 m_pWrtShell->SwEditShell::Insert2( sNew );
460 m_pWrtShell->EndAllAction();
461 m_sOldFormula = sNew;
483 bool bHandled =
false;
494 return bHandled || ChildKeyInput(rEvent);
504 const OUString& rName )
513 OUString aPrefix = rName;
516 OUString aBoxes = aPrefix + rBoxes;
518 int nSelStartPos, nSelEndPos;
519 m_xWidget->get_selection_bounds(nSelStartPos, nSelEndPos);
521 Selection aSelection(nSelStartPos, nSelEndPos);
522 sal_uInt16 nSel = o3tl::narrowing<sal_uInt16>(aSelection.
Len());
525 if( nSel && ( nSel > 1 ||
526 m_xWidget->get_text()[ o3tl::narrowing<sal_uInt16>(aSelection.
Min()) ] != cClose ))
529 aSelection.
Max() = aSelection.
Min();
530 OUString aActText(
m_xWidget->get_text());
531 const sal_uInt16 nLen = aActText.getLength();
534 OUString
aStr = OUStringChar(cOpen) + aBoxes + OUStringChar(cClose);
536 sal_Int32
nPos =
aStr.indexOf( cClose );
537 OSL_ENSURE(
nPos != -1,
"delimiter not found");
545 sal_uInt16
nPos, nEndPos = 0, nStartPos = o3tl::narrowing<sal_uInt16>(aSelection.
Min());
549 if( cOpen == (cCh = aActText[ nStartPos ] ) ||
550 cOpenBracket == cCh )
552 bFound = cCh == cOpen;
555 }
while( nStartPos-- > 0 );
561 while( nEndPos < nLen )
563 if( cClose == aActText[ nEndPos ] )
572 o3tl::narrowing<sal_uInt16>(aSelection.
Max()) > nEndPos + 1 ))
577 nPos = ++nStartPos + 1;
578 aActText = aActText.replaceAt( nStartPos, nEndPos - nStartPos, aBoxes );
583 OUString aTmp = OUStringChar(cOpen) + aBoxes + OUStringChar(cClose);
584 nPos = o3tl::narrowing<sal_uInt16>(aSelection.
Min());
585 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().
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
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)
PaM is Point and Mark: a selection of the document model.
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.
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 OStringLiteral HID_TBX_FORMULA_APPLY
constexpr OStringLiteral HID_EDIT_FORMULA
constexpr OStringLiteral HID_TBX_FORMULA_CANCEL
constexpr OStringLiteral HID_TBX_FORMULA_CALC
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)