1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 31 32 #define _SW_FRMVALID_HXX 33 #include <hintids.hxx> 34 35 #include <svl/globalnameitem.hxx> 36 #include <sfx2/objface.hxx> 37 #include <sfx2/lnkbase.hxx> 38 39 #include <tools/errinf.hxx> 40 #include <svx/svdview.hxx> 41 #include <svl/ptitem.hxx> 42 #include <svl/stritem.hxx> 43 #include <unotools/moduleoptions.hxx> 44 #include <vcl/msgbox.hxx> 45 #include <sfx2/fcontnr.hxx> 46 #include <svx/hlnkitem.hxx> 47 #include <svl/srchitem.hxx> 48 #include <sfx2/dispatch.hxx> 49 #include <sfx2/docfile.hxx> 50 #include <svl/urihelper.hxx> 51 #include <basic/sbxvar.hxx> 52 #include <svl/whiter.hxx> 53 #include <sfx2/request.hxx> 54 #include <editeng/opaqitem.hxx> 55 #include <editeng/fontitem.hxx> 56 #include <editeng/adjitem.hxx> 57 #include <editeng/boxitem.hxx> 58 #include <editeng/sizeitem.hxx> 59 #include <editeng/svxacorr.hxx> 60 #include <editeng/scripttypeitem.hxx> 61 #include <svtools/filter.hxx> 62 #include <svx/htmlmode.hxx> 63 #include <svx/pfiledlg.hxx> 64 #include <svtools/htmlcfg.hxx> 65 #include <com/sun/star/i18n/TransliterationModules.hpp> 66 #include <com/sun/star/i18n/TransliterationModulesExtra.hpp> 67 68 #include <sot/clsids.hxx> 69 #include <editeng/acorrcfg.hxx> 70 #include <wdocsh.hxx> 71 #include <fmtinfmt.hxx> 72 #include <fmtclds.hxx> 73 #include <fmtsrnd.hxx> 74 #include <fmtfsize.hxx> 75 #include <swmodule.hxx> 76 #include <wrtsh.hxx> 77 #include <view.hxx> 78 #include <docsh.hxx> 79 #include <doc.hxx> 80 #include <uitool.hxx> 81 #include <cmdid.h> 82 #include <globals.hrc> 83 #include <frmmgr.hxx> 84 #include <textsh.hxx> 85 #include <frmfmt.hxx> 86 #include <tablemgr.hxx> 87 #include <swundo.hxx> // fuer Undo-IDs 88 #include <shellio.hxx> 89 #include <frmdlg.hxx> 90 #include <usrpref.hxx> 91 #include <swtable.hxx> 92 #include <tblafmt.hxx> 93 #include <caption.hxx> 94 #include <idxmrk.hxx> 95 #include <poolfmt.hxx> 96 #include <breakit.hxx> 97 #include <crsskip.hxx> 98 #include <modcfg.hxx> 99 #include <column.hxx> 100 #include <edtwin.hxx> 101 #include <shells.hrc> 102 #include <popup.hrc> 103 #include <swerror.h> 104 #include <SwAppletImpl.hxx> 105 #include <unochart.hxx> 106 107 #include <chartins.hxx> 108 109 #define SwTextShell 110 #define Paragraph 111 #define HyphenZone 112 #define TextFont 113 #define DropCap 114 #include <sfx2/msg.hxx> 115 #include <swslots.hxx> 116 #include <SwRewriter.hxx> 117 #include <comcore.hrc> 118 119 using namespace ::com::sun::star; 120 using ::rtl::OUString; 121 122 #include <svx/svxdlg.hxx> 123 #include <svx/dialogs.hrc> 124 #include "swabstdlg.hxx" 125 #include <misc.hrc> 126 #include <table.hrc> 127 #include <frmui.hrc> 128 #include <unomid.h> 129 130 131 132 /*-------------------------------------------------------------------- 133 Beschreibung: 134 --------------------------------------------------------------------*/ 135 136 SFX_IMPL_INTERFACE(SwTextShell, SwBaseShell, SW_RES(STR_SHELLNAME_TEXT)) 137 { 138 SFX_POPUPMENU_REGISTRATION(SW_RES(MN_TEXT_POPUPMENU)); 139 SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TEXT_TOOLBOX)); 140 SFX_CHILDWINDOW_REGISTRATION(FN_EDIT_FORMULA); 141 SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_FIELD); 142 SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_IDX_ENTRY_DLG); 143 SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_AUTH_ENTRY_DLG); 144 SFX_CHILDWINDOW_REGISTRATION(SID_RUBY_DIALOG); 145 } 146 147 148 149 TYPEINIT1(SwTextShell,SwBaseShell) 150 151 152 153 void SwTextShell::ExecInsert(SfxRequest &rReq) 154 { 155 SwWrtShell &rSh = GetShell(); 156 157 ASSERT( !rSh.IsObjSelected() && !rSh.IsFrmSelected(), 158 "Falsche Shell auf dem Dispatcher" ); 159 160 const SfxItemSet *pArgs = rReq.GetArgs(); 161 const SfxPoolItem* pItem = 0; 162 sal_uInt16 nSlot = rReq.GetSlot(); 163 if(pArgs) 164 pArgs->GetItemState(nSlot, sal_False, &pItem ); 165 166 switch( nSlot ) 167 { 168 case FN_INSERT_STRING: 169 if( pItem ) 170 rSh.InsertByWord(((const SfxStringItem *)pItem)->GetValue()); 171 break; 172 case FN_INSERT_SOFT_HYPHEN: 173 if( CHAR_SOFTHYPHEN != rSh.SwCrsrShell::GetChar( sal_True, 0 ) && 174 CHAR_SOFTHYPHEN != rSh.SwCrsrShell::GetChar( sal_True, -1 )) 175 rSh.Insert( String( CHAR_SOFTHYPHEN ) ); 176 break; 177 178 case FN_INSERT_HARDHYPHEN: 179 case FN_INSERT_HARD_SPACE: 180 { 181 sal_Unicode cIns = FN_INSERT_HARD_SPACE == nSlot ? CHAR_HARDBLANK 182 : CHAR_HARDHYPHEN; 183 184 SvxAutoCorrCfg* pACfg = SvxAutoCorrCfg::Get(); 185 SvxAutoCorrect* pACorr = pACfg->GetAutoCorrect(); 186 if( pACorr && pACfg->IsAutoFmtByInput() && 187 pACorr->IsAutoCorrFlag( CptlSttSntnc | CptlSttWrd | 188 AddNonBrkSpace | ChgOrdinalNumber | 189 ChgToEnEmDash | SetINetAttr | Autocorrect )) 190 rSh.AutoCorrect( *pACorr, cIns ); 191 else 192 rSh.Insert( String( cIns ) ); 193 } 194 break; 195 case SID_INSERT_RLM : 196 case SID_INSERT_LRM : 197 case SID_INSERT_ZWNBSP : 198 case SID_INSERT_ZWSP: 199 { 200 sal_Unicode cIns = 0; 201 switch(nSlot) 202 { 203 case SID_INSERT_RLM : cIns = CHAR_RLM ; break; 204 case SID_INSERT_LRM : cIns = CHAR_LRM ; break; 205 case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break; 206 case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break; 207 } 208 rSh.Insert( String( cIns ) ); 209 } 210 break; 211 case FN_INSERT_BREAK: 212 rSh.SplitNode(); 213 rReq.Done(); 214 break; 215 case FN_INSERT_PAGEBREAK: 216 rSh.InsertPageBreak(); 217 rReq.Done(); 218 break; 219 case FN_INSERT_LINEBREAK: 220 rSh.InsertLineBreak(); 221 rReq.Done(); 222 break; 223 case FN_INSERT_COLUMN_BREAK: 224 rSh.InsertColumnBreak(); 225 rReq.Done(); 226 break; 227 case SID_HYPERLINK_SETLINK: 228 if (pItem) 229 InsertHyperlink(*((const SvxHyperlinkItem *)pItem)); 230 rReq.Done(); 231 break; 232 case SID_INSERT_AVMEDIA: 233 rReq.SetReturnValue(SfxBoolItem(nSlot, InsertMediaDlg( rReq ))); 234 break; 235 case SID_INSERT_SOUND: 236 case SID_INSERT_VIDEO: 237 { 238 SvxPluginFileDlg aDlg( &GetView().GetViewFrame()->GetWindow(), nSlot ); 239 aDlg.SetContext( nSlot == SID_INSERT_SOUND? sfx2::FileDialogHelper::SW_INSERT_SOUND : sfx2::FileDialogHelper::SW_INSERT_VIDEO ); 240 241 if ( ERRCODE_NONE == aDlg.Execute() ) 242 { 243 // URL ermitteln 244 String aStrURL( aDlg.GetPath() ); 245 aStrURL = URIHelper::SmartRel2Abs( 246 INetURLObject(), aStrURL, URIHelper::GetMaybeFileHdl() ); 247 248 INetURLObject* pURL = new INetURLObject(); 249 pURL->SetSmartProtocol( INET_PROT_FILE ); 250 251 if ( pURL->SetURL( aStrURL, INetURLObject::WAS_ENCODED ) ) 252 { 253 ::rtl::OUString aName; 254 comphelper::EmbeddedObjectContainer aCnt; 255 svt::EmbeddedObjectRef xObj( aCnt.CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence(), aName ), embed::Aspects::MSOLE_CONTENT ); 256 if ( xObj.is() ) 257 { 258 svt::EmbeddedObjectRef::TryRunningState( xObj.GetObject() ); 259 260 // set properties from dialog 261 uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY ); 262 if ( xSet.is() ) 263 { 264 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginURL"), 265 uno::makeAny( ::rtl::OUString( pURL->GetMainURL( INetURLObject::NO_DECODE ) ) ) ); 266 } 267 } 268 269 rSh.InsertObject( xObj, 0, sal_True, nSlot); 270 } 271 } 272 } 273 break; 274 case SID_INSERT_OBJECT: 275 case SID_INSERT_PLUGIN: 276 { 277 SFX_REQUEST_ARG( rReq, pNameItem, SfxGlobalNameItem, SID_INSERT_OBJECT, sal_False ); 278 SvGlobalName *pName = NULL; 279 SvGlobalName aName; 280 if ( pNameItem ) 281 { 282 aName = pNameItem->GetValue(); 283 pName = &aName; 284 } 285 286 SFX_REQUEST_ARG( rReq, pClassLocationItem, SfxStringItem, FN_PARAM_2, sal_False ); 287 SFX_REQUEST_ARG( rReq, pCommandsItem, SfxStringItem, FN_PARAM_3, sal_False ); 288 //TODO/LATER: recording currently not working, need code for Commandlist 289 svt::EmbeddedObjectRef xObj; 290 if( nSlot == SID_INSERT_PLUGIN && ( pClassLocationItem || pCommandsItem ) ) 291 { 292 String sClassLocation; 293 if(pClassLocationItem) 294 sClassLocation = pClassLocationItem->GetValue(); 295 296 SvCommandList aCommandList; 297 if(pCommandsItem) 298 { 299 sal_uInt16 nTemp; 300 aCommandList.AppendCommands( pCommandsItem->GetValue(), &nTemp ); 301 } 302 303 { 304 comphelper::EmbeddedObjectContainer aCnt; 305 ::rtl::OUString sName; 306 xObj.Assign( aCnt.CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence(), sName ), 307 embed::Aspects::MSOLE_CONTENT ); 308 svt::EmbeddedObjectRef::TryRunningState( xObj.GetObject() ); 309 uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY ); 310 if ( xSet.is() ) 311 { 312 try 313 { 314 if ( sClassLocation.Len() ) 315 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginURL"), 316 uno::makeAny( 317 ::rtl::OUString( 318 URIHelper::SmartRel2Abs( 319 INetURLObject(), sClassLocation, 320 URIHelper::GetMaybeFileHdl()) ) ) ); 321 uno::Sequence< beans::PropertyValue > aSeq; 322 if ( aCommandList.Count() ) 323 { 324 aCommandList.FillSequence( aSeq ); 325 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginCommands"), uno::makeAny( aSeq ) ); 326 } 327 } 328 catch ( uno::Exception& ) 329 { 330 } 331 } 332 } 333 334 if(xObj.is()) 335 rSh.InsertOleObject( xObj ); 336 } 337 else 338 { 339 DBG_ASSERT( !pNameItem || nSlot == SID_INSERT_OBJECT, "Superfluous argument!" ); 340 rSh.InsertObject( xObj, pName, sal_True, nSlot); 341 rReq.Done(); 342 } 343 break; 344 } 345 case SID_INSERT_FLOATINGFRAME: 346 { 347 svt::EmbeddedObjectRef xObj; 348 SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, FN_PARAM_1, sal_False ); 349 SFX_REQUEST_ARG( rReq, pURLItem, SfxStringItem, FN_PARAM_2, sal_False ); 350 SFX_REQUEST_ARG( rReq, pMarginItem, SvxSizeItem, FN_PARAM_3, sal_False ); 351 SFX_REQUEST_ARG( rReq, pScrollingItem, SfxByteItem, FN_PARAM_4, sal_False ); 352 SFX_REQUEST_ARG( rReq, pBorderItem, SfxBoolItem, FN_PARAM_5, sal_False ); 353 354 if(pURLItem) // URL is a _must_ 355 { 356 comphelper::EmbeddedObjectContainer aCnt; 357 ::rtl::OUString aName; 358 xObj.Assign( aCnt.CreateEmbeddedObject( SvGlobalName( SO3_IFRAME_CLASSID ).GetByteSequence(), aName ), 359 embed::Aspects::MSOLE_CONTENT ); 360 svt::EmbeddedObjectRef::TryRunningState( xObj.GetObject() ); 361 uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY ); 362 if ( xSet.is() ) 363 { 364 try 365 { 366 ScrollingMode eScroll = ScrollingAuto; 367 if( pScrollingItem && pScrollingItem->GetValue() <= ScrollingAuto ) 368 eScroll = (ScrollingMode) pScrollingItem->GetValue(); 369 370 Size aMargin; 371 if ( pMarginItem ) 372 aMargin = pMarginItem->GetSize(); 373 374 if ( pURLItem ) 375 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameURL"), uno::makeAny( ::rtl::OUString( pURLItem->GetValue() ) ) ); 376 if ( pNameItem ) 377 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameName"), uno::makeAny( ::rtl::OUString( pNameItem->GetValue() ) ) ); 378 379 if ( eScroll == ScrollingAuto ) 380 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoScroll"), 381 uno::makeAny( sal_True ) ); 382 else 383 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsScrollingMode"), 384 uno::makeAny( (sal_Bool) ( eScroll == ScrollingYes) ) ); 385 386 //if ( aFrmDescr.IsFrameBorderSet() ) 387 if ( pBorderItem ) 388 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsBorder"), 389 uno::makeAny( (sal_Bool) pBorderItem->GetValue() ) ); 390 /*else 391 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoBorder"), 392 makeAny( sal_True ) );*/ 393 394 if ( pMarginItem ) 395 { 396 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginWidth"), 397 uno::makeAny( sal_Int32( aMargin.Width() ) ) ); 398 399 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginHeight"), 400 uno::makeAny( sal_Int32( aMargin.Height() ) ) ); 401 } 402 } 403 catch ( uno::Exception& ) 404 { 405 } 406 } 407 408 rSh.InsertOleObject( xObj ); 409 } 410 else 411 { 412 rSh.InsertObject( xObj, 0, sal_True, nSlot); 413 rReq.Done(); 414 } 415 } 416 break; 417 case SID_INSERT_DIAGRAM: 418 { 419 SvtModuleOptions aMOpt; 420 if ( !aMOpt.IsChart() ) 421 break; 422 if(!rReq.IsAPI()) 423 { 424 SfxViewFrame* pVFrame = GetView().GetViewFrame(); 425 SwInsertChart( &GetView().GetEditWin(), &pVFrame->GetBindings() ); 426 } 427 else 428 { 429 uno::Reference< chart2::data::XDataProvider > xDataProvider; 430 sal_Bool bFillWithData = sal_True; 431 OUString aRangeString; 432 if (!GetShell().IsTblComplexForChart()) 433 { 434 SwFrmFmt* pTblFmt = GetShell().GetTableFmt(); 435 String aCurrentTblName = pTblFmt->GetName(); 436 // String aText( String::CreateFromAscii("<.>") ); // was used for UI 437 // aText.Insert( rWrtShell.GetBoxNms(), 2); 438 // aText.Insert( aCurrentTblName, 1 ); 439 aRangeString = aCurrentTblName; 440 aRangeString += OUString::valueOf( sal_Unicode('.') ); 441 aRangeString += GetShell().GetBoxNms(); 442 443 // get table data provider 444 xDataProvider.set( GetView().GetDocShell()->getIDocumentChartDataProviderAccess()->GetChartDataProvider() ); 445 } 446 else 447 bFillWithData = sal_False; // will create chart with only it's default image 448 449 SwTableFUNC( &rSh, sal_False ).InsertChart( xDataProvider, bFillWithData, aRangeString ); 450 rSh.LaunchOLEObj(); 451 452 svt::EmbeddedObjectRef& xObj = rSh.GetOLEObject(); 453 if(pItem && xObj.is()) 454 { 455 Size aSize(((SvxSizeItem*)pItem)->GetSize()); 456 aSize = OutputDevice::LogicToLogic 457 ( aSize, MapMode( MAP_TWIP ), MapMode( MAP_100TH_MM ) ); 458 459 if(aSize.Width() > MINLAY&& aSize.Height()> MINLAY) 460 { 461 awt::Size aSz; 462 aSz.Width = aSize.Width(); 463 aSz.Height = aSize.Height(); 464 xObj->setVisualAreaSize( xObj.GetViewAspect(), aSz ); 465 } 466 } 467 } 468 } 469 break; 470 471 case FN_INSERT_SMA: 472 { 473 // #i34343# Inserting a math object into an autocompletion crashes 474 // the suggestion has to be removed before 475 GetView().GetEditWin().StopQuickHelp(); 476 SvGlobalName aGlobalName( SO3_SM_CLASSID ); 477 rSh.InsertObject( svt::EmbeddedObjectRef(), &aGlobalName, sal_True, 0 ); 478 } 479 break; 480 481 case FN_INSERT_TABLE: 482 InsertTable( rReq ); 483 break; 484 485 case FN_INSERT_FRAME_INTERACT_NOCOL: 486 case FN_INSERT_FRAME_INTERACT: 487 { 488 sal_uInt16 nCols = 1; 489 sal_Bool bModifier1 = rReq.GetModifier() == KEY_MOD1; 490 if(pArgs) 491 { 492 if(FN_INSERT_FRAME_INTERACT_NOCOL != nSlot && 493 pArgs->GetItemState(SID_ATTR_COLUMNS, sal_False, &pItem) == SFX_ITEM_SET) 494 nCols = ((SfxUInt16Item *)pItem)->GetValue(); 495 if(pArgs->GetItemState(SID_MODIFIER, sal_False, &pItem) == SFX_ITEM_SET) 496 bModifier1 |= KEY_MOD1 == ((SfxUInt16Item *)pItem)->GetValue(); 497 } 498 if(bModifier1 ) 499 { 500 SwEditWin& rEdtWin = GetView().GetEditWin(); 501 Size aWinSize = rEdtWin.GetSizePixel(); 502 Point aStartPos(aWinSize.Width()/2, aWinSize.Height() / 2); 503 aStartPos = rEdtWin.PixelToLogic(aStartPos); 504 aStartPos.X() -= 8 * MM50; 505 aStartPos.Y() -= 4 * MM50; 506 Size aSize(16 * MM50, 8 * MM50); 507 GetShell().LockPaint(); 508 GetShell().StartAllAction(); 509 SwFlyFrmAttrMgr aMgr( sal_True, GetShellPtr(), FRMMGR_TYPE_TEXT ); 510 if(nCols > 1) 511 { 512 SwFmtCol aCol; 513 aCol.Init( nCols, aCol.GetGutterWidth(), aCol.GetWishWidth() ); 514 aMgr.SetCol( aCol ); 515 } 516 aMgr.InsertFlyFrm(FLY_AT_PARA, aStartPos, aSize); 517 GetShell().EndAllAction(); 518 GetShell().UnlockPaint(); 519 } 520 else 521 { 522 GetView().InsFrmMode(nCols); 523 } 524 rReq.Ignore(); 525 } 526 break; 527 case FN_INSERT_FRAME: 528 { 529 sal_Bool bSingleCol = sal_False; 530 if( 0!= dynamic_cast< SwWebDocShell*>( GetView().GetDocShell()) ) 531 { 532 SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get(); 533 sal_uInt16 nExport = pHtmlOpt->GetExportMode(); 534 if( HTML_CFG_MSIE == nExport || 535 HTML_CFG_HTML32 == nExport || 536 HTML_CFG_MSIE_40 == nExport || 537 HTML_CFG_HTML32 == nExport ) 538 { 539 bSingleCol = sal_True; 540 } 541 542 } 543 // Rahmen neu anlegen 544 SwFlyFrmAttrMgr aMgr( sal_True, GetShellPtr(), FRMMGR_TYPE_TEXT ); 545 if(pArgs) 546 { 547 Size aSize(aMgr.GetSize()); 548 aSize.Width() = GetShell().GetAnyCurRect(RECT_PAGE_PRT).Width(); 549 Point aPos = aMgr.GetPos(); 550 RndStdIds eAnchor = FLY_AT_PARA; 551 if(pArgs->GetItemState(nSlot, sal_False, &pItem) == SFX_ITEM_SET) 552 eAnchor = (RndStdIds)((SfxUInt16Item *)pItem)->GetValue(); 553 if(pArgs->GetItemState(FN_PARAM_1, sal_False, &pItem) == SFX_ITEM_SET) 554 aPos = ((SfxPointItem *)pItem)->GetValue(); 555 if(pArgs->GetItemState(FN_PARAM_2, sal_False, &pItem) == SFX_ITEM_SET) 556 aSize = ((SvxSizeItem *)pItem)->GetSize(); 557 if(pArgs->GetItemState(SID_ATTR_COLUMNS, sal_False, &pItem) == SFX_ITEM_SET) 558 { 559 sal_uInt16 nCols = ((SfxUInt16Item *)pItem)->GetValue(); 560 if( !bSingleCol && 1 < nCols ) 561 { 562 SwFmtCol aFmtCol; 563 aFmtCol.Init( nCols , (rReq.IsAPI() ? 0 564 : DEF_GUTTER_WIDTH), USHRT_MAX ); 565 aMgr.SetCol(aFmtCol); 566 } 567 } 568 569 GetShell().LockPaint(); 570 GetShell().StartAllAction(); 571 572 aMgr.InsertFlyFrm(eAnchor, aPos, aSize); 573 574 GetShell().EndAllAction(); 575 GetShell().UnlockPaint(); 576 } 577 else 578 { 579 static sal_uInt16 __READONLY_DATA aFrmAttrRange[] = 580 { 581 RES_FRMATR_BEGIN, RES_FRMATR_END-1, 582 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 583 FN_GET_PRINT_AREA, FN_GET_PRINT_AREA, 584 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, 585 FN_SET_FRM_NAME, FN_SET_FRM_NAME, 586 SID_HTML_MODE, SID_HTML_MODE, 587 0 588 }; 589 590 SfxItemSet aSet(GetPool(), aFrmAttrRange ); 591 aSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell()))); 592 const SwRect &rPg = GetShell().GetAnyCurRect(RECT_PAGE); 593 SwFmtFrmSize aFrmSize(ATT_VAR_SIZE, rPg.Width(), rPg.Height()); 594 aFrmSize.SetWhich(GetPool().GetWhich(SID_ATTR_PAGE_SIZE)); 595 aSet.Put(aFrmSize); 596 597 const SwRect &rPr = GetShell().GetAnyCurRect(RECT_PAGE_PRT); 598 SwFmtFrmSize aPrtSize(ATT_VAR_SIZE, rPr.Width(), rPr.Height()); 599 aPrtSize.SetWhich(GetPool().GetWhich(FN_GET_PRINT_AREA)); 600 aSet.Put(aPrtSize); 601 602 aSet.Put(aMgr.GetAttrSet()); 603 aSet.SetParent( aMgr.GetAttrSet().GetParent() ); 604 605 // Minimalgroesse in Spalten loeschen 606 SvxBoxInfoItem aBoxInfo((SvxBoxInfoItem &)aSet.Get(SID_ATTR_BORDER_INNER)); 607 const SvxBoxItem& rBox = (const SvxBoxItem&)aSet.Get(RES_BOX); 608 aBoxInfo.SetMinDist(sal_False); 609 aBoxInfo.SetDefDist(rBox.GetDistance(BOX_LINE_LEFT)); 610 aSet.Put(aBoxInfo); 611 612 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebDocShell, GetView().GetDocShell())); 613 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric))); 614 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 615 DBG_ASSERT(pFact, "Dialogdiet fail!"); 616 SfxAbstractTabDialog* pDlg = pFact->CreateFrmTabDialog( DLG_FRM_STD, 617 GetView().GetViewFrame(), &GetView().GetViewFrame()->GetWindow(), aSet, sal_True); 618 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 619 if(pDlg->Execute() && pDlg->GetOutputItemSet()) 620 { 621 //local variable necessary at least after call of .AutoCaption() because this could be deleted at this point 622 SwWrtShell& rShell = GetShell(); 623 rShell.LockPaint(); 624 rShell.StartAllAction(); 625 rShell.StartUndo(UNDO_INSERT); 626 627 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); 628 aMgr.SetAttrSet(*pOutSet); 629 630 // beim ClickToEditFeld erst die Selektion loeschen 631 if( rShell.IsInClickToEdit() ) 632 rShell.DelRight(); 633 634 aMgr.InsertFlyFrm(); 635 636 uno::Reference< frame::XDispatchRecorder > xRecorder = 637 GetView().GetViewFrame()->GetBindings().GetRecorder(); 638 if ( xRecorder.is() ) 639 { 640 //FN_INSERT_FRAME 641 sal_uInt16 nAnchor = (sal_uInt16)aMgr.GetAnchor(); 642 rReq.AppendItem(SfxUInt16Item(nSlot, nAnchor)); 643 rReq.AppendItem(SfxPointItem(FN_PARAM_1, rShell.GetObjAbsPos())); 644 rReq.AppendItem(SvxSizeItem(FN_PARAM_2, rShell.GetObjSize())); 645 rReq.Done(); 646 } 647 648 GetView().AutoCaption(FRAME_CAP); 649 650 { 651 SwRewriter aRewriter; 652 653 aRewriter.AddRule(UNDO_ARG1, SW_RES(STR_FRAME)); 654 655 rShell.EndUndo(UNDO_INSERT, &aRewriter); 656 } 657 rShell.EndAllAction(); 658 rShell.UnlockPaint(); 659 } 660 661 DELETEZ(pDlg); 662 } 663 break; 664 } 665 case FN_INSERT_HRULER: 666 { 667 String sPath; 668 sal_Bool bSimpleLine = sal_False; 669 sal_Bool bRet = sal_False; 670 Window* pParent = GetView().GetWindow(); 671 if ( pItem ) 672 { 673 sPath = ((SfxStringItem*)pItem)->GetValue(); 674 SFX_REQUEST_ARG( rReq, pSimple, SfxBoolItem, FN_PARAM_1 , sal_False ); 675 if ( pSimple ) 676 bSimpleLine = pSimple->GetValue(); 677 } 678 else 679 { 680 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 681 DBG_ASSERT(pFact, "Dialogdiet fail!"); 682 AbstractInsertGrfRulerDlg* pDlg = pFact->CreateInsertGrfRulerDlg( DLG_INSERT_RULER, 683 pParent ); 684 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 685 // MessageBox fuer fehlende Grafiken 686 if(!pDlg->HasImages()) 687 InfoBox( pParent, SW_RES(MSG_NO_RULER)).Execute(); 688 if(RET_OK == pDlg->Execute()) 689 { 690 sPath = pDlg->GetGraphicName(); 691 bSimpleLine = pDlg->IsSimpleLine(); 692 } 693 694 delete pDlg; 695 rReq.AppendItem( SfxStringItem( FN_INSERT_HRULER, sPath ) ); 696 rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bSimpleLine ) ); 697 } 698 699 rSh.StartAllAction(); 700 rSh.StartUndo(UNDO_UI_INSERT_RULER); 701 if(bSimpleLine) 702 { 703 if(!(rSh.IsSttOfPara() && rSh.IsEndOfPara())) // kein leerer Absatz? 704 rSh.SplitNode( sal_False, sal_False ); // dann Platz schaffen 705 rSh.SplitNode( sal_False, sal_False ); 706 rSh.Left(CRSR_SKIP_CHARS, sal_False, 1, sal_False ); 707 rSh.SetTxtFmtColl( rSh.GetTxtCollFromPool( RES_POOLCOLL_HTML_HR )); 708 rSh.Right(CRSR_SKIP_CHARS, sal_False, 1, sal_False ); 709 bRet = sal_True; 710 } 711 else if(sPath.Len()) 712 { 713 SwFlyFrmAttrMgr aFrmMgr( sal_True, &rSh, FRMMGR_TYPE_GRF ); 714 // am FrmMgr muessen die richtigen Parameter eingestellt werden 715 716 aFrmMgr.SetAnchor(FLY_AS_CHAR); 717 718 rSh.SplitNode( sal_False, sal_False ); 719 rSh.SplitNode( sal_False, sal_False ); 720 rSh.Left(CRSR_SKIP_CHARS, sal_False, 1, sal_False ); 721 rSh.SetAttr(SvxAdjustItem(SVX_ADJUST_CENTER,RES_PARATR_ADJUST )); 722 if(GRFILTER_OK == GetView().InsertGraphic(sPath, aEmptyStr, sal_True, 0, 0 )) 723 bRet = sal_True; 724 rSh.EnterStdMode(); 725 rSh.Right(CRSR_SKIP_CHARS, sal_False, 1, sal_False ); 726 } 727 rSh.EndAllAction(); 728 rSh.EndUndo(UNDO_UI_INSERT_RULER); 729 rReq.SetReturnValue(SfxBoolItem(nSlot, bRet)); 730 rReq.Done(); 731 } 732 break; 733 case FN_FORMAT_COLUMN : 734 { 735 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 736 DBG_ASSERT(pFact, "Dialogdiet fail!"); 737 VclAbstractDialog* pColDlg = pFact->CreateVclAbstractDialog( GetView().GetWindow(), rSh, DLG_COLUMN); 738 DBG_ASSERT(pColDlg, "Dialogdiet fail!"); 739 pColDlg->Execute(); 740 delete pColDlg; 741 } 742 break; 743 744 default: 745 ASSERT( !this, "falscher Dispatcher" ); 746 return; 747 } 748 } 749 750 bool lcl_IsMarkInSameSection( SwWrtShell& rWrtSh, const SwSection* pSect ) 751 { 752 rWrtSh.SwapPam(); 753 bool bRet = pSect == rWrtSh.GetCurrSection(); 754 rWrtSh.SwapPam(); 755 return bRet; 756 } 757 758 759 void SwTextShell::StateInsert( SfxItemSet &rSet ) 760 { 761 sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell()); 762 SfxWhichIter aIter( rSet ); 763 SwWrtShell &rSh = GetShell(); 764 sal_uInt16 nWhich = aIter.FirstWhich(); 765 SvtModuleOptions aMOpt; 766 SfxObjectCreateMode eCreateMode = 767 GetView().GetDocShell()->GetCreateMode(); 768 769 rSh.Push(); 770 const sal_Bool bCrsrInHidden = rSh.SelectHiddenRange(); 771 // --> OD 2009-08-05 #i103839#, #b6855246# 772 // Do not call method <SwCrsrShell::Pop(..)> with 1st parameter = <sal_False> 773 // in order to avoid that the view jumps to the visible cursor. 774 rSh.Pop(); 775 // <-- 776 777 while ( nWhich ) 778 { 779 switch ( nWhich ) 780 { 781 case SID_INSERT_SOUND: 782 case SID_INSERT_VIDEO: 783 /*!SvxPluginFileDlg::IsAvailable( nWhich ) || 784 785 discussed with mba: for performance reasons we skip the IsAvailable call here 786 */ 787 if ( GetShell().IsSelFrmMode() || 788 SFX_CREATE_MODE_EMBEDDED == eCreateMode || bCrsrInHidden ) 789 { 790 rSet.DisableItem( nWhich ); 791 } 792 break; 793 794 case SID_INSERT_DIAGRAM: 795 if( !aMOpt.IsChart() || eCreateMode == SFX_CREATE_MODE_EMBEDDED || bCrsrInHidden ) 796 { 797 rSet.DisableItem( nWhich ); 798 } 799 break; 800 801 case FN_INSERT_SMA: 802 if( !aMOpt.IsMath() || eCreateMode == SFX_CREATE_MODE_EMBEDDED || bCrsrInHidden ) 803 { 804 rSet.DisableItem( nWhich ); 805 } 806 break; 807 808 case SID_INSERT_FLOATINGFRAME: 809 case SID_INSERT_OBJECT: 810 case SID_INSERT_PLUGIN: 811 { 812 if( eCreateMode == SFX_CREATE_MODE_EMBEDDED || bCrsrInHidden ) 813 { 814 rSet.DisableItem( nWhich ); 815 } 816 else if( GetShell().IsSelFrmMode()) 817 rSet.DisableItem( nWhich ); 818 else if(SID_INSERT_FLOATINGFRAME == nWhich && nHtmlMode&HTMLMODE_ON) 819 { 820 SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get(); 821 sal_uInt16 nExport = pHtmlOpt->GetExportMode(); 822 if(HTML_CFG_MSIE_40 != nExport && HTML_CFG_WRITER != nExport ) 823 rSet.DisableItem(nWhich); 824 } 825 } 826 break; 827 case FN_INSERT_FRAME_INTERACT_NOCOL : 828 case FN_INSERT_FRAME_INTERACT: 829 { 830 if ( GetShell().IsSelFrmMode() || 831 (0 != (nHtmlMode & HTMLMODE_ON) && 0 == (nHtmlMode & HTMLMODE_SOME_ABS_POS)) || bCrsrInHidden ) 832 rSet.DisableItem(nWhich); 833 } 834 break; 835 case SID_HYPERLINK_GETLINK: 836 { 837 SfxItemSet aSet(GetPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT); 838 rSh.GetCurAttr( aSet ); 839 840 SvxHyperlinkItem aHLinkItem; 841 const SfxPoolItem* pItem; 842 if(SFX_ITEM_SET == aSet.GetItemState(RES_TXTATR_INETFMT, sal_False, &pItem)) 843 { 844 const SwFmtINetFmt* pINetFmt = (const SwFmtINetFmt*)pItem; 845 aHLinkItem.SetURL(pINetFmt->GetValue()); 846 aHLinkItem.SetTargetFrame(pINetFmt->GetTargetFrame()); 847 aHLinkItem.SetIntName(pINetFmt->GetName()); 848 const SvxMacro *pMacro = pINetFmt->GetMacro( SFX_EVENT_MOUSEOVER_OBJECT ); 849 if( pMacro ) 850 aHLinkItem.SetMacro(HYPERDLG_EVENT_MOUSEOVER_OBJECT, *pMacro); 851 852 pMacro = pINetFmt->GetMacro( SFX_EVENT_MOUSECLICK_OBJECT ); 853 if( pMacro ) 854 aHLinkItem.SetMacro(HYPERDLG_EVENT_MOUSECLICK_OBJECT, *pMacro); 855 856 pMacro = pINetFmt->GetMacro( SFX_EVENT_MOUSEOUT_OBJECT ); 857 if( pMacro ) 858 aHLinkItem.SetMacro(HYPERDLG_EVENT_MOUSEOUT_OBJECT, *pMacro); 859 860 // Text des Links besorgen 861 rSh.StartAction(); 862 rSh.CreateCrsr(); 863 rSh.SwCrsrShell::SelectTxtAttr(RES_TXTATR_INETFMT,sal_True); 864 String sLinkName = rSh.GetSelTxt(); 865 aHLinkItem.SetName(sLinkName); 866 aHLinkItem.SetInsertMode(HLINK_FIELD); 867 rSh.DestroyCrsr(); 868 rSh.EndAction(); 869 } 870 else 871 { 872 String sReturn = rSh.GetSelTxt(); 873 sReturn.Erase(255); 874 sReturn.EraseTrailingChars(); 875 aHLinkItem.SetName(sReturn); 876 } 877 878 aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() | 879 ((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0))); 880 aHLinkItem.SetMacroEvents ( HYPERDLG_EVENT_MOUSEOVER_OBJECT| 881 HYPERDLG_EVENT_MOUSECLICK_OBJECT | HYPERDLG_EVENT_MOUSEOUT_OBJECT ); 882 883 rSet.Put(aHLinkItem); 884 } 885 break; 886 887 case FN_INSERT_FRAME: 888 if(rSh.IsSelFrmMode()) 889 { 890 const int nSel = rSh.GetSelectionType(); 891 if( ((nsSelectionType::SEL_GRF | nsSelectionType::SEL_OLE ) & nSel ) || bCrsrInHidden ) 892 rSet.DisableItem(nWhich); 893 } 894 break; 895 case FN_INSERT_HRULER : 896 if((rSh.IsReadOnlyAvailable() && rSh.HasReadonlySel()) || bCrsrInHidden ) 897 rSet.DisableItem(nWhich); 898 break; 899 case FN_FORMAT_COLUMN : 900 { 901 //#i80458# column dialog cannot work if the selection contains different page styles and different sections 902 bool bDisable = true; 903 if( rSh.GetFlyFrmFmt() || rSh.GetSelectedPageDescs() ) 904 bDisable = false; 905 if( bDisable ) 906 { 907 const SwSection* pCurrSection = rSh.GetCurrSection(); 908 sal_uInt16 nFullSectCnt = rSh.GetFullSelectedSectionCount(); 909 if( pCurrSection && ( !rSh.HasSelection() || 0 != nFullSectCnt )) 910 bDisable = false; 911 else if( 912 rSh.HasSelection() && rSh.IsInsRegionAvailable() && 913 ( !pCurrSection || ( 1 != nFullSectCnt && 914 lcl_IsMarkInSameSection( rSh, pCurrSection ) ))) 915 bDisable = false; 916 } 917 if(bDisable) 918 rSet.DisableItem(nWhich); 919 } 920 break; 921 } 922 nWhich = aIter.NextWhich(); 923 } 924 } 925 926 /*-------------------------------------------------------------------- 927 Beschreibung: 928 --------------------------------------------------------------------*/ 929 930 void SwTextShell::ExecDelete(SfxRequest &rReq) 931 { 932 SwWrtShell &rSh = GetShell(); 933 switch( rReq.GetSlot() ) 934 { 935 case FN_DELETE_SENT: 936 if( rSh.IsTableMode() ) 937 { 938 rSh.DeleteRow(); 939 rSh.EnterStdMode(); 940 } 941 else 942 rSh.DelToEndOfSentence(); 943 break; 944 case FN_DELETE_BACK_SENT: 945 rSh.DelToStartOfSentence(); 946 break; 947 case FN_DELETE_WORD: 948 rSh.DelNxtWord(); 949 break; 950 case FN_DELETE_BACK_WORD: 951 rSh.DelPrvWord(); 952 break; 953 case FN_DELETE_LINE: 954 rSh.DelToEndOfLine(); 955 break; 956 case FN_DELETE_BACK_LINE: 957 rSh.DelToStartOfLine(); 958 break; 959 case FN_DELETE_PARA: 960 rSh.DelToEndOfPara(); 961 break; 962 case FN_DELETE_BACK_PARA: 963 rSh.DelToStartOfPara(); 964 break; 965 case FN_DELETE_WHOLE_LINE: 966 rSh.DelLine(); 967 break; 968 default: 969 ASSERT(!this, "falscher Dispatcher"); 970 return; 971 } 972 rReq.Done(); 973 } 974 975 void SwTextShell::ExecTransliteration( SfxRequest & rReq ) 976 { 977 using namespace ::com::sun::star::i18n; 978 { 979 sal_uInt32 nMode = 0; 980 981 switch( rReq.GetSlot() ) 982 { 983 case SID_TRANSLITERATE_SENTENCE_CASE: 984 nMode = TransliterationModulesExtra::SENTENCE_CASE; 985 break; 986 case SID_TRANSLITERATE_TITLE_CASE: 987 nMode = TransliterationModulesExtra::TITLE_CASE; 988 break; 989 case SID_TRANSLITERATE_TOGGLE_CASE: 990 nMode = TransliterationModulesExtra::TOGGLE_CASE; 991 break; 992 case SID_TRANSLITERATE_UPPER: 993 nMode = TransliterationModules_LOWERCASE_UPPERCASE; 994 break; 995 case SID_TRANSLITERATE_LOWER: 996 nMode = TransliterationModules_UPPERCASE_LOWERCASE; 997 break; 998 999 case SID_TRANSLITERATE_HALFWIDTH: 1000 nMode = TransliterationModules_FULLWIDTH_HALFWIDTH; 1001 break; 1002 case SID_TRANSLITERATE_FULLWIDTH: 1003 nMode = TransliterationModules_HALFWIDTH_FULLWIDTH; 1004 break; 1005 1006 case SID_TRANSLITERATE_HIRAGANA: 1007 nMode = TransliterationModules_KATAKANA_HIRAGANA; 1008 break; 1009 case SID_TRANSLITERATE_KATAGANA: 1010 nMode = TransliterationModules_HIRAGANA_KATAKANA; 1011 break; 1012 1013 default: 1014 ASSERT(!this, "falscher Dispatcher"); 1015 } 1016 1017 if( nMode ) 1018 GetShell().TransliterateText( nMode ); 1019 } 1020 } 1021 1022 1023 /*-------------------------------------------------------------------- 1024 Beschreibung: 1025 --------------------------------------------------------------------*/ 1026 1027 1028 1029 SwTextShell::SwTextShell(SwView &_rView) : 1030 SwBaseShell(_rView), pPostItFldMgr( 0 ) 1031 { 1032 SetName(String::CreateFromAscii("Text")); 1033 SetHelpId(SW_TEXTSHELL); 1034 } 1035 1036 /*-------------------------------------------------------------------- 1037 Beschreibung: 1038 --------------------------------------------------------------------*/ 1039 1040 SwTextShell::~SwTextShell() 1041 { 1042 } 1043 1044 /*-------------------------------------------------------------------- 1045 Beschreibung: 1046 --------------------------------------------------------------------*/ 1047 1048 void SwTextShell::InsertSymbol( SfxRequest& rReq ) 1049 { 1050 const SfxItemSet *pArgs = rReq.GetArgs(); 1051 const SfxPoolItem* pItem = 0; 1052 if( pArgs ) 1053 pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), sal_False, &pItem); 1054 1055 String aChars, aFontName; 1056 if ( pItem ) 1057 { 1058 aChars = ((const SfxStringItem*)pItem)->GetValue(); 1059 const SfxPoolItem* pFtItem = NULL; 1060 pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), sal_False, &pFtItem); 1061 const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem ); 1062 if ( pFontItem ) 1063 aFontName = pFontItem->GetValue(); 1064 } 1065 1066 SwWrtShell &rSh = GetShell(); 1067 SfxItemSet aSet( GetPool(), RES_CHRATR_FONT, RES_CHRATR_FONT, 1068 RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT, 1069 RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONT, 1070 0 ); 1071 rSh.GetCurAttr( aSet ); 1072 sal_uInt16 nScript = rSh.GetScriptType(); 1073 1074 SvxFontItem aFont( RES_CHRATR_FONT ); 1075 { 1076 SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() ); 1077 aSetItem.GetItemSet().Put( aSet, sal_False ); 1078 const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript ); 1079 if( pI ) 1080 aFont = *(SvxFontItem*)pI; 1081 else 1082 aFont = (SvxFontItem&)aSet.Get( GetWhichOfScript( 1083 RES_CHRATR_FONT, 1084 GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() ) )); 1085 if (!aFontName.Len()) 1086 aFontName = aFont.GetFamilyName(); 1087 } 1088 1089 Font aNewFont(aFontName, Size(1,1)); // Size nur wg. CTOR 1090 if( !aChars.Len() ) 1091 { 1092 // Eingestellten Font als Default 1093 SfxAllItemSet aAllSet( rSh.GetAttrPool() ); 1094 aAllSet.Put( SfxBoolItem( FN_PARAM_1, sal_False ) ); 1095 1096 SwViewOption aOpt(*GetShell().GetViewOptions()); 1097 String sSymbolFont = aOpt.GetSymbolFont(); 1098 if( !aFontName.Len() && sSymbolFont.Len() ) 1099 aAllSet.Put( SfxStringItem( SID_FONT_NAME, sSymbolFont ) ); 1100 else 1101 aAllSet.Put( SfxStringItem( SID_FONT_NAME, aFont.GetFamilyName() ) ); 1102 1103 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 1104 SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( GetView().GetWindow(), aAllSet, 1105 GetView().GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP ); 1106 if( RET_OK == pDlg->Execute() ) 1107 { 1108 SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pCItem, SfxStringItem, SID_CHARMAP, sal_False ); 1109 SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, sal_False ); 1110 if ( pFontItem ) 1111 { 1112 aNewFont.SetName( pFontItem->GetFamilyName() ); 1113 aNewFont.SetStyleName( pFontItem->GetStyleName() ); 1114 aNewFont.SetCharSet( pFontItem->GetCharSet() ); 1115 aNewFont.SetPitch( pFontItem->GetPitch() ); 1116 } 1117 1118 if ( pCItem ) 1119 { 1120 aChars = pCItem->GetValue(); 1121 aOpt.SetSymbolFont(aNewFont.GetName()); 1122 SW_MOD()->ApplyUsrPref(aOpt, &GetView()); 1123 } 1124 } 1125 1126 delete pDlg; 1127 } 1128 1129 sal_Bool bFontChanged = sal_False; 1130 if( aChars.Len() ) 1131 { 1132 rSh.StartAllAction(); 1133 1134 // Selektierten Inhalt loeschen 1135 SwRewriter aRewriter; 1136 aRewriter.AddRule(UNDO_ARG1, SW_RES(STR_SPECIALCHAR)); 1137 1138 rSh.StartUndo( UNDO_INSERT, &aRewriter ); 1139 if ( rSh.HasSelection() ) 1140 { 1141 rSh.DelRight(); 1142 aSet.ClearItem(); 1143 rSh.GetCurAttr( aSet ); 1144 1145 SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() ); 1146 aSetItem.GetItemSet().Put( aSet, sal_False ); 1147 const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript ); 1148 if( pI ) 1149 aFont = *(SvxFontItem*)pI; 1150 else 1151 aFont = (SvxFontItem&)aSet.Get( GetWhichOfScript( 1152 RES_CHRATR_FONT, 1153 GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() ) )); 1154 } 1155 1156 // Zeichen einfuegen 1157 rSh.Insert( aChars ); 1158 1159 // #108876# a font attribute has to be set always due to a guessed script type 1160 if( aNewFont.GetName().Len() ) 1161 { 1162 bFontChanged = sal_True; 1163 SvxFontItem aNewFontItem( aFont ); 1164 aNewFontItem.SetFamilyName( aNewFont.GetName()); 1165 aNewFontItem.SetFamily( aNewFont.GetFamily()); 1166 aNewFontItem.SetPitch( aNewFont.GetPitch()); 1167 aNewFontItem.SetCharSet( aNewFont.GetCharSet() ); 1168 1169 SfxItemSet aRestoreSet( GetPool(), RES_CHRATR_FONT, RES_CHRATR_FONT, 1170 RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT, 1171 RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONT, 0 ); 1172 1173 nScript = pBreakIt->GetAllScriptsOfText( aChars ); 1174 if( SCRIPTTYPE_LATIN & nScript ) 1175 { 1176 aRestoreSet.Put( aSet.Get( RES_CHRATR_FONT, sal_True ) ); 1177 aSet.Put( aNewFontItem, RES_CHRATR_FONT); 1178 } 1179 if( SCRIPTTYPE_ASIAN & nScript ) 1180 { 1181 aRestoreSet.Put( aSet.Get( RES_CHRATR_CJK_FONT, sal_True ) ); 1182 aSet.Put( aNewFontItem, RES_CHRATR_CJK_FONT ); 1183 } 1184 if( SCRIPTTYPE_COMPLEX & nScript ) 1185 { 1186 aRestoreSet.Put( aSet.Get( RES_CHRATR_CTL_FONT, sal_True ) ); 1187 aSet.Put( aNewFontItem, RES_CHRATR_CTL_FONT ); 1188 } 1189 1190 rSh.SetMark(); 1191 rSh.ExtendSelection( sal_False, aChars.Len() ); 1192 rSh.SetAttr( aSet, nsSetAttrMode::SETATTR_DONTEXPAND | nsSetAttrMode::SETATTR_NOFORMATATTR ); 1193 if( !rSh.IsCrsrPtAtEnd() ) 1194 rSh.SwapPam(); 1195 1196 rSh.ClearMark(); 1197 1198 // --> FME 2007-07-09 #i75891# 1199 // SETATTR_DONTEXPAND does not work if there are already hard attributes. 1200 // Therefore we have to restore the font attributes. 1201 rSh.SetMark(); 1202 rSh.SetAttr( aRestoreSet ); 1203 rSh.ClearMark(); 1204 // <-- 1205 1206 rSh.UpdateAttr(); 1207 aFont = aNewFontItem; 1208 } 1209 1210 rSh.EndAllAction(); 1211 rSh.EndUndo(); 1212 1213 if ( aChars.Len() ) 1214 { 1215 rReq.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP), aChars ) ); 1216 rReq.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR, aNewFont.GetName() ) ); 1217 rReq.Done(); 1218 } 1219 } 1220 } 1221 1222 1223