31#include <editeng/editeng.hxx>
67#include <document.hxx>
75#define ShellClass_ScEditShell
89 GetStaticInterface()->RegisterPopupMenu(
"celledit");
95 bPastePossible (false),
138 nViewShellId = pViewSh->GetViewShellId();
151 OUString aString( cChar );
161 sal_uInt16 nSlot = rReq.
GetSlot();
165 OSL_ENSURE(pHdl,
"no ScInputHandler");
170 OSL_ENSURE(pTableView,
"no EditView :-(");
183 bool bSetSelIsRef =
false;
184 bool bSetModified =
true;
188 case SID_ATTR_INSERT:
189 case FID_INS_CELL_CONTENTS:
199 OUString aReplaceText;
203 if (!aReplaceText.isEmpty())
210 bSetModified =
false;
225 pTableView->
SetControlWord(nControl | EVControlBits::SINGLELINEPASTE);
239 case SID_CELL_FORMAT_RESET:
245 case SID_CLIPBOARD_FORMAT_ITEMS:
249 if ( pReqArgs && pReqArgs->
GetItemState(nSlot,
true, &pItem) == SfxItemState::SET )
250 if (
auto pIntItem =
dynamic_cast<const SfxUInt32Item*
>( pItem))
253 if ( nFormat != SotClipboardFormatId::NONE )
255 if (SotClipboardFormatId::STRING == nFormat)
266 case SID_PASTE_SPECIAL:
271 pDlg->Insert( SotClipboardFormatId::STRING, OUString() );
272 pDlg->Insert( SotClipboardFormatId::RTF, OUString() );
273 pDlg->Insert( SotClipboardFormatId::RICHTEXT, OUString() );
284 if (!
SC_MOD()->IsInputMode())
287 if (nFormat != SotClipboardFormatId::NONE)
289 if (SotClipboardFormatId::STRING == nFormat)
299 pViewWindow->GrabFocus();
303 case SID_PASTE_UNFORMATTED:
311 pViewWindow->GrabFocus();
326 rBindings.
Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
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 );
339 case SID_UNICODE_NOTATION_TOGGLE:
344 OUString sInput = pEngine->
GetText();
353 sal_Int32 nUtf16Pos=0;
354 while( (nUtf16Pos < sInput.getLength()) && (nUtf16Pos < aSel.
nEndPos) )
356 sInput.iterateCodePoints(&nUtf16Pos);
362 while( nUtf16Pos && aToggle.
AllowMoreInput( sInput[nUtf16Pos-1]) )
365 if( !sReplacement.isEmpty() )
386 auto const attribs = pTableView->
GetAttribs();
388 attribs.Get(nFontWhich));
391 std::shared_ptr<SvxFontItem> aNewItem(std::make_shared<SvxFontItem>(
EE_CHAR_FONTINFO));
404 const OUString& aFontName(pFontItem->
GetValue());
407 aNewItem = std::make_shared<SvxFontItem>(
414 aNewItem.reset(rItem.
Clone());
425 if (!
SC_MOD()->IsInputMode())
429 if ( !aString.isEmpty() )
435 nSetScript = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
442 aSet.
Put( aSetItem.GetItemSet(),
false );
451 SfxStringItem aFontItem( SID_ATTR_SPECIALCHAR, aNewItem->GetFamilyName() );
459 pViewWindow->GrabFocus();
463 case FID_INSERT_NAME:
468 short nRet = pDlg->Execute();
472 if (!
SC_MOD()->IsInputMode())
477 std::vector<OUString> aNames = pDlg->GetSelectedNames();
481 for (
const auto& rName : aNames)
485 const OUString s =
aBuffer.makeStringAndClear();
494 pViewWindow->GrabFocus();
498 case SID_CHAR_DLG_EFFECT:
509 if (nSlot == SID_CHAR_DLG_EFFECT)
511 pDlg->SetCurPageId(
"fonteffects");
513 short nRet = pDlg->Execute();
517 if (!
SC_MOD()->IsInputMode())
533 OUString aText = pEngine->
GetText();
541 const OUString& aNew = aFinder.
GetText();
558 case SID_HYPERLINK_SETLINK:
562 if ( pReqArgs->
GetItemState( SID_HYPERLINK_SETLINK,
true, &pItem ) == SfxItemState::SET )
565 const OUString& rName = pHyper->
GetName();
566 const OUString& rURL = pHyper->
GetURL();
586 SvxURLField aURLField( rURL, rName, SvxURLFormat::Repr );
611 InsertURL( rName, rURL,
rTarget,
static_cast<sal_uInt16
>(
eMode) );
620 case SID_OPEN_HYPERLINK:
627 case SID_EDIT_HYPERLINK:
632 SID_HYPERLINK_DIALOG);
635 case SID_COPY_HYPERLINK_LOCATION:
640 uno::Reference<datatransfer::clipboard::XClipboard> xClipboard
646 case SID_REMOVE_HYPERLINK:
652 case FN_INSERT_SOFT_HYPHEN:
655 case FN_INSERT_HARDHYPHEN:
658 case FN_INSERT_HARD_SPACE:
661 case FN_INSERT_NNBSP:
670 case SID_INSERT_ZWSP:
676 case SID_INSERT_FIELD_SHEET:
683 case SID_INSERT_FIELD_TITLE:
690 case SID_INSERT_FIELD_DATE_VAR:
752 case SID_ATTR_INSERT:
771 case SID_HYPERLINK_GETLINK:
781 else if ( pActiveView )
785 sReturn = sReturn.copy(0, std::min(sReturn.getLength(),
static_cast<sal_Int32
>(255)));
792 case SID_OPEN_HYPERLINK:
793 case SID_EDIT_HYPERLINK:
794 case SID_COPY_HYPERLINK_LOCATION:
795 case SID_REMOVE_HYPERLINK:
797 bool bDisableEditHyperlink;
808 if (bDisableEditHyperlink)
813 case SID_TRANSLITERATE_HALFWIDTH:
814 case SID_TRANSLITERATE_FULLWIDTH:
815 case SID_TRANSLITERATE_HIRAGANA:
816 case SID_TRANSLITERATE_KATAKANA:
826 bool bIsLookUpWord = pActiveView &&
832 if (!bIsLookUpWord || !bCanDoThesaurus)
836 case SID_INSERT_FIELD_SHEET:
837 case SID_INSERT_FIELD_TITLE:
838 case SID_INSERT_FIELD_DATE_VAR:
862 if (
auto pURLField =
dynamic_cast<const SvxURLField*
>(pField))
870 bPastePossible = ( pDataHelper->HasFormat( SotClipboardFormatId::STRING )
871 || pDataHelper->HasFormat( SotClipboardFormatId::RTF )
872 || pDataHelper->HasFormat( SotClipboardFormatId::RICHTEXT ));
877 rBindings.
Invalidate( SID_PASTE_UNFORMATTED );
878 rBindings.
Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
895 || aDataHelper.
HasFormat( SotClipboardFormatId::RTF )
896 || aDataHelper.
HasFormat( SotClipboardFormatId::RICHTEXT ) );
906 case SID_PASTE_SPECIAL:
907 case SID_PASTE_UNFORMATTED:
911 case SID_CLIPBOARD_FORMAT_ITEMS:
918 if ( aDataHelper.
HasFormat( SotClipboardFormatId::STRING ) )
920 if ( aDataHelper.
HasFormat( SotClipboardFormatId::RTF ) )
935 rBindings.
Invalidate( SID_ATTR_CHAR_UNDERLINE );
947 sal_uInt16 nSlot = rReq.
GetSlot();
951 case SID_ATTR_CHAR_FONTHEIGHT:
952 case SID_ATTR_CHAR_FONT:
957 SvtScriptType nScript = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
958 if (nSlot == SID_ATTR_CHAR_FONT)
966 sal_uInt16 nWhich = rPool.
GetWhich( nSlot );
969 aSet.
Put( aSetItem.GetItemSet(),
false );
974 case SID_ATTR_CHAR_COLOR:
986 case SID_ATTR_CHAR_WEIGHT:
989 SvtScriptType nScript = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
1003 aSet.
Put( aSetItem.GetItemSet(),
false );
1009 case SID_ATTR_CHAR_POSTURE:
1012 SvtScriptType nScript = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
1026 aSet.
Put( aSetItem.GetItemSet(),
false );
1032 case SID_ULINE_VAL_NONE:
1037 case SID_ATTR_CHAR_UNDERLINE:
1038 case SID_ULINE_VAL_SINGLE:
1039 case SID_ULINE_VAL_DOUBLE:
1040 case SID_ULINE_VAL_DOTTED:
1046 case SID_ATTR_CHAR_UNDERLINE:
1057 case SID_ULINE_VAL_SINGLE:
1060 case SID_ULINE_VAL_DOUBLE:
1063 case SID_ULINE_VAL_DOTTED:
1072 case SID_ATTR_CHAR_OVERLINE:
1081 case SID_ATTR_CHAR_STRIKEOUT:
1089 case SID_ATTR_CHAR_SHADOWED:
1097 case SID_ATTR_CHAR_CONTOUR:
1105 case SID_SET_SUPER_SCRIPT:
1109 SvxEscapement::Off : SvxEscapement::Superscript;
1114 case SID_SET_SUB_SCRIPT:
1118 SvxEscapement::Off : SvxEscapement::Subscript;
1123 case SID_ATTR_CHAR_KERNING:
1133 case SID_GROW_FONT_SIZE:
1134 case SID_SHRINK_FONT_SIZE:
1138 (pObjSh ? pObjSh->
GetItem(SID_ATTR_CHAR_FONTLIST) :
nullptr);
1141 rBindings.
Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
1199 if ( eState == SfxItemState::DONTCARE )
1228 if ( eState == SfxItemState::DONTCARE )
1236 OUString aStrSelection;
1256 return aStrSelection;
1264 OSL_ENSURE(pHdl,
"no ScInputHandler");
1267 OSL_ENSURE(pTableView,
"no EditView");
1272 sal_uInt16 nSlot = rReq.
GetSlot();
1278 bool bIsUndo = ( nSlot == SID_UNDO );
1282 if ( pReqArgs && pReqArgs->
GetItemState( nSlot,
true, &pItem ) == SfxItemState::SET )
1327 OSL_ENSURE(pHdl,
"no ScInputHandler");
1342 if (
nType == TransliterationFlags::NONE )
1346 assert(pHdl &&
"no ScInputHandler");
1350 assert(pTableView &&
"no EditView");
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 ChangeFontSize(bool bGrow, const FontList *pList)
void RemoveAttribs(bool bRemoveParaAttribs=false, sal_uInt16 nWhich=0)
void SelectFieldAtCursor()
void SetSelection(const ESelection &rNewSel)
void InsertText(const OUString &rNew, bool bSelect=false, bool bLOKShowSelect=true)
const SfxItemSet & GetEmptyItemSet() const
SvtScriptType GetSelectedScriptType() const
vcl::Window * GetWindow() const
const SvxFieldData * GetFieldAtCursor() const
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)
OUString GetSelected() const
void SetAttribs(const SfxItemSet &rSet)
virtual VclPtr< AbstractScNamePasteDlg > CreateScNamePasteDlg(weld::Window *pParent, ScDocShell *pShell)=0
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
virtual VclPtr< SfxAbstractTabDialog > CreateScCharDlg(weld::Window *pParent, const SfxItemSet *pAttr, const SfxObjectShell *pDocShell, bool bDrawText)=0
bool HasStringWeakCharacters(const OUString &rString)
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
SC_DLLPUBLIC SvtScriptType GetStringScriptType(const OUString &rString)
void RepeatDefaults()
Re-apply existing defaults if set, same as in SetText, but without EnableUndo/SetUpdateMode.
rtl::Reference< TransferableClipboardListener > mxClipEvtLstnr
bool ShouldDisableEditHyperlink() const
return true if "Edit Hyperlink" in context menu should be disabled
const SvxURLField * GetURLField()
void ExecuteUndo(const SfxRequest &rReq)
ScInputHandler * GetMyInputHdl()
void GetUndoState(SfxItemSet &rSet)
virtual ~ScEditShell() override
void ExecuteAttr(SfxRequest &rReq)
std::optional< bool > moAtContextMenu_DisableEditHyperlink
OUString GetSelectionText(bool bWholeWord)
ScEditShell(EditView *pView, ScViewData &rData)
void GetAttrState(SfxItemSet &rSet)
void EnableEditHyperlink()
force "Edit Hyperlink" to true, with the expectation that SID_EDIT_HYPERLINK is later Invalidated to ...
void GetState(SfxItemSet &rSet)
void ExecuteTrans(const SfxRequest &rReq)
void SetEditView(EditView *pView)
void Execute(SfxRequest &rReq)
void GetClipState(SfxItemSet &rSet)
static void OpenURL(const OUString &rURL, const OUString &rTarget, bool bIgnoreSettings=false)
Open the specified URL.
static SC_DLLPUBLIC SvtScriptType GetDefaultScriptType()
static bool HasThesaurusLanguage(LanguageType nLang)
void ToggleRel(sal_Int32 nStartPos, sal_Int32 nEndPos)
sal_Int32 GetFound() const
const OUString & GetText() const
sal_Int32 GetSelEnd() const
sal_Int32 GetSelStart() const
static ScTabViewShell * GetActiveViewShell()
ScDocument & GetDocument() const
ScDocShell * GetDocShell() const
ScGridWindow * GetActiveWin()
ScTabViewShell * GetViewShell() const
ScSplitPos GetActivePart() const
weld::Window * GetDialogParent()
SfxObjectShell * GetSfxDocShell() const
ScAddress GetCurPos() const
SfxBindings & GetBindings()
bool HasEditView(ScSplitPos eWhich) const
static TransliterationFlags GetTransliterationType(sal_uInt16 nSlotID)
static void ExecuteCharMap(const SvxFontItem &rOldFont, const ScTabViewShell &rShell)
static void HideDisabledSlot(SfxItemSet &rSet, SfxBindings &rBindings, sal_uInt16 nSlotId)
static void PutItemScript(SfxItemSet &rShellSet, const SfxItemSet &rCoreSet, sal_uInt16 nWhichId, SvtScriptType nScript)
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)
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()
static SvxAbstractDialogFactory * Create()
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)
static const OUString & GetContextName(const Context eContext)
FontFamily GetFamilyType()
const OUString & GetStyleName() const
const OUString & GetFamilyName() const
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)
IMPL_LINK(ScEditShell, ClipboardChanged, TransferableDataHelper *, pDataHelper, void)
static void lcl_RemoveAttribs(EditView &rEditView)
static void lclInsertCharacter(EditView *pTableView, EditView *pTopView, sal_Unicode cChar)
static void lcl_InvalidateUnder(SfxBindings &rBindings)
static void lcl_DisableAll(SfxItemSet &rSet)
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)
const sal_Unicode CHAR_RLM
const sal_Unicode CHAR_NBHY
const sal_Unicode CHAR_SHY
const sal_Unicode CHAR_NBSP
const sal_Unicode CHAR_LRM
const sal_Unicode CHAR_ZWSP
const sal_Unicode CHAR_NNBSP
const sal_Unicode CHAR_WJ
#define LANGUAGE_DONTKNOW
#define LINK(Instance, Class, Member)
SvtScriptType GetScriptTypeOfLanguage(LanguageType nLang)
OString stripEnd(const OString &rIn, char c)
void ReplaceTextWithSynonym(EditView &rEditView, const OUString &rSynonmText)
bool GetStatusValueForThesaurusFromContext(OUString &rStatusVal, LanguageType &rLang, const EditView &rEditView)
OUString ScResId(TranslateId aId)
constexpr TypedWhichId< SvxFontItem > ATTR_FONT(100)
#define SFX_IMPL_INTERFACE(Class, SuperClass)
std::unique_ptr< char[]> aBuffer