47#include <com/sun/star/i18n/XBreakIterator.hpp>
48#include <com/sun/star/i18n/CharacterIteratorMode.hpp>
49#include <com/sun/star/i18n/WordType.hpp>
50#include <com/sun/star/datatransfer/UnsupportedFlavorException.hpp>
51#include <com/sun/star/datatransfer/XTransferable.hpp>
52#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
53#include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
54#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
55#include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp>
56#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
57#include <com/sun/star/util/SearchFlags.hpp>
66TETextDataObject::TETextDataObject( OUString aText ) :
maText(
std::move( aText ))
71css::uno::Any TETextDataObject::queryInterface(
const css::uno::Type & rType )
73 css::uno::Any aRet = ::cppu::queryInterface( rType,
static_cast< css::datatransfer::XTransferable*
>(
this) );
74 return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ));
78css::uno::Any TETextDataObject::getTransferData(
const css::datatransfer::DataFlavor& rFlavor )
83 if ( nT == SotClipboardFormatId::STRING )
87 else if ( nT == SotClipboardFormatId::HTML )
89 sal_uInt64 nLen = GetHTMLStream().TellEnd();
90 GetHTMLStream().Seek(0);
92 css::uno::Sequence< sal_Int8 >
aSeq( nLen );
93 memcpy(
aSeq.getArray(), GetHTMLStream().
GetData(), nLen );
98 throw css::datatransfer::UnsupportedFlavorException();
103css::uno::Sequence< css::datatransfer::DataFlavor > TETextDataObject::getTransferDataFlavors( )
105 GetHTMLStream().Seek( STREAM_SEEK_TO_END );
106 bool bHTML = GetHTMLStream().Tell() > 0;
107 css::uno::Sequence< css::datatransfer::DataFlavor > aDataFlavors( bHTML ? 2 : 1 );
114sal_Bool TETextDataObject::isDataFlavorSupported(
const css::datatransfer::DataFlavor& rFlavor )
117 return ( nT == SotClipboardFormatId::STRING );
128 std::unique_ptr<vcl::Cursor, o3tl::default_delete<vcl::Cursor>>
mpCursor;
130 std::unique_ptr<TextDDInfo, o3tl::default_delete<TextDDInfo>>
mpDDInfo;
135 css::uno::Reference< css::datatransfer::dnd::XDragSourceListener >
mxDnDListener;
154 mpImpl->mpWindow = pWindow;
155 mpImpl->mpTextEngine = pEng;
157 mpImpl->mbPaintSelection =
true;
158 mpImpl->mbAutoScroll =
true;
159 mpImpl->mbInsertMode =
true;
160 mpImpl->mbReadOnly =
false;
161 mpImpl->mbAutoIndent =
false;
162 mpImpl->mbCursorEnabled =
true;
163 mpImpl->mbClickedInSelection =
false;
168 mpImpl->mpSelFuncSet = std::make_unique<TextSelFunctionSet>(
this );
169 mpImpl->mpSelEngine = std::make_unique<SelectionEngine>(
mpImpl->mpWindow,
mpImpl->mpSelFuncSet.get() );
171 mpImpl->mpSelEngine->EnableDrag(
true );
184 css::uno::Reference< css::datatransfer::dnd::XDragGestureListener> xDGL(
mpImpl->mxDnDListener, css::uno::UNO_QUERY );
186 css::uno::Reference< css::datatransfer::dnd::XDropTargetListener> xDTL( xDGL, css::uno::UNO_QUERY );
189 pWindow->
GetDropTarget()->setDefaultActions( css::datatransfer::dnd::DNDConstants::ACTION_COPY_OR_MOVE );
195 mpImpl->mpSelEngine.reset();
196 mpImpl->mpSelFuncSet.reset();
198 if (
mpImpl->mpWindow->GetCursor() ==
mpImpl->mpCursor.get() )
199 mpImpl->mpWindow->SetCursor(
nullptr );
207 mpImpl->mpWindow->Invalidate();
213 if ( !
mpImpl->maSelection.HasRange() )
214 mpImpl->mpTextEngine->CursorMoved(
mpImpl->maSelection.GetStart().GetPara() );
217 mpImpl->mpTextEngine->CheckIdleFormatter();
221 mpImpl->mpTextEngine->ValidateSelection( aNewSel );
234 return mpImpl->maSelection;
238 return mpImpl->maSelection;
245 mpImpl->mpTextEngine->UndoActionStart();
247 mpImpl->mpTextEngine->UndoActionEnd();
250 mpImpl->mpTextEngine->FormatAndUpdate(
this );
256 if (!
mpImpl->mbPaintSelection)
258 pSelection =
nullptr;
272 mpImpl->mpTextEngine->maFont = aFont;
276 mpImpl->mpTextEngine->ImpPaint(&rRenderContext, rStartPos, pPaintArea, pSelection);
286 if ( !
mpImpl->mpTextEngine->GetUpdateMode() ||
mpImpl->mpTextEngine->IsInUndo() )
290 if (
mpImpl->maSelection.HasRange())
291 pDrawSelection = &
mpImpl->maSelection;
294 ImpPaint(rRenderContext, aStartPos, &rRect, pDrawSelection);
299 if (rSelection ==
mpImpl->maSelection)
302 bool bCaret =
false, bSelection =
false;
305 bool bGap = rSelection.
HasRange(), bOldGap =
mpImpl->maSelection.HasRange();
311 mpImpl->maSelection = rSelection;
314 mpImpl->mpTextEngine->Broadcast(
TextHint(SfxHintId::TextViewSelectionChanged));
317 mpImpl->mpTextEngine->Broadcast(
TextHint(SfxHintId::TextViewCaretChanged));
339 if ( !pRangeOrSelection->
HasRange() )
342 if(
mpImpl->mpWindow->IsPaintTransparent() )
343 mpImpl->mpWindow->Invalidate();
348 bool bVisCursor =
mpImpl->mpCursor->IsVisible();
359 bool bModified =
false;
361 bool bEndKey =
false;
362 bool bAllowIdle =
true;
367 bool bWasModified =
mpImpl->mpTextEngine->IsModified();
368 mpImpl->mpTextEngine->SetModified(
false );
381 if ( !
mpImpl->mbReadOnly )
392 if ( !
mpImpl->mbReadOnly )
398 if ( !
mpImpl->mbReadOnly )
404 if ( !
mpImpl->mbReadOnly )
425 case css::awt::Key::MOVE_WORD_FORWARD:
426 case css::awt::Key::SELECT_WORD_FORWARD:
427 case css::awt::Key::MOVE_WORD_BACKWARD:
428 case css::awt::Key::SELECT_WORD_BACKWARD:
429 case css::awt::Key::MOVE_TO_BEGIN_OF_LINE:
430 case css::awt::Key::MOVE_TO_END_OF_LINE:
431 case css::awt::Key::SELECT_TO_BEGIN_OF_LINE:
432 case css::awt::Key::SELECT_TO_END_OF_LINE:
433 case css::awt::Key::MOVE_TO_BEGIN_OF_PARAGRAPH:
434 case css::awt::Key::MOVE_TO_END_OF_PARAGRAPH:
435 case css::awt::Key::SELECT_TO_BEGIN_OF_PARAGRAPH:
436 case css::awt::Key::SELECT_TO_END_OF_PARAGRAPH:
437 case css::awt::Key::MOVE_TO_BEGIN_OF_DOCUMENT:
438 case css::awt::Key::MOVE_TO_END_OF_DOCUMENT:
439 case css::awt::Key::SELECT_TO_BEGIN_OF_DOCUMENT:
440 case css::awt::Key::SELECT_TO_END_OF_DOCUMENT:
460 case css::awt::Key::DELETE_WORD_BACKWARD:
461 case css::awt::Key::DELETE_WORD_FORWARD:
462 case css::awt::Key::DELETE_TO_BEGIN_OF_LINE:
463 case css::awt::Key::DELETE_TO_END_OF_LINE:
474 case css::awt::Key::DELETE_WORD_BACKWARD:
478 case css::awt::Key::DELETE_WORD_FORWARD:
482 case css::awt::Key::DELETE_TO_BEGIN_OF_LINE:
486 case css::awt::Key::DELETE_TO_END_OF_LINE:
493 mpImpl->mpTextEngine->UndoActionStart();
495 mpImpl->mpTextEngine->UndoActionEnd();
523 mpImpl->mpTextEngine->UndoActionStart();
524 aCurSel =
mpImpl->mpTextEngine->ImpInsertParaBreak( aCurSel );
525 if (
mpImpl->mbAutoIndent )
529 while ( ( n < pPrev->GetText().
getLength() ) && (
531 ( pPrev->
GetText()[
n ] ==
'\t' ) ) )
536 aCurSel =
mpImpl->mpTextEngine->ImpInsertText( aCurSel, pPrev->
GetText().copy( 0,
n ) );
538 mpImpl->mpTextEngine->UndoActionEnd();
547 if ( !
mpImpl->mbReadOnly )
558 aCurSel =
mpImpl->mpTextEngine->ImpInsertText( nCharCode, aCurSel, !
IsInsertMode(),
true );
568 if ( aCurSel != aOldSel )
578 mpImpl->mpTextEngine->IdleFormatAndUpdate(
this );
580 mpImpl->mpTextEngine->FormatAndUpdate(
this);
588 if (
mpImpl->mpTextEngine->IsModified() )
589 mpImpl->mpTextEngine->Broadcast(
TextHint( SfxHintId::TextModified ) );
590 else if ( bWasModified )
591 mpImpl->mpTextEngine->SetModified(
true );
598 mpImpl->mbClickedInSelection =
false;
600 mpImpl->mpSelEngine->SelMouseButtonUp( rMouseEvent );
606 if (
mpImpl->mpTextEngine->IsModified() )
607 mpImpl->mpTextEngine->Broadcast(
TextHint( SfxHintId::TextModified ) );
618 mpImpl->mpTextEngine->CheckIdleFormatter();
622 mpImpl->mpTextEngine->SetActiveView(
this );
624 mpImpl->mpSelEngine->SelMouseButtonDown( rMouseEvent );
636 if ( rMouseEvent.
IsMod2() )
646 if (
mpImpl->maSelection.GetEnd().GetIndex() <
mpImpl->mpTextEngine->GetTextLen(
mpImpl->maSelection.GetEnd().GetPara() ) )
660 if (
mpImpl->maSelection.GetStart().GetIndex() || (
mpImpl->maSelection.GetEnd().GetIndex() <
mpImpl->mpTextEngine->GetTextLen(
mpImpl->maSelection.GetEnd().GetPara() ) ) )
665 aNewSel.
GetEnd().
GetIndex() =
mpImpl->mpTextEngine->mpDoc->GetNodes()[
mpImpl->maSelection.GetEnd().GetPara() ]->GetText().getLength();
676 mpImpl->mpSelEngine->SelMouseMove( rMouseEvent );
681 mpImpl->mpTextEngine->CheckIdleFormatter();
682 mpImpl->mpTextEngine->SetActiveView(
this );
693 SAL_WARN_IF( !
mpImpl->mpTextEngine->mpIMEInfos,
"vcl",
"CommandEventId::EndExtTextInput => No Start ?" );
694 if(
mpImpl->mpTextEngine->mpIMEInfos )
696 TEParaPortion* pPortion =
mpImpl->mpTextEngine->mpTEParaPortions->GetObject(
mpImpl->mpTextEngine->mpIMEInfos->aPos.GetPara() );
699 bool bInsertMode = !
mpImpl->mpTextEngine->mpIMEInfos->bWasCursorOverwrite;
701 mpImpl->mpTextEngine->mpIMEInfos.reset();
703 mpImpl->mpTextEngine->TextModified();
704 mpImpl->mpTextEngine->FormatAndUpdate(
this );
708 if (
mpImpl->mpTextEngine->IsModified() )
709 mpImpl->mpTextEngine->Broadcast(
TextHint( SfxHintId::TextModified ) );
714 SAL_WARN_IF( !
mpImpl->mpTextEngine->mpIMEInfos,
"vcl",
"CommandEventId::ExtTextInput => No Start ?" );
715 if(
mpImpl->mpTextEngine->mpIMEInfos )
719 if ( !
pData->IsOnlyCursorChanged() )
723 aSelect =
mpImpl->mpTextEngine->ImpDeleteText( aSelect );
724 aSelect =
mpImpl->mpTextEngine->ImpInsertText( aSelect,
pData->GetText() );
726 if (
mpImpl->mpTextEngine->mpIMEInfos->bWasCursorOverwrite )
728 const sal_Int32 nOldIMETextLen =
mpImpl->mpTextEngine->mpIMEInfos->nLen;
729 const sal_Int32 nNewIMETextLen =
pData->GetText().getLength();
731 if ( ( nOldIMETextLen > nNewIMETextLen ) &&
732 ( nNewIMETextLen < mpImpl->mpTextEngine->mpIMEInfos->aOldTextAfterStartPos.getLength() ) )
735 sal_Int32 nRestore = nOldIMETextLen - nNewIMETextLen;
738 mpImpl->mpTextEngine->ImpInsertText( aPaM,
mpImpl->mpTextEngine->mpIMEInfos->aOldTextAfterStartPos.copy( nNewIMETextLen, nRestore ) );
740 else if ( ( nOldIMETextLen < nNewIMETextLen ) &&
741 ( nOldIMETextLen < mpImpl->mpTextEngine->mpIMEInfos->aOldTextAfterStartPos.getLength() ) )
744 const sal_Int32 nOverwrite = std::min( nNewIMETextLen,
mpImpl->mpTextEngine->mpIMEInfos->aOldTextAfterStartPos.getLength() ) - nOldIMETextLen;
745 SAL_WARN_IF( !nOverwrite || (nOverwrite >= 0xFF00),
"vcl",
"IME Overwrite?!" );
750 mpImpl->mpTextEngine->ImpDeleteText( aSel );
754 if (
pData->GetTextAttr() )
756 mpImpl->mpTextEngine->mpIMEInfos->CopyAttribs(
pData->GetTextAttr(),
pData->GetText().getLength() );
760 mpImpl->mpTextEngine->mpIMEInfos->DestroyAttribs();
763 TEParaPortion* pPPortion =
mpImpl->mpTextEngine->mpTEParaPortions->GetObject(
mpImpl->mpTextEngine->mpIMEInfos->aPos.GetPara() );
765 mpImpl->mpTextEngine->FormatAndUpdate(
this );
772 if (
pData->IsCursorVisible() )
780 if (
mpImpl->mpTextEngine->mpIMEInfos &&
mpImpl->mpTextEngine->mpIMEInfos->nLen )
785 sal_Int32 nInputEnd =
mpImpl->mpTextEngine->mpIMEInfos->aPos.GetIndex() +
mpImpl->mpTextEngine->mpIMEInfos->nLen;
787 if ( !
mpImpl->mpTextEngine->IsFormatted() )
788 mpImpl->mpTextEngine->FormatDoc();
793 if ( nInputEnd > rLine.
GetEnd() )
794 nInputEnd = rLine.
GetEnd();
808 mpImpl->mpSelEngine->Command( rCEvt );
815 if ( !
mpImpl->mbAutoScroll )
827 SAL_WARN_IF( !
mpImpl->mpTextEngine->IsFormatted(),
"vcl",
"Scroll: Not formatted!" );
836 if ( aNewStartPos.
Y() < 0 )
837 aNewStartPos.
setY( 0 );
841 if ( aNewStartPos.
X() < 0 )
842 aNewStartPos.
setX( 0 );
847 if ( nDiffX || nDiffY )
849 bool bVisCursor =
mpImpl->mpCursor->IsVisible();
851 mpImpl->mpWindow->PaintImmediately();
852 mpImpl->maStartDocPos = aNewStartPos;
854 if (
mpImpl->mpTextEngine->IsRightToLeft() )
856 mpImpl->mpWindow->Scroll( nDiffX, nDiffY );
857 mpImpl->mpWindow->PaintImmediately();
858 mpImpl->mpCursor->SetPos(
mpImpl->mpCursor->GetPos() +
Point( nDiffX, nDiffY ) );
859 if ( bVisCursor && !
mpImpl->mbReadOnly )
863 mpImpl->mpTextEngine->Broadcast(
TextHint( SfxHintId::TextViewScrolled ) );
868 mpImpl->mpTextEngine->SetActiveView(
this );
869 mpImpl->mpTextEngine->GetUndoManager().Undo();
874 mpImpl->mpTextEngine->SetActiveView(
this );
875 mpImpl->mpTextEngine->GetUndoManager().Redo();
880 mpImpl->mpTextEngine->UndoActionStart();
883 mpImpl->mpTextEngine->UndoActionEnd();
886void TextView::Copy( css::uno::Reference< css::datatransfer::clipboard::XClipboard >
const & rxClipboard )
888 if ( !rxClipboard.is() )
897 rxClipboard->setContents( pDataObj,
nullptr );
899 css::uno::Reference< css::datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( rxClipboard, css::uno::UNO_QUERY );
900 if( xFlushableClipboard.is() )
901 xFlushableClipboard->flushClipboard();
903 catch(
const css::uno::Exception& )
910 css::uno::Reference<css::datatransfer::clipboard::XClipboard> aClipboard(
GetWindow()->GetClipboard());
914void TextView::Paste( css::uno::Reference< css::datatransfer::clipboard::XClipboard >
const & rxClipboard )
916 if ( !rxClipboard.is() )
919 css::uno::Reference< css::datatransfer::XTransferable > xDataObj;
924 xDataObj = rxClipboard->getContents();
926 catch(
const css::uno::Exception& )
930 if ( !xDataObj.is() )
933 css::datatransfer::DataFlavor aFlavor;
935 if ( !xDataObj->isDataFlavorSupported( aFlavor ) )
940 css::uno::Any
aData = xDataObj->getTransferData( aFlavor );
943 bool bWasTruncated =
false;
944 if(
mpImpl->mpTextEngine->GetMaxTextLen() != 0 )
947 mpImpl->mpTextEngine->Broadcast(
TextHint( SfxHintId::TextModified ) );
952 catch(
const css::datatransfer::UnsupportedFlavorException& )
959 css::uno::Reference<css::datatransfer::clipboard::XClipboard> aClipboard(
GetWindow()->GetClipboard());
970 return mpImpl->mpTextEngine->GetText(
mpImpl->maSelection, aSeparator );
975 if (
mpImpl->mbInsertMode != bInsert )
977 mpImpl->mbInsertMode = bInsert;
987 if ( !
mpImpl->mbReadOnly )
999 mpImpl->mpTextEngine->CheckIdleFormatter();
1005 if (
mpImpl->mpTextEngine->IsRightToLeft() )
1038 case KEY_LEFT: aPaM = bCtrl ?
CursorWordLeft( aPaM ) :
CursorLeft( aPaM, aTranslatedKeyEvent.
GetKeyCode().
IsMod2() ? sal_uInt16(css::i18n::CharacterIteratorMode::SKIPCHARACTER) : sal_uInt16(css::i18n::CharacterIteratorMode::SKIPCELL) );
1042 case css::awt::Key::SELECT_WORD_FORWARD:
1045 case css::awt::Key::MOVE_WORD_FORWARD:
1048 case css::awt::Key::SELECT_WORD_BACKWARD:
1051 case css::awt::Key::MOVE_WORD_BACKWARD:
1054 case css::awt::Key::SELECT_TO_BEGIN_OF_LINE:
1057 case css::awt::Key::MOVE_TO_BEGIN_OF_LINE:
1060 case css::awt::Key::SELECT_TO_END_OF_LINE:
1063 case css::awt::Key::MOVE_TO_END_OF_LINE:
1066 case css::awt::Key::SELECT_TO_BEGIN_OF_PARAGRAPH:
1069 case css::awt::Key::MOVE_TO_BEGIN_OF_PARAGRAPH:
1072 case css::awt::Key::SELECT_TO_END_OF_PARAGRAPH:
1075 case css::awt::Key::MOVE_TO_END_OF_PARAGRAPH:
1078 case css::awt::Key::SELECT_TO_BEGIN_OF_DOCUMENT:
1081 case css::awt::Key::MOVE_TO_BEGIN_OF_DOCUMENT:
1084 case css::awt::Key::SELECT_TO_END_OF_DOCUMENT:
1087 case css::awt::Key::MOVE_TO_END_OF_DOCUMENT:
1095 if ( aOldEnd != aPaM )
1114 return mpImpl->maSelection;
1119 mpImpl->mpTextEngine->UndoActionStart();
1125 mpImpl->mpTextEngine->UndoActionEnd();
1127 mpImpl->mpTextEngine->FormatAndUpdate(
this );
1137 css::uno::Reference < css::i18n::XBreakIterator > xBI =
mpImpl->mpTextEngine->GetBreakIterator();
1157 css::uno::Reference < css::i18n::XBreakIterator > xBI =
mpImpl->mpTextEngine->GetBreakIterator();
1161 else if ( aPaM.
GetPara() < (
mpImpl->mpTextEngine->mpDoc->GetNodes().size()-1) )
1175 css::uno::Reference<css::i18n::XBreakIterator> xBI =
mpImpl->mpTextEngine->GetBreakIterator();
1188 mpImpl->mpTextEngine->GetWord( rPaM, &aPaM );
1192 css::uno::Reference < css::i18n::XBreakIterator > xBI =
mpImpl->mpTextEngine->GetBreakIterator();
1193 aPaM.
GetIndex() = xBI->previousWord( pNode->
GetText(), rPaM.
GetIndex(),
mpImpl->mpTextEngine->GetLocale(), css::i18n::WordType::ANYWORD_IGNOREWHITESPACES ).startPos;
1195 mpImpl->mpTextEngine->GetWord( aPaM, &aPaM );
1216 css::uno::Reference < css::i18n::XBreakIterator > xBI =
mpImpl->mpTextEngine->GetBreakIterator();
1217 aPaM.
GetIndex() = xBI->nextWord( pNode->
GetText(), aPaM.
GetIndex(),
mpImpl->mpTextEngine->GetLocale(), css::i18n::WordType::ANYWORD_IGNOREWHITESPACES ).endPos;
1218 mpImpl->mpTextEngine->GetWord( aPaM,
nullptr, &aPaM );
1220 else if ( aPaM.
GetPara() < (
mpImpl->mpTextEngine->mpDoc->GetNodes().size()-1) )
1231 if (
mpImpl->maSelection.HasRange() )
1232 return mpImpl->mpTextEngine->ImpDeleteText(
mpImpl->maSelection );
1240 aEndPaM =
CursorLeft( aEndPaM, sal_uInt16(css::i18n::CharacterIteratorMode::SKIPCHARACTER) );
1245 css::uno::Reference < css::i18n::XBreakIterator > xBI =
mpImpl->mpTextEngine->GetBreakIterator();
1246 css::i18n::Boundary aBoundary = xBI->getWordBoundary( pNode->
GetText(),
mpImpl->maSelection.GetEnd().GetIndex(),
mpImpl->mpTextEngine->GetLocale(), css::i18n::WordType::ANYWORD_IGNOREWHITESPACES,
true );
1247 if ( aBoundary.startPos ==
mpImpl->maSelection.GetEnd().GetIndex() )
1248 aBoundary = xBI->previousWord( pNode->
GetText(),
mpImpl->maSelection.GetEnd().GetIndex(),
mpImpl->mpTextEngine->GetLocale(), css::i18n::WordType::ANYWORD_IGNOREWHITESPACES );
1250 aEndPaM.
GetIndex() = std::max<sal_Int32>(aBoundary.startPos, 0);
1268 aEndPaM =
CursorRight( aEndPaM, sal_uInt16(css::i18n::CharacterIteratorMode::SKIPCELL) );
1273 css::uno::Reference < css::i18n::XBreakIterator > xBI =
mpImpl->mpTextEngine->GetBreakIterator();
1274 css::i18n::Boundary aBoundary = xBI->nextWord( pNode->
GetText(),
mpImpl->maSelection.GetEnd().GetIndex(),
mpImpl->mpTextEngine->GetLocale(), css::i18n::WordType::ANYWORD_IGNOREWHITESPACES );
1275 aEndPaM.
GetIndex() = aBoundary.startPos;
1282 else if ( aEndPaM.
GetPara() < (
mpImpl->mpTextEngine->mpDoc->GetNodes().size() - 1 ) )
1302 nX =
mpImpl->mpTextEngine->GetEditCursor( rPaM,
false ).Left();
1303 mpImpl->mnTravelXPos =
static_cast<sal_uInt16
>(nX)+1;
1306 nX =
mpImpl->mnTravelXPos;
1323 pPPortion =
mpImpl->mpTextEngine->mpTEParaPortions->GetObject( aPaM.
GetPara() );
1324 std::vector<TextLine>::size_type nL = pPPortion->
GetLines().size() - 1;
1338 nX =
mpImpl->mpTextEngine->GetEditCursor( rPaM,
false ).Left();
1339 mpImpl->mnTravelXPos =
static_cast<sal_uInt16
>(nX)+1;
1342 nX =
mpImpl->mnTravelXPos;
1346 if ( nLine < ( pPPortion->
GetLines().size() - 1 ) )
1355 else if ( rPaM.
GetPara() < (
mpImpl->mpTextEngine->mpDoc->GetNodes().size() - 1 ) )
1358 pPPortion =
mpImpl->mpTextEngine->mpTEParaPortions->GetObject( aPaM.
GetPara() );
1426 const sal_uInt32 nNode =
static_cast<sal_uInt32
>(
mpImpl->mpTextEngine->mpDoc->GetNodes().size() - 1);
1427 TextNode* pNode =
mpImpl->mpTextEngine->mpDoc->GetNodes()[ nNode ].get();
1436 aTopLeft.
AdjustY( -(
mpImpl->mpWindow->GetOutputSizePixel().Height() * 9/10) );
1438 if ( aTopLeft.
Y() < 0 )
1449 aBottomRight.
AdjustY(
mpImpl->mpWindow->GetOutputSizePixel().Height() * 9/10 );
1452 if ( aBottomRight.
Y() > nHeight )
1453 aBottomRight.
setY( nHeight-1 );
1455 TextPaM aPaM =
mpImpl->mpTextEngine->GetPaM( aBottomRight );
1461 if (
mpImpl->mpTextEngine->IsFormatting() )
1463 if ( !
mpImpl->mpTextEngine->GetUpdateMode() )
1465 if (
mpImpl->mpTextEngine->IsInUndo() )
1468 mpImpl->mpTextEngine->CheckIdleFormatter();
1469 if ( !
mpImpl->mpTextEngine->IsFormatted() )
1470 mpImpl->mpTextEngine->FormatAndUpdate(
this );
1476 mpImpl->mbCursorAtEndOfLine =
false;
1480 mpImpl->mbCursorAtEndOfLine =
1490 aEditCursor.
SetLeft(
mpImpl->mpTextEngine->GetEditCursor( aPaM,
false,
true ).Left() );
1495 sal_Int32 nTextPortionStart = 0;
1505 aEditCursor.
SetRight(
mpImpl->mpTextEngine->GetEditCursor( aNext,
true ).Left() );
1510 Size aOutSz =
mpImpl->mpWindow->GetOutputSizePixel();
1529 if ( aEditCursor.
Bottom() > nVisEndY )
1533 else if ( aEditCursor.
Top() < nVisStartY )
1535 aNewStartPos.
AdjustY( -( nVisStartY - aEditCursor.
Top() ) );
1538 if ( aEditCursor.
Right() >= nVisEndX )
1540 aNewStartPos.
AdjustX( aEditCursor.
Right() - nVisEndX );
1543 aNewStartPos.
AdjustX(nMoreX );
1545 else if ( aEditCursor.
Left() <= nVisStartX )
1547 aNewStartPos.
AdjustX( -( nVisStartX - aEditCursor.
Left() ) );
1550 aNewStartPos.
AdjustX( -nMoreX );
1562 if ( aNewStartPos.
X() < 0 )
1563 aNewStartPos.
setX( 0 );
1564 else if ( aNewStartPos.
X() > nMaxX )
1565 aNewStartPos.
setX( nMaxX );
1571 if ( aNewStartPos.
Y() > nYMax )
1572 aNewStartPos.
setY( nYMax );
1574 if ( aNewStartPos !=
mpImpl->maStartDocPos )
1575 Scroll( -(aNewStartPos.
X() -
mpImpl->maStartDocPos.X()), -(aNewStartPos.
Y() -
mpImpl->maStartDocPos.Y()) );
1578 if ( aEditCursor.
Right() < aEditCursor.
Left() )
1586 mpImpl->mpCursor->SetPos( aPoint );
1588 if ( bForceVisCursor &&
mpImpl->mbCursorEnabled )
1589 mpImpl->mpCursor->Show();
1594 mpImpl->mpTextEngine->CheckIdleFormatter();
1605 if ( !
mpImpl->mpSelEngine->HasAnchor() )
1607 if (
mpImpl->maSelection.GetStart() != aPaM )
1608 mpImpl->mpTextEngine->CursorMoved(
mpImpl->maSelection.GetStart().GetPara() );
1618 bool bForceCursor = !
mpImpl->mpDDInfo;
1639 const sal_uInt32 nCurNode = rPaM.
GetPara();
1641 if ( ( nCurNode > nStartNode ) && ( nCurNode < nEndNode ) )
1644 if ( nStartNode == nEndNode )
1646 if ( nCurNode == nStartNode )
1660 if (
mpImpl->mpDDInfo &&
mpImpl->mpDDInfo->mbVisCursor )
1662 mpImpl->mpDDInfo->maCursor.Hide();
1663 mpImpl->mpDDInfo->mbVisCursor =
false;
1669 if ( !
mpImpl->mpDDInfo->mbVisCursor )
1675 mpImpl->mpDDInfo->maCursor.SetWindow(
mpImpl->mpWindow );
1678 mpImpl->mpDDInfo->maCursor.Show();
1679 mpImpl->mpDDInfo->mbVisCursor =
true;
1685 if ( bPaint !=
mpImpl->mbPaintSelection )
1687 mpImpl->mbPaintSelection = bPaint;
1694 mpImpl->mpTextEngine->Read( rInput, &
mpImpl->maSelection );
1700 bool bTruncated =
false;
1702 const sal_Int32 nMaxLen =
mpImpl->mpTextEngine->GetMaxTextLen();
1706 const sal_Int32 nCurLen =
mpImpl->mpTextEngine->GetTextLen();
1708 const sal_Int32 nNewLen = rNewText.getLength();
1709 if ( nCurLen + nNewLen > nMaxLen )
1712 const sal_Int32 nSelLen =
mpImpl->mpTextEngine->GetTextLen(
mpImpl->maSelection );
1713 if ( nCurLen + nNewLen - nSelLen > nMaxLen )
1715 const sal_Int32 nTruncatedLen = nMaxLen - (nCurLen - nSelLen);
1716 rNewText = rNewText.copy( 0, nTruncatedLen );
1727 if (
mpImpl->mpTextEngine->GetMaxTextLen() )
1729 sal_Int32
n =
mpImpl->mpTextEngine->GetTextLen() + rNewText.size();
1730 if (
n >
mpImpl->mpTextEngine->GetMaxTextLen() )
1733 n -=
mpImpl->mpTextEngine->GetTextLen(
mpImpl->maSelection );
1734 if (
n >
mpImpl->mpTextEngine->GetMaxTextLen() )
1743 if ( !
mpImpl->mbClickedInSelection )
1748 SAL_WARN_IF( !
mpImpl->maSelection.HasRange(),
"vcl",
"TextView::dragGestureRecognized: mpImpl->mbClickedInSelection, but no selection?" );
1751 mpImpl->mpDDInfo->mbStarterOfDD =
true;
1755 mpImpl->mpCursor->Hide();
1757 sal_Int8 nActions = css::datatransfer::dnd::DNDConstants::ACTION_COPY;
1759 nActions |= css::datatransfer::dnd::DNDConstants::ACTION_MOVE;
1760 rDGE.DragSource->startDrag( rDGE, nActions, 0 , 0 , pDataObj,
mpImpl->mxDnDListener );
1766 mpImpl->mpDDInfo.reset();
1780 const sal_uInt32 nPrevParaCount =
mpImpl->mpTextEngine->GetParagraphCount();
1781 const sal_Int32 nPrevStartParaLen =
mpImpl->mpTextEngine->GetTextLen( aPrevSel.
GetStart().
GetPara() );
1783 bool bStarterOfDD =
false;
1784 for ( sal_uInt16 nView =
mpImpl->mpTextEngine->GetViewCount(); nView && !bStarterOfDD; )
1785 bStarterOfDD =
mpImpl->mpTextEngine->GetView( --nView )->mpImpl->mpDDInfo &&
mpImpl->mpTextEngine->GetView( nView )->mpImpl->mpDDInfo->mbStarterOfDD;
1790 mpImpl->mpTextEngine->UndoActionStart();
1793 css::uno::Reference< css::datatransfer::XTransferable > xDataObj = rDTDE.Transferable;
1794 if ( xDataObj.is() )
1796 css::datatransfer::DataFlavor aFlavor;
1798 if ( xDataObj->isDataFlavorSupported( aFlavor ) )
1800 css::uno::Any
aData = xDataObj->getTransferData( aFlavor );
1802 aData >>= aOUString;
1807 if ( !aText.isEmpty() && ( aText[ aText.getLength()-1 ] ==
LINE_SEP ) )
1808 aText = aText.copy(0, aText.getLength()-1);
1814 (( rDTDE.DropAction & css::datatransfer::dnd::DNDConstants::ACTION_MOVE ) || !bStarterOfDD) )
1821 const sal_uInt32 nNewParasBeforeSelection =
1822 mpImpl->mpTextEngine->GetParagraphCount() - nPrevParaCount;
1829 const sal_Int32 nNewChars =
1851 mpImpl->mpTextEngine->ImpDeleteText( aPrevSel );
1854 mpImpl->mpTextEngine->UndoActionEnd();
1856 mpImpl->mpDDInfo.reset();
1858 mpImpl->mpTextEngine->FormatAndUpdate(
this );
1860 mpImpl->mpTextEngine->Broadcast(
TextHint( SfxHintId::TextModified ) );
1862 rDTDE.Context->dropComplete(
false );
1883 Point aMousePos( rDTDE.LocationX, rDTDE.LocationY );
1885 mpImpl->mpDDInfo->maDropPos =
mpImpl->mpTextEngine->GetPaM( aDocPos );
1891 rDTDE.Context->rejectDrag();
1896 if ( !
mpImpl->mpDDInfo->mbVisCursor || ( aPrevDropPos !=
mpImpl->mpDDInfo->maDropPos ) )
1901 rDTDE.Context->acceptDrag( rDTDE.DropAction );
1907 Point aStartPos( -rStartDocPos.
X(), -rStartDocPos.
Y() );
1908 if (
mpImpl->mpTextEngine->IsRightToLeft() )
1910 Size aSz =
mpImpl->mpWindow->GetOutputSizePixel();
1911 aStartPos.
setX( rStartDocPos.
X() + aSz.
Width() - 1 );
1922 aPoint.
setY( rWindowPos.
Y() +
mpImpl->maStartDocPos.Y() );
1924 if ( !
mpImpl->mpTextEngine->IsRightToLeft() )
1926 aPoint.
setX( rWindowPos.
X() +
mpImpl->maStartDocPos.X() );
1930 Size aSz =
mpImpl->mpWindow->GetOutputSizePixel();
1931 aPoint.
setX( ( aSz.
Width() - 1 ) - rWindowPos.
X() +
mpImpl->maStartDocPos.X() );
1943 aPoint.
setY( rDocPos.
Y() -
mpImpl->maStartDocPos.Y() );
1945 if ( !
mpImpl->mpTextEngine->IsRightToLeft() )
1947 aPoint.
setX( rDocPos.
X() -
mpImpl->maStartDocPos.X() );
1951 Size aSz =
mpImpl->mpWindow->GetOutputSizePixel();
1952 aPoint.
setX( ( aSz.
Width() - 1 ) - ( rDocPos.
X() -
mpImpl->maStartDocPos.X() ) );
1961 sal_Int32 nLineNo = -1;
1962 if(
mpImpl->mbCursorEnabled )
1968 if(
mpImpl->mbCursorAtEndOfLine )
2021{
return mpImpl->mpTextEngine; }
2023{
return mpImpl->mpWindow; }
2025{
mpImpl->mbCursorEnabled = bEnable; }
2027{
return mpImpl->mbCursorEnabled; }
2029{
mpImpl->maStartDocPos = rPos; }
2031{
return mpImpl->maStartDocPos; }
2033{
mpImpl->mbAutoIndent = bAutoIndent; }
2035{
return mpImpl->mbReadOnly; }
2037{
mpImpl->mbAutoScroll = bAutoScroll; }
2039{
return mpImpl->mbAutoScroll; }
2041{
return mpImpl->maSelection.HasRange(); }
2043{
return mpImpl->mbInsertMode; }
2063 Size aOutSz =
mpImpl->mpWindow->GetOutputSizePixel();
2076 bool bFound =
false;
2104 sal_uInt16 nFound = 0;
2112 Search( rSearchOptions, bForward );
2116 if(
Search( rSearchOptions, bForward ) )
2129 bool bSearchInSelection = (0 != (rSearchOptions.
searchFlag & css::util::SearchFlags::REG_NOT_BEGINOFLINE) );
2130 if ( bSearchInSelection )
2138 bool bFound = pTextEngine->
Search( aSel, rSearchOptions );
2153 bFound = pTextEngine->
Search( aSel, rSearchOptions );
2182 for ( sal_uInt32 nPara = nStartPara; nPara <= nEndPara; ++nPara )
2194 if ( !aText.isEmpty() && (
2195 ( aText[ 0 ] ==
'\t' ) ||
2196 ( aText[ 0 ] ==
' ' ) ) )
static bool AnyInput(VclInputFlags nType=VCL_INPUT_ANY)
Determine if there are any pending input events.
void SetAlpha(sal_uInt8 nAlpha)
CommandEventId GetCommand() const
const CommandExtTextInputData * GetExtTextInputData() const
static void ShowTruncationWarning(weld::Widget *pParent)
bool Search(TextSelection &rSel, const i18nutil::SearchOptions2 &rSearchOptions, bool bForward=true) const
sal_Unicode GetCharCode() const
const vcl::KeyCode & GetKeyCode() const
KeyEvent LogicalTextDirectionality(TextDirectionality eMode) const
sal_uInt16 GetClicks() const
const Point & GetPosPixel() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
const Wallpaper & GetBackground() const
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
constexpr tools::Long getY() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
A helper class that calls Application::ReleaseSolarMutex() in its constructor and restores the mutex ...
static bool GetFormatDataFlavor(SotClipboardFormatId nFormat, css::datatransfer::DataFlavor &rFlavor)
static SotClipboardFormatId GetFormat(const css::datatransfer::DataFlavor &rFlavor)
TETextPortionList & GetTextPortions()
void MarkSelectionInvalid(sal_Int32 nStart)
std::vector< TextLine > & GetLines()
std::vector< TextLine >::size_type GetLineNumber(sal_Int32 nIndex, bool bInclEnd)
TextNode * GetNode() const
std::size_t FindPortion(sal_Int32 nCharPos, sal_Int32 &rPortionStart, bool bPreferStartingPortion=false)
static bool IsSimpleCharInput(const KeyEvent &rKeyEvent)
TextPaM ImpInsertText(const TextSelection &rSel, sal_Unicode c, bool bOverwrite=false)
void FormatAndUpdate(TextView *pCurView=nullptr)
OUString GetText(LineEnd aSeparator=LINEEND_LF) const
TextPaM ImpDeleteText(const TextSelection &rSel)
void UndoActionStart(sal_uInt16 nId=0)
const vcl::Font & GetFont() const
sal_Int32 GetStart() const
const OUString & GetText() const
sal_uInt32 GetPara() const
sal_Int32 GetIndex() const
virtual bool IsSelectionAtPoint(const Point &rPointPixel) override
virtual void DestroyAnchor() override
virtual void BeginDrag() override
virtual void SetCursorAtPoint(const Point &rPointPixel, bool bDontSelectAtCursor=false) override
virtual void CreateAnchor() override
TextSelFunctionSet(TextView *pView)
virtual void DeselectAll() override
virtual void DeselectAtPoint(const Point &) override
const TextPaM & GetStart() const
const TextPaM & GetEnd() const
Point ImpGetOutputStartPos(const Point &rStartDocPos) const
void SetSelection(const TextSelection &rNewSel)
TextPaM ImpDelete(sal_uInt8 nMode, sal_uInt8 nDelMode)
void SetAutoIndentMode(bool bAutoIndent)
void Scroll(tools::Long nHorzScroll, tools::Long nVertScroll)
void CenterPaM(const TextPaM &rPaM)
bool IsSelectionAtPoint(const Point &rPointPixel)
TextPaM CursorEndOfParagraph(const TextPaM &rPaM)
TextPaM CursorLeft(const TextPaM &rPaM, sal_uInt16 nCharacterIteratorMode)
void ShowCursor(bool bGotoCursor=true, bool bForceVisCursor=true)
vcl::Window * GetWindow() const
void Read(SvStream &rInput)
virtual void dragExit(const css::datatransfer::dnd::DropTargetEvent &dte) override
sal_Int32 GetLineNumberOfCursorInSelection() const
Returns the number in paragraph of the line in which the cursor is blinking if enabled,...
bool IsInsertMode() const
void MouseButtonDown(const MouseEvent &rMouseEvent)
void SetReadOnly(bool bReadOnly)
void SetCursorAtPoint(const Point &rPointPixel)
void ImpPaint(vcl::RenderContext &rRenderContext, const Point &rStartPos, tools::Rectangle const *pPaintArea, TextSelection const *pSelection)
bool Search(const i18nutil::SearchOptions2 &rSearchOptions, bool bForward)
TextPaM CursorWordRight(const TextPaM &rPaM)
void EnableCursor(bool bEnable)
OUString GetSelected() const
TextPaM PageDown(const TextPaM &rPaM)
void SetInsertMode(bool bInsert)
virtual ~TextView() override
virtual void dragDropEnd(const css::datatransfer::dnd::DragSourceDropEvent &dsde) override
void Command(const CommandEvent &rCEvt)
void SetPaintSelection(bool bPaint)
void ImpShowCursor(bool bGotoCursor, bool bForceVisCursor, bool bEndKey)
virtual void dragGestureRecognized(const css::datatransfer::dnd::DragGestureEvent &dge) override
std::unique_ptr< ImpTextView > mpImpl
void SetAutoScroll(bool bAutoScroll)
bool IsInSelection(const TextPaM &rPaM) const
TextSelection const & ImpMoveCursor(const KeyEvent &rKeyEvent)
bool ImpIndentBlock(bool bRight)
void MouseMove(const MouseEvent &rMouseEvent)
TextPaM CursorStartOfLine(const TextPaM &rPaM)
Point GetWindowPos(const Point &rDocPos) const
static TextPaM CursorStartOfParagraph(const TextPaM &rPaM)
TextPaM PageUp(const TextPaM &rPaM)
Point GetDocPos(const Point &rWindowPos) const
virtual void dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent &dtdee) override
TextPaM CursorDown(const TextPaM &rPaM)
virtual void dragOver(const css::datatransfer::dnd::DropTargetDragEvent &dtde) override
TextPaM CursorEndOfLine(const TextPaM &rPaM)
void MouseButtonUp(const MouseEvent &rMouseEvent)
virtual void drop(const css::datatransfer::dnd::DropTargetDropEvent &dtde) override
bool KeyInput(const KeyEvent &rKeyEvent)
void ImpShowHideSelection(const TextSelection *pRange=nullptr)
const TextSelection & GetSelection() const
bool IsAutoScroll() const
TextPaM CursorFirstWord(const TextPaM &rPaM)
void ImpSetSelection(const TextSelection &rSelection)
static TextPaM CursorStartOfDoc()
void InsertText(const OUString &rNew)
void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
sal_uInt16 Replace(const i18nutil::SearchOptions2 &rSearchOptions, bool bAll, bool bForward)
TextView(const TextView &)=delete
TextPaM CursorWordLeft(const TextPaM &rPaM)
bool ImplCheckTextLen(std::u16string_view rNewText) const
void SetStartDocPos(const Point &rPos)
TextPaM CursorRight(const TextPaM &rPaM, sal_uInt16 nCharacterIteratorMode)
TextEngine * GetTextEngine() const
const Point & GetStartDocPos() const
bool HasSelection() const
bool IsCursorEnabled() const
TextPaM CursorUp(const TextPaM &rPaM)
bool ImplTruncateNewText(OUString &rNewText) const
const Color & GetColor() const
void SetFillColor(const Color &)
bool IsTransparent() const
const Color & GetFillColor() const
sal_uInt16 GetCode() const
KeyFuncType GetFunction() const
void SetCursorRect(const tools::Rectangle *pRect=nullptr, tools::Long nExtTextInputWidth=0)
void SetInputContext(const InputContext &rInputContext)
void SetCursor(vcl::Cursor *pCursor)
virtual void EnableRTL(bool bEnable=true)
::OutputDevice const * GetOutDev() const
css::uno::Reference< css::datatransfer::dnd::XDropTarget > GetDropTarget()
css::uno::Reference< css::datatransfer::dnd::XDragGestureRecognizer > GetDragGestureRecognizer()
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
ESelection aNewSelection(GetSelection())
@ LeftToRight_TopToBottom
@ RightToLeft_TopToBottom
constexpr sal_uInt16 KEY_RETURN
constexpr sal_uInt16 KEY_HOME
constexpr sal_uInt16 KEY_LEFT
constexpr sal_uInt16 KEY_PAGEDOWN
constexpr sal_uInt16 KEY_TAB
constexpr sal_uInt16 KEY_UP
constexpr sal_uInt16 KEY_RIGHT
constexpr sal_uInt16 KEY_DELETE
constexpr sal_uInt16 KEY_DOWN
constexpr sal_uInt16 KEY_PAGEUP
constexpr sal_uInt16 KEY_INSERT
constexpr sal_uInt16 KEY_BACKSPACE
constexpr sal_uInt16 KEY_END
LineEnd GetSystemLineEnd()
TOOLS_DLLPUBLIC OString convertLineEnd(const OString &rIn, LineEnd eLineEnd)
Sequence< sal_Int8 > aSeq
#define SAL_WARN_IF(condition, area, stream)
std::unique_ptr< sal_Int32[]> pData
constexpr OUStringLiteral aData
double getLength(const B2DPolygon &rCandidate)
bool mbClickedInSelection
std::unique_ptr< vcl::Cursor, o3tl::default_delete< vcl::Cursor > > mpCursor
VclPtr< vcl::Window > mpWindow
ExtTextEngine * mpTextEngine
std::unique_ptr< TextSelFunctionSet > mpSelFuncSet
std::unique_ptr< TextDDInfo, o3tl::default_delete< TextDDInfo > > mpDDInfo
std::unique_ptr< SelectionEngine > mpSelEngine
css::uno::Reference< css::datatransfer::dnd::XDragSourceListener > mxDnDListener
TextSelection maSelection
#define TRAVEL_X_DONTKNOW
#define DELMODE_RESTOFCONTENT
#define DELMODE_RESTOFWORD
Reference< XClipboard > GetSystemPrimarySelection()