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