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 + " ");
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.
732 {
734
735 // Some items are actually useful and still applicable when in formula building mode: enable
736 if (pHdl && pHdl->IsFormulaMode())
737 {
738 rSet.ClearItem(SID_TOGGLE_REL); // F4 Cycle Cell Reference Types
739 rSet.ClearItem(SID_CHARMAP); // Insert Special Characters
740 }
741 return;
742 }
743
744 EditView* pActiveView = pHdl ? pHdl->GetActiveView() : pEditView;
745
746 SfxWhichIter aIter( rSet );
747 sal_uInt16 nWhich = aIter.FirstWhich();
748 while (nWhich)
749 {
750 switch (nWhich)
751 {
752 case SID_ATTR_INSERT: // Status row
753 {
754 if ( pActiveView )
755 rSet.Put( SfxBoolItem( nWhich, pActiveView->IsInsertMode() ) );
756 else
757 {
758 // Here the code used to pass the value 42 and it used
759 // to "work" without warnings because the SfxBoolItem
760 // was based on 'sal_Bool', which is actually 'unsigned
761 // char'. But now it uses actual 'bool', and passing 42
762 // for a 'bool' parameter causes a warning at least with
763 // MSVC. So use 'true'. I really really hope there is
764 // not code somewhere that retrieves this "boolean" item
765 // and checks it value for the magic value 42...
766 rSet.Put( SfxBoolItem( nWhich, true) );
767 }
768 }
769 break;
770
771 case SID_HYPERLINK_GETLINK:
772 {
773 SvxHyperlinkItem aHLinkItem;
774 const SvxURLField* pURLField = GetURLField();
775 if ( pURLField )
776 {
777 aHLinkItem.SetName( pURLField->GetRepresentation() );
778 aHLinkItem.SetURL( pURLField->GetURL() );
779 aHLinkItem.SetTargetFrame( pURLField->GetTargetFrame() );
780 }
781 else if ( pActiveView )
782 {
783 // use selected text as name for urls
784 OUString sReturn = pActiveView->GetSelected();
785 sReturn = sReturn.copy(0, std::min(sReturn.getLength(), static_cast<sal_Int32>(255)));
786 aHLinkItem.SetName(comphelper::string::stripEnd(sReturn, ' '));
787 }
788 rSet.Put(aHLinkItem);
789 }
790 break;
791
792 case SID_OPEN_HYPERLINK:
793 case SID_EDIT_HYPERLINK:
794 case SID_COPY_HYPERLINK_LOCATION:
795 case SID_REMOVE_HYPERLINK:
796 {
797 bool bDisableEditHyperlink;
799 bDisableEditHyperlink = ShouldDisableEditHyperlink();
800 else
801 {
802 // tdf#140361 if a popup menu was active, use the state as of when the popup was launched and then drop
803 // moAtContextMenu_DisableEditHyperlink
804 bDisableEditHyperlink = *moAtContextMenu_DisableEditHyperlink;
806 }
807
808 if (bDisableEditHyperlink)
809 rSet.DisableItem (nWhich);
810 }
811 break;
812
813 case SID_TRANSLITERATE_HALFWIDTH:
814 case SID_TRANSLITERATE_FULLWIDTH:
815 case SID_TRANSLITERATE_HIRAGANA:
816 case SID_TRANSLITERATE_KATAKANA:
817 case SID_INSERT_RLM:
818 case SID_INSERT_LRM:
820 break;
821
822 case SID_THES:
823 {
824 OUString aStatusVal;
826 bool bIsLookUpWord = pActiveView &&
827 GetStatusValueForThesaurusFromContext(aStatusVal, nLang, *pActiveView);
828 rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
829
830 // disable thesaurus context menu entry if there is nothing to look up
831 bool bCanDoThesaurus = ScModule::HasThesaurusLanguage( nLang );
832 if (!bIsLookUpWord || !bCanDoThesaurus)
833 rSet.DisableItem( SID_THES );
834 }
835 break;
836 case SID_INSERT_FIELD_SHEET:
837 case SID_INSERT_FIELD_TITLE:
838 case SID_INSERT_FIELD_DATE_VAR:
839 break;
840 case SID_COPY:
841 case SID_CUT:
842 if (GetObjectShell() && GetObjectShell()->isContentExtractionLocked())
843 {
844 rSet.DisableItem(SID_COPY);
845 rSet.DisableItem(SID_CUT);
846 }
847 break;
848
849 }
850 nWhich = aIter.NextWhich();
851 }
852}
853
855{
857 EditView* pActiveView = pHdl ? pHdl->GetActiveView() : pEditView;
858 if (!pActiveView)
859 return nullptr;
860
861 const SvxFieldData* pField = pActiveView->GetFieldAtCursor();
862 if (auto pURLField = dynamic_cast<const SvxURLField*>(pField))
863 return pURLField;
864
865 return nullptr;
866}
867
868IMPL_LINK( ScEditShell, ClipboardChanged, TransferableDataHelper*, pDataHelper, void )
869{
870 bPastePossible = ( pDataHelper->HasFormat( SotClipboardFormatId::STRING )
871 || pDataHelper->HasFormat( SotClipboardFormatId::RTF )
872 || pDataHelper->HasFormat( SotClipboardFormatId::RICHTEXT ));
873
874 SfxBindings& rBindings = rViewData.GetBindings();
875 rBindings.Invalidate( SID_PASTE );
876 rBindings.Invalidate( SID_PASTE_SPECIAL );
877 rBindings.Invalidate( SID_PASTE_UNFORMATTED );
878 rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
879}
880
882{
883 // Do not offer SotClipboardFormatId::STRING_TSVC for in-cell paste.
884
885 if ( !mxClipEvtLstnr.is() )
886 {
887 // create listener
888 mxClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScEditShell, ClipboardChanged ) );
890 mxClipEvtLstnr->AddListener( pWin );
891
892 // get initial state
894 bPastePossible = ( aDataHelper.HasFormat( SotClipboardFormatId::STRING )
895 || aDataHelper.HasFormat( SotClipboardFormatId::RTF )
896 || aDataHelper.HasFormat( SotClipboardFormatId::RICHTEXT ) );
897 }
898
899 SfxWhichIter aIter( rSet );
900 sal_uInt16 nWhich = aIter.FirstWhich();
901 while (nWhich)
902 {
903 switch (nWhich)
904 {
905 case SID_PASTE:
906 case SID_PASTE_SPECIAL:
907 case SID_PASTE_UNFORMATTED:
908 if( !bPastePossible )
909 rSet.DisableItem( nWhich );
910 break;
911 case SID_CLIPBOARD_FORMAT_ITEMS:
912 if( bPastePossible )
913 {
914 SvxClipboardFormatItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
915 TransferableDataHelper aDataHelper(
917
918 if ( aDataHelper.HasFormat( SotClipboardFormatId::STRING ) )
919 aFormats.AddClipbrdFormat( SotClipboardFormatId::STRING );
920 if ( aDataHelper.HasFormat( SotClipboardFormatId::RTF ) )
921 aFormats.AddClipbrdFormat( SotClipboardFormatId::RTF );
922
923 rSet.Put( aFormats );
924 }
925 else
926 rSet.DisableItem( nWhich );
927 break;
928 }
929 nWhich = aIter.NextWhich();
930 }
931}
932
933static void lcl_InvalidateUnder( SfxBindings& rBindings )
934{
935 rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE );
936 rBindings.Invalidate( SID_ULINE_VAL_NONE );
937 rBindings.Invalidate( SID_ULINE_VAL_SINGLE );
938 rBindings.Invalidate( SID_ULINE_VAL_DOUBLE );
939 rBindings.Invalidate( SID_ULINE_VAL_DOTTED );
940}
941
943{
945 SfxBindings& rBindings = rViewData.GetBindings();
946 const SfxItemSet* pArgs = rReq.GetArgs();
947 sal_uInt16 nSlot = rReq.GetSlot();
948
949 switch ( nSlot )
950 {
951 case SID_ATTR_CHAR_FONTHEIGHT:
952 case SID_ATTR_CHAR_FONT:
953 {
954 if (pArgs)
955 {
956 // #i78017 establish the same behaviour as in Writer
957 SvtScriptType nScript = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
958 if (nSlot == SID_ATTR_CHAR_FONT)
959 {
960 nScript = pEditView->GetSelectedScriptType();
961 if (nScript == SvtScriptType::NONE) nScript = ScGlobal::GetDefaultScriptType();
962 }
963
964 SfxItemPool& rPool = GetPool();
965 SvxScriptSetItem aSetItem( nSlot, rPool );
966 sal_uInt16 nWhich = rPool.GetWhich( nSlot );
967 aSetItem.PutItemForScriptType( nScript, pArgs->Get( nWhich ) );
968
969 aSet.Put( aSetItem.GetItemSet(), false );
970 }
971 }
972 break;
973
974 case SID_ATTR_CHAR_COLOR:
975 {
976 if (pArgs)
977 {
978 aSet.Put( pArgs->Get( pArgs->GetPool()->GetWhich( nSlot ) ) );
979 rBindings.Invalidate( nSlot );
980 }
981 }
982 break;
983
984 // Toggles
985
986 case SID_ATTR_CHAR_WEIGHT:
987 {
988 // #i78017 establish the same behaviour as in Writer
989 SvtScriptType nScript = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
990
991 SfxItemPool& rPool = GetPool();
992
993 bool bOld = false;
994 SvxScriptSetItem aOldSetItem( nSlot, rPool );
995 aOldSetItem.GetItemSet().Put( pEditView->GetAttribs(), false );
996 const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
997 if ( pCore && static_cast<const SvxWeightItem*>(pCore)->GetWeight() > WEIGHT_NORMAL )
998 bOld = true;
999
1000 SvxScriptSetItem aSetItem( nSlot, rPool );
1001 aSetItem.PutItemForScriptType( nScript,
1003 aSet.Put( aSetItem.GetItemSet(), false );
1004
1005 rBindings.Invalidate( nSlot );
1006 }
1007 break;
1008
1009 case SID_ATTR_CHAR_POSTURE:
1010 {
1011 // #i78017 establish the same behaviour as in Writer
1012 SvtScriptType nScript = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
1013
1014 SfxItemPool& rPool = GetPool();
1015
1016 bool bOld = false;
1017 SvxScriptSetItem aOldSetItem( nSlot, rPool );
1018 aOldSetItem.GetItemSet().Put( pEditView->GetAttribs(), false );
1019 const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
1020 if ( pCore && static_cast<const SvxPostureItem*>(pCore)->GetValue() != ITALIC_NONE )
1021 bOld = true;
1022
1023 SvxScriptSetItem aSetItem( nSlot, rPool );
1024 aSetItem.PutItemForScriptType( nScript,
1026 aSet.Put( aSetItem.GetItemSet(), false );
1027
1028 rBindings.Invalidate( nSlot );
1029 }
1030 break;
1031
1032 case SID_ULINE_VAL_NONE:
1034 lcl_InvalidateUnder( rBindings );
1035 break;
1036
1037 case SID_ATTR_CHAR_UNDERLINE:
1038 case SID_ULINE_VAL_SINGLE:
1039 case SID_ULINE_VAL_DOUBLE:
1040 case SID_ULINE_VAL_DOTTED:
1041 {
1042 FontLineStyle eOld = pEditView->GetAttribs().Get(EE_CHAR_UNDERLINE).GetLineStyle();
1043 FontLineStyle eNew = eOld;
1044 switch (nSlot)
1045 {
1046 case SID_ATTR_CHAR_UNDERLINE:
1047 if ( pArgs )
1048 {
1049 const SvxTextLineItem& rTextLineItem = static_cast< const SvxTextLineItem& >( pArgs->Get( pArgs->GetPool()->GetWhich(nSlot) ) );
1050 eNew = rTextLineItem.GetLineStyle();
1051 }
1052 else
1053 {
1054 eNew = ( eOld != LINESTYLE_NONE ) ? LINESTYLE_NONE : LINESTYLE_SINGLE;
1055 }
1056 break;
1057 case SID_ULINE_VAL_SINGLE:
1058 eNew = ( eOld == LINESTYLE_SINGLE ) ? LINESTYLE_NONE : LINESTYLE_SINGLE;
1059 break;
1060 case SID_ULINE_VAL_DOUBLE:
1061 eNew = ( eOld == LINESTYLE_DOUBLE ) ? LINESTYLE_NONE : LINESTYLE_DOUBLE;
1062 break;
1063 case SID_ULINE_VAL_DOTTED:
1064 eNew = ( eOld == LINESTYLE_DOTTED ) ? LINESTYLE_NONE : LINESTYLE_DOTTED;
1065 break;
1066 }
1067 aSet.Put( SvxUnderlineItem( eNew, EE_CHAR_UNDERLINE ) );
1068 lcl_InvalidateUnder( rBindings );
1069 }
1070 break;
1071
1072 case SID_ATTR_CHAR_OVERLINE:
1073 {
1074 FontLineStyle eOld = pEditView->GetAttribs().Get(EE_CHAR_OVERLINE).GetLineStyle();
1076 aSet.Put( SvxOverlineItem( eNew, EE_CHAR_OVERLINE ) );
1077 rBindings.Invalidate( nSlot );
1078 }
1079 break;
1080
1081 case SID_ATTR_CHAR_STRIKEOUT:
1082 {
1083 bool bOld = pEditView->GetAttribs().Get(EE_CHAR_STRIKEOUT).GetValue() != STRIKEOUT_NONE;
1085 rBindings.Invalidate( nSlot );
1086 }
1087 break;
1088
1089 case SID_ATTR_CHAR_SHADOWED:
1090 {
1091 bool bOld = pEditView->GetAttribs().Get(EE_CHAR_SHADOW).GetValue();
1092 aSet.Put( SvxShadowedItem( !bOld, EE_CHAR_SHADOW ) );
1093 rBindings.Invalidate( nSlot );
1094 }
1095 break;
1096
1097 case SID_ATTR_CHAR_CONTOUR:
1098 {
1099 bool bOld = pEditView->GetAttribs().Get(EE_CHAR_OUTLINE).GetValue();
1100 aSet.Put( SvxContourItem( !bOld, EE_CHAR_OUTLINE ) );
1101 rBindings.Invalidate( nSlot );
1102 }
1103 break;
1104
1105 case SID_SET_SUPER_SCRIPT:
1106 {
1107 SvxEscapement eOld = static_cast<SvxEscapement>(pEditView->GetAttribs().Get(EE_CHAR_ESCAPEMENT).GetEnumValue());
1108 SvxEscapement eNew = (eOld == SvxEscapement::Superscript) ?
1109 SvxEscapement::Off : SvxEscapement::Superscript;
1110 aSet.Put( SvxEscapementItem( eNew, EE_CHAR_ESCAPEMENT ) );
1111 rBindings.Invalidate( nSlot );
1112 }
1113 break;
1114 case SID_SET_SUB_SCRIPT:
1115 {
1116 SvxEscapement eOld = static_cast<SvxEscapement>(pEditView->GetAttribs().Get(EE_CHAR_ESCAPEMENT).GetEnumValue());
1117 SvxEscapement eNew = (eOld == SvxEscapement::Subscript) ?
1118 SvxEscapement::Off : SvxEscapement::Subscript;
1119 aSet.Put( SvxEscapementItem( eNew, EE_CHAR_ESCAPEMENT ) );
1120 rBindings.Invalidate( nSlot );
1121 }
1122 break;
1123 case SID_ATTR_CHAR_KERNING:
1124 {
1125 if(pArgs)
1126 {
1127 aSet.Put ( pArgs->Get(pArgs->GetPool()->GetWhich(nSlot)));
1128 rBindings.Invalidate( nSlot );
1129 }
1130 }
1131 break;
1132
1133 case SID_GROW_FONT_SIZE:
1134 case SID_SHRINK_FONT_SIZE:
1135 {
1137 const SvxFontListItem* pFontListItem = static_cast<const SvxFontListItem*>
1138 (pObjSh ? pObjSh->GetItem(SID_ATTR_CHAR_FONTLIST) : nullptr);
1139 const FontList* pFontList = pFontListItem ? pFontListItem->GetFontList() : nullptr;
1140 pEditView->ChangeFontSize( nSlot == SID_GROW_FONT_SIZE, pFontList );
1141 rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
1142 }
1143 break;
1144 }
1145
1146 // apply
1147
1148 EditEngine* pEngine = pEditView->GetEditEngine();
1149 bool bOld = pEngine->SetUpdateLayout(false);
1150
1151 pEditView->SetAttribs( aSet );
1152
1153 pEngine->SetUpdateLayout(bOld);
1155
1156 ScInputHandler* pHdl = GetMyInputHdl();
1157 pHdl->SetModified();
1158
1159 rReq.Done();
1160}
1161
1163{
1165 {
1167 return;
1168 }
1169
1170 SfxItemSet aAttribs = pEditView->GetAttribs();
1171 rSet.Put( aAttribs );
1172
1173 // choose font info according to selection script type
1174
1176 if (nScript == SvtScriptType::NONE) nScript = ScGlobal::GetDefaultScriptType();
1177
1178 // #i55929# input-language-dependent script type (depends on input language if nothing selected)
1179 SvtScriptType nInputScript = nScript;
1180 if ( !pEditView->GetSelection().HasRange() )
1181 {
1183 if (nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
1184 nInputScript = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
1185 }
1186
1187 // #i55929# according to spec, nInputScript is used for font and font height only
1188 if ( rSet.GetItemState( EE_CHAR_FONTINFO ) != SfxItemState::UNKNOWN )
1189 ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_FONTINFO, nInputScript );
1190 if ( rSet.GetItemState( EE_CHAR_FONTHEIGHT ) != SfxItemState::UNKNOWN )
1191 ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_FONTHEIGHT, nInputScript );
1192 if ( rSet.GetItemState( EE_CHAR_WEIGHT ) != SfxItemState::UNKNOWN )
1193 ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_WEIGHT, nScript );
1194 if ( rSet.GetItemState( EE_CHAR_ITALIC ) != SfxItemState::UNKNOWN )
1195 ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_ITALIC, nScript );
1196
1197 // underline
1198 SfxItemState eState = aAttribs.GetItemState( EE_CHAR_UNDERLINE );
1199 if ( eState == SfxItemState::DONTCARE )
1200 {
1201 rSet.InvalidateItem( SID_ULINE_VAL_NONE );
1202 rSet.InvalidateItem( SID_ULINE_VAL_SINGLE );
1203 rSet.InvalidateItem( SID_ULINE_VAL_DOUBLE );
1204 rSet.InvalidateItem( SID_ULINE_VAL_DOTTED );
1205 }
1206 else
1207 {
1208 FontLineStyle eUnderline = aAttribs.Get(EE_CHAR_UNDERLINE).GetLineStyle();
1209 rSet.Put(SfxBoolItem(SID_ULINE_VAL_SINGLE, eUnderline == LINESTYLE_SINGLE));
1210 rSet.Put(SfxBoolItem(SID_ULINE_VAL_DOUBLE, eUnderline == LINESTYLE_DOUBLE));
1211 rSet.Put(SfxBoolItem(SID_ULINE_VAL_DOTTED, eUnderline == LINESTYLE_DOTTED));
1212 rSet.Put(SfxBoolItem(SID_ULINE_VAL_NONE, eUnderline == LINESTYLE_NONE));
1213 }
1214
1216 ScInputHandler* pHdl = GetMyInputHdl();
1217 if ( pHdl && pHdl->IsFormulaMode() )
1218 rSet.ClearItem( EE_CHAR_WEIGHT ); // Highlighted brace not here
1219
1220 SvxEscapement eEsc = static_cast<SvxEscapement>(aAttribs.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
1221 rSet.Put(SfxBoolItem(SID_SET_SUPER_SCRIPT, eEsc == SvxEscapement::Superscript));
1222 rSet.Put(SfxBoolItem(SID_SET_SUB_SCRIPT, eEsc == SvxEscapement::Subscript));
1223 rViewData.GetBindings().Invalidate( SID_SET_SUPER_SCRIPT );
1224 rViewData.GetBindings().Invalidate( SID_SET_SUB_SCRIPT );
1225
1226 eState = aAttribs.GetItemState( EE_CHAR_KERNING );
1227 rViewData.GetBindings().Invalidate( SID_ATTR_CHAR_KERNING );
1228 if ( eState == SfxItemState::DONTCARE )
1229 {
1231 }
1232}
1233
1234OUString ScEditShell::GetSelectionText( bool bWholeWord )
1235{
1236 OUString aStrSelection;
1237
1239 {
1240 if ( bWholeWord )
1241 {
1242 EditEngine* pEngine = pEditView->GetEditEngine();
1244 OUString aStrCurrentDelimiters = pEngine->GetWordDelimiters();
1245
1246 pEngine->SetWordDelimiters(" .,;\"'");
1247 aStrSelection = pEngine->GetWord( aSel.nEndPara, aSel.nEndPos );
1248 pEngine->SetWordDelimiters( aStrCurrentDelimiters );
1249 }
1250 else
1251 {
1252 aStrSelection = pEditView->GetSelected();
1253 }
1254 }
1255
1256 return aStrSelection;
1257}
1258
1260{
1261 // Undo must be handled here because it's called for both EditViews
1262
1263 ScInputHandler* pHdl = GetMyInputHdl();
1264 OSL_ENSURE(pHdl,"no ScInputHandler");
1265 EditView* pTopView = pHdl->GetTopView();
1266 EditView* pTableView = pHdl->GetTableView();
1267 OSL_ENSURE(pTableView,"no EditView");
1268
1269 pHdl->DataChanging();
1270
1271 const SfxItemSet* pReqArgs = rReq.GetArgs();
1272 sal_uInt16 nSlot = rReq.GetSlot();
1273 switch ( nSlot )
1274 {
1275 case SID_UNDO:
1276 case SID_REDO:
1277 {
1278 bool bIsUndo = ( nSlot == SID_UNDO );
1279
1280 sal_uInt16 nCount = 1;
1281 const SfxPoolItem* pItem;
1282 if ( pReqArgs && pReqArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET )
1283 nCount = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1284
1285 for (sal_uInt16 i=0; i<nCount; i++)
1286 {
1287 if ( bIsUndo )
1288 {
1289 pTableView->Undo();
1290 if (pTopView)
1291 pTopView->Undo();
1292 }
1293 else
1294 {
1295 pTableView->Redo();
1296 if (pTopView)
1297 pTopView->Redo();
1298 }
1299 }
1300 }
1301 break;
1302 }
1304
1305 pHdl->DataChanged();
1306}
1307
1309{
1310 // Undo state is taken from normal ViewFrame state function
1311
1313 if ( GetUndoManager() )
1314 {
1315 SfxWhichIter aIter(rSet);
1316 sal_uInt16 nWhich = aIter.FirstWhich();
1317 while( nWhich )
1318 {
1319 rViewFrm.GetSlotState( nWhich, nullptr, &rSet );
1320 nWhich = aIter.NextWhich();
1321 }
1322 }
1323
1324 // disable if no action in input line EditView
1325
1326 ScInputHandler* pHdl = GetMyInputHdl();
1327 OSL_ENSURE(pHdl,"no ScInputHandler");
1328 EditView* pTopView = pHdl->GetTopView();
1329 if (pTopView)
1330 {
1331 SfxUndoManager& rTopMgr = pTopView->GetEditEngine()->GetUndoManager();
1332 if ( rTopMgr.GetUndoActionCount() == 0 )
1333 rSet.DisableItem( SID_UNDO );
1334 if ( rTopMgr.GetRedoActionCount() == 0 )
1335 rSet.DisableItem( SID_REDO );
1336 }
1337}
1338
1340{
1342 if ( nType == TransliterationFlags::NONE )
1343 return;
1344
1345 ScInputHandler* pHdl = GetMyInputHdl();
1346 assert(pHdl && "no ScInputHandler");
1347
1348 EditView* pTopView = pHdl->GetTopView();
1349 EditView* pTableView = pHdl->GetTableView();
1350 assert(pTableView && "no EditView");
1351
1352 pHdl->DataChanging();
1353
1354 pTableView->TransliterateText( nType );
1355 if (pTopView)
1356 pTopView->TransliterateText( nType );
1357
1358 pHdl->DataChanged();
1359}
1360
1361/* 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:492
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:659
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:854
EditView * pEditView
Definition: editsh.hxx:39
void ExecuteUndo(const SfxRequest &rReq)
Definition: editsh.cxx:1259
bool bPastePossible
Definition: editsh.hxx:42
ScInputHandler * GetMyInputHdl()
Definition: editsh.cxx:116
void GetUndoState(SfxItemSet &rSet)
Definition: editsh.cxx:1308
ScViewData & rViewData
Definition: editsh.hxx:40
virtual ~ScEditShell() override
Definition: editsh.cxx:104
void ExecuteAttr(SfxRequest &rReq)
Definition: editsh.cxx:942
std::optional< bool > moAtContextMenu_DisableEditHyperlink
Definition: editsh.hxx:49
bool bIsInsertMode
Definition: editsh.hxx:43
OUString GetSelectionText(bool bWholeWord)
Definition: editsh.cxx:1234
ScEditShell(EditView *pView, ScViewData &rData)
Definition: editsh.cxx:92
void GetAttrState(SfxItemSet &rSet)
Definition: editsh.cxx:1162
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:1339
void SetEditView(EditView *pView)
Definition: editsh.cxx:121
void Execute(SfxRequest &rReq)
Definition: editsh.cxx:158
void GetClipState(SfxItemSet &rSet)
Definition: editsh.cxx:881
static void OpenURL(const OUString &rURL, const OUString &rTarget, bool bIgnoreSettings=false)
Open the specified URL.
Definition: global.cxx:810
static SC_DLLPUBLIC SvtScriptType GetDefaultScriptType()
Definition: global.cxx:900
void SetModified()
Definition: inputhdl.hxx:246
void DataChanged(bool bFromTopNotify=false, bool bSetModified=true)
Definition: inputhdl.cxx:2722
EditView * GetTopView()
Definition: inputhdl.hxx:239
EditView * GetActiveView()
Definition: inputhdl.cxx:2355
bool IsFormulaMode() const
Definition: inputhdl.hxx:263
bool DataChanging(sal_Unicode cTyped=0, bool bFromCommand=false)
Definition: inputhdl.cxx:2710
EditView * GetTableView()
Definition: inputhdl.hxx:238
void SetSelIsRef(bool bSet)
Definition: inputhdl.hxx:249
static bool HasThesaurusLanguage(LanguageType nLang)
Definition: scmod.cxx:2280
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:3162
ScTabViewShell * GetViewShell() const
Definition: viewdata.hxx:357
ScSplitPos GetActivePart() const
Definition: viewdata.hxx:398
weld::Window * GetDialogParent()
Definition: viewdata.cxx:3156
SfxObjectShell * GetSfxDocShell() const
Definition: viewdata.hxx:358
ScAddress GetCurPos() const
Definition: viewdata.cxx:4119
SfxBindings & GetBindings()
Definition: viewdata.cxx:3134
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 SAL_WARN_UNUSED_RESULT 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 SAL_WARN_UNUSED_RESULT 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)
int nCount
IMPL_LINK(ScEditShell, ClipboardChanged, TransferableDataHelper *, pDataHelper, void)
Definition: editsh.cxx:868
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:933
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< 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:247
#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