LibreOffice Module sc (master) 1
editsh.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 <comphelper/string.hxx>
21#include <scitems.hxx>
22#include <editeng/eeitem.hxx>
23#include <i18nutil/unicode.hxx>
25
26#include <svx/clipfmtitem.hxx>
27#include <svx/svxdlg.hxx>
29#include <editeng/outliner.hxx>
31#include <editeng/editeng.hxx>
32#include <editeng/editview.hxx>
34#include <editeng/flditem.hxx>
35#include <editeng/flstitem.hxx>
36#include <editeng/fontitem.hxx>
38#include <svx/hlnkitem.hxx>
39#include <vcl/EnumContext.hxx>
40#include <editeng/postitem.hxx>
42#include <editeng/shdditem.hxx>
43#include <editeng/udlnitem.hxx>
44#include <editeng/wghtitem.hxx>
45#include <sfx2/bindings.hxx>
46#include <sfx2/dispatch.hxx>
47#include <sfx2/msg.hxx>
48#include <sfx2/objface.hxx>
49#include <sfx2/objsh.hxx>
50#include <sfx2/request.hxx>
51#include <sfx2/viewfrm.hxx>
53#include <svl/whiter.hxx>
54#include <sot/formats.hxx>
55#include <vcl/transfer.hxx>
56#include <vcl/unohelp2.hxx>
57#include <svl/stritem.hxx>
58#include <editeng/colritem.hxx>
59
60#include <editsh.hxx>
61#include <global.hxx>
62#include <sc.hrc>
63#include <scmod.hxx>
64#include <inputhdl.hxx>
65#include <viewutil.hxx>
66#include <viewdata.hxx>
67#include <document.hxx>
68#include <reffind.hxx>
69#include <tabvwsh.hxx>
70#include <editutil.hxx>
71#include <globstr.hrc>
72#include <scresid.hxx>
73#include <gridwin.hxx>
74
75#define ShellClass_ScEditShell
76#include <scslots.hxx>
77
78#include <scui_def.hxx>
79#include <scabstdlg.hxx>
80#include <memory>
81
82using namespace ::com::sun::star;
83
84
86
87void ScEditShell::InitInterface_Impl()
88{
89 GetStaticInterface()->RegisterPopupMenu("celledit");
90}
91
93 pEditView (pView),
94 rViewData (rData),
95 bPastePossible (false),
96 bIsInsertMode (true)
97{
100 SetName("EditCell");
102}
103
105{
106 if ( mxClipEvtLstnr.is() )
107 {
108 mxClipEvtLstnr->RemoveListener( rViewData.GetActiveWin() );
109
110 // The listener may just now be waiting for the SolarMutex and call the link
111 // afterwards, in spite of RemoveListener. So the link has to be reset, too.
112 mxClipEvtLstnr->ClearCallbackLink();
113 }
114}
115
117{
118 return SC_MOD()->GetInputHdl( rViewData.GetViewShell() );
119}
120
122{
123 pEditView = pView;
127}
128
129static void lcl_RemoveAttribs( EditView& rEditView )
130{
131 ScEditEngineDefaulter* pEngine = static_cast<ScEditEngineDefaulter*>(rEditView.GetEditEngine());
132
133 bool bOld = pEngine->SetUpdateLayout(false);
134
135 OUString aName = ScResId( STR_UNDO_DELETECONTENTS );
136 ViewShellId nViewShellId(-1);
138 nViewShellId = pViewSh->GetViewShellId();
139 pEngine->GetUndoManager().EnterListAction( aName, aName, 0, nViewShellId );
140
141 rEditView.RemoveAttribs(true);
142 pEngine->RepeatDefaults(); // paragraph attributes from cell formats must be preserved
143
144 pEngine->GetUndoManager().LeaveListAction();
145
146 pEngine->SetUpdateLayout(bOld);
147}
148
149static void lclInsertCharacter( EditView* pTableView, EditView* pTopView, sal_Unicode cChar )
150{
151 OUString aString( cChar );
152 if( pTableView )
153 pTableView->InsertText( aString );
154 if( pTopView )
155 pTopView->InsertText( aString );
156}
157
159{
160 const SfxItemSet* pReqArgs = rReq.GetArgs();
161 sal_uInt16 nSlot = rReq.GetSlot();
162 SfxBindings& rBindings = rViewData.GetBindings();
163
165 OSL_ENSURE(pHdl,"no ScInputHandler");
166
167 EditView* pTopView = pHdl->GetTopView(); // Has thee input cell the focus?
168 EditView* pTableView = pHdl->GetTableView();
169
170 OSL_ENSURE(pTableView,"no EditView :-(");
171 /* #i91683# No EditView if spell-check dialog is active and positioned on
172 * an error and user immediately (without double click or F2) selected a
173 * text portion of that cell with the mouse and wanted to modify it. */
174 /* FIXME: Bailing out only cures the symptom and prevents a crash, no edit
175 * action is possible. A real fix somehow would need to create a valid
176 * EditView from the spell-check view. */
177 if (!pTableView)
178 return;
179
180 EditEngine* pEngine = pTableView->GetEditEngine();
181
182 pHdl->DataChanging();
183 bool bSetSelIsRef = false;
184 bool bSetModified = true;
185
186 switch ( nSlot )
187 {
188 case SID_ATTR_INSERT:
189 case FID_INS_CELL_CONTENTS: // Insert taste, while defined as Acc
190 bIsInsertMode = !pTableView->IsInsertMode();
191 pTableView->SetInsertMode( bIsInsertMode );
192 if (pTopView)
193 pTopView->SetInsertMode( bIsInsertMode );
194 rBindings.Invalidate( SID_ATTR_INSERT );
195 break;
196
197 case SID_THES:
198 {
199 OUString aReplaceText;
200 const SfxStringItem* pItem2 = rReq.GetArg(FN_PARAM_THES_WORD_REPLACE);
201 if (pItem2)
202 aReplaceText = pItem2->GetValue();
203 if (!aReplaceText.isEmpty())
204 ReplaceTextWithSynonym( *pEditView, aReplaceText );
205 }
206 break;
207
208 case SID_COPY:
209 pTableView->Copy();
210 bSetModified = false;
211 break;
212
213 case SID_CUT:
214 pTableView->Cut();
215 if (pTopView)
216 pTopView->DeleteSelected();
217 break;
218
219 case SID_PASTE:
220 {
221 EVControlBits nControl = pTableView->GetControlWord();
222 if (pTopView)
223 {
224 pTopView->Paste();
225 pTableView->SetControlWord(nControl | EVControlBits::SINGLELINEPASTE);
226 }
227
228 pTableView->PasteSpecial();
229 pTableView->SetControlWord(nControl);
230 }
231 break;
232
233 case SID_DELETE:
234 pTableView->DeleteSelected();
235 if (pTopView)
236 pTopView->DeleteSelected();
237 break;
238
239 case SID_CELL_FORMAT_RESET: // "Standard"
240 lcl_RemoveAttribs( *pTableView );
241 if ( pTopView )
242 lcl_RemoveAttribs( *pTopView );
243 break;
244
245 case SID_CLIPBOARD_FORMAT_ITEMS:
246 {
247 SotClipboardFormatId nFormat = SotClipboardFormatId::NONE;
248 const SfxPoolItem* pItem;
249 if ( pReqArgs && pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET )
250 if (auto pIntItem = dynamic_cast<const SfxUInt32Item*>( pItem))
251 nFormat = static_cast<SotClipboardFormatId>(pIntItem->GetValue());
252
253 if ( nFormat != SotClipboardFormatId::NONE )
254 {
255 if (SotClipboardFormatId::STRING == nFormat)
256 pTableView->Paste();
257 else
258 pTableView->PasteSpecial();
259
260 if (pTopView)
261 pTopView->Paste();
262 }
263 }
264 break;
265
266 case SID_PASTE_SPECIAL:
267 {
269 ScopedVclPtr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog(rViewData.GetDialogParent()));
270 SotClipboardFormatId nFormat = SotClipboardFormatId::NONE;
271 pDlg->Insert( SotClipboardFormatId::STRING, OUString() );
272 pDlg->Insert( SotClipboardFormatId::RTF, OUString() );
273 pDlg->Insert( SotClipboardFormatId::RICHTEXT, OUString() );
274 // Do not offer SotClipboardFormatId::STRING_TSVC for
275 // in-cell paste.
276
277 TransferableDataHelper aDataHelper(
279
280 nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() );
281 pDlg.disposeAndClear();
282
283 // while the dialog was open, edit mode may have been stopped
284 if (!SC_MOD()->IsInputMode())
285 return;
286
287 if (nFormat != SotClipboardFormatId::NONE)
288 {
289 if (SotClipboardFormatId::STRING == nFormat)
290 pTableView->Paste();
291 else
292 pTableView->PasteSpecial();
293
294 if (pTopView)
295 pTopView->Paste();
296 }
297
298 if (vcl::Window* pViewWindow = pTopView ? pTopView->GetWindow() : nullptr)
299 pViewWindow->GrabFocus();
300 }
301 break;
302
303 case SID_PASTE_UNFORMATTED:
304 {
305 pTableView->Paste();
306
307 if (pTopView)
308 {
309 pTopView->Paste();
310 if (vcl::Window* pViewWindow = pTopView->GetWindow())
311 pViewWindow->GrabFocus();
312 }
313 }
314 break;
315
316 case SID_SELECTALL:
317 {
318 sal_Int32 nPar = pEngine->GetParagraphCount();
319 if (nPar)
320 {
321 sal_Int32 nLen = pEngine->GetTextLen(nPar-1);
322 pTableView->SetSelection(ESelection(0,0,nPar-1,nLen));
323 if (pTopView)
324 pTopView->SetSelection(ESelection(0,0,nPar-1,nLen));
325 rBindings.Invalidate( SID_ATTR_CHAR_FONT );
326 rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
327 rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT );
328 rBindings.Invalidate( SID_ATTR_CHAR_POSTURE );
329 rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE );
330 rBindings.Invalidate( SID_ATTR_CHAR_STRIKEOUT );
331 rBindings.Invalidate( SID_ATTR_CHAR_SHADOWED );
332 rBindings.Invalidate( SID_ATTR_CHAR_KERNING );
333 rBindings.Invalidate( SID_ATTR_CHAR_COLOR );
334 rBindings.Invalidate( SID_SET_SUPER_SCRIPT );
335 rBindings.Invalidate( SID_SET_SUB_SCRIPT );
336 }
337 }
338 return;
339 case SID_UNICODE_NOTATION_TOGGLE:
340 {
341 EditView* pActiveView = pHdl->GetActiveView();
342 if( pActiveView )
343 {
344 OUString sInput = pEngine->GetText();
345 ESelection aSel( pActiveView->GetSelection() );
346 if( aSel.HasRange() )
347 sInput = pActiveView->GetSelected();
348
349 if( aSel.nStartPos > aSel.nEndPos )
350 aSel.nEndPos = aSel.nStartPos;
351
352 //calculate a valid end-position by reading logical characters
353 sal_Int32 nUtf16Pos=0;
354 while( (nUtf16Pos < sInput.getLength()) && (nUtf16Pos < aSel.nEndPos) )
355 {
356 sInput.iterateCodePoints(&nUtf16Pos);
357 if( nUtf16Pos > aSel.nEndPos )
358 aSel.nEndPos = nUtf16Pos;
359 }
360
362 while( nUtf16Pos && aToggle.AllowMoreInput( sInput[nUtf16Pos-1]) )
363 --nUtf16Pos;
364 OUString sReplacement = aToggle.ReplacementString();
365 if( !sReplacement.isEmpty() )
366 {
367 aSel.nStartPos = aSel.nEndPos - aToggle.StringToReplace().getLength();
368 pTableView->SetSelection( aSel );
369 pTableView->InsertText(sReplacement, true);
370 if( pTopView )
371 {
372 pTopView->SetSelection( aSel );
373 pTopView->InsertText(sReplacement, true);
374 }
375 }
376 }
377 }
378 break;
379
380 case SID_CHARMAP:
381 {
382 SvtScriptType nScript = pTableView->GetSelectedScriptType();
383 sal_uInt16 nFontWhich = ( nScript == SvtScriptType::ASIAN ) ? EE_CHAR_FONTINFO_CJK :
384 ( ( nScript == SvtScriptType::COMPLEX ) ? EE_CHAR_FONTINFO_CTL :
386 auto const attribs = pTableView->GetAttribs();
387 const SvxFontItem& rItem = static_cast<const SvxFontItem&>(
388 attribs.Get(nFontWhich));
389
390 OUString aString;
391 std::shared_ptr<SvxFontItem> aNewItem(std::make_shared<SvxFontItem>(EE_CHAR_FONTINFO));
392
393 const SfxItemSet *pArgs = rReq.GetArgs();
394 const SfxPoolItem* pItem = nullptr;
395 if( pArgs )
396 pArgs->GetItemState(SID_CHARMAP, false, &pItem);
397
398 if ( pItem )
399 {
400 aString = static_cast<const SfxStringItem*>(pItem)->GetValue();
401 const SfxStringItem* pFontItem = pArgs->GetItemIfSet( SID_ATTR_SPECIALCHAR, false);
402 if ( pFontItem )
403 {
404 const OUString& aFontName(pFontItem->GetValue());
405 vcl::Font aFont(aFontName, Size(1,1)); // Size just because CTOR
406 // tdf#125054 see comment in drtxob.cxx, same ID
407 aNewItem = std::make_shared<SvxFontItem>(
408 aFont.GetFamilyType(), aFont.GetFamilyName(),
409 aFont.GetStyleName(), aFont.GetPitch(),
410 aFont.GetCharSet(), ATTR_FONT);
411 }
412 else
413 {
414 aNewItem.reset(rItem.Clone());
415 }
416
417 // tdf#125054 force Item to correct intended ID
418 aNewItem->SetWhich(EE_CHAR_FONTINFO);
419 }
420 else
421 {
423
424 // while the dialog was open, edit mode may have been stopped
425 if (!SC_MOD()->IsInputMode())
426 return;
427 }
428
429 if ( !aString.isEmpty() )
430 {
431 // if string contains WEAK characters, set all fonts
432 SvtScriptType nSetScript;
434 if ( rDoc.HasStringWeakCharacters( aString ) )
435 nSetScript = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
436 else
437 nSetScript = rDoc.GetStringScriptType( aString );
438
439 SfxItemSet aSet( pTableView->GetEmptyItemSet() );
440 SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, GetPool() );
441 aSetItem.PutItemForScriptType( nSetScript, *aNewItem );
442 aSet.Put( aSetItem.GetItemSet(), false );
443
444 // SetAttribs on the View selects a word, when nothing is selected
445 pTableView->GetEditEngine()->QuickSetAttribs( aSet, pTableView->GetSelection() );
446 pTableView->InsertText(aString);
447 if (pTopView)
448 pTopView->InsertText(aString);
449
450 SfxStringItem aStringItem( SID_CHARMAP, aString );
451 SfxStringItem aFontItem( SID_ATTR_SPECIALCHAR, aNewItem->GetFamilyName() );
452 rReq.AppendItem( aFontItem );
453 rReq.AppendItem( aStringItem );
454 rReq.Done();
455
456 }
457
458 if (vcl::Window* pViewWindow = pTopView ? pTopView->GetWindow() : nullptr)
459 pViewWindow->GrabFocus();
460 }
461 break;
462
463 case FID_INSERT_NAME:
464 {
466
468 short nRet = pDlg->Execute();
469 // pDlg is needed below
470
471 // while the dialog was open, edit mode may have been stopped
472 if (!SC_MOD()->IsInputMode())
473 return;
474
475 if ( nRet == BTN_PASTE_NAME )
476 {
477 std::vector<OUString> aNames = pDlg->GetSelectedNames();
478 if (!aNames.empty())
479 {
480 OUStringBuffer aBuffer;
481 for (const auto& rName : aNames)
482 {
483 aBuffer.append(rName).append(' ');
484 }
485 const OUString s = aBuffer.makeStringAndClear();
486 pTableView->InsertText(s);
487 if (pTopView)
488 pTopView->InsertText(s);
489 }
490 }
491 pDlg.disposeAndClear();
492
493 if (vcl::Window* pViewWindow = pTopView ? pTopView->GetWindow() : nullptr)
494 pViewWindow->GrabFocus();
495 }
496 break;
497
498 case SID_CHAR_DLG_EFFECT:
499 case SID_CHAR_DLG:
500 {
501 SfxItemSet aAttrs( pTableView->GetAttribs() );
502
504
506
508 rViewData.GetDialogParent(), &aAttrs, pObjSh, false));
509 if (nSlot == SID_CHAR_DLG_EFFECT)
510 {
511 pDlg->SetCurPageId("fonteffects");
512 }
513 short nRet = pDlg->Execute();
514 // pDlg is needed below
515
516 // while the dialog was open, edit mode may have been stopped
517 if (!SC_MOD()->IsInputMode())
518 return;
519
520 if ( nRet == RET_OK )
521 {
522 const SfxItemSet* pOut = pDlg->GetOutputItemSet();
523 pTableView->SetAttribs( *pOut );
524 }
525 }
526 break;
527
528 case SID_TOGGLE_REL:
529 {
530 /* TODO: MLFORMULA: this should work also with multi-line formulas. */
531 if (pEngine->GetParagraphCount() == 1)
532 {
533 OUString aText = pEngine->GetText();
534 ESelection aSel = pEditView->GetSelection(); // current View
535
537 ScRefFinder aFinder(aText, rViewData.GetCurPos(), rDoc, rDoc.GetAddressConvention());
538 aFinder.ToggleRel( aSel.nStartPos, aSel.nEndPos );
539 if (aFinder.GetFound())
540 {
541 const OUString& aNew = aFinder.GetText();
542 ESelection aNewSel( 0,aFinder.GetSelStart(), 0,aFinder.GetSelEnd() );
543 pEngine->SetText( aNew );
544 pTableView->SetSelection( aNewSel );
545 if ( pTopView )
546 {
547 pTopView->GetEditEngine()->SetText( aNew );
548 pTopView->SetSelection( aNewSel );
549 }
550
551 // reference is being selected -> do not overwrite when typing
552 bSetSelIsRef = true;
553 }
554 }
555 }
556 break;
557
558 case SID_HYPERLINK_SETLINK:
559 if( pReqArgs )
560 {
561 const SfxPoolItem* pItem;
562 if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, true, &pItem ) == SfxItemState::SET )
563 {
564 const SvxHyperlinkItem* pHyper = static_cast<const SvxHyperlinkItem*>(pItem);
565 const OUString& rName = pHyper->GetName();
566 const OUString& rURL = pHyper->GetURL();
567 const OUString& rTarget = pHyper->GetTargetFrame();
569
570 bool bDone = false;
571 if ( eMode == HLINK_DEFAULT || eMode == HLINK_FIELD )
572 {
573 const SvxURLField* pURLField = GetURLField();
574 if ( pURLField )
575 {
576 // select old field
577
578 ESelection aSel = pTableView->GetSelection();
579 aSel.Adjust();
580 aSel.nEndPara = aSel.nStartPara;
581 aSel.nEndPos = aSel.nStartPos + 1;
582 pTableView->SetSelection( aSel );
583
584 // insert new field
585
586 SvxURLField aURLField( rURL, rName, SvxURLFormat::Repr );
587 aURLField.SetTargetFrame( rTarget );
588 SvxFieldItem aURLItem( aURLField, EE_FEATURE_FIELD );
589 pTableView->InsertField( aURLItem );
590 pTableView->SetSelection( aSel ); // select inserted field
591
592 // now also fields in the Top-View
593
594 if ( pTopView )
595 {
596 aSel = pTopView->GetSelection();
597 aSel.nEndPara = aSel.nStartPara;
598 aSel.nEndPos = aSel.nStartPos + 1;
599 pTopView->SetSelection( aSel );
600 pTopView->InsertField( aURLItem );
601 pTopView->SetSelection( aSel ); // select inserted field
602 }
603
604 bDone = true;
605 }
606 }
607
608 if (!bDone)
609 {
611 InsertURL( rName, rURL, rTarget, static_cast<sal_uInt16>(eMode) );
612
613 // when "Button", the InsertURL in ViewShell turns the EditShell off
614 // thus the immediate return statement
615 return;
616 }
617 }
618 }
619 break;
620 case SID_OPEN_HYPERLINK:
621 {
622 const SvxURLField* pURLField = GetURLField();
623 if ( pURLField )
624 ScGlobal::OpenURL( pURLField->GetURL(), pURLField->GetTargetFrame(), true );
625 return;
626 }
627 case SID_EDIT_HYPERLINK:
628 {
629 // Ensure the field is selected first
632 SID_HYPERLINK_DIALOG);
633 }
634 break;
635 case SID_COPY_HYPERLINK_LOCATION:
636 {
637 const SvxFieldData* pField = pEditView->GetFieldAtCursor();
638 if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField))
639 {
640 uno::Reference<datatransfer::clipboard::XClipboard> xClipboard
643 }
644 }
645 break;
646 case SID_REMOVE_HYPERLINK:
647 {
649 }
650 break;
651
652 case FN_INSERT_SOFT_HYPHEN:
653 lclInsertCharacter( pTableView, pTopView, CHAR_SHY );
654 break;
655 case FN_INSERT_HARDHYPHEN:
656 lclInsertCharacter( pTableView, pTopView, CHAR_NBHY );
657 break;
658 case FN_INSERT_HARD_SPACE:
659 lclInsertCharacter( pTableView, pTopView, CHAR_NBSP );
660 break;
661 case FN_INSERT_NNBSP:
662 lclInsertCharacter( pTableView, pTopView, CHAR_NNBSP );
663 break;
664 case SID_INSERT_RLM:
665 lclInsertCharacter( pTableView, pTopView, CHAR_RLM );
666 break;
667 case SID_INSERT_LRM:
668 lclInsertCharacter( pTableView, pTopView, CHAR_LRM );
669 break;
670 case SID_INSERT_ZWSP:
671 lclInsertCharacter( pTableView, pTopView, CHAR_ZWSP );
672 break;
673 case SID_INSERT_WJ:
674 lclInsertCharacter( pTableView, pTopView, CHAR_WJ );
675 break;
676 case SID_INSERT_FIELD_SHEET:
677 {
679 SvxFieldItem aItem(aField, EE_FEATURE_FIELD);
680 pTableView->InsertField(aItem);
681 }
682 break;
683 case SID_INSERT_FIELD_TITLE:
684 {
685 SvxFileField aField;
686 SvxFieldItem aItem(aField, EE_FEATURE_FIELD);
687 pTableView->InsertField(aItem);
688 }
689 break;
690 case SID_INSERT_FIELD_DATE_VAR:
691 {
692 SvxDateField aField;
693 SvxFieldItem aItem(aField, EE_FEATURE_FIELD);
694 pTableView->InsertField(aItem);
695 }
696 break;
697 }
698
699 pHdl->DataChanged(false, bSetModified);
700 if (bSetSelIsRef)
701 pHdl->SetSelIsRef(true);
702}
703
704static void lcl_DisableAll( SfxItemSet& rSet ) // disable all slots
705{
706 SfxWhichIter aIter( rSet );
707 sal_uInt16 nWhich = aIter.FirstWhich();
708 while (nWhich)
709 {
710 rSet.DisableItem( nWhich );
711 nWhich = aIter.NextWhich();
712 }
713}
714
716{
718}
719
721{
723}
724
726{
727 // When deactivating the view, edit mode is stopped, but the EditShell is left active
728 // (a shell can't be removed from within Deactivate). In that state, the EditView isn't inserted
729 // into the EditEngine, so it can have an invalid selection and must not be used.
731 {
733 return;
734 }
735
737 EditView* pActiveView = pHdl ? pHdl->GetActiveView() : pEditView;
738
739 SfxWhichIter aIter( rSet );
740 sal_uInt16 nWhich = aIter.FirstWhich();
741 while (nWhich)
742 {
743 switch (nWhich)
744 {
745 case SID_ATTR_INSERT: // Status row
746 {
747 if ( pActiveView )
748 rSet.Put( SfxBoolItem( nWhich, pActiveView->IsInsertMode() ) );
749 else
750 {
751 // Here the code used to pass the value 42 and it used
752 // to "work" without warnings because the SfxBoolItem
753 // was based on 'sal_Bool', which is actually 'unsigned
754 // char'. But now it uses actual 'bool', and passing 42
755 // for a 'bool' parameter causes a warning at least with
756 // MSVC. So use 'true'. I really really hope there is
757 // not code somewhere that retrieves this "boolean" item
758 // and checks it value for the magic value 42...
759 rSet.Put( SfxBoolItem( nWhich, true) );
760 }
761 }
762 break;
763
764 case SID_HYPERLINK_GETLINK:
765 {
766 SvxHyperlinkItem aHLinkItem;
767 const SvxURLField* pURLField = GetURLField();
768 if ( pURLField )
769 {
770 aHLinkItem.SetName( pURLField->GetRepresentation() );
771 aHLinkItem.SetURL( pURLField->GetURL() );
772 aHLinkItem.SetTargetFrame( pURLField->GetTargetFrame() );
773 }
774 else if ( pActiveView )
775 {
776 // use selected text as name for urls
777 OUString sReturn = pActiveView->GetSelected();
778 sReturn = sReturn.copy(0, std::min(sReturn.getLength(), static_cast<sal_Int32>(255)));
779 aHLinkItem.SetName(comphelper::string::stripEnd(sReturn, ' '));
780 }
781 rSet.Put(aHLinkItem);
782 }
783 break;
784
785 case SID_OPEN_HYPERLINK:
786 case SID_EDIT_HYPERLINK:
787 case SID_COPY_HYPERLINK_LOCATION:
788 case SID_REMOVE_HYPERLINK:
789 {
790 bool bDisableEditHyperlink;
792 bDisableEditHyperlink = ShouldDisableEditHyperlink();
793 else
794 {
795 // tdf#140361 if a popup menu was active, use the state as of when the popup was launched and then drop
796 // moAtContextMenu_DisableEditHyperlink
797 bDisableEditHyperlink = *moAtContextMenu_DisableEditHyperlink;
799 }
800
801 if (bDisableEditHyperlink)
802 rSet.DisableItem (nWhich);
803 }
804 break;
805
806 case SID_TRANSLITERATE_HALFWIDTH:
807 case SID_TRANSLITERATE_FULLWIDTH:
808 case SID_TRANSLITERATE_HIRAGANA:
809 case SID_TRANSLITERATE_KATAKANA:
810 case SID_INSERT_RLM:
811 case SID_INSERT_LRM:
813 break;
814
815 case SID_THES:
816 {
817 OUString aStatusVal;
819 bool bIsLookUpWord = pActiveView &&
820 GetStatusValueForThesaurusFromContext(aStatusVal, nLang, *pActiveView);
821 rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
822
823 // disable thesaurus context menu entry if there is nothing to look up
824 bool bCanDoThesaurus = ScModule::HasThesaurusLanguage( nLang );
825 if (!bIsLookUpWord || !bCanDoThesaurus)
826 rSet.DisableItem( SID_THES );
827 }
828 break;
829 case SID_INSERT_FIELD_SHEET:
830 case SID_INSERT_FIELD_TITLE:
831 case SID_INSERT_FIELD_DATE_VAR:
832 break;
833 case SID_COPY:
834 case SID_CUT:
835 if (GetObjectShell() && GetObjectShell()->isContentExtractionLocked())
836 {
837 rSet.DisableItem(SID_COPY);
838 rSet.DisableItem(SID_CUT);
839 }
840 break;
841
842 }
843 nWhich = aIter.NextWhich();
844 }
845}
846
848{
850 EditView* pActiveView = pHdl ? pHdl->GetActiveView() : pEditView;
851 if (!pActiveView)
852 return nullptr;
853
854 const SvxFieldData* pField = pActiveView->GetFieldAtCursor();
855 if (auto pURLField = dynamic_cast<const SvxURLField*>(pField))
856 return pURLField;
857
858 return nullptr;
859}
860
861IMPL_LINK( ScEditShell, ClipboardChanged, TransferableDataHelper*, pDataHelper, void )
862{
863 bPastePossible = ( pDataHelper->HasFormat( SotClipboardFormatId::STRING )
864 || pDataHelper->HasFormat( SotClipboardFormatId::RTF )
865 || pDataHelper->HasFormat( SotClipboardFormatId::RICHTEXT ));
866
867 SfxBindings& rBindings = rViewData.GetBindings();
868 rBindings.Invalidate( SID_PASTE );
869 rBindings.Invalidate( SID_PASTE_SPECIAL );
870 rBindings.Invalidate( SID_PASTE_UNFORMATTED );
871 rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
872}
873
875{
876 // Do not offer SotClipboardFormatId::STRING_TSVC for in-cell paste.
877
878 if ( !mxClipEvtLstnr.is() )
879 {
880 // create listener
881 mxClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScEditShell, ClipboardChanged ) );
883 mxClipEvtLstnr->AddListener( pWin );
884
885 // get initial state
887 bPastePossible = ( aDataHelper.HasFormat( SotClipboardFormatId::STRING )
888 || aDataHelper.HasFormat( SotClipboardFormatId::RTF )
889 || aDataHelper.HasFormat( SotClipboardFormatId::RICHTEXT ) );
890 }
891
892 SfxWhichIter aIter( rSet );
893 sal_uInt16 nWhich = aIter.FirstWhich();
894 while (nWhich)
895 {
896 switch (nWhich)
897 {
898 case SID_PASTE:
899 case SID_PASTE_SPECIAL:
900 case SID_PASTE_UNFORMATTED:
901 if( !bPastePossible )
902 rSet.DisableItem( nWhich );
903 break;
904 case SID_CLIPBOARD_FORMAT_ITEMS:
905 if( bPastePossible )
906 {
907 SvxClipboardFormatItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
908 TransferableDataHelper aDataHelper(
910
911 if ( aDataHelper.HasFormat( SotClipboardFormatId::STRING ) )
912 aFormats.AddClipbrdFormat( SotClipboardFormatId::STRING );
913 if ( aDataHelper.HasFormat( SotClipboardFormatId::RTF ) )
914 aFormats.AddClipbrdFormat( SotClipboardFormatId::RTF );
915
916 rSet.Put( aFormats );
917 }
918 else
919 rSet.DisableItem( nWhich );
920 break;
921 }
922 nWhich = aIter.NextWhich();
923 }
924}
925
926static void lcl_InvalidateUnder( SfxBindings& rBindings )
927{
928 rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE );
929 rBindings.Invalidate( SID_ULINE_VAL_NONE );
930 rBindings.Invalidate( SID_ULINE_VAL_SINGLE );
931 rBindings.Invalidate( SID_ULINE_VAL_DOUBLE );
932 rBindings.Invalidate( SID_ULINE_VAL_DOTTED );
933}
934
936{
938 SfxBindings& rBindings = rViewData.GetBindings();
939 const SfxItemSet* pArgs = rReq.GetArgs();
940 sal_uInt16 nSlot = rReq.GetSlot();
941
942 switch ( nSlot )
943 {
944 case SID_ATTR_CHAR_FONTHEIGHT:
945 case SID_ATTR_CHAR_FONT:
946 {
947 if (pArgs)
948 {
949 // #i78017 establish the same behaviour as in Writer
950 SvtScriptType nScript = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
951 if (nSlot == SID_ATTR_CHAR_FONT)
952 {
953 nScript = pEditView->GetSelectedScriptType();
954 if (nScript == SvtScriptType::NONE) nScript = ScGlobal::GetDefaultScriptType();
955 }
956
957 SfxItemPool& rPool = GetPool();
958 SvxScriptSetItem aSetItem( nSlot, rPool );
959 sal_uInt16 nWhich = rPool.GetWhich( nSlot );
960 aSetItem.PutItemForScriptType( nScript, pArgs->Get( nWhich ) );
961
962 aSet.Put( aSetItem.GetItemSet(), false );
963 }
964 }
965 break;
966
967 case SID_ATTR_CHAR_COLOR:
968 {
969 if (pArgs)
970 {
971 if ( const SfxStringItem* pColorStringItem = pArgs->GetItemIfSet( SID_ATTR_COLOR_STR, false ) )
972 {
973 Color aColor;
974 OUString sColor = pColorStringItem->GetValue();
975 if ( sColor == "transparent" )
976 aColor = COL_TRANSPARENT;
977 else
978 aColor = Color( ColorTransparency, sColor.toInt32( 16 ) );
979
980 aSet.Put( SvxColorItem( aColor, EE_CHAR_COLOR ) );
981 }
982 else
983 {
984 aSet.Put( pArgs->Get( pArgs->GetPool()->GetWhich( nSlot ) ) );
985 }
986 rBindings.Invalidate( nSlot );
987 }
988 }
989 break;
990
991 // Toggles
992
993 case SID_ATTR_CHAR_WEIGHT:
994 {
995 // #i78017 establish the same behaviour as in Writer
996 SvtScriptType nScript = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
997
998 SfxItemPool& rPool = GetPool();
999
1000 bool bOld = false;
1001 SvxScriptSetItem aOldSetItem( nSlot, rPool );
1002 aOldSetItem.GetItemSet().Put( pEditView->GetAttribs(), false );
1003 const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
1004 if ( pCore && static_cast<const SvxWeightItem*>(pCore)->GetWeight() > WEIGHT_NORMAL )
1005 bOld = true;
1006
1007 SvxScriptSetItem aSetItem( nSlot, rPool );
1008 aSetItem.PutItemForScriptType( nScript,
1010 aSet.Put( aSetItem.GetItemSet(), false );
1011
1012 rBindings.Invalidate( nSlot );
1013 }
1014 break;
1015
1016 case SID_ATTR_CHAR_POSTURE:
1017 {
1018 // #i78017 establish the same behaviour as in Writer
1019 SvtScriptType nScript = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
1020
1021 SfxItemPool& rPool = GetPool();
1022
1023 bool bOld = false;
1024 SvxScriptSetItem aOldSetItem( nSlot, rPool );
1025 aOldSetItem.GetItemSet().Put( pEditView->GetAttribs(), false );
1026 const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
1027 if ( pCore && static_cast<const SvxPostureItem*>(pCore)->GetValue() != ITALIC_NONE )
1028 bOld = true;
1029
1030 SvxScriptSetItem aSetItem( nSlot, rPool );
1031 aSetItem.PutItemForScriptType( nScript,
1033 aSet.Put( aSetItem.GetItemSet(), false );
1034
1035 rBindings.Invalidate( nSlot );
1036 }
1037 break;
1038
1039 case SID_ULINE_VAL_NONE:
1041 lcl_InvalidateUnder( rBindings );
1042 break;
1043
1044 case SID_ATTR_CHAR_UNDERLINE:
1045 case SID_ULINE_VAL_SINGLE:
1046 case SID_ULINE_VAL_DOUBLE:
1047 case SID_ULINE_VAL_DOTTED:
1048 {
1049 FontLineStyle eOld = pEditView->GetAttribs().Get(EE_CHAR_UNDERLINE).GetLineStyle();
1050 FontLineStyle eNew = eOld;
1051 switch (nSlot)
1052 {
1053 case SID_ATTR_CHAR_UNDERLINE:
1054 if ( pArgs )
1055 {
1056 const SvxTextLineItem& rTextLineItem = static_cast< const SvxTextLineItem& >( pArgs->Get( pArgs->GetPool()->GetWhich(nSlot) ) );
1057 eNew = rTextLineItem.GetLineStyle();
1058 }
1059 else
1060 {
1061 eNew = ( eOld != LINESTYLE_NONE ) ? LINESTYLE_NONE : LINESTYLE_SINGLE;
1062 }
1063 break;
1064 case SID_ULINE_VAL_SINGLE:
1065 eNew = ( eOld == LINESTYLE_SINGLE ) ? LINESTYLE_NONE : LINESTYLE_SINGLE;
1066 break;
1067 case SID_ULINE_VAL_DOUBLE:
1068 eNew = ( eOld == LINESTYLE_DOUBLE ) ? LINESTYLE_NONE : LINESTYLE_DOUBLE;
1069 break;
1070 case SID_ULINE_VAL_DOTTED:
1071 eNew = ( eOld == LINESTYLE_DOTTED ) ? LINESTYLE_NONE : LINESTYLE_DOTTED;
1072 break;
1073 }
1074 aSet.Put( SvxUnderlineItem( eNew, EE_CHAR_UNDERLINE ) );
1075 lcl_InvalidateUnder( rBindings );
1076 }
1077 break;
1078
1079 case SID_ATTR_CHAR_OVERLINE:
1080 {
1081 FontLineStyle eOld = pEditView->GetAttribs().Get(EE_CHAR_OVERLINE).GetLineStyle();
1083 aSet.Put( SvxOverlineItem( eNew, EE_CHAR_OVERLINE ) );
1084 rBindings.Invalidate( nSlot );
1085 }
1086 break;
1087
1088 case SID_ATTR_CHAR_STRIKEOUT:
1089 {
1090 bool bOld = pEditView->GetAttribs().Get(EE_CHAR_STRIKEOUT).GetValue() != STRIKEOUT_NONE;
1092 rBindings.Invalidate( nSlot );
1093 }
1094 break;
1095
1096 case SID_ATTR_CHAR_SHADOWED:
1097 {
1098 bool bOld = pEditView->GetAttribs().Get(EE_CHAR_SHADOW).GetValue();
1099 aSet.Put( SvxShadowedItem( !bOld, EE_CHAR_SHADOW ) );
1100 rBindings.Invalidate( nSlot );
1101 }
1102 break;
1103
1104 case SID_ATTR_CHAR_CONTOUR:
1105 {
1106 bool bOld = pEditView->GetAttribs().Get(EE_CHAR_OUTLINE).GetValue();
1107 aSet.Put( SvxContourItem( !bOld, EE_CHAR_OUTLINE ) );
1108 rBindings.Invalidate( nSlot );
1109 }
1110 break;
1111
1112 case SID_SET_SUPER_SCRIPT:
1113 {
1114 SvxEscapement eOld = static_cast<SvxEscapement>(pEditView->GetAttribs().Get(EE_CHAR_ESCAPEMENT).GetEnumValue());
1115 SvxEscapement eNew = (eOld == SvxEscapement::Superscript) ?
1116 SvxEscapement::Off : SvxEscapement::Superscript;
1117 aSet.Put( SvxEscapementItem( eNew, EE_CHAR_ESCAPEMENT ) );
1118 rBindings.Invalidate( nSlot );
1119 }
1120 break;
1121 case SID_SET_SUB_SCRIPT:
1122 {
1123 SvxEscapement eOld = static_cast<SvxEscapement>(pEditView->GetAttribs().Get(EE_CHAR_ESCAPEMENT).GetEnumValue());
1124 SvxEscapement eNew = (eOld == SvxEscapement::Subscript) ?
1125 SvxEscapement::Off : SvxEscapement::Subscript;
1126 aSet.Put( SvxEscapementItem( eNew, EE_CHAR_ESCAPEMENT ) );
1127 rBindings.Invalidate( nSlot );
1128 }
1129 break;
1130 case SID_ATTR_CHAR_KERNING:
1131 {
1132 if(pArgs)
1133 {
1134 aSet.Put ( pArgs->Get(pArgs->GetPool()->GetWhich(nSlot)));
1135 rBindings.Invalidate( nSlot );
1136 }
1137 }
1138 break;
1139
1140 case SID_GROW_FONT_SIZE:
1141 case SID_SHRINK_FONT_SIZE:
1142 {
1143 const SvxFontListItem* pFontListItem = static_cast< const SvxFontListItem* >
1144 ( SfxObjectShell::Current()->GetItem( SID_ATTR_CHAR_FONTLIST ) );
1145 const FontList* pFontList = pFontListItem ? pFontListItem->GetFontList() : nullptr;
1146 pEditView->ChangeFontSize( nSlot == SID_GROW_FONT_SIZE, pFontList );
1147 rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
1148 }
1149 break;
1150 }
1151
1152 // apply
1153
1154 EditEngine* pEngine = pEditView->GetEditEngine();
1155 bool bOld = pEngine->SetUpdateLayout(false);
1156
1157 pEditView->SetAttribs( aSet );
1158
1159 pEngine->SetUpdateLayout(bOld);
1161
1162 ScInputHandler* pHdl = GetMyInputHdl();
1163 pHdl->SetModified();
1164
1165 rReq.Done();
1166}
1167
1169{
1171 {
1173 return;
1174 }
1175
1176 SfxItemSet aAttribs = pEditView->GetAttribs();
1177 rSet.Put( aAttribs );
1178
1179 // choose font info according to selection script type
1180
1182 if (nScript == SvtScriptType::NONE) nScript = ScGlobal::GetDefaultScriptType();
1183
1184 // #i55929# input-language-dependent script type (depends on input language if nothing selected)
1185 SvtScriptType nInputScript = nScript;
1186 if ( !pEditView->GetSelection().HasRange() )
1187 {
1189 if (nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
1190 nInputScript = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
1191 }
1192
1193 // #i55929# according to spec, nInputScript is used for font and font height only
1194 if ( rSet.GetItemState( EE_CHAR_FONTINFO ) != SfxItemState::UNKNOWN )
1195 ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_FONTINFO, nInputScript );
1196 if ( rSet.GetItemState( EE_CHAR_FONTHEIGHT ) != SfxItemState::UNKNOWN )
1197 ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_FONTHEIGHT, nInputScript );
1198 if ( rSet.GetItemState( EE_CHAR_WEIGHT ) != SfxItemState::UNKNOWN )
1199 ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_WEIGHT, nScript );
1200 if ( rSet.GetItemState( EE_CHAR_ITALIC ) != SfxItemState::UNKNOWN )
1201 ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_ITALIC, nScript );
1202
1203 // underline
1204 SfxItemState eState = aAttribs.GetItemState( EE_CHAR_UNDERLINE );
1205 if ( eState == SfxItemState::DONTCARE )
1206 {
1207 rSet.InvalidateItem( SID_ULINE_VAL_NONE );
1208 rSet.InvalidateItem( SID_ULINE_VAL_SINGLE );
1209 rSet.InvalidateItem( SID_ULINE_VAL_DOUBLE );
1210 rSet.InvalidateItem( SID_ULINE_VAL_DOTTED );
1211 }
1212 else
1213 {
1214 FontLineStyle eUnderline = aAttribs.Get(EE_CHAR_UNDERLINE).GetLineStyle();
1215 rSet.Put(SfxBoolItem(SID_ULINE_VAL_SINGLE, eUnderline == LINESTYLE_SINGLE));
1216 rSet.Put(SfxBoolItem(SID_ULINE_VAL_DOUBLE, eUnderline == LINESTYLE_DOUBLE));
1217 rSet.Put(SfxBoolItem(SID_ULINE_VAL_DOTTED, eUnderline == LINESTYLE_DOTTED));
1218 rSet.Put(SfxBoolItem(SID_ULINE_VAL_NONE, eUnderline == LINESTYLE_NONE));
1219 }
1220
1222 ScInputHandler* pHdl = GetMyInputHdl();
1223 if ( pHdl && pHdl->IsFormulaMode() )
1224 rSet.ClearItem( EE_CHAR_WEIGHT ); // Highlighted brace not here
1225
1226 SvxEscapement eEsc = static_cast<SvxEscapement>(aAttribs.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
1227 rSet.Put(SfxBoolItem(SID_SET_SUPER_SCRIPT, eEsc == SvxEscapement::Superscript));
1228 rSet.Put(SfxBoolItem(SID_SET_SUB_SCRIPT, eEsc == SvxEscapement::Subscript));
1229 rViewData.GetBindings().Invalidate( SID_SET_SUPER_SCRIPT );
1230 rViewData.GetBindings().Invalidate( SID_SET_SUB_SCRIPT );
1231
1232 eState = aAttribs.GetItemState( EE_CHAR_KERNING );
1233 rViewData.GetBindings().Invalidate( SID_ATTR_CHAR_KERNING );
1234 if ( eState == SfxItemState::DONTCARE )
1235 {
1237 }
1238}
1239
1240OUString ScEditShell::GetSelectionText( bool bWholeWord )
1241{
1242 OUString aStrSelection;
1243
1245 {
1246 if ( bWholeWord )
1247 {
1248 EditEngine* pEngine = pEditView->GetEditEngine();
1250 OUString aStrCurrentDelimiters = pEngine->GetWordDelimiters();
1251
1252 pEngine->SetWordDelimiters(" .,;\"'");
1253 aStrSelection = pEngine->GetWord( aSel.nEndPara, aSel.nEndPos );
1254 pEngine->SetWordDelimiters( aStrCurrentDelimiters );
1255 }
1256 else
1257 {
1258 aStrSelection = pEditView->GetSelected();
1259 }
1260 }
1261
1262 return aStrSelection;
1263}
1264
1266{
1267 // Undo must be handled here because it's called for both EditViews
1268
1269 ScInputHandler* pHdl = GetMyInputHdl();
1270 OSL_ENSURE(pHdl,"no ScInputHandler");
1271 EditView* pTopView = pHdl->GetTopView();
1272 EditView* pTableView = pHdl->GetTableView();
1273 OSL_ENSURE(pTableView,"no EditView");
1274
1275 pHdl->DataChanging();
1276
1277 const SfxItemSet* pReqArgs = rReq.GetArgs();
1278 sal_uInt16 nSlot = rReq.GetSlot();
1279 switch ( nSlot )
1280 {
1281 case SID_UNDO:
1282 case SID_REDO:
1283 {
1284 bool bIsUndo = ( nSlot == SID_UNDO );
1285
1286 sal_uInt16 nCount = 1;
1287 const SfxPoolItem* pItem;
1288 if ( pReqArgs && pReqArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET )
1289 nCount = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1290
1291 for (sal_uInt16 i=0; i<nCount; i++)
1292 {
1293 if ( bIsUndo )
1294 {
1295 pTableView->Undo();
1296 if (pTopView)
1297 pTopView->Undo();
1298 }
1299 else
1300 {
1301 pTableView->Redo();
1302 if (pTopView)
1303 pTopView->Redo();
1304 }
1305 }
1306 }
1307 break;
1308 }
1310
1311 pHdl->DataChanged();
1312}
1313
1315{
1316 // Undo state is taken from normal ViewFrame state function
1317
1319 if ( pViewFrm && GetUndoManager() )
1320 {
1321 SfxWhichIter aIter(rSet);
1322 sal_uInt16 nWhich = aIter.FirstWhich();
1323 while( nWhich )
1324 {
1325 pViewFrm->GetSlotState( nWhich, nullptr, &rSet );
1326 nWhich = aIter.NextWhich();
1327 }
1328 }
1329
1330 // disable if no action in input line EditView
1331
1332 ScInputHandler* pHdl = GetMyInputHdl();
1333 OSL_ENSURE(pHdl,"no ScInputHandler");
1334 EditView* pTopView = pHdl->GetTopView();
1335 if (pTopView)
1336 {
1337 SfxUndoManager& rTopMgr = pTopView->GetEditEngine()->GetUndoManager();
1338 if ( rTopMgr.GetUndoActionCount() == 0 )
1339 rSet.DisableItem( SID_UNDO );
1340 if ( rTopMgr.GetRedoActionCount() == 0 )
1341 rSet.DisableItem( SID_REDO );
1342 }
1343}
1344
1346{
1348 if ( nType == TransliterationFlags::NONE )
1349 return;
1350
1351 ScInputHandler* pHdl = GetMyInputHdl();
1352 assert(pHdl && "no ScInputHandler");
1353
1354 EditView* pTopView = pHdl->GetTopView();
1355 EditView* pTableView = pHdl->GetTableView();
1356 assert(pTableView && "no EditView");
1357
1358 pHdl->DataChanging();
1359
1360 pTableView->TransliterateText( nType );
1361 if (pTopView)
1362 pTopView->TransliterateText( nType );
1363
1364 pHdl->DataChanged();
1365}
1366
1367/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 GetValue() const
const OUString & GetValue() const
OUString GetWord(sal_Int32 nPara, sal_Int32 nIndex)
OUString GetText(LineEnd eEnd=LINEEND_LF) const
void SetWordDelimiters(const OUString &rDelimiters)
void SetText(const OUString &rStr)
bool SetUpdateLayout(bool bUpdate, bool bRestoring=false)
sal_Int32 GetParagraphCount() const
sal_Int32 GetTextLen() const
const SfxItemSet & GetEmptyItemSet() const
void QuickSetAttribs(const SfxItemSet &rSet, const ESelection &rSel)
const OUString & GetWordDelimiters() const
SfxUndoManager & GetUndoManager()
void SetControlWord(EVControlBits nWord)
bool IsInsertMode() const
ESelection GetSelection() const
void Copy()
void ChangeFontSize(bool bGrow, const FontList *pList)
void RemoveAttribs(bool bRemoveParaAttribs=false, sal_uInt16 nWhich=0)
void Undo()
void SelectFieldAtCursor()
void Cut()
void SetSelection(const ESelection &rNewSel)
void Redo()
void InsertText(const OUString &rNew, bool bSelect=false, bool bLOKShowSelect=true)
SfxItemSet GetAttribs()
const SfxItemSet & GetEmptyItemSet() const
SvtScriptType GetSelectedScriptType() const
vcl::Window * GetWindow() const
const SvxFieldData * GetFieldAtCursor() const
void DeleteSelected()
EVControlBits GetControlWord() const
css::uno::Reference< css::datatransfer::clipboard::XClipboard > GetClipboard() const
EditEngine * GetEditEngine() const
void SetInsertMode(bool bInsert)
void TransliterateText(TransliterationFlags nTransliterationMode)
void InsertField(const SvxFieldItem &rFld)
void Invalidate()
OUString GetSelected() const
void PasteSpecial()
void SetAttribs(const SfxItemSet &rSet)
void Paste()
virtual VclPtr< AbstractScNamePasteDlg > CreateScNamePasteDlg(weld::Window *pParent, ScDocShell *pShell)=0
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
Definition: scabstdlg.cxx:37
virtual VclPtr< SfxAbstractTabDialog > CreateScCharDlg(weld::Window *pParent, const SfxItemSet *pAttr, const SfxObjectShell *pDocShell, bool bDrawText)=0
bool HasStringWeakCharacters(const OUString &rString)
Definition: documen6.cxx:51
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
Definition: documen3.cxx:500
SC_DLLPUBLIC SvtScriptType GetStringScriptType(const OUString &rString)
Definition: documen6.cxx:76
void RepeatDefaults()
Re-apply existing defaults if set, same as in SetText, but without EnableUndo/SetUpdateMode.
Definition: editutil.cxx:656
rtl::Reference< TransferableClipboardListener > mxClipEvtLstnr
Definition: editsh.hxx:41
bool ShouldDisableEditHyperlink() const
return true if "Edit Hyperlink" in context menu should be disabled
Definition: editsh.cxx:715
const SvxURLField * GetURLField()
Definition: editsh.cxx:847
EditView * pEditView
Definition: editsh.hxx:39
void ExecuteUndo(const SfxRequest &rReq)
Definition: editsh.cxx:1265
bool bPastePossible
Definition: editsh.hxx:42
ScInputHandler * GetMyInputHdl()
Definition: editsh.cxx:116
void GetUndoState(SfxItemSet &rSet)
Definition: editsh.cxx:1314
ScViewData & rViewData
Definition: editsh.hxx:40
virtual ~ScEditShell() override
Definition: editsh.cxx:104
void ExecuteAttr(SfxRequest &rReq)
Definition: editsh.cxx:935
std::optional< bool > moAtContextMenu_DisableEditHyperlink
Definition: editsh.hxx:49
bool bIsInsertMode
Definition: editsh.hxx:43
OUString GetSelectionText(bool bWholeWord)
Definition: editsh.cxx:1240
ScEditShell(EditView *pView, ScViewData &rData)
Definition: editsh.cxx:92
void GetAttrState(SfxItemSet &rSet)
Definition: editsh.cxx:1168
void EnableEditHyperlink()
force "Edit Hyperlink" to true, with the expectation that SID_EDIT_HYPERLINK is later Invalidated to ...
Definition: editsh.cxx:720
void GetState(SfxItemSet &rSet)
Definition: editsh.cxx:725
void ExecuteTrans(const SfxRequest &rReq)
Definition: editsh.cxx:1345
void SetEditView(EditView *pView)
Definition: editsh.cxx:121
void Execute(SfxRequest &rReq)
Definition: editsh.cxx:158
void GetClipState(SfxItemSet &rSet)
Definition: editsh.cxx:874
static void OpenURL(const OUString &rURL, const OUString &rTarget, bool bIgnoreSettings=false)
Open the specified URL.
Definition: global.cxx:808
static SC_DLLPUBLIC SvtScriptType GetDefaultScriptType()
Definition: global.cxx:898
void SetModified()
Definition: inputhdl.hxx:246
void DataChanged(bool bFromTopNotify=false, bool bSetModified=true)
Definition: inputhdl.cxx:2688
EditView * GetTopView()
Definition: inputhdl.hxx:239
EditView * GetActiveView()
Definition: inputhdl.cxx:2321
bool IsFormulaMode() const
Definition: inputhdl.hxx:263
bool DataChanging(sal_Unicode cTyped=0, bool bFromCommand=false)
Definition: inputhdl.cxx:2676
EditView * GetTableView()
Definition: inputhdl.hxx:238
void SetSelIsRef(bool bSet)
Definition: inputhdl.hxx:249
static bool HasThesaurusLanguage(LanguageType nLang)
Definition: scmod.cxx:2277
void ToggleRel(sal_Int32 nStartPos, sal_Int32 nEndPos)
Definition: reffind.cxx:235
sal_Int32 GetFound() const
Definition: reffind.hxx:43
const OUString & GetText() const
Definition: reffind.hxx:42
sal_Int32 GetSelEnd() const
Definition: reffind.hxx:45
sal_Int32 GetSelStart() const
Definition: reffind.hxx:44
static ScTabViewShell * GetActiveViewShell()
Definition: tabvwsh4.cxx:1076
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
ScDocument & GetDocument() const
Definition: viewdata.hxx:380
ScDocShell * GetDocShell() const
Definition: viewdata.hxx:354
ScGridWindow * GetActiveWin()
Definition: viewdata.cxx:3157
ScTabViewShell * GetViewShell() const
Definition: viewdata.hxx:357
ScSplitPos GetActivePart() const
Definition: viewdata.hxx:398
weld::Window * GetDialogParent()
Definition: viewdata.cxx:3151
SfxObjectShell * GetSfxDocShell() const
Definition: viewdata.hxx:358
ScAddress GetCurPos() const
Definition: viewdata.cxx:4127
SfxBindings & GetBindings()
Definition: viewdata.cxx:3129
bool HasEditView(ScSplitPos eWhich) const
Definition: viewdata.hxx:582
static TransliterationFlags GetTransliterationType(sal_uInt16 nSlotID)
Definition: viewutil.cxx:99
static void ExecuteCharMap(const SvxFontItem &rOldFont, const ScTabViewShell &rShell)
Definition: viewutil.cxx:318
static void HideDisabledSlot(SfxItemSet &rSet, SfxBindings &rBindings, sal_uInt16 nSlotId)
Definition: viewutil.cxx:284
static void PutItemScript(SfxItemSet &rShellSet, const SfxItemSet &rCoreSet, sal_uInt16 nWhichId, SvtScriptType nScript)
Definition: viewutil.cxx:50
void Invalidate(sal_uInt16 nId)
void InvalidateAll(bool bWithMsg)
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
SfxItemPool * GetPool() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void DisableItem(sal_uInt16 nWhich)
void InvalidateItem(sal_uInt16 nWhich)
static SfxObjectShell * Current()
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
const T * GetArg(sal_uInt16 nSlotId) const
void AppendItem(const SfxPoolItem &)
void Done(bool bRemove=false)
const SfxPoolItem * GetSlotState(sal_uInt16 nSlotId, const SfxInterface *pIF=nullptr, SfxItemSet *pStateSet=nullptr)
void SetUndoManager(SfxUndoManager *pNewUndoMgr)
SfxItemPool & GetPool() const
void SetContextName(const OUString &rsContextName)
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
virtual SfxObjectShell * GetObjectShell()
virtual SfxUndoManager * GetUndoManager()
void SetPool(SfxItemPool *pNewPool)
void SetName(const OUString &rName)
size_t LeaveListAction()
virtual void EnterListAction(const OUString &rComment, const OUString &rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId)
virtual size_t GetRedoActionCount(bool const i_currentLevel=CurrentLevel) const
virtual size_t GetUndoActionCount(bool const i_currentLevel=CurrentLevel) const
SfxDispatcher * GetDispatcher()
SfxViewFrame * GetViewFrame() const
static SfxViewShell * Current()
sal_uInt16 FirstWhich()
sal_uInt16 NextWhich()
static SvxAbstractDialogFactory * Create()
void AddClipbrdFormat(SotClipboardFormatId nId)
virtual SvxFontItem * Clone(SfxItemPool *pPool=nullptr) const override
const FontList * GetFontList() const
SvxLinkInsertMode GetInsertMode() const
const OUString & GetName() const
const OUString & GetURL() const
void SetName(const OUString &rName)
void SetURL(const OUString &rURL)
const OUString & GetTargetFrame() const
void SetTargetFrame(const OUString &rTarget)
void PutItemForScriptType(SvtScriptType nScriptType, const SfxPoolItem &rItem)
const SfxPoolItem * GetItemOfScript(SvtScriptType nScript) const
FontLineStyle GetLineStyle() const
const OUString & GetRepresentation() const
void SetTargetFrame(const OUString &rFrm)
const OUString & GetTargetFrame() const
const OUString & GetURL() const
OUString ReplacementString()
bool AllowMoreInput(sal_Unicode uChar)
OUString StringToReplace()
static TransferableDataHelper CreateFromSystemClipboard(vcl::Window *pWindow)
bool HasFormat(SotClipboardFormatId nFormat) const
const css::uno::Reference< css::datatransfer::XTransferable > & GetTransferable() const
static void RemoveURLField(EditView &pEditView)
static bool IsCursorAtURLField(const EditView &pEditView)
void disposeAndClear()
static const OUString & GetContextName(const Context eContext)
FontFamily GetFamilyType()
const OUString & GetStyleName() const
const OUString & GetFamilyName() const
FontPitch GetPitch()
rtl_TextEncoding GetCharSet() const
LanguageType GetInputLanguage() const
static void CopyStringTo(const OUString &rContent, const css::uno::Reference< css::datatransfer::clipboard::XClipboard > &rxClipboard, const vcl::ILibreOfficeKitNotifier *pNotifier=nullptr)
ColorTransparency
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
const OUStringLiteral sColor
int nCount
IMPL_LINK(ScEditShell, ClipboardChanged, TransferableDataHelper *, pDataHelper, void)
Definition: editsh.cxx:861
static void lcl_RemoveAttribs(EditView &rEditView)
Definition: editsh.cxx:129
static void lclInsertCharacter(EditView *pTableView, EditView *pTopView, sal_Unicode cChar)
Definition: editsh.cxx:149
static void lcl_InvalidateUnder(SfxBindings &rBindings)
Definition: editsh.cxx:926
static void lcl_DisableAll(SfxItemSet &rSet)
Definition: editsh.cxx:704
EVControlBits
constexpr TypedWhichId< SvxContourItem > EE_CHAR_OUTLINE(EE_CHAR_START+8)
constexpr TypedWhichId< SvxKerningItem > EE_CHAR_KERNING(EE_CHAR_START+12)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CJK(EE_CHAR_START+17)
constexpr TypedWhichId< SvxFieldItem > EE_FEATURE_FIELD(EE_FEATURE_NOTCONV+1)
constexpr TypedWhichId< SvxUnderlineItem > EE_CHAR_UNDERLINE(EE_CHAR_START+5)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
constexpr TypedWhichId< SvxShadowedItem > EE_CHAR_SHADOW(EE_CHAR_START+9)
constexpr TypedWhichId< SvxOverlineItem > EE_CHAR_OVERLINE(EE_CHAR_START+29)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT(EE_CHAR_START+4)
constexpr TypedWhichId< SvxColorItem > EE_CHAR_COLOR(EE_CHAR_START+0)
constexpr TypedWhichId< SvxCrossedOutItem > EE_CHAR_STRIKEOUT(EE_CHAR_START+6)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC(EE_CHAR_START+7)
constexpr TypedWhichId< SvxEscapementItem > EE_CHAR_ESCAPEMENT(EE_CHAR_START+10)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CTL(EE_CHAR_START+18)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO(EE_CHAR_START+1)
FilterGroup & rTarget
FontLineStyle
LINESTYLE_SINGLE
LINESTYLE_DOUBLE
LINESTYLE_NONE
LINESTYLE_DOTTED
STRIKEOUT_SINGLE
STRIKEOUT_NONE
ITALIC_NORMAL
ITALIC_NONE
WEIGHT_BOLD
WEIGHT_NORMAL
SotClipboardFormatId
const sal_Unicode CHAR_RLM
Definition: global.hxx:71
const sal_Unicode CHAR_NBHY
Definition: global.hxx:72
const sal_Unicode CHAR_SHY
Definition: global.hxx:68
const sal_Unicode CHAR_NBSP
Definition: global.hxx:67
const sal_Unicode CHAR_LRM
Definition: global.hxx:70
const sal_Unicode CHAR_ZWSP
Definition: global.hxx:69
const sal_Unicode CHAR_NNBSP
Definition: global.hxx:74
const sal_Unicode CHAR_WJ
Definition: global.hxx:73
SvxLinkInsertMode
HLINK_FIELD
HLINK_DEFAULT
OUString aName
Mode eMode
#define LANGUAGE_SYSTEM
#define LANGUAGE_NONE
#define LANGUAGE_DONTKNOW
SvtScriptType
SvtScriptType GetScriptTypeOfLanguage(LanguageType nLang)
OString stripEnd(const OString &rIn, char c)
int i
const char GetValue[]
void ReplaceTextWithSynonym(EditView &rEditView, const OUString &rSynonmText)
bool GetStatusValueForThesaurusFromContext(OUString &rStatusVal, LanguageType &rLang, const EditView &rEditView)
SfxItemState
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
constexpr TypedWhichId< SvxFontItem > ATTR_FONT(100)
#define SC_MOD()
Definition: scmod.hxx:249
#define BTN_PASTE_NAME
Definition: scui_def.hxx:61
static SfxItemSet & rSet
#define SFX_IMPL_INTERFACE(Class, SuperClass)
bool HasRange() const
sal_Int32 nStartPara
sal_Int32 nEndPos
sal_Int32 nStartPos
void Adjust()
sal_Int32 nEndPara
SvxEscapement
TransliterationFlags
sal_uInt16 sal_Unicode
RET_OK
oslFileHandle & pOut
std::unique_ptr< char[]> aBuffer