1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: EditWindow.cxx,v $
10 * $Revision: 1.7.138.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "EditWindow.hxx"
37 #include <svx/editeng.hxx>
38 #include <svx/editview.hxx>
39 #include <vcl/scrbar.hxx>
40 #include <svx/eeitem.hxx>
41 #include "sdresid.hxx"
42 #include <svtools/itempool.hxx>
43 #include <svx/fhgtitem.hxx>
44 #include <vos/mutex.hxx>
45 #include <vcl/svapp.hxx>
46 #include <svtools/linguprops.hxx>
47 #include <svtools/lingucfg.hxx>
48 #include <svx/fontitem.hxx>
49 #include <svx/editstat.hxx>
51 #define SCROLL_LINE 24
53 using namespace com::sun::star::accessibility
;
54 using namespace com::sun::star
;
55 using namespace com::sun::star::uno
;
57 namespace sd
{ namespace notes
{
59 EditWindow::EditWindow (Window
* pParentWindow
, SfxItemPool
* pItemPool
)
60 : Window (pParentWindow
, WinBits()),
61 DropTargetHelper(this),
64 mpHorizontalScrollBar(NULL
),
65 mpVerticalScrollBar(NULL
),
68 SetMapMode(MAP_PIXEL
);
70 // compare DataChanged
71 SetBackground (GetSettings().GetStyleSettings().GetWindowColor());
73 maModifyTimer
.SetTimeout(2000);
74 maModifyTimer
.Start();
76 maCursorMoveTimer
.SetTimeout(500);
80 SvxFontHeightItem
aItem (GetFont().GetSize().Height(), 100,
82 pItemPool
->SetPoolDefaultItem (aItem
);
83 aItem
.SetWhich(EE_CHAR_FONTHEIGHT_CJK
);
84 pItemPool
->SetPoolDefaultItem (aItem
);
85 aItem
.SetWhich(EE_CHAR_FONTHEIGHT_CTL
);
86 pItemPool
->SetPoolDefaultItem (aItem
);
88 InsertText (UniString::CreateFromAscii("EditWindow created and ready.\n"));
92 EditWindow::~EditWindow (void)
94 maCursorMoveTimer
.Stop();
97 if (mpEditView
!= NULL
)
99 EditEngine
*pEditEngine
= mpEditView
->GetEditEngine();
102 pEditEngine
->SetStatusEventHdl(Link());
103 pEditEngine
->RemoveView (mpEditView
);
107 delete mpHorizontalScrollBar
;
108 delete mpVerticalScrollBar
;
113 ////////////////////////////////////////
116 void SmGetLeftSelectionPart(const ESelection aSel
,
117 USHORT
&nPara
, USHORT
&nPos
)
118 // returns paragraph number and position of the selections left part
120 // compare start and end of selection and use the one that comes first
122 (aSel
.nStartPara
< aSel
.nEndPara
) ||
123 (aSel
.nStartPara
== aSel
.nEndPara
&& aSel
.nStartPos
< aSel
.nEndPos
)
125 { nPara
= aSel
.nStartPara
;
126 nPos
= aSel
.nStartPos
;
129 { nPara
= aSel
.nEndPara
;
137 EditEngine
* EditWindow::GetEditEngine (void)
139 if (mpEditEngine
== NULL
)
140 mpEditEngine
= CreateEditEngine ();
147 EditEngine
* EditWindow::CreateEditEngine (void)
149 EditEngine
* pEditEngine
= mpEditEngine
;
150 if (pEditEngine
== NULL
)
152 mpEditEngineItemPool
= EditEngine::CreatePool();
155 // set fonts to be used
157 SvtLinguOptions aOpt
;
158 SvtLinguConfig().GetOptions( aOpt
);
167 // info to get western font to be used
168 { LANGUAGE_ENGLISH_US
, LANGUAGE_NONE
,
169 DEFAULTFONT_SERIF
, EE_CHAR_FONTINFO
},
170 // info to get CJK font to be used
171 { LANGUAGE_JAPANESE
, LANGUAGE_NONE
,
172 DEFAULTFONT_CJK_TEXT
, EE_CHAR_FONTINFO_CJK
},
173 // info to get CTL font to be used
174 { LANGUAGE_ARABIC_SAUDI_ARABIA
, LANGUAGE_NONE
,
175 DEFAULTFONT_CTL_TEXT
, EE_CHAR_FONTINFO_CTL
}
177 aTable
[0].nLang
= aOpt
.nDefaultLanguage
;
178 aTable
[1].nLang
= aOpt
.nDefaultLanguage_CJK
;
179 aTable
[2].nLang
= aOpt
.nDefaultLanguage_CTL
;
181 for (int i
= 0; i
< 3; ++i
)
183 const FontDta
&rFntDta
= aTable
[i
];
184 LanguageType nLang
= (LANGUAGE_NONE
== rFntDta
.nLang
) ?
185 rFntDta
.nFallbackLang
: rFntDta
.nLang
;
186 Font aFont
= Application::GetDefaultDevice()->GetDefaultFont(
187 rFntDta
.nFontType
, nLang
, DEFAULTFONT_FLAGS_ONLYONE
);
188 mpEditEngineItemPool
->SetPoolDefaultItem(
192 aFont
.GetStyleName(),
195 rFntDta
.nFontInfoId
));
199 SvxFontHeightItem
aFontHeigt(
200 Application::GetDefaultDevice()->LogicToPixel(
201 Size (0, 10), MapMode (MAP_POINT
)).Height(), 100,
202 EE_CHAR_FONTHEIGHT
);
203 mpEditEngineItemPool
->SetPoolDefaultItem( aFontHeigt
);
204 aFontHeigt
.SetWhich (EE_CHAR_FONTHEIGHT_CJK
);
205 mpEditEngineItemPool
->SetPoolDefaultItem( aFontHeigt
);
206 aFontHeigt
.SetWhich (EE_CHAR_FONTHEIGHT_CTL
);
207 mpEditEngineItemPool
->SetPoolDefaultItem( aFontHeigt
);
209 pEditEngine
= new EditEngine (mpEditEngineItemPool
);
211 pEditEngine
->EnableUndo (TRUE
);
212 pEditEngine
->SetDefTab (USHORT(
213 Application::GetDefaultDevice()->GetTextWidth(
214 UniString::CreateFromAscii("XXXX"))));
216 pEditEngine
->SetControlWord(
217 (pEditEngine
->GetControlWord()
218 | EE_CNTRL_AUTOINDENTING
) &
219 (~EE_CNTRL_UNDOATTRIBS
) &
220 (~EE_CNTRL_PASTESPECIAL
));
222 pEditEngine
->SetWordDelimiters (
223 UniString::CreateFromAscii(" .=+-*/(){}[];\""));
224 pEditEngine
->SetRefMapMode (MAP_PIXEL
);
225 pEditEngine
->SetPaperSize (Size(800, 0));
226 pEditEngine
->EraseVirtualDevice();
227 pEditEngine
->ClearModifyFlag();
236 void EditWindow::DataChanged (const DataChangedEvent
&)
238 const StyleSettings
aSettings (GetSettings().GetStyleSettings());
240 SetBackground( aSettings
.GetWindowColor() );
242 // edit fields in other Applications use this font instead of
243 // the application font thus we use this one too
244 SetPointFont( aSettings
.GetFieldFont() );
245 EditEngine
* pEditEngine
= GetEditEngine();
247 if (pEditEngine
!=NULL
&& mpEditEngineItemPool
!=NULL
)
250 //! see also SmDocShell::GetEditEngine() !
253 // pEditEngine->SetDefTab( USHORT( GetTextWidth( C2S("XXXX") ) ) );
255 USHORT aFntInfoId
[3] = {
256 EE_CHAR_FONTINFO
, EE_CHAR_FONTINFO_CJK
, EE_CHAR_FONTINFO_CTL
};
257 for (int i
= 0; i
< 3; ++i
)
259 const SfxPoolItem
*pItem
= mpEditEngineItemPool
->GetPoolDefaultItem( aFntInfoId
[i
] );
262 const SvxFontItem
*pFntItem
= ((const SvxFontItem
*) pItem
);
263 const Font
&rFnt
= aSettings
.GetFieldFont();
264 SvxFontItem
aFntItem( rFnt
.GetFamily(), rFnt
.GetName(),
265 rFnt
.GetStyleName(), rFnt
.GetPitch(),
266 pFntItem
->GetCharSet(),
268 mpEditEngineItemPool
->SetPoolDefaultItem( aFntItem
);
272 SvxFontHeightItem
aItem( GetFont().GetSize().Height(), 100,
273 EE_CHAR_FONTHEIGHT
);
274 mpEditEngineItemPool
->SetPoolDefaultItem( aItem
);
275 aItem
.SetWhich( EE_CHAR_FONTHEIGHT_CJK
);
276 mpEditEngineItemPool
->SetPoolDefaultItem( aItem
);
277 aItem
.SetWhich( EE_CHAR_FONTHEIGHT_CTL
);
278 mpEditEngineItemPool
->SetPoolDefaultItem( aItem
);
280 // forces new settings to be used
281 // unfortunately this resets the whole edit engine
282 // thus we need to save at least the text
283 String
aTxt( pEditEngine
->GetText( LINEEND_LF
) );
284 pEditEngine
->Clear(); //#77957 incorrect font size
285 pEditEngine
->SetText( aTxt
);
288 String
aText (mpEditEngine
->GetText (LINEEND_LF
));
289 mpEditEngine
->Clear();
290 mpEditEngine
->SetText (aText
);
299 void EditWindow::Resize (void)
304 if (mpEditView
!= NULL
)
306 mpEditView
->SetOutputArea(AdjustScrollBars());
307 mpEditView
->ShowCursor();
309 DBG_ASSERT( mpEditView
->GetEditEngine(), "EditEngine missing" );
310 const long nMaxVisAreaStart
= mpEditView
->GetEditEngine()->GetTextHeight() -
311 mpEditView
->GetOutputArea().GetHeight();
312 if (mpEditView
->GetVisArea().Top() > nMaxVisAreaStart
)
314 Rectangle
aVisArea(mpEditView
->GetVisArea() );
315 aVisArea
.Top() = (nMaxVisAreaStart
> 0 ) ? nMaxVisAreaStart
: 0;
316 aVisArea
.SetSize(mpEditView
->GetOutputArea().GetSize());
317 mpEditView
->SetVisArea(aVisArea
);
318 mpEditView
->ShowCursor();
328 void EditWindow::MouseButtonUp(const MouseEvent
&rEvt
)
330 if (mpEditView
!= NULL
)
331 mpEditView
->MouseButtonUp(rEvt
);
333 Window::MouseButtonUp (rEvt
);
335 // ggf FormulaCursor neu positionieren
336 // CursorMoveTimerHdl(&aCursorMoveTimer);
342 void EditWindow::MouseButtonDown(const MouseEvent
&rEvt
)
344 if (mpEditView
!= NULL
)
345 mpEditView
->MouseButtonDown(rEvt
);
347 Window::MouseButtonDown (rEvt
);
355 void EditWindow::Command(const CommandEvent
& rCEvt
)
357 /* if (rCEvt.GetCommand() == COMMAND_CONTEXTMENU)
359 GetParent()->ToTop();
361 Point aPoint = rCEvt.GetMousePosPixel();
362 PopupMenu* pPopupMenu = new PopupMenu(SmResId(RID_COMMANDMENU));
364 // added for replaceability of context menus #96085, #93782
366 ::com::sun::star::ui::ContextMenuExecuteEvent aEvent;
367 aEvent.SourceWindow = VCLUnoHelper::GetInterface( this );
368 aEvent.ExecutePosition.X = aPoint.X();
369 aEvent.ExecutePosition.Y = aPoint.Y();
370 if ( GetView()->TryContextMenuInterception( *pPopupMenu, pMenu, aEvent ) )
375 pPopupMenu = (PopupMenu*) pMenu;
379 pPopupMenu->SetSelectHdl(LINK(this, EditWindow, MenuSelectHdl));
381 pPopupMenu->Execute( this, aPoint );
384 else*/ if (mpEditView
)
385 mpEditView
->Command( rCEvt
);
387 Window::Command (rCEvt
);
390 IMPL_LINK_INLINE_START( EditWindow
, MenuSelectHdl
, Menu
*, EMPTYARG
)
392 /* SmViewShell *pViewSh = rCmdBox.GetView();
394 pViewSh->GetViewFrame()->GetDispatcher()->Execute(
395 SID_INSERTCOMMAND, SFX_CALLMODE_STANDARD,
396 new SfxInt16Item(SID_INSERTCOMMAND, pMenu->GetCurItemId()), 0L);
400 IMPL_LINK_INLINE_END( EditWindow
, MenuSelectHdl
, Menu
*, EMPTYARG
)
402 void EditWindow::KeyInput(const KeyEvent
& )
404 /* if (rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE)
406 BOOL bCallBase = TRUE;
407 SfxViewShell* pViewShell = SfxViewShell::Current();
408 if ( pViewShell && pViewShell->ISA(SmViewShell) )
410 SmDocShell* pDocSh = (SmDocShell*) pViewShell->GetViewFrame()->GetObjectShell();
413 // fuert zum (sofortigen) Zerstoeren von this!
414 pDocSh->DoInPlaceActivate( FALSE );
419 Window::KeyInput( rKEvt );
423 // Timer neu starten, um den Handler (auch bei längeren Eingaben)
424 // möglichst nur einmal am Ende aufzurufen.
425 aCursorMoveTimer.Start();
427 DBG_ASSERT( mpEditView, "EditView missing (NULL pointer)" );
430 if ( !mpEditView->PostKeyEvent(rKEvt) )
432 if ( !SfxViewShell::Current()->KeyInput(rKEvt) )
434 // fuert bei F1 (Hilfe) zum Zerstoeren von this!
436 if ( aModifyTimer.IsActive() )
438 Window::KeyInput(rKEvt);
442 //SFX hat evtl. Slot an der View gecallt und dabei (wg. Hack
443 //im SFX) den Focus auf die View gesetzt
444 SfxViewShell* pVShell = SfxViewShell::Current();
445 if ( pVShell && pVShell->ISA(SmViewShell) &&
446 ((SmViewShell*)pVShell)->GetGraphicWindow().HasFocus() )
454 // have doc-shell modified only for formula input/change and not
455 // cursor travelling and such things...
456 SmDocShell *pDocShell = GetDoc();
458 pDocShell->SetModified( GetEditEngine()->IsModified() );
460 aModifyTimer.Start();
469 void EditWindow::Paint(const Rectangle
& rRect
)
473 mpEditView
->Paint(rRect
);
479 void EditWindow::CreateEditView (void)
481 EditEngine
* pEditEngine
= GetEditEngine();
483 //! pEditEngine and mpEditView may be 0.
484 //! For example when the program is used by the document-converter
485 if (mpEditView
==NULL
&& pEditEngine
!=NULL
)
487 mpEditView
= new EditView (pEditEngine
, this);
488 pEditEngine
->InsertView (mpEditView
);
490 if (mpVerticalScrollBar
== NULL
)
491 mpVerticalScrollBar
= new ScrollBar (
492 this, WinBits(WB_VSCROLL
| WB_DRAG
));
493 if (mpHorizontalScrollBar
== NULL
)
494 mpHorizontalScrollBar
= new ScrollBar (
495 this, WinBits(WB_HSCROLL
| WB_DRAG
));
496 if (mpScrollBox
== NULL
)
497 mpScrollBox
= new ScrollBarBox (this);
498 mpVerticalScrollBar
->SetScrollHdl(LINK(this, EditWindow
, ScrollHdl
));
499 mpHorizontalScrollBar
->SetScrollHdl(LINK(this, EditWindow
, ScrollHdl
));
501 mpEditView
->SetOutputArea(AdjustScrollBars());
503 ESelection eSelection
;
505 mpEditView
->SetSelection(eSelection
);
507 mpEditView
->ShowCursor(TRUE
, TRUE
);
509 pEditEngine
->SetStatusEventHdl(
510 LINK(this, EditWindow
, EditStatusHdl
));
511 SetPointer(mpEditView
->GetPointer());
513 SetScrollBarRanges();
520 IMPL_LINK( EditWindow
, EditStatusHdl
, EditStatus
*, EMPTYARG
)
526 SetScrollBarRanges();
531 IMPL_LINK_INLINE_START( EditWindow
, ScrollHdl
, ScrollBar
*, EMPTYARG
)
533 DBG_ASSERT(mpEditView
, "EditView missing");
536 mpEditView
->SetVisArea(Rectangle(Point(mpHorizontalScrollBar
->GetThumbPos(),
537 mpVerticalScrollBar
->GetThumbPos()),
538 mpEditView
->GetVisArea().GetSize()));
539 mpEditView
->Invalidate();
543 IMPL_LINK_INLINE_END( EditWindow
, ScrollHdl
, ScrollBar
*, EMPTYARG
)
545 Rectangle
EditWindow::AdjustScrollBars()
547 const Size
aOut( GetOutputSizePixel() );
549 Rectangle
aRect( aPoint
, aOut
);
551 if (mpVerticalScrollBar
&& mpHorizontalScrollBar
&& mpScrollBox
)
553 const long nTmp
= GetSettings().GetStyleSettings().GetScrollBarSize();
554 Point
aPt( aRect
.TopRight() ); aPt
.X() -= nTmp
-1L;
555 mpVerticalScrollBar
->SetPosSizePixel( aPt
, Size(nTmp
, aOut
.Height() - nTmp
));
557 aPt
= aRect
.BottomLeft(); aPt
.Y() -= nTmp
- 1L;
558 mpHorizontalScrollBar
->SetPosSizePixel( aPt
, Size(aOut
.Width() - nTmp
, nTmp
));
560 aPt
.X() = mpHorizontalScrollBar
->GetSizePixel().Width();
561 aPt
.Y() = mpVerticalScrollBar
->GetSizePixel().Height();
562 mpScrollBox
->SetPosSizePixel(aPt
, Size(nTmp
, nTmp
));
564 aRect
.Right() = aPt
.X() - 2;
565 aRect
.Bottom() = aPt
.Y() - 2;
570 void EditWindow::SetScrollBarRanges()
572 EditEngine
* pEditEngine
= GetEditEngine();
573 if (mpEditView
!= NULL
&& pEditEngine
!= NULL
)
575 if (mpVerticalScrollBar
!= NULL
)
577 long nTmp
= pEditEngine
->GetTextHeight();
578 mpVerticalScrollBar
->SetRange(Range(0, nTmp
));
579 mpVerticalScrollBar
->SetThumbPos(mpEditView
->GetVisArea().Top());
581 if (mpHorizontalScrollBar
!= NULL
)
583 long nTmp
= pEditEngine
->GetPaperSize().Width();
584 mpHorizontalScrollBar
->SetRange(Range(0,nTmp
));
585 mpHorizontalScrollBar
->SetThumbPos(mpEditView
->GetVisArea().Left());
590 void EditWindow::InitScrollBars()
592 if (mpEditView
!= NULL
)
594 const Size
aOut( mpEditView
->GetOutputArea().GetSize() );
595 if (mpVerticalScrollBar
!= NULL
)
597 mpVerticalScrollBar
->SetVisibleSize(aOut
.Height());
598 mpVerticalScrollBar
->SetPageSize(aOut
.Height() * 8 / 10);
599 mpVerticalScrollBar
->SetLineSize(aOut
.Height() * 2 / 10);
602 if (mpHorizontalScrollBar
!= NULL
)
604 mpHorizontalScrollBar
->SetVisibleSize(aOut
.Width());
605 mpHorizontalScrollBar
->SetPageSize(aOut
.Width() * 8 / 10);
606 mpHorizontalScrollBar
->SetLineSize(SCROLL_LINE
);
609 SetScrollBarRanges();
611 if (mpVerticalScrollBar
!= NULL
)
612 mpVerticalScrollBar
->Show();
613 if (mpHorizontalScrollBar
!= NULL
)
614 mpHorizontalScrollBar
->Show();
615 if (mpScrollBox
!= NULL
)
621 XubString
EditWindow::GetText()
624 EditEngine
*pEditEngine
= GetEditEngine();
625 DBG_ASSERT( pEditEngine
, "EditEngine missing" );
627 aText
= pEditEngine
->GetText( LINEEND_LF
);
632 void EditWindow::SetText(const XubString
& rText
)
634 EditEngine
*pEditEngine
= GetEditEngine();
635 DBG_ASSERT( pEditEngine
, "EditEngine missing" );
636 if (pEditEngine
&& !pEditEngine
->IsModified())
641 ESelection eSelection
= mpEditView
->GetSelection();
643 pEditEngine
->SetText(rText
);
644 pEditEngine
->ClearModifyFlag();
646 //! Hier die Timer neu zu starten verhindert, dass die Handler für andere
647 //! (im Augenblick nicht mehr aktive) Math Tasks aufgerufen werden.
648 maModifyTimer
.Start();
649 maCursorMoveTimer
.Start();
651 mpEditView
->SetSelection(eSelection
);
656 void EditWindow::GetFocus()
662 if (mpEditEngine
!= NULL
)
663 mpEditEngine
->SetStatusEventHdl(
664 LINK(this, EditWindow
, EditStatusHdl
));
668 void EditWindow::LoseFocus()
670 if (mpEditEngine
!= NULL
)
671 mpEditEngine
->SetStatusEventHdl (Link());
677 BOOL
EditWindow::IsAllSelected() const
680 EditEngine
*pEditEngine
= ((EditWindow
*) this)->GetEditEngine();
681 DBG_ASSERT( mpEditView
, "NULL pointer" );
682 DBG_ASSERT( pEditEngine
, "NULL pointer" );
683 if (pEditEngine
&& mpEditView
)
685 ESelection
eSelection( mpEditView
->GetSelection() );
686 INT32 nParaCnt
= pEditEngine
->GetParagraphCount();
689 String
Text( pEditEngine
->GetText( LINEEND_LF
) );
690 bRes
= !eSelection
.nStartPos
&& (eSelection
.nEndPos
== Text
.Len () - 1);
694 bRes
= !eSelection
.nStartPara
&& (eSelection
.nEndPara
== nParaCnt
- 1);
700 void EditWindow::SelectAll()
702 DBG_ASSERT( mpEditView
, "NULL pointer" );
705 // 0xFFFF as last two parameters refers to the end of the text
706 mpEditView
->SetSelection( ESelection( 0, 0, 0xFFFF, 0xFFFF ) );
711 void EditWindow::MarkError(const Point
&rPos
)
713 DBG_ASSERT( mpEditView
, "EditView missing" );
716 const int Col
= rPos
.X();
717 const int Row
= rPos
.Y() - 1;
719 mpEditView
->SetSelection(ESelection ( (USHORT
)Row
, (USHORT
)(Col
- 1), (USHORT
)Row
, (USHORT
)Col
));
724 void EditWindow::SelNextMark()
726 EditEngine
*pEditEngine
= GetEditEngine();
727 DBG_ASSERT( mpEditView
, "NULL pointer" );
728 DBG_ASSERT( pEditEngine
, "NULL pointer" );
729 if (pEditEngine
&& mpEditView
)
731 ESelection eSelection
= mpEditView
->GetSelection();
732 USHORT Pos
= eSelection
.nEndPos
;
733 String
aMark (UniString::CreateFromAscii("<?>"));
735 USHORT nCounts
= pEditEngine
->GetParagraphCount();
737 while (eSelection
.nEndPara
< nCounts
)
739 aText
= pEditEngine
->GetText( eSelection
.nEndPara
);
740 Pos
= aText
.Search(aMark
, Pos
);
742 if (Pos
!= STRING_NOTFOUND
)
744 mpEditView
->SetSelection(ESelection (eSelection
.nEndPara
, Pos
, eSelection
.nEndPara
, Pos
+ 3));
749 eSelection
.nEndPara
++;
754 void EditWindow::SelPrevMark()
756 EditEngine
*pEditEngine
= GetEditEngine();
757 DBG_ASSERT( pEditEngine
, "NULL pointer" );
758 DBG_ASSERT( mpEditView
, "NULL pointer" );
759 if (pEditEngine
&& mpEditView
)
761 ESelection eSelection
= mpEditView
->GetSelection();
762 USHORT Pos
= STRING_NOTFOUND
;
763 xub_StrLen Max
= eSelection
.nStartPos
;
764 String
Text( pEditEngine
->GetText( eSelection
.nStartPara
) );
765 String
aMark (UniString::CreateFromAscii("<?>"));
766 USHORT nCounts
= pEditEngine
->GetParagraphCount();
770 USHORT Fnd
= Text
.Search(aMark
, 0);
772 while ((Fnd
< Max
) && (Fnd
!= STRING_NOTFOUND
))
775 Fnd
= Text
.Search(aMark
, Fnd
+ 1);
778 if (Pos
== STRING_NOTFOUND
)
780 eSelection
.nStartPara
--;
781 Text
= pEditEngine
->GetText( eSelection
.nStartPara
);
785 while ((eSelection
.nStartPara
< nCounts
) &&
786 (Pos
== STRING_NOTFOUND
));
788 if (Pos
!= STRING_NOTFOUND
)
790 mpEditView
->SetSelection(ESelection (eSelection
.nStartPara
, Pos
, eSelection
.nStartPara
, Pos
+ 3));
795 BOOL
EditWindow::HasMark(const String
& rText
) const
796 // returns true iff 'rText' contains a mark
798 return rText
.SearchAscii("<?>", 0) != STRING_NOTFOUND
;
801 void EditWindow::MouseMove(const MouseEvent
&rEvt
)
804 mpEditView
->MouseMove(rEvt
);
807 sal_Int8
EditWindow::AcceptDrop( const AcceptDropEvent
& )
809 return mpEditView
? /*mpEditView->QueryDrop( rEvt )*/DND_ACTION_NONE
: DND_ACTION_NONE
;
812 sal_Int8
EditWindow::ExecuteDrop( const ExecuteDropEvent
& )
814 return mpEditView
? /*mpEditView->Drop( rEvt )*/DND_ACTION_NONE
: DND_ACTION_NONE
;
817 ESelection
EditWindow::GetSelection() const
819 // pointer may be 0 when reloading a document and the old view
820 // was already destroyed
821 //(DBG_ASSERT( mpEditView, "NULL pointer" );
824 eSel
= mpEditView
->GetSelection();
828 void EditWindow::SetSelection(const ESelection
&rSel
)
830 DBG_ASSERT( mpEditView
, "NULL pointer" );
832 mpEditView
->SetSelection(rSel
);
835 BOOL
EditWindow::IsEmpty() const
837 EditEngine
*pEditEngine
= ((EditWindow
*) this)->GetEditEngine();
838 return (pEditEngine
&& (pEditEngine
->GetTextLen() == 0)) ? TRUE
: FALSE
;
841 BOOL
EditWindow::IsSelected() const
843 return mpEditView
? mpEditView
->HasSelection() : FALSE
;
846 void EditWindow::Cut()
848 DBG_ASSERT( mpEditView
, "EditView missing" );
853 void EditWindow::Copy()
855 DBG_ASSERT( mpEditView
, "EditView missing" );
860 void EditWindow::Paste()
862 DBG_ASSERT( mpEditView
, "EditView missing" );
867 void EditWindow::Delete()
869 DBG_ASSERT( mpEditView
, "EditView missing" );
871 mpEditView
->DeleteSelected();
874 void EditWindow::InsertText(const String
& Text
)
876 DBG_ASSERT( mpEditView
, "EditView missing" );
877 ::vos::OGuard
aGuard (::Application::GetSolarMutex());
879 mpEditView
->InsertText(Text
);
884 } } // end of namespace ::sd::notes