1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <starmath.hrc>
23 #include <vcl/commandevent.hxx>
24 #include <vcl/event.hxx>
25 #include <vcl/ptrstyle.hxx>
26 #include <vcl/settings.hxx>
28 #include <editeng/editview.hxx>
29 #include <editeng/editeng.hxx>
30 #include <sfx2/dispatch.hxx>
31 #include <sfx2/sfxsids.hrc>
32 #include <svl/stritem.hxx>
33 #include <sfx2/viewfrm.hxx>
34 #include <osl/diagnose.h>
35 #include <o3tl/string_view.hxx>
40 #include <document.hxx>
41 #include <cfgitem.hxx>
42 #include <smediteng.hxx>
44 using namespace com::sun::star::accessibility
;
45 using namespace com::sun::star
;
48 void SmGetLeftSelectionPart(const ESelection
&rSel
,
49 sal_Int32
&nPara
, sal_uInt16
&nPos
)
50 // returns paragraph number and position of the selections left part
52 // compare start and end of selection and use the one that comes first
53 if ( rSel
.nStartPara
< rSel
.nEndPara
54 || (rSel
.nStartPara
== rSel
.nEndPara
&& rSel
.nStartPos
< rSel
.nEndPos
) )
55 { nPara
= rSel
.nStartPara
;
56 nPos
= rSel
.nStartPos
;
59 { nPara
= rSel
.nEndPara
;
64 SmEditTextWindow::SmEditTextWindow(SmEditWindow
& rEditWindow
)
65 : mrEditWindow(rEditWindow
)
66 , aModifyIdle("SmEditWindow ModifyIdle")
67 , aCursorMoveIdle("SmEditWindow CursorMoveIdle")
71 aModifyIdle
.SetInvokeHandler(LINK(this, SmEditTextWindow
, ModifyTimerHdl
));
72 aModifyIdle
.SetPriority(TaskPriority::LOWEST
);
74 if (!SmViewShell::IsInlineEditEnabled())
76 aCursorMoveIdle
.SetInvokeHandler(LINK(this, SmEditTextWindow
, CursorMoveTimerHdl
));
77 aCursorMoveIdle
.SetPriority(TaskPriority::LOWEST
);
81 SmEditTextWindow::~SmEditTextWindow()
87 EditEngine
* SmEditTextWindow::GetEditEngine() const
89 SmDocShell
*pDoc
= mrEditWindow
.GetDoc();
91 return &pDoc
->GetEditEngine();
94 void SmEditTextWindow::EditViewScrollStateChange()
96 mrEditWindow
.SetScrollBarRanges();
99 void SmEditTextWindow::SetDrawingArea(weld::DrawingArea
* pDrawingArea
)
101 weld::CustomWidgetController::SetDrawingArea(pDrawingArea
);
103 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
104 Color aBgColor
= rStyleSettings
.GetWindowColor();
106 OutputDevice
& rDevice
= pDrawingArea
->get_ref_device();
107 rDevice
.SetBackground(aBgColor
);
109 SetHelpId(HID_SMA_COMMAND_WIN_EDIT
);
113 EditEngine
* pEditEngine
= GetEditEngine();
115 m_xEditView
.reset(new EditView(pEditEngine
, nullptr));
116 m_xEditView
->setEditViewCallbacks(this);
118 pEditEngine
->InsertView(m_xEditView
.get());
120 m_xEditView
->SetOutputArea(mrEditWindow
.AdjustScrollBars());
122 m_xEditView
->SetBackgroundColor(aBgColor
);
124 pDrawingArea
->set_cursor(PointerStyle::Text
);
126 pEditEngine
->SetStatusEventHdl(LINK(this, SmEditTextWindow
, EditStatusHdl
));
130 //Apply zoom to smeditwindow text
132 static_cast<SmEditEngine
*>(GetEditEngine())->executeZoom(GetEditView());
135 SmEditWindow::SmEditWindow(SmCmdBoxWindow
&rMyCmdBoxWin
, weld::Builder
& rBuilder
)
136 : rCmdBox(rMyCmdBoxWin
)
137 , mxScrolledWindow(rBuilder
.weld_scrolled_window("scrolledwindow", true))
139 mxScrolledWindow
->connect_vadjustment_changed(LINK(this, SmEditWindow
, ScrollHdl
));
141 CreateEditView(rBuilder
);
144 SmEditWindow::~SmEditWindow() COVERITY_NOEXCEPT_FALSE
147 mxScrolledWindow
.reset();
150 weld::Window
* SmEditWindow::GetFrameWeld() const
152 return rCmdBox
.GetFrameWeld();
155 void SmEditTextWindow::StartCursorMove()
157 if (!SmViewShell::IsInlineEditEnabled())
158 aCursorMoveIdle
.Stop();
161 void SmEditWindow::InvalidateSlots()
163 SfxBindings
& rBind
= GetView()->GetViewFrame().GetBindings();
164 rBind
.Invalidate(SID_COPY
);
165 rBind
.Invalidate(SID_CUT
);
166 rBind
.Invalidate(SID_DELETE
);
169 SmViewShell
* SmEditWindow::GetView()
171 return rCmdBox
.GetView();
174 SmDocShell
* SmEditWindow::GetDoc()
176 SmViewShell
*pView
= rCmdBox
.GetView();
177 return pView
? pView
->GetDoc() : nullptr;
180 EditView
* SmEditWindow::GetEditView() const
182 return mxTextControl
? mxTextControl
->GetEditView() : nullptr;
185 EditEngine
* SmEditWindow::GetEditEngine()
187 if (SmDocShell
*pDoc
= GetDoc())
188 return &pDoc
->GetEditEngine();
192 void SmEditTextWindow::StyleUpdated()
194 WeldEditView::StyleUpdated();
195 EditEngine
*pEditEngine
= GetEditEngine();
196 SmDocShell
*pDoc
= mrEditWindow
.GetDoc();
198 if (pEditEngine
&& pDoc
)
201 //! see also SmDocShell::GetEditEngine() !
203 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
205 pDoc
->UpdateEditEngineDefaultFonts();
206 pEditEngine
->SetBackgroundColor(rStyleSettings
.GetFieldColor());
207 pEditEngine
->SetDefTab(sal_uInt16(GetTextWidth("XXXX")));
209 // forces new settings to be used
210 // unfortunately this resets the whole edit engine
211 // thus we need to save at least the text
212 OUString
aTxt( pEditEngine
->GetText() );
213 pEditEngine
->Clear(); //incorrect font size
214 pEditEngine
->SetText( aTxt
);
219 // Apply zoom to smeditwindow text
220 static_cast<SmEditEngine
*>(GetEditEngine())->executeZoom(GetEditView());
223 IMPL_LINK_NOARG(SmEditTextWindow
, ModifyTimerHdl
, Timer
*, void)
229 IMPL_LINK_NOARG(SmEditTextWindow
, CursorMoveTimerHdl
, Timer
*, void)
230 // every once in a while check cursor position (selection) of edit
231 // window and if it has changed (try to) set the formula-cursor
232 // according to that.
234 if (SmViewShell::IsInlineEditEnabled())
237 ESelection
aNewSelection(GetSelection());
239 if (aNewSelection
!= aOldSelection
)
241 if (SmViewShell
*pViewSh
= mrEditWindow
.GetView())
243 // get row and column to look for
246 SmGetLeftSelectionPart(aNewSelection
, nRow
, nCol
);
247 pViewSh
->GetGraphicWidget().SetCursorPos(static_cast<sal_uInt16
>(nRow
), nCol
);
248 aOldSelection
= aNewSelection
;
251 aCursorMoveIdle
.Stop();
254 bool SmEditTextWindow::MouseButtonUp(const MouseEvent
&rEvt
)
256 bool bRet
= WeldEditView::MouseButtonUp(rEvt
);
257 if (!SmViewShell::IsInlineEditEnabled())
258 CursorMoveTimerHdl(&aCursorMoveIdle
);
259 mrEditWindow
.InvalidateSlots();
263 bool SmEditTextWindow::Command(const CommandEvent
& rCEvt
)
265 // no zooming in Command window
266 const CommandWheelData
* pWData
= rCEvt
.GetWheelData();
267 if (pWData
&& CommandWheelMode::ZOOM
== pWData
->GetMode())
270 //pass alt press/release to parent impl
271 if (rCEvt
.GetCommand() == CommandEventId::ModKeyChange
)
274 if (rCEvt
.GetCommand() == CommandEventId::ContextMenu
)
277 SmCmdBoxWindow
& rCmdBox
= mrEditWindow
.GetCmdBox();
278 rCmdBox
.ShowContextMenu(rCmdBox
.WidgetToWindowPos(*GetDrawingArea(), rCEvt
.GetMousePosPixel()));
283 bool bConsumed
= WeldEditView::Command(rCEvt
);
285 UserPossiblyChangedText();
289 bool SmEditTextWindow::KeyInput(const KeyEvent
& rKEvt
)
291 if (rKEvt
.GetKeyCode().GetCode() == KEY_ESCAPE
)
293 bool bCallBase
= true;
294 SfxViewShell
* pViewShell
= mrEditWindow
.GetView();
295 if ( dynamic_cast<const SmViewShell
*>(pViewShell
) )
297 // Terminate possible InPlace mode
298 bCallBase
= !pViewShell
->Escape();
305 bool autoClose
= false;
306 EditView
* pEditView
= GetEditView();
307 ESelection aSelection
= pEditView
->GetSelection();
308 // as we don't support RTL in Math, we need to swap values from selection when they were done
311 OUString selected
= pEditView
->GetEditEngine()->GetText(aSelection
);
313 // Check is auto close brackets/braces is disabled
314 SmModule
*pMod
= SM_MOD();
315 if (pMod
&& !pMod
->GetConfig()->IsAutoCloseBrackets())
317 else if (o3tl::trim(selected
) == u
"<?>")
319 else if (selected
.isEmpty() && !aSelection
.HasRange())
321 selected
= pEditView
->GetEditEngine()->GetText(aSelection
.nEndPara
);
322 if (!selected
.isEmpty())
324 sal_Int32 index
= selected
.indexOf("\n", aSelection
.nEndPos
);
327 selected
= selected
.copy(index
, sal_Int32(aSelection
.nEndPos
-index
));
328 if (o3tl::trim(selected
).empty())
333 sal_Int32 length
= selected
.getLength();
334 if (aSelection
.nEndPos
== length
)
338 selected
= selected
.copy(aSelection
.nEndPos
);
339 if (o3tl::trim(selected
).empty())
348 bool bConsumed
= WeldEditView::KeyInput(rKEvt
);
351 SmViewShell
*pView
= mrEditWindow
.GetView();
353 bConsumed
= pView
->KeyInput(rKEvt
);
354 if (pView
&& !bConsumed
)
356 // F1 (help) leads to the destruction of this
358 if ( aModifyIdle
.IsActive() )
363 // SFX has maybe called a slot of the view and thus (because of a hack in SFX)
364 // set the focus to the view
365 SmViewShell
* pVShell
= mrEditWindow
.GetView();
366 if ( pVShell
&& pVShell
->GetGraphicWidget().HasFocus() )
374 UserPossiblyChangedText();
377 // get the current char of the key event
378 sal_Unicode cCharCode
= rKEvt
.GetCharCode();
381 if (cCharCode
== '{')
383 else if (cCharCode
== '[')
385 else if (cCharCode
== '(')
388 // auto close the current character only when needed
389 if (!sClose
.isEmpty() && autoClose
)
391 pEditView
->InsertText(sClose
);
392 // position it at center of brackets
393 aSelection
.nStartPos
+= 2;
394 aSelection
.nEndPos
= aSelection
.nStartPos
;
395 pEditView
->SetSelection(aSelection
);
398 mrEditWindow
.InvalidateSlots();
402 void SmEditTextWindow::UserPossiblyChangedText()
404 // have doc-shell modified only for formula input/change and not
405 // cursor travelling and such things...
406 SmDocShell
*pDocShell
= mrEditWindow
.GetDoc();
407 EditEngine
*pEditEngine
= GetEditEngine();
408 if (pDocShell
&& pEditEngine
&& pEditEngine
->IsModified())
409 pDocShell
->SetModified(true);
413 void SmEditWindow::CreateEditView(weld::Builder
& rBuilder
)
415 assert(!mxTextControl
);
417 EditEngine
*pEditEngine
= GetEditEngine();
418 //! pEditEngine may be 0.
419 //! For example when the program is used by the document-converter
423 mxTextControl
.reset(new SmEditTextWindow(*this));
424 mxTextControlWin
.reset(new weld::CustomWeld(rBuilder
, "editview", *mxTextControl
));
426 SetScrollBarRanges();
429 IMPL_LINK_NOARG(SmEditTextWindow
, EditStatusHdl
, EditStatus
&, void)
434 IMPL_LINK(SmEditWindow
, ScrollHdl
, weld::ScrolledWindow
&, rScrolledWindow
, void)
436 if (EditView
* pEditView
= GetEditView())
438 pEditView
->SetVisArea(tools::Rectangle(
440 rScrolledWindow
.vadjustment_get_value()),
441 pEditView
->GetVisArea().GetSize()));
442 pEditView
->Invalidate();
446 tools::Rectangle
SmEditWindow::AdjustScrollBars()
448 tools::Rectangle
aRect(Point(), rCmdBox
.GetOutputSizePixel());
450 if (mxScrolledWindow
)
452 const auto nScrollSize
= mxScrolledWindow
->get_scroll_thickness();
453 const auto nMargin
= nScrollSize
+ 2;
454 aRect
.AdjustRight(-nMargin
);
455 aRect
.AdjustBottom(-nMargin
);
461 void SmEditWindow::SetScrollBarRanges()
463 EditEngine
*pEditEngine
= GetEditEngine();
466 if (!mxScrolledWindow
)
468 EditView
* pEditView
= GetEditView();
472 int nVUpper
= pEditEngine
->GetTextHeight();
473 int nVCurrentDocPos
= pEditView
->GetVisArea().Top();
474 const Size
aOut(pEditView
->GetOutputArea().GetSize());
475 int nVStepIncrement
= aOut
.Height() * 2 / 10;
476 int nVPageIncrement
= aOut
.Height() * 8 / 10;
477 int nVPageSize
= aOut
.Height();
479 /* limit the page size to below nUpper because gtk's gtk_scrolled_window_start_deceleration has
482 lower = gtk_adjustment_get_lower
483 upper = gtk_adjustment_get_upper - gtk_adjustment_get_page_size
485 and requires that upper > lower or the deceleration animation never ends
487 nVPageSize
= std::min(nVPageSize
, nVUpper
);
489 mxScrolledWindow
->vadjustment_configure(nVCurrentDocPos
, 0, nVUpper
,
490 nVStepIncrement
, nVPageIncrement
, nVPageSize
);
493 OUString
SmEditWindow::GetText() const
496 EditEngine
*pEditEngine
= const_cast< SmEditWindow
* >(this)->GetEditEngine();
497 OSL_ENSURE( pEditEngine
, "EditEngine missing" );
499 aText
= pEditEngine
->GetText();
503 void SmEditWindow::SetText(const OUString
& rText
)
507 mxTextControl
->SetText(rText
);
510 void SmEditWindow::Flush()
514 mxTextControl
->Flush();
517 void SmEditWindow::GrabFocus()
521 mxTextControl
->GrabFocus();
524 void SmEditTextWindow::SetText(const OUString
& rText
)
526 EditEngine
*pEditEngine
= GetEditEngine();
527 OSL_ENSURE( pEditEngine
, "EditEngine missing" );
528 if (!pEditEngine
|| pEditEngine
->IsModified())
531 EditView
* pEditView
= GetEditView();
532 ESelection eSelection
= pEditView
->GetSelection();
534 pEditEngine
->SetText(rText
);
535 pEditEngine
->ClearModifyFlag();
537 // Restarting the timer here, prevents calling the handlers for other (currently inactive)
541 // Apply zoom to smeditwindow text
542 static_cast<SmEditEngine
*>(pEditView
->GetEditEngine())->executeZoom(pEditView
);
543 pEditView
->SetSelection(eSelection
);
546 void SmEditTextWindow::GetFocus()
548 WeldEditView::GetFocus();
550 EditEngine
*pEditEngine
= GetEditEngine();
552 pEditEngine
->SetStatusEventHdl(LINK(this, SmEditTextWindow
, EditStatusHdl
));
554 //Let SmViewShell know we got focus
555 if (mrEditWindow
.GetView() && SmViewShell::IsInlineEditEnabled())
556 mrEditWindow
.GetView()->SetInsertIntoEditWindow(true);
559 void SmEditTextWindow::LoseFocus()
561 EditEngine
*pEditEngine
= GetEditEngine();
563 pEditEngine
->SetStatusEventHdl( Link
<EditStatus
&,void>() );
565 WeldEditView::LoseFocus();
568 bool SmEditWindow::IsAllSelected() const
570 EditEngine
*pEditEngine
= const_cast<SmEditWindow
*>(this)->GetEditEngine();
573 EditView
* pEditView
= GetEditView();
577 ESelection
eSelection( pEditView
->GetSelection() );
578 sal_Int32 nParaCnt
= pEditEngine
->GetParagraphCount();
581 sal_Int32 nTextLen
= pEditEngine
->GetText().getLength();
582 bRes
= !eSelection
.nStartPos
&& (eSelection
.nEndPos
== nTextLen
- 1);
586 bRes
= !eSelection
.nStartPara
&& (eSelection
.nEndPara
== nParaCnt
- 1);
591 void SmEditWindow::SelectAll()
593 if (EditView
* pEditView
= GetEditView())
595 // ALL as last two parameters refers to the end of the text
596 pEditView
->SetSelection( ESelection( 0, 0, EE_PARA_ALL
, EE_TEXTPOS_ALL
) );
600 void SmEditWindow::MarkError(const Point
&rPos
)
602 if (EditView
* pEditView
= GetEditView())
604 const sal_uInt16 nCol
= sal::static_int_cast
< sal_uInt16
>(rPos
.X());
605 const sal_uInt16 nRow
= sal::static_int_cast
< sal_uInt16
>(rPos
.Y() - 1);
607 pEditView
->SetSelection(ESelection(nRow
, nCol
- 1, nRow
, nCol
));
612 void SmEditWindow::SelNextMark()
616 mxTextControl
->SelNextMark();
619 // Makes selection to next <?> symbol
620 void SmEditTextWindow::SelNextMark()
622 EditEngine
*pEditEngine
= GetEditEngine();
625 EditView
* pEditView
= GetEditView();
629 ESelection eSelection
= pEditView
->GetSelection();
630 sal_Int32 nPos
= eSelection
.nEndPos
;
631 sal_Int32 nCounts
= pEditEngine
->GetParagraphCount();
633 while (eSelection
.nEndPara
< nCounts
)
635 OUString aText
= pEditEngine
->GetText(eSelection
.nEndPara
);
636 nPos
= aText
.indexOf("<?>", nPos
);
639 pEditView
->SetSelection(ESelection(
640 eSelection
.nEndPara
, nPos
, eSelection
.nEndPara
, nPos
+ 3));
645 eSelection
.nEndPara
++;
649 void SmEditWindow::SelPrevMark()
651 EditEngine
*pEditEngine
= GetEditEngine();
654 EditView
* pEditView
= GetEditView();
658 ESelection eSelection
= pEditView
->GetSelection();
659 sal_Int32 nPara
= eSelection
.nStartPara
;
660 sal_Int32 nMax
= eSelection
.nStartPos
;
661 OUString
aText(pEditEngine
->GetText(nPara
));
662 static const OUStringLiteral
aMark(u
"<?>");
665 while ( (nPos
= aText
.lastIndexOf(aMark
, nMax
)) < 0 )
669 aText
= pEditEngine
->GetText(nPara
);
670 nMax
= aText
.getLength();
672 pEditView
->SetSelection(ESelection(nPara
, nPos
, nPara
, nPos
+ 3));
675 // returns true iff 'rText' contains a mark
676 static bool HasMark(std::u16string_view rText
)
678 return rText
.find(u
"<?>") != std::u16string_view::npos
;
681 ESelection
SmEditWindow::GetSelection() const
684 return mxTextControl
->GetSelection();
688 ESelection
SmEditTextWindow::GetSelection() const
690 // pointer may be 0 when reloading a document and the old view
691 // was already destroyed
692 if (EditView
* pEditView
= GetEditView())
693 return pEditView
->GetSelection();
697 void SmEditWindow::SetSelection(const ESelection
&rSel
)
699 if (EditView
* pEditView
= GetEditView())
700 pEditView
->SetSelection(rSel
);
704 bool SmEditWindow::IsEmpty() const
706 EditEngine
*pEditEngine
= const_cast<SmEditWindow
*>(this)->GetEditEngine();
707 bool bEmpty
= ( pEditEngine
&& pEditEngine
->GetTextLen() == 0 );
711 bool SmEditWindow::IsSelected() const
713 EditView
* pEditView
= GetEditView();
714 return pEditView
&& pEditView
->HasSelection();
717 void SmEditTextWindow::UpdateStatus(bool bSetDocModified
)
719 SmModule
*pMod
= SM_MOD();
720 if (pMod
&& pMod
->GetConfig()->IsAutoRedraw())
723 if (SmDocShell
*pModifyDoc
= bSetDocModified
? mrEditWindow
.GetDoc() : nullptr)
724 pModifyDoc
->SetModified();
726 static_cast<SmEditEngine
*>(GetEditEngine())->executeZoom(GetEditView());
729 void SmEditWindow::UpdateStatus()
731 mxTextControl
->UpdateStatus(/*bSetDocModified*/false);
734 void SmEditWindow::Cut()
738 mxTextControl
->Cut();
739 mxTextControl
->UpdateStatus(true);
743 void SmEditWindow::Copy()
746 mxTextControl
->Copy();
749 void SmEditWindow::Paste()
753 mxTextControl
->Paste();
754 mxTextControl
->UpdateStatus(true);
758 void SmEditWindow::Delete()
762 mxTextControl
->Delete();
763 mxTextControl
->UpdateStatus(true);
767 void SmEditWindow::InsertText(const OUString
& rText
)
771 mxTextControl
->InsertText(rText
);
774 void SmEditTextWindow::InsertText(const OUString
& rText
)
776 EditView
* pEditView
= GetEditView();
780 // Note: Insertion of a space in front of commands is done here and
781 // in SmEditWindow::InsertCommand.
782 ESelection aSelection
= pEditView
->GetSelection();
783 OUString aCurrentFormula
= pEditView
->GetEditEngine()->GetText();
784 sal_Int32 nStartIndex
= 0;
786 // get the start position (when we get a multi line formula)
787 for (sal_Int32 nParaPos
= 0; nParaPos
< aSelection
.nStartPara
; nParaPos
++)
788 nStartIndex
= aCurrentFormula
.indexOf("\n", nStartIndex
) + 1;
790 nStartIndex
+= aSelection
.nStartPos
;
792 // TODO: unify this function with the InsertCommand: The do the same thing for different
794 OUString
string(rText
);
796 OUString
selected(pEditView
->GetSelected());
797 // if we have text selected, use it in the first placeholder
798 if (!selected
.isEmpty())
799 string
= string
.replaceFirst("<?>", selected
);
801 // put a space before a new command if not in the beginning of a line
802 if (aSelection
.nStartPos
> 0 && aCurrentFormula
[nStartIndex
- 1] != ' ')
803 string
= " " + string
;
805 pEditView
->InsertText(string
);
807 // Remember start of the selection and move the cursor there afterwards.
808 aSelection
.nEndPara
= aSelection
.nStartPara
;
811 aSelection
.nEndPos
= aSelection
.nStartPos
;
812 pEditView
->SetSelection(aSelection
);
816 { // set selection after inserted text
817 aSelection
.nEndPos
= aSelection
.nStartPos
+ string
.getLength();
818 aSelection
.nStartPos
= aSelection
.nEndPos
;
819 pEditView
->SetSelection(aSelection
);
828 void SmEditTextWindow::Flush()
830 EditEngine
*pEditEngine
= GetEditEngine();
831 if (pEditEngine
&& pEditEngine
->IsModified())
833 pEditEngine
->ClearModifyFlag();
834 if (SmViewShell
*pViewSh
= mrEditWindow
.GetView())
836 SfxStringItem
aTextToFlush(SID_TEXT
, GetText());
837 pViewSh
->GetViewFrame().GetDispatcher()->ExecuteList(
838 SID_TEXT
, SfxCallMode::RECORD
,
842 if (aCursorMoveIdle
.IsActive())
844 aCursorMoveIdle
.Stop();
845 CursorMoveTimerHdl(&aCursorMoveIdle
);
849 void SmEditWindow::DeleteEditView()
851 if (EditView
* pEditView
= GetEditView())
853 if (EditEngine
* pEditEngine
= pEditView
->GetEditEngine())
855 pEditEngine
->SetStatusEventHdl( Link
<EditStatus
&,void>() );
856 pEditEngine
->RemoveView(pEditView
);
858 mxTextControlWin
.reset();
859 mxTextControl
.reset();
863 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */