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 OUString &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 KernArray aDX;
477 if (nLen)
478 GetOutDev()->GetCaretPositions(aText, aDX, 0, nLen);
479
482
483 vcl::Cursor* pCursor = GetCursor();
484 bool bVisCursor = pCursor && pCursor->IsVisible();
485 if (pCursor)
486 pCursor->Hide();
487
488 ImplClearBackground(rRenderContext, rRectangle, 0, GetOutputSizePixel().Width()-1);
489
490 bool bPaintPlaceholderText = aText.isEmpty() && !maPlaceholderText.isEmpty();
491
492 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
493
494 if (!IsEnabled() || bPaintPlaceholderText)
495 rRenderContext.SetTextColor(rStyleSettings.GetDisableColor());
496
497 // Set background color of the normal text
499 {
500 // check if we need to set ControlBackground even in NWF case
502 rRenderContext.SetLineColor();
503 rRenderContext.SetFillColor(GetControlBackground());
505 rRenderContext.Pop();
506
507 rRenderContext.SetTextFillColor(GetControlBackground());
508 }
509 else if (IsPaintTransparent() || ImplUseNativeBorder(rRenderContext, GetStyle()))
510 rRenderContext.SetTextFillColor();
511 else
512 rRenderContext.SetTextFillColor(IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor());
513
514 ImplPaintBorder(rRenderContext);
515
516 bool bDrawSelection = maSelection.Len() && (HasFocus() || (GetStyle() & WB_NOHIDESELECTION) || mbActivePopup);
517
519 if (bPaintPlaceholderText)
520 {
521 rRenderContext.DrawText(aPos, maPlaceholderText);
522 }
523 else if (!bDrawSelection && !mpIMEInfos)
524 {
525 rRenderContext.DrawText(aPos, aText, 0, nLen);
526 }
527 else
528 {
529 // save graphics state
530 rRenderContext.Push();
531 // first calculate highlighted and non highlighted clip regions
532 vcl::Region aHighlightClipRegion;
533 vcl::Region aNormalClipRegion;
534 Selection aTmpSel(maSelection);
535 aTmpSel.Normalize();
536 // selection is highlighted
537 for(sal_Int32 i = 0; i < nLen; ++i)
538 {
539 tools::Rectangle aRect(aPos, Size(10, nTH));
540 aRect.SetLeft( aDX[2 * i] + mnXOffset + ImplGetExtraXOffset() );
541 aRect.SetRight( aDX[2 * i + 1] + mnXOffset + ImplGetExtraXOffset() );
542 aRect.Normalize();
543 bool bHighlight = false;
544 if (i >= aTmpSel.Min() && i < aTmpSel.Max())
545 bHighlight = true;
546
547 if (mpIMEInfos && mpIMEInfos->pAttribs &&
548 i >= mpIMEInfos->nPos && i < (mpIMEInfos->nPos+mpIMEInfos->nLen) &&
549 (mpIMEInfos->pAttribs[i - mpIMEInfos->nPos] & ExtTextInputAttr::Highlight))
550 {
551 bHighlight = true;
552 }
553
554 if (bHighlight)
555 aHighlightClipRegion.Union(aRect);
556 else
557 aNormalClipRegion.Union(aRect);
558 }
559 // draw normal text
560 Color aNormalTextColor = rRenderContext.GetTextColor();
561 rRenderContext.SetClipRegion(aNormalClipRegion);
562
563 if (IsPaintTransparent())
564 rRenderContext.SetTextFillColor();
565 else
566 {
567 // Set background color when part of the text is selected
568 if (ImplUseNativeBorder(rRenderContext, GetStyle()))
569 {
571 rRenderContext.SetTextFillColor(GetControlBackground());
572 else
573 rRenderContext.SetTextFillColor();
574 }
575 else
576 {
577 rRenderContext.SetTextFillColor(IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor());
578 }
579 }
580 rRenderContext.DrawText(aPos, aText, 0, nLen);
581
582 // draw highlighted text
583 rRenderContext.SetClipRegion(aHighlightClipRegion);
584 rRenderContext.SetTextColor(rStyleSettings.GetHighlightTextColor());
585 rRenderContext.SetTextFillColor(rStyleSettings.GetHighlightColor());
586 rRenderContext.DrawText(aPos, aText, 0, nLen);
587
588 // if IME info exists loop over portions and output different font attributes
589 if (mpIMEInfos && mpIMEInfos->pAttribs)
590 {
591 for(int n = 0; n < 2; n++)
592 {
593 vcl::Region aRegion;
594 if (n == 0)
595 {
596 rRenderContext.SetTextColor(aNormalTextColor);
597 if (IsPaintTransparent())
598 rRenderContext.SetTextFillColor();
599 else
600 rRenderContext.SetTextFillColor(IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor());
601 aRegion = aNormalClipRegion;
602 }
603 else
604 {
605 rRenderContext.SetTextColor(rStyleSettings.GetHighlightTextColor());
606 rRenderContext.SetTextFillColor(rStyleSettings.GetHighlightColor());
607 aRegion = aHighlightClipRegion;
608 }
609
610 for(int i = 0; i < mpIMEInfos->nLen; )
611 {
612 ExtTextInputAttr nAttr = mpIMEInfos->pAttribs[i];
613 vcl::Region aClip;
614 int nIndex = i;
615 while (nIndex < mpIMEInfos->nLen && mpIMEInfos->pAttribs[nIndex] == nAttr) // #112631# check nIndex before using it
616 {
617 tools::Rectangle aRect( aPos, Size( 10, nTH ) );
618 aRect.SetLeft( aDX[2 * (nIndex + mpIMEInfos->nPos)] + mnXOffset + ImplGetExtraXOffset() );
619 aRect.SetRight( aDX[2 * (nIndex + mpIMEInfos->nPos) + 1] + mnXOffset + ImplGetExtraXOffset() );
620 aRect.Normalize();
621 aClip.Union(aRect);
622 nIndex++;
623 }
624 i = nIndex;
625 aClip.Intersect(aRegion);
626 if (!aClip.IsEmpty() && nAttr != ExtTextInputAttr::NONE)
627 {
628 vcl::Font aFont = rRenderContext.GetFont();
629 if (nAttr & ExtTextInputAttr::Underline)
631 else if (nAttr & ExtTextInputAttr::DoubleUnderline)
633 else if (nAttr & ExtTextInputAttr::BoldUnderline)
635 else if (nAttr & ExtTextInputAttr::DottedUnderline)
637 else if (nAttr & ExtTextInputAttr::DashDotUnderline)
639 else if (nAttr & ExtTextInputAttr::GrayWaveline)
640 {
642 rRenderContext.SetTextLineColor(COL_LIGHTGRAY);
643 }
644 rRenderContext.SetFont(aFont);
645
646 if (nAttr & ExtTextInputAttr::RedText)
647 rRenderContext.SetTextColor(COL_RED);
648 else if (nAttr & ExtTextInputAttr::HalfToneText)
649 rRenderContext.SetTextColor(COL_LIGHTGRAY);
650
651 rRenderContext.SetClipRegion(aClip);
652 rRenderContext.DrawText(aPos, aText, 0, nLen);
653 }
654 }
655 }
656 }
657
658 // restore graphics state
659 rRenderContext.Pop();
660 }
661
662 if (bVisCursor && (!mpIMEInfos || mpIMEInfos->bCursor))
663 pCursor->Show();
664}
665
666void Edit::ImplDelete( const Selection& rSelection, sal_uInt8 nDirection, sal_uInt8 nMode )
667{
668 const sal_Int32 nTextLen = ImplGetText().getLength();
669
670 // deleting possible?
671 if ( !rSelection.Len() &&
672 (((rSelection.Min() == 0) && (nDirection == EDIT_DEL_LEFT)) ||
673 ((rSelection.Max() == nTextLen) && (nDirection == EDIT_DEL_RIGHT))) )
674 return;
675
677
678 Selection aSelection( rSelection );
679 aSelection.Normalize();
680
681 if ( !aSelection.Len() )
682 {
683 uno::Reference < i18n::XBreakIterator > xBI = ImplGetBreakIterator();
684 if ( nDirection == EDIT_DEL_LEFT )
685 {
686 if ( nMode == EDIT_DELMODE_RESTOFWORD )
687 {
688 const OUString sText = maText.toString();
689 i18n::Boundary aBoundary = xBI->getWordBoundary( sText, aSelection.Min(),
690 GetSettings().GetLanguageTag().getLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES, true );
691 auto startPos = aBoundary.startPos;
692 if ( startPos == aSelection.Min() )
693 {
694 aBoundary = xBI->previousWord( sText, aSelection.Min(),
695 GetSettings().GetLanguageTag().getLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES );
696 startPos = std::max(aBoundary.startPos, sal_Int32(0));
697 }
698 aSelection.Min() = startPos;
699 }
700 else if ( nMode == EDIT_DELMODE_RESTOFCONTENT )
701 {
702 aSelection.Min() = 0;
703 }
704 else
705 {
706 sal_Int32 nCount = 1;
707 aSelection.Min() = xBI->previousCharacters( maText.toString(), aSelection.Min(),
708 GetSettings().GetLanguageTag().getLocale(), i18n::CharacterIteratorMode::SKIPCHARACTER, nCount, nCount );
709 }
710 }
711 else
712 {
713 if ( nMode == EDIT_DELMODE_RESTOFWORD )
714 {
715 i18n::Boundary aBoundary = xBI->nextWord( maText.toString(), aSelection.Max(),
716 GetSettings().GetLanguageTag().getLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES );
717 aSelection.Max() = aBoundary.startPos;
718 }
719 else if ( nMode == EDIT_DELMODE_RESTOFCONTENT )
720 {
721 aSelection.Max() = nTextLen;
722 }
723 else
724 {
725 sal_Int32 nCount = 1;
726 aSelection.Max() = xBI->nextCharacters( maText.toString(), aSelection.Max(),
727 GetSettings().GetLanguageTag().getLocale(), i18n::CharacterIteratorMode::SKIPCHARACTER, nCount, nCount );
728 }
729 }
730 }
731
732 const auto nSelectionMin = aSelection.Min();
733 maText.remove( nSelectionMin, aSelection.Len() );
734 maSelection.Min() = nSelectionMin;
735 maSelection.Max() = nSelectionMin;
737 mbInternModified = true;
738}
739
740OUString Edit::ImplGetValidString( const OUString& rString )
741{
742 OUString aValidString = rString.replaceAll("\n", "").replaceAll("\r", "");
743 aValidString = aValidString.replace('\t', ' ');
744 return aValidString;
745}
746
747uno::Reference <i18n::XBreakIterator> const& Edit::ImplGetBreakIterator()
748{
749 if (!mxBreakIterator)
750 mxBreakIterator = i18n::BreakIterator::create(::comphelper::getProcessComponentContext());
751 return mxBreakIterator;
752}
753
754uno::Reference <i18n::XExtendedInputSequenceChecker> const& Edit::ImplGetInputSequenceChecker()
755{
756 if (!mxISC.is())
757 mxISC = i18n::InputSequenceChecker::create(::comphelper::getProcessComponentContext());
758 return mxISC;
759}
760
762{
763 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent, VclMessageType::Warning,
764 VclButtonsType::Ok, VclResId(SV_EDIT_WARNING_STR)));
765 xBox->run();
766}
767
768bool Edit::ImplTruncateToMaxLen( OUString& rStr, sal_Int32 nSelectionLen ) const
769{
770 bool bWasTruncated = false;
771 if (maText.getLength() - nSelectionLen > mnMaxTextLen - rStr.getLength())
772 {
773 sal_Int32 nErasePos = mnMaxTextLen - maText.getLength() + nSelectionLen;
774 rStr = rStr.copy( 0, nErasePos );
775 bWasTruncated = true;
776 }
777 return bWasTruncated;
778}
779
780void Edit::ImplInsertText( const OUString& rStr, const Selection* pNewSel, bool bIsUserInput )
781{
782 Selection aSelection( maSelection );
783 aSelection.Normalize();
784
785 OUString aNewText( ImplGetValidString( rStr ) );
786
787 // as below, if there's no selection, but we're in overwrite mode and not beyond
788 // the end of the existing text then that's like a selection of 1
789 auto nSelectionLen = aSelection.Len();
790 if (!nSelectionLen && !mbInsertMode && aSelection.Max() < maText.getLength())
791 nSelectionLen = 1;
792 ImplTruncateToMaxLen( aNewText, nSelectionLen );
793
795
796 if ( aSelection.Len() )
797 maText.remove( aSelection.Min(), aSelection.Len() );
798 else if (!mbInsertMode && aSelection.Max() < maText.getLength())
799 maText.remove( aSelection.Max(), 1 );
800
801 // take care of input-sequence-checking now
802 if (bIsUserInput && !rStr.isEmpty())
803 {
804 SAL_WARN_IF( rStr.getLength() != 1, "vcl", "unexpected string length. User input is expected to provide 1 char only!" );
805
806 // determine if input-sequence-checking should be applied or not
807
808 uno::Reference < i18n::XBreakIterator > xBI = ImplGetBreakIterator();
809 bool bIsInputSequenceChecking = rStr.getLength() == 1 &&
810 officecfg::Office::Common::I18N::CTL::CTLFont::get() &&
811 officecfg::Office::Common::I18N::CTL::CTLSequenceChecking::get() &&
812 aSelection.Min() > 0 && /* first char needs not to be checked */
813 xBI.is() && i18n::ScriptType::COMPLEX == xBI->getScriptType( rStr, 0 );
814
815 if (bIsInputSequenceChecking)
816 {
817 uno::Reference < i18n::XExtendedInputSequenceChecker > xISC = ImplGetInputSequenceChecker();
818 if (xISC.is())
819 {
820 sal_Unicode cChar = rStr[0];
821 sal_Int32 nTmpPos = aSelection.Min();
822 sal_Int16 nCheckMode = officecfg::Office::Common::I18N::CTL::CTLSequenceCheckingRestricted::get()?
823 i18n::InputSequenceCheckMode::STRICT : i18n::InputSequenceCheckMode::BASIC;
824
825 // the text that needs to be checked is only the one
826 // before the current cursor position
827 const OUString aOldText( maText.subView(0, nTmpPos) );
828 OUString aTmpText( aOldText );
829 if (officecfg::Office::Common::I18N::CTL::CTLSequenceCheckingTypeAndReplace::get())
830 {
831 xISC->correctInputSequence( aTmpText, nTmpPos - 1, cChar, nCheckMode );
832
833 // find position of first character that has changed
834 sal_Int32 nOldLen = aOldText.getLength();
835 sal_Int32 nTmpLen = aTmpText.getLength();
836 const sal_Unicode *pOldTxt = aOldText.getStr();
837 const sal_Unicode *pTmpTxt = aTmpText.getStr();
838 sal_Int32 nChgPos = 0;
839 while ( nChgPos < nOldLen && nChgPos < nTmpLen &&
840 pOldTxt[nChgPos] == pTmpTxt[nChgPos] )
841 ++nChgPos;
842
843 const OUString aChgText( aTmpText.copy( nChgPos ) );
844
845 // remove text from first pos to be changed to current pos
846 maText.remove( nChgPos, nTmpPos - nChgPos );
847
848 if (!aChgText.isEmpty())
849 {
850 aNewText = aChgText;
851 aSelection.Min() = nChgPos; // position for new text to be inserted
852 }
853 else
854 aNewText.clear();
855 }
856 else
857 {
858 // should the character be ignored (i.e. not get inserted) ?
859 if (!xISC->checkInputSequence( aOldText, nTmpPos - 1, cChar, nCheckMode ))
860 aNewText.clear();
861 }
862 }
863 }
864
865 // at this point now we will insert the non-empty text 'normally' some lines below...
866 }
867
868 if ( !aNewText.isEmpty() )
869 maText.insert( aSelection.Min(), aNewText );
870
871 if ( !pNewSel )
872 {
873 maSelection.Min() = aSelection.Min() + aNewText.getLength();
875 }
876 else
877 {
878 maSelection = *pNewSel;
879 if ( maSelection.Min() > maText.getLength() )
880 maSelection.Min() = maText.getLength();
881 if ( maSelection.Max() > maText.getLength() )
882 maSelection.Max() = maText.getLength();
883 }
884
886 mbInternModified = true;
887}
888
889void Edit::ImplSetText( const OUString& rText, const Selection* pNewSelection )
890{
891 // we delete text by "selecting" the old text completely then calling InsertText; this is flicker free
892 if ( ( rText.getLength() > mnMaxTextLen ) ||
893 ( std::u16string_view(rText) == std::u16string_view(maText)
894 && (!pNewSelection || (*pNewSelection == maSelection)) ) )
895 return;
896
898 maSelection.Min() = 0;
899 maSelection.Max() = maText.getLength();
900 if ( mnXOffset || HasPaintEvent() )
901 {
902 mnXOffset = 0;
903 maText = ImplGetValidString( rText );
904
905 // #i54929# recalculate mnXOffset before ImplSetSelection,
906 // else cursor ends up in wrong position
907 ImplAlign();
908
909 if ( pNewSelection )
910 ImplSetSelection( *pNewSelection, false );
911
912 if ( mnXOffset && !pNewSelection )
913 maSelection.Max() = 0;
914
915 Invalidate();
916 }
917 else
918 ImplInsertText( rText, pNewSelection );
919
921}
922
924{
926 const vcl::Window* pControl = mbIsSubEdit ? GetParent() : this;
927
928 switch (pControl->GetType())
929 {
938 nCtrl = ControlType::Combobox;
939 break;
940
942 if ( GetWindow( GetWindowType::Border ) != this )
944 else
946 break;
947
948 case WindowType::EDIT:
956 if (pControl->GetStyle() & WB_SPIN)
957 nCtrl = ControlType::Spinbox;
958 else
959 {
960 if (GetWindow(GetWindowType::Border) != this)
961 nCtrl = ControlType::Editbox;
962 else
964 }
965 break;
966
967 default:
968 nCtrl = ControlType::Editbox;
969 }
970 return nCtrl;
971}
972
973void Edit::ImplClearBackground(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRectangle, tools::Long nXStart, tools::Long nXEnd )
974{
975 /*
976 * note: at this point the cursor must be switched off already
977 */
979 aRect.SetLeft( nXStart );
980 aRect.SetRight( nXEnd );
981
982 if( !(ImplUseNativeBorder(rRenderContext, GetStyle()) || IsPaintTransparent()))
983 rRenderContext.Erase(aRect);
985 {
986 // ImplPaintBorder() is a NOP, we have a native border, and this is a sub-edit of a control.
987 // That means we have to draw the parent native widget to paint the edit area to clear our background.
989 GetParent()->Paint(rRenderContext, rRectangle);
990 }
991}
992
993void Edit::ImplPaintBorder(vcl::RenderContext const & rRenderContext)
994{
995 // this is not needed when double-buffering
997 return;
998
999 if (!(ImplUseNativeBorder(rRenderContext, GetStyle()) || IsPaintTransparent()))
1000 return;
1001
1002 // draw the inner part by painting the whole control using its border window
1004 if (pBorder == this)
1005 {
1006 // we have no border, use parent
1007 vcl::Window* pControl = mbIsSubEdit ? GetParent() : this;
1008 pBorder = pControl->GetWindow(GetWindowType::Border);
1009 if (pBorder == this)
1010 pBorder = GetParent();
1011 }
1012
1013 if (!pBorder)
1014 return;
1015
1016 // set proper clipping region to not overdraw the whole control
1017 vcl::Region aClipRgn = GetPaintRegion();
1018 if (!aClipRgn.IsNull())
1019 {
1020 // transform clipping region to border window's coordinate system
1021 if (IsRTLEnabled() != pBorder->IsRTLEnabled() && AllSettings::GetLayoutRTL())
1022 {
1023 // need to mirror in case border is not RTL but edit is (or vice versa)
1024
1025 // mirror
1026 tools::Rectangle aBounds(aClipRgn.GetBoundRect());
1027 int xNew = GetOutputSizePixel().Width() - aBounds.GetWidth() - aBounds.Left();
1028 aClipRgn.Move(xNew - aBounds.Left(), 0);
1029
1030 // move offset of border window
1031 Point aBorderOffs = pBorder->ScreenToOutputPixel(OutputToScreenPixel(Point()));
1032 aClipRgn.Move(aBorderOffs.X(), aBorderOffs.Y());
1033 }
1034 else
1035 {
1036 // normal case
1037 Point aBorderOffs = pBorder->ScreenToOutputPixel(OutputToScreenPixel(Point()));
1038 aClipRgn.Move(aBorderOffs.X(), aBorderOffs.Y());
1039 }
1040
1041 vcl::Region oldRgn(pBorder->GetOutDev()->GetClipRegion());
1042 pBorder->GetOutDev()->SetClipRegion(aClipRgn);
1043
1044 pBorder->Paint(*pBorder->GetOutDev(), tools::Rectangle());
1045
1046 pBorder->GetOutDev()->SetClipRegion(oldRgn);
1047 }
1048 else
1049 {
1050 pBorder->Paint(*pBorder->GetOutDev(), tools::Rectangle());
1051 }
1052}
1053
1054void Edit::ImplShowCursor( bool bOnlyIfVisible )
1055{
1056 if ( !IsUpdateMode() || ( bOnlyIfVisible && !IsReallyVisible() ) )
1057 return;
1058
1059 vcl::Cursor* pCursor = GetCursor();
1060 OUString aText = ImplGetText();
1061
1062 tools::Long nTextPos = 0;
1063
1064 if( !aText.isEmpty() )
1065 {
1066 KernArray aDX;
1067 GetOutDev()->GetCaretPositions(aText, aDX, 0, aText.getLength());
1068
1069 if( maSelection.Max() < aText.getLength() )
1070 nTextPos = aDX[ 2*maSelection.Max() ];
1071 else
1072 nTextPos = aDX[ 2*aText.getLength()-1 ];
1073 }
1074
1075 tools::Long nCursorWidth = 0;
1076 if ( !mbInsertMode && !maSelection.Len() && (maSelection.Max() < aText.getLength()) )
1077 nCursorWidth = GetTextWidth(aText, maSelection.Max(), 1);
1078 tools::Long nCursorPosX = nTextPos + mnXOffset + ImplGetExtraXOffset();
1079
1080 // cursor should land in visible area
1081 const Size aOutSize = GetOutputSizePixel();
1082 if ( (nCursorPosX < 0) || (nCursorPosX >= aOutSize.Width()) )
1083 {
1084 tools::Long nOldXOffset = mnXOffset;
1085
1086 if ( nCursorPosX < 0 )
1087 {
1088 mnXOffset = - nTextPos;
1089 tools::Long nMaxX = 0;
1090 mnXOffset += aOutSize.Width() / 5;
1091 if ( mnXOffset > nMaxX )
1092 mnXOffset = nMaxX;
1093 }
1094 else
1095 {
1096 mnXOffset = (aOutSize.Width()-ImplGetExtraXOffset()) - nTextPos;
1097 // Something more?
1098 if ( (aOutSize.Width()-ImplGetExtraXOffset()) < nTextPos )
1099 {
1100 tools::Long nMaxNegX = (aOutSize.Width()-ImplGetExtraXOffset()) - GetTextWidth( aText );
1101 mnXOffset -= aOutSize.Width() / 5;
1102 if ( mnXOffset < nMaxNegX ) // both negative...
1103 mnXOffset = nMaxNegX;
1104 }
1105 }
1106
1107 nCursorPosX = nTextPos + mnXOffset + ImplGetExtraXOffset();
1108 if ( nCursorPosX == aOutSize.Width() ) // then invisible...
1109 nCursorPosX--;
1110
1111 if ( mnXOffset != nOldXOffset )
1113 }
1114
1115 const tools::Long nTextHeight = GetTextHeight();
1116 const tools::Long nCursorPosY = ImplGetTextYPosition();
1117 if (pCursor)
1118 {
1119 pCursor->SetPos( Point( nCursorPosX, nCursorPosY ) );
1120 pCursor->SetSize( Size( nCursorWidth, nTextHeight ) );
1121 pCursor->Show();
1122 }
1123}
1124
1126{
1128 {
1129 // short circuit common case and avoid slow GetTextWidth() calc
1130 return;
1131 }
1132
1133 tools::Long nTextWidth = GetTextWidth( ImplGetText() );
1134 tools::Long nOutWidth = GetOutputSizePixel().Width();
1135
1136 if ( mnAlign == EDIT_ALIGN_LEFT )
1137 {
1138 if (nTextWidth < nOutWidth)
1139 mnXOffset = 0;
1140 }
1141 else if ( mnAlign == EDIT_ALIGN_RIGHT )
1142 {
1143 tools::Long nMinXOffset = nOutWidth - nTextWidth - 1 - ImplGetExtraXOffset();
1144 bool bRTL = IsRTLEnabled();
1145 if( mbIsSubEdit && GetParent() )
1146 bRTL = GetParent()->IsRTLEnabled();
1147 if( bRTL )
1148 {
1149 if( nTextWidth < nOutWidth )
1150 mnXOffset = nMinXOffset;
1151 }
1152 else
1153 {
1154 if( nTextWidth < nOutWidth )
1155 mnXOffset = nMinXOffset;
1156 else if ( mnXOffset < nMinXOffset )
1157 mnXOffset = nMinXOffset;
1158 }
1159 }
1160 else if( mnAlign == EDIT_ALIGN_CENTER )
1161 {
1162 // would be nicer with check while scrolling but then it's not centred in scrolled state
1163 mnXOffset = (nOutWidth - nTextWidth) / 2;
1164 }
1165}
1166
1168{
1169 ImplAlign();
1172}
1173
1174sal_Int32 Edit::ImplGetCharPos( const Point& rWindowPos ) const
1175{
1176 sal_Int32 nIndex = EDIT_NOLIMIT;
1177 OUString aText = ImplGetText();
1178
1179 if (aText.isEmpty())
1180 return nIndex;
1181
1182 KernArray aDX;
1183 GetOutDev()->GetCaretPositions(aText, aDX, 0, aText.getLength());
1184 tools::Long nX = rWindowPos.X() - mnXOffset - ImplGetExtraXOffset();
1185 for (sal_Int32 i = 0; i < aText.getLength(); aText.iterateCodePoints(&i))
1186 {
1187 if( (aDX[2*i] >= nX && aDX[2*i+1] <= nX) ||
1188 (aDX[2*i+1] >= nX && aDX[2*i] <= nX))
1189 {
1190 nIndex = i;
1191 if( aDX[2*i] < aDX[2*i+1] )
1192 {
1193 if( nX > (aDX[2*i]+aDX[2*i+1])/2 )
1194 aText.iterateCodePoints(&nIndex);
1195 }
1196 else
1197 {
1198 if( nX < (aDX[2*i]+aDX[2*i+1])/2 )
1199 aText.iterateCodePoints(&nIndex);
1200 }
1201 break;
1202 }
1203 }
1204 if( nIndex == EDIT_NOLIMIT )
1205 {
1206 nIndex = 0;
1207 sal_Int32 nFinalIndex = 0;
1208 tools::Long nDiff = std::abs( aDX[0]-nX );
1209 sal_Int32 i = 0;
1210 if (!aText.isEmpty())
1211 {
1212 aText.iterateCodePoints(&i); //skip the first character
1213 }
1214 while (i < aText.getLength())
1215 {
1216 tools::Long nNewDiff = std::abs( aDX[2*i]-nX );
1217
1218 if( nNewDiff < nDiff )
1219 {
1220 nIndex = i;
1221 nDiff = nNewDiff;
1222 }
1223
1224 nFinalIndex = i;
1225
1226 aText.iterateCodePoints(&i);
1227 }
1228 if (nIndex == nFinalIndex && std::abs( aDX[2*nIndex+1] - nX ) < nDiff)
1230 }
1231
1232 return nIndex;
1233}
1234
1235void Edit::ImplSetCursorPos( sal_Int32 nChar, bool bSelect )
1236{
1237 Selection aSelection( maSelection );
1238 aSelection.Max() = nChar;
1239 if ( !bSelect )
1240 aSelection.Min() = aSelection.Max();
1241 ImplSetSelection( aSelection );
1242}
1243
1245{
1246 if ( GetSelection().Len() )
1247 {
1248 css::uno::Reference<css::datatransfer::clipboard::XClipboard> aSelection(GetSystemPrimarySelection());
1249 ImplCopy( aSelection );
1250 }
1251}
1252
1253void Edit::ImplCopy( uno::Reference< datatransfer::clipboard::XClipboard > const & rxClipboard )
1254{
1256}
1257
1258void Edit::ImplPaste( uno::Reference< datatransfer::clipboard::XClipboard > const & rxClipboard )
1259{
1260 if ( !rxClipboard.is() )
1261 return;
1262
1263 uno::Reference< datatransfer::XTransferable > xDataObj;
1264
1265 try
1266 {
1267 SolarMutexReleaser aReleaser;
1268 xDataObj = rxClipboard->getContents();
1269 }
1270 catch( const css::uno::Exception& )
1271 {
1272 }
1273
1274 if ( !xDataObj.is() )
1275 return;
1276
1277 datatransfer::DataFlavor aFlavor;
1278 SotExchange::GetFormatDataFlavor( SotClipboardFormatId::STRING, aFlavor );
1279 try
1280 {
1281 uno::Any aData = xDataObj->getTransferData( aFlavor );
1282 OUString aText;
1283 aData >>= aText;
1284
1285 // tdf#127588 - extend selection to the entire field or paste the text
1286 // from the clipboard to the current position if there is no selection
1287 if (mnMaxTextLen < EDIT_NOLIMIT && maSelection.Len() == 0)
1288 {
1289 const sal_Int32 aTextLen = aText.getLength();
1290 if (aTextLen == mnMaxTextLen)
1291 {
1292 maSelection.Min() = 0;
1294 } else
1295 maSelection.Max() = std::min<sal_Int32>(maSelection.Min() + aTextLen, mnMaxTextLen);
1296 }
1297
1298 Selection aSelection(maSelection);
1299 aSelection.Normalize();
1300 if (ImplTruncateToMaxLen(aText, aSelection.Len()))
1302
1303 ReplaceSelected( aText );
1304 }
1305 catch( const css::uno::Exception& )
1306 {
1307 }
1308}
1309
1311{
1312 if ( mpSubEdit )
1313 {
1314 Control::MouseButtonDown( rMEvt );
1315 return;
1316 }
1317
1318 sal_Int32 nCharPos = ImplGetCharPos( rMEvt.GetPosPixel() );
1319 Selection aSelection( maSelection );
1320 aSelection.Normalize();
1321
1322 if ( rMEvt.GetClicks() < 4 )
1323 {
1324 mbClickedInSelection = false;
1325 if ( rMEvt.GetClicks() == 3 )
1326 {
1329
1330 }
1331 else if ( rMEvt.GetClicks() == 2 )
1332 {
1333 uno::Reference < i18n::XBreakIterator > xBI = ImplGetBreakIterator();
1334 i18n::Boundary aBoundary = xBI->getWordBoundary( maText.toString(), aSelection.Max(),
1335 GetSettings().GetLanguageTag().getLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES, true );
1336 ImplSetSelection( Selection( aBoundary.startPos, aBoundary.endPos ) );
1338 }
1339 else if ( !rMEvt.IsShift() && HasFocus() && aSelection.Contains( nCharPos ) )
1340 mbClickedInSelection = true;
1341 else if ( rMEvt.IsLeft() )
1342 ImplSetCursorPos( nCharPos, rMEvt.IsShift() );
1343
1344 if ( !mbClickedInSelection && rMEvt.IsLeft() && ( rMEvt.GetClicks() == 1 ) )
1346 }
1347
1348 GrabFocus();
1349}
1350
1352{
1353 if ( mbClickedInSelection && rMEvt.IsLeft() )
1354 {
1355 sal_Int32 nCharPos = ImplGetCharPos( rMEvt.GetPosPixel() );
1356 ImplSetCursorPos( nCharPos, false );
1357 mbClickedInSelection = false;
1358 }
1359 else if ( rMEvt.IsMiddle() && !mbReadOnly &&
1360 ( GetSettings().GetMouseSettings().GetMiddleButtonAction() == MouseMiddleButtonAction::PasteSelection ) )
1361 {
1362 css::uno::Reference<css::datatransfer::clipboard::XClipboard> aSelection(GetSystemPrimarySelection());
1363 ImplPaste( aSelection );
1364 Modify();
1365 }
1366}
1367
1368void Edit::Tracking( const TrackingEvent& rTEvt )
1369{
1370 if ( rTEvt.IsTrackingEnded() )
1371 {
1373 {
1374 sal_Int32 nCharPos = ImplGetCharPos( rTEvt.GetMouseEvent().GetPosPixel() );
1375 ImplSetCursorPos( nCharPos, false );
1376 mbClickedInSelection = false;
1377 }
1378 else if ( rTEvt.GetMouseEvent().IsLeft() )
1379 {
1381 }
1382 }
1383 else
1384 {
1386 {
1387 sal_Int32 nCharPos = ImplGetCharPos( rTEvt.GetMouseEvent().GetPosPixel() );
1388 ImplSetCursorPos( nCharPos, true );
1389 }
1390 }
1391}
1392
1394{
1395 bool bDone = false;
1396 sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
1397 KeyFuncType eFunc = rKEvt.GetKeyCode().GetFunction();
1398
1399 mbInternModified = false;
1400
1401 if ( eFunc != KeyFuncType::DONTKNOW )
1402 {
1403 switch ( eFunc )
1404 {
1405 case KeyFuncType::CUT:
1406 {
1407 if ( !mbReadOnly && maSelection.Len() && !mbPassword )
1408 {
1409 Cut();
1410 Modify();
1411 bDone = true;
1412 }
1413 }
1414 break;
1415
1416 case KeyFuncType::COPY:
1417 {
1418 if ( !mbPassword )
1419 {
1420 Copy();
1421 bDone = true;
1422 }
1423 }
1424 break;
1425
1426 case KeyFuncType::PASTE:
1427 {
1428 if ( !mbReadOnly )
1429 {
1430 Paste();
1431 bDone = true;
1432 }
1433 }
1434 break;
1435
1436 case KeyFuncType::UNDO:
1437 {
1438 if ( !mbReadOnly )
1439 {
1440 Undo();
1441 bDone = true;
1442 }
1443 }
1444 break;
1445
1446 default:
1447 eFunc = KeyFuncType::DONTKNOW;
1448 }
1449 }
1450
1451 if ( !bDone && rKEvt.GetKeyCode().IsMod1() && !rKEvt.GetKeyCode().IsMod2() )
1452 {
1453 if ( nCode == KEY_A )
1454 {
1455 ImplSetSelection( Selection( 0, maText.getLength() ) );
1456 bDone = true;
1457 }
1458 else if ( rKEvt.GetKeyCode().IsShift() && (nCode == KEY_S) )
1459 {
1461 {
1462 Selection aSaveSel = GetSelection(); // if someone changes the selection in Get/LoseFocus, e.g. URL bar
1463 OUString aChars = pImplFncGetSpecialChars( GetFrameWeld(), GetFont() );
1464 SetSelection( aSaveSel );
1465 if ( !aChars.isEmpty() )
1466 {
1467 ImplInsertText( aChars );
1468 Modify();
1469 }
1470 bDone = true;
1471 }
1472 }
1473 }
1474
1475 if ( eFunc == KeyFuncType::DONTKNOW && ! bDone )
1476 {
1477 switch ( nCode )
1478 {
1479 case css::awt::Key::SELECT_ALL:
1480 {
1481 ImplSetSelection( Selection( 0, maText.getLength() ) );
1482 bDone = true;
1483 }
1484 break;
1485
1486 case KEY_LEFT:
1487 case KEY_RIGHT:
1488 case KEY_HOME:
1489 case KEY_END:
1490 case css::awt::Key::MOVE_WORD_FORWARD:
1491 case css::awt::Key::SELECT_WORD_FORWARD:
1492 case css::awt::Key::MOVE_WORD_BACKWARD:
1493 case css::awt::Key::SELECT_WORD_BACKWARD:
1494 case css::awt::Key::MOVE_TO_BEGIN_OF_LINE:
1495 case css::awt::Key::MOVE_TO_END_OF_LINE:
1496 case css::awt::Key::SELECT_TO_BEGIN_OF_LINE:
1497 case css::awt::Key::SELECT_TO_END_OF_LINE:
1498 case css::awt::Key::MOVE_TO_BEGIN_OF_PARAGRAPH:
1499 case css::awt::Key::MOVE_TO_END_OF_PARAGRAPH:
1500 case css::awt::Key::SELECT_TO_BEGIN_OF_PARAGRAPH:
1501 case css::awt::Key::SELECT_TO_END_OF_PARAGRAPH:
1502 case css::awt::Key::MOVE_TO_BEGIN_OF_DOCUMENT:
1503 case css::awt::Key::MOVE_TO_END_OF_DOCUMENT:
1504 case css::awt::Key::SELECT_TO_BEGIN_OF_DOCUMENT:
1505 case css::awt::Key::SELECT_TO_END_OF_DOCUMENT:
1506 {
1507 if ( !rKEvt.GetKeyCode().IsMod2() )
1508 {
1510 uno::Reference < i18n::XBreakIterator > xBI = ImplGetBreakIterator();
1511
1512 Selection aSel( maSelection );
1513 bool bWord = rKEvt.GetKeyCode().IsMod1();
1514 bool bSelect = rKEvt.GetKeyCode().IsShift();
1515 bool bGoLeft = (nCode == KEY_LEFT);
1516 bool bGoRight = (nCode == KEY_RIGHT);
1517 bool bGoHome = (nCode == KEY_HOME);
1518 bool bGoEnd = (nCode == KEY_END);
1519
1520 switch( nCode )
1521 {
1522 case css::awt::Key::MOVE_WORD_FORWARD:
1523 bGoRight = bWord = true;break;
1524 case css::awt::Key::SELECT_WORD_FORWARD:
1525 bGoRight = bSelect = bWord = true;break;
1526 case css::awt::Key::MOVE_WORD_BACKWARD:
1527 bGoLeft = bWord = true;break;
1528 case css::awt::Key::SELECT_WORD_BACKWARD:
1529 bGoLeft = bSelect = bWord = true;break;
1530 case css::awt::Key::SELECT_TO_BEGIN_OF_LINE:
1531 case css::awt::Key::SELECT_TO_BEGIN_OF_PARAGRAPH:
1532 case css::awt::Key::SELECT_TO_BEGIN_OF_DOCUMENT:
1533 bSelect = true;
1534 [[fallthrough]];
1535 case css::awt::Key::MOVE_TO_BEGIN_OF_LINE:
1536 case css::awt::Key::MOVE_TO_BEGIN_OF_PARAGRAPH:
1537 case css::awt::Key::MOVE_TO_BEGIN_OF_DOCUMENT:
1538 bGoHome = true;break;
1539 case css::awt::Key::SELECT_TO_END_OF_LINE:
1540 case css::awt::Key::SELECT_TO_END_OF_PARAGRAPH:
1541 case css::awt::Key::SELECT_TO_END_OF_DOCUMENT:
1542 bSelect = true;
1543 [[fallthrough]];
1544 case css::awt::Key::MOVE_TO_END_OF_LINE:
1545 case css::awt::Key::MOVE_TO_END_OF_PARAGRAPH:
1546 case css::awt::Key::MOVE_TO_END_OF_DOCUMENT:
1547 bGoEnd = true;break;
1548 default:
1549 break;
1550 }
1551
1552 // range is checked in ImplSetSelection ...
1553 if ( bGoLeft && aSel.Max() )
1554 {
1555 if ( bWord )
1556 {
1557 const OUString sText = maText.toString();
1558 i18n::Boundary aBoundary = xBI->getWordBoundary( sText, aSel.Max(),
1559 GetSettings().GetLanguageTag().getLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES, true );
1560 if ( aBoundary.startPos == aSel.Max() )
1561 aBoundary = xBI->previousWord( sText, aSel.Max(),
1562 GetSettings().GetLanguageTag().getLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES );
1563 aSel.Max() = aBoundary.startPos;
1564 }
1565 else
1566 {
1567 sal_Int32 nCount = 1;
1568 aSel.Max() = xBI->previousCharacters( maText.toString(), aSel.Max(),
1569 GetSettings().GetLanguageTag().getLocale(), i18n::CharacterIteratorMode::SKIPCHARACTER, nCount, nCount );
1570 }
1571 }
1572 else if ( bGoRight && ( aSel.Max() < maText.getLength() ) )
1573 {
1574 if ( bWord )
1575 {
1576 i18n::Boundary aBoundary = xBI->nextWord( maText.toString(), aSel.Max(),
1577 GetSettings().GetLanguageTag().getLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES );
1578 aSel.Max() = aBoundary.startPos;
1579 }
1580 else
1581 {
1582 sal_Int32 nCount = 1;
1583 aSel.Max() = xBI->nextCharacters( maText.toString(), aSel.Max(),
1584 GetSettings().GetLanguageTag().getLocale(), i18n::CharacterIteratorMode::SKIPCHARACTER, nCount, nCount );
1585 }
1586 }
1587 else if ( bGoHome )
1588 {
1589 aSel.Max() = 0;
1590 }
1591 else if ( bGoEnd )
1592 {
1593 aSel.Max() = EDIT_NOLIMIT;
1594 }
1595
1596 if ( !bSelect )
1597 aSel.Min() = aSel.Max();
1598
1599 if ( aSel != GetSelection() )
1600 {
1601 ImplSetSelection( aSel );
1603 }
1604
1605 if (bGoEnd && maAutocompleteHdl.IsSet() && !rKEvt.GetKeyCode().GetModifier())
1606 {
1607 if ( (maSelection.Min() == maSelection.Max()) && (maSelection.Min() == maText.getLength()) )
1608 {
1609 maAutocompleteHdl.Call(*this);
1610 }
1611 }
1612
1613 bDone = true;
1614 }
1615 }
1616 break;
1617
1618 case css::awt::Key::DELETE_WORD_BACKWARD:
1619 case css::awt::Key::DELETE_WORD_FORWARD:
1620 case css::awt::Key::DELETE_TO_BEGIN_OF_LINE:
1621 case css::awt::Key::DELETE_TO_END_OF_LINE:
1622 case KEY_BACKSPACE:
1623 case KEY_DELETE:
1624 {
1625 if ( !mbReadOnly && !rKEvt.GetKeyCode().IsMod2() )
1626 {
1627 sal_uInt8 nDel = (nCode == KEY_DELETE) ? EDIT_DEL_RIGHT : EDIT_DEL_LEFT;
1629 if ( (nMode == EDIT_DELMODE_RESTOFWORD) && rKEvt.GetKeyCode().IsShift() )
1631 switch( nCode )
1632 {
1633 case css::awt::Key::DELETE_WORD_BACKWARD:
1634 nDel = EDIT_DEL_LEFT;
1636 break;
1637 case css::awt::Key::DELETE_WORD_FORWARD:
1638 nDel = EDIT_DEL_RIGHT;
1640 break;
1641 case css::awt::Key::DELETE_TO_BEGIN_OF_LINE:
1642 nDel = EDIT_DEL_LEFT;
1644 break;
1645 case css::awt::Key::DELETE_TO_END_OF_LINE:
1646 nDel = EDIT_DEL_RIGHT;
1648 break;
1649 default: break;
1650 }
1651 sal_Int32 nOldLen = maText.getLength();
1652 ImplDelete( maSelection, nDel, nMode );
1653 if ( maText.getLength() != nOldLen )
1654 Modify();
1655 bDone = true;
1656 }
1657 }
1658 break;
1659
1660 case KEY_INSERT:
1661 {
1662 if ( !mpIMEInfos && !mbReadOnly && !rKEvt.GetKeyCode().IsMod2() )
1663 {
1665 bDone = true;
1666 }
1667 }
1668 break;
1669
1670 case KEY_RETURN:
1671 if (maActivateHdl.IsSet() && !rKEvt.GetKeyCode().GetModifier())
1672 bDone = maActivateHdl.Call(*this);
1673 break;
1674
1675 default:
1676 {
1677 if ( IsCharInput( rKEvt ) )
1678 {
1679 bDone = true; // read characters also when in ReadOnly
1680 if ( !mbReadOnly )
1681 {
1682 ImplInsertText(OUString(rKEvt.GetCharCode()), nullptr, true);
1684 {
1685 if ( (maSelection.Min() == maSelection.Max()) && (maSelection.Min() == maText.getLength()) )
1686 {
1687 maAutocompleteHdl.Call(*this);
1688 }
1689 }
1690 }
1691 }
1692 }
1693 }
1694 }
1695
1696 if ( mbInternModified )
1697 Modify();
1698
1699 return bDone;
1700}
1701
1702void Edit::KeyInput( const KeyEvent& rKEvt )
1703{
1704 if ( mpSubEdit || !ImplHandleKeyEvent( rKEvt ) )
1705 Control::KeyInput( rKEvt );
1706}
1707
1709{
1710 mxLayoutData.emplace();
1711 const_cast<Edit*>(this)->Invalidate();
1712}
1713
1714void Edit::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRectangle)
1715{
1716 if (!mpSubEdit)
1717 ImplRepaint(rRenderContext, rRectangle);
1718}
1719
1721{
1722 if ( !mpSubEdit && IsReallyVisible() )
1723 {
1725 // because of vertical centering...
1726 mnXOffset = 0;
1727 ImplAlign();
1728 Invalidate();
1730 }
1731}
1732
1733void Edit::Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlags nFlags )
1734{
1735 ApplySettings(*pDev);
1736
1737 Point aPos = pDev->LogicToPixel( rPos );
1738 Size aSize = GetSizePixel();
1739 vcl::Font aFont = GetDrawPixelFont( pDev );
1740
1741 pDev->Push();
1742 pDev->SetMapMode();
1743 pDev->SetFont( aFont );
1744 pDev->SetTextFillColor();
1745
1746 // Border/Background
1747 pDev->SetLineColor();
1748 pDev->SetFillColor();
1749 bool bBorder = (GetStyle() & WB_BORDER);
1750 bool bBackground = IsControlBackground();
1751 if ( bBorder || bBackground )
1752 {
1753 tools::Rectangle aRect( aPos, aSize );
1754 if ( bBorder )
1755 {
1756 ImplDrawFrame( pDev, aRect );
1757 }
1758 if ( bBackground )
1759 {
1761 pDev->DrawRect( aRect );
1762 }
1763 }
1764
1765 // Content
1766 if ( nFlags & SystemTextColorFlags::Mono )
1767 pDev->SetTextColor( COL_BLACK );
1768 else
1769 {
1770 if ( !IsEnabled() )
1771 {
1772 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1773 pDev->SetTextColor( rStyleSettings.GetDisableColor() );
1774 }
1775 else
1776 {
1777 pDev->SetTextColor( GetTextColor() );
1778 }
1779 }
1780
1781 const tools::Long nOnePixel = GetDrawPixel( pDev, 1 );
1782 const tools::Long nOffX = 3*nOnePixel;
1784 tools::Rectangle aTextRect( aPos, aSize );
1785
1786 if ( GetStyle() & WB_CENTER )
1787 nTextStyle |= DrawTextFlags::Center;
1788 else if ( GetStyle() & WB_RIGHT )
1789 nTextStyle |= DrawTextFlags::Right;
1790 else
1791 nTextStyle |= DrawTextFlags::Left;
1792
1793 aTextRect.AdjustLeft(nOffX );
1794 aTextRect.AdjustRight( -nOffX );
1795
1796 OUString aText = ImplGetText();
1797 tools::Long nTextHeight = pDev->GetTextHeight();
1798 tools::Long nTextWidth = pDev->GetTextWidth( aText );
1799 tools::Long nOffY = (aSize.Height() - nTextHeight) / 2;
1800
1801 // Clipping?
1802 if ( (nOffY < 0) ||
1803 ((nOffY+nTextHeight) > aSize.Height()) ||
1804 ((nOffX+nTextWidth) > aSize.Width()) )
1805 {
1806 tools::Rectangle aClip( aPos, aSize );
1807 if ( nTextHeight > aSize.Height() )
1808 aClip.AdjustBottom(nTextHeight-aSize.Height()+1 ); // prevent HP printers from 'optimizing'
1809 pDev->IntersectClipRegion( aClip );
1810 }
1811
1812 pDev->DrawText( aTextRect, aText, nTextStyle );
1813 pDev->Pop();
1814
1815 if ( GetSubEdit() )
1816 {
1817 Size aOrigSize(GetSubEdit()->GetSizePixel());
1819 GetSubEdit()->Draw(pDev, rPos, nFlags);
1820 GetSubEdit()->SetSizePixel(aOrigSize);
1821 }
1822}
1823
1825{
1826 // allow control to show focused state
1827 vcl::Window *pInvalWin = pWin;
1828 for (;;)
1829 {
1830 vcl::Window* pBorder = pInvalWin->GetWindow( GetWindowType::Border );
1831 if (pBorder == pInvalWin || !pBorder ||
1832 pInvalWin->ImplGetFrame() != pBorder->ImplGetFrame() )
1833 break;
1834 pInvalWin = pBorder;
1835 }
1836
1838}
1839
1841{
1842 if ( mpSubEdit )
1844 else if ( !mbActivePopup )
1845 {
1846 maUndoText = maText.toString();
1850 {
1851 if ( nSelOptions & SelectionOptions::ShowFirst )
1852 {
1853 maSelection.Min() = maText.getLength();
1854 maSelection.Max() = 0;
1855 }
1856 else
1857 {
1858 maSelection.Min() = 0;
1859 maSelection.Max() = maText.getLength();
1860 }
1861 if ( mbIsSubEdit )
1863 else
1865 }
1866
1868
1869 if (IsNativeWidgetEnabled() &&
1871 {
1873 }
1874 else if ( maSelection.Len() )
1875 {
1876 // paint the selection
1877 if ( !HasPaintEvent() )
1879 else
1880 Invalidate();
1881 }
1882
1884 }
1885
1887}
1888
1890{
1891 if ( !mpSubEdit )
1892 {
1893 if (IsNativeWidgetEnabled() &&
1895 {
1897 }
1898
1900 ImplInvalidateOrRepaint(); // paint the selection
1901 }
1902
1904}
1905
1907{
1908 if (rNEvt.GetType() == NotifyEventType::MOUSEMOVE)
1909 {
1910 const MouseEvent* pMouseEvt = rNEvt.GetMouseEvent();
1911 if (pMouseEvt && !pMouseEvt->GetButtons() && !pMouseEvt->IsSynthetic() && !pMouseEvt->IsModifierChanged())
1912 {
1913 // trigger redraw if mouse over state has changed
1914 if (pMouseEvt->IsLeaveWindow() || pMouseEvt->IsEnterWindow())
1915 {
1916 if (IsNativeWidgetEnabled() &&
1918 {
1920 }
1921 }
1922 }
1923 }
1924
1925 return Control::PreNotify(rNEvt);
1926}
1927
1928void Edit::Command( const CommandEvent& rCEvt )
1929{
1930 if ( rCEvt.GetCommand() == CommandEventId::ContextMenu )
1931 {
1933
1934 bool bEnableCut = true;
1935 bool bEnableCopy = true;
1936 bool bEnableDelete = true;
1937 bool bEnablePaste = true;
1938 bool bEnableSpecialChar = true;
1939
1940 if ( !maSelection.Len() )
1941 {
1942 bEnableCut = false;
1943 bEnableCopy = false;
1944 bEnableDelete = false;
1945 }
1946
1947 if ( IsReadOnly() )
1948 {
1949 bEnableCut = false;
1950 bEnablePaste = false;
1951 bEnableDelete = false;
1952 bEnableSpecialChar = false;
1953 }
1954 else
1955 {
1956 // only paste if text available in clipboard
1957 bool bData = false;
1958 uno::Reference< datatransfer::clipboard::XClipboard > xClipboard = GetClipboard();
1959
1960 if ( xClipboard.is() )
1961 {
1962 uno::Reference< datatransfer::XTransferable > xDataObj;
1963 {
1964 SolarMutexReleaser aReleaser;
1965 xDataObj = xClipboard->getContents();
1966 }
1967 if ( xDataObj.is() )
1968 {
1969 datatransfer::DataFlavor aFlavor;
1970 SotExchange::GetFormatDataFlavor( SotClipboardFormatId::STRING, aFlavor );
1971 bData = xDataObj->isDataFlavorSupported( aFlavor );
1972 }
1973 }
1974 bEnablePaste = bData;
1975 }
1976
1977 pPopup->EnableItem(pPopup->GetItemId(u"cut"), bEnableCut);
1978 pPopup->EnableItem(pPopup->GetItemId(u"copy"), bEnableCopy);
1979 pPopup->EnableItem(pPopup->GetItemId(u"delete"), bEnableDelete);
1980 pPopup->EnableItem(pPopup->GetItemId(u"paste"), bEnablePaste);
1981 pPopup->EnableItem(pPopup->GetItemId(u"specialchar"), bEnableSpecialChar);
1982 pPopup->EnableItem(
1983 pPopup->GetItemId(u"undo"),
1984 std::u16string_view(maUndoText) != std::u16string_view(maText));
1985 bool bAllSelected = maSelection.Min() == 0 && maSelection.Max() == maText.getLength();
1986 pPopup->EnableItem(pPopup->GetItemId(u"selectall"), !bAllSelected);
1987 pPopup->ShowItem(pPopup->GetItemId(u"specialchar"), pImplFncGetSpecialChars != nullptr);
1988
1989 mbActivePopup = true;
1990 Selection aSaveSel = GetSelection(); // if someone changes selection in Get/LoseFocus, e.g. URL bar
1991 Point aPos = rCEvt.GetMousePosPixel();
1992 if ( !rCEvt.IsMouseEvent() )
1993 {
1994 // Show menu eventually centered in selection
1995 Size aSize = GetOutputSizePixel();
1996 aPos = Point( aSize.Width()/2, aSize.Height()/2 );
1997 }
1998 sal_uInt16 n = pPopup->Execute( this, aPos );
1999 SetSelection( aSaveSel );
2000 OUString sCommand = pPopup->GetItemIdent(n);
2001 if (sCommand == "undo")
2002 {
2003 Undo();
2004 Modify();
2005 }
2006 else if (sCommand == "cut")
2007 {
2008 Cut();
2009 Modify();
2010 }
2011 else if (sCommand == "copy")
2012 {
2013 Copy();
2014 }
2015 else if (sCommand == "paste")
2016 {
2017 Paste();
2018 Modify();
2019 }
2020 else if (sCommand == "delete")
2021 {
2023 Modify();
2024 }
2025 else if (sCommand == "selectall")
2026 {
2027 ImplSetSelection( Selection( 0, maText.getLength() ) );
2028 }
2029 else if (sCommand == "specialchar" && pImplFncGetSpecialChars)
2030 {
2031 OUString aChars = pImplFncGetSpecialChars(GetFrameWeld(), GetFont());
2032 if (!isDisposed()) // destroyed while the insert special character dialog was still open
2033 {
2034 SetSelection( aSaveSel );
2035 if (!aChars.isEmpty())
2036 {
2037 ImplInsertText( aChars );
2038 Modify();
2039 }
2040 }
2041 }
2042 pPopup.clear();
2043 mbActivePopup = false;
2044 }
2045 else if ( rCEvt.GetCommand() == CommandEventId::StartExtTextInput )
2046 {
2048 sal_Int32 nPos = maSelection.Max();
2049 mpIMEInfos.reset(new Impl_IMEInfos( nPos, maText.copy(nPos).makeStringAndClear() ));
2050 mpIMEInfos->bWasCursorOverwrite = !IsInsertMode();
2051 }
2052 else if ( rCEvt.GetCommand() == CommandEventId::EndExtTextInput )
2053 {
2054 bool bInsertMode = !mpIMEInfos->bWasCursorOverwrite;
2055 mpIMEInfos.reset();
2056
2057 SetInsertMode(bInsertMode);
2058 Modify();
2059
2060 Invalidate();
2061
2062 // #i25161# call auto complete handler for ext text commit also
2064 {
2065 if ( (maSelection.Min() == maSelection.Max()) && (maSelection.Min() == maText.getLength()) )
2066 {
2067 maAutocompleteHdl.Call(*this);
2068 }
2069 }
2070 }
2071 else if ( rCEvt.GetCommand() == CommandEventId::ExtTextInput )
2072 {
2074
2075 maText.remove( mpIMEInfos->nPos, mpIMEInfos->nLen );
2076 maText.insert( mpIMEInfos->nPos, pData->GetText() );
2077 if ( mpIMEInfos->bWasCursorOverwrite )
2078 {
2079 const sal_Int32 nOldIMETextLen = mpIMEInfos->nLen;
2080 const sal_Int32 nNewIMETextLen = pData->GetText().getLength();
2081 if ( ( nOldIMETextLen > nNewIMETextLen ) &&
2082 ( nNewIMETextLen < mpIMEInfos->aOldTextAfterStartPos.getLength() ) )
2083 {
2084 // restore old characters
2085 const sal_Int32 nRestore = nOldIMETextLen - nNewIMETextLen;
2086 maText.insert( mpIMEInfos->nPos + nNewIMETextLen, mpIMEInfos->aOldTextAfterStartPos.subView( nNewIMETextLen, nRestore ) );
2087 }
2088 else if ( ( nOldIMETextLen < nNewIMETextLen ) &&
2089 ( nOldIMETextLen < mpIMEInfos->aOldTextAfterStartPos.getLength() ) )
2090 {
2091 const sal_Int32 nOverwrite = ( nNewIMETextLen > mpIMEInfos->aOldTextAfterStartPos.getLength()
2092 ? mpIMEInfos->aOldTextAfterStartPos.getLength() : nNewIMETextLen ) - nOldIMETextLen;
2093 maText.remove( mpIMEInfos->nPos + nNewIMETextLen, nOverwrite );
2094 }
2095 }
2096
2097 if ( pData->GetTextAttr() )
2098 {
2099 mpIMEInfos->CopyAttribs( pData->GetTextAttr(), pData->GetText().getLength() );
2100 mpIMEInfos->bCursor = pData->IsCursorVisible();
2101 }
2102 else
2103 {
2104 mpIMEInfos->DestroyAttribs();
2105 }
2106
2108 sal_Int32 nCursorPos = mpIMEInfos->nPos + pData->GetCursorPos();
2109 SetSelection( Selection( nCursorPos, nCursorPos ) );
2110 SetInsertMode( !pData->IsCursorOverwrite() );
2111
2112 if ( pData->IsCursorVisible() )
2113 GetCursor()->Show();
2114 else
2115 GetCursor()->Hide();
2116 }
2117 else if ( rCEvt.GetCommand() == CommandEventId::CursorPos )
2118 {
2119 if ( mpIMEInfos )
2120 {
2121 sal_Int32 nCursorPos = GetSelection().Max();
2122 SetCursorRect( nullptr, GetTextWidth( maText.toString(), nCursorPos, mpIMEInfos->nPos+mpIMEInfos->nLen-nCursorPos ) );
2123 }
2124 else
2125 {
2126 SetCursorRect();
2127 }
2128 }
2129 else if ( rCEvt.GetCommand() == CommandEventId::SelectionChange )
2130 {
2132 Selection aSelection( pData->GetStart(), pData->GetEnd() );
2133 SetSelection(aSelection);
2134 }
2135 else if ( rCEvt.GetCommand() == CommandEventId::QueryCharPosition )
2136 {
2137 if (mpIMEInfos && mpIMEInfos->nLen > 0)
2138 {
2139 OUString aText = ImplGetText();
2140 KernArray aDX;
2141 GetOutDev()->GetCaretPositions(aText, aDX, 0, aText.getLength());
2142
2143 tools::Long nTH = GetTextHeight();
2145
2146 std::vector<tools::Rectangle> aRects(mpIMEInfos->nLen);
2147 for ( int nIndex = 0; nIndex < mpIMEInfos->nLen; ++nIndex )
2148 {
2149 tools::Rectangle aRect( aPos, Size( 10, nTH ) );
2150 aRect.SetLeft( aDX[2*(nIndex+mpIMEInfos->nPos)] + mnXOffset + ImplGetExtraXOffset() );
2151 aRects[ nIndex ] = aRect;
2152 }
2153 SetCompositionCharRect(aRects.data(), mpIMEInfos->nLen);
2154 }
2155 }
2156 else
2157 Control::Command( rCEvt );
2158}
2159
2161{
2163 {
2164 if (!mpSubEdit)
2165 {
2166 mnXOffset = 0; // if GrabFocus before while size was still wrong
2167 ImplAlign();
2168 if (!mpSubEdit)
2169 ImplShowCursor(false);
2170 Invalidate();
2171 }
2172 }
2173 else if (nType == StateChangedType::Enable)
2174 {
2175 if (!mpSubEdit)
2176 {
2177 // change text color only
2179 }
2180 }
2182 {
2183 WinBits nStyle = GetStyle();
2185 {
2186 nStyle = ImplInitStyle(GetStyle());
2187 SetStyle(nStyle);
2188 }
2189
2190 sal_uInt16 nOldAlign = mnAlign;
2192
2193 // hack: right align until keyinput and cursor travelling works
2194 // edits are always RTL disabled
2195 // however the parent edits contain the correct setting
2197 {
2198 if (GetParent()->GetStyle() & WB_LEFT)
2202 }
2203 else if (mbIsSubEdit && !GetParent()->IsRTLEnabled())
2204 {
2207 }
2208
2209 if (nStyle & WB_RIGHT)
2211 else if (nStyle & WB_CENTER)
2213 if (!maText.isEmpty() && (mnAlign != nOldAlign))
2214 {
2215 ImplAlign();
2216 Invalidate();
2217 }
2218
2219 }
2221 {
2222 if (!mpSubEdit)
2223 {
2226 Invalidate();
2227 }
2228 }
2230 {
2231 if (!mpSubEdit)
2232 {
2234 Invalidate();
2235 }
2236 }
2237
2239}
2240
2242{
2243 if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
2245 ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
2246 (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
2247 {
2248 if ( !mpSubEdit )
2249 {
2252 Invalidate();
2253 }
2254 }
2255
2256 Control::DataChanged( rDCEvt );
2257}
2258
2260{
2261 if (!mpDDInfo->bVisCursor)
2262 {
2263 tools::Long nTextWidth = GetTextWidth( maText.toString(), 0, mpDDInfo->nDropPos );
2264 tools::Long nTextHeight = GetTextHeight();
2265 tools::Rectangle aCursorRect( Point( nTextWidth + mnXOffset, (GetOutDev()->GetOutputSize().Height()-nTextHeight)/2 ), Size( 2, nTextHeight ) );
2266 mpDDInfo->aCursor.SetWindow( this );
2267 mpDDInfo->aCursor.SetPos( aCursorRect.TopLeft() );
2268 mpDDInfo->aCursor.SetSize( aCursorRect.GetSize() );
2269 mpDDInfo->aCursor.Show();
2270 mpDDInfo->bVisCursor = true;
2271 }
2272}
2273
2275{
2276 if ( mpDDInfo && mpDDInfo->bVisCursor )
2277 {
2278 mpDDInfo->aCursor.Hide();
2279 mpDDInfo->bVisCursor = false;
2280 }
2281}
2282
2283TextFilter::TextFilter(OUString _aForbiddenChars)
2284 : sForbiddenChars(std::move(_aForbiddenChars))
2285{
2286}
2287
2289{
2290}
2291
2292OUString TextFilter::filter(const OUString &rText)
2293{
2294 OUString sTemp(rText);
2295 for (sal_Int32 i = 0; i < sForbiddenChars.getLength(); ++i)
2296 {
2297 sTemp = sTemp.replaceAll(OUStringChar(sForbiddenChars[i]), "");
2298 }
2299 return sTemp;
2300}
2301
2303{
2304 Selection aSel = GetSelection();
2305 const OUString sOrig = GetText();
2306 const OUString sNew = mpFilterText->filter(GetText());
2307 if (sOrig != sNew)
2308 {
2309 sal_Int32 nDiff = sOrig.getLength() - sNew.getLength();
2310 if (nDiff)
2311 {
2312 aSel.setMin(aSel.getMin() - nDiff);
2313 aSel.setMax(aSel.getMin());
2314 }
2315 SetText(sNew);
2316 SetSelection(aSel);
2317 }
2318}
2319
2321{
2322 if (mpFilterText)
2323 filterText();
2324
2325 if ( mbIsSubEdit )
2326 {
2327 static_cast<Edit*>(GetParent())->Modify();
2328 }
2329 else
2330 {
2332 // have been destroyed while calling into the handlers
2333 return;
2334
2335 // #i13677# notify edit listeners about caret position change
2337 // FIXME: this is currently only on macOS
2338 // check for other platforms that need similar handling
2339 if( ImplGetSVData()->maNWFData.mbNoFocusRects &&
2342 {
2344 }
2345 }
2346}
2347
2349{
2350 mcEchoChar = c;
2351 if ( mpSubEdit )
2352 mpSubEdit->SetEchoChar( c );
2353}
2354
2355void Edit::SetReadOnly( bool bReadOnly )
2356{
2357 if ( mbReadOnly != bReadOnly )
2358 {
2360 if ( mpSubEdit )
2362
2364 }
2365}
2366
2367void Edit::SetInsertMode( bool bInsert )
2368{
2369 if ( bInsert != mbInsertMode )
2370 {
2371 mbInsertMode = bInsert;
2372 if ( mpSubEdit )
2373 mpSubEdit->SetInsertMode( bInsert );
2374 else
2376 }
2377}
2378
2380{
2381 if ( mpSubEdit )
2382 return mpSubEdit->IsInsertMode();
2383 else
2384 return mbInsertMode;
2385}
2386
2387void Edit::SetMaxTextLen(sal_Int32 nMaxLen)
2388{
2389 mnMaxTextLen = nMaxLen > 0 ? nMaxLen : EDIT_NOLIMIT;
2390
2391 if ( mpSubEdit )
2393 else
2394 {
2395 if ( maText.getLength() > mnMaxTextLen )
2397 }
2398}
2399
2400void Edit::SetSelection( const Selection& rSelection )
2401{
2402 // If the selection was changed from outside, e.g. by MouseButtonDown, don't call Tracking()
2403 // directly afterwards which would change the selection again
2404 if ( IsTracking() )
2405 EndTracking();
2406 else if ( mpSubEdit && mpSubEdit->IsTracking() )
2408
2409 ImplSetSelection( rSelection );
2410}
2411
2412void Edit::ImplSetSelection( const Selection& rSelection, bool bPaint )
2413{
2414 if ( mpSubEdit )
2415 mpSubEdit->ImplSetSelection( rSelection );
2416 else
2417 {
2418 if ( rSelection != maSelection )
2419 {
2420 Selection aOld( maSelection );
2421 Selection aNew( rSelection );
2422
2423 if ( aNew.Min() > maText.getLength() )
2424 aNew.Min() = maText.getLength();
2425 if ( aNew.Max() > maText.getLength() )
2426 aNew.Max() = maText.getLength();
2427 if ( aNew.Min() < 0 )
2428 aNew.Min() = 0;
2429 if ( aNew.Max() < 0 )
2430 aNew.Max() = 0;
2431
2432 if ( aNew != maSelection )
2433 {
2435 Selection aTemp = maSelection;
2436 maSelection = aNew;
2437
2438 if ( bPaint && ( aOld.Len() || aNew.Len() || IsPaintTransparent() ) )
2441
2442 bool bCaret = false, bSelection = false;
2443 tools::Long nB=aNew.Max(), nA=aNew.Min(),oB=aTemp.Max(), oA=aTemp.Min();
2444 tools::Long nGap = nB-nA, oGap = oB-oA;
2445 if (nB != oB)
2446 bCaret = true;
2447 if (nGap != 0 || oGap != 0)
2448 bSelection = true;
2449
2450 if (bSelection)
2451 {
2452 if ( mbIsSubEdit )
2454 else
2456 }
2457
2458 if (bCaret)
2459 {
2460 if ( mbIsSubEdit )
2462 else
2464 }
2465
2466 // #103511# notify combobox listeners of deselection
2469 }
2470 }
2471 }
2472}
2473
2475{
2476 if ( mpSubEdit )
2477 return mpSubEdit->GetSelection();
2478 else
2479 return maSelection;
2480}
2481
2482void Edit::ReplaceSelected( const OUString& rStr )
2483{
2484 if ( mpSubEdit )
2485 mpSubEdit->ReplaceSelected( rStr );
2486 else
2487 ImplInsertText( rStr );
2488}
2489
2491{
2492 if ( mpSubEdit )
2494 else
2495 {
2496 if ( maSelection.Len() )
2498 }
2499}
2500
2501OUString Edit::GetSelected() const
2502{
2503 if ( mpSubEdit )
2504 return mpSubEdit->GetSelected();
2505 else
2506 {
2507 Selection aSelection( maSelection );
2508 aSelection.Normalize();
2509 return OUString( maText.getStr() + aSelection.Min(), aSelection.Len() );
2510 }
2511}
2512
2514{
2515 if ( !mbPassword )
2516 {
2517 Copy();
2518 ReplaceSelected( OUString() );
2519 }
2520}
2521
2523{
2524 if ( !mbPassword )
2525 {
2526 css::uno::Reference<css::datatransfer::clipboard::XClipboard> aClipboard(GetClipboard());
2527 ImplCopy( aClipboard );
2528 }
2529}
2530
2532{
2533 css::uno::Reference<css::datatransfer::clipboard::XClipboard> aClipboard(GetClipboard());
2534 ImplPaste( aClipboard );
2535}
2536
2538{
2539 if ( mpSubEdit )
2540 mpSubEdit->Undo();
2541 else
2542 {
2543 const OUString aText( maText.toString() );
2544 ImplDelete( Selection( 0, aText.getLength() ), EDIT_DEL_RIGHT, EDIT_DELMODE_SIMPLE );
2546 ImplSetSelection( Selection( 0, maUndoText.getLength() ) );
2547 maUndoText = aText;
2548 }
2549}
2550
2551void Edit::SetText( const OUString& rStr )
2552{
2553 if ( mpSubEdit )
2554 mpSubEdit->SetText( rStr ); // not directly ImplSetText if SetText overridden
2555 else
2556 {
2557 Selection aNewSel( 0, 0 ); // prevent scrolling
2558 ImplSetText( rStr, &aNewSel );
2559 }
2560}
2561
2562void Edit::SetText( const OUString& rStr, const Selection& rSelection )
2563{
2564 if ( mpSubEdit )
2565 mpSubEdit->SetText( rStr, rSelection );
2566 else
2567 ImplSetText( rStr, &rSelection );
2568}
2569
2570OUString Edit::GetText() const
2571{
2572 if ( mpSubEdit )
2573 return mpSubEdit->GetText();
2574 else
2575 return maText.toString();
2576}
2577
2579 ImplSetCursorPos( GetText().getLength(), false );
2580}
2581
2582void Edit::SetPlaceholderText( const OUString& rStr )
2583{
2584 if ( mpSubEdit )
2586 else if ( maPlaceholderText != rStr )
2587 {
2588 maPlaceholderText = rStr;
2589 if ( GetText().isEmpty() )
2590 Invalidate();
2591 }
2592}
2593
2595{
2596}
2597
2599{
2601 mpSubEdit.set(pEdit);
2602
2603 if (mpSubEdit)
2604 {
2605 SetPointer(PointerStyle::Arrow); // Only SubEdit has the BEAM...
2606 mpSubEdit->mbIsSubEdit = true;
2607
2610 }
2611}
2612
2613Size Edit::CalcMinimumSizeForText(const OUString &rString) const
2614{
2616
2617 Size aSize;
2618 if (mnWidthInChars != -1)
2619 {
2620 //CalcSize calls CalcWindowSize, but we will call that also in this
2621 //function, so undo the first one with CalcOutputSize
2623 }
2624 else
2625 {
2626 OUString aString;
2627 if (mnMaxWidthChars != -1 && mnMaxWidthChars < rString.getLength())
2628 aString = rString.copy(0, mnMaxWidthChars);
2629 else
2630 aString = rString;
2631
2632 aSize.setHeight( GetTextHeight() );
2633 aSize.setWidth( GetTextWidth(aString) );
2634 aSize.AdjustWidth(ImplGetExtraXOffset() * 2 );
2635
2636 // do not create edit fields in which one cannot enter anything
2637 // a default minimum width should exist for at least 3 characters
2638
2639 //CalcSize calls CalcWindowSize, but we will call that also in this
2640 //function, so undo the first one with CalcOutputSize
2641 Size aMinSize(CalcOutputSize(CalcSize(3)));
2642 if (aSize.Width() < aMinSize.Width())
2643 aSize.setWidth( aMinSize.Width() );
2644 }
2645
2646 aSize.AdjustHeight(ImplGetExtraYOffset() * 2 );
2647
2648 aSize = CalcWindowSize( aSize );
2649
2650 // ask NWF what if it has an opinion, too
2651 ImplControlValue aControlValue;
2652 tools::Rectangle aRect( Point( 0, 0 ), aSize );
2653 tools::Rectangle aContent, aBound;
2655 aControlValue, aBound, aContent))
2656 {
2657 if (aBound.GetHeight() > aSize.Height())
2658 aSize.setHeight( aBound.GetHeight() );
2659 }
2660 return aSize;
2661}
2662
2664{
2666}
2667
2669{
2670 return CalcMinimumSize();
2671}
2672
2673Size Edit::CalcSize(sal_Int32 nChars) const
2674{
2675 // width for N characters, independent from content.
2676 // works only correct for fixed fonts, average otherwise
2677 float fUnitWidth = std::max(approximate_char_width(), approximate_digit_width());
2678 Size aSz(fUnitWidth * nChars, GetTextHeight());
2679 aSz.AdjustWidth(ImplGetExtraXOffset() * 2 );
2680 aSz = CalcWindowSize( aSz );
2681 return aSz;
2682}
2683
2684sal_Int32 Edit::GetMaxVisChars() const
2685{
2686 const vcl::Window* pW = mpSubEdit ? mpSubEdit : this;
2687 sal_Int32 nOutWidth = pW->GetOutputSizePixel().Width();
2688 float fUnitWidth = std::max(approximate_char_width(), approximate_digit_width());
2689 return nOutWidth / fUnitWidth;
2690}
2691
2692namespace vcl
2693{
2695 {
2697 }
2698
2700 {
2702 }
2703}
2704
2706{
2707 if (!mpUIBuilder)
2708 mpUIBuilder.reset(new VclBuilder(nullptr, AllSettings::GetUIRootDir(), "vcl/ui/editmenu.ui", ""));
2709 VclPtr<PopupMenu> pPopup = mpUIBuilder->get_menu(u"menu");
2710 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
2711 if (rStyleSettings.GetHideDisabledMenuItems())
2713 else
2715 if (rStyleSettings.GetContextMenuShortcuts())
2716 {
2717 pPopup->SetAccelKey(pPopup->GetItemId(u"undo"), vcl::KeyCode( KeyFuncType::UNDO));
2718 pPopup->SetAccelKey(pPopup->GetItemId(u"cut"), vcl::KeyCode( KeyFuncType::CUT));
2719 pPopup->SetAccelKey(pPopup->GetItemId(u"copy"), vcl::KeyCode( KeyFuncType::COPY));
2720 pPopup->SetAccelKey(pPopup->GetItemId(u"paste"), vcl::KeyCode( KeyFuncType::PASTE));
2721 pPopup->SetAccelKey(pPopup->GetItemId(u"delete"), vcl::KeyCode( KeyFuncType::DELETE));
2722 pPopup->SetAccelKey(pPopup->GetItemId(u"selectall"), vcl::KeyCode( KEY_A, false, true, false, false));
2723 pPopup->SetAccelKey(pPopup->GetItemId(u"specialchar"), vcl::KeyCode( KEY_S, true, true, false, false));
2724 }
2725 return pPopup;
2726}
2727
2728// css::datatransfer::dnd::XDragGestureListener
2729void Edit::dragGestureRecognized( const css::datatransfer::dnd::DragGestureEvent& rDGE )
2730{
2731 SolarMutexGuard aVclGuard;
2732
2733 if ( !(!IsTracking() && maSelection.Len() &&
2734 !mbPassword && (!mpDDInfo || !mpDDInfo->bStarterOfDD)) ) // no repeated D&D
2735 return;
2736
2737 Selection aSel( maSelection );
2738 aSel.Normalize();
2739
2740 // only if mouse in the selection...
2741 Point aMousePos( rDGE.DragOriginX, rDGE.DragOriginY );
2742 sal_Int32 nCharPos = ImplGetCharPos( aMousePos );
2743 if ( (nCharPos < aSel.Min()) || (nCharPos >= aSel.Max()) )
2744 return;
2745
2746 if ( !mpDDInfo )
2747 mpDDInfo.reset(new DDInfo);
2748
2749 mpDDInfo->bStarterOfDD = true;
2750 mpDDInfo->aDndStartSel = aSel;
2751
2752 if ( IsTracking() )
2753 EndTracking(); // before D&D disable tracking
2754
2756 sal_Int8 nActions = datatransfer::dnd::DNDConstants::ACTION_COPY;
2757 if ( !IsReadOnly() )
2758 nActions |= datatransfer::dnd::DNDConstants::ACTION_MOVE;
2759 rDGE.DragSource->startDrag( rDGE, nActions, 0 /*cursor*/, 0 /*image*/, pDataObj, mxDnDListener );
2760 if ( GetCursor() )
2761 GetCursor()->Hide();
2762}
2763
2764// css::datatransfer::dnd::XDragSourceListener
2765void Edit::dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent& rDSDE )
2766{
2767 SolarMutexGuard aVclGuard;
2768
2769 if (rDSDE.DropSuccess && (rDSDE.DropAction & datatransfer::dnd::DNDConstants::ACTION_MOVE) && mpDDInfo)
2770 {
2771 Selection aSel( mpDDInfo->aDndStartSel );
2772 if ( mpDDInfo->bDroppedInMe )
2773 {
2774 if ( aSel.Max() > mpDDInfo->nDropPos )
2775 {
2776 tools::Long nLen = aSel.Len();
2777 aSel.Min() += nLen;
2778 aSel.Max() += nLen;
2779 }
2780 }
2782 Modify();
2783 }
2784
2786 mpDDInfo.reset();
2787}
2788
2789// css::datatransfer::dnd::XDropTargetListener
2790void Edit::drop( const css::datatransfer::dnd::DropTargetDropEvent& rDTDE )
2791{
2792 SolarMutexGuard aVclGuard;
2793
2794 bool bChanges = false;
2795 if ( !mbReadOnly && mpDDInfo )
2796 {
2798
2799 Selection aSel( maSelection );
2800 aSel.Normalize();
2801
2802 if ( aSel.Len() && !mpDDInfo->bStarterOfDD )
2804
2805 mpDDInfo->bDroppedInMe = true;
2806
2807 aSel.Min() = mpDDInfo->nDropPos;
2808 aSel.Max() = mpDDInfo->nDropPos;
2809 ImplSetSelection( aSel );
2810
2811 uno::Reference< datatransfer::XTransferable > xDataObj = rDTDE.Transferable;
2812 if ( xDataObj.is() )
2813 {
2814 datatransfer::DataFlavor aFlavor;
2815 SotExchange::GetFormatDataFlavor( SotClipboardFormatId::STRING, aFlavor );
2816 if ( xDataObj->isDataFlavorSupported( aFlavor ) )
2817 {
2818 uno::Any aData = xDataObj->getTransferData( aFlavor );
2819 OUString aText;
2820 aData >>= aText;
2821 ImplInsertText( aText );
2822 bChanges = true;
2823 Modify();
2824 }
2825 }
2826
2827 if ( !mpDDInfo->bStarterOfDD )
2828 {
2829 mpDDInfo.reset();
2830 }
2831 }
2832
2833 rDTDE.Context->dropComplete( bChanges );
2834}
2835
2836void Edit::dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& rDTDE )
2837{
2838 if ( !mpDDInfo )
2839 {
2840 mpDDInfo.reset(new DDInfo);
2841 }
2842 // search for string data type
2843 const Sequence< css::datatransfer::DataFlavor >& rFlavors( rDTDE.SupportedDataFlavors );
2844 mpDDInfo->bIsStringSupported = std::any_of(rFlavors.begin(), rFlavors.end(),
2845 [](const css::datatransfer::DataFlavor& rFlavor) {
2846 sal_Int32 nIndex = 0;
2847 const std::u16string_view aMimetype = o3tl::getToken(rFlavor.MimeType, 0, ';', nIndex );
2848 return aMimetype == u"text/plain";
2849 });
2850}
2851
2852void Edit::dragExit( const css::datatransfer::dnd::DropTargetEvent& )
2853{
2854 SolarMutexGuard aVclGuard;
2855
2857}
2858
2859void Edit::dragOver( const css::datatransfer::dnd::DropTargetDragEvent& rDTDE )
2860{
2861 SolarMutexGuard aVclGuard;
2862
2863 Point aMousePos( rDTDE.LocationX, rDTDE.LocationY );
2864
2865 sal_Int32 nPrevDropPos = mpDDInfo->nDropPos;
2866 mpDDInfo->nDropPos = ImplGetCharPos( aMousePos );
2867
2868 /*
2869 Size aOutSize = GetOutputSizePixel();
2870 if ( ( aMousePos.X() < 0 ) || ( aMousePos.X() > aOutSize.Width() ) )
2871 {
2872 // Scroll?
2873 // No, I will not receive events in this case...
2874 }
2875 */
2876
2877 Selection aSel( maSelection );
2878 aSel.Normalize();
2879
2880 // Don't accept drop in selection or read-only field...
2881 if ( IsReadOnly() || aSel.Contains( mpDDInfo->nDropPos ) || ! mpDDInfo->bIsStringSupported )
2882 {
2884 rDTDE.Context->rejectDrag();
2885 }
2886 else
2887 {
2888 // draw the old cursor away...
2889 if ( !mpDDInfo->bVisCursor || ( nPrevDropPos != mpDDInfo->nDropPos ) )
2890 {
2893 }
2894 rDTDE.Context->acceptDrag( rDTDE.DropAction );
2895 }
2896}
2897
2899{
2900 if (mpSubEdit)
2901 return mpSubEdit->GetSurroundingText();
2902 return maText.toString();
2903}
2904
2906{
2907 return GetSelection();
2908}
2909
2911{
2912 SetSelection(rSelection);
2914 // maybe we should update mpIMEInfos here
2915 return true;
2916}
2917
2919{
2920 return EditUIObject::create;
2921}
2922
2923
2925{
2926 Control::DumpAsPropertyTree(rJsonWriter);
2927
2928 if (!maPlaceholderText.isEmpty())
2929 rJsonWriter.put("placeholder", maPlaceholderText);
2930
2931 if (IsPassword())
2932 rJsonWriter.put("password", true);
2933}
2934
2935/* 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:638
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
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:80
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: ctrl.cxx:413
std::optional< vcl::ControlLayoutData > mxLayoutData
Definition: ctrl.hxx:82
SAL_DLLPRIVATE void ImplClearLayoutData() const
Definition: ctrl.cxx:326
bool ImplCallEventListenersAndHandler(VclEventId nEvent, std::function< void()> const &callHandler)
this calls both our event listeners, and a specified handler
Definition: ctrl.cxx:301
virtual void StateChanged(StateChangedType nStateChange) override
Definition: ctrl.cxx:256
virtual void Resize() override
Definition: ctrl.cxx:77
virtual void EnableRTL(bool bEnable=true) override
Definition: ctrl.cxx:68
SAL_DLLPRIVATE void ImplDrawFrame(OutputDevice *pDev, tools::Rectangle &rRect)
draws a frame around the give rectangle, onto the given device
Definition: ctrl.cxx:331
void CallEventListeners(VclEventId nEvent, void *pData=nullptr)
Definition: ctrl.cxx:293
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: ctrl.cxx:61
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:1714
virtual void Modify()
Definition: edit.cxx:2320
SAL_DLLPRIVATE void ImplPaste(css::uno::Reference< css::datatransfer::clipboard::XClipboard > const &rxClipboard)
Definition: edit.cxx:1258
Link< Edit &, bool > maActivateHdl
Definition: edit.hxx:83
sal_Int32 mnMaxTextLen
Definition: edit.hxx:69
virtual void dragDropEnd(const css::datatransfer::dnd::DragSourceDropEvent &dsde) override
Definition: edit.cxx:2765
virtual bool DeleteSurroundingText(const Selection &rSelection) override
Definition: edit.cxx:2910
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:2482
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:1125
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:747
VclPtr< Edit > mpSubEdit
Definition: edit.hxx:58
bool mbActivePopup
Definition: edit.hxx:78
virtual void Copy()
Definition: edit.cxx:2522
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:2582
virtual Size CalcSize(sal_Int32 nChars) const
Definition: edit.cxx:2673
virtual void SetText(const OUString &rStr) override
Definition: edit.cxx:2551
virtual Selection GetSurroundingTextSelection() const override
Definition: edit.cxx:2905
bool mbClickedInSelection
Definition: edit.hxx:76
virtual void dragGestureRecognized(const css::datatransfer::dnd::DragGestureEvent &dge) override
Definition: edit.cxx:2729
void Undo()
Definition: edit.cxx:2537
css::uno::Reference< css::i18n::XExtendedInputSequenceChecker > mxISC
Definition: edit.hxx:87
SAL_DLLPRIVATE css::uno::Reference< css::i18n::XExtendedInputSequenceChecker > const & ImplGetInputSequenceChecker()
Definition: edit.cxx:754
SAL_DLLPRIVATE void ImplDelete(const Selection &rSelection, sal_uInt8 nDirection, sal_uInt8 nMode)
Definition: edit.cxx:666
virtual OUString GetSurroundingText() const override
Definition: edit.cxx:2898
bool mbInternModified
Definition: edit.hxx:73
virtual Size GetOptimalSize() const override
Definition: edit.cxx:2668
bool IsPassword() const
Definition: edit.hxx:244
virtual bool set_property(const OUString &rKey, const OUString &rValue) override
Definition: edit.cxx:183
SAL_DLLPRIVATE void ImplCopyToSelectionClipboard()
Definition: edit.cxx:1244
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:1906
SAL_DLLPRIVATE void ImplSetText(const OUString &rStr, const Selection *pNewSelection)
Definition: edit.cxx:889
SAL_DLLPRIVATE tools::Long ImplGetExtraYOffset() const
Definition: edit.cxx:415
SAL_DLLPRIVATE void ImplPaintBorder(vcl::RenderContext const &rRenderContext)
Definition: edit.cxx:993
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: edit.cxx:2241
virtual const Selection & GetSelection() const
Definition: edit.cxx:2474
Edit(WindowType nType)
Definition: edit.cxx:152
virtual void DeleteSelected()
Definition: edit.cxx:2490
css::uno::Reference< css::i18n::XBreakIterator > mxBreakIterator
Definition: edit.hxx:86
bool mbForceControlBackground
Definition: edit.hxx:79
virtual void Cut()
Definition: edit.cxx:2513
void SetInsertMode(bool bInsert)
Definition: edit.cxx:2367
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:2387
virtual void GetFocus() override
Definition: edit.cxx:1840
void SetCursorAtLast()
Definition: edit.cxx:2578
virtual Size CalcMinimumSize() const
Definition: edit.cxx:2663
css::uno::Reference< css::datatransfer::dnd::XDragSourceListener > mxDnDListener
Definition: edit.hxx:88
SAL_DLLPRIVATE void ImplShowCursor(bool bOnlyIfVisible=true)
Definition: edit.cxx:1054
virtual void dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent &dtdee) override
Definition: edit.cxx:2836
SAL_DLLPRIVATE void filterText()
Definition: edit.cxx:2302
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:2924
Edit * GetSubEdit() const
Definition: edit.hxx:217
virtual void Tracking(const TrackingEvent &rTEvt) override
Definition: edit.cxx:1368
SAL_DLLPRIVATE tools::Long ImplGetExtraXOffset() const
Definition: edit.cxx:403
virtual void SetSelection(const Selection &rSelection)
Definition: edit.cxx:2400
static SAL_DLLPRIVATE void ImplInvalidateOutermostBorder(vcl::Window *pWin)
Definition: edit.cxx:1824
SAL_DLLPRIVATE void ImplShowDDCursor()
Definition: edit.cxx:2259
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: edit.cxx:1310
OUString maPlaceholderText
Definition: edit.hxx:63
virtual void LoseFocus() override
Definition: edit.cxx:1889
bool IsInsertMode() const
Definition: edit.cxx:2379
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:1253
SAL_DLLPRIVATE void ImplSetCursorPos(sal_Int32 nChar, bool bSelect)
Definition: edit.cxx:1235
bool mbPassword
Definition: edit.hxx:80
SAL_DLLPRIVATE bool ImplTruncateToMaxLen(OUString &, sal_Int32 nSelectionLen) const
Definition: edit.cxx:768
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
Definition: edit.cxx:1351
virtual void SetReadOnly(bool bReadOnly=true)
Definition: edit.cxx:2355
void SetSubEdit(Edit *pEdit)
Definition: edit.cxx:2598
SAL_DLLPRIVATE void ImplClearBackground(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRectangle, tools::Long nXStart, tools::Long nXEnd)
Definition: edit.cxx:973
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: edit.cxx:1702
virtual void dragExit(const css::datatransfer::dnd::DropTargetEvent &dte) override
Definition: edit.cxx:2852
virtual ~Edit() override
Definition: edit.cxx:220
TextFilter * mpFilterText
Definition: edit.hxx:59
static void ShowTruncationWarning(weld::Widget *pParent)
Definition: edit.cxx:761
virtual OUString GetSelected() const
Definition: edit.cxx:2501
virtual void dragOver(const css::datatransfer::dnd::DropTargetDragEvent &dtde) override
Definition: edit.cxx:2859
bool mbIsSubEdit
Definition: edit.hxx:77
SAL_DLLPRIVATE void ImplInvalidateOrRepaint()
Definition: edit.cxx:444
virtual Size CalcMinimumSizeForText(const OUString &rString) const
Definition: edit.cxx:2613
sal_Int32 GetMaxVisChars() const
Definition: edit.cxx:2684
SAL_DLLPRIVATE void ImplHideDDCursor()
Definition: edit.cxx:2274
std::unique_ptr< VclBuilder > mpUIBuilder
Definition: edit.hxx:84
virtual bool IsReadOnly() const
Definition: edit.hxx:175
virtual void SetModifyFlag()
Definition: edit.cxx:2594
SAL_DLLPRIVATE void ImplSetSelection(const Selection &rSelection, bool bPaint=true)
Definition: edit.cxx:2412
SAL_DLLPRIVATE ControlType ImplGetNativeControlType() const
Definition: edit.cxx:923
virtual void FillLayoutData() const override
Definition: edit.cxx:1708
sal_Unicode mcEchoChar
Definition: edit.hxx:72
SAL_DLLPRIVATE void ImplInsertText(const OUString &rStr, const Selection *pNewSelection=nullptr, bool bIsUserInput=false)
Definition: edit.cxx:780
virtual FactoryFunction GetUITestFactory() const override
Definition: edit.cxx:2918
virtual void Draw(OutputDevice *pDev, const Point &rPos, SystemTextColorFlags nFlags) override
Definition: edit.cxx:1733
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: edit.cxx:365
VclPtr< PopupMenu > CreatePopupMenu()
Definition: edit.cxx:2705
virtual void Command(const CommandEvent &rCEvt) override
Definition: edit.cxx:1928
SAL_DLLPRIVATE void ImplAlignAndPaint()
Definition: edit.cxx:1167
virtual void Resize() override
Definition: edit.cxx:1720
virtual void Paste()
Definition: edit.cxx:2531
OUString maUndoText
Definition: edit.hxx:65
tools::Long mnXOffset
Definition: edit.hxx:66
virtual void StateChanged(StateChangedType nType) override
Definition: edit.cxx:2160
virtual OUString GetText() const override
Definition: edit.cxx:2570
static SAL_DLLPRIVATE OUString ImplGetValidString(const OUString &rString)
Definition: edit.cxx:740
Link< Edit &, void > maModifyHdl
Definition: edit.hxx:81
SAL_DLLPRIVATE sal_Int32 ImplGetCharPos(const Point &rWindowPos) const
Definition: edit.cxx:1174
SAL_DLLPRIVATE void ImplInitEditData()
Definition: edit.cxx:262
virtual void drop(const css::datatransfer::dnd::DropTargetDropEvent &dtde) override
Definition: edit.cxx:2790
void SetEchoChar(sal_Unicode c)
Definition: edit.cxx:2348
SAL_DLLPRIVATE bool ImplHandleKeyEvent(const KeyEvent &rKEvt)
Definition: edit.cxx:1393
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
void ShowItem(sal_uInt16 nItemId, bool bVisible=true)
Definition: menu.cxx:964
void SetMenuFlags(MenuFlags nFlags)
Definition: menu.hxx:252
sal_uInt16 GetItemId(sal_uInt16 nPos) const
Definition: menu.cxx:641
void SetAccelKey(sal_uInt16 nItemId, const vcl::KeyCode &rKeyCode)
Definition: menu.cxx:785
OUString GetItemIdent(sal_uInt16 nItemId) const
Definition: menu.cxx:683
void EnableItem(sal_uInt16 nItemId, bool bEnable=true)
Definition: menu.cxx:919
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
void GetCaretPositions(const OUString &, KernArray &rCaretXArray, sal_Int32 nIndex, sal_Int32 nLen, const SalLayoutGlyphs *pGlyphs=nullptr) const
Definition: text.cxx:1038
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:597
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:879
const Color & GetTextColor() const
Definition: outdev.hxx:1003
void SetTextFillColor()
Definition: text.cxx:734
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:894
constexpr tools::Long Y() const
void setX(tools::Long nX)
constexpr tools::Long X() const
sal_uInt16 Execute(vcl::Window *pWindow, const Point &rPopupPos)
Definition: menu.cxx:2771
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:1414
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:2292
TextFilter(OUString aForbiddenChars=OUString(" "))
Definition: edit.cxx:2283
OUString sForbiddenChars
Definition: textfilter.hxx:18
virtual ~TextFilter()
Definition: edit.cxx:2288
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(std::u16string_view 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:405
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:2806
Size CalcOutputSize(const Size &rWinSz) const
Definition: window2.cxx:574
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:1962
void SetCursorRect(const tools::Rectangle *pRect=nullptr, tools::Long nExtTextInputWidth=0)
Definition: window.cxx:2112
SAL_DLLPRIVATE void ImplGrabFocus(GetFocusFlags nFlags)
Definition: mouse.cxx:195
bool IsNativeWidgetEnabled() const
Definition: window.cxx:3710
void SetInputContext(const InputContext &rInputContext)
Definition: window.cxx:2076
bool IsReallyVisible() const
Definition: window2.cxx:1133
virtual void GetFocus()
Definition: window.cxx:1841
void StartTracking(StartTrackingFlags nFlags=StartTrackingFlags::NONE)
Definition: window2.cxx:252
vcl::Window * GetParent() const
Definition: window2.cxx:1123
GetFocusFlags GetGetFocusFlags() const
Definition: window2.cxx:1214
void PaintImmediately()
Definition: paint.cxx:1268
bool IsTracking() const
Definition: window2.cxx:337
void EndTracking(TrackingEventFlags nFlags=TrackingEventFlags::NONE)
Definition: window2.cxx:293
bool IsPaintTransparent() const
Definition: window2.cxx:1063
WindowType GetType() const
Definition: window2.cxx:1000
bool SupportsDoubleBuffering() const
Can the widget derived from this Window do the double-buffering via RenderContext properly?
Definition: window.cxx:3860
float approximate_digit_width() const
Definition: window3.cxx:72
virtual void SetSizePixel(const Size &rNewSize)
Definition: window2.cxx:1288
virtual void Command(const CommandEvent &rCEvt)
Definition: window.cxx:1923
vcl::Window * GetWindow(GetWindowType nType) const
Definition: stacking.cxx:1036
void SetCursor(vcl::Cursor *pCursor)
Definition: window.cxx:3013
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
Definition: window2.cxx:1353
void GrabFocus()
Definition: window.cxx:2976
bool IsUpdateMode() const
Definition: window2.cxx:1199
bool HasFocus() const
Definition: window.cxx:2981
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:1229
vcl::Font GetDrawPixelFont(::OutputDevice const *pDev) const
Definition: window2.cxx:582
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:979
const AllSettings & GetSettings() const
Definition: window3.cxx:129
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1805
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:2147
Size CalcWindowSize(const Size &rOutSz) const
Definition: window2.cxx:566
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:592
const Color & GetTextColor() const
Definition: window3.cxx:109
std::unique_ptr< WindowImpl > mpWindowImpl
Definition: window.hxx:484
SalFrame * ImplGetFrame() const
Definition: window2.cxx:879
virtual void DumpAsPropertyTree(tools::JsonWriter &)
Dumps itself and potentially its children to a property tree, to be written easily to JSON.
Definition: window.cxx:3356
bool IsRTLEnabled() const
Definition: window3.cxx:127
virtual Size GetSizePixel() const
Definition: window.cxx:2402
Size GetOutputSizePixel() const
Definition: window3.cxx:89
bool IsControlBackground() const
Definition: window2.cxx:1113
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:36
virtual void LoseFocus()
Definition: window.cxx:1855
const Color & GetControlBackground() const
Definition: window2.cxx:1108
virtual void SetPointer(PointerStyle)
Definition: mouse.cxx:486
vcl::Region GetPaintRegion() const
Definition: paint.cxx:1127
bool HasPaintEvent() const
Definition: paint.cxx:1241
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1143
weld::Window * GetFrameWeld() const
Definition: window2.cxx:884
css::uno::Reference< css::datatransfer::clipboard::XClipboard > GetClipboard()
Definition: window.cxx:3447
void SetBorderStyle(WindowBorderStyle nBorderStyle)
Definition: window.cxx:1994
void ApplyControlFont(vcl::RenderContext &rRenderContext, const vcl::Font &rDefaultFont)
Definition: window2.cxx:478
css::uno::Reference< css::datatransfer::dnd::XDropTarget > GetDropTarget()
Definition: mouse.cxx:651
void SetType(WindowType nType)
Definition: window2.cxx:994
virtual bool set_property(const OUString &rKey, const OUString &rValue)
Definition: window2.cxx:1478
Point ScreenToOutputPixel(const Point &rPos) const
Definition: window.cxx:2812
void ApplyControlForeground(vcl::RenderContext &rRenderContext, const Color &rDefaultColor)
Definition: window2.cxx:518
css::uno::Reference< css::datatransfer::dnd::XDragGestureRecognizer > GetDragGestureRecognizer()
Definition: mouse.cxx:737
bool IsEnabled() const
Definition: window2.cxx:1148
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:941
SAL_DLLPRIVATE void CompatStateChanged(StateChangedType nStateChange)
Definition: window.cxx:3898
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)
@ HideDisabledEntries
@ AlwaysShowDisabledEntries
std::unique_ptr< sal_Int32[]> pData
constexpr OUStringLiteral aData
double getLength(const B2DPolygon &rCandidate)
const LanguageTag & getLocale()
OStringBuffer & padToLength(OStringBuffer &rBuffer, sal_Int32 nLength, char cFill='\0')
int i
long Long
FncGetSpecialChars GetGetSpecialCharsFunction()
Definition: edit.cxx:2699
void SetGetSpecialCharsFunction(FncGetSpecialChars fn)
Definition: edit.cxx:2694
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:77
OUString VclResId(TranslateId aId)
Definition: svdata.cxx:261
Reference< XClipboard > GetSystemPrimarySelection()
Definition: transfer2.cxx:505
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