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 <com/sun/star/accessibility/XAccessible.hpp>
21 #include <com/sun/star/accessibility/AccessibleEventObject.hpp>
22 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
23 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
24 #include <toolkit/helper/vclunohelper.hxx>
27 #include "starmath.hrc"
29 #include <vcl/menu.hxx>
30 #include <editeng/editview.hxx>
31 #include <editeng/editeng.hxx>
32 #include <editeng/editstat.hxx>
33 #include <editeng/eeitem.hxx>
34 #include <sfx2/dispatch.hxx>
35 #include <svl/intitem.hxx>
36 #include <svl/itempool.hxx>
37 #include <svl/stritem.hxx>
38 #include <editeng/fhgtitem.hxx>
39 #include <editeng/wghtitem.hxx>
40 #include <editeng/lrspitem.hxx>
41 #include <svl/itemset.hxx>
42 #include <editeng/fontitem.hxx>
43 #include <sfx2/viewfrm.hxx>
47 #include "document.hxx"
49 #include "accessibility.hxx"
51 #define SCROLL_LINE 24
54 using namespace com::sun::star::accessibility
;
55 using namespace com::sun::star
;
56 using namespace com::sun::star::uno
;
58 ////////////////////////////////////////
61 void SmGetLeftSelectionPart(const ESelection
&rSel
,
62 sal_Int32
&nPara
, sal_uInt16
&nPos
)
63 // returns paragraph number and position of the selections left part
65 // compare start and end of selection and use the one that comes first
66 if ( rSel
.nStartPara
< rSel
.nEndPara
67 || (rSel
.nStartPara
== rSel
.nEndPara
&& rSel
.nStartPos
< rSel
.nEndPos
) )
68 { nPara
= rSel
.nStartPara
;
69 nPos
= rSel
.nStartPos
;
72 { nPara
= rSel
.nEndPara
;
77 bool SmEditWindow::IsInlineEditEnabled()
79 SmViewShell
*pView
= GetView();
80 return pView
? pView
->IsInlineEditEnabled() : false;
83 ////////////////////////////////////////
85 SmEditWindow::SmEditWindow( SmCmdBoxWindow
&rMyCmdBoxWin
) :
86 Window (&rMyCmdBoxWin
),
87 DropTargetHelper ( this ),
89 rCmdBox (rMyCmdBoxWin
),
95 SetHelpId(HID_SMA_COMMAND_WIN_EDIT
);
96 SetMapMode(MAP_PIXEL
);
98 // Even RTL languages don't use RTL for math
99 rCmdBox
.GetEditWindow()->EnableRTL( false );
101 ApplyColorConfigValues( SM_MOD()->GetColorConfig() );
103 // compare DataChanged
104 SetBackground( GetSettings().GetStyleSettings().GetWindowColor() );
106 aModifyTimer
.SetTimeoutHdl(LINK(this, SmEditWindow
, ModifyTimerHdl
));
107 aModifyTimer
.SetTimeout(500);
109 if (!IsInlineEditEnabled())
111 aCursorMoveTimer
.SetTimeoutHdl(LINK(this, SmEditWindow
, CursorMoveTimerHdl
));
112 aCursorMoveTimer
.SetTimeout(500);
115 // if not called explicitly the this edit window within the
116 // command window will just show an empty gray panel.
121 SmEditWindow::~SmEditWindow()
127 // clean up of classes used for accessibility
128 // must be done before EditView (and thus EditEngine) is no longer
129 // available for those classes.
131 pAccessible
->ClearWin(); // make Accessible defunctional
132 // Note: memory for pAccessible will be freed when the reference
133 // xAccessible is released.
137 EditEngine
*pEditEngine
= pEditView
->GetEditEngine();
140 pEditEngine
->SetStatusEventHdl( Link() );
141 pEditEngine
->RemoveView( pEditView
);
150 void SmEditWindow::StartCursorMove()
152 if (!IsInlineEditEnabled())
153 aCursorMoveTimer
.Stop();
156 void SmEditWindow::InvalidateSlots()
158 SfxBindings
& rBind
= GetView()->GetViewFrame()->GetBindings();
159 rBind
.Invalidate(SID_COPY
);
160 rBind
.Invalidate(SID_CUT
);
161 rBind
.Invalidate(SID_DELETE
);
164 SmViewShell
* SmEditWindow::GetView()
166 return rCmdBox
.GetView();
170 SmDocShell
* SmEditWindow::GetDoc()
172 SmViewShell
*pView
= rCmdBox
.GetView();
173 return pView
? pView
->GetDoc() : 0;
177 EditEngine
* SmEditWindow::GetEditEngine()
179 EditEngine
*pEditEng
= 0;
181 pEditEng
= pEditView
->GetEditEngine();
184 SmDocShell
*pDoc
= GetDoc();
186 pEditEng
= &pDoc
->GetEditEngine();
192 SfxItemPool
* SmEditWindow::GetEditEngineItemPool()
194 SmDocShell
*pDoc
= GetDoc();
195 return pDoc
? &pDoc
->GetEditEngineItemPool() : 0;
198 void SmEditWindow::ApplyColorConfigValues( const svtools::ColorConfig
&rColorCfg
)
200 // Note: SetBackground still done in SmEditWindow::DataChanged
201 #if OSL_DEBUG_LEVEL > 1
202 // ColorData nVal = rColorCfg.GetColorValue(svtools::FONTCOLOR).nColor;
204 SetTextColor( rColorCfg
.GetColorValue(svtools::FONTCOLOR
).nColor
);
208 void SmEditWindow::DataChanged( const DataChangedEvent
& )
210 const StyleSettings
aSettings( GetSettings().GetStyleSettings() );
212 ApplyColorConfigValues( SM_MOD()->GetColorConfig() );
213 SetBackground( aSettings
.GetWindowColor() );
215 // edit fields in other Applications use this font instead of
216 // the application font thus we use this one too
217 SetPointFont( aSettings
.GetFieldFont() /*aSettings.GetAppFont()*/ );
219 EditEngine
*pEditEngine
= GetEditEngine();
220 SfxItemPool
*pEditEngineItemPool
= GetEditEngineItemPool();
222 if (pEditEngine
&& pEditEngineItemPool
)
225 //! see also SmDocShell::GetEditEngine() !
228 pEditEngine
->SetDefTab(sal_uInt16(GetTextWidth(OUString("XXXX"))));
230 SetEditEngineDefaultFonts(*pEditEngineItemPool
);
232 // forces new settings to be used
233 // unfortunately this resets the whole edit engine
234 // thus we need to save at least the text
235 OUString
aTxt( pEditEngine
->GetText( LINEEND_LF
) );
236 pEditEngine
->Clear(); //incorrect font size
237 pEditEngine
->SetText( aTxt
);
244 IMPL_LINK( SmEditWindow
, ModifyTimerHdl
, Timer
*, EMPTYARG
/*pTimer*/ )
251 IMPL_LINK(SmEditWindow
, CursorMoveTimerHdl
, Timer
*, EMPTYARG
/*pTimer*/)
252 // every once in a while check cursor position (selection) of edit
253 // window and if it has changed (try to) set the formula-cursor
254 // according to that.
256 if (IsInlineEditEnabled())
259 ESelection
aNewSelection(GetSelection());
261 if (!aNewSelection
.IsEqual(aOldSelection
))
263 SmViewShell
*pView
= rCmdBox
.GetView();
266 // get row and column to look for
269 SmGetLeftSelectionPart(aNewSelection
, nRow
, nCol
);
272 pView
->GetGraphicWindow().SetCursorPos(static_cast<sal_uInt16
>(nRow
), nCol
);
273 aOldSelection
= aNewSelection
;
276 aCursorMoveTimer
.Stop();
281 void SmEditWindow::Resize()
288 pEditView
->SetOutputArea(AdjustScrollBars());
289 pEditView
->ShowCursor();
291 OSL_ENSURE( pEditView
->GetEditEngine(), "EditEngine missing" );
292 const long nMaxVisAreaStart
= pEditView
->GetEditEngine()->GetTextHeight() -
293 pEditView
->GetOutputArea().GetHeight();
294 if (pEditView
->GetVisArea().Top() > nMaxVisAreaStart
)
296 Rectangle
aVisArea(pEditView
->GetVisArea() );
297 aVisArea
.Top() = (nMaxVisAreaStart
> 0 ) ? nMaxVisAreaStart
: 0;
298 aVisArea
.SetSize(pEditView
->GetOutputArea().GetSize());
299 pEditView
->SetVisArea(aVisArea
);
300 pEditView
->ShowCursor();
307 void SmEditWindow::MouseButtonUp(const MouseEvent
&rEvt
)
310 pEditView
->MouseButtonUp(rEvt
);
312 Window::MouseButtonUp (rEvt
);
314 if (!IsInlineEditEnabled())
315 CursorMoveTimerHdl(&aCursorMoveTimer
);
319 void SmEditWindow::MouseButtonDown(const MouseEvent
&rEvt
)
322 pEditView
->MouseButtonDown(rEvt
);
324 Window::MouseButtonDown (rEvt
);
329 void SmEditWindow::Command(const CommandEvent
& rCEvt
)
331 bool bForwardEvt
= true;
332 if (rCEvt
.GetCommand() == COMMAND_CONTEXTMENU
)
334 GetParent()->ToTop();
336 Point aPoint
= rCEvt
.GetMousePosPixel();
337 PopupMenu
* pPopupMenu
= new PopupMenu(SmResId(RID_COMMANDMENU
));
339 // added for replaceability of context menus
341 ::com::sun::star::ui::ContextMenuExecuteEvent aEvent
;
342 aEvent
.SourceWindow
= VCLUnoHelper::GetInterface( this );
343 aEvent
.ExecutePosition
.X
= aPoint
.X();
344 aEvent
.ExecutePosition
.Y
= aPoint
.Y();
346 if ( GetView()->TryContextMenuInterception( *pPopupMenu
, sDummy
, pMenu
, aEvent
) )
351 pPopupMenu
= (PopupMenu
*) pMenu
;
355 pPopupMenu
->SetSelectHdl(LINK(this, SmEditWindow
, MenuSelectHdl
));
357 pPopupMenu
->Execute( this, aPoint
);
361 else if (rCEvt
.GetCommand() == COMMAND_WHEEL
)
362 bForwardEvt
= !HandleWheelCommands( rCEvt
);
367 pEditView
->Command( rCEvt
);
369 Window::Command (rCEvt
);
374 bool SmEditWindow::HandleWheelCommands( const CommandEvent
&rCEvt
)
376 bool bCommandHandled
= false; // true if the CommandEvent needs not
377 // to be passed on (because it has fully
378 // been taken care of).
380 const CommandWheelData
* pWData
= rCEvt
.GetWheelData();
383 if (COMMAND_WHEEL_ZOOM
== pWData
->GetMode())
384 bCommandHandled
= true; // no zooming in Command window
386 bCommandHandled
= HandleScrollCommand( rCEvt
, pHScrollBar
, pVScrollBar
);
389 return bCommandHandled
;
393 IMPL_LINK_INLINE_START( SmEditWindow
, MenuSelectHdl
, Menu
*, pMenu
)
395 SmViewShell
*pViewSh
= rCmdBox
.GetView();
397 pViewSh
->GetViewFrame()->GetDispatcher()->Execute(
398 SID_INSERTCOMMAND
, SFX_CALLMODE_STANDARD
,
399 new SfxInt16Item(SID_INSERTCOMMAND
, pMenu
->GetCurItemId()), 0L);
402 IMPL_LINK_INLINE_END( SmEditWindow
, MenuSelectHdl
, Menu
*, pMenu
)
404 void SmEditWindow::KeyInput(const KeyEvent
& rKEvt
)
406 if (rKEvt
.GetKeyCode().GetCode() == KEY_ESCAPE
)
408 bool bCallBase
= true;
409 SfxViewShell
* pViewShell
= GetView();
410 if ( pViewShell
&& pViewShell
->ISA(SmViewShell
) )
412 // Terminate possible InPlace mode
413 bCallBase
= !pViewShell
->Escape();
416 Window::KeyInput( rKEvt
);
424 if ( !pEditView
->PostKeyEvent(rKEvt
) )
426 SmViewShell
*pView
= GetView();
427 if ( pView
&& !pView
->KeyInput(rKEvt
) )
429 // F1 (help) leads to the destruction of this
431 if ( aModifyTimer
.IsActive() )
433 Window::KeyInput(rKEvt
);
437 // SFX has maybe called a slot of the view and thus (because of a hack in SFX)
438 // set the focus to the view
439 SfxViewShell
* pVShell
= GetView();
440 if ( pVShell
&& pVShell
->ISA(SmViewShell
) &&
441 ((SmViewShell
*)pVShell
)->GetGraphicWindow().HasFocus() )
449 // have doc-shell modified only for formula input/change and not
450 // cursor travelling and such things...
451 SmDocShell
*pDocShell
= GetDoc();
453 pDocShell
->SetModified( GetEditEngine()->IsModified() );
455 aModifyTimer
.Start();
462 void SmEditWindow::Paint(const Rectangle
& rRect
)
466 pEditView
->Paint(rRect
);
469 void SmEditWindow::CreateEditView()
471 EditEngine
*pEditEngine
= GetEditEngine();
473 //! pEditEngine and pEditView may be 0.
474 //! For example when the program is used by the document-converter
475 if (!pEditView
&& pEditEngine
)
477 pEditView
= new EditView( pEditEngine
, this );
478 pEditEngine
->InsertView( pEditView
);
481 pVScrollBar
= new ScrollBar(this, WinBits(WB_VSCROLL
));
483 pHScrollBar
= new ScrollBar(this, WinBits(WB_HSCROLL
));
485 pScrollBox
= new ScrollBarBox(this);
486 pVScrollBar
->SetScrollHdl(LINK(this, SmEditWindow
, ScrollHdl
));
487 pHScrollBar
->SetScrollHdl(LINK(this, SmEditWindow
, ScrollHdl
));
488 pVScrollBar
->EnableDrag( true );
489 pHScrollBar
->EnableDrag( true );
491 pEditView
->SetOutputArea(AdjustScrollBars());
493 ESelection eSelection
;
495 pEditView
->SetSelection(eSelection
);
497 pEditView
->ShowCursor(true, true);
499 pEditEngine
->SetStatusEventHdl( LINK(this, SmEditWindow
, EditStatusHdl
) );
500 SetPointer(pEditView
->GetPointer());
502 SetScrollBarRanges();
507 IMPL_LINK( SmEditWindow
, EditStatusHdl
, EditStatus
*, EMPTYARG
/*pStat*/ )
518 IMPL_LINK_INLINE_START( SmEditWindow
, ScrollHdl
, ScrollBar
*, EMPTYARG
/*pScrollBar*/ )
520 OSL_ENSURE(pEditView
, "EditView missing");
523 pEditView
->SetVisArea(Rectangle(Point(pHScrollBar
->GetThumbPos(),
524 pVScrollBar
->GetThumbPos()),
525 pEditView
->GetVisArea().GetSize()));
526 pEditView
->Invalidate();
530 IMPL_LINK_INLINE_END( SmEditWindow
, ScrollHdl
, ScrollBar
*, pScrollBar
)
532 Rectangle
SmEditWindow::AdjustScrollBars()
534 const Size
aOut( GetOutputSizePixel() );
536 Rectangle
aRect( aPoint
, aOut
);
538 if (pVScrollBar
&& pHScrollBar
&& pScrollBox
)
540 const long nTmp
= GetSettings().GetStyleSettings().GetScrollBarSize();
541 Point
aPt( aRect
.TopRight() ); aPt
.X() -= nTmp
-1L;
542 pVScrollBar
->SetPosSizePixel( aPt
, Size(nTmp
, aOut
.Height() - nTmp
));
544 aPt
= aRect
.BottomLeft(); aPt
.Y() -= nTmp
- 1L;
545 pHScrollBar
->SetPosSizePixel( aPt
, Size(aOut
.Width() - nTmp
, nTmp
));
547 aPt
.X() = pHScrollBar
->GetSizePixel().Width();
548 aPt
.Y() = pVScrollBar
->GetSizePixel().Height();
549 pScrollBox
->SetPosSizePixel(aPt
, Size(nTmp
, nTmp
));
551 aRect
.Right() = aPt
.X() - 2;
552 aRect
.Bottom() = aPt
.Y() - 2;
557 void SmEditWindow::SetScrollBarRanges()
559 // Extra method, not InitScrollBars, since it's also being used for EditEngine events
560 EditEngine
*pEditEngine
= GetEditEngine();
561 if (pVScrollBar
&& pHScrollBar
&& pEditEngine
&& pEditView
)
563 long nTmp
= pEditEngine
->GetTextHeight();
564 pVScrollBar
->SetRange(Range(0, nTmp
));
565 pVScrollBar
->SetThumbPos(pEditView
->GetVisArea().Top());
567 nTmp
= pEditEngine
->GetPaperSize().Width();
568 pHScrollBar
->SetRange(Range(0,nTmp
));
569 pHScrollBar
->SetThumbPos(pEditView
->GetVisArea().Left());
573 void SmEditWindow::InitScrollBars()
575 if (pVScrollBar
&& pHScrollBar
&& pScrollBox
&& pEditView
)
577 const Size
aOut( pEditView
->GetOutputArea().GetSize() );
578 pVScrollBar
->SetVisibleSize(aOut
.Height());
579 pVScrollBar
->SetPageSize(aOut
.Height() * 8 / 10);
580 pVScrollBar
->SetLineSize(aOut
.Height() * 2 / 10);
582 pHScrollBar
->SetVisibleSize(aOut
.Width());
583 pHScrollBar
->SetPageSize(aOut
.Width() * 8 / 10);
584 pHScrollBar
->SetLineSize(SCROLL_LINE
);
586 SetScrollBarRanges();
595 OUString
SmEditWindow::GetText() const
598 EditEngine
*pEditEngine
= const_cast< SmEditWindow
* >(this)->GetEditEngine();
599 OSL_ENSURE( pEditEngine
, "EditEngine missing" );
601 aText
= pEditEngine
->GetText( LINEEND_LF
);
606 void SmEditWindow::SetText(const OUString
& rText
)
608 EditEngine
*pEditEngine
= GetEditEngine();
609 OSL_ENSURE( pEditEngine
, "EditEngine missing" );
610 if (pEditEngine
&& !pEditEngine
->IsModified())
615 ESelection eSelection
= pEditView
->GetSelection();
617 pEditEngine
->SetText(rText
);
618 pEditEngine
->ClearModifyFlag();
620 // Restarting the timer here, prevents calling the handlers for other (currently inactive)
622 aModifyTimer
.Start();
624 pEditView
->SetSelection(eSelection
);
629 void SmEditWindow::GetFocus()
633 if (xAccessible
.is())
635 // Note: will implicitly send the AccessibleStateType::FOCUSED event
636 ::accessibility::AccessibleTextHelper
*pHelper
= pAccessible
->GetTextHelper();
638 pHelper
->SetFocus(true);
643 EditEngine
*pEditEngine
= GetEditEngine();
645 pEditEngine
->SetStatusEventHdl( LINK(this, SmEditWindow
, EditStatusHdl
) );
647 //Let SmViewShell know we got focus
648 if(GetView() && IsInlineEditEnabled())
649 GetView()->SetInsertIntoEditWindow(true);
653 void SmEditWindow::LoseFocus()
655 EditEngine
*pEditEngine
= GetEditEngine();
657 pEditEngine
->SetStatusEventHdl( Link() );
661 if (xAccessible
.is())
663 // Note: will implicitly send the AccessibleStateType::FOCUSED event
664 ::accessibility::AccessibleTextHelper
*pHelper
= pAccessible
->GetTextHelper();
666 pHelper
->SetFocus(false);
671 bool SmEditWindow::IsAllSelected() const
674 EditEngine
*pEditEngine
= ((SmEditWindow
*) this)->GetEditEngine();
675 OSL_ENSURE( pEditView
, "NULL pointer" );
676 OSL_ENSURE( pEditEngine
, "NULL pointer" );
677 if (pEditEngine
&& pEditView
)
679 ESelection
eSelection( pEditView
->GetSelection() );
680 sal_Int32 nParaCnt
= pEditEngine
->GetParagraphCount();
683 sal_Int32 nTextLen
= pEditEngine
->GetText( LINEEND_LF
).getLength();
684 bRes
= !eSelection
.nStartPos
&& (eSelection
.nEndPos
== nTextLen
- 1);
688 bRes
= !eSelection
.nStartPara
&& (eSelection
.nEndPara
== nParaCnt
- 1);
694 void SmEditWindow::SelectAll()
696 OSL_ENSURE( pEditView
, "NULL pointer" );
699 // ALL as last two parameters refers to the end of the text
700 pEditView
->SetSelection( ESelection( 0, 0, EE_PARA_ALL
, EE_TEXTPOS_ALL
) );
704 void SmEditWindow::InsertCommand(sal_uInt16 nCommand
)
706 OSL_ENSURE( pEditView
, "EditView missing" );
709 // Remember start of the selection and move the cursor there afterwards.
710 // Only this way the SelNextMark() makes sense...
711 ESelection aSelection
= pEditView
->GetSelection();
712 aSelection
.nEndPos
= aSelection
.nStartPos
;
713 aSelection
.nEndPara
= aSelection
.nStartPara
;
715 OSL_ENSURE( pEditView
, "NULL pointer" );
716 OUString aText
= SM_RESSTR(nCommand
);
717 pEditView
->InsertText(aText
);
720 { // set selection to next mark
721 pEditView
->SetSelection(aSelection
);
725 { // set selection after inserted text
726 aSelection
.nEndPos
+= aText
.getLength();
727 aSelection
.nStartPos
= aSelection
.nEndPos
;
728 pEditView
->SetSelection(aSelection
);
731 aModifyTimer
.Start();
737 void SmEditWindow::MarkError(const Point
&rPos
)
739 OSL_ENSURE( pEditView
, "EditView missing" );
742 const xub_StrLen nCol
= sal::static_int_cast
< xub_StrLen
>(rPos
.X());
743 const sal_uInt16 nRow
= sal::static_int_cast
< sal_uInt16
>(rPos
.Y() - 1);
745 pEditView
->SetSelection(ESelection(nRow
, nCol
- 1, nRow
, nCol
));
750 void SmEditWindow::SelNextMark()
752 EditEngine
*pEditEngine
= GetEditEngine();
753 OSL_ENSURE( pEditView
, "NULL pointer" );
754 OSL_ENSURE( pEditEngine
, "NULL pointer" );
755 if (pEditEngine
&& pEditView
)
757 ESelection eSelection
= pEditView
->GetSelection();
758 sal_Int32 nPos
= eSelection
.nEndPos
;
759 sal_Int32 nCounts
= pEditEngine
->GetParagraphCount();
761 while (eSelection
.nEndPara
< nCounts
)
763 OUString aText
= pEditEngine
->GetText(eSelection
.nEndPara
);
764 nPos
= aText
.indexOf("<?>", nPos
);
767 pEditView
->SetSelection(ESelection(
768 eSelection
.nEndPara
, nPos
, eSelection
.nEndPara
, nPos
+ 3));
773 eSelection
.nEndPara
++;
778 void SmEditWindow::SelPrevMark()
780 EditEngine
*pEditEngine
= GetEditEngine();
781 OSL_ENSURE( pEditEngine
, "NULL pointer" );
782 OSL_ENSURE( pEditView
, "NULL pointer" );
783 if (pEditEngine
&& pEditView
)
785 ESelection eSelection
= pEditView
->GetSelection();
787 sal_Int32 nMax
= eSelection
.nStartPos
;
788 OUString
aText(pEditEngine
->GetText(eSelection
.nStartPara
));
789 OUString
aMark("<?>");
790 sal_Int32 nCounts
= pEditEngine
->GetParagraphCount();
794 sal_Int32 nMarkIndex
= aText
.indexOf(aMark
);
795 while ((nMarkIndex
< nMax
) && (nMarkIndex
!= -1))
798 nMarkIndex
= aText
.indexOf(aMark
, nMarkIndex
+ 1);
803 eSelection
.nStartPara
--;
804 aText
= pEditEngine
->GetText(eSelection
.nStartPara
);
805 nMax
= aText
.getLength();
808 while ((eSelection
.nStartPara
< nCounts
) &&
813 pEditView
->SetSelection(ESelection(
814 eSelection
.nStartPara
, nPos
, eSelection
.nStartPara
, nPos
+ 3));
819 bool SmEditWindow::HasMark(const OUString
& rText
) const
820 // returns true iff 'rText' contains a mark
822 return rText
.indexOf("<?>") != -1;
825 void SmEditWindow::MouseMove(const MouseEvent
&rEvt
)
828 pEditView
->MouseMove(rEvt
);
831 sal_Int8
SmEditWindow::AcceptDrop( const AcceptDropEvent
& /*rEvt*/ )
833 return pEditView
? /*pEditView->QueryDrop( rEvt )*/DND_ACTION_NONE
: DND_ACTION_NONE
;
836 sal_Int8
SmEditWindow::ExecuteDrop( const ExecuteDropEvent
& /*rEvt*/ )
838 return pEditView
? /*pEditView->Drop( rEvt )*/DND_ACTION_NONE
: DND_ACTION_NONE
;
841 ESelection
SmEditWindow::GetSelection() const
843 // pointer may be 0 when reloading a document and the old view
844 // was already destroyed
845 //(OSL_ENSURE( pEditView, "NULL pointer" );
848 eSel
= pEditView
->GetSelection();
852 void SmEditWindow::SetSelection(const ESelection
&rSel
)
854 OSL_ENSURE( pEditView
, "NULL pointer" );
856 pEditView
->SetSelection(rSel
);
860 bool SmEditWindow::IsEmpty() const
862 EditEngine
*pEditEngine
= ((SmEditWindow
*) this)->GetEditEngine();
863 bool bEmpty
= ( pEditEngine
? pEditEngine
->GetTextLen() == 0 : false);
867 bool SmEditWindow::IsSelected() const
869 return pEditView
? pEditView
->HasSelection() : false;
873 void SmEditWindow::UpdateStatus( bool bSetDocModified
)
875 SmModule
*pMod
= SM_MOD();
876 if (pMod
&& pMod
->GetConfig()->IsAutoRedraw())
878 if ( bSetDocModified
)
879 GetDoc()->SetModified(true);
882 void SmEditWindow::Cut()
884 OSL_ENSURE( pEditView
, "EditView missing" );
892 void SmEditWindow::Copy()
894 OSL_ENSURE( pEditView
, "EditView missing" );
899 void SmEditWindow::Paste()
901 OSL_ENSURE( pEditView
, "EditView missing" );
909 void SmEditWindow::Delete()
911 OSL_ENSURE( pEditView
, "EditView missing" );
914 pEditView
->DeleteSelected();
919 void SmEditWindow::InsertText(const OUString
& rText
)
921 OSL_ENSURE( pEditView
, "EditView missing" );
924 pEditView
->InsertText(rText
);
925 aModifyTimer
.Start();
930 void SmEditWindow::Flush()
932 EditEngine
*pEditEngine
= GetEditEngine();
933 if (pEditEngine
&& pEditEngine
->IsModified())
935 pEditEngine
->ClearModifyFlag();
936 SmViewShell
*pViewSh
= rCmdBox
.GetView();
939 pViewSh
->GetViewFrame()->GetDispatcher()->Execute(
940 SID_TEXT
, SFX_CALLMODE_STANDARD
,
941 new SfxStringItem(SID_TEXT
, GetText()), 0L);
944 if (aCursorMoveTimer
.IsActive())
946 aCursorMoveTimer
.Stop();
947 CursorMoveTimerHdl(&aCursorMoveTimer
);
952 void SmEditWindow::DeleteEditView( SmViewShell
& /*rView*/ )
956 EditEngine
*pEditEngine
= pEditView
->GetEditEngine();
959 pEditEngine
->SetStatusEventHdl( Link() );
960 pEditEngine
->RemoveView( pEditView
);
968 uno::Reference
< XAccessible
> SmEditWindow::CreateAccessible()
972 pAccessible
= new SmEditAccessible( this );
973 xAccessible
= pAccessible
;
979 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */