1b3f79822SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file 5b3f79822SAndrew Rist * distributed with this work for additional information 6b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the 8b3f79822SAndrew Rist * "License"); you may not use this file except in compliance 9b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at 10b3f79822SAndrew Rist * 11b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12b3f79822SAndrew Rist * 13b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing, 14b3f79822SAndrew Rist * software distributed under the License is distributed on an 15b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16b3f79822SAndrew Rist * KIND, either express or implied. See the License for the 17b3f79822SAndrew Rist * specific language governing permissions and limitations 18b3f79822SAndrew Rist * under the License. 19b3f79822SAndrew Rist * 20b3f79822SAndrew Rist *************************************************************/ 21b3f79822SAndrew Rist 22b3f79822SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sc.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir 29cdf0e10cSrcweir //------------------------------------------------------------------ 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <com/sun/star/linguistic2/XThesaurus.hpp> 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include "scitems.hxx" 34cdf0e10cSrcweir #include <editeng/eeitem.hxx> 35cdf0e10cSrcweir 36cdf0e10cSrcweir #include <svx/clipfmtitem.hxx> 37cdf0e10cSrcweir #include <svx/svxdlg.hxx> 38cdf0e10cSrcweir #include <editeng/cntritem.hxx> 39cdf0e10cSrcweir #include <editeng/outliner.hxx> 40cdf0e10cSrcweir #include <editeng/unolingu.hxx> 41cdf0e10cSrcweir #include <editeng/crsditem.hxx> 42cdf0e10cSrcweir #include <editeng/editeng.hxx> 43cdf0e10cSrcweir #include <editeng/editview.hxx> 44cdf0e10cSrcweir #include <editeng/escpitem.hxx> 45cdf0e10cSrcweir #include <editeng/flditem.hxx> 46cdf0e10cSrcweir #include <editeng/fontitem.hxx> 47cdf0e10cSrcweir #include <svx/hlnkitem.hxx> 48*f120fe41SAndre Fischer #include <sfx2/sidebar/EnumContext.hxx> 49cdf0e10cSrcweir #include <editeng/postitem.hxx> 50cdf0e10cSrcweir #include <editeng/scripttypeitem.hxx> 51cdf0e10cSrcweir #include <editeng/shdditem.hxx> 52cdf0e10cSrcweir #include <svl/srchitem.hxx> 53cdf0e10cSrcweir #include <editeng/udlnitem.hxx> 54cdf0e10cSrcweir #include <editeng/wghtitem.hxx> 55cdf0e10cSrcweir #include <sfx2/basedlgs.hxx> 56cdf0e10cSrcweir #include <sfx2/bindings.hxx> 57cdf0e10cSrcweir #include <sfx2/msg.hxx> 58cdf0e10cSrcweir #include <sfx2/objface.hxx> 59cdf0e10cSrcweir #include <sfx2/objsh.hxx> 60cdf0e10cSrcweir #include <sfx2/request.hxx> 61cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 62cdf0e10cSrcweir #include <sot/exchange.hxx> 63cdf0e10cSrcweir #include <svtools/cliplistener.hxx> 64cdf0e10cSrcweir #include <svl/whiter.hxx> 65cdf0e10cSrcweir #include <vcl/msgbox.hxx> 66cdf0e10cSrcweir #include <vcl/sound.hxx> 67cdf0e10cSrcweir #include <sot/formats.hxx> 68cdf0e10cSrcweir #include <svtools/transfer.hxx> 69cdf0e10cSrcweir #include <svl/stritem.hxx> 70cdf0e10cSrcweir 71cdf0e10cSrcweir #define _EDITSH_CXX 72cdf0e10cSrcweir #include "editsh.hxx" 73cdf0e10cSrcweir 74cdf0e10cSrcweir #include "scresid.hxx" 75cdf0e10cSrcweir #include "global.hxx" 76cdf0e10cSrcweir #include "sc.hrc" 77cdf0e10cSrcweir #include "scmod.hxx" 78cdf0e10cSrcweir #include "inputhdl.hxx" 79cdf0e10cSrcweir #include "viewutil.hxx" 80cdf0e10cSrcweir #include "viewdata.hxx" 81cdf0e10cSrcweir #include "document.hxx" 82cdf0e10cSrcweir //CHINA001 #include "namepast.hxx" 83cdf0e10cSrcweir #include "reffind.hxx" 84cdf0e10cSrcweir #include "tabvwsh.hxx" 85cdf0e10cSrcweir //CHINA001 #include "textdlgs.hxx" 86cdf0e10cSrcweir #include "editutil.hxx" 87cdf0e10cSrcweir #include "globstr.hrc" 88cdf0e10cSrcweir 89cdf0e10cSrcweir #define ScEditShell 90cdf0e10cSrcweir #include "scslots.hxx" 91cdf0e10cSrcweir 92cdf0e10cSrcweir #include "scui_def.hxx" //CHINA001 93cdf0e10cSrcweir #include "scabstdlg.hxx" //CHINA001 94cdf0e10cSrcweir 95cdf0e10cSrcweir 96cdf0e10cSrcweir using namespace ::com::sun::star; 97cdf0e10cSrcweir 98cdf0e10cSrcweir 99cdf0e10cSrcweir TYPEINIT1( ScEditShell, SfxShell ); 100cdf0e10cSrcweir 101cdf0e10cSrcweir SFX_IMPL_INTERFACE(ScEditShell, SfxShell, ScResId(SCSTR_EDITSHELL)) 102cdf0e10cSrcweir { 103cdf0e10cSrcweir SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_EDIT) ); 104cdf0e10cSrcweir } 105cdf0e10cSrcweir 106cdf0e10cSrcweir 107cdf0e10cSrcweir ScEditShell::ScEditShell(EditView* pView, ScViewData* pData) : 108cdf0e10cSrcweir pEditView (pView), 109cdf0e10cSrcweir pViewData (pData), 110cdf0e10cSrcweir pClipEvtLstnr (NULL), 111cdf0e10cSrcweir bPastePossible (sal_False), 112cdf0e10cSrcweir bIsInsertMode (sal_True) 113cdf0e10cSrcweir { 114cdf0e10cSrcweir SetPool( pEditView->GetEditEngine()->GetEmptyItemSet().GetPool() ); 115cdf0e10cSrcweir SetUndoManager( &pEditView->GetEditEngine()->GetUndoManager() ); 116cdf0e10cSrcweir SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("EditCell"))); 117*f120fe41SAndre Fischer SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_EditCell)); 118cdf0e10cSrcweir } 119cdf0e10cSrcweir 120cdf0e10cSrcweir ScEditShell::~ScEditShell() 121cdf0e10cSrcweir { 122cdf0e10cSrcweir if ( pClipEvtLstnr ) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir pClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), sal_False ); 125cdf0e10cSrcweir 126cdf0e10cSrcweir // #122057# The listener may just now be waiting for the SolarMutex and call the link 127cdf0e10cSrcweir // afterwards, in spite of RemoveListener. So the link has to be reset, too. 128cdf0e10cSrcweir pClipEvtLstnr->ClearCallbackLink(); 129cdf0e10cSrcweir 130cdf0e10cSrcweir pClipEvtLstnr->release(); 131cdf0e10cSrcweir } 132cdf0e10cSrcweir } 133cdf0e10cSrcweir 134cdf0e10cSrcweir ScInputHandler* ScEditShell::GetMyInputHdl() 135cdf0e10cSrcweir { 136cdf0e10cSrcweir return SC_MOD()->GetInputHdl( pViewData->GetViewShell() ); 137cdf0e10cSrcweir } 138cdf0e10cSrcweir 139cdf0e10cSrcweir void ScEditShell::SetEditView(EditView* pView) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir pEditView = pView; 142cdf0e10cSrcweir pEditView->SetInsertMode( bIsInsertMode ); 143cdf0e10cSrcweir SetPool( pEditView->GetEditEngine()->GetEmptyItemSet().GetPool() ); 144cdf0e10cSrcweir SetUndoManager( &pEditView->GetEditEngine()->GetUndoManager() ); 145cdf0e10cSrcweir } 146cdf0e10cSrcweir 147cdf0e10cSrcweir void lcl_RemoveAttribs( EditView& rEditView ) 148cdf0e10cSrcweir { 149cdf0e10cSrcweir ScEditEngineDefaulter* pEngine = static_cast<ScEditEngineDefaulter*>(rEditView.GetEditEngine()); 150cdf0e10cSrcweir 151cdf0e10cSrcweir sal_Bool bOld = pEngine->GetUpdateMode(); 152cdf0e10cSrcweir pEngine->SetUpdateMode(sal_False); 153cdf0e10cSrcweir 154cdf0e10cSrcweir String aName = ScGlobal::GetRscString( STR_UNDO_DELETECONTENTS ); 155cdf0e10cSrcweir pEngine->GetUndoManager().EnterListAction( aName, aName ); 156cdf0e10cSrcweir 157cdf0e10cSrcweir rEditView.RemoveAttribs(sal_True); 158cdf0e10cSrcweir pEngine->RepeatDefaults(); // #97226# paragraph attributes from cell formats must be preserved 159cdf0e10cSrcweir 160cdf0e10cSrcweir pEngine->GetUndoManager().LeaveListAction(); 161cdf0e10cSrcweir 162cdf0e10cSrcweir pEngine->SetUpdateMode(bOld); 163cdf0e10cSrcweir } 164cdf0e10cSrcweir 165cdf0e10cSrcweir void lclInsertCharacter( EditView* pTableView, EditView* pTopView, sal_Unicode cChar ) 166cdf0e10cSrcweir { 167cdf0e10cSrcweir String aString( cChar ); 168cdf0e10cSrcweir if( pTableView ) 169cdf0e10cSrcweir pTableView->InsertText( aString ); 170cdf0e10cSrcweir if( pTopView ) 171cdf0e10cSrcweir pTopView->InsertText( aString ); 172cdf0e10cSrcweir } 173cdf0e10cSrcweir 174cdf0e10cSrcweir void ScEditShell::Execute( SfxRequest& rReq ) 175cdf0e10cSrcweir { 176cdf0e10cSrcweir const SfxItemSet* pReqArgs = rReq.GetArgs(); 177cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot(); 178cdf0e10cSrcweir SfxBindings& rBindings = pViewData->GetBindings(); 179cdf0e10cSrcweir 180cdf0e10cSrcweir ScInputHandler* pHdl = GetMyInputHdl(); 181cdf0e10cSrcweir DBG_ASSERT(pHdl,"kein ScInputHandler"); 182cdf0e10cSrcweir 183cdf0e10cSrcweir EditView* pTopView = pHdl->GetTopView(); // hat Eingabezeile den Focus? 184cdf0e10cSrcweir EditView* pTableView = pHdl->GetTableView(); 185cdf0e10cSrcweir 186cdf0e10cSrcweir DBG_ASSERT(pTableView,"no EditView :-("); 187cdf0e10cSrcweir /* #i91683# No EditView if spell-check dialog is active and positioned on 188cdf0e10cSrcweir * an error and user immediately (without double click or F2) selected a 189cdf0e10cSrcweir * text portion of that cell with the mouse and wanted to modify it. */ 190cdf0e10cSrcweir /* FIXME: Bailing out only cures the symptom and prevents a crash, no edit 191cdf0e10cSrcweir * action is possible. A real fix somehow would need to create a valid 192cdf0e10cSrcweir * EditView from the spell-check view. */ 193cdf0e10cSrcweir if (!pTableView) 194cdf0e10cSrcweir return; 195cdf0e10cSrcweir 196cdf0e10cSrcweir EditEngine* pEngine = pTableView->GetEditEngine(); 197cdf0e10cSrcweir 198cdf0e10cSrcweir pHdl->DataChanging(); 199cdf0e10cSrcweir sal_Bool bSetSelIsRef = sal_False; 200cdf0e10cSrcweir sal_Bool bSetModified = sal_True; 201cdf0e10cSrcweir 202cdf0e10cSrcweir switch ( nSlot ) 203cdf0e10cSrcweir { 204cdf0e10cSrcweir case FID_INS_CELL_CONTENTS: // Insert-Taste, weil als Acc definiert 205cdf0e10cSrcweir bIsInsertMode = !pTableView->IsInsertMode(); 206cdf0e10cSrcweir pTableView->SetInsertMode( bIsInsertMode ); 207cdf0e10cSrcweir if (pTopView) 208cdf0e10cSrcweir pTopView->SetInsertMode( bIsInsertMode ); 209cdf0e10cSrcweir rBindings.Invalidate( SID_ATTR_INSERT ); 210cdf0e10cSrcweir break; 211cdf0e10cSrcweir 212cdf0e10cSrcweir case SID_ATTR_INSERT: 213cdf0e10cSrcweir if ( pReqArgs ) 214cdf0e10cSrcweir { 215cdf0e10cSrcweir bIsInsertMode = ((const SfxBoolItem&)pReqArgs->Get(nSlot)).GetValue(); 216cdf0e10cSrcweir pTableView->SetInsertMode( bIsInsertMode ); 217cdf0e10cSrcweir if (pTopView) 218cdf0e10cSrcweir pTopView->SetInsertMode( bIsInsertMode ); 219cdf0e10cSrcweir rBindings.Invalidate( SID_ATTR_INSERT ); 220cdf0e10cSrcweir } 221cdf0e10cSrcweir break; 222cdf0e10cSrcweir 223cdf0e10cSrcweir case SID_THES: 224cdf0e10cSrcweir { 225cdf0e10cSrcweir String aReplaceText; 226cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES , sal_False ); 227cdf0e10cSrcweir if (pItem2) 228cdf0e10cSrcweir aReplaceText = pItem2->GetValue(); 229cdf0e10cSrcweir if (aReplaceText.Len() > 0) 230cdf0e10cSrcweir ReplaceTextWithSynonym( *pEditView, aReplaceText ); 231cdf0e10cSrcweir } 232cdf0e10cSrcweir break; 233cdf0e10cSrcweir 234cdf0e10cSrcweir case SID_COPY: 235cdf0e10cSrcweir pTableView->Copy(); 236cdf0e10cSrcweir bSetModified = sal_False; 237cdf0e10cSrcweir break; 238cdf0e10cSrcweir 239cdf0e10cSrcweir case SID_CUT: 240cdf0e10cSrcweir pTableView->Cut(); 241cdf0e10cSrcweir if (pTopView) 242cdf0e10cSrcweir pTopView->DeleteSelected(); 243cdf0e10cSrcweir break; 244cdf0e10cSrcweir 245cdf0e10cSrcweir case SID_PASTE: 246cdf0e10cSrcweir pTableView->PasteSpecial(); 247cdf0e10cSrcweir if (pTopView) 248cdf0e10cSrcweir pTopView->Paste(); 249cdf0e10cSrcweir break; 250cdf0e10cSrcweir 251cdf0e10cSrcweir case SID_DELETE: 252cdf0e10cSrcweir pTableView->DeleteSelected(); 253cdf0e10cSrcweir if (pTopView) 254cdf0e10cSrcweir pTopView->DeleteSelected(); 255cdf0e10cSrcweir break; 256cdf0e10cSrcweir 257cdf0e10cSrcweir case SID_CELL_FORMAT_RESET: // "Standard" 258cdf0e10cSrcweir lcl_RemoveAttribs( *pTableView ); 259cdf0e10cSrcweir if ( pTopView ) 260cdf0e10cSrcweir lcl_RemoveAttribs( *pTopView ); 261cdf0e10cSrcweir break; 262cdf0e10cSrcweir 263cdf0e10cSrcweir case SID_CLIPBOARD_FORMAT_ITEMS: 264cdf0e10cSrcweir { 265cdf0e10cSrcweir sal_uLong nFormat = 0; 266cdf0e10cSrcweir const SfxPoolItem* pItem; 267cdf0e10cSrcweir if ( pReqArgs && 268cdf0e10cSrcweir pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET && 269cdf0e10cSrcweir pItem->ISA(SfxUInt32Item) ) 270cdf0e10cSrcweir { 271cdf0e10cSrcweir nFormat = ((const SfxUInt32Item*)pItem)->GetValue(); 272cdf0e10cSrcweir } 273cdf0e10cSrcweir 274cdf0e10cSrcweir if ( nFormat ) 275cdf0e10cSrcweir { 276cdf0e10cSrcweir if (SOT_FORMAT_STRING == nFormat) 277cdf0e10cSrcweir pTableView->Paste(); 278cdf0e10cSrcweir else 279cdf0e10cSrcweir pTableView->PasteSpecial(); 280cdf0e10cSrcweir 281cdf0e10cSrcweir if (pTopView) 282cdf0e10cSrcweir pTopView->Paste(); 283cdf0e10cSrcweir } 284cdf0e10cSrcweir } 285cdf0e10cSrcweir break; 286cdf0e10cSrcweir 287cdf0e10cSrcweir case SID_PASTE_SPECIAL: 288cdf0e10cSrcweir { 289cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 290cdf0e10cSrcweir SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( pViewData->GetDialogParent() ); 291cdf0e10cSrcweir sal_uLong nFormat = 0; 292cdf0e10cSrcweir if ( pDlg ) 293cdf0e10cSrcweir { 294cdf0e10cSrcweir pDlg->Insert( SOT_FORMAT_STRING, EMPTY_STRING ); 295cdf0e10cSrcweir pDlg->Insert( SOT_FORMAT_RTF, EMPTY_STRING ); 296cdf0e10cSrcweir 297cdf0e10cSrcweir TransferableDataHelper aDataHelper( 298cdf0e10cSrcweir TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) ); 299cdf0e10cSrcweir 300cdf0e10cSrcweir nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() ); 301cdf0e10cSrcweir DELETEZ(pDlg); 302cdf0e10cSrcweir } 303cdf0e10cSrcweir 304cdf0e10cSrcweir // while the dialog was open, edit mode may have been stopped 305cdf0e10cSrcweir if (!SC_MOD()->IsInputMode()) 306cdf0e10cSrcweir { 307cdf0e10cSrcweir Sound::Beep(); 308cdf0e10cSrcweir return; 309cdf0e10cSrcweir } 310cdf0e10cSrcweir 311cdf0e10cSrcweir if (nFormat > 0) 312cdf0e10cSrcweir { 313cdf0e10cSrcweir if (SOT_FORMAT_STRING == nFormat) 314cdf0e10cSrcweir pTableView->Paste(); 315cdf0e10cSrcweir else 316cdf0e10cSrcweir pTableView->PasteSpecial(); 317cdf0e10cSrcweir 318cdf0e10cSrcweir if (pTopView) 319cdf0e10cSrcweir pTopView->Paste(); 320cdf0e10cSrcweir } 321cdf0e10cSrcweir 322cdf0e10cSrcweir if (pTopView) 323cdf0e10cSrcweir pTopView->GetWindow()->GrabFocus(); 324cdf0e10cSrcweir } 325cdf0e10cSrcweir break; 326cdf0e10cSrcweir 327cdf0e10cSrcweir case SID_SELECTALL: 328cdf0e10cSrcweir { 329cdf0e10cSrcweir sal_uInt16 nPar = pEngine->GetParagraphCount(); 330cdf0e10cSrcweir if (nPar) 331cdf0e10cSrcweir { 332cdf0e10cSrcweir xub_StrLen nLen = pEngine->GetTextLen(nPar-1); 333cdf0e10cSrcweir pTableView->SetSelection(ESelection(0,0,nPar-1,nLen)); 334cdf0e10cSrcweir if (pTopView) 335cdf0e10cSrcweir pTopView->SetSelection(ESelection(0,0,nPar-1,nLen)); 336cdf0e10cSrcweir } 337cdf0e10cSrcweir bSetModified = sal_False; 338cdf0e10cSrcweir } 339cdf0e10cSrcweir break; 340cdf0e10cSrcweir 341cdf0e10cSrcweir case SID_CHARMAP: 342cdf0e10cSrcweir { 343cdf0e10cSrcweir sal_uInt16 nScript = pTableView->GetSelectedScriptType(); 344cdf0e10cSrcweir sal_uInt16 nFontWhich = ( nScript == SCRIPTTYPE_ASIAN ) ? EE_CHAR_FONTINFO_CJK : 345cdf0e10cSrcweir ( ( nScript == SCRIPTTYPE_COMPLEX ) ? EE_CHAR_FONTINFO_CTL : 346cdf0e10cSrcweir EE_CHAR_FONTINFO ); 347cdf0e10cSrcweir const SvxFontItem& rItem = (const SvxFontItem&) 348cdf0e10cSrcweir pTableView->GetAttribs().Get(nFontWhich); 349cdf0e10cSrcweir 350cdf0e10cSrcweir String aString; 351cdf0e10cSrcweir SvxFontItem aNewItem( EE_CHAR_FONTINFO ); 352cdf0e10cSrcweir 353cdf0e10cSrcweir const SfxItemSet *pArgs = rReq.GetArgs(); 354cdf0e10cSrcweir const SfxPoolItem* pItem = 0; 355cdf0e10cSrcweir if( pArgs ) 356cdf0e10cSrcweir pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), sal_False, &pItem); 357cdf0e10cSrcweir 358cdf0e10cSrcweir if ( pItem ) 359cdf0e10cSrcweir { 360cdf0e10cSrcweir aString = ((const SfxStringItem*)pItem)->GetValue(); 361cdf0e10cSrcweir const SfxPoolItem* pFtItem = NULL; 362cdf0e10cSrcweir pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), sal_False, &pFtItem); 363cdf0e10cSrcweir const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem ); 364cdf0e10cSrcweir if ( pFontItem ) 365cdf0e10cSrcweir { 366cdf0e10cSrcweir String aFontName(pFontItem->GetValue()); 367cdf0e10cSrcweir Font aFont(aFontName, Size(1,1)); // Size nur wg. CTOR 368cdf0e10cSrcweir aNewItem = SvxFontItem( aFont.GetFamily(), aFont.GetName(), 369cdf0e10cSrcweir aFont.GetStyleName(), aFont.GetPitch(), 370cdf0e10cSrcweir aFont.GetCharSet(), ATTR_FONT ); 371cdf0e10cSrcweir } 372cdf0e10cSrcweir else 373cdf0e10cSrcweir aNewItem = rItem; 374cdf0e10cSrcweir } 375cdf0e10cSrcweir else 376cdf0e10cSrcweir { 377cdf0e10cSrcweir ScViewUtil::ExecuteCharMap( rItem, *pViewData->GetViewShell()->GetViewFrame(), aNewItem, aString ); 378cdf0e10cSrcweir 379cdf0e10cSrcweir // while the dialog was open, edit mode may have been stopped 380cdf0e10cSrcweir if (!SC_MOD()->IsInputMode()) 381cdf0e10cSrcweir { 382cdf0e10cSrcweir Sound::Beep(); 383cdf0e10cSrcweir return; 384cdf0e10cSrcweir } 385cdf0e10cSrcweir } 386cdf0e10cSrcweir 387cdf0e10cSrcweir if ( aString.Len() ) 388cdf0e10cSrcweir { 389cdf0e10cSrcweir // if string contains WEAK characters, set all fonts 390cdf0e10cSrcweir sal_uInt8 nSetScript; 391cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 392cdf0e10cSrcweir if ( pDoc->HasStringWeakCharacters( aString ) ) 393cdf0e10cSrcweir nSetScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX; 394cdf0e10cSrcweir else 395cdf0e10cSrcweir nSetScript = pDoc->GetStringScriptType( aString ); 396cdf0e10cSrcweir 397cdf0e10cSrcweir SfxItemSet aSet( pTableView->GetEmptyItemSet() ); 398cdf0e10cSrcweir SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, GetPool() ); 399cdf0e10cSrcweir aSetItem.PutItemForScriptType( nSetScript, aNewItem ); 400cdf0e10cSrcweir aSet.Put( aSetItem.GetItemSet(), sal_False ); 401cdf0e10cSrcweir 402cdf0e10cSrcweir // SetAttribs an der View selektiert ein Wort, wenn nichts selektiert ist 403cdf0e10cSrcweir pTableView->GetEditEngine()->QuickSetAttribs( aSet, pTableView->GetSelection() ); 404cdf0e10cSrcweir pTableView->InsertText(aString); 405cdf0e10cSrcweir if (pTopView) 406cdf0e10cSrcweir pTopView->InsertText(aString); 407cdf0e10cSrcweir 408cdf0e10cSrcweir SfxStringItem aStringItem( SID_CHARMAP, aString ); 409cdf0e10cSrcweir SfxStringItem aFontItem( SID_ATTR_SPECIALCHAR, aNewItem.GetFamilyName() ); 410cdf0e10cSrcweir rReq.AppendItem( aFontItem ); 411cdf0e10cSrcweir rReq.AppendItem( aStringItem ); 412cdf0e10cSrcweir rReq.Done(); 413cdf0e10cSrcweir 414cdf0e10cSrcweir 415cdf0e10cSrcweir } 416cdf0e10cSrcweir 417cdf0e10cSrcweir if (pTopView) 418cdf0e10cSrcweir pTopView->GetWindow()->GrabFocus(); 419cdf0e10cSrcweir } 420cdf0e10cSrcweir break; 421cdf0e10cSrcweir 422cdf0e10cSrcweir case FID_INSERT_NAME: 423cdf0e10cSrcweir { 424cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 425cdf0e10cSrcweir //CHINA001 ScNamePasteDlg* pDlg = new ScNamePasteDlg( pViewData->GetDialogParent(), 426cdf0e10cSrcweir //CHINA001 pDoc->GetRangeName(), sal_False ); 427cdf0e10cSrcweir // "Liste" disablen 428cdf0e10cSrcweir ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 429cdf0e10cSrcweir DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 430cdf0e10cSrcweir 431cdf0e10cSrcweir AbstractScNamePasteDlg* pDlg = pFact->CreateScNamePasteDlg( pViewData->GetDialogParent(), pDoc->GetRangeName(), RID_SCDLG_NAMES_PASTE, sal_False ); 432cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 433cdf0e10cSrcweir short nRet = pDlg->Execute(); 434cdf0e10cSrcweir // pDlg is needed below 435cdf0e10cSrcweir 436cdf0e10cSrcweir // while the dialog was open, edit mode may have been stopped 437cdf0e10cSrcweir if (!SC_MOD()->IsInputMode()) 438cdf0e10cSrcweir { 439cdf0e10cSrcweir Sound::Beep(); 440cdf0e10cSrcweir delete pDlg; 441cdf0e10cSrcweir return; 442cdf0e10cSrcweir } 443cdf0e10cSrcweir 444cdf0e10cSrcweir if ( nRet == BTN_PASTE_NAME ) 445cdf0e10cSrcweir { 446cdf0e10cSrcweir String aName = pDlg->GetSelectedName(); 447cdf0e10cSrcweir pTableView->InsertText(aName); 448cdf0e10cSrcweir if (pTopView) 449cdf0e10cSrcweir pTopView->InsertText(aName); 450cdf0e10cSrcweir } 451cdf0e10cSrcweir delete pDlg; 452cdf0e10cSrcweir 453cdf0e10cSrcweir if (pTopView) 454cdf0e10cSrcweir pTopView->GetWindow()->GrabFocus(); 455cdf0e10cSrcweir } 456cdf0e10cSrcweir break; 457cdf0e10cSrcweir 458cdf0e10cSrcweir case SID_CHAR_DLG: 459cdf0e10cSrcweir { 460cdf0e10cSrcweir SfxItemSet aAttrs( pTableView->GetAttribs() ); 461cdf0e10cSrcweir 462cdf0e10cSrcweir SfxObjectShell* pObjSh = pViewData->GetSfxDocShell(); 463cdf0e10cSrcweir 464cdf0e10cSrcweir //CHINA001 ScCharDlg* pDlg = new ScCharDlg( pViewData->GetDialogParent(), &aAttrs, pObjSh ); 465cdf0e10cSrcweir ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 466cdf0e10cSrcweir DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 467cdf0e10cSrcweir 468cdf0e10cSrcweir SfxAbstractTabDialog* pDlg = pFact->CreateScCharDlg( pViewData->GetDialogParent(), &aAttrs, 469cdf0e10cSrcweir pObjSh, RID_SCDLG_CHAR ); 470cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 471cdf0e10cSrcweir short nRet = pDlg->Execute(); 472cdf0e10cSrcweir // pDlg is needed below 473cdf0e10cSrcweir 474cdf0e10cSrcweir // while the dialog was open, edit mode may have been stopped 475cdf0e10cSrcweir if (!SC_MOD()->IsInputMode()) 476cdf0e10cSrcweir { 477cdf0e10cSrcweir Sound::Beep(); 478cdf0e10cSrcweir delete pDlg; 479cdf0e10cSrcweir return; 480cdf0e10cSrcweir } 481cdf0e10cSrcweir 482cdf0e10cSrcweir if ( nRet == RET_OK ) 483cdf0e10cSrcweir { 484cdf0e10cSrcweir const SfxItemSet* pOut = pDlg->GetOutputItemSet(); 485cdf0e10cSrcweir pTableView->SetAttribs( *pOut ); 486cdf0e10cSrcweir } 487cdf0e10cSrcweir delete pDlg; 488cdf0e10cSrcweir } 489cdf0e10cSrcweir break; 490cdf0e10cSrcweir 491cdf0e10cSrcweir case SID_TOGGLE_REL: 492cdf0e10cSrcweir { 493cdf0e10cSrcweir sal_Bool bOk = sal_False; 494cdf0e10cSrcweir if (pEngine->GetParagraphCount() == 1) 495cdf0e10cSrcweir { 496cdf0e10cSrcweir String aText = pEngine->GetText(); 497cdf0e10cSrcweir ESelection aSel = pEditView->GetSelection(); // aktuelle View 498cdf0e10cSrcweir 499cdf0e10cSrcweir ScRefFinder aFinder( aText, pViewData->GetDocument() ); 500cdf0e10cSrcweir aFinder.ToggleRel( aSel.nStartPos, aSel.nEndPos ); 501cdf0e10cSrcweir if (aFinder.GetFound()) 502cdf0e10cSrcweir { 503cdf0e10cSrcweir String aNew = aFinder.GetText(); 504cdf0e10cSrcweir ESelection aNewSel( 0,aFinder.GetSelStart(), 0,aFinder.GetSelEnd() ); 505cdf0e10cSrcweir pEngine->SetText( aNew ); 506cdf0e10cSrcweir pTableView->SetSelection( aNewSel ); 507cdf0e10cSrcweir if ( pTopView ) 508cdf0e10cSrcweir { 509cdf0e10cSrcweir pTopView->GetEditEngine()->SetText( aNew ); 510cdf0e10cSrcweir pTopView->SetSelection( aNewSel ); 511cdf0e10cSrcweir } 512cdf0e10cSrcweir bOk = sal_True; 513cdf0e10cSrcweir 514cdf0e10cSrcweir // Referenz wird selektiert -> beim Tippen nicht ueberschreiben 515cdf0e10cSrcweir bSetSelIsRef = sal_True; 516cdf0e10cSrcweir } 517cdf0e10cSrcweir } 518cdf0e10cSrcweir if (!bOk) 519cdf0e10cSrcweir Sound::Beep(); // keine Referenzen oder mehrere Absaetze 520cdf0e10cSrcweir } 521cdf0e10cSrcweir break; 522cdf0e10cSrcweir 523cdf0e10cSrcweir case SID_HYPERLINK_SETLINK: 524cdf0e10cSrcweir if( pReqArgs ) 525cdf0e10cSrcweir { 526cdf0e10cSrcweir const SfxPoolItem* pItem; 527cdf0e10cSrcweir if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, sal_True, &pItem ) == SFX_ITEM_SET ) 528cdf0e10cSrcweir { 529cdf0e10cSrcweir const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem; 530cdf0e10cSrcweir const String& rName = pHyper->GetName(); 531cdf0e10cSrcweir const String& rURL = pHyper->GetURL(); 532cdf0e10cSrcweir const String& rTarget = pHyper->GetTargetFrame(); 533cdf0e10cSrcweir SvxLinkInsertMode eMode = pHyper->GetInsertMode(); 534cdf0e10cSrcweir 535cdf0e10cSrcweir sal_Bool bDone = sal_False; 536cdf0e10cSrcweir if ( eMode == HLINK_DEFAULT || eMode == HLINK_FIELD ) 537cdf0e10cSrcweir { 538cdf0e10cSrcweir const SvxURLField* pURLField = GetURLField(); 539cdf0e10cSrcweir if ( pURLField ) 540cdf0e10cSrcweir { 541cdf0e10cSrcweir // altes Feld selektieren 542cdf0e10cSrcweir 543cdf0e10cSrcweir ESelection aSel = pTableView->GetSelection(); 544cdf0e10cSrcweir aSel.Adjust(); 545cdf0e10cSrcweir aSel.nEndPara = aSel.nStartPara; 546cdf0e10cSrcweir aSel.nEndPos = aSel.nStartPos + 1; 547cdf0e10cSrcweir pTableView->SetSelection( aSel ); 548cdf0e10cSrcweir 549cdf0e10cSrcweir // neues Feld einfuegen 550cdf0e10cSrcweir 551cdf0e10cSrcweir SvxURLField aURLField( rURL, rName, SVXURLFORMAT_REPR ); 552cdf0e10cSrcweir aURLField.SetTargetFrame( rTarget ); 553cdf0e10cSrcweir SvxFieldItem aURLItem( aURLField, EE_FEATURE_FIELD ); 554cdf0e10cSrcweir pTableView->InsertField( aURLItem ); 555cdf0e10cSrcweir pTableView->SetSelection( aSel ); // select inserted field 556cdf0e10cSrcweir 557cdf0e10cSrcweir // #57254# jetzt doch auch Felder in der Top-View 558cdf0e10cSrcweir 559cdf0e10cSrcweir if ( pTopView ) 560cdf0e10cSrcweir { 561cdf0e10cSrcweir aSel = pTopView->GetSelection(); 562cdf0e10cSrcweir aSel.nEndPara = aSel.nStartPara; 563cdf0e10cSrcweir aSel.nEndPos = aSel.nStartPos + 1; 564cdf0e10cSrcweir pTopView->SetSelection( aSel ); 565cdf0e10cSrcweir pTopView->InsertField( aURLItem ); 566cdf0e10cSrcweir pTopView->SetSelection( aSel ); // select inserted field 567cdf0e10cSrcweir } 568cdf0e10cSrcweir 569cdf0e10cSrcweir bDone = sal_True; 570cdf0e10cSrcweir } 571cdf0e10cSrcweir } 572cdf0e10cSrcweir 573cdf0e10cSrcweir if (!bDone) 574cdf0e10cSrcweir { 575cdf0e10cSrcweir pViewData->GetViewShell()-> 576cdf0e10cSrcweir InsertURL( rName, rURL, rTarget, (sal_uInt16) eMode ); 577cdf0e10cSrcweir 578cdf0e10cSrcweir // InsertURL an der ViewShell schaltet bei "Button" 579cdf0e10cSrcweir // die EditShell ab, darum sofort return 580cdf0e10cSrcweir 581cdf0e10cSrcweir return; 582cdf0e10cSrcweir } 583cdf0e10cSrcweir } 584cdf0e10cSrcweir } 585cdf0e10cSrcweir break; 586cdf0e10cSrcweir 587cdf0e10cSrcweir case SID_OPEN_HYPERLINK: 588cdf0e10cSrcweir { 589cdf0e10cSrcweir const SvxURLField* pURLField = GetURLField(); 590cdf0e10cSrcweir if ( pURLField ) 591cdf0e10cSrcweir ScGlobal::OpenURL( pURLField->GetURL(), pURLField->GetTargetFrame() ); 592cdf0e10cSrcweir return; 593cdf0e10cSrcweir } 594cdf0e10cSrcweir //break; 595cdf0e10cSrcweir 596cdf0e10cSrcweir case FN_INSERT_SOFT_HYPHEN: 597cdf0e10cSrcweir lclInsertCharacter( pTableView, pTopView, CHAR_SHY ); 598cdf0e10cSrcweir break; 599cdf0e10cSrcweir case FN_INSERT_HARDHYPHEN: 600cdf0e10cSrcweir lclInsertCharacter( pTableView, pTopView, CHAR_NBHY ); 601cdf0e10cSrcweir break; 602cdf0e10cSrcweir case FN_INSERT_HARD_SPACE: 603cdf0e10cSrcweir lclInsertCharacter( pTableView, pTopView, CHAR_NBSP ); 604cdf0e10cSrcweir break; 605cdf0e10cSrcweir case SID_INSERT_RLM: 606cdf0e10cSrcweir lclInsertCharacter( pTableView, pTopView, CHAR_RLM ); 607cdf0e10cSrcweir break; 608cdf0e10cSrcweir case SID_INSERT_LRM: 609cdf0e10cSrcweir lclInsertCharacter( pTableView, pTopView, CHAR_LRM ); 610cdf0e10cSrcweir break; 611cdf0e10cSrcweir case SID_INSERT_ZWSP: 612cdf0e10cSrcweir lclInsertCharacter( pTableView, pTopView, CHAR_ZWSP ); 613cdf0e10cSrcweir break; 614cdf0e10cSrcweir case SID_INSERT_ZWNBSP: 615cdf0e10cSrcweir lclInsertCharacter( pTableView, pTopView, CHAR_ZWNBSP ); 616cdf0e10cSrcweir break; 617cdf0e10cSrcweir } 618cdf0e10cSrcweir 619cdf0e10cSrcweir pHdl->DataChanged(sal_False, bSetModified); 620cdf0e10cSrcweir if (bSetSelIsRef) 621cdf0e10cSrcweir pHdl->SetSelIsRef(sal_True); 622cdf0e10cSrcweir } 623cdf0e10cSrcweir 624cdf0e10cSrcweir void lcl_DisableAll( SfxItemSet& rSet ) // disable all slots 625cdf0e10cSrcweir { 626cdf0e10cSrcweir SfxWhichIter aIter( rSet ); 627cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich(); 628cdf0e10cSrcweir while (nWhich) 629cdf0e10cSrcweir { 630cdf0e10cSrcweir rSet.DisableItem( nWhich ); 631cdf0e10cSrcweir nWhich = aIter.NextWhich(); 632cdf0e10cSrcweir } 633cdf0e10cSrcweir } 634cdf0e10cSrcweir 635cdf0e10cSrcweir void __EXPORT ScEditShell::GetState( SfxItemSet& rSet ) 636cdf0e10cSrcweir { 637cdf0e10cSrcweir // #125326# When deactivating the view, edit mode is stopped, but the EditShell is left active 638cdf0e10cSrcweir // (a shell can't be removed from within Deactivate). In that state, the EditView isn't inserted 639cdf0e10cSrcweir // into the EditEngine, so it can have an invalid selection and must not be used. 640cdf0e10cSrcweir if ( !pViewData->HasEditView( pViewData->GetActivePart() ) ) 641cdf0e10cSrcweir { 642cdf0e10cSrcweir lcl_DisableAll( rSet ); 643cdf0e10cSrcweir return; 644cdf0e10cSrcweir } 645cdf0e10cSrcweir 646cdf0e10cSrcweir ScInputHandler* pHdl = GetMyInputHdl(); 647cdf0e10cSrcweir EditView* pActiveView = pHdl ? pHdl->GetActiveView() : pEditView; 648cdf0e10cSrcweir 649cdf0e10cSrcweir SfxWhichIter aIter( rSet ); 650cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich(); 651cdf0e10cSrcweir while (nWhich) 652cdf0e10cSrcweir { 653cdf0e10cSrcweir switch (nWhich) 654cdf0e10cSrcweir { 655cdf0e10cSrcweir case SID_ATTR_INSERT: // Statuszeile 656cdf0e10cSrcweir { 657cdf0e10cSrcweir if ( pActiveView ) 658cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, pActiveView->IsInsertMode() ) ); 659cdf0e10cSrcweir else 660cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, 42 ) ); 661cdf0e10cSrcweir } 662cdf0e10cSrcweir break; 663cdf0e10cSrcweir 664cdf0e10cSrcweir case SID_HYPERLINK_GETLINK: 665cdf0e10cSrcweir { 666cdf0e10cSrcweir SvxHyperlinkItem aHLinkItem; 667cdf0e10cSrcweir const SvxURLField* pURLField = GetURLField(); 668cdf0e10cSrcweir if ( pURLField ) 669cdf0e10cSrcweir { 670cdf0e10cSrcweir aHLinkItem.SetName( pURLField->GetRepresentation() ); 671cdf0e10cSrcweir aHLinkItem.SetURL( pURLField->GetURL() ); 672cdf0e10cSrcweir aHLinkItem.SetTargetFrame( pURLField->GetTargetFrame() ); 673cdf0e10cSrcweir } 674cdf0e10cSrcweir else if ( pActiveView ) 675cdf0e10cSrcweir { 676cdf0e10cSrcweir // use selected text as name for urls 677cdf0e10cSrcweir String sReturn = pActiveView->GetSelected(); 678cdf0e10cSrcweir sReturn.Erase(255); 679cdf0e10cSrcweir sReturn.EraseTrailingChars(); 680cdf0e10cSrcweir aHLinkItem.SetName(sReturn); 681cdf0e10cSrcweir } 682cdf0e10cSrcweir rSet.Put(aHLinkItem); 683cdf0e10cSrcweir } 684cdf0e10cSrcweir break; 685cdf0e10cSrcweir 686cdf0e10cSrcweir case SID_OPEN_HYPERLINK: 687cdf0e10cSrcweir { 688cdf0e10cSrcweir if ( !GetURLField() ) 689cdf0e10cSrcweir rSet.DisableItem( nWhich ); 690cdf0e10cSrcweir } 691cdf0e10cSrcweir break; 692cdf0e10cSrcweir 693cdf0e10cSrcweir case SID_TRANSLITERATE_HALFWIDTH: 694cdf0e10cSrcweir case SID_TRANSLITERATE_FULLWIDTH: 695cdf0e10cSrcweir case SID_TRANSLITERATE_HIRAGANA: 696cdf0e10cSrcweir case SID_TRANSLITERATE_KATAGANA: 697cdf0e10cSrcweir case SID_INSERT_RLM: 698cdf0e10cSrcweir case SID_INSERT_LRM: 699cdf0e10cSrcweir case SID_INSERT_ZWNBSP: 700cdf0e10cSrcweir case SID_INSERT_ZWSP: 701cdf0e10cSrcweir ScViewUtil::HideDisabledSlot( rSet, pViewData->GetBindings(), nWhich ); 702cdf0e10cSrcweir break; 703cdf0e10cSrcweir 704cdf0e10cSrcweir case SID_THES: 705cdf0e10cSrcweir { 706cdf0e10cSrcweir String aStatusVal; 707cdf0e10cSrcweir LanguageType nLang = LANGUAGE_NONE; 708cdf0e10cSrcweir bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, *pActiveView ); 709cdf0e10cSrcweir rSet.Put( SfxStringItem( SID_THES, aStatusVal ) ); 710cdf0e10cSrcweir 711cdf0e10cSrcweir // disable thesaurus context menu entry if there is nothing to look up 712cdf0e10cSrcweir sal_Bool bCanDoThesaurus = ScModule::HasThesaurusLanguage( nLang ); 713cdf0e10cSrcweir if (!bIsLookUpWord || !bCanDoThesaurus) 714cdf0e10cSrcweir rSet.DisableItem( SID_THES ); 715cdf0e10cSrcweir } 716cdf0e10cSrcweir break; 717cdf0e10cSrcweir 718cdf0e10cSrcweir 719cdf0e10cSrcweir } 720cdf0e10cSrcweir nWhich = aIter.NextWhich(); 721cdf0e10cSrcweir } 722cdf0e10cSrcweir } 723cdf0e10cSrcweir 724cdf0e10cSrcweir const SvxURLField* ScEditShell::GetURLField() 725cdf0e10cSrcweir { 726cdf0e10cSrcweir ScInputHandler* pHdl = GetMyInputHdl(); 727cdf0e10cSrcweir EditView* pActiveView = pHdl ? pHdl->GetActiveView() : pEditView; 728cdf0e10cSrcweir if ( pActiveView ) 729cdf0e10cSrcweir { 730cdf0e10cSrcweir const SvxFieldItem* pFieldItem = pActiveView->GetFieldAtSelection(); 731cdf0e10cSrcweir if (pFieldItem) 732cdf0e10cSrcweir { 733cdf0e10cSrcweir const SvxFieldData* pField = pFieldItem->GetField(); 734cdf0e10cSrcweir if ( pField && pField->ISA(SvxURLField) ) 735cdf0e10cSrcweir return (const SvxURLField*)pField; 736cdf0e10cSrcweir } 737cdf0e10cSrcweir } 738cdf0e10cSrcweir 739cdf0e10cSrcweir return NULL; 740cdf0e10cSrcweir } 741cdf0e10cSrcweir 742cdf0e10cSrcweir IMPL_LINK( ScEditShell, ClipboardChanged, TransferableDataHelper*, pDataHelper ) 743cdf0e10cSrcweir { 744cdf0e10cSrcweir if ( pDataHelper ) 745cdf0e10cSrcweir { 746cdf0e10cSrcweir bPastePossible = ( pDataHelper->HasFormat( SOT_FORMAT_STRING ) || pDataHelper->HasFormat( SOT_FORMAT_RTF ) ); 747cdf0e10cSrcweir 748cdf0e10cSrcweir SfxBindings& rBindings = pViewData->GetBindings(); 749cdf0e10cSrcweir rBindings.Invalidate( SID_PASTE ); 750cdf0e10cSrcweir rBindings.Invalidate( SID_PASTE_SPECIAL ); 751cdf0e10cSrcweir rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS ); 752cdf0e10cSrcweir } 753cdf0e10cSrcweir return 0; 754cdf0e10cSrcweir } 755cdf0e10cSrcweir 756cdf0e10cSrcweir void __EXPORT ScEditShell::GetClipState( SfxItemSet& rSet ) 757cdf0e10cSrcweir { 758cdf0e10cSrcweir if ( !pClipEvtLstnr ) 759cdf0e10cSrcweir { 760cdf0e10cSrcweir // create listener 761cdf0e10cSrcweir pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScEditShell, ClipboardChanged ) ); 762cdf0e10cSrcweir pClipEvtLstnr->acquire(); 763cdf0e10cSrcweir Window* pWin = pViewData->GetActiveWin(); 764cdf0e10cSrcweir pClipEvtLstnr->AddRemoveListener( pWin, sal_True ); 765cdf0e10cSrcweir 766cdf0e10cSrcweir // get initial state 767cdf0e10cSrcweir TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) ); 768cdf0e10cSrcweir bPastePossible = ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) || aDataHelper.HasFormat( SOT_FORMAT_RTF ) ); 769cdf0e10cSrcweir } 770cdf0e10cSrcweir 771cdf0e10cSrcweir SfxWhichIter aIter( rSet ); 772cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich(); 773cdf0e10cSrcweir while (nWhich) 774cdf0e10cSrcweir { 775cdf0e10cSrcweir switch (nWhich) 776cdf0e10cSrcweir { 777cdf0e10cSrcweir case SID_PASTE: 778cdf0e10cSrcweir case SID_PASTE_SPECIAL: 779cdf0e10cSrcweir if( !bPastePossible ) 780cdf0e10cSrcweir rSet.DisableItem( nWhich ); 781cdf0e10cSrcweir break; 782cdf0e10cSrcweir case SID_CLIPBOARD_FORMAT_ITEMS: 783cdf0e10cSrcweir if( bPastePossible ) 784cdf0e10cSrcweir { 785cdf0e10cSrcweir SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS ); 786cdf0e10cSrcweir TransferableDataHelper aDataHelper( 787cdf0e10cSrcweir TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) ); 788cdf0e10cSrcweir 789cdf0e10cSrcweir if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) ) 790cdf0e10cSrcweir aFormats.AddClipbrdFormat( SOT_FORMAT_STRING ); 791cdf0e10cSrcweir if ( aDataHelper.HasFormat( SOT_FORMAT_RTF ) ) 792cdf0e10cSrcweir aFormats.AddClipbrdFormat( SOT_FORMAT_RTF ); 793cdf0e10cSrcweir 794cdf0e10cSrcweir rSet.Put( aFormats ); 795cdf0e10cSrcweir } 796cdf0e10cSrcweir else 797cdf0e10cSrcweir rSet.DisableItem( nWhich ); 798cdf0e10cSrcweir break; 799cdf0e10cSrcweir } 800cdf0e10cSrcweir nWhich = aIter.NextWhich(); 801cdf0e10cSrcweir } 802cdf0e10cSrcweir } 803cdf0e10cSrcweir 804cdf0e10cSrcweir void lcl_InvalidateUnder( SfxBindings& rBindings ) 805cdf0e10cSrcweir { 806cdf0e10cSrcweir rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE ); 807cdf0e10cSrcweir rBindings.Invalidate( SID_ULINE_VAL_NONE ); 808cdf0e10cSrcweir rBindings.Invalidate( SID_ULINE_VAL_SINGLE ); 809cdf0e10cSrcweir rBindings.Invalidate( SID_ULINE_VAL_DOUBLE ); 810cdf0e10cSrcweir rBindings.Invalidate( SID_ULINE_VAL_DOTTED ); 811cdf0e10cSrcweir } 812cdf0e10cSrcweir 813cdf0e10cSrcweir void ScEditShell::ExecuteAttr(SfxRequest& rReq) 814cdf0e10cSrcweir { 815cdf0e10cSrcweir SfxItemSet aSet( pEditView->GetEmptyItemSet() ); 816cdf0e10cSrcweir SfxBindings& rBindings = pViewData->GetBindings(); 817cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs(); 818cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot(); 819cdf0e10cSrcweir 820cdf0e10cSrcweir switch ( nSlot ) 821cdf0e10cSrcweir { 822cdf0e10cSrcweir case SID_ATTR_CHAR_FONTHEIGHT: 823cdf0e10cSrcweir case SID_ATTR_CHAR_FONT: 824cdf0e10cSrcweir { 825cdf0e10cSrcweir if (pArgs) 826cdf0e10cSrcweir { 827cdf0e10cSrcweir // #i78017 establish the same behaviour as in Writer 828cdf0e10cSrcweir sal_uInt16 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX; 829cdf0e10cSrcweir if (nSlot == SID_ATTR_CHAR_FONT) 830cdf0e10cSrcweir { 831cdf0e10cSrcweir nScript = pEditView->GetSelectedScriptType(); 832cdf0e10cSrcweir if (nScript == 0) nScript = ScGlobal::GetDefaultScriptType(); 833cdf0e10cSrcweir } 834cdf0e10cSrcweir 835cdf0e10cSrcweir SfxItemPool& rPool = GetPool(); 836cdf0e10cSrcweir SvxScriptSetItem aSetItem( nSlot, rPool ); 837cdf0e10cSrcweir sal_uInt16 nWhich = rPool.GetWhich( nSlot ); 838cdf0e10cSrcweir aSetItem.PutItemForScriptType( nScript, pArgs->Get( nWhich ) ); 839cdf0e10cSrcweir 840cdf0e10cSrcweir aSet.Put( aSetItem.GetItemSet(), sal_False ); 841cdf0e10cSrcweir } 842cdf0e10cSrcweir } 843cdf0e10cSrcweir break; 844cdf0e10cSrcweir 845cdf0e10cSrcweir case SID_ATTR_CHAR_COLOR: 846cdf0e10cSrcweir { 847cdf0e10cSrcweir if (pArgs) 848cdf0e10cSrcweir { 849cdf0e10cSrcweir aSet.Put( pArgs->Get( pArgs->GetPool()->GetWhich( nSlot ) ) ); 850cdf0e10cSrcweir rBindings.Invalidate( nSlot ); 851cdf0e10cSrcweir } 852cdf0e10cSrcweir } 853cdf0e10cSrcweir break; 854cdf0e10cSrcweir 855cdf0e10cSrcweir // Toggles 856cdf0e10cSrcweir 857cdf0e10cSrcweir case SID_ATTR_CHAR_WEIGHT: 858cdf0e10cSrcweir { 859cdf0e10cSrcweir // #i78017 establish the same behaviour as in Writer 860cdf0e10cSrcweir sal_uInt16 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX; 861cdf0e10cSrcweir 862cdf0e10cSrcweir SfxItemPool& rPool = GetPool(); 863cdf0e10cSrcweir 864cdf0e10cSrcweir sal_Bool bOld = sal_False; 865cdf0e10cSrcweir SvxScriptSetItem aOldSetItem( nSlot, rPool ); 866cdf0e10cSrcweir aOldSetItem.GetItemSet().Put( pEditView->GetAttribs(), sal_False ); 867cdf0e10cSrcweir const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript ); 868cdf0e10cSrcweir if ( pCore && ((const SvxWeightItem*)pCore)->GetWeight() > WEIGHT_NORMAL ) 869cdf0e10cSrcweir bOld = sal_True; 870cdf0e10cSrcweir 871cdf0e10cSrcweir SvxScriptSetItem aSetItem( nSlot, rPool ); 872cdf0e10cSrcweir aSetItem.PutItemForScriptType( nScript, 873cdf0e10cSrcweir SvxWeightItem( bOld ? WEIGHT_NORMAL : WEIGHT_BOLD, EE_CHAR_WEIGHT ) ); 874cdf0e10cSrcweir aSet.Put( aSetItem.GetItemSet(), sal_False ); 875cdf0e10cSrcweir 876cdf0e10cSrcweir rBindings.Invalidate( nSlot ); 877cdf0e10cSrcweir } 878cdf0e10cSrcweir break; 879cdf0e10cSrcweir 880cdf0e10cSrcweir case SID_ATTR_CHAR_POSTURE: 881cdf0e10cSrcweir { 882cdf0e10cSrcweir // #i78017 establish the same behaviour as in Writer 883cdf0e10cSrcweir sal_uInt16 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX; 884cdf0e10cSrcweir 885cdf0e10cSrcweir SfxItemPool& rPool = GetPool(); 886cdf0e10cSrcweir 887cdf0e10cSrcweir sal_Bool bOld = sal_False; 888cdf0e10cSrcweir SvxScriptSetItem aOldSetItem( nSlot, rPool ); 889cdf0e10cSrcweir aOldSetItem.GetItemSet().Put( pEditView->GetAttribs(), sal_False ); 890cdf0e10cSrcweir const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript ); 891cdf0e10cSrcweir if ( pCore && ((const SvxPostureItem*)pCore)->GetValue() != ITALIC_NONE ) 892cdf0e10cSrcweir bOld = sal_True; 893cdf0e10cSrcweir 894cdf0e10cSrcweir SvxScriptSetItem aSetItem( nSlot, rPool ); 895cdf0e10cSrcweir aSetItem.PutItemForScriptType( nScript, 896cdf0e10cSrcweir SvxPostureItem( bOld ? ITALIC_NONE : ITALIC_NORMAL, EE_CHAR_ITALIC ) ); 897cdf0e10cSrcweir aSet.Put( aSetItem.GetItemSet(), sal_False ); 898cdf0e10cSrcweir 899cdf0e10cSrcweir rBindings.Invalidate( nSlot ); 900cdf0e10cSrcweir } 901cdf0e10cSrcweir break; 902cdf0e10cSrcweir 903cdf0e10cSrcweir case SID_ULINE_VAL_NONE: 904cdf0e10cSrcweir aSet.Put( SvxUnderlineItem( UNDERLINE_NONE, EE_CHAR_UNDERLINE ) ); 905cdf0e10cSrcweir lcl_InvalidateUnder( rBindings ); 906cdf0e10cSrcweir break; 907cdf0e10cSrcweir 908cdf0e10cSrcweir case SID_ATTR_CHAR_UNDERLINE: // Toggles 909cdf0e10cSrcweir case SID_ULINE_VAL_SINGLE: 910cdf0e10cSrcweir case SID_ULINE_VAL_DOUBLE: 911cdf0e10cSrcweir case SID_ULINE_VAL_DOTTED: 912cdf0e10cSrcweir { 913cdf0e10cSrcweir FontUnderline eOld = ((const SvxUnderlineItem&) pEditView-> 914cdf0e10cSrcweir GetAttribs().Get(EE_CHAR_UNDERLINE)).GetLineStyle(); 915cdf0e10cSrcweir FontUnderline eNew = eOld; 916cdf0e10cSrcweir switch (nSlot) 917cdf0e10cSrcweir { 918cdf0e10cSrcweir case SID_ATTR_CHAR_UNDERLINE: 919cdf0e10cSrcweir eNew = ( eOld != UNDERLINE_NONE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE; 920cdf0e10cSrcweir break; 921cdf0e10cSrcweir case SID_ULINE_VAL_SINGLE: 922cdf0e10cSrcweir eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE; 923cdf0e10cSrcweir break; 924cdf0e10cSrcweir case SID_ULINE_VAL_DOUBLE: 925cdf0e10cSrcweir eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE; 926cdf0e10cSrcweir break; 927cdf0e10cSrcweir case SID_ULINE_VAL_DOTTED: 928cdf0e10cSrcweir eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED; 929cdf0e10cSrcweir break; 930cdf0e10cSrcweir } 931cdf0e10cSrcweir aSet.Put( SvxUnderlineItem( eNew, EE_CHAR_UNDERLINE ) ); 932cdf0e10cSrcweir lcl_InvalidateUnder( rBindings ); 933cdf0e10cSrcweir } 934cdf0e10cSrcweir break; 935cdf0e10cSrcweir 936cdf0e10cSrcweir case SID_ATTR_CHAR_OVERLINE: 937cdf0e10cSrcweir { 938cdf0e10cSrcweir FontUnderline eOld = ((const SvxOverlineItem&) pEditView-> 939cdf0e10cSrcweir GetAttribs().Get(EE_CHAR_OVERLINE)).GetLineStyle(); 940cdf0e10cSrcweir FontUnderline eNew = ( eOld != UNDERLINE_NONE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE; 941cdf0e10cSrcweir aSet.Put( SvxOverlineItem( eNew, EE_CHAR_OVERLINE ) ); 942cdf0e10cSrcweir rBindings.Invalidate( nSlot ); 943cdf0e10cSrcweir } 944cdf0e10cSrcweir break; 945cdf0e10cSrcweir 946cdf0e10cSrcweir case SID_ATTR_CHAR_STRIKEOUT: 947cdf0e10cSrcweir { 948cdf0e10cSrcweir sal_Bool bOld = ((const SvxCrossedOutItem&)pEditView->GetAttribs(). 949cdf0e10cSrcweir Get(EE_CHAR_STRIKEOUT)).GetValue() != STRIKEOUT_NONE; 950cdf0e10cSrcweir aSet.Put( SvxCrossedOutItem( bOld ? STRIKEOUT_NONE : STRIKEOUT_SINGLE, EE_CHAR_STRIKEOUT ) ); 951cdf0e10cSrcweir rBindings.Invalidate( nSlot ); 952cdf0e10cSrcweir } 953cdf0e10cSrcweir break; 954cdf0e10cSrcweir 955cdf0e10cSrcweir case SID_ATTR_CHAR_SHADOWED: 956cdf0e10cSrcweir { 957cdf0e10cSrcweir sal_Bool bOld = ((const SvxShadowedItem&)pEditView->GetAttribs(). 958cdf0e10cSrcweir Get(EE_CHAR_SHADOW)).GetValue(); 959cdf0e10cSrcweir aSet.Put( SvxShadowedItem( !bOld, EE_CHAR_SHADOW ) ); 960cdf0e10cSrcweir rBindings.Invalidate( nSlot ); 961cdf0e10cSrcweir } 962cdf0e10cSrcweir break; 963cdf0e10cSrcweir 964cdf0e10cSrcweir case SID_ATTR_CHAR_CONTOUR: 965cdf0e10cSrcweir { 966cdf0e10cSrcweir sal_Bool bOld = ((const SvxContourItem&)pEditView->GetAttribs(). 967cdf0e10cSrcweir Get(EE_CHAR_OUTLINE)).GetValue(); 968cdf0e10cSrcweir aSet.Put( SvxContourItem( !bOld, EE_CHAR_OUTLINE ) ); 969cdf0e10cSrcweir rBindings.Invalidate( nSlot ); 970cdf0e10cSrcweir } 971cdf0e10cSrcweir break; 972cdf0e10cSrcweir 973cdf0e10cSrcweir case SID_SET_SUPER_SCRIPT: 974cdf0e10cSrcweir { 975cdf0e10cSrcweir SvxEscapement eOld = (SvxEscapement) ((const SvxEscapementItem&) 976cdf0e10cSrcweir pEditView->GetAttribs().Get(EE_CHAR_ESCAPEMENT)).GetEnumValue(); 977cdf0e10cSrcweir SvxEscapement eNew = (eOld == SVX_ESCAPEMENT_SUPERSCRIPT) ? 978cdf0e10cSrcweir SVX_ESCAPEMENT_OFF : SVX_ESCAPEMENT_SUPERSCRIPT; 979cdf0e10cSrcweir aSet.Put( SvxEscapementItem( eNew, EE_CHAR_ESCAPEMENT ) ); 980cdf0e10cSrcweir rBindings.Invalidate( nSlot ); 981cdf0e10cSrcweir } 982cdf0e10cSrcweir break; 983cdf0e10cSrcweir case SID_SET_SUB_SCRIPT: 984cdf0e10cSrcweir { 985cdf0e10cSrcweir SvxEscapement eOld = (SvxEscapement) ((const SvxEscapementItem&) 986cdf0e10cSrcweir pEditView->GetAttribs().Get(EE_CHAR_ESCAPEMENT)).GetEnumValue(); 987cdf0e10cSrcweir SvxEscapement eNew = (eOld == SVX_ESCAPEMENT_SUBSCRIPT) ? 988cdf0e10cSrcweir SVX_ESCAPEMENT_OFF : SVX_ESCAPEMENT_SUBSCRIPT; 989cdf0e10cSrcweir aSet.Put( SvxEscapementItem( eNew, EE_CHAR_ESCAPEMENT ) ); 990cdf0e10cSrcweir rBindings.Invalidate( nSlot ); 991cdf0e10cSrcweir } 992cdf0e10cSrcweir break; 993cdf0e10cSrcweir } 994cdf0e10cSrcweir 995cdf0e10cSrcweir // 996cdf0e10cSrcweir // anwenden 997cdf0e10cSrcweir // 998cdf0e10cSrcweir 999cdf0e10cSrcweir EditEngine* pEngine = pEditView->GetEditEngine(); 1000cdf0e10cSrcweir sal_Bool bOld = pEngine->GetUpdateMode(); 1001cdf0e10cSrcweir pEngine->SetUpdateMode(sal_False); 1002cdf0e10cSrcweir 1003cdf0e10cSrcweir pEditView->SetAttribs( aSet ); 1004cdf0e10cSrcweir 1005cdf0e10cSrcweir pEngine->SetUpdateMode(bOld); 1006cdf0e10cSrcweir pEditView->Invalidate(); 1007cdf0e10cSrcweir 1008cdf0e10cSrcweir ScInputHandler* pHdl = GetMyInputHdl(); 1009cdf0e10cSrcweir pHdl->SetModified(); 1010cdf0e10cSrcweir 1011cdf0e10cSrcweir rReq.Done(); 1012cdf0e10cSrcweir } 1013cdf0e10cSrcweir 1014cdf0e10cSrcweir void ScEditShell::GetAttrState(SfxItemSet &rSet) 1015cdf0e10cSrcweir { 1016cdf0e10cSrcweir if ( !pViewData->HasEditView( pViewData->GetActivePart() ) ) // #125326# 1017cdf0e10cSrcweir { 1018cdf0e10cSrcweir lcl_DisableAll( rSet ); 1019cdf0e10cSrcweir return; 1020cdf0e10cSrcweir } 1021cdf0e10cSrcweir 1022cdf0e10cSrcweir SfxItemSet aAttribs = pEditView->GetAttribs(); 1023cdf0e10cSrcweir rSet.Put( aAttribs ); 1024cdf0e10cSrcweir 1025cdf0e10cSrcweir // choose font info according to selection script type 1026cdf0e10cSrcweir 1027cdf0e10cSrcweir sal_uInt16 nScript = pEditView->GetSelectedScriptType(); 1028cdf0e10cSrcweir if (nScript == 0) nScript = ScGlobal::GetDefaultScriptType(); 1029cdf0e10cSrcweir 1030cdf0e10cSrcweir // #i55929# input-language-dependent script type (depends on input language if nothing selected) 1031cdf0e10cSrcweir sal_uInt16 nInputScript = nScript; 1032cdf0e10cSrcweir if ( !pEditView->GetSelection().HasRange() ) 1033cdf0e10cSrcweir { 1034cdf0e10cSrcweir LanguageType nInputLang = pViewData->GetActiveWin()->GetInputLanguage(); 1035cdf0e10cSrcweir if (nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM) 1036cdf0e10cSrcweir nInputScript = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang ); 1037cdf0e10cSrcweir } 1038cdf0e10cSrcweir 1039cdf0e10cSrcweir // #i55929# according to spec, nInputScript is used for font and font height only 1040cdf0e10cSrcweir if ( rSet.GetItemState( EE_CHAR_FONTINFO ) != SFX_ITEM_UNKNOWN ) 1041cdf0e10cSrcweir ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_FONTINFO, nInputScript ); 1042cdf0e10cSrcweir if ( rSet.GetItemState( EE_CHAR_FONTHEIGHT ) != SFX_ITEM_UNKNOWN ) 1043cdf0e10cSrcweir ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_FONTHEIGHT, nInputScript ); 1044cdf0e10cSrcweir if ( rSet.GetItemState( EE_CHAR_WEIGHT ) != SFX_ITEM_UNKNOWN ) 1045cdf0e10cSrcweir ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_WEIGHT, nScript ); 1046cdf0e10cSrcweir if ( rSet.GetItemState( EE_CHAR_ITALIC ) != SFX_ITEM_UNKNOWN ) 1047cdf0e10cSrcweir ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_ITALIC, nScript ); 1048cdf0e10cSrcweir 1049cdf0e10cSrcweir // Unterstreichung 1050cdf0e10cSrcweir 1051cdf0e10cSrcweir SfxItemState eState = aAttribs.GetItemState( EE_CHAR_UNDERLINE, sal_True ); 1052cdf0e10cSrcweir if ( eState == SFX_ITEM_DONTCARE ) 1053cdf0e10cSrcweir { 1054cdf0e10cSrcweir rSet.InvalidateItem( SID_ULINE_VAL_NONE ); 1055cdf0e10cSrcweir rSet.InvalidateItem( SID_ULINE_VAL_SINGLE ); 1056cdf0e10cSrcweir rSet.InvalidateItem( SID_ULINE_VAL_DOUBLE ); 1057cdf0e10cSrcweir rSet.InvalidateItem( SID_ULINE_VAL_DOTTED ); 1058cdf0e10cSrcweir } 1059cdf0e10cSrcweir else 1060cdf0e10cSrcweir { 1061cdf0e10cSrcweir FontUnderline eUnderline = ((const SvxUnderlineItem&) 1062cdf0e10cSrcweir aAttribs.Get(EE_CHAR_UNDERLINE)).GetLineStyle(); 1063cdf0e10cSrcweir sal_uInt16 nId = SID_ULINE_VAL_NONE; 1064cdf0e10cSrcweir switch (eUnderline) 1065cdf0e10cSrcweir { 1066cdf0e10cSrcweir case UNDERLINE_SINGLE: nId = SID_ULINE_VAL_SINGLE; break; 1067cdf0e10cSrcweir case UNDERLINE_DOUBLE: nId = SID_ULINE_VAL_DOUBLE; break; 1068cdf0e10cSrcweir case UNDERLINE_DOTTED: nId = SID_ULINE_VAL_DOTTED; break; 1069cdf0e10cSrcweir default: 1070cdf0e10cSrcweir break; 1071cdf0e10cSrcweir } 1072cdf0e10cSrcweir rSet.Put( SfxBoolItem( nId, sal_True ) ); 1073cdf0e10cSrcweir } 1074cdf0e10cSrcweir 1075cdf0e10cSrcweir //! Testen, ob Klammer-Hervorhebung aktiv ist !!!! 1076cdf0e10cSrcweir ScInputHandler* pHdl = GetMyInputHdl(); 1077cdf0e10cSrcweir if ( pHdl && pHdl->IsFormulaMode() ) 1078cdf0e10cSrcweir rSet.ClearItem( EE_CHAR_WEIGHT ); // hervorgehobene Klammern hier nicht 1079cdf0e10cSrcweir } 1080cdf0e10cSrcweir 1081cdf0e10cSrcweir String ScEditShell::GetSelectionText( sal_Bool bWholeWord ) 1082cdf0e10cSrcweir { 1083cdf0e10cSrcweir String aStrSelection; 1084cdf0e10cSrcweir 1085cdf0e10cSrcweir if ( pViewData->HasEditView( pViewData->GetActivePart() ) ) // #125326# 1086cdf0e10cSrcweir { 1087cdf0e10cSrcweir if ( bWholeWord ) 1088cdf0e10cSrcweir { 1089cdf0e10cSrcweir EditEngine* pEngine = pEditView->GetEditEngine(); 1090cdf0e10cSrcweir ESelection aSel = pEditView->GetSelection(); 1091cdf0e10cSrcweir String aStrCurrentDelimiters = pEngine->GetWordDelimiters(); 1092cdf0e10cSrcweir 1093cdf0e10cSrcweir pEngine->SetWordDelimiters( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(" .,;\"'")) ); 1094cdf0e10cSrcweir aStrSelection = pEngine->GetWord( aSel.nEndPara, aSel.nEndPos ); 1095cdf0e10cSrcweir pEngine->SetWordDelimiters( aStrCurrentDelimiters ); 1096cdf0e10cSrcweir } 1097cdf0e10cSrcweir else 1098cdf0e10cSrcweir { 1099cdf0e10cSrcweir aStrSelection = pEditView->GetSelected(); 1100cdf0e10cSrcweir } 1101cdf0e10cSrcweir } 1102cdf0e10cSrcweir 1103cdf0e10cSrcweir return aStrSelection; 1104cdf0e10cSrcweir } 1105cdf0e10cSrcweir 1106cdf0e10cSrcweir void ScEditShell::ExecuteUndo(SfxRequest& rReq) 1107cdf0e10cSrcweir { 1108cdf0e10cSrcweir // #81733# Undo must be handled here because it's called for both EditViews 1109cdf0e10cSrcweir 1110cdf0e10cSrcweir ScInputHandler* pHdl = GetMyInputHdl(); 1111cdf0e10cSrcweir DBG_ASSERT(pHdl,"no ScInputHandler"); 1112cdf0e10cSrcweir EditView* pTopView = pHdl->GetTopView(); 1113cdf0e10cSrcweir EditView* pTableView = pHdl->GetTableView(); 1114cdf0e10cSrcweir DBG_ASSERT(pTableView,"no EditView"); 1115cdf0e10cSrcweir 1116cdf0e10cSrcweir pHdl->DataChanging(); 1117cdf0e10cSrcweir 1118cdf0e10cSrcweir const SfxItemSet* pReqArgs = rReq.GetArgs(); 1119cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot(); 1120cdf0e10cSrcweir switch ( nSlot ) 1121cdf0e10cSrcweir { 1122cdf0e10cSrcweir case SID_UNDO: 1123cdf0e10cSrcweir case SID_REDO: 1124cdf0e10cSrcweir { 1125cdf0e10cSrcweir sal_Bool bIsUndo = ( nSlot == SID_UNDO ); 1126cdf0e10cSrcweir 1127cdf0e10cSrcweir sal_uInt16 nCount = 1; 1128cdf0e10cSrcweir const SfxPoolItem* pItem; 1129cdf0e10cSrcweir if ( pReqArgs && pReqArgs->GetItemState( nSlot, sal_True, &pItem ) == SFX_ITEM_SET ) 1130cdf0e10cSrcweir nCount = ((const SfxUInt16Item*)pItem)->GetValue(); 1131cdf0e10cSrcweir 1132cdf0e10cSrcweir for (sal_uInt16 i=0; i<nCount; i++) 1133cdf0e10cSrcweir { 1134cdf0e10cSrcweir if ( bIsUndo ) 1135cdf0e10cSrcweir { 1136cdf0e10cSrcweir pTableView->Undo(); 1137cdf0e10cSrcweir if (pTopView) 1138cdf0e10cSrcweir pTopView->Undo(); 1139cdf0e10cSrcweir } 1140cdf0e10cSrcweir else 1141cdf0e10cSrcweir { 1142cdf0e10cSrcweir pTableView->Redo(); 1143cdf0e10cSrcweir if (pTopView) 1144cdf0e10cSrcweir pTopView->Redo(); 1145cdf0e10cSrcweir } 1146cdf0e10cSrcweir } 1147cdf0e10cSrcweir } 1148cdf0e10cSrcweir break; 1149cdf0e10cSrcweir } 1150cdf0e10cSrcweir pViewData->GetBindings().InvalidateAll(sal_False); 1151cdf0e10cSrcweir 1152cdf0e10cSrcweir pHdl->DataChanged(); 1153cdf0e10cSrcweir } 1154cdf0e10cSrcweir 1155cdf0e10cSrcweir void ScEditShell::GetUndoState(SfxItemSet &rSet) 1156cdf0e10cSrcweir { 1157cdf0e10cSrcweir // Undo state is taken from normal ViewFrame state function 1158cdf0e10cSrcweir 1159cdf0e10cSrcweir SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame(); 1160cdf0e10cSrcweir if ( pViewFrm && GetUndoManager() ) 1161cdf0e10cSrcweir { 1162cdf0e10cSrcweir SfxWhichIter aIter(rSet); 1163cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich(); 1164cdf0e10cSrcweir while( nWhich ) 1165cdf0e10cSrcweir { 1166cdf0e10cSrcweir pViewFrm->GetSlotState( nWhich, NULL, &rSet ); 1167cdf0e10cSrcweir nWhich = aIter.NextWhich(); 1168cdf0e10cSrcweir } 1169cdf0e10cSrcweir } 1170cdf0e10cSrcweir 1171cdf0e10cSrcweir // disable if no action in input line EditView 1172cdf0e10cSrcweir 1173cdf0e10cSrcweir ScInputHandler* pHdl = GetMyInputHdl(); 1174cdf0e10cSrcweir DBG_ASSERT(pHdl,"no ScInputHandler"); 1175cdf0e10cSrcweir EditView* pTopView = pHdl->GetTopView(); 1176cdf0e10cSrcweir if (pTopView) 1177cdf0e10cSrcweir { 1178cdf0e10cSrcweir ::svl::IUndoManager& rTopMgr = pTopView->GetEditEngine()->GetUndoManager(); 1179cdf0e10cSrcweir if ( rTopMgr.GetUndoActionCount() == 0 ) 1180cdf0e10cSrcweir rSet.DisableItem( SID_UNDO ); 1181cdf0e10cSrcweir if ( rTopMgr.GetRedoActionCount() == 0 ) 1182cdf0e10cSrcweir rSet.DisableItem( SID_REDO ); 1183cdf0e10cSrcweir } 1184cdf0e10cSrcweir } 1185cdf0e10cSrcweir 1186cdf0e10cSrcweir void ScEditShell::ExecuteTrans( SfxRequest& rReq ) 1187cdf0e10cSrcweir { 1188cdf0e10cSrcweir sal_Int32 nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() ); 1189cdf0e10cSrcweir if ( nType ) 1190cdf0e10cSrcweir { 1191cdf0e10cSrcweir ScInputHandler* pHdl = GetMyInputHdl(); 1192cdf0e10cSrcweir DBG_ASSERT( pHdl, "no ScInputHandler" ); 1193cdf0e10cSrcweir 1194cdf0e10cSrcweir EditView* pTopView = pHdl->GetTopView(); 1195cdf0e10cSrcweir EditView* pTableView = pHdl->GetTableView(); 1196cdf0e10cSrcweir DBG_ASSERT( pTableView, "no EditView" ); 1197cdf0e10cSrcweir 1198cdf0e10cSrcweir pHdl->DataChanging(); 1199cdf0e10cSrcweir 1200cdf0e10cSrcweir pTableView->TransliterateText( nType ); 1201cdf0e10cSrcweir if (pTopView) 1202cdf0e10cSrcweir pTopView->TransliterateText( nType ); 1203cdf0e10cSrcweir 1204cdf0e10cSrcweir pHdl->DataChanged(); 1205cdf0e10cSrcweir } 1206cdf0e10cSrcweir } 1207