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> 48f120fe41SAndre 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"))); 117f120fe41SAndre 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)); 336512ec161SZheng Fan rBindings.Invalidate( SID_ATTR_CHAR_FONT ); 337512ec161SZheng Fan rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT ); 338512ec161SZheng Fan rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT ); 339512ec161SZheng Fan rBindings.Invalidate( SID_ATTR_CHAR_POSTURE ); 340512ec161SZheng Fan rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE ); 341512ec161SZheng Fan rBindings.Invalidate( SID_ATTR_CHAR_STRIKEOUT ); 342512ec161SZheng Fan rBindings.Invalidate( SID_ATTR_CHAR_SHADOWED ); 343512ec161SZheng Fan rBindings.Invalidate( SID_ATTR_CHAR_KERNING ); 344512ec161SZheng Fan rBindings.Invalidate( SID_ATTR_CHAR_COLOR ); 345512ec161SZheng Fan rBindings.Invalidate( SID_SET_SUPER_SCRIPT ); 346512ec161SZheng Fan rBindings.Invalidate( SID_SET_SUB_SCRIPT ); 347cdf0e10cSrcweir } 348cdf0e10cSrcweir bSetModified = sal_False; 349cdf0e10cSrcweir } 350cdf0e10cSrcweir break; 351cdf0e10cSrcweir 352cdf0e10cSrcweir case SID_CHARMAP: 353cdf0e10cSrcweir { 354cdf0e10cSrcweir sal_uInt16 nScript = pTableView->GetSelectedScriptType(); 355cdf0e10cSrcweir sal_uInt16 nFontWhich = ( nScript == SCRIPTTYPE_ASIAN ) ? EE_CHAR_FONTINFO_CJK : 356cdf0e10cSrcweir ( ( nScript == SCRIPTTYPE_COMPLEX ) ? EE_CHAR_FONTINFO_CTL : 357cdf0e10cSrcweir EE_CHAR_FONTINFO ); 358cdf0e10cSrcweir const SvxFontItem& rItem = (const SvxFontItem&) 359cdf0e10cSrcweir pTableView->GetAttribs().Get(nFontWhich); 360cdf0e10cSrcweir 361cdf0e10cSrcweir String aString; 362cdf0e10cSrcweir SvxFontItem aNewItem( EE_CHAR_FONTINFO ); 363cdf0e10cSrcweir 364cdf0e10cSrcweir const SfxItemSet *pArgs = rReq.GetArgs(); 365cdf0e10cSrcweir const SfxPoolItem* pItem = 0; 366cdf0e10cSrcweir if( pArgs ) 367cdf0e10cSrcweir pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), sal_False, &pItem); 368cdf0e10cSrcweir 369cdf0e10cSrcweir if ( pItem ) 370cdf0e10cSrcweir { 371cdf0e10cSrcweir aString = ((const SfxStringItem*)pItem)->GetValue(); 372cdf0e10cSrcweir const SfxPoolItem* pFtItem = NULL; 373cdf0e10cSrcweir pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), sal_False, &pFtItem); 374cdf0e10cSrcweir const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem ); 375cdf0e10cSrcweir if ( pFontItem ) 376cdf0e10cSrcweir { 377cdf0e10cSrcweir String aFontName(pFontItem->GetValue()); 378cdf0e10cSrcweir Font aFont(aFontName, Size(1,1)); // Size nur wg. CTOR 379cdf0e10cSrcweir aNewItem = SvxFontItem( aFont.GetFamily(), aFont.GetName(), 380cdf0e10cSrcweir aFont.GetStyleName(), aFont.GetPitch(), 381cdf0e10cSrcweir aFont.GetCharSet(), ATTR_FONT ); 382cdf0e10cSrcweir } 383cdf0e10cSrcweir else 384cdf0e10cSrcweir aNewItem = rItem; 385cdf0e10cSrcweir } 386cdf0e10cSrcweir else 387cdf0e10cSrcweir { 388cdf0e10cSrcweir ScViewUtil::ExecuteCharMap( rItem, *pViewData->GetViewShell()->GetViewFrame(), aNewItem, aString ); 389cdf0e10cSrcweir 390cdf0e10cSrcweir // while the dialog was open, edit mode may have been stopped 391cdf0e10cSrcweir if (!SC_MOD()->IsInputMode()) 392cdf0e10cSrcweir { 393cdf0e10cSrcweir Sound::Beep(); 394cdf0e10cSrcweir return; 395cdf0e10cSrcweir } 396cdf0e10cSrcweir } 397cdf0e10cSrcweir 398cdf0e10cSrcweir if ( aString.Len() ) 399cdf0e10cSrcweir { 400cdf0e10cSrcweir // if string contains WEAK characters, set all fonts 401cdf0e10cSrcweir sal_uInt8 nSetScript; 402cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 403cdf0e10cSrcweir if ( pDoc->HasStringWeakCharacters( aString ) ) 404cdf0e10cSrcweir nSetScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX; 405cdf0e10cSrcweir else 406cdf0e10cSrcweir nSetScript = pDoc->GetStringScriptType( aString ); 407cdf0e10cSrcweir 408cdf0e10cSrcweir SfxItemSet aSet( pTableView->GetEmptyItemSet() ); 409cdf0e10cSrcweir SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, GetPool() ); 410cdf0e10cSrcweir aSetItem.PutItemForScriptType( nSetScript, aNewItem ); 411cdf0e10cSrcweir aSet.Put( aSetItem.GetItemSet(), sal_False ); 412cdf0e10cSrcweir 413cdf0e10cSrcweir // SetAttribs an der View selektiert ein Wort, wenn nichts selektiert ist 414cdf0e10cSrcweir pTableView->GetEditEngine()->QuickSetAttribs( aSet, pTableView->GetSelection() ); 415cdf0e10cSrcweir pTableView->InsertText(aString); 416cdf0e10cSrcweir if (pTopView) 417cdf0e10cSrcweir pTopView->InsertText(aString); 418cdf0e10cSrcweir 419cdf0e10cSrcweir SfxStringItem aStringItem( SID_CHARMAP, aString ); 420cdf0e10cSrcweir SfxStringItem aFontItem( SID_ATTR_SPECIALCHAR, aNewItem.GetFamilyName() ); 421cdf0e10cSrcweir rReq.AppendItem( aFontItem ); 422cdf0e10cSrcweir rReq.AppendItem( aStringItem ); 423cdf0e10cSrcweir rReq.Done(); 424cdf0e10cSrcweir 425cdf0e10cSrcweir 426cdf0e10cSrcweir } 427cdf0e10cSrcweir 428cdf0e10cSrcweir if (pTopView) 429cdf0e10cSrcweir pTopView->GetWindow()->GrabFocus(); 430cdf0e10cSrcweir } 431cdf0e10cSrcweir break; 432cdf0e10cSrcweir 433cdf0e10cSrcweir case FID_INSERT_NAME: 434cdf0e10cSrcweir { 435cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 436cdf0e10cSrcweir //CHINA001 ScNamePasteDlg* pDlg = new ScNamePasteDlg( pViewData->GetDialogParent(), 437cdf0e10cSrcweir //CHINA001 pDoc->GetRangeName(), sal_False ); 438cdf0e10cSrcweir // "Liste" disablen 439cdf0e10cSrcweir ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 440cdf0e10cSrcweir DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 441cdf0e10cSrcweir 442cdf0e10cSrcweir AbstractScNamePasteDlg* pDlg = pFact->CreateScNamePasteDlg( pViewData->GetDialogParent(), pDoc->GetRangeName(), RID_SCDLG_NAMES_PASTE, sal_False ); 443cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 444cdf0e10cSrcweir short nRet = pDlg->Execute(); 445cdf0e10cSrcweir // pDlg is needed below 446cdf0e10cSrcweir 447cdf0e10cSrcweir // while the dialog was open, edit mode may have been stopped 448cdf0e10cSrcweir if (!SC_MOD()->IsInputMode()) 449cdf0e10cSrcweir { 450cdf0e10cSrcweir Sound::Beep(); 451cdf0e10cSrcweir delete pDlg; 452cdf0e10cSrcweir return; 453cdf0e10cSrcweir } 454cdf0e10cSrcweir 455cdf0e10cSrcweir if ( nRet == BTN_PASTE_NAME ) 456cdf0e10cSrcweir { 457cdf0e10cSrcweir String aName = pDlg->GetSelectedName(); 458cdf0e10cSrcweir pTableView->InsertText(aName); 459cdf0e10cSrcweir if (pTopView) 460cdf0e10cSrcweir pTopView->InsertText(aName); 461cdf0e10cSrcweir } 462cdf0e10cSrcweir delete pDlg; 463cdf0e10cSrcweir 464cdf0e10cSrcweir if (pTopView) 465cdf0e10cSrcweir pTopView->GetWindow()->GrabFocus(); 466cdf0e10cSrcweir } 467cdf0e10cSrcweir break; 468cdf0e10cSrcweir 469d9a8b508SZheng Fan case SID_CHAR_DLG_EFFECT: 470cdf0e10cSrcweir case SID_CHAR_DLG: 471cdf0e10cSrcweir { 472cdf0e10cSrcweir SfxItemSet aAttrs( pTableView->GetAttribs() ); 473cdf0e10cSrcweir 474cdf0e10cSrcweir SfxObjectShell* pObjSh = pViewData->GetSfxDocShell(); 475cdf0e10cSrcweir 476cdf0e10cSrcweir //CHINA001 ScCharDlg* pDlg = new ScCharDlg( pViewData->GetDialogParent(), &aAttrs, pObjSh ); 477cdf0e10cSrcweir ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 478cdf0e10cSrcweir DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 479cdf0e10cSrcweir 480cdf0e10cSrcweir SfxAbstractTabDialog* pDlg = pFact->CreateScCharDlg( pViewData->GetDialogParent(), &aAttrs, 481cdf0e10cSrcweir pObjSh, RID_SCDLG_CHAR ); 482cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 483d9a8b508SZheng Fan if (nSlot == SID_CHAR_DLG_EFFECT) 484d9a8b508SZheng Fan { 485d9a8b508SZheng Fan pDlg->SetCurPageId(RID_SVXPAGE_CHAR_EFFECTS); 486d9a8b508SZheng Fan } 487cdf0e10cSrcweir short nRet = pDlg->Execute(); 488cdf0e10cSrcweir // pDlg is needed below 489cdf0e10cSrcweir 490cdf0e10cSrcweir // while the dialog was open, edit mode may have been stopped 491cdf0e10cSrcweir if (!SC_MOD()->IsInputMode()) 492cdf0e10cSrcweir { 493cdf0e10cSrcweir Sound::Beep(); 494cdf0e10cSrcweir delete pDlg; 495cdf0e10cSrcweir return; 496cdf0e10cSrcweir } 497cdf0e10cSrcweir 498cdf0e10cSrcweir if ( nRet == RET_OK ) 499cdf0e10cSrcweir { 500cdf0e10cSrcweir const SfxItemSet* pOut = pDlg->GetOutputItemSet(); 501cdf0e10cSrcweir pTableView->SetAttribs( *pOut ); 502cdf0e10cSrcweir } 503cdf0e10cSrcweir delete pDlg; 504cdf0e10cSrcweir } 505cdf0e10cSrcweir break; 506cdf0e10cSrcweir 507cdf0e10cSrcweir case SID_TOGGLE_REL: 508cdf0e10cSrcweir { 509cdf0e10cSrcweir sal_Bool bOk = sal_False; 510cdf0e10cSrcweir if (pEngine->GetParagraphCount() == 1) 511cdf0e10cSrcweir { 512cdf0e10cSrcweir String aText = pEngine->GetText(); 513cdf0e10cSrcweir ESelection aSel = pEditView->GetSelection(); // aktuelle View 514cdf0e10cSrcweir 515cdf0e10cSrcweir ScRefFinder aFinder( aText, pViewData->GetDocument() ); 516cdf0e10cSrcweir aFinder.ToggleRel( aSel.nStartPos, aSel.nEndPos ); 517cdf0e10cSrcweir if (aFinder.GetFound()) 518cdf0e10cSrcweir { 519cdf0e10cSrcweir String aNew = aFinder.GetText(); 520cdf0e10cSrcweir ESelection aNewSel( 0,aFinder.GetSelStart(), 0,aFinder.GetSelEnd() ); 521cdf0e10cSrcweir pEngine->SetText( aNew ); 522cdf0e10cSrcweir pTableView->SetSelection( aNewSel ); 523cdf0e10cSrcweir if ( pTopView ) 524cdf0e10cSrcweir { 525cdf0e10cSrcweir pTopView->GetEditEngine()->SetText( aNew ); 526cdf0e10cSrcweir pTopView->SetSelection( aNewSel ); 527cdf0e10cSrcweir } 528cdf0e10cSrcweir bOk = sal_True; 529cdf0e10cSrcweir 530cdf0e10cSrcweir // Referenz wird selektiert -> beim Tippen nicht ueberschreiben 531cdf0e10cSrcweir bSetSelIsRef = sal_True; 532cdf0e10cSrcweir } 533cdf0e10cSrcweir } 534cdf0e10cSrcweir if (!bOk) 535cdf0e10cSrcweir Sound::Beep(); // keine Referenzen oder mehrere Absaetze 536cdf0e10cSrcweir } 537cdf0e10cSrcweir break; 538cdf0e10cSrcweir 539cdf0e10cSrcweir case SID_HYPERLINK_SETLINK: 540cdf0e10cSrcweir if( pReqArgs ) 541cdf0e10cSrcweir { 542cdf0e10cSrcweir const SfxPoolItem* pItem; 543cdf0e10cSrcweir if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, sal_True, &pItem ) == SFX_ITEM_SET ) 544cdf0e10cSrcweir { 545cdf0e10cSrcweir const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem; 546cdf0e10cSrcweir const String& rName = pHyper->GetName(); 547cdf0e10cSrcweir const String& rURL = pHyper->GetURL(); 548cdf0e10cSrcweir const String& rTarget = pHyper->GetTargetFrame(); 549cdf0e10cSrcweir SvxLinkInsertMode eMode = pHyper->GetInsertMode(); 550cdf0e10cSrcweir 551cdf0e10cSrcweir sal_Bool bDone = sal_False; 552cdf0e10cSrcweir if ( eMode == HLINK_DEFAULT || eMode == HLINK_FIELD ) 553cdf0e10cSrcweir { 554cdf0e10cSrcweir const SvxURLField* pURLField = GetURLField(); 555cdf0e10cSrcweir if ( pURLField ) 556cdf0e10cSrcweir { 557cdf0e10cSrcweir // altes Feld selektieren 558cdf0e10cSrcweir 559cdf0e10cSrcweir ESelection aSel = pTableView->GetSelection(); 560cdf0e10cSrcweir aSel.Adjust(); 561cdf0e10cSrcweir aSel.nEndPara = aSel.nStartPara; 562cdf0e10cSrcweir aSel.nEndPos = aSel.nStartPos + 1; 563cdf0e10cSrcweir pTableView->SetSelection( aSel ); 564cdf0e10cSrcweir 565cdf0e10cSrcweir // neues Feld einfuegen 566cdf0e10cSrcweir 567cdf0e10cSrcweir SvxURLField aURLField( rURL, rName, SVXURLFORMAT_REPR ); 568cdf0e10cSrcweir aURLField.SetTargetFrame( rTarget ); 569cdf0e10cSrcweir SvxFieldItem aURLItem( aURLField, EE_FEATURE_FIELD ); 570cdf0e10cSrcweir pTableView->InsertField( aURLItem ); 571cdf0e10cSrcweir pTableView->SetSelection( aSel ); // select inserted field 572cdf0e10cSrcweir 573cdf0e10cSrcweir // #57254# jetzt doch auch Felder in der Top-View 574cdf0e10cSrcweir 575cdf0e10cSrcweir if ( pTopView ) 576cdf0e10cSrcweir { 577cdf0e10cSrcweir aSel = pTopView->GetSelection(); 578cdf0e10cSrcweir aSel.nEndPara = aSel.nStartPara; 579cdf0e10cSrcweir aSel.nEndPos = aSel.nStartPos + 1; 580cdf0e10cSrcweir pTopView->SetSelection( aSel ); 581cdf0e10cSrcweir pTopView->InsertField( aURLItem ); 582cdf0e10cSrcweir pTopView->SetSelection( aSel ); // select inserted field 583cdf0e10cSrcweir } 584cdf0e10cSrcweir 585cdf0e10cSrcweir bDone = sal_True; 586cdf0e10cSrcweir } 587cdf0e10cSrcweir } 588cdf0e10cSrcweir 589cdf0e10cSrcweir if (!bDone) 590cdf0e10cSrcweir { 591cdf0e10cSrcweir pViewData->GetViewShell()-> 592cdf0e10cSrcweir InsertURL( rName, rURL, rTarget, (sal_uInt16) eMode ); 593cdf0e10cSrcweir 594cdf0e10cSrcweir // InsertURL an der ViewShell schaltet bei "Button" 595cdf0e10cSrcweir // die EditShell ab, darum sofort return 596cdf0e10cSrcweir 597cdf0e10cSrcweir return; 598cdf0e10cSrcweir } 599cdf0e10cSrcweir } 600cdf0e10cSrcweir } 601cdf0e10cSrcweir break; 602cdf0e10cSrcweir 603cdf0e10cSrcweir case SID_OPEN_HYPERLINK: 604cdf0e10cSrcweir { 605cdf0e10cSrcweir const SvxURLField* pURLField = GetURLField(); 606cdf0e10cSrcweir if ( pURLField ) 607cdf0e10cSrcweir ScGlobal::OpenURL( pURLField->GetURL(), pURLField->GetTargetFrame() ); 608cdf0e10cSrcweir return; 609cdf0e10cSrcweir } 610cdf0e10cSrcweir //break; 611cdf0e10cSrcweir 612cdf0e10cSrcweir case FN_INSERT_SOFT_HYPHEN: 613cdf0e10cSrcweir lclInsertCharacter( pTableView, pTopView, CHAR_SHY ); 614cdf0e10cSrcweir break; 615cdf0e10cSrcweir case FN_INSERT_HARDHYPHEN: 616cdf0e10cSrcweir lclInsertCharacter( pTableView, pTopView, CHAR_NBHY ); 617cdf0e10cSrcweir break; 618cdf0e10cSrcweir case FN_INSERT_HARD_SPACE: 619cdf0e10cSrcweir lclInsertCharacter( pTableView, pTopView, CHAR_NBSP ); 620cdf0e10cSrcweir break; 621cdf0e10cSrcweir case SID_INSERT_RLM: 622cdf0e10cSrcweir lclInsertCharacter( pTableView, pTopView, CHAR_RLM ); 623cdf0e10cSrcweir break; 624cdf0e10cSrcweir case SID_INSERT_LRM: 625cdf0e10cSrcweir lclInsertCharacter( pTableView, pTopView, CHAR_LRM ); 626cdf0e10cSrcweir break; 627cdf0e10cSrcweir case SID_INSERT_ZWSP: 628cdf0e10cSrcweir lclInsertCharacter( pTableView, pTopView, CHAR_ZWSP ); 629cdf0e10cSrcweir break; 630cdf0e10cSrcweir case SID_INSERT_ZWNBSP: 631cdf0e10cSrcweir lclInsertCharacter( pTableView, pTopView, CHAR_ZWNBSP ); 632cdf0e10cSrcweir break; 633cdf0e10cSrcweir } 634cdf0e10cSrcweir 635cdf0e10cSrcweir pHdl->DataChanged(sal_False, bSetModified); 636cdf0e10cSrcweir if (bSetSelIsRef) 637cdf0e10cSrcweir pHdl->SetSelIsRef(sal_True); 638cdf0e10cSrcweir } 639cdf0e10cSrcweir 640cdf0e10cSrcweir void lcl_DisableAll( SfxItemSet& rSet ) // disable all slots 641cdf0e10cSrcweir { 642cdf0e10cSrcweir SfxWhichIter aIter( rSet ); 643cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich(); 644cdf0e10cSrcweir while (nWhich) 645cdf0e10cSrcweir { 646cdf0e10cSrcweir rSet.DisableItem( nWhich ); 647cdf0e10cSrcweir nWhich = aIter.NextWhich(); 648cdf0e10cSrcweir } 649cdf0e10cSrcweir } 650cdf0e10cSrcweir 651cdf0e10cSrcweir void __EXPORT ScEditShell::GetState( SfxItemSet& rSet ) 652cdf0e10cSrcweir { 653cdf0e10cSrcweir // #125326# When deactivating the view, edit mode is stopped, but the EditShell is left active 654cdf0e10cSrcweir // (a shell can't be removed from within Deactivate). In that state, the EditView isn't inserted 655cdf0e10cSrcweir // into the EditEngine, so it can have an invalid selection and must not be used. 656cdf0e10cSrcweir if ( !pViewData->HasEditView( pViewData->GetActivePart() ) ) 657cdf0e10cSrcweir { 658cdf0e10cSrcweir lcl_DisableAll( rSet ); 659cdf0e10cSrcweir return; 660cdf0e10cSrcweir } 661cdf0e10cSrcweir 662cdf0e10cSrcweir ScInputHandler* pHdl = GetMyInputHdl(); 663cdf0e10cSrcweir EditView* pActiveView = pHdl ? pHdl->GetActiveView() : pEditView; 664cdf0e10cSrcweir 665cdf0e10cSrcweir SfxWhichIter aIter( rSet ); 666cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich(); 667cdf0e10cSrcweir while (nWhich) 668cdf0e10cSrcweir { 669cdf0e10cSrcweir switch (nWhich) 670cdf0e10cSrcweir { 671cdf0e10cSrcweir case SID_ATTR_INSERT: // Statuszeile 672cdf0e10cSrcweir { 673cdf0e10cSrcweir if ( pActiveView ) 674cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, pActiveView->IsInsertMode() ) ); 675cdf0e10cSrcweir else 676cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, 42 ) ); 677cdf0e10cSrcweir } 678cdf0e10cSrcweir break; 679cdf0e10cSrcweir 680cdf0e10cSrcweir case SID_HYPERLINK_GETLINK: 681cdf0e10cSrcweir { 682cdf0e10cSrcweir SvxHyperlinkItem aHLinkItem; 683cdf0e10cSrcweir const SvxURLField* pURLField = GetURLField(); 684cdf0e10cSrcweir if ( pURLField ) 685cdf0e10cSrcweir { 686cdf0e10cSrcweir aHLinkItem.SetName( pURLField->GetRepresentation() ); 687cdf0e10cSrcweir aHLinkItem.SetURL( pURLField->GetURL() ); 688cdf0e10cSrcweir aHLinkItem.SetTargetFrame( pURLField->GetTargetFrame() ); 689cdf0e10cSrcweir } 690cdf0e10cSrcweir else if ( pActiveView ) 691cdf0e10cSrcweir { 692cdf0e10cSrcweir // use selected text as name for urls 693cdf0e10cSrcweir String sReturn = pActiveView->GetSelected(); 694cdf0e10cSrcweir sReturn.Erase(255); 695cdf0e10cSrcweir sReturn.EraseTrailingChars(); 696cdf0e10cSrcweir aHLinkItem.SetName(sReturn); 697cdf0e10cSrcweir } 698cdf0e10cSrcweir rSet.Put(aHLinkItem); 699cdf0e10cSrcweir } 700cdf0e10cSrcweir break; 701cdf0e10cSrcweir 702cdf0e10cSrcweir case SID_OPEN_HYPERLINK: 703cdf0e10cSrcweir { 704cdf0e10cSrcweir if ( !GetURLField() ) 705cdf0e10cSrcweir rSet.DisableItem( nWhich ); 706cdf0e10cSrcweir } 707cdf0e10cSrcweir break; 708cdf0e10cSrcweir 709cdf0e10cSrcweir case SID_TRANSLITERATE_HALFWIDTH: 710cdf0e10cSrcweir case SID_TRANSLITERATE_FULLWIDTH: 711cdf0e10cSrcweir case SID_TRANSLITERATE_HIRAGANA: 712cdf0e10cSrcweir case SID_TRANSLITERATE_KATAGANA: 713cdf0e10cSrcweir case SID_INSERT_RLM: 714cdf0e10cSrcweir case SID_INSERT_LRM: 715cdf0e10cSrcweir case SID_INSERT_ZWNBSP: 716cdf0e10cSrcweir case SID_INSERT_ZWSP: 717cdf0e10cSrcweir ScViewUtil::HideDisabledSlot( rSet, pViewData->GetBindings(), nWhich ); 718cdf0e10cSrcweir break; 719cdf0e10cSrcweir 720cdf0e10cSrcweir case SID_THES: 721cdf0e10cSrcweir { 722cdf0e10cSrcweir String aStatusVal; 723cdf0e10cSrcweir LanguageType nLang = LANGUAGE_NONE; 724cdf0e10cSrcweir bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, *pActiveView ); 725cdf0e10cSrcweir rSet.Put( SfxStringItem( SID_THES, aStatusVal ) ); 726cdf0e10cSrcweir 727cdf0e10cSrcweir // disable thesaurus context menu entry if there is nothing to look up 728cdf0e10cSrcweir sal_Bool bCanDoThesaurus = ScModule::HasThesaurusLanguage( nLang ); 729cdf0e10cSrcweir if (!bIsLookUpWord || !bCanDoThesaurus) 730cdf0e10cSrcweir rSet.DisableItem( SID_THES ); 731cdf0e10cSrcweir } 732cdf0e10cSrcweir break; 733cdf0e10cSrcweir 734cdf0e10cSrcweir 735cdf0e10cSrcweir } 736cdf0e10cSrcweir nWhich = aIter.NextWhich(); 737cdf0e10cSrcweir } 738cdf0e10cSrcweir } 739cdf0e10cSrcweir 740cdf0e10cSrcweir const SvxURLField* ScEditShell::GetURLField() 741cdf0e10cSrcweir { 742cdf0e10cSrcweir ScInputHandler* pHdl = GetMyInputHdl(); 743cdf0e10cSrcweir EditView* pActiveView = pHdl ? pHdl->GetActiveView() : pEditView; 744cdf0e10cSrcweir if ( pActiveView ) 745cdf0e10cSrcweir { 746cdf0e10cSrcweir const SvxFieldItem* pFieldItem = pActiveView->GetFieldAtSelection(); 747cdf0e10cSrcweir if (pFieldItem) 748cdf0e10cSrcweir { 749cdf0e10cSrcweir const SvxFieldData* pField = pFieldItem->GetField(); 750cdf0e10cSrcweir if ( pField && pField->ISA(SvxURLField) ) 751cdf0e10cSrcweir return (const SvxURLField*)pField; 752cdf0e10cSrcweir } 753cdf0e10cSrcweir } 754cdf0e10cSrcweir 755cdf0e10cSrcweir return NULL; 756cdf0e10cSrcweir } 757cdf0e10cSrcweir 758cdf0e10cSrcweir IMPL_LINK( ScEditShell, ClipboardChanged, TransferableDataHelper*, pDataHelper ) 759cdf0e10cSrcweir { 760cdf0e10cSrcweir if ( pDataHelper ) 761cdf0e10cSrcweir { 762cdf0e10cSrcweir bPastePossible = ( pDataHelper->HasFormat( SOT_FORMAT_STRING ) || pDataHelper->HasFormat( SOT_FORMAT_RTF ) ); 763cdf0e10cSrcweir 764cdf0e10cSrcweir SfxBindings& rBindings = pViewData->GetBindings(); 765cdf0e10cSrcweir rBindings.Invalidate( SID_PASTE ); 766cdf0e10cSrcweir rBindings.Invalidate( SID_PASTE_SPECIAL ); 767cdf0e10cSrcweir rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS ); 768cdf0e10cSrcweir } 769cdf0e10cSrcweir return 0; 770cdf0e10cSrcweir } 771cdf0e10cSrcweir 772cdf0e10cSrcweir void __EXPORT ScEditShell::GetClipState( SfxItemSet& rSet ) 773cdf0e10cSrcweir { 774cdf0e10cSrcweir if ( !pClipEvtLstnr ) 775cdf0e10cSrcweir { 776cdf0e10cSrcweir // create listener 777cdf0e10cSrcweir pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScEditShell, ClipboardChanged ) ); 778cdf0e10cSrcweir pClipEvtLstnr->acquire(); 779cdf0e10cSrcweir Window* pWin = pViewData->GetActiveWin(); 780cdf0e10cSrcweir pClipEvtLstnr->AddRemoveListener( pWin, sal_True ); 781cdf0e10cSrcweir 782cdf0e10cSrcweir // get initial state 783cdf0e10cSrcweir TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) ); 784cdf0e10cSrcweir bPastePossible = ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) || aDataHelper.HasFormat( SOT_FORMAT_RTF ) ); 785cdf0e10cSrcweir } 786cdf0e10cSrcweir 787cdf0e10cSrcweir SfxWhichIter aIter( rSet ); 788cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich(); 789cdf0e10cSrcweir while (nWhich) 790cdf0e10cSrcweir { 791cdf0e10cSrcweir switch (nWhich) 792cdf0e10cSrcweir { 793cdf0e10cSrcweir case SID_PASTE: 794cdf0e10cSrcweir case SID_PASTE_SPECIAL: 795cdf0e10cSrcweir if( !bPastePossible ) 796cdf0e10cSrcweir rSet.DisableItem( nWhich ); 797cdf0e10cSrcweir break; 798cdf0e10cSrcweir case SID_CLIPBOARD_FORMAT_ITEMS: 799cdf0e10cSrcweir if( bPastePossible ) 800cdf0e10cSrcweir { 801cdf0e10cSrcweir SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS ); 802cdf0e10cSrcweir TransferableDataHelper aDataHelper( 803cdf0e10cSrcweir TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) ); 804cdf0e10cSrcweir 805cdf0e10cSrcweir if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) ) 806cdf0e10cSrcweir aFormats.AddClipbrdFormat( SOT_FORMAT_STRING ); 807cdf0e10cSrcweir if ( aDataHelper.HasFormat( SOT_FORMAT_RTF ) ) 808cdf0e10cSrcweir aFormats.AddClipbrdFormat( SOT_FORMAT_RTF ); 809cdf0e10cSrcweir 810cdf0e10cSrcweir rSet.Put( aFormats ); 811cdf0e10cSrcweir } 812cdf0e10cSrcweir else 813cdf0e10cSrcweir rSet.DisableItem( nWhich ); 814cdf0e10cSrcweir break; 815cdf0e10cSrcweir } 816cdf0e10cSrcweir nWhich = aIter.NextWhich(); 817cdf0e10cSrcweir } 818cdf0e10cSrcweir } 819cdf0e10cSrcweir 820cdf0e10cSrcweir void lcl_InvalidateUnder( SfxBindings& rBindings ) 821cdf0e10cSrcweir { 822cdf0e10cSrcweir rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE ); 823cdf0e10cSrcweir rBindings.Invalidate( SID_ULINE_VAL_NONE ); 824cdf0e10cSrcweir rBindings.Invalidate( SID_ULINE_VAL_SINGLE ); 825cdf0e10cSrcweir rBindings.Invalidate( SID_ULINE_VAL_DOUBLE ); 826cdf0e10cSrcweir rBindings.Invalidate( SID_ULINE_VAL_DOTTED ); 827cdf0e10cSrcweir } 828cdf0e10cSrcweir 829cdf0e10cSrcweir void ScEditShell::ExecuteAttr(SfxRequest& rReq) 830cdf0e10cSrcweir { 831cdf0e10cSrcweir SfxItemSet aSet( pEditView->GetEmptyItemSet() ); 832cdf0e10cSrcweir SfxBindings& rBindings = pViewData->GetBindings(); 833cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs(); 834cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot(); 835cdf0e10cSrcweir 836cdf0e10cSrcweir switch ( nSlot ) 837cdf0e10cSrcweir { 838cdf0e10cSrcweir case SID_ATTR_CHAR_FONTHEIGHT: 839cdf0e10cSrcweir case SID_ATTR_CHAR_FONT: 840cdf0e10cSrcweir { 841cdf0e10cSrcweir if (pArgs) 842cdf0e10cSrcweir { 843cdf0e10cSrcweir // #i78017 establish the same behaviour as in Writer 844cdf0e10cSrcweir sal_uInt16 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX; 845cdf0e10cSrcweir if (nSlot == SID_ATTR_CHAR_FONT) 846cdf0e10cSrcweir { 847cdf0e10cSrcweir nScript = pEditView->GetSelectedScriptType(); 848cdf0e10cSrcweir if (nScript == 0) nScript = ScGlobal::GetDefaultScriptType(); 849cdf0e10cSrcweir } 850cdf0e10cSrcweir 851cdf0e10cSrcweir SfxItemPool& rPool = GetPool(); 852cdf0e10cSrcweir SvxScriptSetItem aSetItem( nSlot, rPool ); 853cdf0e10cSrcweir sal_uInt16 nWhich = rPool.GetWhich( nSlot ); 854cdf0e10cSrcweir aSetItem.PutItemForScriptType( nScript, pArgs->Get( nWhich ) ); 855cdf0e10cSrcweir 856cdf0e10cSrcweir aSet.Put( aSetItem.GetItemSet(), sal_False ); 857cdf0e10cSrcweir } 858cdf0e10cSrcweir } 859cdf0e10cSrcweir break; 860cdf0e10cSrcweir 861cdf0e10cSrcweir case SID_ATTR_CHAR_COLOR: 862cdf0e10cSrcweir { 863cdf0e10cSrcweir if (pArgs) 864cdf0e10cSrcweir { 865cdf0e10cSrcweir aSet.Put( pArgs->Get( pArgs->GetPool()->GetWhich( nSlot ) ) ); 866cdf0e10cSrcweir rBindings.Invalidate( nSlot ); 867cdf0e10cSrcweir } 868cdf0e10cSrcweir } 869cdf0e10cSrcweir break; 870cdf0e10cSrcweir 871cdf0e10cSrcweir // Toggles 872cdf0e10cSrcweir 873cdf0e10cSrcweir case SID_ATTR_CHAR_WEIGHT: 874cdf0e10cSrcweir { 875cdf0e10cSrcweir // #i78017 establish the same behaviour as in Writer 876cdf0e10cSrcweir sal_uInt16 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX; 877cdf0e10cSrcweir 878cdf0e10cSrcweir SfxItemPool& rPool = GetPool(); 879cdf0e10cSrcweir 880cdf0e10cSrcweir sal_Bool bOld = sal_False; 881cdf0e10cSrcweir SvxScriptSetItem aOldSetItem( nSlot, rPool ); 882cdf0e10cSrcweir aOldSetItem.GetItemSet().Put( pEditView->GetAttribs(), sal_False ); 883cdf0e10cSrcweir const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript ); 884cdf0e10cSrcweir if ( pCore && ((const SvxWeightItem*)pCore)->GetWeight() > WEIGHT_NORMAL ) 885cdf0e10cSrcweir bOld = sal_True; 886cdf0e10cSrcweir 887cdf0e10cSrcweir SvxScriptSetItem aSetItem( nSlot, rPool ); 888cdf0e10cSrcweir aSetItem.PutItemForScriptType( nScript, 889cdf0e10cSrcweir SvxWeightItem( bOld ? WEIGHT_NORMAL : WEIGHT_BOLD, EE_CHAR_WEIGHT ) ); 890cdf0e10cSrcweir aSet.Put( aSetItem.GetItemSet(), sal_False ); 891cdf0e10cSrcweir 892cdf0e10cSrcweir rBindings.Invalidate( nSlot ); 893cdf0e10cSrcweir } 894cdf0e10cSrcweir break; 895cdf0e10cSrcweir 896cdf0e10cSrcweir case SID_ATTR_CHAR_POSTURE: 897cdf0e10cSrcweir { 898cdf0e10cSrcweir // #i78017 establish the same behaviour as in Writer 899cdf0e10cSrcweir sal_uInt16 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX; 900cdf0e10cSrcweir 901cdf0e10cSrcweir SfxItemPool& rPool = GetPool(); 902cdf0e10cSrcweir 903cdf0e10cSrcweir sal_Bool bOld = sal_False; 904cdf0e10cSrcweir SvxScriptSetItem aOldSetItem( nSlot, rPool ); 905cdf0e10cSrcweir aOldSetItem.GetItemSet().Put( pEditView->GetAttribs(), sal_False ); 906cdf0e10cSrcweir const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript ); 907cdf0e10cSrcweir if ( pCore && ((const SvxPostureItem*)pCore)->GetValue() != ITALIC_NONE ) 908cdf0e10cSrcweir bOld = sal_True; 909cdf0e10cSrcweir 910cdf0e10cSrcweir SvxScriptSetItem aSetItem( nSlot, rPool ); 911cdf0e10cSrcweir aSetItem.PutItemForScriptType( nScript, 912cdf0e10cSrcweir SvxPostureItem( bOld ? ITALIC_NONE : ITALIC_NORMAL, EE_CHAR_ITALIC ) ); 913cdf0e10cSrcweir aSet.Put( aSetItem.GetItemSet(), sal_False ); 914cdf0e10cSrcweir 915cdf0e10cSrcweir rBindings.Invalidate( nSlot ); 916cdf0e10cSrcweir } 917cdf0e10cSrcweir break; 918cdf0e10cSrcweir 919cdf0e10cSrcweir case SID_ULINE_VAL_NONE: 920cdf0e10cSrcweir aSet.Put( SvxUnderlineItem( UNDERLINE_NONE, EE_CHAR_UNDERLINE ) ); 921cdf0e10cSrcweir lcl_InvalidateUnder( rBindings ); 922cdf0e10cSrcweir break; 923cdf0e10cSrcweir 924*900fdb6dSOliver-Rainer Wittmann case SID_ATTR_CHAR_UNDERLINE: 925*900fdb6dSOliver-Rainer Wittmann case SID_ULINE_VAL_SINGLE: 926*900fdb6dSOliver-Rainer Wittmann case SID_ULINE_VAL_DOUBLE: 927*900fdb6dSOliver-Rainer Wittmann case SID_ULINE_VAL_DOTTED: 928*900fdb6dSOliver-Rainer Wittmann { 929*900fdb6dSOliver-Rainer Wittmann FontUnderline eOld = ((const SvxUnderlineItem&) pEditView-> 930*900fdb6dSOliver-Rainer Wittmann GetAttribs().Get(EE_CHAR_UNDERLINE)).GetLineStyle(); 931*900fdb6dSOliver-Rainer Wittmann FontUnderline eNew = eOld; 932*900fdb6dSOliver-Rainer Wittmann switch (nSlot) 933*900fdb6dSOliver-Rainer Wittmann { 934*900fdb6dSOliver-Rainer Wittmann case SID_ATTR_CHAR_UNDERLINE: 935*900fdb6dSOliver-Rainer Wittmann if ( pArgs ) 936*900fdb6dSOliver-Rainer Wittmann { 937*900fdb6dSOliver-Rainer Wittmann const SvxTextLineItem& rTextLineItem = static_cast< const SvxTextLineItem& >( pArgs->Get( pArgs->GetPool()->GetWhich(nSlot) ) ); 938*900fdb6dSOliver-Rainer Wittmann eNew = rTextLineItem.GetLineStyle(); 939*900fdb6dSOliver-Rainer Wittmann } 940*900fdb6dSOliver-Rainer Wittmann else 941*900fdb6dSOliver-Rainer Wittmann { 942*900fdb6dSOliver-Rainer Wittmann eNew = ( eOld != UNDERLINE_NONE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE; 943*900fdb6dSOliver-Rainer Wittmann } 944*900fdb6dSOliver-Rainer Wittmann break; 945*900fdb6dSOliver-Rainer Wittmann case SID_ULINE_VAL_SINGLE: 946*900fdb6dSOliver-Rainer Wittmann eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE; 947*900fdb6dSOliver-Rainer Wittmann break; 948*900fdb6dSOliver-Rainer Wittmann case SID_ULINE_VAL_DOUBLE: 949*900fdb6dSOliver-Rainer Wittmann eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE; 950*900fdb6dSOliver-Rainer Wittmann break; 951*900fdb6dSOliver-Rainer Wittmann case SID_ULINE_VAL_DOTTED: 952*900fdb6dSOliver-Rainer Wittmann eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED; 953*900fdb6dSOliver-Rainer Wittmann break; 954*900fdb6dSOliver-Rainer Wittmann } 955*900fdb6dSOliver-Rainer Wittmann aSet.Put( SvxUnderlineItem( eNew, EE_CHAR_UNDERLINE ) ); 956*900fdb6dSOliver-Rainer Wittmann lcl_InvalidateUnder( rBindings ); 957*900fdb6dSOliver-Rainer Wittmann } 958*900fdb6dSOliver-Rainer Wittmann break; 959cdf0e10cSrcweir 960cdf0e10cSrcweir case SID_ATTR_CHAR_OVERLINE: 961cdf0e10cSrcweir { 962cdf0e10cSrcweir FontUnderline eOld = ((const SvxOverlineItem&) pEditView-> 963cdf0e10cSrcweir GetAttribs().Get(EE_CHAR_OVERLINE)).GetLineStyle(); 964cdf0e10cSrcweir FontUnderline eNew = ( eOld != UNDERLINE_NONE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE; 965cdf0e10cSrcweir aSet.Put( SvxOverlineItem( eNew, EE_CHAR_OVERLINE ) ); 966cdf0e10cSrcweir rBindings.Invalidate( nSlot ); 967cdf0e10cSrcweir } 968cdf0e10cSrcweir break; 969cdf0e10cSrcweir 970cdf0e10cSrcweir case SID_ATTR_CHAR_STRIKEOUT: 971cdf0e10cSrcweir { 972cdf0e10cSrcweir sal_Bool bOld = ((const SvxCrossedOutItem&)pEditView->GetAttribs(). 973cdf0e10cSrcweir Get(EE_CHAR_STRIKEOUT)).GetValue() != STRIKEOUT_NONE; 974cdf0e10cSrcweir aSet.Put( SvxCrossedOutItem( bOld ? STRIKEOUT_NONE : STRIKEOUT_SINGLE, EE_CHAR_STRIKEOUT ) ); 975cdf0e10cSrcweir rBindings.Invalidate( nSlot ); 976cdf0e10cSrcweir } 977cdf0e10cSrcweir break; 978cdf0e10cSrcweir 979cdf0e10cSrcweir case SID_ATTR_CHAR_SHADOWED: 980cdf0e10cSrcweir { 981cdf0e10cSrcweir sal_Bool bOld = ((const SvxShadowedItem&)pEditView->GetAttribs(). 982cdf0e10cSrcweir Get(EE_CHAR_SHADOW)).GetValue(); 983cdf0e10cSrcweir aSet.Put( SvxShadowedItem( !bOld, EE_CHAR_SHADOW ) ); 984cdf0e10cSrcweir rBindings.Invalidate( nSlot ); 985cdf0e10cSrcweir } 986cdf0e10cSrcweir break; 987cdf0e10cSrcweir 988cdf0e10cSrcweir case SID_ATTR_CHAR_CONTOUR: 989cdf0e10cSrcweir { 990cdf0e10cSrcweir sal_Bool bOld = ((const SvxContourItem&)pEditView->GetAttribs(). 991cdf0e10cSrcweir Get(EE_CHAR_OUTLINE)).GetValue(); 992cdf0e10cSrcweir aSet.Put( SvxContourItem( !bOld, EE_CHAR_OUTLINE ) ); 993cdf0e10cSrcweir rBindings.Invalidate( nSlot ); 994cdf0e10cSrcweir } 995cdf0e10cSrcweir break; 996cdf0e10cSrcweir 997cdf0e10cSrcweir case SID_SET_SUPER_SCRIPT: 998cdf0e10cSrcweir { 999cdf0e10cSrcweir SvxEscapement eOld = (SvxEscapement) ((const SvxEscapementItem&) 1000cdf0e10cSrcweir pEditView->GetAttribs().Get(EE_CHAR_ESCAPEMENT)).GetEnumValue(); 1001cdf0e10cSrcweir SvxEscapement eNew = (eOld == SVX_ESCAPEMENT_SUPERSCRIPT) ? 1002cdf0e10cSrcweir SVX_ESCAPEMENT_OFF : SVX_ESCAPEMENT_SUPERSCRIPT; 1003cdf0e10cSrcweir aSet.Put( SvxEscapementItem( eNew, EE_CHAR_ESCAPEMENT ) ); 1004cdf0e10cSrcweir rBindings.Invalidate( nSlot ); 1005cdf0e10cSrcweir } 1006cdf0e10cSrcweir break; 1007cdf0e10cSrcweir case SID_SET_SUB_SCRIPT: 1008cdf0e10cSrcweir { 1009cdf0e10cSrcweir SvxEscapement eOld = (SvxEscapement) ((const SvxEscapementItem&) 1010cdf0e10cSrcweir pEditView->GetAttribs().Get(EE_CHAR_ESCAPEMENT)).GetEnumValue(); 1011cdf0e10cSrcweir SvxEscapement eNew = (eOld == SVX_ESCAPEMENT_SUBSCRIPT) ? 1012cdf0e10cSrcweir SVX_ESCAPEMENT_OFF : SVX_ESCAPEMENT_SUBSCRIPT; 1013cdf0e10cSrcweir aSet.Put( SvxEscapementItem( eNew, EE_CHAR_ESCAPEMENT ) ); 1014cdf0e10cSrcweir rBindings.Invalidate( nSlot ); 1015cdf0e10cSrcweir } 1016cdf0e10cSrcweir break; 1017512ec161SZheng Fan case SID_ATTR_CHAR_KERNING: 1018512ec161SZheng Fan { 1019512ec161SZheng Fan if(pArgs) 1020512ec161SZheng Fan { 1021512ec161SZheng Fan aSet.Put ( pArgs->Get(pArgs->GetPool()->GetWhich(nSlot))); 1022512ec161SZheng Fan rBindings.Invalidate( nSlot ); 1023512ec161SZheng Fan } 1024512ec161SZheng Fan } 1025512ec161SZheng Fan break; 1026cdf0e10cSrcweir } 1027cdf0e10cSrcweir 1028cdf0e10cSrcweir // 1029cdf0e10cSrcweir // anwenden 1030cdf0e10cSrcweir // 1031cdf0e10cSrcweir 1032cdf0e10cSrcweir EditEngine* pEngine = pEditView->GetEditEngine(); 1033cdf0e10cSrcweir sal_Bool bOld = pEngine->GetUpdateMode(); 1034cdf0e10cSrcweir pEngine->SetUpdateMode(sal_False); 1035cdf0e10cSrcweir 1036cdf0e10cSrcweir pEditView->SetAttribs( aSet ); 1037cdf0e10cSrcweir 1038cdf0e10cSrcweir pEngine->SetUpdateMode(bOld); 1039cdf0e10cSrcweir pEditView->Invalidate(); 1040cdf0e10cSrcweir 1041cdf0e10cSrcweir ScInputHandler* pHdl = GetMyInputHdl(); 1042cdf0e10cSrcweir pHdl->SetModified(); 1043cdf0e10cSrcweir 1044cdf0e10cSrcweir rReq.Done(); 1045cdf0e10cSrcweir } 1046cdf0e10cSrcweir 1047cdf0e10cSrcweir void ScEditShell::GetAttrState(SfxItemSet &rSet) 1048cdf0e10cSrcweir { 1049cdf0e10cSrcweir if ( !pViewData->HasEditView( pViewData->GetActivePart() ) ) // #125326# 1050cdf0e10cSrcweir { 1051cdf0e10cSrcweir lcl_DisableAll( rSet ); 1052cdf0e10cSrcweir return; 1053cdf0e10cSrcweir } 1054cdf0e10cSrcweir 1055cdf0e10cSrcweir SfxItemSet aAttribs = pEditView->GetAttribs(); 1056cdf0e10cSrcweir rSet.Put( aAttribs ); 1057cdf0e10cSrcweir 1058cdf0e10cSrcweir // choose font info according to selection script type 1059cdf0e10cSrcweir 1060cdf0e10cSrcweir sal_uInt16 nScript = pEditView->GetSelectedScriptType(); 1061cdf0e10cSrcweir if (nScript == 0) nScript = ScGlobal::GetDefaultScriptType(); 1062cdf0e10cSrcweir 1063cdf0e10cSrcweir // #i55929# input-language-dependent script type (depends on input language if nothing selected) 1064cdf0e10cSrcweir sal_uInt16 nInputScript = nScript; 1065cdf0e10cSrcweir if ( !pEditView->GetSelection().HasRange() ) 1066cdf0e10cSrcweir { 1067cdf0e10cSrcweir LanguageType nInputLang = pViewData->GetActiveWin()->GetInputLanguage(); 1068cdf0e10cSrcweir if (nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM) 1069cdf0e10cSrcweir nInputScript = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang ); 1070cdf0e10cSrcweir } 1071cdf0e10cSrcweir 1072cdf0e10cSrcweir // #i55929# according to spec, nInputScript is used for font and font height only 1073cdf0e10cSrcweir if ( rSet.GetItemState( EE_CHAR_FONTINFO ) != SFX_ITEM_UNKNOWN ) 1074cdf0e10cSrcweir ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_FONTINFO, nInputScript ); 1075cdf0e10cSrcweir if ( rSet.GetItemState( EE_CHAR_FONTHEIGHT ) != SFX_ITEM_UNKNOWN ) 1076cdf0e10cSrcweir ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_FONTHEIGHT, nInputScript ); 1077cdf0e10cSrcweir if ( rSet.GetItemState( EE_CHAR_WEIGHT ) != SFX_ITEM_UNKNOWN ) 1078cdf0e10cSrcweir ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_WEIGHT, nScript ); 1079cdf0e10cSrcweir if ( rSet.GetItemState( EE_CHAR_ITALIC ) != SFX_ITEM_UNKNOWN ) 1080cdf0e10cSrcweir ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_ITALIC, nScript ); 1081cdf0e10cSrcweir 1082cdf0e10cSrcweir // Unterstreichung 1083cdf0e10cSrcweir 1084cdf0e10cSrcweir SfxItemState eState = aAttribs.GetItemState( EE_CHAR_UNDERLINE, sal_True ); 1085cdf0e10cSrcweir if ( eState == SFX_ITEM_DONTCARE ) 1086cdf0e10cSrcweir { 1087cdf0e10cSrcweir rSet.InvalidateItem( SID_ULINE_VAL_NONE ); 1088cdf0e10cSrcweir rSet.InvalidateItem( SID_ULINE_VAL_SINGLE ); 1089cdf0e10cSrcweir rSet.InvalidateItem( SID_ULINE_VAL_DOUBLE ); 1090cdf0e10cSrcweir rSet.InvalidateItem( SID_ULINE_VAL_DOTTED ); 1091cdf0e10cSrcweir } 1092cdf0e10cSrcweir else 1093cdf0e10cSrcweir { 1094cdf0e10cSrcweir FontUnderline eUnderline = ((const SvxUnderlineItem&) 1095cdf0e10cSrcweir aAttribs.Get(EE_CHAR_UNDERLINE)).GetLineStyle(); 1096cdf0e10cSrcweir sal_uInt16 nId = SID_ULINE_VAL_NONE; 1097cdf0e10cSrcweir switch (eUnderline) 1098cdf0e10cSrcweir { 1099cdf0e10cSrcweir case UNDERLINE_SINGLE: nId = SID_ULINE_VAL_SINGLE; break; 1100cdf0e10cSrcweir case UNDERLINE_DOUBLE: nId = SID_ULINE_VAL_DOUBLE; break; 1101cdf0e10cSrcweir case UNDERLINE_DOTTED: nId = SID_ULINE_VAL_DOTTED; break; 1102cdf0e10cSrcweir default: 1103cdf0e10cSrcweir break; 1104cdf0e10cSrcweir } 1105cdf0e10cSrcweir rSet.Put( SfxBoolItem( nId, sal_True ) ); 1106cdf0e10cSrcweir } 1107cdf0e10cSrcweir 1108cdf0e10cSrcweir //! Testen, ob Klammer-Hervorhebung aktiv ist !!!! 1109cdf0e10cSrcweir ScInputHandler* pHdl = GetMyInputHdl(); 1110cdf0e10cSrcweir if ( pHdl && pHdl->IsFormulaMode() ) 1111cdf0e10cSrcweir rSet.ClearItem( EE_CHAR_WEIGHT ); // hervorgehobene Klammern hier nicht 1112512ec161SZheng Fan 1113512ec161SZheng Fan SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&) 1114512ec161SZheng Fan aAttribs.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue(); 1115512ec161SZheng Fan if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT ) 1116512ec161SZheng Fan { 1117512ec161SZheng Fan rSet.Put( SfxBoolItem( SID_SET_SUPER_SCRIPT, sal_True ) ); 1118512ec161SZheng Fan } 1119512ec161SZheng Fan else if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT ) 1120512ec161SZheng Fan { 1121512ec161SZheng Fan rSet.Put( SfxBoolItem( SID_SET_SUB_SCRIPT, sal_True ) ); 1122512ec161SZheng Fan } 1123512ec161SZheng Fan pViewData->GetBindings().Invalidate( SID_SET_SUPER_SCRIPT ); 1124512ec161SZheng Fan pViewData->GetBindings().Invalidate( SID_SET_SUB_SCRIPT ); 1125512ec161SZheng Fan 1126512ec161SZheng Fan eState = aAttribs.GetItemState( EE_CHAR_KERNING, sal_True ); 1127512ec161SZheng Fan pViewData->GetBindings().Invalidate( SID_ATTR_CHAR_KERNING ); 1128512ec161SZheng Fan if ( eState == SFX_ITEM_DONTCARE ) 1129512ec161SZheng Fan { 1130512ec161SZheng Fan // rSet.InvalidateItem( SID_ATTR_CHAR_KERNING ); 1131512ec161SZheng Fan rSet.InvalidateItem(EE_CHAR_KERNING); 1132512ec161SZheng Fan } 1133cdf0e10cSrcweir } 1134cdf0e10cSrcweir 1135cdf0e10cSrcweir String ScEditShell::GetSelectionText( sal_Bool bWholeWord ) 1136cdf0e10cSrcweir { 1137cdf0e10cSrcweir String aStrSelection; 1138cdf0e10cSrcweir 1139cdf0e10cSrcweir if ( pViewData->HasEditView( pViewData->GetActivePart() ) ) // #125326# 1140cdf0e10cSrcweir { 1141cdf0e10cSrcweir if ( bWholeWord ) 1142cdf0e10cSrcweir { 1143cdf0e10cSrcweir EditEngine* pEngine = pEditView->GetEditEngine(); 1144cdf0e10cSrcweir ESelection aSel = pEditView->GetSelection(); 1145cdf0e10cSrcweir String aStrCurrentDelimiters = pEngine->GetWordDelimiters(); 1146cdf0e10cSrcweir 1147cdf0e10cSrcweir pEngine->SetWordDelimiters( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(" .,;\"'")) ); 1148cdf0e10cSrcweir aStrSelection = pEngine->GetWord( aSel.nEndPara, aSel.nEndPos ); 1149cdf0e10cSrcweir pEngine->SetWordDelimiters( aStrCurrentDelimiters ); 1150cdf0e10cSrcweir } 1151cdf0e10cSrcweir else 1152cdf0e10cSrcweir { 1153cdf0e10cSrcweir aStrSelection = pEditView->GetSelected(); 1154cdf0e10cSrcweir } 1155cdf0e10cSrcweir } 1156cdf0e10cSrcweir 1157cdf0e10cSrcweir return aStrSelection; 1158cdf0e10cSrcweir } 1159cdf0e10cSrcweir 1160cdf0e10cSrcweir void ScEditShell::ExecuteUndo(SfxRequest& rReq) 1161cdf0e10cSrcweir { 1162cdf0e10cSrcweir // #81733# Undo must be handled here because it's called for both EditViews 1163cdf0e10cSrcweir 1164cdf0e10cSrcweir ScInputHandler* pHdl = GetMyInputHdl(); 1165cdf0e10cSrcweir DBG_ASSERT(pHdl,"no ScInputHandler"); 1166cdf0e10cSrcweir EditView* pTopView = pHdl->GetTopView(); 1167cdf0e10cSrcweir EditView* pTableView = pHdl->GetTableView(); 1168cdf0e10cSrcweir DBG_ASSERT(pTableView,"no EditView"); 1169cdf0e10cSrcweir 1170cdf0e10cSrcweir pHdl->DataChanging(); 1171cdf0e10cSrcweir 1172cdf0e10cSrcweir const SfxItemSet* pReqArgs = rReq.GetArgs(); 1173cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot(); 1174cdf0e10cSrcweir switch ( nSlot ) 1175cdf0e10cSrcweir { 1176cdf0e10cSrcweir case SID_UNDO: 1177cdf0e10cSrcweir case SID_REDO: 1178cdf0e10cSrcweir { 1179cdf0e10cSrcweir sal_Bool bIsUndo = ( nSlot == SID_UNDO ); 1180cdf0e10cSrcweir 1181cdf0e10cSrcweir sal_uInt16 nCount = 1; 1182cdf0e10cSrcweir const SfxPoolItem* pItem; 1183cdf0e10cSrcweir if ( pReqArgs && pReqArgs->GetItemState( nSlot, sal_True, &pItem ) == SFX_ITEM_SET ) 1184cdf0e10cSrcweir nCount = ((const SfxUInt16Item*)pItem)->GetValue(); 1185cdf0e10cSrcweir 1186cdf0e10cSrcweir for (sal_uInt16 i=0; i<nCount; i++) 1187cdf0e10cSrcweir { 1188cdf0e10cSrcweir if ( bIsUndo ) 1189cdf0e10cSrcweir { 1190cdf0e10cSrcweir pTableView->Undo(); 1191cdf0e10cSrcweir if (pTopView) 1192cdf0e10cSrcweir pTopView->Undo(); 1193cdf0e10cSrcweir } 1194cdf0e10cSrcweir else 1195cdf0e10cSrcweir { 1196cdf0e10cSrcweir pTableView->Redo(); 1197cdf0e10cSrcweir if (pTopView) 1198cdf0e10cSrcweir pTopView->Redo(); 1199cdf0e10cSrcweir } 1200cdf0e10cSrcweir } 1201cdf0e10cSrcweir } 1202cdf0e10cSrcweir break; 1203cdf0e10cSrcweir } 1204cdf0e10cSrcweir pViewData->GetBindings().InvalidateAll(sal_False); 1205cdf0e10cSrcweir 1206cdf0e10cSrcweir pHdl->DataChanged(); 1207cdf0e10cSrcweir } 1208cdf0e10cSrcweir 1209cdf0e10cSrcweir void ScEditShell::GetUndoState(SfxItemSet &rSet) 1210cdf0e10cSrcweir { 1211cdf0e10cSrcweir // Undo state is taken from normal ViewFrame state function 1212cdf0e10cSrcweir 1213cdf0e10cSrcweir SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame(); 1214cdf0e10cSrcweir if ( pViewFrm && GetUndoManager() ) 1215cdf0e10cSrcweir { 1216cdf0e10cSrcweir SfxWhichIter aIter(rSet); 1217cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich(); 1218cdf0e10cSrcweir while( nWhich ) 1219cdf0e10cSrcweir { 1220cdf0e10cSrcweir pViewFrm->GetSlotState( nWhich, NULL, &rSet ); 1221cdf0e10cSrcweir nWhich = aIter.NextWhich(); 1222cdf0e10cSrcweir } 1223cdf0e10cSrcweir } 1224cdf0e10cSrcweir 1225cdf0e10cSrcweir // disable if no action in input line EditView 1226cdf0e10cSrcweir 1227cdf0e10cSrcweir ScInputHandler* pHdl = GetMyInputHdl(); 1228cdf0e10cSrcweir DBG_ASSERT(pHdl,"no ScInputHandler"); 1229cdf0e10cSrcweir EditView* pTopView = pHdl->GetTopView(); 1230cdf0e10cSrcweir if (pTopView) 1231cdf0e10cSrcweir { 1232cdf0e10cSrcweir ::svl::IUndoManager& rTopMgr = pTopView->GetEditEngine()->GetUndoManager(); 1233cdf0e10cSrcweir if ( rTopMgr.GetUndoActionCount() == 0 ) 1234cdf0e10cSrcweir rSet.DisableItem( SID_UNDO ); 1235cdf0e10cSrcweir if ( rTopMgr.GetRedoActionCount() == 0 ) 1236cdf0e10cSrcweir rSet.DisableItem( SID_REDO ); 1237cdf0e10cSrcweir } 1238cdf0e10cSrcweir } 1239cdf0e10cSrcweir 1240cdf0e10cSrcweir void ScEditShell::ExecuteTrans( SfxRequest& rReq ) 1241cdf0e10cSrcweir { 1242cdf0e10cSrcweir sal_Int32 nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() ); 1243cdf0e10cSrcweir if ( nType ) 1244cdf0e10cSrcweir { 1245cdf0e10cSrcweir ScInputHandler* pHdl = GetMyInputHdl(); 1246cdf0e10cSrcweir DBG_ASSERT( pHdl, "no ScInputHandler" ); 1247cdf0e10cSrcweir 1248cdf0e10cSrcweir EditView* pTopView = pHdl->GetTopView(); 1249cdf0e10cSrcweir EditView* pTableView = pHdl->GetTableView(); 1250cdf0e10cSrcweir DBG_ASSERT( pTableView, "no EditView" ); 1251cdf0e10cSrcweir 1252cdf0e10cSrcweir pHdl->DataChanging(); 1253cdf0e10cSrcweir 1254cdf0e10cSrcweir pTableView->TransliterateText( nType ); 1255cdf0e10cSrcweir if (pTopView) 1256cdf0e10cSrcweir pTopView->TransliterateText( nType ); 1257cdf0e10cSrcweir 1258cdf0e10cSrcweir pHdl->DataChanged(); 1259cdf0e10cSrcweir } 1260cdf0e10cSrcweir } 1261