LibreOffice Module vcl (master) 1
edit.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <utility>
21#include <vcl/builder.hxx>
22#include <vcl/event.hxx>
23#include <vcl/cursor.hxx>
24#include <vcl/menu.hxx>
25#include <vcl/toolkit/edit.hxx>
26#include <vcl/weld.hxx>
27#include <vcl/specialchars.hxx>
28#include <vcl/svapp.hxx>
29#include <vcl/settings.hxx>
30#include <vcl/transfer.hxx>
32#include <vcl/ptrstyle.hxx>
33
34#include <window.h>
35#include <svdata.hxx>
36#include <strings.hrc>
37
38#include <com/sun/star/i18n/BreakIterator.hpp>
39#include <com/sun/star/i18n/CharacterIteratorMode.hpp>
40#include <com/sun/star/i18n/WordType.hpp>
41#include <com/sun/star/datatransfer/XTransferable.hpp>
42#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
43
44#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
45#include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp>
46#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
47
48#include <com/sun/star/i18n/InputSequenceChecker.hpp>
49#include <com/sun/star/i18n/InputSequenceCheckMode.hpp>
50#include <com/sun/star/i18n/ScriptType.hpp>
51
52#include <com/sun/star/uno/Any.hxx>
53
55#include <comphelper/string.hxx>
56
57#include <sot/exchange.hxx>
58#include <sot/formats.hxx>
59#include <sal/macros.h>
60#include <sal/log.hxx>
61
63#include <vcl/unohelp2.hxx>
64#include <o3tl/safeint.hxx>
65#include <o3tl/string_view.hxx>
66#include <officecfg/Office/Common.hxx>
67#include <tools/json_writer.hxx>
68
69#include <algorithm>
70#include <memory>
71#include <string_view>
72
73using namespace ::com::sun::star;
74using namespace ::com::sun::star::uno;
75using namespace ::com::sun::star::lang;
76
77// - Redo
78// - if Tracking-Cancel recreate DefaultSelection
79
81
82#define EDIT_ALIGN_LEFT 1
83#define EDIT_ALIGN_CENTER 2
84#define EDIT_ALIGN_RIGHT 3
85
86#define EDIT_DEL_LEFT 1
87#define EDIT_DEL_RIGHT 2
88
89#define EDIT_DELMODE_SIMPLE 11
90#define EDIT_DELMODE_RESTOFWORD 12
91#define EDIT_DELMODE_RESTOFCONTENT 13
92
93struct DDInfo
94{
97 sal_Int32 nDropPos;
102
104 {
106 nDropPos = 0;
107 bStarterOfDD = false;
108 bDroppedInMe = false;
109 bVisCursor = false;
110 bIsStringSupported = false;
111 }
112};
113
115{
117 std::unique_ptr<ExtTextInputAttr[]>
119 sal_Int32 nPos;
120 sal_Int32 nLen;
123
124 Impl_IMEInfos(sal_Int32 nPos, OUString aOldTextAfterStartPos);
125
126 void CopyAttribs(const ExtTextInputAttr* pA, sal_Int32 nL);
127 void DestroyAttribs();
128};
129
130Impl_IMEInfos::Impl_IMEInfos(sal_Int32 nP, OUString _aOldTextAfterStartPos)
131 : aOldTextAfterStartPos(std::move(_aOldTextAfterStartPos)),
132 nPos(nP),
133 nLen(0),
134 bCursor(true),
135 bWasCursorOverwrite(false)
136{
137}
138
139void Impl_IMEInfos::CopyAttribs(const ExtTextInputAttr* pA, sal_Int32 nL)
140{
141 nLen = nL;
142 pAttribs.reset(new ExtTextInputAttr[ nL ]);
143 memcpy( pAttribs.get(), pA, nL*sizeof(ExtTextInputAttr) );
144}
145
147{
148 pAttribs.reset();
149 nLen = 0;
150}
151
153 : Control( nType )
154{
156}
157
158Edit::Edit( vcl::Window* pParent, WinBits nStyle )
160{
162 ImplInit( pParent, nStyle );
163}
164
165void Edit::SetWidthInChars(sal_Int32 nWidthInChars)
166{
167 if (mnWidthInChars != nWidthInChars)
168 {
169 mnWidthInChars = nWidthInChars;
170 queue_resize();
171 }
172}
173
174void Edit::setMaxWidthChars(sal_Int32 nWidth)
175{
176 if (nWidth != mnMaxWidthChars)
177 {
178 mnMaxWidthChars = nWidth;
179 queue_resize();
180 }
181}
182
183bool Edit::set_property(const OString &rKey, const OUString &rValue)
184{
185 if (rKey == "width-chars")
186 SetWidthInChars(rValue.toInt32());
187 else if (rKey == "max-width-chars")
188 setMaxWidthChars(rValue.toInt32());
189 else if (rKey == "max-length")
190 {
191 sal_Int32 nTextLen = rValue.toInt32();
192 SetMaxTextLen(nTextLen == 0 ? EDIT_NOLIMIT : nTextLen);
193 }
194 else if (rKey == "editable")
195 {
196 SetReadOnly(!toBool(rValue));
197 }
198 else if (rKey == "overwrite-mode")
199 {
200 SetInsertMode(!toBool(rValue));
201 }
202 else if (rKey == "visibility")
203 {
204 mbPassword = false;
205 if (!toBool(rValue))
206 mbPassword = true;
207 }
208 else if (rKey == "placeholder-text")
209 SetPlaceholderText(rValue);
210 else if (rKey == "shadow-type")
211 {
212 if (GetStyle() & WB_BORDER)
214 }
215 else
216 return Control::set_property(rKey, rValue);
217 return true;
218}
219
221{
222 disposeOnce();
223}
224
226{
227 mpUIBuilder.reset();
228 mpDDInfo.reset();
229
230 vcl::Cursor* pCursor = GetCursor();
231 if ( pCursor )
232 {
233 SetCursor( nullptr );
234 delete pCursor;
235 }
236
237 mpIMEInfos.reset();
238
239 if ( mxDnDListener.is() )
240 {
241 if ( GetDragGestureRecognizer().is() )
242 {
243 uno::Reference< datatransfer::dnd::XDragGestureListener> xDGL( mxDnDListener, uno::UNO_QUERY );
244 GetDragGestureRecognizer()->removeDragGestureListener( xDGL );
245 }
246 if ( GetDropTarget().is() )
247 {
248 uno::Reference< datatransfer::dnd::XDropTargetListener> xDTL( mxDnDListener, uno::UNO_QUERY );
249 GetDropTarget()->removeDropTargetListener( xDTL );
250 }
251
252 mxDnDListener->disposing( lang::EventObject() ); // #95154# #96585# Empty Source means it's the Client
253 mxDnDListener.clear();
254 }
255
257
260}
261
263{
265 mpFilterText = nullptr;
266 mnXOffset = 0;
269 mnWidthInChars = -1;
270 mnMaxWidthChars = -1;
271 mbInternModified = false;
272 mbReadOnly = false;
273 mbInsertMode = true;
274 mbClickedInSelection = false;
275 mbActivePopup = false;
276 mbIsSubEdit = false;
278 mbPassword = false;
279 mpDDInfo = nullptr;
280 mpIMEInfos = nullptr;
281 mcEchoChar = 0;
282
283 // no default mirroring for Edit controls
284 // note: controls that use a subedit will revert this (SpinField, ComboBox)
285 EnableRTL( false );
286
288}
289
290bool Edit::ImplUseNativeBorder(vcl::RenderContext const & rRenderContext, WinBits nStyle) const
291{
292 bool bRet = rRenderContext.IsNativeControlSupported(ImplGetNativeControlType(),
294 && ((nStyle & WB_BORDER) && !(nStyle & WB_NOBORDER));
295 if (!bRet && mbIsSubEdit)
296 {
297 vcl::Window* pWindow = GetParent();
298 nStyle = pWindow->GetStyle();
301 && ((nStyle & WB_BORDER) && !(nStyle & WB_NOBORDER));
302 }
303 return bRet;
304}
305
306void Edit::ImplInit(vcl::Window* pParent, WinBits nStyle)
307{
308 nStyle = ImplInitStyle(nStyle);
309
310 if (!(nStyle & (WB_CENTER | WB_RIGHT)))
311 nStyle |= WB_LEFT;
312
313 Control::ImplInit(pParent, nStyle, nullptr);
314
315 mbReadOnly = (nStyle & WB_READONLY) != 0;
316
318
319 // hack: right align until keyinput and cursor travelling works
320 if( IsRTLEnabled() )
322
323 if ( nStyle & WB_RIGHT )
325 else if ( nStyle & WB_CENTER )
327
328 SetCursor( new vcl::Cursor );
329
332
333 uno::Reference< datatransfer::dnd::XDragGestureListener> xDGL( mxDnDListener, uno::UNO_QUERY );
334 uno::Reference< datatransfer::dnd::XDragGestureRecognizer > xDGR = GetDragGestureRecognizer();
335 if ( xDGR.is() )
336 {
337 xDGR->addDragGestureListener( xDGL );
338 uno::Reference< datatransfer::dnd::XDropTargetListener> xDTL( mxDnDListener, uno::UNO_QUERY );
339 GetDropTarget()->addDropTargetListener( xDTL );
340 GetDropTarget()->setActive( true );
341 GetDropTarget()->setDefaultActions( datatransfer::dnd::DNDConstants::ACTION_COPY_OR_MOVE );
342 }
343}
344
346{
347 if ( !(nStyle & WB_NOTABSTOP) )
348 nStyle |= WB_TABSTOP;
349 if ( !(nStyle & WB_NOGROUP) )
350 nStyle |= WB_GROUP;
351
352 return nStyle;
353}
354
355bool Edit::IsCharInput( const KeyEvent& rKeyEvent )
356{
357 // In the future we must use new Unicode functions for this
358 sal_Unicode cCharCode = rKeyEvent.GetCharCode();
359 return ((cCharCode >= 32) && (cCharCode != 127) &&
360 !rKeyEvent.GetKeyCode().IsMod3() &&
361 !rKeyEvent.GetKeyCode().IsMod2() &&
362 !rKeyEvent.GetKeyCode().IsMod1() );
363}
364
366{
367 Control::ApplySettings(rRenderContext);
368
369 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
370
371 const vcl::Font& aFont = rStyleSettings.GetFieldFont();
372 ApplyControlFont(rRenderContext, aFont);
373
375
376 Color aTextColor = rStyleSettings.GetFieldTextColor();
377 ApplyControlForeground(rRenderContext, aTextColor);
378
380 {
381 rRenderContext.SetBackground(GetControlBackground());
382 rRenderContext.SetFillColor(GetControlBackground());
383
384 if (ImplUseNativeBorder(rRenderContext, GetStyle()))
385 {
386 // indicates that no non-native drawing of background should take place
387 mpWindowImpl->mnNativeBackground = ControlPart::Entire;
388 }
389 }
390 else if (ImplUseNativeBorder(rRenderContext, GetStyle()))
391 {
392 // Transparent background
393 rRenderContext.SetBackground();
394 rRenderContext.SetFillColor();
395 }
396 else
397 {
398 rRenderContext.SetBackground(rStyleSettings.GetFieldColor());
399 rRenderContext.SetFillColor(rStyleSettings.GetFieldColor());
400 }
401}
402
404{
405 // MT 09/2002: nExtraOffsetX should become a member, instead of checking every time,
406 // but I need an incompatible update for this...
407 // #94095# Use extra offset only when edit has a border
408 tools::Long nExtraOffset = 0;
409 if( ( GetStyle() & WB_BORDER ) || ( mbIsSubEdit && ( GetParent()->GetStyle() & WB_BORDER ) ) )
410 nExtraOffset = 2;
411
412 return nExtraOffset;
413}
414
416{
417 tools::Long nExtraOffset = 0;
419 if (eCtrlType != ControlType::EditboxNoBorder)
420 {
421 // add some space between text entry and border
422 nExtraOffset = 2;
423 }
424 return nExtraOffset;
425}
426
427OUString Edit::ImplGetText() const
428{
429 if ( mcEchoChar || mbPassword )
430 {
431 sal_Unicode cEchoChar;
432 if ( mcEchoChar )
433 cEchoChar = mcEchoChar;
434 else
435 cEchoChar = u'\x2022';
436 OUStringBuffer aText(maText.getLength());
437 comphelper::string::padToLength(aText, maText.getLength(), cEchoChar);
438 return aText.makeStringAndClear();
439 }
440 else
441 return maText.toString();
442}
443
445{
446 if( IsPaintTransparent() )
447 {
448 Invalidate();
449 // FIXME: this is currently only on macOS
450 if( ImplGetSVData()->maNWFData.mbNoFocusRects )
452 }
453 else
454 Invalidate();
455}
456
458{
459 if ( GetStyle() & WB_TOP )
460 return ImplGetExtraXOffset();
461 else if ( GetStyle() & WB_BOTTOM )
463 return ( GetOutputSizePixel().Height() - GetTextHeight() ) / 2;
464}
465
466void Edit::ImplRepaint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRectangle)
467{
468 if (!IsReallyVisible())
469 return;
470
471 ApplySettings(rRenderContext);
472
473 const OUString aText = ImplGetText();
474 const sal_Int32 nLen = aText.getLength();
475
476 sal_Int32 nDXBuffer[256];
477 std::unique_ptr<sal_Int32[]> pDXBuffer;
478 sal_Int32* pDX = nDXBuffer;
479
480 if (nLen)
481 {
482 if (o3tl::make_unsigned(2 * nLen) > SAL_N_ELEMENTS(nDXBuffer))
483 {
484 pDXBuffer.reset(new sal_Int32[2 * (nLen + 1)]);
485 pDX = pDXBuffer.get();
486 }
487
488 GetOutDev()->GetCaretPositions(aText, pDX, 0, nLen);
489 }
490
493
494 vcl::Cursor* pCursor = GetCursor();
495 bool bVisCursor = pCursor && pCursor->IsVisible();
496 if (pCursor)
497 pCursor->Hide();
498
499 ImplClearBackground(rRenderContext, rRectangle, 0, GetOutputSizePixel().Width()-1);
500
501 bool bPaintPlaceholderText = aText.isEmpty() && !maPlaceholderText.isEmpty();
502
503 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
504
505 if (!IsEnabled() || bPaintPlaceholderText)
506 rRenderContext.SetTextColor(rStyleSettings.GetDisableColor());
507
508 // Set background color of the normal text
510 {
511 // check if we need to set ControlBackground even in NWF case
513 rRenderContext.SetLineColor();
514 rRenderContext.SetFillColor(GetControlBackground());
516 rRenderContext.Pop();
517
518 rRenderContext.SetTextFillColor(GetControlBackground());
519 }
520 else if (IsPaintTransparent() || ImplUseNativeBorder(rRenderContext, GetStyle()))
521 rRenderContext.SetTextFillColor();
522 else
523 rRenderContext.SetTextFillColor(IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor());
524
525 ImplPaintBorder(rRenderContext);
526
527 bool bDrawSelection = maSelection.Len() && (HasFocus() || (GetStyle() & WB_NOHIDESELECTION) || mbActivePopup);
528
529 aPos.setX( mnXOffset + ImplGetExtraXOffset() );
530 if (bPaintPlaceholderText)
531 {
532 rRenderContext.DrawText(aPos, maPlaceholderText);
533 }
534 else if (!bDrawSelection && !mpIMEInfos)
535 {
536 rRenderContext.DrawText(aPos, aText, 0, nLen);
537 }
538 else
539 {
540 // save graphics state
541 rRenderContext.Push();
542 // first calculate highlighted and non highlighted clip regions
543 vcl::Region aHighlightClipRegion;
544 vcl::Region aNormalClipRegion;
545 Selection aTmpSel(maSelection);
546 aTmpSel.Normalize();
547 // selection is highlighted
548 for(sal_Int32 i = 0; i < nLen; ++i)
549 {
550 tools::Rectangle aRect(aPos, Size(10, nTH));
551 aRect.SetLeft( pDX[2 * i] + mnXOffset + ImplGetExtraXOffset() );
552 aRect.SetRight( pDX[2 * i + 1] + mnXOffset + ImplGetExtraXOffset() );
553 aRect.Normalize();
554 bool bHighlight = false;
555 if (i >= aTmpSel.Min() && i < aTmpSel.Max())
556 bHighlight = true;
557
558 if (mpIMEInfos && mpIMEInfos->pAttribs &&
559 i >= mpIMEInfos->nPos && i < (mpIMEInfos->nPos+mpIMEInfos->nLen) &&
560 (mpIMEInfos->pAttribs[i - mpIMEInfos->nPos] & ExtTextInputAttr::Highlight))
561 {
562 bHighlight = true;
563 }
564
565 if (bHighlight)
566 aHighlightClipRegion.Union(aRect);
567 else
568 aNormalClipRegion.Union(aRect);
569 }
570 // draw normal text
571 Color aNormalTextColor = rRenderContext.GetTextColor();
572 rRenderContext.SetClipRegion(aNormalClipRegion);
573
574 if (IsPaintTransparent())
575 rRenderContext.SetTextFillColor();
576 else
577 {
578 // Set background color when part of the text is selected
579 if (ImplUseNativeBorder(rRenderContext, GetStyle()))
580 {
582 rRenderContext.SetTextFillColor(GetControlBackground());
583 else
584 rRenderContext.SetTextFillColor();
585 }
586 else
587 {
588 rRenderContext.SetTextFillColor(IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor());
589 }
590 }
591 rRenderContext.DrawText(aPos, aText, 0, nLen);
592
593 // draw highlighted text
594 rRenderContext.SetClipRegion(aHighlightClipRegion);
595 rRenderContext.SetTextColor(rStyleSettings.GetHighlightTextColor());
596 rRenderContext.SetTextFillColor(rStyleSettings.GetHighlightColor());
597 rRenderContext.DrawText(aPos, aText, 0, nLen);
598
599 // if IME info exists loop over portions and output different font attributes
600 if (mpIMEInfos && mpIMEInfos->pAttribs)
601 {
602 for(int n = 0; n < 2; n++)
603 {
604 vcl::Region aRegion;
605 if (n == 0)
606 {
607 rRenderContext.SetTextColor(aNormalTextColor);
608 if (IsPaintTransparent())
609 rRenderContext.SetTextFillColor();
610 else
611 rRenderContext.SetTextFillColor(IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor());
612 aRegion = aNormalClipRegion;
613 }
614 else
615 {
616 rRenderContext.SetTextColor(rStyleSettings.GetHighlightTextColor());
617 rRenderContext.SetTextFillColor(rStyleSettings.GetHighlightColor());
618 aRegion = aHighlightClipRegion;
619 }
620
621 for(int i = 0; i < mpIMEInfos->nLen; )
622 {
623 ExtTextInputAttr nAttr = mpIMEInfos->pAttribs[i];
624 vcl::Region aClip;
625 int nIndex = i;
626 while (nIndex < mpIMEInfos->nLen && mpIMEInfos->pAttribs[nIndex] == nAttr) // #112631# check nIndex before using it
627 {
628 tools::Rectangle aRect( aPos, Size( 10, nTH ) );
629 aRect.SetLeft( pDX[2 * (nIndex + mpIMEInfos->nPos)] + mnXOffset + ImplGetExtraXOffset() );
630 aRect.SetRight( pDX[2 * (nIndex + mpIMEInfos->nPos) + 1] + mnXOffset + ImplGetExtraXOffset() );
631 aRect.Normalize();
632 aClip.Union(aRect);
633 nIndex++;
634 }
635 i = nIndex;
636 aClip.Intersect(aRegion);
637 if (!aClip.IsEmpty() && nAttr != ExtTextInputAttr::NONE)
638 {
639 vcl::Font aFont = rRenderContext.GetFont();
640 if (nAttr & ExtTextInputAttr::Underline)
642 else if (nAttr & ExtTextInputAttr::DoubleUnderline)
644 else if (nAttr & ExtTextInputAttr::BoldUnderline)
646 else if (nAttr & ExtTextInputAttr::DottedUnderline)
648 else if (nAttr & ExtTextInputAttr::DashDotUnderline)
650 else if (nAttr & ExtTextInputAttr::GrayWaveline)
651 {
653 rRenderContext.SetTextLineColor(COL_LIGHTGRAY);
654 }
655 rRenderContext.SetFont(aFont);
656
657 if (nAttr & ExtTextInputAttr::RedText)
658 rRenderContext.SetTextColor(COL_RED);
659 else if (nAttr & ExtTextInputAttr::HalfToneText)
660 rRenderContext.SetTextColor(COL_LIGHTGRAY);
661
662 rRenderContext.SetClipRegion(aClip);
663 rRenderContext.DrawText(aPos, aText, 0, nLen);
664 }
665 }
666 }
667 }
668
669 // restore graphics state
670 rRenderContext.Pop();
671 }
672
673 if (bVisCursor && (!mpIMEInfos || mpIMEInfos->bCursor))
674 pCursor->Show();
675}
676
677void Edit::ImplDelete( const Selection& rSelection, sal_uInt8 nDirection, sal_uInt8 nMode )
678{
679 const sal_Int32 nTextLen = ImplGetText().getLength();
680
681 // deleting possible?
682 if ( !rSelection.Len() &&
683 (((rSelection.Min() == 0) && (nDirection == EDIT_DEL_LEFT)) ||
684 ((rSelection.Max() == nTextLen) && (nDirection == EDIT_DEL_RIGHT))) )
685 return;
686
688
689 Selection aSelection( rSelection );
690 aSelection.Normalize();
691
692 if ( !aSelection.Len() )
693 {
694 uno::Reference < i18n::XBreakIterator > xBI = ImplGetBreakIterator();
695 if ( nDirection == EDIT_DEL_LEFT )
696 {
697 if ( nMode == EDIT_DELMODE_RESTOFWORD )
698 {
699 const OUString sText = maText.toString();
700 i18n::Boundary aBoundary = xBI->getWordBoundary( sText, aSelection.Min(),
701 GetSettings().GetLanguageTag().getLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES, true );
702 auto startPos = aBoundary.startPos;
703 if ( startPos == aSelection.Min() )
704 {
705 aBoundary = xBI->previousWord( sText, aSelection.Min(),
706 GetSettings().GetLanguageTag().getLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES );
707 startPos = std::max(aBoundary.startPos, sal_Int32(0));
708 }
709 aSelection.Min() = startPos;
710 }
711 else if ( nMode == EDIT_DELMODE_RESTOFCONTENT )
712 {
713 aSelection.Min() = 0;
714 }
715 else
716 {
717 sal_Int32 nCount = 1;
718 aSelection.Min() = xBI->previousCharacters( maText.toString(), aSelection.Min(),
719 GetSettings().GetLanguageTag().getLocale(), i18n::CharacterIteratorMode::SKIPCHARACTER, nCount, nCount );
720 }
721 }
722 else
723 {
724 if ( nMode == EDIT_DELMODE_RESTOFWORD )
725 {
726 i18n::Boundary aBoundary = xBI->nextWord( maText.toString(), aSelection.Max(),
727 GetSettings().GetLanguageTag().getLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES );
728 aSelection.Max() = aBoundary.startPos;
729 }
730 else if ( nMode == EDIT_DELMODE_RESTOFCONTENT )
731 {
732 aSelection.Max() = nTextLen;
733 }
734 else
735 {
736 sal_Int32 nCount = 1;
737 aSelection.Max() = xBI->nextCharacters( maText.toString(), aSelection.Max(),
738 GetSettings().GetLanguageTag().getLocale(), i18n::CharacterIteratorMode::SKIPCHARACTER, nCount, nCount );
739 }
740 }
741 }
742
743 const auto nSelectionMin = aSelection.Min();
744 maText.remove( nSelectionMin, aSelection.Len() );
745 maSelection.Min() = nSelectionMin;
746 maSelection.Max() = nSelectionMin;
748 mbInternModified = true;
749}
750
751OUString Edit::ImplGetValidString( const OUString& rString )
752{
753 OUString aValidString = rString.replaceAll("\n", "").replaceAll("\r", "");
754 aValidString = aValidString.replace('\t', ' ');
755 return aValidString;
756}
757
758uno::Reference <i18n::XBreakIterator> const& Edit::ImplGetBreakIterator()
759{
760 if (!mxBreakIterator)
761 mxBreakIterator = i18n::BreakIterator::create(::comphelper::getProcessComponentContext());
762 return mxBreakIterator;
763}
764
765uno::Reference <i18n::XExtendedInputSequenceChecker> const& Edit::ImplGetInputSequenceChecker()
766{
767 if (!mxISC.is())
768 mxISC = i18n::InputSequenceChecker::create(::comphelper::getProcessComponentContext());
769 return mxISC;
770}
771
773{
774 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent, VclMessageType::Warning,
775 VclButtonsType::Ok, VclResId(SV_EDIT_WARNING_STR)));
776 xBox->run();
777}
778
779bool Edit::ImplTruncateToMaxLen( OUString& rStr, sal_Int32 nSelectionLen ) const
780{
781 bool bWasTruncated = false;
782 if (maText.getLength() - nSelectionLen > mnMaxTextLen - rStr.getLength())
783 {
784 sal_Int32 nErasePos = mnMaxTextLen - maText.getLength() + nSelectionLen;
785 rStr = rStr.copy( 0, nErasePos );
786 bWasTruncated = true;
787 }
788 return bWasTruncated;
789}
790
791void Edit::ImplInsertText( const OUString& rStr, const Selection* pNewSel, bool bIsUserInput )
792{
793 Selection aSelection( maSelection );
794 aSelection.Normalize();
795
796 OUString aNewText( ImplGetValidString( rStr ) );
797
798 // as below, if there's no selection, but we're in overwrite mode and not beyond
799 // the end of the existing text then that's like a selection of 1
800 auto nSelectionLen = aSelection.Len();
801 if (!nSelectionLen && !mbInsertMode && aSelection.Max() < maText.getLength())
802 nSelectionLen = 1;
803 ImplTruncateToMaxLen( aNewText, nSelectionLen );
804
806
807 if ( aSelection.Len() )
808 maText.remove( aSelection.Min(), aSelection.Len() );
809 else if (!mbInsertMode && aSelection.Max() < maText.getLength())
810 maText.remove( aSelection.Max(), 1 );
811
812 // take care of input-sequence-checking now
813 if (bIsUserInput && !rStr.isEmpty())
814 {
815 SAL_WARN_IF( rStr.getLength() != 1, "vcl", "unexpected string length. User input is expected to provide 1 char only!" );
816
817 // determine if input-sequence-checking should be applied or not
818
819 uno::Reference < i18n::XBreakIterator > xBI = ImplGetBreakIterator();
820 bool bIsInputSequenceChecking = rStr.getLength() == 1 &&
821 officecfg::Office::Common::I18N::CTL::CTLFont::get() &&
822 officecfg::Office::Common::I18N::CTL::CTLSequenceChecking::get() &&
823 aSelection.Min() > 0 && /* first char needs not to be checked */
824 xBI.is() && i18n::ScriptType::COMPLEX == xBI->getScriptType( rStr, 0 );
825
826 if (bIsInputSequenceChecking)
827 {
828 uno::Reference < i18n::XExtendedInputSequenceChecker > xISC = ImplGetInputSequenceChecker();
829 if (xISC.is())
830 {
831 sal_Unicode cChar = rStr[0];
832 sal_Int32 nTmpPos = aSelection.Min();
833 sal_Int16 nCheckMode = officecfg::Office::Common::I18N::CTL::CTLSequenceCheckingRestricted::get()?
834 i18n::InputSequenceCheckMode::STRICT : i18n::InputSequenceCheckMode::BASIC;
835
836 // the text that needs to be checked is only the one
837 // before the current cursor position
838 const OUString aOldText( maText.getStr(), nTmpPos);
839 OUString aTmpText( aOldText );
840 if (officecfg::Office::Common::I18N::CTL::CTLSequenceCheckingTypeAndReplace::get())
841 {
842 xISC->correctInputSequence( aTmpText, nTmpPos - 1, cChar, nCheckMode );
843
844 // find position of first character that has changed
845 sal_Int32 nOldLen = aOldText.getLength();
846 sal_Int32 nTmpLen = aTmpText.getLength();
847 const sal_Unicode *pOldTxt = aOldText.getStr();
848 const sal_Unicode *pTmpTxt = aTmpText.getStr();
849 sal_Int32 nChgPos = 0;
850 while ( nChgPos < nOldLen && nChgPos < nTmpLen &&
851 pOldTxt[nChgPos] == pTmpTxt[nChgPos] )
852 ++nChgPos;
853
854 const OUString aChgText( aTmpText.copy( nChgPos ) );
855
856 // remove text from first pos to be changed to current pos
857 maText.remove( nChgPos, nTmpPos - nChgPos );
858
859 if (!aChgText.isEmpty())
860 {
861 aNewText = aChgText;
862 aSelection.Min() = nChgPos; // position for new text to be inserted
863 }
864 else
865 aNewText.clear();
866 }
867 else
868 {
869 // should the character be ignored (i.e. not get inserted) ?
870 if (!xISC->checkInputSequence( aOldText, nTmpPos - 1, cChar, nCheckMode ))
871 aNewText.clear();
872 }
873 }
874 }
875
876 // at this point now we will insert the non-empty text 'normally' some lines below...
877 }
878
879 if ( !aNewText.isEmpty() )
880 maText.insert( aSelection.Min(), aNewText );
881
882 if ( !pNewSel )
883 {
884 maSelection.Min() = aSelection.Min() + aNewText.getLength();
886 }
887 else
888 {
889 maSelection = *pNewSel;
890 if ( maSelection.Min() > maText.getLength() )
891 maSelection.Min() = maText.getLength();
892 if ( maSelection.Max() > maText.getLength() )
893 maSelection.Max() = maText.getLength();
894 }
895
897 mbInternModified = true;
898}
899
900void Edit::ImplSetText( const OUString& rText, const Selection* pNewSelection )
901{
902 // we delete text by "selecting" the old text completely then calling InsertText; this is flicker free
903 if ( ( rText.getLength() > mnMaxTextLen ) ||
904 ( std::u16string_view(rText) == std::u16string_view(maText.getStr(), maText.getLength())
905 && (!pNewSelection || (*pNewSelection == maSelection)) ) )
906 return;
907
909 maSelection.Min() = 0;
910 maSelection.Max() = maText.getLength();
911 if ( mnXOffset || HasPaintEvent() )
912 {
913 mnXOffset = 0;
914 maText = ImplGetValidString( rText );
915
916 // #i54929# recalculate mnXOffset before ImplSetSelection,
917 // else cursor ends up in wrong position
918 ImplAlign();
919
920 if ( pNewSelection )
921 ImplSetSelection( *pNewSelection, false );
922
923 if ( mnXOffset && !pNewSelection )
924 maSelection.Max() = 0;
925
926 Invalidate();
927 }
928 else
929 ImplInsertText( rText, pNewSelection );
930
932}
933
935{
937 const vcl::Window* pControl = mbIsSubEdit ? GetParent() : this;
938
939 switch (pControl->GetType())
940 {
949 nCtrl = ControlType::Combobox;
950 break;
951
953 if ( GetWindow( GetWindowType::Border ) != this )
955 else
957 break;
958
959 case WindowType::EDIT:
967 if (pControl->GetStyle() & WB_SPIN)
968 nCtrl = ControlType::Spinbox;
969 else
970 {
971 if (GetWindow(GetWindowType::Border) != this)
972 nCtrl = ControlType::Editbox;
973 else
975 }
976 break;
977
978 default:
979 nCtrl = ControlType::Editbox;
980 }
981 return nCtrl;
982}
983
984void Edit::ImplClearBackground(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRectangle, tools::Long nXStart, tools::Long nXEnd )
985{
986 /*
987 * note: at this point the cursor must be switched off already
988 */
990 aRect.SetLeft( nXStart );
991 aRect.SetRight( nXEnd );
992
993 if( !(ImplUseNativeBorder(rRenderContext, GetStyle()) || IsPaintTransparent()))
994 rRenderContext.Erase(aRect);
996 {
997 // ImplPaintBorder() is a NOP, we have a native border, and this is a sub-edit of a control.
998 // That means we have to draw the parent native widget to paint the edit area to clear our background.
1000 GetParent()->Paint(rRenderContext, rRectangle);
1001 }
1002}
1003
1004void Edit::ImplPaintBorder(vcl::RenderContext const & rRenderContext)
1005{
1006 // this is not needed when double-buffering
1008 return;
1009
1010 if (!(ImplUseNativeBorder(rRenderContext, GetStyle()) || IsPaintTransparent()))
1011 return;
1012
1013 // draw the inner part by painting the whole control using its border window
1015 if (pBorder == this)
1016 {
1017 // we have no border, use parent
1018 vcl::Window* pControl = mbIsSubEdit ? GetParent() : this;
1019 pBorder = pControl->GetWindow(GetWindowType::Border);
1020 if (pBorder == this)
1021 pBorder = GetParent();
1022 }
1023
1024 if (!pBorder)
1025 return;
1026
1027 // set proper clipping region to not overdraw the whole control
1028 vcl::Region aClipRgn = GetPaintRegion();
1029 if (!aClipRgn.IsNull())
1030 {
1031 // transform clipping region to border window's coordinate system
1032 if (IsRTLEnabled() != pBorder->IsRTLEnabled() && AllSettings::GetLayoutRTL())
1033 {
1034 // need to mirror in case border is not RTL but edit is (or vice versa)
1035
1036 // mirror
1037 tools::Rectangle aBounds(aClipRgn.GetBoundRect());
1038 int xNew = GetOutputSizePixel().Width() - aBounds.GetWidth() - aBounds.Left();
1039 aClipRgn.Move(xNew - aBounds.Left(), 0);
1040
1041 // move offset of border window
1042 Point aBorderOffs = pBorder->ScreenToOutputPixel(OutputToScreenPixel(Point()));
1043 aClipRgn.Move(aBorderOffs.X(), aBorderOffs.Y());
1044 }
1045 else
1046 {
1047 // normal case
1048 Point aBorderOffs = pBorder->ScreenToOutputPixel(OutputToScreenPixel(Point()));
1049 aClipRgn.Move(aBorderOffs.X(), aBorderOffs.Y());
1050 }
1051
1052 vcl::Region oldRgn(pBorder->GetOutDev()->GetClipRegion());
1053 pBorder->GetOutDev()->SetClipRegion(aClipRgn);
1054
1055 pBorder->Paint(*pBorder->GetOutDev(), tools::Rectangle());
1056
1057 pBorder->GetOutDev()->SetClipRegion(oldRgn);
1058 }
1059 else
1060 {
1061 pBorder->Paint(*pBorder->GetOutDev(), tools::Rectangle());
1062 }
1063}
1064
1065void Edit::ImplShowCursor( bool bOnlyIfVisible )
1066{
1067 if ( !IsUpdateMode() || ( bOnlyIfVisible && !IsReallyVisible() ) )
1068 return;
1069
1070 vcl::Cursor* pCursor = GetCursor();
1071 OUString aText = ImplGetText();
1072
1073 tools::Long nTextPos = 0;
1074
1075 sal_Int32 nDXBuffer[256];
1076 std::unique_ptr<sal_Int32[]> pDXBuffer;
1077 sal_Int32* pDX = nDXBuffer;
1078
1079 if( !aText.isEmpty() )
1080 {
1081 if( o3tl::make_unsigned(2*aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer) )
1082 {
1083 pDXBuffer.reset(new sal_Int32[2*(aText.getLength()+1)]);
1084 pDX = pDXBuffer.get();
1085 }
1086
1087 GetOutDev()->GetCaretPositions( aText, pDX, 0, aText.getLength() );
1088
1089 if( maSelection.Max() < aText.getLength() )
1090 nTextPos = pDX[ 2*maSelection.Max() ];
1091 else
1092 nTextPos = pDX[ 2*aText.getLength()-1 ];
1093 }
1094
1095 tools::Long nCursorWidth = 0;
1096 if ( !mbInsertMode && !maSelection.Len() && (maSelection.Max() < aText.getLength()) )
1097 nCursorWidth = GetTextWidth(aText, maSelection.Max(), 1);
1098 tools::Long nCursorPosX = nTextPos + mnXOffset + ImplGetExtraXOffset();
1099
1100 // cursor should land in visible area
1101 const Size aOutSize = GetOutputSizePixel();
1102 if ( (nCursorPosX < 0) || (nCursorPosX >= aOutSize.Width()) )
1103 {
1104 tools::Long nOldXOffset = mnXOffset;
1105
1106 if ( nCursorPosX < 0 )
1107 {
1108 mnXOffset = - nTextPos;
1109 tools::Long nMaxX = 0;
1110 mnXOffset += aOutSize.Width() / 5;
1111 if ( mnXOffset > nMaxX )
1112 mnXOffset = nMaxX;
1113 }
1114 else
1115 {
1116 mnXOffset = (aOutSize.Width()-ImplGetExtraXOffset()) - nTextPos;
1117 // Something more?
1118 if ( (aOutSize.Width()-ImplGetExtraXOffset()) < nTextPos )
1119 {
1120 tools::Long nMaxNegX = (aOutSize.Width()-ImplGetExtraXOffset()) - GetTextWidth( aText );
1121 mnXOffset -= aOutSize.Width() / 5;
1122 if ( mnXOffset < nMaxNegX ) // both negative...
1123 mnXOffset = nMaxNegX;
1124 }
1125 }
1126
1127 nCursorPosX = nTextPos + mnXOffset + ImplGetExtraXOffset();
1128 if ( nCursorPosX == aOutSize.Width() ) // then invisible...
1129 nCursorPosX--;
1130
1131 if ( mnXOffset != nOldXOffset )
1133 }
1134
1135 const tools::Long nTextHeight = GetTextHeight();
1136 const tools::Long nCursorPosY = ImplGetTextYPosition();
1137 if (pCursor)
1138 {
1139 pCursor->SetPos( Point( nCursorPosX, nCursorPosY ) );
1140 pCursor->SetSize( Size( nCursorWidth, nTextHeight ) );
1141 pCursor->Show();
1142 }
1143}
1144
1146{
1148 {
1149 // short circuit common case and avoid slow GetTextWidth() calc
1150 return;
1151 }
1152
1153 tools::Long nTextWidth = GetTextWidth( ImplGetText() );
1154 tools::Long nOutWidth = GetOutputSizePixel().Width();
1155
1156 if ( mnAlign == EDIT_ALIGN_LEFT )
1157 {
1158 if (nTextWidth < nOutWidth)
1159 mnXOffset = 0;
1160 }
1161 else if ( mnAlign == EDIT_ALIGN_RIGHT )
1162 {
1163 tools::Long nMinXOffset = nOutWidth - nTextWidth - 1 - ImplGetExtraXOffset();
1164 bool bRTL = IsRTLEnabled();
1165 if( mbIsSubEdit && GetParent() )
1166 bRTL = GetParent()->IsRTLEnabled();
1167 if( bRTL )
1168 {
1169 if( nTextWidth < nOutWidth )
1170 mnXOffset = nMinXOffset;
1171 }
1172 else
1173 {
1174 if( nTextWidth < nOutWidth )
1175 mnXOffset = nMinXOffset;
1176 else if ( mnXOffset < nMinXOffset )
1177 mnXOffset = nMinXOffset;
1178 }
1179 }
1180 else if( mnAlign == EDIT_ALIGN_CENTER )
1181 {
1182 // would be nicer with check while scrolling but then it's not centred in scrolled state
1183 mnXOffset = (nOutWidth - nTextWidth) / 2;
1184 }
1185}
1186
1188{
1189 ImplAlign();
1192}
1193
1194sal_Int32 Edit::ImplGetCharPos( const Point& rWindowPos ) const
1195{
1196 sal_Int32 nIndex = EDIT_NOLIMIT;
1197 OUString aText = ImplGetText();
1198
1199 sal_Int32 nDXBuffer[256];
1200 std::unique_ptr<sal_Int32[]> pDXBuffer;
1201 sal_Int32* pDX = nDXBuffer;
1202 if( o3tl::make_unsigned(2*aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer) )
1203 {
1204 pDXBuffer.reset(new sal_Int32[2*(aText.getLength()+1)]);
1205 pDX = pDXBuffer.get();
1206 }
1207
1208 GetOutDev()->GetCaretPositions( aText, pDX, 0, aText.getLength() );
1209 tools::Long nX = rWindowPos.X() - mnXOffset - ImplGetExtraXOffset();
1210 for (sal_Int32 i = 0; i < aText.getLength(); aText.iterateCodePoints(&i))
1211 {
1212 if( (pDX[2*i] >= nX && pDX[2*i+1] <= nX) ||
1213 (pDX[2*i+1] >= nX && pDX[2*i] <= nX))
1214 {
1215 nIndex = i;
1216 if( pDX[2*i] < pDX[2*i+1] )
1217 {
1218 if( nX > (pDX[2*i]+pDX[2*i+1])/2 )
1219 aText.iterateCodePoints(&nIndex);
1220 }
1221 else
1222 {
1223 if( nX < (pDX[2*i]+pDX[2*i+1])/2 )
1224 aText.iterateCodePoints(&nIndex);
1225 }
1226 break;
1227 }
1228 }
1229 if( nIndex == EDIT_NOLIMIT )
1230 {
1231 nIndex = 0;
1232 sal_Int32 nFinalIndex = 0;
1233 tools::Long nDiff = std::abs( pDX[0]-nX );
1234 sal_Int32 i = 0;
1235 if (!aText.isEmpty())
1236 {
1237 aText.iterateCodePoints(&i); //skip the first character
1238 }
1239 while (i < aText.getLength())
1240 {
1241 tools::Long nNewDiff = std::abs( pDX[2*i]-nX );
1242
1243 if( nNewDiff < nDiff )
1244 {
1245 nIndex = i;
1246 nDiff = nNewDiff;
1247 }
1248
1249 nFinalIndex = i;
1250
1251 aText.iterateCodePoints(&i);
1252 }
1253 if (nIndex == nFinalIndex && std::abs( pDX[2*nIndex+1] - nX ) < nDiff)
1255 }
1256
1257 return nIndex;
1258}
1259
1260void Edit::ImplSetCursorPos( sal_Int32 nChar, bool bSelect )
1261{
1262 Selection aSelection( maSelection );
1263 aSelection.Max() = nChar;
1264 if ( !bSelect )
1265 aSelection.Min() = aSelection.Max();
1266 ImplSetSelection( aSelection );
1267}
1268
1270{
1271 if ( GetSelection().Len() )
1272 {
1273 css::uno::Reference<css::datatransfer::clipboard::XClipboard> aSelection(GetSystemPrimarySelection());
1274 ImplCopy( aSelection );
1275 }
1276}
1277
1278void Edit::ImplCopy( uno::Reference< datatransfer::clipboard::XClipboard > const & rxClipboard )
1279{
1281}
1282
1283void Edit::ImplPaste( uno::Reference< datatransfer::clipboard::XClipboard > const & rxClipboard )
1284{
1285 if ( !rxClipboard.is() )
1286 return;
1287
1288 uno::Reference< datatransfer::XTransferable > xDataObj;
1289
1290 try
1291 {
1292 SolarMutexReleaser aReleaser;
1293 xDataObj = rxClipboard->getContents();
1294 }
1295 catch( const css::uno::Exception& )
1296 {
1297 }
1298
1299 if ( !xDataObj.is() )
1300 return;
1301
1302 datatransfer::DataFlavor aFlavor;
1303 SotExchange::GetFormatDataFlavor( SotClipboardFormatId::STRING, aFlavor );
1304 try
1305 {
1306 uno::Any aData = xDataObj->getTransferData( aFlavor );
1307 OUString aText;
1308 aData >>= aText;
1309
1310 // tdf#127588 - extend selection to the entire field or paste the text
1311 // from the clipboard to the current position if there is no selection
1312 if (mnMaxTextLen < EDIT_NOLIMIT && maSelection.Len() == 0)
1313 {
1314 const sal_Int32 aTextLen = aText.getLength();
1315 if (aTextLen == mnMaxTextLen)
1316 {
1317 maSelection.Min() = 0;
1319 } else
1320 maSelection.Max() = std::min<sal_Int32>(maSelection.Min() + aTextLen, mnMaxTextLen);
1321 }
1322
1323 Selection aSelection(maSelection);
1324 aSelection.Normalize();
1325 if (ImplTruncateToMaxLen(aText, aSelection.Len()))
1327
1328 ReplaceSelected( aText );
1329 }
1330 catch( const css::uno::Exception& )
1331 {
1332 }
1333}
1334
1336{
1337 if ( mpSubEdit )
1338 {
1339 Control::MouseButtonDown( rMEvt );
1340 return;
1341 }
1342
1343 sal_Int32 nCharPos = ImplGetCharPos( rMEvt.GetPosPixel() );
1344 Selection aSelection( maSelection );
1345 aSelection.Normalize();
1346
1347 if ( rMEvt.GetClicks() < 4 )
1348 {
1349 mbClickedInSelection = false;
1350 if ( rMEvt.GetClicks() == 3 )
1351 {
1354
1355 }
1356 else if ( rMEvt.GetClicks() == 2 )
1357 {
1358 uno::Reference < i18n::XBreakIterator > xBI = ImplGetBreakIterator();
1359 i18n::Boundary aBoundary = xBI->getWordBoundary( maText.toString(), aSelection.Max(),
1360 GetSettings().GetLanguageTag().getLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES, true );
1361 ImplSetSelection( Selection( aBoundary.startPos, aBoundary.endPos ) );
1363 }
1364 else if ( !rMEvt.IsShift() && HasFocus() && aSelection.Contains( nCharPos ) )
1365 mbClickedInSelection = true;
1366 else if ( rMEvt.IsLeft() )
1367 ImplSetCursorPos( nCharPos, rMEvt.IsShift() );
1368
1369 if ( !mbClickedInSelection && rMEvt.IsLeft() && ( rMEvt.GetClicks() == 1 ) )
1371 }
1372
1373 GrabFocus();
1374}
1375
1377{
1378 if ( mbClickedInSelection && rMEvt.IsLeft() )
1379 {
1380 sal_Int32 nCharPos = ImplGetCharPos( rMEvt.GetPosPixel() );
1381 ImplSetCursorPos( nCharPos, false );
1382 mbClickedInSelection = false;
1383 }
1384 else if ( rMEvt.IsMiddle() && !mbReadOnly &&
1385 ( GetSettings().GetMouseSettings().GetMiddleButtonAction() == MouseMiddleButtonAction::PasteSelection ) )
1386 {
1387 css::uno::Reference<css::datatransfer::clipboard::XClipboard> aSelection(GetSystemPrimarySelection());
1388 ImplPaste( aSelection );
1389 Modify();
1390 }
1391}
1392
1393void Edit::Tracking( const TrackingEvent& rTEvt )
1394{
1395 if ( rTEvt.IsTrackingEnded() )
1396 {
1398 {
1399 sal_Int32 nCharPos = ImplGetCharPos( rTEvt.GetMouseEvent().GetPosPixel() );
1400 ImplSetCursorPos( nCharPos, false );
1401 mbClickedInSelection = false;
1402 }
1403 else if ( rTEvt.GetMouseEvent().IsLeft() )
1404 {
1406 }
1407 }
1408 else
1409 {
1411 {
1412 sal_Int32 nCharPos = ImplGetCharPos( rTEvt.GetMouseEvent().GetPosPixel() );
1413 ImplSetCursorPos( nCharPos, true );
1414 }
1415 }
1416}
1417
1419{
1420 bool bDone = false;
1421 sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
1422 KeyFuncType eFunc = rKEvt.GetKeyCode().GetFunction();
1423
1424 mbInternModified = false;
1425
1426 if ( eFunc != KeyFuncType::DONTKNOW )
1427 {
1428 switch ( eFunc )
1429 {
1430 case KeyFuncType::CUT:
1431 {
1432 if ( !mbReadOnly && maSelection.Len() && !mbPassword )
1433 {
1434 Cut();
1435 Modify();
1436 bDone = true;
1437 }
1438 }
1439 break;
1440
1441 case KeyFuncType::COPY:
1442 {
1443 if ( !mbPassword )
1444 {
1445 Copy();
1446 bDone = true;
1447 }
1448 }
1449 break;
1450
1451 case KeyFuncType::PASTE:
1452 {
1453 if ( !mbReadOnly )
1454 {
1455 Paste();
1456 bDone = true;
1457 }
1458 }
1459 break;
1460
1461 case KeyFuncType::UNDO:
1462 {
1463 if ( !mbReadOnly )
1464 {
1465 Undo();
1466 bDone = true;
1467 }
1468 }
1469 break;
1470
1471 default:
1472 eFunc = KeyFuncType::DONTKNOW;
1473 }
1474 }
1475
1476 if ( !bDone && rKEvt.GetKeyCode().IsMod1() && !rKEvt.GetKeyCode().IsMod2() )
1477 {
1478 if ( nCode == KEY_A )
1479 {
1480 ImplSetSelection( Selection( 0, maText.getLength() ) );
1481 bDone = true;
1482 }
1483 else if ( rKEvt.GetKeyCode().IsShift() && (nCode == KEY_S) )
1484 {
1486 {
1487 Selection aSaveSel = GetSelection(); // if someone changes the selection in Get/LoseFocus, e.g. URL bar
1488 OUString aChars = pImplFncGetSpecialChars( GetFrameWeld(), GetFont() );
1489 SetSelection( aSaveSel );
1490 if ( !aChars.isEmpty() )
1491 {
1492 ImplInsertText( aChars );
1493 Modify();
1494 }
1495 bDone = true;
1496 }
1497 }
1498 }
1499
1500 if ( eFunc == KeyFuncType::DONTKNOW && ! bDone )
1501 {
1502 switch ( nCode )
1503 {
1504 case css::awt::Key::SELECT_ALL:
1505 {
1506 ImplSetSelection( Selection( 0, maText.getLength() ) );
1507 bDone = true;
1508 }
1509 break;
1510
1511 case KEY_LEFT:
1512 case KEY_RIGHT:
1513 case KEY_HOME:
1514 case KEY_END:
1515 case css::awt::Key::MOVE_WORD_FORWARD:
1516 case css::awt::Key::SELECT_WORD_FORWARD:
1517 case css::awt::Key::MOVE_WORD_BACKWARD:
1518 case css::awt::Key::SELECT_WORD_BACKWARD:
1519 case css::awt::Key::MOVE_TO_BEGIN_OF_LINE:
1520 case css::awt::Key::MOVE_TO_END_OF_LINE:
1521 case css::awt::Key::SELECT_TO_BEGIN_OF_LINE:
1522 case css::awt::Key::SELECT_TO_END_OF_LINE:
1523 case css::awt::Key::MOVE_TO_BEGIN_OF_PARAGRAPH:
1524 case css::awt::Key::MOVE_TO_END_OF_PARAGRAPH:
1525 case css::awt::Key::SELECT_TO_BEGIN_OF_PARAGRAPH:
1526 case css::awt::Key::SELECT_TO_END_OF_PARAGRAPH:
1527 case css::awt::Key::MOVE_TO_BEGIN_OF_DOCUMENT:
1528 case css::awt::Key::MOVE_TO_END_OF_DOCUMENT:
1529 case css::awt::Key::SELECT_TO_BEGIN_OF_DOCUMENT:
1530 case css::awt::Key::SELECT_TO_END_OF_DOCUMENT:
1531 {
1532 if ( !rKEvt.GetKeyCode().IsMod2() )
1533 {
1535 uno::Reference < i18n::XBreakIterator > xBI = ImplGetBreakIterator();
1536
1537 Selection aSel( maSelection );
1538 bool bWord = rKEvt.GetKeyCode().IsMod1();
1539 bool bSelect = rKEvt.GetKeyCode().IsShift();
1540 bool bGoLeft = (nCode == KEY_LEFT);
1541 bool bGoRight = (nCode == KEY_RIGHT);
1542 bool bGoHome = (nCode == KEY_HOME);
1543 bool bGoEnd = (nCode == KEY_END);
1544
1545 switch( nCode )
1546 {
1547 case css::awt::Key::MOVE_WORD_FORWARD:
1548 bGoRight = bWord = true;break;
1549 case css::awt::Key::SELECT_WORD_FORWARD:
1550 bGoRight = bSelect = bWord = true;break;
1551 case css::awt::Key::MOVE_WORD_BACKWARD:
1552 bGoLeft = bWord = true;break;
1553 case css::awt::Key::SELECT_WORD_BACKWARD:
1554 bGoLeft = bSelect = bWord = true;break;
1555 case css::awt::Key::SELECT_TO_BEGIN_OF_LINE:
1556 case css::awt::Key::SELECT_TO_BEGIN_OF_PARAGRAPH:
1557 case css::awt::Key::SELECT_TO_BEGIN_OF_DOCUMENT:
1558 bSelect = true;
1559 [[fallthrough]];
1560 case css::awt::Key::MOVE_TO_BEGIN_OF_LINE:
1561 case css::awt::Key::MOVE_TO_BEGIN_OF_PARAGRAPH:
1562 case css::awt::Key::MOVE_TO_BEGIN_OF_DOCUMENT:
1563 bGoHome = true;break;
1564 case css::awt::Key::SELECT_TO_END_OF_LINE:
1565 case css::awt::Key::SELECT_TO_END_OF_PARAGRAPH:
1566 case css::awt::Key::SELECT_TO_END_OF_DOCUMENT:
1567 bSelect = true;
1568 [[fallthrough]];
1569 case css::awt::Key::MOVE_TO_END_OF_LINE:
1570 case css::awt::Key::MOVE_TO_END_OF_PARAGRAPH:
1571 case css::awt::Key::MOVE_TO_END_OF_DOCUMENT:
1572 bGoEnd = true;break;
1573 default:
1574 break;
1575 }
1576
1577 // range is checked in ImplSetSelection ...
1578 if ( bGoLeft && aSel.Max() )
1579 {
1580 if ( bWord )
1581 {
1582 const OUString sText = maText.toString();
1583 i18n::Boundary aBoundary = xBI->getWordBoundary( sText, aSel.Max(),
1584 GetSettings().GetLanguageTag().getLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES, true );
1585 if ( aBoundary.startPos == aSel.Max() )
1586 aBoundary = xBI->previousWord( sText, aSel.Max(),
1587 GetSettings().GetLanguageTag().getLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES );
1588 aSel.Max() = aBoundary.startPos;
1589 }
1590 else
1591 {
1592 sal_Int32 nCount = 1;
1593 aSel.Max() = xBI->previousCharacters( maText.toString(), aSel.Max(),
1594 GetSettings().GetLanguageTag().getLocale(), i18n::CharacterIteratorMode::SKIPCHARACTER, nCount, nCount );
1595 }
1596 }
1597 else if ( bGoRight && ( aSel.Max() < maText.getLength() ) )
1598 {
1599 if ( bWord )
1600 {
1601 i18n::Boundary aBoundary = xBI->nextWord( maText.toString(), aSel.Max(),
1602 GetSettings().GetLanguageTag().getLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES );
1603 aSel.Max() = aBoundary.startPos;
1604 }
1605 else
1606 {
1607 sal_Int32 nCount = 1;
1608 aSel.Max() = xBI->nextCharacters( maText.toString(), aSel.Max(),
1609 GetSettings().GetLanguageTag().getLocale(), i18n::CharacterIteratorMode::SKIPCHARACTER, nCount, nCount );
1610 }
1611 }
1612 else if ( bGoHome )
1613 {
1614 aSel.Max() = 0;
1615 }
1616 else if ( bGoEnd )
1617 {
1618 aSel.Max() = EDIT_NOLIMIT;
1619 }
1620
1621 if ( !bSelect )
1622 aSel.Min() = aSel.Max();
1623
1624 if ( aSel != GetSelection() )
1625 {
1626 ImplSetSelection( aSel );
1628 }
1629
1630 if (bGoEnd && maAutocompleteHdl.IsSet() && !rKEvt.GetKeyCode().GetModifier())
1631 {
1632 if ( (maSelection.Min() == maSelection.Max()) && (maSelection.Min() == maText.getLength()) )
1633 {
1634 maAutocompleteHdl.Call(*this);
1635 }
1636 }
1637
1638 bDone = true;
1639 }
1640 }
1641 break;
1642
1643 case css::awt::Key::DELETE_WORD_BACKWARD:
1644 case css::awt::Key::DELETE_WORD_FORWARD:
1645 case css::awt::Key::DELETE_TO_BEGIN_OF_LINE:
1646 case css::awt::Key::DELETE_TO_END_OF_LINE:
1647 case KEY_BACKSPACE:
1648 case KEY_DELETE:
1649 {
1650 if ( !mbReadOnly && !rKEvt.GetKeyCode().IsMod2() )
1651 {
1654 if ( (nMode == EDIT_DELMODE_RESTOFWORD) && rKEvt.GetKeyCode().IsShift() )
1656 switch( nCode )
1657 {
1658 case css::awt::Key::DELETE_WORD_BACKWARD:
1659 nDel = EDIT_DEL_LEFT;
1661 break;
1662 case css::awt::Key::DELETE_WORD_FORWARD:
1663 nDel = EDIT_DEL_RIGHT;
1665 break;
1666 case css::awt::Key::DELETE_TO_BEGIN_OF_LINE:
1667 nDel = EDIT_DEL_LEFT;
1669 break;
1670 case css::awt::Key::DELETE_TO_END_OF_LINE:
1671 nDel = EDIT_DEL_RIGHT;
1673 break;
1674 default: break;
1675 }
1676 sal_Int32 nOldLen = maText.getLength();
1677 ImplDelete( maSelection, nDel, nMode );
1678 if ( maText.getLength() != nOldLen )
1679 Modify();
1680 bDone = true;
1681 }
1682 }
1683 break;
1684
1685 case KEY_INSERT:
1686 {
1687 if ( !mpIMEInfos && !mbReadOnly && !rKEvt.GetKeyCode().IsMod2() )
1688 {
1690 bDone = true;
1691 }
1692 }
1693 break;
1694
1695 case KEY_RETURN:
1696 if (maActivateHdl.IsSet() && !rKEvt.GetKeyCode().GetModifier())
1697 bDone = maActivateHdl.Call(*this);
1698 break;
1699
1700 default:
1701 {
1702 if ( IsCharInput( rKEvt ) )
1703 {
1704 bDone = true; // read characters also when in ReadOnly
1705 if ( !mbReadOnly )
1706 {
1707 ImplInsertText(OUString(rKEvt.GetCharCode()), nullptr, true);
1709 {
1710 if ( (maSelection.Min() == maSelection.Max()) && (maSelection.Min() == maText.getLength()) )
1711 {
1712 maAutocompleteHdl.Call(*this);
1713 }
1714 }
1715 }
1716 }
1717 }
1718 }
1719 }
1720
1721 if ( mbInternModified )
1722 Modify();
1723
1724 return bDone;
1725}
1726
1727void Edit::KeyInput( const KeyEvent& rKEvt )
1728{
1729 if ( mpSubEdit || !ImplHandleKeyEvent( rKEvt ) )
1730 Control::KeyInput( rKEvt );
1731}
1732
1734{
1735 mxLayoutData.emplace();
1736 const_cast<Edit*>(this)->Invalidate();
1737}
1738
1739void Edit::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRectangle)
1740{
1741 if (!mpSubEdit)
1742 ImplRepaint(rRenderContext, rRectangle);
1743}
1744
1746{
1747 if ( !mpSubEdit && IsReallyVisible() )
1748 {
1750 // because of vertical centering...
1751 mnXOffset = 0;
1752 ImplAlign();
1753 Invalidate();
1755 }
1756}
1757
1758void Edit::Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlags nFlags )
1759{
1760 ApplySettings(*pDev);
1761
1762 Point aPos = pDev->LogicToPixel( rPos );
1763 Size aSize = GetSizePixel();
1764 vcl::Font aFont = GetDrawPixelFont( pDev );
1765
1766 pDev->Push();
1767 pDev->SetMapMode();
1768 pDev->SetFont( aFont );
1769 pDev->SetTextFillColor();
1770
1771 // Border/Background
1772 pDev->SetLineColor();
1773 pDev->SetFillColor();
1774 bool bBorder = (GetStyle() & WB_BORDER);
1775 bool bBackground = IsControlBackground();
1776 if ( bBorder || bBackground )
1777 {
1778 tools::Rectangle aRect( aPos, aSize );
1779 if ( bBorder )
1780 {
1781 ImplDrawFrame( pDev, aRect );
1782 }
1783 if ( bBackground )
1784 {
1786 pDev->DrawRect( aRect );
1787 }
1788 }
1789
1790 // Content
1791 if ( nFlags & SystemTextColorFlags::Mono )
1792 pDev->SetTextColor( COL_BLACK );
1793 else
1794 {
1795 if ( !IsEnabled() )
1796 {
1797 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1798 pDev->SetTextColor( rStyleSettings.GetDisableColor() );
1799 }
1800 else
1801 {
1802 pDev->SetTextColor( GetTextColor() );
1803 }
1804 }
1805
1806 const tools::Long nOnePixel = GetDrawPixel( pDev, 1 );
1807 const tools::Long nOffX = 3*nOnePixel;
1809 tools::Rectangle aTextRect( aPos, aSize );
1810
1811 if ( GetStyle() & WB_CENTER )
1812 nTextStyle |= DrawTextFlags::Center;
1813 else if ( GetStyle() & WB_RIGHT )
1814 nTextStyle |= DrawTextFlags::Right;
1815 else
1816 nTextStyle |= DrawTextFlags::Left;
1817
1818 aTextRect.AdjustLeft(nOffX );
1819 aTextRect.AdjustRight( -nOffX );
1820
1821 OUString aText = ImplGetText();
1822 tools::Long nTextHeight = pDev->GetTextHeight();
1823 tools::Long nTextWidth = pDev->GetTextWidth( aText );
1824 tools::Long nOffY = (aSize.Height() - nTextHeight) / 2;
1825
1826 // Clipping?
1827 if ( (nOffY < 0) ||
1828 ((nOffY+nTextHeight) > aSize.Height()) ||
1829 ((nOffX+nTextWidth) > aSize.Width()) )
1830 {
1831 tools::Rectangle aClip( aPos, aSize );
1832 if ( nTextHeight > aSize.Height() )
1833 aClip.AdjustBottom(nTextHeight-aSize.Height()+1 ); // prevent HP printers from 'optimizing'
1834 pDev->IntersectClipRegion( aClip );
1835 }
1836
1837 pDev->DrawText( aTextRect, aText, nTextStyle );
1838 pDev->Pop();
1839
1840 if ( GetSubEdit() )
1841 {
1842 Size aOrigSize(GetSubEdit()->GetSizePixel());
1844 GetSubEdit()->Draw(pDev, rPos, nFlags);
1845 GetSubEdit()->SetSizePixel(aOrigSize);
1846 }
1847}
1848
1850{
1851 // allow control to show focused state
1852 vcl::Window *pInvalWin = pWin;
1853 for (;;)
1854 {
1855 vcl::Window* pBorder = pInvalWin->GetWindow( GetWindowType::Border );
1856 if (pBorder == pInvalWin || !pBorder ||
1857 pInvalWin->ImplGetFrame() != pBorder->ImplGetFrame() )
1858 break;
1859 pInvalWin = pBorder;
1860 }
1861
1863}
1864
1866{
1867 if ( mpSubEdit )
1869 else if ( !mbActivePopup )
1870 {
1871 maUndoText = maText.toString();
1875 {
1876 if ( nSelOptions & SelectionOptions::ShowFirst )
1877 {
1878 maSelection.Min() = maText.getLength();
1879 maSelection.Max() = 0;
1880 }
1881 else
1882 {
1883 maSelection.Min() = 0;
1884 maSelection.Max() = maText.getLength();
1885 }
1886 if ( mbIsSubEdit )
1888 else
1890 }
1891
1893
1894 if (IsNativeWidgetEnabled() &&
1896 {
1898 }
1899 else if ( maSelection.Len() )
1900 {
1901 // paint the selection
1902 if ( !HasPaintEvent() )
1904 else
1905 Invalidate();
1906 }
1907
1909 }
1910
1912}
1913
1915{
1916 if ( !mpSubEdit )
1917 {
1918 if (IsNativeWidgetEnabled() &&
1920 {
1922 }
1923
1925 ImplInvalidateOrRepaint(); // paint the selection
1926 }
1927
1929}
1930
1932{
1933 if (rNEvt.GetType() == NotifyEventType::MOUSEMOVE)
1934 {
1935 const MouseEvent* pMouseEvt = rNEvt.GetMouseEvent();
1936 if (pMouseEvt && !pMouseEvt->GetButtons() && !pMouseEvt->IsSynthetic() && !pMouseEvt->IsModifierChanged())
1937 {
1938 // trigger redraw if mouse over state has changed
1939 if (pMouseEvt->IsLeaveWindow() || pMouseEvt->IsEnterWindow())
1940 {
1941 if (IsNativeWidgetEnabled() &&
1943 {
1945 }
1946 }
1947 }
1948 }
1949
1950 return Control::PreNotify(rNEvt);
1951}
1952
1953void Edit::Command( const CommandEvent& rCEvt )
1954{
1955 if ( rCEvt.GetCommand() == CommandEventId::ContextMenu )
1956 {
1958
1959 bool bEnableCut = true;
1960 bool bEnableCopy = true;
1961 bool bEnableDelete = true;
1962 bool bEnablePaste = true;
1963 bool bEnableSpecialChar = true;
1964
1965 if ( !maSelection.Len() )
1966 {
1967 bEnableCut = false;
1968 bEnableCopy = false;
1969 bEnableDelete = false;
1970 }
1971
1972 if ( IsReadOnly() )
1973 {
1974 bEnableCut = false;
1975 bEnablePaste = false;
1976 bEnableDelete = false;
1977 bEnableSpecialChar = false;
1978 }
1979 else
1980 {
1981 // only paste if text available in clipboard
1982 bool bData = false;
1983 uno::Reference< datatransfer::clipboard::XClipboard > xClipboard = GetClipboard();
1984
1985 if ( xClipboard.is() )
1986 {
1987 uno::Reference< datatransfer::XTransferable > xDataObj;
1988 {
1989 SolarMutexReleaser aReleaser;
1990 xDataObj = xClipboard->getContents();
1991 }
1992 if ( xDataObj.is() )
1993 {
1994 datatransfer::DataFlavor aFlavor;
1995 SotExchange::GetFormatDataFlavor( SotClipboardFormatId::STRING, aFlavor );
1996 bData = xDataObj->isDataFlavorSupported( aFlavor );
1997 }
1998 }
1999 bEnablePaste = bData;
2000 }
2001
2002 pPopup->EnableItem(pPopup->GetItemId("cut"), bEnableCut);
2003 pPopup->EnableItem(pPopup->GetItemId("copy"), bEnableCopy);
2004 pPopup->EnableItem(pPopup->GetItemId("delete"), bEnableDelete);
2005 pPopup->EnableItem(pPopup->GetItemId("paste"), bEnablePaste);
2006 pPopup->EnableItem(pPopup->GetItemId("specialchar"), bEnableSpecialChar);
2007 pPopup->EnableItem(
2008 pPopup->GetItemId("undo"),
2009 std::u16string_view(maUndoText)
2010 != std::u16string_view(maText.getStr(), maText.getLength()));
2011 bool bAllSelected = maSelection.Min() == 0 && maSelection.Max() == maText.getLength();
2012 pPopup->EnableItem(pPopup->GetItemId("selectall"), !bAllSelected);
2013 pPopup->ShowItem(pPopup->GetItemId("specialchar"), pImplFncGetSpecialChars != nullptr);
2014
2015 mbActivePopup = true;
2016 Selection aSaveSel = GetSelection(); // if someone changes selection in Get/LoseFocus, e.g. URL bar
2017 Point aPos = rCEvt.GetMousePosPixel();
2018 if ( !rCEvt.IsMouseEvent() )
2019 {
2020 // Show menu eventually centered in selection
2021 Size aSize = GetOutputSizePixel();
2022 aPos = Point( aSize.Width()/2, aSize.Height()/2 );
2023 }
2024 sal_uInt16 n = pPopup->Execute( this, aPos );
2025 SetSelection( aSaveSel );
2026 OString sCommand = pPopup->GetItemIdent(n);
2027 if (sCommand == "undo")
2028 {
2029 Undo();
2030 Modify();
2031 }
2032 else if (sCommand == "cut")
2033 {
2034 Cut();
2035 Modify();
2036 }
2037 else if (sCommand == "copy")
2038 {
2039 Copy();
2040 }
2041 else if (sCommand == "paste")
2042 {
2043 Paste();
2044 Modify();
2045 }
2046 else if (sCommand == "delete")
2047 {
2049 Modify();
2050 }
2051 else if (sCommand == "selectall")
2052 {
2053 ImplSetSelection( Selection( 0, maText.getLength() ) );
2054 }
2055 else if (sCommand == "specialchar" && pImplFncGetSpecialChars)
2056 {
2057 OUString aChars = pImplFncGetSpecialChars(GetFrameWeld(), GetFont());
2058 if (!isDisposed()) // destroyed while the insert special character dialog was still open
2059 {
2060 SetSelection( aSaveSel );
2061 if (!aChars.isEmpty())
2062 {
2063 ImplInsertText( aChars );
2064 Modify();
2065 }
2066 }
2067 }
2068 pPopup.clear();
2069 mbActivePopup = false;
2070 }
2071 else if ( rCEvt.GetCommand() == CommandEventId::StartExtTextInput )
2072 {
2074 sal_Int32 nPos = maSelection.Max();
2075 mpIMEInfos.reset(new Impl_IMEInfos( nPos, maText.copy(nPos).makeStringAndClear() ));
2076 mpIMEInfos->bWasCursorOverwrite = !IsInsertMode();
2077 }
2078 else if ( rCEvt.GetCommand() == CommandEventId::EndExtTextInput )
2079 {
2080 bool bInsertMode = !mpIMEInfos->bWasCursorOverwrite;
2081 mpIMEInfos.reset();
2082
2083 SetInsertMode(bInsertMode);
2084 Modify();
2085
2086 Invalidate();
2087
2088 // #i25161# call auto complete handler for ext text commit also
2090 {
2091 if ( (maSelection.Min() == maSelection.Max()) && (maSelection.Min() == maText.getLength()) )
2092 {
2093 maAutocompleteHdl.Call(*this);
2094 }
2095 }
2096 }
2097 else if ( rCEvt.GetCommand() == CommandEventId::ExtTextInput )
2098 {
2100
2101 maText.remove( mpIMEInfos->nPos, mpIMEInfos->nLen );
2102 maText.insert( mpIMEInfos->nPos, pData->GetText() );
2103 if ( mpIMEInfos->bWasCursorOverwrite )
2104 {
2105 const sal_Int32 nOldIMETextLen = mpIMEInfos->nLen;
2106 const sal_Int32 nNewIMETextLen = pData->GetText().getLength();
2107 if ( ( nOldIMETextLen > nNewIMETextLen ) &&
2108 ( nNewIMETextLen < mpIMEInfos->aOldTextAfterStartPos.getLength() ) )
2109 {
2110 // restore old characters
2111 const sal_Int32 nRestore = nOldIMETextLen - nNewIMETextLen;
2112 maText.insert( mpIMEInfos->nPos + nNewIMETextLen, mpIMEInfos->aOldTextAfterStartPos.subView( nNewIMETextLen, nRestore ) );
2113 }
2114 else if ( ( nOldIMETextLen < nNewIMETextLen ) &&
2115 ( nOldIMETextLen < mpIMEInfos->aOldTextAfterStartPos.getLength() ) )
2116 {
2117 const sal_Int32 nOverwrite = ( nNewIMETextLen > mpIMEInfos->aOldTextAfterStartPos.getLength()
2118 ? mpIMEInfos->aOldTextAfterStartPos.getLength() : nNewIMETextLen ) - nOldIMETextLen;
2119 maText.remove( mpIMEInfos->nPos + nNewIMETextLen, nOverwrite );
2120 }
2121 }
2122
2123 if ( pData->GetTextAttr() )
2124 {
2125 mpIMEInfos->CopyAttribs( pData->GetTextAttr(), pData->GetText().getLength() );
2126 mpIMEInfos->bCursor = pData->IsCursorVisible();
2127 }
2128 else
2129 {
2130 mpIMEInfos->DestroyAttribs();
2131 }
2132
2134 sal_Int32 nCursorPos = mpIMEInfos->nPos + pData->GetCursorPos();
2135 SetSelection( Selection( nCursorPos, nCursorPos ) );
2136 SetInsertMode( !pData->IsCursorOverwrite() );
2137
2138 if ( pData->IsCursorVisible() )
2139 GetCursor()->Show();
2140 else
2141 GetCursor()->Hide();
2142 }
2143 else if ( rCEvt.GetCommand() == CommandEventId::CursorPos )
2144 {
2145 if ( mpIMEInfos )
2146 {
2147 sal_Int32 nCursorPos = GetSelection().Max();
2148 SetCursorRect( nullptr, GetTextWidth( maText.toString(), nCursorPos, mpIMEInfos->nPos+mpIMEInfos->nLen-nCursorPos ) );
2149 }
2150 else
2151 {
2152 SetCursorRect();
2153 }
2154 }
2155 else if ( rCEvt.GetCommand() == CommandEventId::SelectionChange )
2156 {
2158 Selection aSelection( pData->GetStart(), pData->GetEnd() );
2159 SetSelection(aSelection);
2160 }
2161 else if ( rCEvt.GetCommand() == CommandEventId::QueryCharPosition )
2162 {
2163 if (mpIMEInfos && mpIMEInfos->nLen > 0)
2164 {
2165 OUString aText = ImplGetText();
2166 std::vector<sal_Int32> aDX(2*(aText.getLength()+1));
2167
2168 GetOutDev()->GetCaretPositions( aText, aDX.data(), 0, aText.getLength() );
2169
2170 tools::Long nTH = GetTextHeight();
2172
2173 std::vector<tools::Rectangle> aRects(mpIMEInfos->nLen);
2174 for ( int nIndex = 0; nIndex < mpIMEInfos->nLen; ++nIndex )
2175 {
2176 tools::Rectangle aRect( aPos, Size( 10, nTH ) );
2177 aRect.SetLeft( aDX[2*(nIndex+mpIMEInfos->nPos)] + mnXOffset + ImplGetExtraXOffset() );
2178 aRects[ nIndex ] = aRect;
2179 }
2180 SetCompositionCharRect(aRects.data(), mpIMEInfos->nLen);
2181 }
2182 }
2183 else
2184 Control::Command( rCEvt );
2185}
2186
2188{
2190 {
2191 if (!mpSubEdit)
2192 {
2193 mnXOffset = 0; // if GrabFocus before while size was still wrong
2194 ImplAlign();
2195 if (!mpSubEdit)
2196 ImplShowCursor(false);
2197 Invalidate();
2198 }
2199 }
2200 else if (nType == StateChangedType::Enable)
2201 {
2202 if (!mpSubEdit)
2203 {
2204 // change text color only
2206 }
2207 }
2209 {
2210 WinBits nStyle = GetStyle();
2212 {
2213 nStyle = ImplInitStyle(GetStyle());
2214 SetStyle(nStyle);
2215 }
2216
2217 sal_uInt16 nOldAlign = mnAlign;
2219
2220 // hack: right align until keyinput and cursor travelling works
2221 // edits are always RTL disabled
2222 // however the parent edits contain the correct setting
2224 {
2225 if (GetParent()->GetStyle() & WB_LEFT)
2229 }
2230 else if (mbIsSubEdit && !GetParent()->IsRTLEnabled())
2231 {
2234 }
2235
2236 if (nStyle & WB_RIGHT)
2238 else if (nStyle & WB_CENTER)
2240 if (!maText.isEmpty() && (mnAlign != nOldAlign))
2241 {
2242 ImplAlign();
2243 Invalidate();
2244 }
2245
2246 }
2248 {
2249 if (!mpSubEdit)
2250 {
2253 Invalidate();
2254 }
2255 }
2257 {
2258 if (!mpSubEdit)
2259 {
2261 Invalidate();
2262 }
2263 }
2264
2266}
2267
2269{
2270 if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
2272 ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
2273 (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
2274 {
2275 if ( !mpSubEdit )
2276 {
2279 Invalidate();
2280 }
2281 }
2282
2283 Control::DataChanged( rDCEvt );
2284}
2285
2287{
2288 if (!mpDDInfo->bVisCursor)
2289 {
2290 tools::Long nTextWidth = GetTextWidth( maText.toString(), 0, mpDDInfo->nDropPos );
2291 tools::Long nTextHeight = GetTextHeight();
2292 tools::Rectangle aCursorRect( Point( nTextWidth + mnXOffset, (GetOutDev()->GetOutputSize().Height()-nTextHeight)/2 ), Size( 2, nTextHeight ) );
2293 mpDDInfo->aCursor.SetWindow( this );
2294 mpDDInfo->aCursor.SetPos( aCursorRect.TopLeft() );
2295 mpDDInfo->aCursor.SetSize( aCursorRect.GetSize() );
2296 mpDDInfo->aCursor.Show();
2297 mpDDInfo->bVisCursor = true;
2298 }
2299}
2300
2302{
2303 if ( mpDDInfo && mpDDInfo->bVisCursor )
2304 {
2305 mpDDInfo->aCursor.Hide();
2306 mpDDInfo->bVisCursor = false;
2307 }
2308}
2309
2310TextFilter::TextFilter(OUString _aForbiddenChars)
2311 : sForbiddenChars(std::move(_aForbiddenChars))
2312{
2313}
2314
2316{
2317}
2318
2319OUString TextFilter::filter(const OUString &rText)
2320{
2321 OUString sTemp(rText);
2322 for (sal_Int32 i = 0; i < sForbiddenChars.getLength(); ++i)
2323 {
2324 sTemp = sTemp.replaceAll(OUStringChar(sForbiddenChars[i]), "");
2325 }
2326 return sTemp;
2327}
2328
2330{
2331 Selection aSel = GetSelection();
2332 const OUString sOrig = GetText();
2333 const OUString sNew = mpFilterText->filter(GetText());
2334 if (sOrig != sNew)
2335 {
2336 sal_Int32 nDiff = sOrig.getLength() - sNew.getLength();
2337 if (nDiff)
2338 {
2339 aSel.setMin(aSel.getMin() - nDiff);
2340 aSel.setMax(aSel.getMin());
2341 }
2342 SetText(sNew);
2343 SetSelection(aSel);
2344 }
2345}
2346
2348{
2349 if (mpFilterText)
2350 filterText();
2351
2352 if ( mbIsSubEdit )
2353 {
2354 static_cast<Edit*>(GetParent())->Modify();
2355 }
2356 else
2357 {
2359 // have been destroyed while calling into the handlers
2360 return;
2361
2362 // #i13677# notify edit listeners about caret position change
2364 // FIXME: this is currently only on macOS
2365 // check for other platforms that need similar handling
2366 if( ImplGetSVData()->maNWFData.mbNoFocusRects &&
2369 {
2371 }
2372 }
2373}
2374
2376{
2377 mcEchoChar = c;
2378 if ( mpSubEdit )
2379 mpSubEdit->SetEchoChar( c );
2380}
2381
2382void Edit::SetReadOnly( bool bReadOnly )
2383{
2384 if ( mbReadOnly != bReadOnly )
2385 {
2387 if ( mpSubEdit )
2389
2391 }
2392}
2393
2394void Edit::SetInsertMode( bool bInsert )
2395{
2396 if ( bInsert != mbInsertMode )
2397 {
2398 mbInsertMode = bInsert;
2399 if ( mpSubEdit )
2400 mpSubEdit->SetInsertMode( bInsert );
2401 else
2403 }
2404}
2405
2407{
2408 if ( mpSubEdit )
2409 return mpSubEdit->IsInsertMode();
2410 else
2411 return mbInsertMode;
2412}
2413
2414void Edit::SetMaxTextLen(sal_Int32 nMaxLen)
2415{
2416 mnMaxTextLen = nMaxLen > 0 ? nMaxLen : EDIT_NOLIMIT;
2417
2418 if ( mpSubEdit )
2420 else
2421 {
2422 if ( maText.getLength() > mnMaxTextLen )
2424 }
2425}
2426
2427void Edit::SetSelection( const Selection& rSelection )
2428{
2429 // If the selection was changed from outside, e.g. by MouseButtonDown, don't call Tracking()
2430 // directly afterwards which would change the selection again
2431 if ( IsTracking() )
2432 EndTracking();
2433 else if ( mpSubEdit && mpSubEdit->IsTracking() )
2435
2436 ImplSetSelection( rSelection );
2437}
2438
2439void Edit::ImplSetSelection( const Selection& rSelection, bool bPaint )
2440{
2441 if ( mpSubEdit )
2442 mpSubEdit->ImplSetSelection( rSelection );
2443 else
2444 {
2445 if ( rSelection != maSelection )
2446 {
2447 Selection aOld( maSelection );
2448 Selection aNew( rSelection );
2449
2450 if ( aNew.Min() > maText.getLength() )
2451 aNew.Min() = maText.getLength();
2452 if ( aNew.Max() > maText.getLength() )
2453 aNew.Max() = maText.getLength();
2454 if ( aNew.Min() < 0 )
2455 aNew.Min() = 0;
2456 if ( aNew.Max() < 0 )
2457 aNew.Max() = 0;
2458
2459 if ( aNew != maSelection )
2460 {
2462 Selection aTemp = maSelection;
2463 maSelection = aNew;
2464
2465 if ( bPaint && ( aOld.Len() || aNew.Len() || IsPaintTransparent() ) )
2468
2469 bool bCaret = false, bSelection = false;
2470 tools::Long nB=aNew.Max(), nA=aNew.Min(),oB=aTemp.Max(), oA=aTemp.Min();
2471 tools::Long nGap = nB-nA, oGap = oB-oA;
2472 if (nB != oB)
2473 bCaret = true;
2474 if (nGap != 0 || oGap != 0)
2475 bSelection = true;
2476
2477 if (bSelection)
2478 {
2479 if ( mbIsSubEdit )
2481 else
2483 }
2484
2485 if (bCaret)
2486 {
2487 if ( mbIsSubEdit )
2489 else
2491 }
2492
2493 // #103511# notify combobox listeners of deselection
2496 }
2497 }
2498 }
2499}
2500
2502{
2503 if ( mpSubEdit )
2504 return mpSubEdit->GetSelection();
2505 else
2506 return maSelection;
2507}
2508
2509void Edit::ReplaceSelected( const OUString& rStr )
2510{
2511 if ( mpSubEdit )
2512 mpSubEdit->ReplaceSelected( rStr );
2513 else
2514 ImplInsertText( rStr );
2515}
2516
2518{
2519 if ( mpSubEdit )
2521 else
2522 {
2523 if ( maSelection.Len() )
2525 }
2526}
2527
2528OUString Edit::GetSelected() const
2529{
2530 if ( mpSubEdit )
2531 return mpSubEdit->GetSelected();
2532 else
2533 {
2534 Selection aSelection( maSelection );
2535 aSelection.Normalize();
2536 return OUString( maText.getStr() + aSelection.Min(), aSelection.Len() );
2537 }
2538}
2539
2541{
2542 if ( !mbPassword )
2543 {
2544 Copy();
2545 ReplaceSelected( OUString() );
2546 }
2547}
2548
2550{
2551 if ( !mbPassword )
2552 {
2553 css::uno::Reference<css::datatransfer::clipboard::XClipboard> aClipboard(GetClipboard());
2554 ImplCopy( aClipboard );
2555 }
2556}
2557
2559{
2560 css::uno::Reference<css::datatransfer::clipboard::XClipboard> aClipboard(GetClipboard());
2561 ImplPaste( aClipboard );
2562}
2563
2565{
2566 if ( mpSubEdit )
2567 mpSubEdit->Undo();
2568 else
2569 {
2570 const OUString aText( maText.toString() );
2571 ImplDelete( Selection( 0, aText.getLength() ), EDIT_DEL_RIGHT, EDIT_DELMODE_SIMPLE );
2573 ImplSetSelection( Selection( 0, maUndoText.getLength() ) );
2574 maUndoText = aText;
2575 }
2576}
2577
2578void Edit::SetText( const OUString& rStr )
2579{
2580 if ( mpSubEdit )
2581 mpSubEdit->SetText( rStr ); // not directly ImplSetText if SetText overridden
2582 else
2583 {
2584 Selection aNewSel( 0, 0 ); // prevent scrolling
2585 ImplSetText( rStr, &aNewSel );
2586 }
2587}
2588
2589void Edit::SetText( const OUString& rStr, const Selection& rSelection )
2590{
2591 if ( mpSubEdit )
2592 mpSubEdit->SetText( rStr, rSelection );
2593 else
2594 ImplSetText( rStr, &rSelection );
2595}
2596
2597OUString Edit::GetText() const
2598{
2599 if ( mpSubEdit )
2600 return mpSubEdit->GetText();
2601 else
2602 return maText.toString();
2603}
2604
2606 ImplSetCursorPos( GetText().getLength(), false );
2607}
2608
2609void Edit::SetPlaceholderText( const OUString& rStr )
2610{
2611 if ( mpSubEdit )
2613 else if ( maPlaceholderText != rStr )
2614 {
2615 maPlaceholderText = rStr;
2616 if ( GetText().isEmpty() )
2617 Invalidate();
2618 }
2619}
2620
2622{
2623}
2624
2626{
2628 mpSubEdit.set(pEdit);
2629
2630 if (mpSubEdit)
2631 {
2632 SetPointer(PointerStyle::Arrow); // Only SubEdit has the BEAM...
2633 mpSubEdit->mbIsSubEdit = true;
2634
2637 }
2638}
2639
2640Size Edit::CalcMinimumSizeForText(const OUString &rString) const
2641{
2643
2644 Size aSize;
2645 if (mnWidthInChars != -1)
2646 {
2647 //CalcSize calls CalcWindowSize, but we will call that also in this
2648 //function, so undo the first one with CalcOutputSize
2650 }
2651 else
2652 {
2653 OUString aString;
2654 if (mnMaxWidthChars != -1 && mnMaxWidthChars < rString.getLength())
2655 aString = rString.copy(0, mnMaxWidthChars);
2656 else
2657 aString = rString;
2658
2659 aSize.setHeight( GetTextHeight() );
2660 aSize.setWidth( GetTextWidth(aString) );
2661 aSize.AdjustWidth(ImplGetExtraXOffset() * 2 );
2662
2663 // do not create edit fields in which one cannot enter anything
2664 // a default minimum width should exist for at least 3 characters
2665
2666 //CalcSize calls CalcWindowSize, but we will call that also in this
2667 //function, so undo the first one with CalcOutputSize
2668 Size aMinSize(CalcOutputSize(CalcSize(3)));
2669 if (aSize.Width() < aMinSize.Width())
2670 aSize.setWidth( aMinSize.Width() );
2671 }
2672
2673 aSize.AdjustHeight(ImplGetExtraYOffset() * 2 );
2674
2675 aSize = CalcWindowSize( aSize );
2676
2677 // ask NWF what if it has an opinion, too
2678 ImplControlValue aControlValue;
2679 tools::Rectangle aRect( Point( 0, 0 ), aSize );
2680 tools::Rectangle aContent, aBound;
2682 aControlValue, aBound, aContent))
2683 {
2684 if (aBound.GetHeight() > aSize.Height())
2685 aSize.setHeight( aBound.GetHeight() );
2686 }
2687 return aSize;
2688}
2689
2691{
2693}
2694
2696{
2697 return CalcMinimumSize();
2698}
2699
2700Size Edit::CalcSize(sal_Int32 nChars) const
2701{
2702 // width for N characters, independent from content.
2703 // works only correct for fixed fonts, average otherwise
2704 float fUnitWidth = std::max(approximate_char_width(), approximate_digit_width());
2705 Size aSz(fUnitWidth * nChars, GetTextHeight());
2706 aSz.AdjustWidth(ImplGetExtraXOffset() * 2 );
2707 aSz = CalcWindowSize( aSz );
2708 return aSz;
2709}
2710
2711sal_Int32 Edit::GetMaxVisChars() const
2712{
2713 const vcl::Window* pW = mpSubEdit ? mpSubEdit : this;
2714 sal_Int32 nOutWidth = pW->GetOutputSizePixel().Width();
2715 float fUnitWidth = std::max(approximate_char_width(), approximate_digit_width());
2716 return nOutWidth / fUnitWidth;
2717}
2718
2719namespace vcl
2720{
2722 {
2724 }
2725
2727 {
2729 }
2730}
2731
2733{
2734 if (!mpUIBuilder)
2735 mpUIBuilder.reset(new VclBuilder(nullptr, AllSettings::GetUIRootDir(), "vcl/ui/editmenu.ui", ""));
2736 VclPtr<PopupMenu> pPopup = mpUIBuilder->get_menu("menu");
2737 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
2738 if (rStyleSettings.GetHideDisabledMenuItems())
2740 else
2742 if (rStyleSettings.GetContextMenuShortcuts())
2743 {
2744 pPopup->SetAccelKey(pPopup->GetItemId("undo"), vcl::KeyCode( KeyFuncType::UNDO));
2745 pPopup->SetAccelKey(pPopup->GetItemId("cut"), vcl::KeyCode( KeyFuncType::CUT));
2746 pPopup->SetAccelKey(pPopup->GetItemId("copy"), vcl::KeyCode( KeyFuncType::COPY));
2747 pPopup->SetAccelKey(pPopup->GetItemId("paste"), vcl::KeyCode( KeyFuncType::PASTE));
2748 pPopup->SetAccelKey(pPopup->GetItemId("delete"), vcl::KeyCode( KeyFuncType::DELETE));
2749 pPopup->SetAccelKey(pPopup->GetItemId("selectall"), vcl::KeyCode( KEY_A, false, true, false, false));
2750 pPopup->SetAccelKey(pPopup->GetItemId("specialchar"), vcl::KeyCode( KEY_S, true, true, false, false));
2751 }
2752 return pPopup;
2753}
2754
2755// css::datatransfer::dnd::XDragGestureListener
2756void Edit::dragGestureRecognized( const css::datatransfer::dnd::DragGestureEvent& rDGE )
2757{
2758 SolarMutexGuard aVclGuard;
2759
2760 if ( !(!IsTracking() && maSelection.Len() &&
2761 !mbPassword && (!mpDDInfo || !mpDDInfo->bStarterOfDD)) ) // no repeated D&D
2762 return;
2763
2764 Selection aSel( maSelection );
2765 aSel.Normalize();
2766
2767 // only if mouse in the selection...
2768 Point aMousePos( rDGE.DragOriginX, rDGE.DragOriginY );
2769 sal_Int32 nCharPos = ImplGetCharPos( aMousePos );
2770 if ( (nCharPos < aSel.Min()) || (nCharPos >= aSel.Max()) )
2771 return;
2772
2773 if ( !mpDDInfo )
2774 mpDDInfo.reset(new DDInfo);
2775
2776 mpDDInfo->bStarterOfDD = true;
2777 mpDDInfo->aDndStartSel = aSel;
2778
2779 if ( IsTracking() )
2780 EndTracking(); // before D&D disable tracking
2781
2783 sal_Int8 nActions = datatransfer::dnd::DNDConstants::ACTION_COPY;
2784 if ( !IsReadOnly() )
2785 nActions |= datatransfer::dnd::DNDConstants::ACTION_MOVE;
2786 rDGE.DragSource->startDrag( rDGE, nActions, 0 /*cursor*/, 0 /*image*/, pDataObj, mxDnDListener );
2787 if ( GetCursor() )
2788 GetCursor()->Hide();
2789}
2790
2791// css::datatransfer::dnd::XDragSourceListener
2792void Edit::dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent& rDSDE )
2793{
2794 SolarMutexGuard aVclGuard;
2795
2796 if (rDSDE.DropSuccess && (rDSDE.DropAction & datatransfer::dnd::DNDConstants::ACTION_MOVE) && mpDDInfo)
2797 {
2798 Selection aSel( mpDDInfo->aDndStartSel );
2799 if ( mpDDInfo->bDroppedInMe )
2800 {
2801 if ( aSel.Max() > mpDDInfo->nDropPos )
2802 {
2803 tools::Long nLen = aSel.Len();
2804 aSel.Min() += nLen;
2805 aSel.Max() += nLen;
2806 }
2807 }
2809 Modify();
2810 }
2811
2813 mpDDInfo.reset();
2814}
2815
2816// css::datatransfer::dnd::XDropTargetListener
2817void Edit::drop( const css::datatransfer::dnd::DropTargetDropEvent& rDTDE )
2818{
2819 SolarMutexGuard aVclGuard;
2820
2821 bool bChanges = false;
2822 if ( !mbReadOnly && mpDDInfo )
2823 {
2825
2826 Selection aSel( maSelection );
2827 aSel.Normalize();
2828
2829 if ( aSel.Len() && !mpDDInfo->bStarterOfDD )
2831
2832 mpDDInfo->bDroppedInMe = true;
2833
2834 aSel.Min() = mpDDInfo->nDropPos;
2835 aSel.Max() = mpDDInfo->nDropPos;
2836 ImplSetSelection( aSel );
2837
2838 uno::Reference< datatransfer::XTransferable > xDataObj = rDTDE.Transferable;
2839 if ( xDataObj.is() )
2840 {
2841 datatransfer::DataFlavor aFlavor;
2842 SotExchange::GetFormatDataFlavor( SotClipboardFormatId::STRING, aFlavor );
2843 if ( xDataObj->isDataFlavorSupported( aFlavor ) )
2844 {
2845 uno::Any aData = xDataObj->getTransferData( aFlavor );
2846 OUString aText;
2847 aData >>= aText;
2848 ImplInsertText( aText );
2849 bChanges = true;
2850 Modify();
2851 }
2852 }
2853
2854 if ( !mpDDInfo->bStarterOfDD )
2855 {
2856 mpDDInfo.reset();
2857 }
2858 }
2859
2860 rDTDE.Context->dropComplete( bChanges );
2861}
2862
2863void Edit::dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& rDTDE )
2864{
2865 if ( !mpDDInfo )
2866 {
2867 mpDDInfo.reset(new DDInfo);
2868 }
2869 // search for string data type
2870 const Sequence< css::datatransfer::DataFlavor >& rFlavors( rDTDE.SupportedDataFlavors );
2871 mpDDInfo->bIsStringSupported = std::any_of(rFlavors.begin(), rFlavors.end(),
2872 [](const css::datatransfer::DataFlavor& rFlavor) {
2873 sal_Int32 nIndex = 0;
2874 const std::u16string_view aMimetype = o3tl::getToken(rFlavor.MimeType, 0, ';', nIndex );
2875 return aMimetype == u"text/plain";
2876 });
2877}
2878
2879void Edit::dragExit( const css::datatransfer::dnd::DropTargetEvent& )
2880{
2881 SolarMutexGuard aVclGuard;
2882
2884}
2885
2886void Edit::dragOver( const css::datatransfer::dnd::DropTargetDragEvent& rDTDE )
2887{
2888 SolarMutexGuard aVclGuard;
2889
2890 Point aMousePos( rDTDE.LocationX, rDTDE.LocationY );
2891
2892 sal_Int32 nPrevDropPos = mpDDInfo->nDropPos;
2893 mpDDInfo->nDropPos = ImplGetCharPos( aMousePos );
2894
2895 /*
2896 Size aOutSize = GetOutputSizePixel();
2897 if ( ( aMousePos.X() < 0 ) || ( aMousePos.X() > aOutSize.Width() ) )
2898 {
2899 // Scroll?
2900 // No, I will not receive events in this case...
2901 }
2902 */
2903
2904 Selection aSel( maSelection );
2905 aSel.Normalize();
2906
2907 // Don't accept drop in selection or read-only field...
2908 if ( IsReadOnly() || aSel.Contains( mpDDInfo->nDropPos ) || ! mpDDInfo->bIsStringSupported )
2909 {
2911 rDTDE.Context->rejectDrag();
2912 }
2913 else
2914 {
2915 // draw the old cursor away...
2916 if ( !mpDDInfo->bVisCursor || ( nPrevDropPos != mpDDInfo->nDropPos ) )
2917 {
2920 }
2921 rDTDE.Context->acceptDrag( rDTDE.DropAction );
2922 }
2923}
2924
2926{
2927 if (mpSubEdit)
2928 return mpSubEdit->GetSurroundingText();
2929 return maText.toString();
2930}
2931
2933{
2934 return GetSelection();
2935}
2936
2938{
2939 SetSelection(rSelection);
2941 // maybe we should update mpIMEInfos here
2942 return true;
2943}
2944
2946{
2947 return EditUIObject::create;
2948}
2949
2950
2952{
2953 Control::DumpAsPropertyTree(rJsonWriter);
2954
2955 if (!maPlaceholderText.isEmpty())
2956 rJsonWriter.put("placeholder", maPlaceholderText);
2957
2958 if (IsPassword())
2959 rJsonWriter.put("password", true);
2960}
2961
2962/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DrawTextFlags
SystemTextColorFlags
@ HasBackgroundTexture
ControlType
These types are all based on the supported variants vcl/salnativewidgets.hxx and must be kept in-sync...
static bool toBool(std::string_view rValue)
Definition: builder.cxx:92
const LanguageTag & GetLanguageTag() const
const StyleSettings & GetStyleSettings() const
static bool GetLayoutRTL()
static OUString GetUIRootDir()
Definition: dialog.cxx:557
static const AllSettings & GetSettings()
Gets the application's settings.
Definition: svapp.cxx:761
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage)
Definition: builder.cxx:215
CommandEventId GetCommand() const
const Point & GetMousePosPixel() const
const CommandSelectionChangeData * GetSelectionChangeData() const
const CommandExtTextInputData * GetExtTextInputData() const
bool IsMouseEvent() const
Definition: ctrl.hxx:82
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: ctrl.cxx:414
std::optional< vcl::ControlLayoutData > mxLayoutData
Definition: ctrl.hxx:84
SAL_DLLPRIVATE void ImplClearLayoutData() const
Definition: ctrl.cxx:327
bool ImplCallEventListenersAndHandler(VclEventId nEvent, std::function< void()> const &callHandler)
this calls both our event listeners, and a specified handler
Definition: ctrl.cxx:302
virtual void StateChanged(StateChangedType nStateChange) override
Definition: ctrl.cxx:257
virtual void Resize() override
Definition: ctrl.cxx:75
virtual void EnableRTL(bool bEnable=true) override
Definition: ctrl.cxx:66
SAL_DLLPRIVATE void ImplDrawFrame(OutputDevice *pDev, tools::Rectangle &rRect)
draws a frame around the give rectangle, onto the given device
Definition: ctrl.cxx:332
void CallEventListeners(VclEventId nEvent, void *pData=nullptr)
Definition: ctrl.cxx:294
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: ctrl.cxx:59
DataChangedEventType GetType() const
Definition: event.hxx:362
AllSettingsFlags GetFlags() const
Definition: event.hxx:363
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
Definition: edit.hxx:56
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: edit.cxx:1739
virtual void Modify()
Definition: edit.cxx:2347
SAL_DLLPRIVATE void ImplPaste(css::uno::Reference< css::datatransfer::clipboard::XClipboard > const &rxClipboard)
Definition: edit.cxx:1283
Link< Edit &, bool > maActivateHdl
Definition: edit.hxx:83
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: edit.cxx:183
sal_Int32 mnMaxTextLen
Definition: edit.hxx:69
virtual void dragDropEnd(const css::datatransfer::dnd::DragSourceDropEvent &dsde) override
Definition: edit.cxx:2792
virtual bool DeleteSurroundingText(const Selection &rSelection) override
Definition: edit.cxx:2937
static bool IsCharInput(const KeyEvent &rKEvt)
Definition: edit.cxx:355
sal_Int32 mnWidthInChars
Definition: edit.hxx:70
sal_Int32 mnMaxWidthChars
Definition: edit.hxx:71
bool mbInsertMode
Definition: edit.hxx:75
virtual void ReplaceSelected(const OUString &rStr)
Definition: edit.cxx:2509
bool mbReadOnly
Definition: edit.hxx:74
void SetWidthInChars(sal_Int32 nWidthInChars)
Definition: edit.cxx:165
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: edit.cxx:306
SAL_DLLPRIVATE void ImplAlign()
Definition: edit.cxx:1145
std::unique_ptr< DDInfo, o3tl::default_delete< DDInfo > > mpDDInfo
Definition: edit.hxx:60
SAL_DLLPRIVATE tools::Long ImplGetTextYPosition() const
Definition: edit.cxx:457
OUStringBuffer maText
Definition: edit.hxx:62
SAL_DLLPRIVATE css::uno::Reference< css::i18n::XBreakIterator > const & ImplGetBreakIterator()
Definition: edit.cxx:758
VclPtr< Edit > mpSubEdit
Definition: edit.hxx:58
bool mbActivePopup
Definition: edit.hxx:78
virtual void Copy()
Definition: edit.cxx:2549
sal_uInt16 mnAlign
Definition: edit.hxx:68
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: edit.cxx:225
void SetPlaceholderText(const OUString &rStr)
Definition: edit.cxx:2609
virtual Size CalcSize(sal_Int32 nChars) const
Definition: edit.cxx:2700
virtual void SetText(const OUString &rStr) override
Definition: edit.cxx:2578
virtual Selection GetSurroundingTextSelection() const override
Definition: edit.cxx:2932
bool mbClickedInSelection
Definition: edit.hxx:76
virtual void dragGestureRecognized(const css::datatransfer::dnd::DragGestureEvent &dge) override
Definition: edit.cxx:2756
void Undo()
Definition: edit.cxx:2564
css::uno::Reference< css::i18n::XExtendedInputSequenceChecker > mxISC
Definition: edit.hxx:87
SAL_DLLPRIVATE css::uno::Reference< css::i18n::XExtendedInputSequenceChecker > const & ImplGetInputSequenceChecker()
Definition: edit.cxx:765
SAL_DLLPRIVATE void ImplDelete(const Selection &rSelection, sal_uInt8 nDirection, sal_uInt8 nMode)
Definition: edit.cxx:677
virtual OUString GetSurroundingText() const override
Definition: edit.cxx:2925
bool mbInternModified
Definition: edit.hxx:73
virtual Size GetOptimalSize() const override
Definition: edit.cxx:2695
bool IsPassword() const
Definition: edit.hxx:244
SAL_DLLPRIVATE void ImplCopyToSelectionClipboard()
Definition: edit.cxx:1269
void setMaxWidthChars(sal_Int32 nWidth)
Definition: edit.cxx:174
std::unique_ptr< Impl_IMEInfos > mpIMEInfos
Definition: edit.hxx:61
Selection maSelection
Definition: edit.hxx:67
virtual bool PreNotify(NotifyEvent &rNEvt) override
Definition: edit.cxx:1931
SAL_DLLPRIVATE void ImplSetText(const OUString &rStr, const Selection *pNewSelection)
Definition: edit.cxx:900
SAL_DLLPRIVATE tools::Long ImplGetExtraYOffset() const
Definition: edit.cxx:415
SAL_DLLPRIVATE void ImplPaintBorder(vcl::RenderContext const &rRenderContext)
Definition: edit.cxx:1004
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: edit.cxx:2268
virtual const Selection & GetSelection() const
Definition: edit.cxx:2501
Edit(WindowType nType)
Definition: edit.cxx:152
virtual void DeleteSelected()
Definition: edit.cxx:2517
css::uno::Reference< css::i18n::XBreakIterator > mxBreakIterator
Definition: edit.hxx:86
bool mbForceControlBackground
Definition: edit.hxx:79
virtual void Cut()
Definition: edit.cxx:2540
void SetInsertMode(bool bInsert)
Definition: edit.cxx:2394
static SAL_DLLPRIVATE WinBits ImplInitStyle(WinBits nStyle)
Definition: edit.cxx:345
SAL_DLLPRIVATE void ImplRepaint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRectangle)
Definition: edit.cxx:466
virtual void SetMaxTextLen(sal_Int32 nMaxLen)
Definition: edit.cxx:2414
virtual void GetFocus() override
Definition: edit.cxx:1865
void SetCursorAtLast()
Definition: edit.cxx:2605
virtual Size CalcMinimumSize() const
Definition: edit.cxx:2690
css::uno::Reference< css::datatransfer::dnd::XDragSourceListener > mxDnDListener
Definition: edit.hxx:88
SAL_DLLPRIVATE void ImplShowCursor(bool bOnlyIfVisible=true)
Definition: edit.cxx:1065
virtual void dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent &dtdee) override
Definition: edit.cxx:2863
SAL_DLLPRIVATE void filterText()
Definition: edit.cxx:2329
virtual void DumpAsPropertyTree(tools::JsonWriter &rJsonWriter) override
Dumps itself and potentially its children to a property tree, to be written easily to JSON.
Definition: edit.cxx:2951
Edit * GetSubEdit() const
Definition: edit.hxx:217
virtual void Tracking(const TrackingEvent &rTEvt) override
Definition: edit.cxx:1393
SAL_DLLPRIVATE tools::Long ImplGetExtraXOffset() const
Definition: edit.cxx:403
virtual void SetSelection(const Selection &rSelection)
Definition: edit.cxx:2427
static SAL_DLLPRIVATE void ImplInvalidateOutermostBorder(vcl::Window *pWin)
Definition: edit.cxx:1849
SAL_DLLPRIVATE void ImplShowDDCursor()
Definition: edit.cxx:2286
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: edit.cxx:1335
OUString maPlaceholderText
Definition: edit.hxx:63
virtual void LoseFocus() override
Definition: edit.cxx:1914
bool IsInsertMode() const
Definition: edit.cxx:2406
Link< Edit &, void > maAutocompleteHdl
Definition: edit.hxx:82
SAL_DLLPRIVATE bool ImplUseNativeBorder(vcl::RenderContext const &rRenderContext, WinBits nStyle) const
Definition: edit.cxx:290
SAL_DLLPRIVATE void ImplCopy(css::uno::Reference< css::datatransfer::clipboard::XClipboard > const &rxClipboard)
Definition: edit.cxx:1278
SAL_DLLPRIVATE void ImplSetCursorPos(sal_Int32 nChar, bool bSelect)
Definition: edit.cxx:1260
bool mbPassword
Definition: edit.hxx:80
SAL_DLLPRIVATE bool ImplTruncateToMaxLen(OUString &, sal_Int32 nSelectionLen) const
Definition: edit.cxx:779
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
Definition: edit.cxx:1376
virtual void SetReadOnly(bool bReadOnly=true)
Definition: edit.cxx:2382
void SetSubEdit(Edit *pEdit)
Definition: edit.cxx:2625
SAL_DLLPRIVATE void ImplClearBackground(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRectangle, tools::Long nXStart, tools::Long nXEnd)
Definition: edit.cxx:984
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: edit.cxx:1727
virtual void dragExit(const css::datatransfer::dnd::DropTargetEvent &dte) override
Definition: edit.cxx:2879
virtual ~Edit() override
Definition: edit.cxx:220
TextFilter * mpFilterText
Definition: edit.hxx:59
static void ShowTruncationWarning(weld::Widget *pParent)
Definition: edit.cxx:772
virtual OUString GetSelected() const
Definition: edit.cxx:2528
virtual void dragOver(const css::datatransfer::dnd::DropTargetDragEvent &dtde) override
Definition: edit.cxx:2886
bool mbIsSubEdit
Definition: edit.hxx:77
SAL_DLLPRIVATE void ImplInvalidateOrRepaint()
Definition: edit.cxx:444
virtual Size CalcMinimumSizeForText(const OUString &rString) const
Definition: edit.cxx:2640
sal_Int32 GetMaxVisChars() const
Definition: edit.cxx:2711
SAL_DLLPRIVATE void ImplHideDDCursor()
Definition: edit.cxx:2301
std::unique_ptr< VclBuilder > mpUIBuilder
Definition: edit.hxx:84
virtual bool IsReadOnly() const
Definition: edit.hxx:175
virtual void SetModifyFlag()
Definition: edit.cxx:2621
SAL_DLLPRIVATE void ImplSetSelection(const Selection &rSelection, bool bPaint=true)
Definition: edit.cxx:2439
SAL_DLLPRIVATE ControlType ImplGetNativeControlType() const
Definition: edit.cxx:934
virtual void FillLayoutData() const override
Definition: edit.cxx:1733
sal_Unicode mcEchoChar
Definition: edit.hxx:72
SAL_DLLPRIVATE void ImplInsertText(const OUString &rStr, const Selection *pNewSelection=nullptr, bool bIsUserInput=false)
Definition: edit.cxx:791
virtual FactoryFunction GetUITestFactory() const override
Definition: edit.cxx:2945
virtual void Draw(OutputDevice *pDev, const Point &rPos, SystemTextColorFlags nFlags) override
Definition: edit.cxx:1758
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: edit.cxx:365
VclPtr< PopupMenu > CreatePopupMenu()
Definition: edit.cxx:2732
virtual void Command(const CommandEvent &rCEvt) override
Definition: edit.cxx:1953
SAL_DLLPRIVATE void ImplAlignAndPaint()
Definition: edit.cxx:1187
virtual void Resize() override
Definition: edit.cxx:1745
virtual void Paste()
Definition: edit.cxx:2558
OUString maUndoText
Definition: edit.hxx:65
tools::Long mnXOffset
Definition: edit.hxx:66
virtual void StateChanged(StateChangedType nType) override
Definition: edit.cxx:2187
virtual OUString GetText() const override
Definition: edit.cxx:2597
static SAL_DLLPRIVATE OUString ImplGetValidString(const OUString &rString)
Definition: edit.cxx:751
Link< Edit &, void > maModifyHdl
Definition: edit.hxx:81
SAL_DLLPRIVATE sal_Int32 ImplGetCharPos(const Point &rWindowPos) const
Definition: edit.cxx:1194
SAL_DLLPRIVATE void ImplInitEditData()
Definition: edit.cxx:262
virtual void drop(const css::datatransfer::dnd::DropTargetDropEvent &dtde) override
Definition: edit.cxx:2817
void SetEchoChar(sal_Unicode c)
Definition: edit.cxx:2375
SAL_DLLPRIVATE bool ImplHandleKeyEvent(const KeyEvent &rKEvt)
Definition: edit.cxx:1418
SAL_DLLPRIVATE OUString ImplGetText() const
Definition: edit.cxx:427
sal_Unicode GetCharCode() const
Definition: event.hxx:56
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:57
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
OString GetItemIdent(sal_uInt16 nItemId) const
Definition: menu.cxx:665
void ShowItem(sal_uInt16 nItemId, bool bVisible=true)
Definition: menu.cxx:939
void SetMenuFlags(MenuFlags nFlags)
Definition: menu.hxx:251
sal_uInt16 GetItemId(sal_uInt16 nPos) const
Definition: menu.cxx:623
void SetAccelKey(sal_uInt16 nItemId, const vcl::KeyCode &rKeyCode)
Definition: menu.cxx:760
void EnableItem(sal_uInt16 nItemId, bool bEnable=true)
Definition: menu.cxx:894
bool IsEnterWindow() const
Definition: event.hxx:138
bool IsSynthetic() const
Definition: event.hxx:142
bool IsLeaveWindow() const
Definition: event.hxx:140
sal_uInt16 GetClicks() const
Definition: event.hxx:126
sal_uInt16 GetButtons() const
Definition: event.hxx:147
const Point & GetPosPixel() const
Definition: event.hxx:123
bool IsMiddle() const
Definition: event.hxx:151
bool IsModifierChanged() const
Definition: event.hxx:144
bool IsLeft() const
Definition: event.hxx:149
bool IsShift() const
Definition: event.hxx:158
const MouseEvent * GetMouseEvent() const
Definition: event.hxx:324
NotifyEventType GetType() const
Definition: event.hxx:308
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:170
vcl::Region GetClipRegion() const
const vcl::Font & GetFont() const
Definition: outdev.hxx:529
void SetFont(const vcl::Font &rNewFont)
Definition: outdev/font.cxx:56
void DrawRect(const tools::Rectangle &rRect)
Definition: rect.cxx:50
void SetLineColor()
Definition: line.cxx:37
void SetMapMode()
Definition: map.cxx:610
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
Width of the text.
Definition: text.cxx:886
void SetTextColor(const Color &rColor)
Definition: text.cxx:716
void SetFillColor()
Definition: fill.cxx:29
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:892
const Color & GetTextColor() const
Definition: outdev.hxx:1003
void SetTextFillColor()
Definition: text.cxx:734
void GetCaretPositions(const OUString &, sal_Int32 *pCaretXArray, sal_Int32 nIndex, sal_Int32 nLen, const SalLayoutGlyphs *pGlyphs=nullptr) const
Definition: text.cxx:1062
void Erase()
Definition: wallpaper.cxx:96
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
Definition: stack.cxx:32
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
Definition: text.cxx:897
void SetBackground()
Definition: background.cxx:27
void Pop()
Definition: stack.cxx:91
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
Definition: text.cxx:797
void SetLayoutMode(vcl::text::ComplexTextLayoutFlags nTextLayoutMode)
Definition: text.cxx:60
const AllSettings & GetSettings() const
Definition: outdev.hxx:288
void IntersectClipRegion(const tools::Rectangle &rRect)
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
void SetTextLineColor()
Definition: textline.cxx:888
sal_uInt16 Execute(vcl::Window *pWindow, const Point &rPopupPos)
Definition: menu.cxx:2743
tools::Long Min() const
bool Contains(tools::Long nIs) const
tools::Long getMin() const
void setMin(tools::Long nMin)
void setMax(tools::Long nMax)
tools::Long Len() const
void Normalize()
tools::Long Max() const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
A helper class that calls Application::ReleaseSolarMutex() in its constructor and restores the mutex ...
Definition: svapp.hxx:1447
static bool GetFormatDataFlavor(SotClipboardFormatId nFormat, css::datatransfer::DataFlavor &rFlavor)
SelectionOptions GetSelectionOptions() const
const Color & GetFieldTextColor() const
bool GetContextMenuShortcuts() const
const Color & GetFieldColor() const
const vcl::Font & GetFieldFont() const
const Color & GetHighlightColor() const
const Color & GetHighlightTextColor() const
const Color & GetDisableColor() const
bool GetHideDisabledMenuItems() const
virtual OUString filter(const OUString &rText)
Definition: edit.cxx:2319
TextFilter(OUString aForbiddenChars=OUString(" "))
Definition: edit.cxx:2310
OUString sForbiddenChars
Definition: textfilter.hxx:18
virtual ~TextFilter()
Definition: edit.cxx:2315
bool IsTrackingEnded() const
Definition: event.hxx:261
const MouseEvent & GetMouseEvent() const
Definition: event.hxx:257
Creates a hierarchy of vcl::Windows (widgets) from a .ui file for dialogs, sidebar,...
Definition: builder.hxx:69
void disposeAndClear()
Definition: vclptr.hxx:200
void clear()
Definition: vclptr.hxx:190
void set(reference_type *pBody)
Definition: vclptr.hxx:148
bool isDisposed() const
void put(const char *pPropName, const OUString &rPropValue)
constexpr tools::Long GetWidth() const
constexpr void SetLeft(tools::Long v)
constexpr Point TopLeft() const
constexpr void SetRight(tools::Long v)
constexpr Size GetSize() const
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
constexpr tools::Long GetHeight() const
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
constexpr tools::Long Left() const
bool IsVisible() const
Definition: cursor.hxx:77
void Hide()
Definition: cursor.cxx:399
void SetStyle(sal_uInt16 nStyle)
Definition: cursor.cxx:381
void SetPos(const Point &rNewPos)
Definition: cursor.cxx:417
void Show()
Definition: cursor.cxx:390
void SetSize(const Size &rNewSize)
Definition: cursor.cxx:426
void SetUnderline(FontLineStyle)
Definition: font/font.cxx:266
bool IsMod1() const
Definition: keycod.hxx:56
sal_uInt16 GetCode() const
Definition: keycod.hxx:49
sal_uInt16 GetModifier() const
Definition: keycod.hxx:52
KeyFuncType GetFunction() const
Definition: keycod.cxx:72
bool IsShift() const
Definition: keycod.hxx:54
bool IsMod2() const
Definition: keycod.hxx:58
bool IsMod3() const
Definition: keycod.hxx:60
Sets up the buffer to have settings matching the window, and restores the original state in the dtor.
Definition: window.h:406
void Move(tools::Long nHorzMove, tools::Long nVertMove)
Definition: region.cxx:401
bool IsNull() const
Definition: region.hxx:99
void Intersect(const tools::Rectangle &rRegion)
Definition: region.cxx:583
bool IsEmpty() const
Definition: region.cxx:229
tools::Rectangle GetBoundRect() const
Definition: region.cxx:1219
void Union(const tools::Rectangle &rRegion)
Definition: region.cxx:507
Point OutputToScreenPixel(const Point &rPos) const
Definition: window.cxx:2810
Size CalcOutputSize(const Size &rWinSz) const
Definition: window2.cxx:569
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
Width of the text.
Definition: window3.cxx:66
void SetStyle(WinBits nStyle)
Definition: window.cxx:1966
void SetCursorRect(const tools::Rectangle *pRect=nullptr, tools::Long nExtTextInputWidth=0)
Definition: window.cxx:2116
SAL_DLLPRIVATE void ImplGrabFocus(GetFocusFlags nFlags)
Definition: mouse.cxx:195
bool IsNativeWidgetEnabled() const
Definition: window.cxx:3711
void SetInputContext(const InputContext &rInputContext)
Definition: window.cxx:2080
bool IsReallyVisible() const
Definition: window2.cxx:1138
virtual void GetFocus()
Definition: window.cxx:1845
void StartTracking(StartTrackingFlags nFlags=StartTrackingFlags::NONE)
Definition: window2.cxx:252
vcl::Window * GetParent() const
Definition: window2.cxx:1128
GetFocusFlags GetGetFocusFlags() const
Definition: window2.cxx:1219
void PaintImmediately()
Definition: paint.cxx:1268
bool IsTracking() const
Definition: window2.cxx:340
void EndTracking(TrackingEventFlags nFlags=TrackingEventFlags::NONE)
Definition: window2.cxx:293
bool IsPaintTransparent() const
Definition: window2.cxx:1068
WindowType GetType() const
Definition: window2.cxx:1005
bool SupportsDoubleBuffering() const
Can the widget derived from this Window do the double-buffering via RenderContext properly?
Definition: window.cxx:3861
float approximate_digit_width() const
Definition: window3.cxx:72
virtual void SetSizePixel(const Size &rNewSize)
Definition: window2.cxx:1293
virtual void Command(const CommandEvent &rCEvt)
Definition: window.cxx:1927
vcl::Window * GetWindow(GetWindowType nType) const
Definition: stacking.cxx:1035
void SetCursor(vcl::Cursor *pCursor)
Definition: window.cxx:3020
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
Definition: window2.cxx:1358
void GrabFocus()
Definition: window.cxx:2983
bool IsUpdateMode() const
Definition: window2.cxx:1204
bool HasFocus() const
Definition: window.cxx:2988
virtual void MouseButtonDown(const MouseEvent &rMEvt)
Definition: mouse.cxx:420
bool GetNativeControlRegion(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion) const
Query the native control's actual drawing region (including adornment)
Definition: window3.cxx:79
vcl::Cursor * GetCursor() const
Definition: window2.cxx:1234
vcl::Font GetDrawPixelFont(::OutputDevice const *pDev) const
Definition: window2.cxx:577
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
Definition: window3.cxx:65
WinBits GetStyle() const
Definition: window2.cxx:984
const AllSettings & GetSettings() const
Definition: window3.cxx:129
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1809
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: paint.cxx:1020
void SetCompositionCharRect(const tools::Rectangle *pRect, tools::Long nCompositionLength, bool bVertical=false)
Definition: window.cxx:2151
Size CalcWindowSize(const Size &rOutSz) const
Definition: window2.cxx:561
virtual bool PreNotify(NotifyEvent &rNEvt)
Definition: event.cxx:52
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
Definition: window3.cxx:74
::OutputDevice const * GetOutDev() const
Definition: window.cxx:567
const vcl::Font & GetFont() const
Definition: window3.cxx:58
SAL_DLLPRIVATE float approximate_char_width() const
Definition: window3.cxx:61
SAL_DLLPRIVATE WindowImpl * ImplGetWindowImpl() const
Definition: window.hxx:528
tools::Long GetDrawPixel(::OutputDevice const *pDev, tools::Long nPixels) const
Definition: window2.cxx:587
const Color & GetTextColor() const
Definition: window3.cxx:109
std::unique_ptr< WindowImpl > mpWindowImpl
Definition: window.hxx:484
SalFrame * ImplGetFrame() const
Definition: window2.cxx:874
virtual void DumpAsPropertyTree(tools::JsonWriter &)
Dumps itself and potentially its children to a property tree, to be written easily to JSON.
Definition: window.cxx:3365
bool IsRTLEnabled() const
Definition: window3.cxx:127
virtual Size GetSizePixel() const
Definition: window.cxx:2406
Size GetOutputSizePixel() const
Definition: window3.cxx:89
bool IsControlBackground() const
Definition: window2.cxx:1118
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:36
virtual bool set_property(const OString &rKey, const OUString &rValue)
Definition: window2.cxx:1483
virtual void LoseFocus()
Definition: window.cxx:1859
const Color & GetControlBackground() const
Definition: window2.cxx:1113
void SetPointer(PointerStyle)
Definition: mouse.cxx:486
vcl::Region GetPaintRegion() const
Definition: paint.cxx:1127
bool HasPaintEvent() const
Definition: paint.cxx:1241
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1143
weld::Window * GetFrameWeld() const
Definition: window2.cxx:879
css::uno::Reference< css::datatransfer::clipboard::XClipboard > GetClipboard()
Definition: window.cxx:3448
void SetBorderStyle(WindowBorderStyle nBorderStyle)
Definition: window.cxx:1998
void ApplyControlFont(vcl::RenderContext &rRenderContext, const vcl::Font &rDefaultFont)
Definition: window2.cxx:473
css::uno::Reference< css::datatransfer::dnd::XDropTarget > GetDropTarget()
Definition: mouse.cxx:675
void SetType(WindowType nType)
Definition: window2.cxx:999
Point ScreenToOutputPixel(const Point &rPos) const
Definition: window.cxx:2816
void ApplyControlForeground(vcl::RenderContext &rRenderContext, const Color &rDefaultColor)
Definition: window2.cxx:513
css::uno::Reference< css::datatransfer::dnd::XDragGestureRecognizer > GetDragGestureRecognizer()
Definition: mouse.cxx:761
bool IsEnabled() const
Definition: window2.cxx:1153
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:942
SAL_DLLPRIVATE void CompatStateChanged(StateChangedType nStateChange)
Definition: window.cxx:3899
static void CopyStringTo(const OUString &rContent, const css::uno::Reference< css::datatransfer::clipboard::XClipboard > &rxClipboard, const vcl::ILibreOfficeKitNotifier *pNotifier=nullptr)
copies a given string to a given clipboard
Definition: unohelp2.cxx:46
constexpr ::Color COL_RED(0x80, 0x00, 0x00)
constexpr ::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
ExtTextInputAttr
#define CURSOR_SHADOW
Definition: cursor.hxx:36
int nCount
float u
static FncGetSpecialChars pImplFncGetSpecialChars
Definition: edit.cxx:80
#define EDIT_ALIGN_LEFT
Definition: edit.cxx:82
#define EDIT_DELMODE_SIMPLE
Definition: edit.cxx:89
#define EDIT_ALIGN_CENTER
Definition: edit.cxx:83
#define EDIT_DELMODE_RESTOFCONTENT
Definition: edit.cxx:91
#define EDIT_ALIGN_RIGHT
Definition: edit.cxx:84
#define EDIT_DEL_RIGHT
Definition: edit.cxx:87
#define EDIT_DELMODE_RESTOFWORD
Definition: edit.cxx:90
#define EDIT_DEL_LEFT
Definition: edit.cxx:86
#define EDIT_NOLIMIT
Definition: edit.hxx:51
LINESTYLE_SINGLE
LINESTYLE_DOUBLE
LINESTYLE_DASHDOT
LINESTYLE_DOTTED
LINESTYLE_WAVE
LINESTYLE_BOLD
bool bReadOnly
std::function< std::unique_ptr< UIObject >(vcl::Window *)> FactoryFunction
sal_Int32 nIndex
sal_Int64 n
KeyFuncType
Definition: keycod.hxx:27
constexpr sal_uInt16 KEY_RETURN
Definition: keycodes.hxx:119
constexpr sal_uInt16 KEY_HOME
Definition: keycodes.hxx:114
constexpr sal_uInt16 KEY_LEFT
Definition: keycodes.hxx:112
constexpr sal_uInt16 KEY_S
Definition: keycodes.hxx:74
constexpr sal_uInt16 KEY_A
Definition: keycodes.hxx:56
constexpr sal_uInt16 KEY_RIGHT
Definition: keycodes.hxx:113
constexpr sal_uInt16 KEY_DELETE
Definition: keycodes.hxx:125
constexpr sal_uInt16 KEY_INSERT
Definition: keycodes.hxx:124
constexpr sal_uInt16 KEY_BACKSPACE
Definition: keycodes.hxx:122
constexpr sal_uInt16 KEY_END
Definition: keycodes.hxx:115
sal_uInt16 nPos
#define SAL_WARN_IF(condition, area, stream)
#define SAL_N_ELEMENTS(arr)
@ HideDisabledEntries
@ AlwaysShowDisabledEntries
std::unique_ptr< sal_Int32[]> pData
sal_uInt16 nCode
constexpr OUStringLiteral aData
double getLength(const B2DPolygon &rCandidate)
const LanguageTag & getLocale()
OStringBuffer & padToLength(OStringBuffer &rBuffer, sal_Int32 nLength, char cFill='\0')
int i
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
long Long
FncGetSpecialChars GetGetSpecialCharsFunction()
Definition: edit.cxx:2726
void SetGetSpecialCharsFunction(FncGetSpecialChars fn)
Definition: edit.cxx:2721
QPRO_FUNC_TYPE nType
SelectionOptions
Definition: settings.hxx:179
OUString(* FncGetSpecialChars)(weld::Widget *pWin, const vcl::Font &rFont)
Definition: edit.cxx:94
bool bIsStringSupported
Definition: edit.cxx:101
sal_Int32 nDropPos
Definition: edit.cxx:97
DDInfo()
Definition: edit.cxx:103
vcl::Cursor aCursor
Definition: edit.cxx:95
bool bStarterOfDD
Definition: edit.cxx:98
bool bDroppedInMe
Definition: edit.cxx:99
Selection aDndStartSel
Definition: edit.cxx:96
bool bVisCursor
Definition: edit.cxx:100
sal_Int32 nLen
Definition: edit.cxx:120
void CopyAttribs(const ExtTextInputAttr *pA, sal_Int32 nL)
Definition: edit.cxx:139
sal_Int32 nPos
Definition: edit.cxx:119
bool bWasCursorOverwrite
Definition: edit.cxx:122
std::unique_ptr< ExtTextInputAttr[]> pAttribs
Definition: edit.cxx:118
OUString aOldTextAfterStartPos
Definition: edit.cxx:116
Impl_IMEInfos(sal_Int32 nPos, OUString aOldTextAfterStartPos)
Definition: edit.cxx:130
bool bCursor
Definition: edit.cxx:121
void DestroyAttribs()
Definition: edit.cxx:146
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:76
OUString VclResId(TranslateId aId)
Definition: svdata.cxx:260
Reference< XClipboard > GetSystemPrimarySelection()
Definition: transfer2.cxx:493
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
signed char sal_Int8
@ EditSelectionChanged
StateChangedType
Definition: window.hxx:291
@ Update
The invalidated area is updated immediately.
@ Children
The child windows are invalidated, too.
sal_Int64 WinBits
Definition: wintypes.hxx:109
WinBits const WB_TOP
Definition: wintypes.hxx:149
WinBits const WB_CENTER
Definition: wintypes.hxx:147
WindowType
Definition: wintypes.hxx:27
WinBits const WB_NOTABSTOP
Definition: wintypes.hxx:141
WinBits const WB_GROUP
Definition: wintypes.hxx:142
WinBits const WB_RIGHT
Definition: wintypes.hxx:148
WinBits const WB_BORDER
Definition: wintypes.hxx:115
WinBits const WB_SPIN
Definition: wintypes.hxx:153
WinBits const WB_NOGROUP
Definition: wintypes.hxx:143
WinBits const WB_TABSTOP
Definition: wintypes.hxx:140
WinBits const WB_READONLY
Definition: wintypes.hxx:194
WinBits const WB_BOTTOM
Definition: wintypes.hxx:151
WinBits const WB_NOBORDER
Definition: wintypes.hxx:116
WinBits const WB_LEFT
Definition: wintypes.hxx:146
WinBits const WB_NOHIDESELECTION
Definition: wintypes.hxx:195