1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sw.hxx" 26 27 #include <hintids.hxx> 28 29 #include <com/sun/star/i18n/TransliterationModules.hpp> 30 #include <com/sun/star/i18n/TransliterationModulesExtra.hpp> 31 #include <com/sun/star/i18n/TextConversionOption.hpp> 32 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> 33 #include <com/sun/star/lang/XInitialization.hpp> 34 35 #include <tools/shl.hxx> 36 #include <i18npool/mslangid.hxx> 37 #include <sfx2/objface.hxx> 38 #include <sfx2/viewfrm.hxx> 39 #include <sfx2/bindings.hxx> 40 #include <sfx2/dispatch.hxx> 41 #include <sfx2/request.hxx> 42 #include <editeng/spltitem.hxx> 43 #include <editeng/lrspitem.hxx> 44 #include <editeng/ulspitem.hxx> 45 #include <editeng/orphitem.hxx> 46 #include <editeng/brkitem.hxx> 47 #include <editeng/widwitem.hxx> 48 #include <editeng/kernitem.hxx> 49 #include <editeng/escpitem.hxx> 50 #include <editeng/lspcitem.hxx> 51 #include <editeng/adjitem.hxx> 52 #include <editeng/crsditem.hxx> 53 #include <editeng/shdditem.hxx> 54 #include <editeng/hyznitem.hxx> 55 #include <editeng/udlnitem.hxx> 56 #include <editeng/fontitem.hxx> 57 #include <editeng/fhgtitem.hxx> 58 #include <svx/clipfmtitem.hxx> 59 #include <svl/stritem.hxx> 60 #include <svl/slstitm.hxx> 61 #include <editeng/colritem.hxx> 62 #include <editeng/wghtitem.hxx> 63 #include <editeng/cntritem.hxx> 64 #include <editeng/postitem.hxx> 65 #include <editeng/frmdiritem.hxx> 66 #include <svx/svdoutl.hxx> 67 #include <svl/whiter.hxx> 68 #include <svl/cjkoptions.hxx> 69 #include <svl/ctloptions.hxx> 70 #include <unotools/useroptions.hxx> 71 #include <vcl/msgbox.hxx> 72 #include <editeng/flditem.hxx> 73 #include <editeng/editstat.hxx> 74 #include <svx/hlnkitem.hxx> 75 #include <svx/htmlmode.hxx> 76 #include <editeng/langitem.hxx> 77 #include <editeng/unolingu.hxx> 78 #include <editeng/scripttypeitem.hxx> 79 #include <editeng/writingmodeitem.hxx> 80 #include <swundo.hxx> 81 #include <doc.hxx> 82 #include <viewopt.hxx> 83 #include <wrtsh.hxx> 84 #include <uitool.hxx> 85 #include <popup.hrc> 86 #include <pardlg.hxx> 87 #include <swdtflvr.hxx> 88 #include <drwtxtsh.hxx> 89 #include <swmodule.hxx> 90 #include <initui.hxx> 91 #include <edtwin.hxx> 92 #include <swwait.hxx> 93 #include <docstat.hxx> 94 95 #include <cmdid.h> 96 #include <globals.hrc> 97 #include <shells.hrc> 98 #include <breakit.hxx> 99 #include "annotsh.hxx" 100 #include "view.hxx" 101 #include <PostItMgr.hxx> 102 #include <SidebarWin.hxx> 103 104 #include "swtypes.hxx" 105 106 #include <svx/svxdlg.hxx> 107 #include <svx/dialogs.hrc> 108 109 #include <svx/svxids.hrc> 110 #include <sfx2/sidebar/EnumContext.hxx> 111 #include <svl/itempool.hxx> 112 #include <editeng/outliner.hxx> 113 #include <editeng/editeng.hxx> 114 #include <editeng/editview.hxx> 115 116 #include <svl/languageoptions.hxx> 117 #include <editeng/langitem.hxx> 118 #include <svtools/langtab.hxx> 119 #include <svl/slstitm.hxx> 120 121 #include <docsh.hxx> 122 #include <svl/undo.hxx> 123 #include "swabstdlg.hxx" 124 #include "chrdlg.hrc" 125 #include "misc.hrc" 126 #include <app.hrc> 127 128 #include <comphelper/processfactory.hxx> 129 130 #include <cppuhelper/bootstrap.hxx> 131 132 #include <langhelper.hxx> 133 134 using namespace ::com::sun::star; 135 using namespace ::com::sun::star::uno; 136 using namespace ::com::sun::star::beans; 137 using namespace ::com::sun::star::i18n; 138 139 #define SwAnnotationShell 140 141 #include <sfx2/msg.hxx> 142 #include <swslots.hxx> 143 144 SFX_IMPL_INTERFACE(SwAnnotationShell, SfxShell, SW_RES(STR_SHELLNAME_DRAW_TEXT)) 145 { 146 SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TEXT_TOOLBOX)); 147 SFX_POPUPMENU_REGISTRATION(SW_RES(MN_ANNOTATION_POPUPMENU)); 148 } 149 150 TYPEINIT1(SwAnnotationShell,SfxShell) 151 152 SwAnnotationShell::SwAnnotationShell( SwView& r ) 153 : rView(r) 154 { 155 SwWrtShell &rSh = rView.GetWrtShell(); 156 SetPool(rSh.GetAttrPool().GetSecondaryPool()); 157 SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Annotation)); 158 } 159 160 SwAnnotationShell::~SwAnnotationShell() 161 { 162 } 163 164 ::svl::IUndoManager* SwAnnotationShell::GetUndoManager() 165 { 166 SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); 167 if ( !pPostItMgr || 168 !pPostItMgr->HasActiveSidebarWin() ) 169 { 170 DBG_ASSERT(pPostItMgr,"PostItMgr::Layout(): We are looping forever"); 171 return 0; 172 } 173 return &pPostItMgr->GetActiveSidebarWin()->GetOutlinerView()->GetOutliner()->GetUndoManager(); 174 } 175 176 void SwAnnotationShell::Exec( SfxRequest &rReq ) 177 { 178 //TODO: clean this up!!!! 179 SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); 180 if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() ) 181 return; 182 183 OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView(); 184 SfxItemSet aEditAttr(pOLV->GetAttribs()); 185 SfxItemSet aNewAttr(*aEditAttr.GetPool(), aEditAttr.GetRanges()); 186 187 sal_uInt16 nSlot = rReq.GetSlot(); 188 sal_uInt16 nWhich = GetPool().GetWhich(nSlot); 189 const SfxItemSet *pNewAttrs = rReq.GetArgs(); 190 sal_uInt16 nEEWhich = 0; 191 switch (nSlot) 192 { 193 case SID_ATTR_PARA_LRSPACE: 194 { 195 SvxLRSpaceItem aParaMargin((const SvxLRSpaceItem&)rReq. 196 GetArgs()->Get(nSlot)); 197 aParaMargin.SetWhich( EE_PARA_LRSPACE ); 198 199 aNewAttr.Put(aParaMargin); 200 rReq.Done(); 201 break; 202 } 203 case SID_ATTR_PARA_LINESPACE: 204 { 205 SvxLineSpacingItem aParaMargin = (const SvxLineSpacingItem&)pNewAttrs->Get( 206 GetPool().GetWhich(nSlot)); 207 aParaMargin.SetWhich( EE_PARA_SBL ); 208 209 aNewAttr.Put(aParaMargin); 210 rReq.Done(); 211 break; 212 } 213 case SID_ATTR_PARA_ULSPACE: 214 { 215 SvxULSpaceItem aULSpace = (const SvxULSpaceItem&)pNewAttrs->Get( 216 GetPool().GetWhich(nSlot)); 217 aULSpace.SetWhich( EE_PARA_ULSPACE ); 218 aNewAttr.Put( aULSpace ); 219 rReq.Done(); 220 } 221 break; 222 case SID_ATTR_CHAR_FONT: 223 case SID_ATTR_CHAR_FONTHEIGHT: 224 case SID_ATTR_CHAR_WEIGHT: 225 case SID_ATTR_CHAR_POSTURE: 226 { 227 SfxItemPool* pSecondPool = aEditAttr.GetPool()->GetSecondaryPool(); 228 if( !pSecondPool ) 229 pSecondPool = aEditAttr.GetPool(); 230 SvxScriptSetItem aSetItem( nSlot, *pSecondPool ); 231 aSetItem.PutItemForScriptType( pOLV->GetSelectedScriptType(), pNewAttrs->Get( nWhich )); 232 aNewAttr.Put( aSetItem.GetItemSet() ); 233 rReq.Done(); 234 break; 235 } 236 case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break; 237 case SID_ATTR_CHAR_UNDERLINE: 238 { 239 FontUnderline eFU = ((const SvxUnderlineItem&)aEditAttr.Get(EE_CHAR_UNDERLINE)).GetLineStyle(); 240 aNewAttr.Put(SvxUnderlineItem(eFU == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_UNDERLINE)); 241 break; 242 } 243 case SID_ATTR_CHAR_OVERLINE: 244 { 245 FontUnderline eFO = ((const SvxOverlineItem&)aEditAttr.Get(EE_CHAR_OVERLINE)).GetLineStyle(); 246 aNewAttr.Put(SvxOverlineItem(eFO == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_OVERLINE)); 247 break; 248 } 249 case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break; 250 case SID_ATTR_CHAR_SHADOWED: nEEWhich = EE_CHAR_SHADOW; break; 251 case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT; break; 252 case SID_ATTR_CHAR_WORDLINEMODE: nEEWhich = EE_CHAR_WLM; break; 253 case SID_ATTR_CHAR_RELIEF : nEEWhich = EE_CHAR_RELIEF; break; 254 case SID_ATTR_CHAR_LANGUAGE : nEEWhich = EE_CHAR_LANGUAGE;break; 255 case SID_ATTR_CHAR_KERNING : nEEWhich = EE_CHAR_KERNING; break; 256 case SID_ATTR_CHAR_SCALEWIDTH: nEEWhich = EE_CHAR_FONTWIDTH; break; 257 case SID_ATTR_CHAR_AUTOKERN : nEEWhich = EE_CHAR_PAIRKERNING; break; 258 case SID_ATTR_CHAR_ESCAPEMENT: nEEWhich = EE_CHAR_ESCAPEMENT; break; 259 case SID_ATTR_PARA_ADJUST_LEFT: 260 aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_LEFT, EE_PARA_JUST)); 261 break; 262 case SID_ATTR_PARA_ADJUST_CENTER: 263 aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST)); 264 break; 265 case SID_ATTR_PARA_ADJUST_RIGHT: 266 aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_RIGHT, EE_PARA_JUST)); 267 break; 268 case SID_ATTR_PARA_ADJUST_BLOCK: 269 aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_BLOCK, EE_PARA_JUST)); 270 break; 271 272 case SID_ATTR_PARA_LINESPACE_10: 273 { 274 SvxLineSpacingItem aItem(SVX_LINESPACE_ONE_LINE, EE_PARA_SBL); 275 aItem.SetPropLineSpace(100); 276 aNewAttr.Put(aItem); 277 } 278 break; 279 case SID_ATTR_PARA_LINESPACE_15: 280 { 281 SvxLineSpacingItem aItem(SVX_LINESPACE_ONE_POINT_FIVE_LINES, EE_PARA_SBL); 282 aItem.SetPropLineSpace(150); 283 aNewAttr.Put(aItem); 284 } 285 break; 286 case SID_ATTR_PARA_LINESPACE_20: 287 { 288 SvxLineSpacingItem aItem(SVX_LINESPACE_TWO_LINES, EE_PARA_SBL); 289 aItem.SetPropLineSpace(200); 290 aNewAttr.Put(aItem); 291 } 292 break; 293 case SID_SELECTALL: 294 { 295 Outliner * pOutliner = pOLV->GetOutliner(); 296 if(pOutliner) 297 { 298 sal_uLong nParaCount = pOutliner->GetParagraphCount(); 299 if (nParaCount > 0) 300 pOLV->SelectRange(0L, sal_uInt16(nParaCount) ); 301 } 302 break; 303 } 304 case FN_FORMAT_RESET: 305 { 306 pPostItMgr->GetActiveSidebarWin()->ResetAttributes(); 307 rReq.Done(); 308 break; 309 } 310 case FN_SET_SUPER_SCRIPT: 311 { 312 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); 313 SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&) 314 aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue(); 315 316 if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT ) 317 aItem.SetEscapement( SVX_ESCAPEMENT_OFF ); 318 else 319 aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT ); 320 aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT ); 321 } 322 break; 323 case FN_SET_SUB_SCRIPT: 324 { 325 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); 326 SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&) 327 aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue(); 328 329 if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT ) 330 aItem.SetEscapement( SVX_ESCAPEMENT_OFF ); 331 else 332 aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT ); 333 aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT ); 334 } 335 break; 336 case SID_HYPERLINK_SETLINK: 337 { 338 const SfxPoolItem* pItem = 0; 339 if(pNewAttrs) 340 pNewAttrs->GetItemState(nSlot, sal_False, &pItem); 341 342 if(pItem) 343 { 344 const SvxHyperlinkItem& rHLinkItem = *(const SvxHyperlinkItem *)pItem; 345 SvxURLField aFld(rHLinkItem.GetURL(), rHLinkItem.GetName(), SVXURLFORMAT_APPDEFAULT); 346 aFld.SetTargetFrame(rHLinkItem.GetTargetFrame()); 347 348 const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection(); 349 350 if (pFieldItem && pFieldItem->GetField()->ISA(SvxURLField)) 351 { 352 // Feld selektieren, so dass es beim Insert geloescht wird 353 ESelection aSel = pOLV->GetSelection(); 354 aSel.nEndPos++; 355 pOLV->SetSelection(aSel); 356 } 357 if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED) 358 pOLV->InsertField(SvxFieldItem(aFld, EE_FEATURE_FIELD)); 359 } 360 break; 361 } 362 case FN_INSERT_SOFT_HYPHEN: 363 case FN_INSERT_HARDHYPHEN: 364 case FN_INSERT_HARD_SPACE: 365 case SID_INSERT_RLM : 366 case SID_INSERT_LRM : 367 case SID_INSERT_ZWNBSP : 368 case SID_INSERT_ZWSP: 369 { 370 sal_Unicode cIns = 0; 371 switch(rReq.GetSlot()) 372 { 373 case FN_INSERT_SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break; 374 case FN_INSERT_HARDHYPHEN: cIns = CHAR_HARDHYPHEN; break; 375 case FN_INSERT_HARD_SPACE: cIns = CHAR_HARDBLANK; break; 376 case SID_INSERT_RLM : cIns = CHAR_RLM ; break; 377 case SID_INSERT_LRM : cIns = CHAR_LRM ; break; 378 case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break; 379 case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break; 380 } 381 pOLV->InsertText( String(cIns)); 382 rReq.Done(); 383 break; 384 } 385 case SID_CHARMAP: 386 { 387 if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED) 388 InsertSymbol(rReq); 389 break; 390 } 391 case FN_INSERT_STRING: 392 { 393 const SfxPoolItem* pItem = 0; 394 if(pNewAttrs) 395 pNewAttrs->GetItemState(nSlot, sal_False, &pItem ); 396 if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED) 397 pOLV->InsertText(((const SfxStringItem *)pItem)->GetValue()); 398 break; 399 } 400 401 case FN_FORMAT_FOOTNOTE_DLG: 402 { 403 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 404 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 405 406 VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg( rView.GetWindow(), rView.GetWrtShell(), DLG_DOC_FOOTNOTE ); 407 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 408 pDlg->Execute(); 409 delete pDlg; 410 break; 411 } 412 case FN_NUMBERING_OUTLINE_DLG: 413 { 414 SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1); 415 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 416 DBG_ASSERT(pFact, "Dialogdiet fail!"); 417 SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE, 418 rView.GetWindow(), &aTmp, rView.GetWrtShell()); 419 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 420 pDlg->Execute(); 421 delete pDlg; 422 rReq.Done(); 423 } 424 break; 425 case SID_OPEN_XML_FILTERSETTINGS: 426 { 427 try 428 { 429 uno::Reference < ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY); 430 if( xDialog.is() ) 431 { 432 xDialog->execute(); 433 } 434 } 435 catch( uno::Exception& ) 436 { 437 } 438 rReq.Ignore (); 439 } 440 break; 441 case FN_WORDCOUNT_DIALOG: 442 { 443 SwWrtShell &rSh = rView.GetWrtShell(); 444 SwDocStat aCurr; 445 SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() ); 446 { 447 SwWait aWait( *rView.GetDocShell(), sal_True ); 448 rSh.StartAction(); 449 rSh.CountWords( aCurr ); 450 rSh.UpdateDocStat( aDocStat ); 451 rSh.EndAction(); 452 } 453 454 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 455 DBG_ASSERT(pFact, "Dialogdiet fail!"); 456 AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( rView.GetWindow() ); 457 pDialog->SetValues(aCurr, aDocStat ); 458 pDialog->Execute(); 459 delete pDialog; 460 } 461 break; 462 case SID_CHAR_DLG_EFFECT: 463 case SID_CHAR_DLG: 464 { 465 const SfxItemSet* pArgs = rReq.GetArgs(); 466 467 if( !pArgs ) 468 { 469 /* mod 470 SwView* pView = &GetView(); 471 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView)); 472 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, eMetric)); 473 */ 474 SfxItemSet aDlgAttr(GetPool(), EE_ITEMS_START, EE_ITEMS_END); 475 476 // util::Language gibts an der EditEngine nicht! Daher nicht im Set. 477 478 aDlgAttr.Put( aEditAttr ); 479 aDlgAttr.Put( SvxKerningItem(0, RES_CHRATR_KERNING) ); 480 481 //CHINA001 SwCharDlg* pDlg = new SwCharDlg(pView->GetWindow(), *pView, aDlgAttr, 0, sal_True); 482 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();//CHINA001 483 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");//CHINA001 484 485 SfxAbstractTabDialog* pDlg = pFact->CreateSwCharDlg( rView.GetWindow(), rView, aDlgAttr, DLG_CHAR,0, sal_True ); 486 DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001 487 if (nSlot == SID_CHAR_DLG_EFFECT) 488 { 489 pDlg->SetCurPageId(TP_CHAR_EXT); 490 } 491 sal_uInt16 nRet = pDlg->Execute(); 492 if(RET_OK == nRet ) 493 { 494 rReq.Done( *( pDlg->GetOutputItemSet() ) ); 495 aNewAttr.Put(*pDlg->GetOutputItemSet()); 496 } 497 delete( pDlg ); 498 if(RET_OK != nRet) 499 return ; 500 } 501 else 502 aNewAttr.Put(*pArgs); 503 break; 504 } 505 case SID_PARA_DLG: 506 { 507 const SfxItemSet* pArgs = rReq.GetArgs(); 508 509 if (!pArgs) 510 { 511 /* mod todo ??? 512 SwView* pView = &GetView(); 513 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView)); 514 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, eMetric)); 515 */ 516 SfxItemSet aDlgAttr(GetPool(), 517 EE_ITEMS_START, EE_ITEMS_END, 518 SID_ATTR_PARA_HYPHENZONE, SID_ATTR_PARA_HYPHENZONE, 519 SID_ATTR_PARA_SPLIT, SID_ATTR_PARA_SPLIT, 520 SID_ATTR_PARA_WIDOWS, SID_ATTR_PARA_WIDOWS, 521 SID_ATTR_PARA_ORPHANS, SID_ATTR_PARA_ORPHANS, 522 0); 523 524 aDlgAttr.Put(aEditAttr); 525 526 527 aDlgAttr.Put( SvxHyphenZoneItem( sal_False, RES_PARATR_HYPHENZONE) ); 528 aDlgAttr.Put( SvxFmtBreakItem( SVX_BREAK_NONE, RES_BREAK ) ); 529 aDlgAttr.Put( SvxFmtSplitItem( sal_True, RES_PARATR_SPLIT ) ); 530 aDlgAttr.Put( SvxWidowsItem( 0, RES_PARATR_WIDOWS ) ); 531 aDlgAttr.Put( SvxOrphansItem( 0, RES_PARATR_ORPHANS ) ); 532 533 //CHINA001 SwParaDlg* pDlg = new SwParaDlg(GetView().GetWindow(), GetView(), aDlgAttr, DLG_STD, 0, sal_True); 534 535 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();//CHINA001 536 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");//CHINA001 537 538 SfxAbstractTabDialog* pDlg = pFact->CreateSwParaDlg( rView.GetWindow(), rView, aDlgAttr,DLG_STD, DLG_PARA, 0, sal_True ); 539 DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001 540 sal_uInt16 nRet = pDlg->Execute(); 541 if(RET_OK == nRet) 542 { 543 rReq.Done( *( pDlg->GetOutputItemSet() ) ); 544 aNewAttr.Put(*pDlg->GetOutputItemSet()); 545 } 546 delete( pDlg ); 547 if(RET_OK != nRet) 548 return; 549 } 550 else 551 aNewAttr.Put(*pArgs); 552 break; 553 } 554 555 case SID_AUTOSPELL_CHECK: 556 { 557 rView.ExecuteSlot(rReq); 558 break; 559 } 560 case SID_ATTR_PARA_LEFT_TO_RIGHT: 561 case SID_ATTR_PARA_RIGHT_TO_LEFT: 562 { 563 sal_Bool bLeftToRight = nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT; 564 565 const SfxPoolItem* pPoolItem; 566 if( pNewAttrs && SFX_ITEM_SET == pNewAttrs->GetItemState( nSlot, sal_True, &pPoolItem ) ) 567 { 568 if( !( (SfxBoolItem*)pPoolItem)->GetValue() ) 569 bLeftToRight = !bLeftToRight; 570 } 571 SfxItemSet aAttr( *aNewAttr.GetPool(), 572 EE_PARA_JUST, EE_PARA_JUST, 573 EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR, 574 0 ); 575 576 sal_uInt16 nAdjust = SVX_ADJUST_LEFT; 577 if( SFX_ITEM_ON == aEditAttr.GetItemState(EE_PARA_JUST, sal_True, &pPoolItem ) ) 578 nAdjust = ( (SvxAdjustItem*)pPoolItem)->GetEnumValue(); 579 580 if( bLeftToRight ) 581 { 582 aAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR ) ); 583 if( nAdjust == SVX_ADJUST_RIGHT ) 584 aAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) ); 585 } 586 else 587 { 588 aAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP, EE_PARA_WRITINGDIR ) ); 589 if( nAdjust == SVX_ADJUST_LEFT ) 590 aAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) ); 591 } 592 pOLV->SetAttribs(aAttr); 593 break; 594 } 595 } 596 597 if(nEEWhich && pNewAttrs) 598 aNewAttr.Put(pNewAttrs->Get(nWhich), nEEWhich); 599 600 Rectangle aNullRect; 601 Rectangle aOutRect = pOLV->GetOutputArea(); 602 if (aNullRect != aOutRect) 603 pOLV->SetAttribs(aNewAttr); 604 605 rView.GetViewFrame()->GetBindings().InvalidateAll(sal_False); 606 if ( pOLV->GetOutliner()->IsModified() ) 607 rView.GetWrtShell().SetModified(); 608 609 } 610 611 void SwAnnotationShell::GetState(SfxItemSet& rSet) 612 { 613 //TODO: clean this up!!! 614 // FN_SET_SUPER_SCRIPT 615 //SID_ATTR_PARA_ADJUST 616 //SID_ATTR_PARA_ADJUST_BLOCK 617 618 SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); 619 if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() ) 620 return; 621 622 OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView(); 623 SfxItemSet aEditAttr(pOLV->GetAttribs()); 624 625 SfxWhichIter aIter(rSet); 626 sal_uInt16 nWhich = aIter.FirstWhich(); 627 while(nWhich) 628 { 629 sal_uInt16 nEEWhich = 0; 630 sal_uInt16 nSlotId = GetPool().GetSlotId( nWhich ); 631 switch( nSlotId ) 632 { 633 case SID_ATTR_PARA_LRSPACE: 634 { 635 SfxItemState eState = aEditAttr.GetItemState( EE_PARA_LRSPACE ); 636 if( eState >= SFX_ITEM_DEFAULT ) 637 { 638 SvxLRSpaceItem aLR = ( (const SvxLRSpaceItem&) aEditAttr.Get( EE_PARA_LRSPACE ) ); 639 aLR.SetWhich(SID_ATTR_PARA_LRSPACE); 640 rSet.Put(aLR); 641 } 642 else 643 rSet.InvalidateItem(nSlotId); 644 } 645 break; 646 case SID_ATTR_PARA_LINESPACE: 647 { 648 SfxItemState eState = aEditAttr.GetItemState( EE_PARA_SBL ); 649 if( eState >= SFX_ITEM_DEFAULT ) 650 { 651 SvxLineSpacingItem aLR = ( (const SvxLineSpacingItem&) aEditAttr.Get( EE_PARA_SBL ) ); 652 rSet.Put(aLR); 653 } 654 else 655 rSet.InvalidateItem(nSlotId); 656 } 657 break; 658 case SID_ATTR_PARA_ULSPACE: 659 { 660 SfxItemState eState = aEditAttr.GetItemState( EE_PARA_ULSPACE ); 661 if( eState >= SFX_ITEM_DEFAULT ) 662 { 663 SvxULSpaceItem aULSpace = (const SvxULSpaceItem&) aEditAttr.Get( EE_PARA_ULSPACE ); 664 aULSpace.SetWhich(SID_ATTR_PARA_ULSPACE); 665 rSet.Put(aULSpace); 666 } 667 else 668 rSet.InvalidateItem(nSlotId); 669 } 670 break; 671 case SID_ATTR_CHAR_FONT: 672 case SID_ATTR_CHAR_FONTHEIGHT: 673 case SID_ATTR_CHAR_WEIGHT: 674 case SID_ATTR_CHAR_POSTURE: 675 { 676 if ( pOLV ) 677 { 678 sal_uInt16 nScriptType = pOLV->GetSelectedScriptType(); 679 SfxItemPool* pSecondPool = aEditAttr.GetPool()->GetSecondaryPool(); 680 if( !pSecondPool ) 681 pSecondPool = aEditAttr.GetPool(); 682 SvxScriptSetItem aSetItem( nSlotId, *pSecondPool ); 683 aSetItem.GetItemSet().Put( aEditAttr, sal_False ); 684 const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType ); 685 if( pI ) 686 rSet.Put( *pI, nWhich ); 687 else 688 rSet.InvalidateItem( nWhich ); 689 } 690 else 691 rSet.InvalidateItem( nWhich ); 692 } 693 break; 694 case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break; 695 case SID_ATTR_CHAR_UNDERLINE: nEEWhich = EE_CHAR_UNDERLINE;break; 696 case SID_ATTR_CHAR_OVERLINE: nEEWhich = EE_CHAR_OVERLINE;break; 697 case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break; 698 case SID_ATTR_CHAR_SHADOWED: nEEWhich = EE_CHAR_SHADOW;break; 699 case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT;break; 700 case SID_ATTR_CHAR_LANGUAGE : nEEWhich = EE_CHAR_LANGUAGE;break; 701 case FN_SET_SUPER_SCRIPT: 702 case FN_SET_SUB_SCRIPT: 703 { 704 sal_uInt16 nEsc = 0; 705 const SfxPoolItem *pEscItem = 0; 706 if (nWhich==FN_SET_SUPER_SCRIPT) 707 nEsc = SVX_ESCAPEMENT_SUPERSCRIPT; 708 else 709 nEsc = SVX_ESCAPEMENT_SUBSCRIPT; 710 711 if( !pEscItem ) 712 pEscItem = &aEditAttr.Get( EE_CHAR_ESCAPEMENT ); 713 714 if( nEsc == ((const SvxEscapementItem*)pEscItem)->GetEnumValue() ) 715 rSet.Put( SfxBoolItem( nWhich, sal_True )); 716 else 717 rSet.InvalidateItem( nWhich ); 718 break; 719 } 720 case SID_ATTR_PARA_ADJUST_LEFT: 721 case SID_ATTR_PARA_ADJUST_RIGHT: 722 case SID_ATTR_PARA_ADJUST_CENTER: 723 case SID_ATTR_PARA_ADJUST_BLOCK: 724 { 725 const SfxPoolItem *pAdjust = 0; 726 int eAdjust = 0; 727 728 if (nWhich==SID_ATTR_PARA_ADJUST_LEFT) 729 eAdjust = SVX_ADJUST_LEFT; 730 else 731 if (nWhich==SID_ATTR_PARA_ADJUST_RIGHT) 732 eAdjust = SVX_ADJUST_RIGHT; 733 else 734 if (nWhich==SID_ATTR_PARA_ADJUST_CENTER) 735 eAdjust = SVX_ADJUST_CENTER; 736 else 737 if (nWhich==SID_ATTR_PARA_ADJUST_BLOCK) 738 eAdjust = SVX_ADJUST_BLOCK; 739 740 if( !pAdjust ) 741 aEditAttr.GetItemState( EE_PARA_JUST, sal_False, &pAdjust); 742 743 if( !pAdjust || IsInvalidItem( pAdjust )) 744 rSet.InvalidateItem( nSlotId ), nSlotId = 0; 745 else 746 { 747 if ( eAdjust == ((const SvxAdjustItem*)pAdjust)->GetAdjust()) 748 rSet.Put( SfxBoolItem( nWhich, sal_True )); 749 else 750 rSet.InvalidateItem( nWhich ); 751 } 752 break; 753 } 754 case SID_ATTR_PARA_LINESPACE_10: 755 case SID_ATTR_PARA_LINESPACE_15: 756 case SID_ATTR_PARA_LINESPACE_20: 757 { 758 const SfxPoolItem *pLSpace = 0; 759 int nLSpace = 0; 760 761 if (nWhich==SID_ATTR_PARA_LINESPACE_10) 762 nLSpace = 100; 763 else 764 if (nWhich==SID_ATTR_PARA_LINESPACE_15) 765 nLSpace = 150; 766 else 767 if (nWhich==SID_ATTR_PARA_LINESPACE_20) 768 nLSpace = 200; 769 770 if( !pLSpace ) 771 aEditAttr.GetItemState( EE_PARA_SBL, sal_False, &pLSpace ); 772 773 if( !pLSpace || IsInvalidItem( pLSpace )) 774 rSet.InvalidateItem( nSlotId ), nSlotId = 0; 775 else 776 { 777 if( nLSpace == ((const SvxLineSpacingItem*)pLSpace)->GetPropLineSpace() ) 778 rSet.Put( SfxBoolItem( nWhich, sal_True )); 779 else 780 rSet.InvalidateItem( nWhich ); 781 } 782 break; 783 } 784 case SID_AUTOSPELL_CHECK: 785 { 786 const SfxPoolItem* pState = rView.GetSlotState(nWhich); 787 if (pState) 788 rSet.Put(SfxBoolItem(nWhich, ((const SfxBoolItem*)pState)->GetValue())); 789 else 790 rSet.DisableItem( nWhich ); 791 break; 792 } 793 case SID_ATTR_PARA_LEFT_TO_RIGHT: 794 case SID_ATTR_PARA_RIGHT_TO_LEFT: 795 { 796 if ( !SvtLanguageOptions().IsCTLFontEnabled() ) 797 rSet.DisableItem( nWhich ); 798 else 799 { 800 if(pOLV->GetOutliner() && pOLV->GetOutliner()->IsVertical()) 801 rSet.DisableItem( nWhich ); 802 else 803 { 804 sal_Bool bFlag = sal_False; 805 switch( ( ( (SvxFrameDirectionItem&) aEditAttr.Get( EE_PARA_WRITINGDIR ) ) ).GetValue() ) 806 { 807 case FRMDIR_HORI_LEFT_TOP: 808 { 809 bFlag = nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT; 810 rSet.Put( SfxBoolItem( nWhich, bFlag )); 811 break; 812 } 813 case FRMDIR_HORI_RIGHT_TOP: 814 { 815 bFlag = nWhich != SID_ATTR_PARA_LEFT_TO_RIGHT; 816 rSet.Put( SfxBoolItem( nWhich, bFlag )); 817 break; 818 } 819 } 820 } 821 } 822 } 823 break; 824 case SID_INSERT_RLM : 825 case SID_INSERT_LRM : 826 case SID_INSERT_ZWNBSP : 827 case SID_INSERT_ZWSP: 828 { 829 SvtCTLOptions aCTLOptions; 830 sal_Bool bEnabled = aCTLOptions.IsCTLFontEnabled(); 831 rView.GetViewFrame()->GetBindings().SetVisibleState( nWhich, bEnabled ); 832 if(!bEnabled) 833 rSet.DisableItem(nWhich); 834 } 835 break; 836 default: 837 rSet.InvalidateItem( nWhich ); 838 break; 839 } 840 841 if(nEEWhich) 842 rSet.Put(aEditAttr.Get(nEEWhich, sal_True), nWhich); 843 844 if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED) 845 rSet.DisableItem( nWhich ); 846 847 nWhich = aIter.NextWhich(); 848 } 849 } 850 851 void SwAnnotationShell::ExecSearch(SfxRequest& rReq, sal_Bool bNoMessage) 852 { 853 rView.ExecSearch(rReq,bNoMessage); 854 } 855 856 void SwAnnotationShell::StateSearch(SfxItemSet &rSet) 857 { 858 rView.StateSearch(rSet); 859 } 860 861 void SwAnnotationShell::ExecClpbrd(SfxRequest &rReq) 862 { 863 SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); 864 if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() ) 865 return; 866 867 OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView(); 868 SfxItemSet aEditAttr(pOLV->GetAttribs()); 869 SfxItemSet aNewAttr(*aEditAttr.GetPool(), aEditAttr.GetRanges()); 870 871 long aOldHeight = pPostItMgr->GetActiveSidebarWin()->GetPostItTextHeight(); 872 sal_uInt16 nSlot = rReq.GetSlot(); 873 switch (nSlot) 874 { 875 case SID_CUT: 876 if ( (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED) && pOLV->HasSelection() ) 877 pOLV->Cut(); 878 break; 879 case SID_COPY: 880 if( pOLV->HasSelection() ) 881 pOLV->Copy(); 882 break; 883 case SID_PASTE: 884 if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED) 885 pOLV->Paste(); 886 break; 887 case SID_PASTE_SPECIAL: 888 { 889 if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED) 890 { 891 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 892 SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( &rView.GetEditWin() ); 893 894 pDlg->Insert( SOT_FORMAT_STRING, aEmptyStr ); 895 pDlg->Insert( SOT_FORMAT_RTF, aEmptyStr ); 896 897 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &rView.GetEditWin() ) ); 898 899 sal_uLong nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() ); 900 901 if (nFormat > 0) 902 { 903 if (nFormat == SOT_FORMAT_STRING) 904 pOLV->Paste(); 905 else 906 pOLV->PasteSpecial(); 907 } 908 delete pDlg; 909 } 910 break; 911 } 912 case SID_CLIPBOARD_FORMAT_ITEMS: 913 { 914 sal_uLong nFormat = 0; 915 const SfxPoolItem* pItem; 916 if ( rReq.GetArgs() && rReq.GetArgs()->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET && 917 pItem->ISA(SfxUInt32Item) ) 918 { 919 nFormat = ((const SfxUInt32Item*)pItem)->GetValue(); 920 } 921 922 if ( nFormat ) 923 { 924 if (SOT_FORMAT_STRING == nFormat) 925 pOLV->Paste(); 926 else 927 pOLV->PasteSpecial(); 928 } 929 break; 930 } 931 } 932 pPostItMgr->GetActiveSidebarWin()->ResizeIfNeccessary(aOldHeight,pPostItMgr->GetActiveSidebarWin()->GetPostItTextHeight()); 933 } 934 935 void SwAnnotationShell::StateClpbrd(SfxItemSet &rSet) 936 { 937 SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); 938 if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() ) 939 return; 940 OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView(); 941 942 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &rView.GetEditWin() ) ); 943 bool bPastePossible = ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) || aDataHelper.HasFormat( SOT_FORMAT_RTF ) ); 944 bPastePossible = bPastePossible && (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED); 945 946 SfxWhichIter aIter(rSet); 947 sal_uInt16 nWhich = aIter.FirstWhich(); 948 949 while(nWhich) 950 { 951 switch(nWhich) 952 { 953 case SID_CUT: 954 { 955 if ( (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED) || !pOLV->HasSelection() ) 956 rSet.DisableItem( nWhich ); 957 } 958 case SID_COPY: 959 { 960 if( !pOLV->HasSelection() ) 961 rSet.DisableItem( nWhich ); 962 break; 963 } 964 case SID_PASTE: 965 case SID_PASTE_SPECIAL: 966 { 967 if( !bPastePossible ) 968 rSet.DisableItem( nWhich ); 969 break; 970 } 971 case SID_CLIPBOARD_FORMAT_ITEMS: 972 { 973 if ( bPastePossible ) 974 { 975 SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS ); 976 if ( aDataHelper.HasFormat( SOT_FORMAT_RTF ) ) 977 aFormats.AddClipbrdFormat( SOT_FORMAT_RTF ); 978 //if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) ) 979 aFormats.AddClipbrdFormat( SOT_FORMAT_STRING ); 980 rSet.Put( aFormats ); 981 } 982 else 983 rSet.DisableItem( nWhich ); 984 break; 985 } 986 } 987 nWhich = aIter.NextWhich(); 988 } 989 } 990 991 void SwAnnotationShell::StateStatusLine(SfxItemSet &rSet) 992 { 993 SfxWhichIter aIter( rSet ); 994 sal_uInt16 nWhich = aIter.FirstWhich(); 995 996 while( nWhich ) 997 { 998 switch( nWhich ) 999 { 1000 case FN_STAT_SELMODE: 1001 { 1002 rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 0)); 1003 rSet.DisableItem( nWhich ); 1004 break; 1005 } 1006 case FN_STAT_TEMPLATE: 1007 { 1008 rSet.DisableItem( nWhich ); 1009 break; 1010 } 1011 } 1012 nWhich = aIter.NextWhich(); 1013 } 1014 } 1015 1016 void SwAnnotationShell::StateInsert(SfxItemSet &rSet) 1017 { 1018 SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); 1019 if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() ) 1020 return; 1021 1022 OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView(); 1023 SfxWhichIter aIter(rSet); 1024 sal_uInt16 nWhich = aIter.FirstWhich(); 1025 1026 while(nWhich) 1027 { 1028 switch(nWhich) 1029 { 1030 case SID_HYPERLINK_GETLINK: 1031 { 1032 SvxHyperlinkItem aHLinkItem; 1033 aHLinkItem.SetInsertMode(HLINK_FIELD); 1034 1035 const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection(); 1036 1037 if (pFieldItem) 1038 { 1039 const SvxFieldData* pField = pFieldItem->GetField(); 1040 1041 if (pField->ISA(SvxURLField)) 1042 { 1043 aHLinkItem.SetName(((const SvxURLField*) pField)->GetRepresentation()); 1044 aHLinkItem.SetURL(((const SvxURLField*) pField)->GetURL()); 1045 aHLinkItem.SetTargetFrame(((const SvxURLField*) pField)->GetTargetFrame()); 1046 } 1047 } 1048 else 1049 { 1050 String sSel(pOLV->GetSelected()); 1051 sSel.Erase(255); 1052 sSel.EraseTrailingChars(); 1053 aHLinkItem.SetName(sSel); 1054 } 1055 1056 sal_uInt16 nHtmlMode = ::GetHtmlMode(rView.GetDocShell()); 1057 aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() | 1058 ((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0))); 1059 1060 rSet.Put(aHLinkItem); 1061 } 1062 break; 1063 } 1064 1065 if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED) 1066 rSet.DisableItem( nWhich ); 1067 1068 nWhich = aIter.NextWhich(); 1069 } 1070 } 1071 1072 1073 void SwAnnotationShell::NoteExec(SfxRequest &rReq) 1074 { 1075 SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); 1076 if ( !pPostItMgr ) 1077 return; 1078 1079 sal_uInt16 nSlot = rReq.GetSlot(); 1080 switch (nSlot) 1081 { 1082 case FN_REPLY: 1083 case FN_POSTIT: 1084 case FN_DELETE_COMMENT: 1085 if ( pPostItMgr->HasActiveSidebarWin() ) 1086 pPostItMgr->GetActiveSidebarWin()->ExecuteCommand(nSlot); 1087 break; 1088 case FN_DELETE_ALL_NOTES: 1089 pPostItMgr->Delete(); 1090 break; 1091 case FN_DELETE_NOTE_AUTHOR: 1092 { 1093 SFX_REQUEST_ARG( rReq, pItem, SfxStringItem, nSlot, sal_False); 1094 if ( pItem ) 1095 pPostItMgr->Delete( pItem->GetValue() ); 1096 break; 1097 } 1098 case FN_HIDE_NOTE: 1099 /* 1100 if ( Mgr()->GetActiveSidebarWin() == this ) 1101 { 1102 Mgr()->SetActivePostIt(0); 1103 // put the cursor back into the document 1104 SwitchToFieldPos(); 1105 } 1106 Mgr()->Hide(mpFld); 1107 */ 1108 break; 1109 case FN_HIDE_ALL_NOTES: 1110 pPostItMgr->Hide(); 1111 break; 1112 case FN_HIDE_NOTE_AUTHOR: 1113 { 1114 SFX_REQUEST_ARG( rReq, pItem, SfxStringItem, nSlot, sal_False); 1115 if ( pItem ) 1116 pPostItMgr->Hide( pItem->GetValue() ); 1117 } 1118 } 1119 } 1120 1121 void SwAnnotationShell::GetNoteState(SfxItemSet &rSet) 1122 { 1123 SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); 1124 SfxWhichIter aIter(rSet); 1125 sal_uInt16 nWhich = aIter.FirstWhich(); 1126 while(nWhich) 1127 { 1128 sal_uInt16 nSlotId = GetPool().GetSlotId( nWhich ); 1129 switch( nSlotId ) 1130 { 1131 case FN_POSTIT: 1132 case FN_DELETE_NOTE_AUTHOR: 1133 case FN_DELETE_ALL_NOTES: 1134 case FN_HIDE_NOTE: 1135 case FN_HIDE_NOTE_AUTHOR: 1136 case FN_HIDE_ALL_NOTES: 1137 case FN_DELETE_COMMENT: 1138 { 1139 if ( !pPostItMgr || 1140 !pPostItMgr->HasActiveAnnotationWin() ) 1141 { 1142 rSet.DisableItem(nWhich); 1143 } 1144 break; 1145 } 1146 case FN_REPLY: 1147 { 1148 if ( !pPostItMgr || 1149 !pPostItMgr->HasActiveAnnotationWin() ) 1150 { 1151 rSet.DisableItem(nWhich); 1152 } 1153 else 1154 { 1155 SvtUserOptions aUserOpt; 1156 String sAuthor; 1157 if( !(sAuthor = aUserOpt.GetFullName()).Len()) 1158 if( !(sAuthor = aUserOpt.GetID()).Len() ) 1159 sAuthor = String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR )); 1160 if (sAuthor == pPostItMgr->GetActiveSidebarWin()->GetAuthor()) 1161 rSet.DisableItem(nWhich); 1162 } 1163 break; 1164 } 1165 default: 1166 rSet.InvalidateItem( nWhich ); 1167 break; 1168 } 1169 1170 if (pPostItMgr->HasActiveSidebarWin()) 1171 { 1172 if ( (pPostItMgr->GetActiveSidebarWin()->IsProtected()) && 1173 ( (nSlotId==FN_DELETE_COMMENT) || (nSlotId==FN_REPLY) ) ) 1174 rSet.DisableItem( nWhich ); 1175 } 1176 nWhich = aIter.NextWhich(); 1177 } 1178 } 1179 1180 void SwAnnotationShell::ExecLingu(SfxRequest &rReq) 1181 { 1182 SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); 1183 if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() ) 1184 return; 1185 1186 OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView(); 1187 SfxItemSet aEditAttr(pOLV->GetAttribs()); 1188 sal_uInt16 nSlot = rReq.GetSlot(); 1189 SwWrtShell &rSh = rView.GetWrtShell(); 1190 bool bRestoreSelection = false; 1191 ESelection aOldSelection; 1192 1193 switch (nSlot) 1194 { 1195 case SID_LANGUAGE_STATUS: 1196 { 1197 aOldSelection = pOLV->GetSelection(); 1198 if (!pOLV->GetEditView().HasSelection()) 1199 { 1200 bRestoreSelection = true; 1201 pOLV->GetEditView().SelectCurrentWord(); 1202 } 1203 1204 bRestoreSelection = SwLangHelper::SetLanguageStatus(pOLV,rReq,rView,rSh); 1205 break; 1206 } 1207 case SID_THES: 1208 { 1209 String aReplaceText; 1210 SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES, sal_False ); 1211 if (pItem2) 1212 aReplaceText = pItem2->GetValue(); 1213 if (aReplaceText.Len() > 0) 1214 ReplaceTextWithSynonym( pOLV->GetEditView(), aReplaceText ); 1215 break; 1216 } 1217 case SID_THESAURUS: 1218 { 1219 pOLV->StartThesaurus(); 1220 break; 1221 } 1222 case SID_HANGUL_HANJA_CONVERSION: 1223 pOLV->StartTextConversion( LANGUAGE_KOREAN, LANGUAGE_KOREAN, NULL, 1224 i18n::TextConversionOption::CHARACTER_BY_CHARACTER, sal_True, sal_False ); 1225 break; 1226 1227 case SID_CHINESE_CONVERSION: 1228 { 1229 //open ChineseTranslationDialog 1230 Reference< XComponentContext > xContext( 1231 ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one 1232 if(xContext.is()) 1233 { 1234 Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() ); 1235 if(xMCF.is()) 1236 { 1237 Reference< ui::dialogs::XExecutableDialog > xDialog( 1238 xMCF->createInstanceWithContext( 1239 rtl::OUString::createFromAscii("com.sun.star.linguistic2.ChineseTranslationDialog") 1240 , xContext), UNO_QUERY); 1241 Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY ); 1242 if( xInit.is() ) 1243 { 1244 // initialize dialog 1245 Reference< awt::XWindow > xDialogParentWindow(0); 1246 Sequence<Any> aSeq(1); 1247 Any* pArray = aSeq.getArray(); 1248 PropertyValue aParam; 1249 aParam.Name = rtl::OUString::createFromAscii("ParentWindow"); 1250 aParam.Value <<= makeAny(xDialogParentWindow); 1251 pArray[0] <<= makeAny(aParam); 1252 xInit->initialize( aSeq ); 1253 1254 //execute dialog 1255 sal_Int16 nDialogRet = xDialog->execute(); 1256 if( RET_OK == nDialogRet ) 1257 { 1258 //get some parameters from the dialog 1259 sal_Bool bToSimplified = sal_True; 1260 sal_Bool bUseVariants = sal_True; 1261 sal_Bool bCommonTerms = sal_True; 1262 Reference< beans::XPropertySet > xProp( xDialog, UNO_QUERY ); 1263 if( xProp.is() ) 1264 { 1265 try 1266 { 1267 xProp->getPropertyValue( C2U("IsDirectionToSimplified") ) >>= bToSimplified; 1268 xProp->getPropertyValue( C2U("IsUseCharacterVariants") ) >>= bUseVariants; 1269 xProp->getPropertyValue( C2U("IsTranslateCommonTerms") ) >>= bCommonTerms; 1270 } 1271 catch( Exception& ) 1272 { 1273 } 1274 } 1275 1276 //execute translation 1277 sal_Int16 nSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED; 1278 sal_Int16 nTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL; 1279 sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0; 1280 if( !bCommonTerms ) 1281 nOptions = nOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER; 1282 1283 Font aTargetFont = pOLV->GetWindow()->GetDefaultFont( DEFAULTFONT_CJK_TEXT, 1284 nTargetLang, DEFAULTFONT_FLAGS_ONLYONE ); 1285 1286 pOLV->StartTextConversion( nSourceLang, nTargetLang, &aTargetFont, nOptions, sal_False, sal_False ); 1287 } 1288 } 1289 Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY ); 1290 if( xComponent.is() ) 1291 xComponent->dispose(); 1292 } 1293 } 1294 } 1295 break; 1296 } 1297 1298 if (bRestoreSelection) 1299 { 1300 // restore selection 1301 pOLV->GetEditView().SetSelection( aOldSelection ); 1302 } 1303 } 1304 1305 void SwAnnotationShell::GetLinguState(SfxItemSet &rSet) 1306 { 1307 SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); 1308 if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() ) 1309 return; 1310 1311 OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView(); 1312 SfxItemSet aEditAttr(pOLV->GetAttribs()); 1313 1314 SfxWhichIter aIter(rSet); 1315 sal_uInt16 nWhich = aIter.FirstWhich(); 1316 while(nWhich) 1317 { 1318 switch (nWhich) 1319 { 1320 case SID_LANGUAGE_STATUS: 1321 { 1322 SwLangHelper::GetLanguageStatus(pOLV,rSet); 1323 break; 1324 } 1325 1326 case SID_THES: 1327 { 1328 String aStatusVal; 1329 LanguageType nLang = LANGUAGE_NONE; 1330 bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, pOLV->GetEditView() ); 1331 rSet.Put( SfxStringItem( SID_THES, aStatusVal ) ); 1332 1333 // disable "Thesaurus" context menu entry if there is nothing to look up 1334 uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() ); 1335 lang::Locale aLocale( SvxCreateLocale( nLang ) ); 1336 if (!bIsLookUpWord || 1337 !xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( aLocale )) 1338 rSet.DisableItem( SID_THES ); 1339 break; 1340 } 1341 1342 // disable "Thesaurus" if the language is not supported 1343 case SID_THESAURUS: 1344 { 1345 const SfxPoolItem &rItem = rView.GetWrtShell().GetDoc()->GetDefault( 1346 GetWhichOfScript( RES_CHRATR_LANGUAGE, 1347 GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage())) ); 1348 LanguageType nLang = ((const SvxLanguageItem &) 1349 rItem).GetLanguage(); 1350 uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() ); 1351 if (!xThes.is() || nLang == LANGUAGE_NONE || 1352 !xThes->hasLocale( SvxCreateLocale( nLang ) )) 1353 rSet.DisableItem( SID_THESAURUS ); 1354 } 1355 break; 1356 case SID_HANGUL_HANJA_CONVERSION: 1357 case SID_CHINESE_CONVERSION: 1358 { 1359 if (!SvtCJKOptions().IsAnyEnabled()) 1360 { 1361 rView.GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False ); 1362 rSet.DisableItem(nWhich); 1363 } 1364 else 1365 rView.GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True ); 1366 } 1367 break; 1368 } 1369 1370 if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED) 1371 rSet.DisableItem( nWhich ); 1372 1373 nWhich = aIter.NextWhich(); 1374 } 1375 } 1376 1377 void SwAnnotationShell::ExecTransliteration(SfxRequest &rReq) 1378 { 1379 SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); 1380 if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() ) 1381 return; 1382 1383 OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView(); 1384 1385 using namespace ::com::sun::star::i18n; 1386 { 1387 sal_uInt32 nMode = 0; 1388 1389 switch( rReq.GetSlot() ) 1390 { 1391 case SID_TRANSLITERATE_SENTENCE_CASE: 1392 nMode = TransliterationModulesExtra::SENTENCE_CASE; 1393 break; 1394 case SID_TRANSLITERATE_TITLE_CASE: 1395 nMode = TransliterationModulesExtra::TITLE_CASE; 1396 break; 1397 case SID_TRANSLITERATE_TOGGLE_CASE: 1398 nMode = TransliterationModulesExtra::TOGGLE_CASE; 1399 break; 1400 case SID_TRANSLITERATE_UPPER: 1401 nMode = TransliterationModules_LOWERCASE_UPPERCASE; 1402 break; 1403 case SID_TRANSLITERATE_LOWER: 1404 nMode = TransliterationModules_UPPERCASE_LOWERCASE; 1405 break; 1406 case SID_TRANSLITERATE_HALFWIDTH: 1407 nMode = TransliterationModules_FULLWIDTH_HALFWIDTH; 1408 break; 1409 case SID_TRANSLITERATE_FULLWIDTH: 1410 nMode = TransliterationModules_HALFWIDTH_FULLWIDTH; 1411 break; 1412 case SID_TRANSLITERATE_HIRAGANA: 1413 nMode = TransliterationModules_KATAKANA_HIRAGANA; 1414 break; 1415 case SID_TRANSLITERATE_KATAGANA: 1416 nMode = TransliterationModules_HIRAGANA_KATAKANA; 1417 break; 1418 1419 default: 1420 ASSERT(!this, "falscher Dispatcher"); 1421 } 1422 1423 if( nMode ) 1424 { 1425 pOLV->TransliterateText( nMode ); 1426 } 1427 } 1428 } 1429 1430 void SwAnnotationShell::ExecUndo(SfxRequest &rReq) 1431 { 1432 const SfxItemSet* pArgs = rReq.GetArgs(); 1433 ::svl::IUndoManager* pUndoManager = GetUndoManager(); 1434 SwWrtShell &rSh = rView.GetWrtShell(); 1435 1436 long aOldHeight = rView.GetPostItMgr()->HasActiveSidebarWin() 1437 ? rView.GetPostItMgr()->GetActiveSidebarWin()->GetPostItTextHeight() 1438 : 0; 1439 1440 sal_uInt16 nId = rReq.GetSlot(); 1441 sal_uInt16 nCnt = 1; 1442 const SfxPoolItem* pItem=0; 1443 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nId, sal_False, &pItem ) ) 1444 nCnt = ((SfxUInt16Item*)pItem)->GetValue(); 1445 switch( nId ) 1446 { 1447 case SID_UNDO: 1448 { 1449 if ( pUndoManager ) 1450 { 1451 sal_uInt16 nCount = pUndoManager->GetUndoActionCount(); 1452 sal_uInt16 nSteps = nCnt; 1453 if ( nCount < nCnt ) 1454 { 1455 nCnt = nCnt - nCount; 1456 nSteps = nCount; 1457 } 1458 else 1459 nCnt = 0; 1460 1461 while( nSteps-- ) 1462 pUndoManager->Undo(); 1463 } 1464 1465 if ( nCnt ) 1466 rSh.Do( SwWrtShell::UNDO, nCnt ); 1467 1468 break; 1469 } 1470 1471 case SID_REDO: 1472 { 1473 if ( pUndoManager ) 1474 { 1475 sal_uInt16 nCount = pUndoManager->GetRedoActionCount(); 1476 sal_uInt16 nSteps = nCnt; 1477 if ( nCount < nCnt ) 1478 { 1479 nCnt = nCnt - nCount; 1480 nSteps = nCount; 1481 } 1482 else 1483 nCnt = 0; 1484 1485 while( nSteps-- ) 1486 pUndoManager->Redo(); 1487 } 1488 1489 if ( nCnt ) 1490 rSh.Do( SwWrtShell::REDO, nCnt ); 1491 1492 break; 1493 } 1494 } 1495 1496 rView.GetViewFrame()->GetBindings().InvalidateAll(sal_False); 1497 1498 if (rView.GetPostItMgr()->HasActiveSidebarWin()) 1499 rView.GetPostItMgr()->GetActiveSidebarWin()->ResizeIfNeccessary(aOldHeight,rView.GetPostItMgr()->GetActiveSidebarWin()->GetPostItTextHeight()); 1500 } 1501 1502 void SwAnnotationShell::StateUndo(SfxItemSet &rSet) 1503 { 1504 SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); 1505 if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() ) 1506 return; 1507 1508 SfxWhichIter aIter(rSet); 1509 sal_uInt16 nWhich = aIter.FirstWhich(); 1510 ::svl::IUndoManager* pUndoManager = GetUndoManager(); 1511 SfxViewFrame *pSfxViewFrame = rView.GetViewFrame(); 1512 SwWrtShell &rSh = rView.GetWrtShell(); 1513 1514 while( nWhich ) 1515 { 1516 switch ( nWhich ) 1517 { 1518 case SID_UNDO: 1519 { 1520 sal_uInt16 nCount = pUndoManager->GetUndoActionCount(); 1521 if ( nCount ) 1522 pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet ); 1523 else if (rSh.GetLastUndoInfo(0, 0)) 1524 { 1525 rSet.Put( SfxStringItem( nWhich, rSh.GetDoString(SwWrtShell::UNDO)) ); 1526 } 1527 else 1528 rSet.DisableItem(nWhich); 1529 break; 1530 } 1531 case SID_REDO: 1532 { 1533 sal_uInt16 nCount = pUndoManager->GetRedoActionCount(); 1534 if ( nCount ) 1535 pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet ); 1536 else if (rSh.GetFirstRedoInfo(0)) 1537 { 1538 rSet.Put(SfxStringItem( nWhich, rSh.GetDoString(SwWrtShell::REDO)) ); 1539 } 1540 else 1541 rSet.DisableItem(nWhich); 1542 break; 1543 } 1544 case SID_GETUNDOSTRINGS: 1545 case SID_GETREDOSTRINGS: 1546 { 1547 if( pUndoManager ) 1548 { 1549 UniString (::svl::IUndoManager:: *fnGetComment)( size_t, bool const ) const; 1550 1551 sal_uInt16 nCount; 1552 if( SID_GETUNDOSTRINGS == nWhich ) 1553 { 1554 nCount = pUndoManager->GetUndoActionCount(); 1555 fnGetComment = &::svl::IUndoManager::GetUndoActionComment; 1556 } 1557 else 1558 { 1559 nCount = pUndoManager->GetRedoActionCount(); 1560 fnGetComment = &::svl::IUndoManager::GetRedoActionComment; 1561 } 1562 1563 String sList; 1564 if( nCount ) 1565 { 1566 for( sal_uInt16 n = 0; n < nCount; ++n ) 1567 ( sList += (pUndoManager->*fnGetComment)( n, ::svl::IUndoManager::TopLevel ) ) 1568 += '\n'; 1569 } 1570 1571 SfxStringListItem aItem( nWhich ); 1572 if ((nWhich == SID_GETUNDOSTRINGS) && 1573 rSh.GetLastUndoInfo(0, 0)) 1574 { 1575 rSh.GetDoStrings( SwWrtShell::UNDO, aItem ); 1576 } 1577 else if ((nWhich == SID_GETREDOSTRINGS) && 1578 (rSh.GetFirstRedoInfo(0))) 1579 { 1580 rSh.GetDoStrings( SwWrtShell::UNDO, aItem ); 1581 } 1582 1583 sList += aItem.GetString(); 1584 aItem.SetString( sList ); 1585 rSet.Put( aItem ); 1586 } 1587 else 1588 rSet.DisableItem( nWhich ); 1589 } 1590 break; 1591 1592 default: 1593 { 1594 pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet ); 1595 break; 1596 } 1597 1598 } 1599 1600 if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED) 1601 rSet.DisableItem( nWhich ); 1602 1603 nWhich = aIter.NextWhich(); 1604 } 1605 } 1606 1607 void SwAnnotationShell::StateDisableItems( SfxItemSet &rSet ) 1608 { 1609 SfxWhichIter aIter(rSet); 1610 sal_uInt16 nWhich = aIter.FirstWhich(); 1611 while (nWhich) 1612 { 1613 rSet.DisableItem( nWhich ); 1614 nWhich = aIter.NextWhich(); 1615 } 1616 } 1617 1618 void SwAnnotationShell::InsertSymbol(SfxRequest& rReq) 1619 { 1620 SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); 1621 if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() ) 1622 return; 1623 1624 OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView(); 1625 1626 const SfxItemSet *pArgs = rReq.GetArgs(); 1627 const SfxPoolItem* pItem = 0; 1628 if( pArgs ) 1629 pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), sal_False, &pItem); 1630 1631 String sSym; 1632 String sFontName; 1633 if ( pItem ) 1634 { 1635 sSym = ((const SfxStringItem*)pItem)->GetValue(); 1636 const SfxPoolItem* pFtItem = NULL; 1637 pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), sal_False, &pFtItem); 1638 const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem ); 1639 if ( pFontItem ) 1640 sFontName = pFontItem->GetValue(); 1641 } 1642 1643 SfxItemSet aSet(pOLV->GetAttribs()); 1644 sal_uInt16 nScript = pOLV->GetSelectedScriptType(); 1645 SvxFontItem aSetDlgFont( RES_CHRATR_FONT ); 1646 { 1647 SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() ); 1648 aSetItem.GetItemSet().Put( aSet, sal_False ); 1649 const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript ); 1650 if( pI ) 1651 aSetDlgFont = *(SvxFontItem*)pI; 1652 else 1653 aSetDlgFont = (SvxFontItem&)aSet.Get( GetWhichOfScript( 1654 SID_ATTR_CHAR_FONT, 1655 GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() ) )); 1656 if (!sFontName.Len()) 1657 sFontName = aSetDlgFont.GetFamilyName(); 1658 } 1659 1660 Font aFont(sFontName, Size(1,1)); 1661 if( !sSym.Len() ) 1662 { 1663 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 1664 1665 SfxAllItemSet aAllSet( GetPool() ); 1666 aAllSet.Put( SfxBoolItem( FN_PARAM_1, sal_False ) ); 1667 1668 SwViewOption aOpt(*rView.GetWrtShell().GetViewOptions()); 1669 String sSymbolFont = aOpt.GetSymbolFont(); 1670 if( sSymbolFont.Len() ) 1671 aAllSet.Put( SfxStringItem( SID_FONT_NAME, sSymbolFont ) ); 1672 else 1673 aAllSet.Put( SfxStringItem( SID_FONT_NAME, aSetDlgFont.GetFamilyName() ) ); 1674 1675 // Wenn Zeichen selektiert ist kann es angezeigt werden 1676 SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( rView.GetWindow(), aAllSet, 1677 rView.GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP ); 1678 1679 sal_uInt16 nResult = pDlg->Execute(); 1680 if( nResult == RET_OK ) 1681 { 1682 SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pCItem, SfxStringItem, SID_CHARMAP, sal_False ); 1683 SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, sal_False ); 1684 if ( pFontItem ) 1685 { 1686 aFont.SetName( pFontItem->GetFamilyName() ); 1687 aFont.SetStyleName( pFontItem->GetStyleName() ); 1688 aFont.SetCharSet( pFontItem->GetCharSet() ); 1689 aFont.SetPitch( pFontItem->GetPitch() ); 1690 } 1691 1692 if ( pCItem ) 1693 { 1694 sSym = pCItem->GetValue(); 1695 aOpt.SetSymbolFont(aFont.GetName()); 1696 SW_MOD()->ApplyUsrPref(aOpt, &rView); 1697 } 1698 } 1699 1700 delete( pDlg ); 1701 } 1702 1703 if( sSym.Len() ) 1704 { 1705 // nicht flackern 1706 pOLV->HideCursor(); 1707 Outliner * pOutliner = pOLV->GetOutliner(); 1708 pOutliner->SetUpdateMode(sal_False); 1709 1710 SfxItemSet aOldSet( pOLV->GetAttribs() ); 1711 SfxItemSet aFontSet( *aOldSet.GetPool(), 1712 EE_CHAR_FONTINFO, EE_CHAR_FONTINFO, 1713 EE_CHAR_FONTINFO_CJK, EE_CHAR_FONTINFO_CJK, 1714 EE_CHAR_FONTINFO_CTL, EE_CHAR_FONTINFO_CTL, 1715 0 ); 1716 aFontSet.Set( aOldSet ); 1717 1718 // String einfuegen 1719 pOLV->InsertText( sSym); 1720 1721 // attributieren (Font setzen) 1722 SfxItemSet aSetFont( *aFontSet.GetPool(), aFontSet.GetRanges() ); 1723 SvxFontItem aFontItem (aFont.GetFamily(), aFont.GetName(), 1724 aFont.GetStyleName(), aFont.GetPitch(), 1725 aFont.GetCharSet(), 1726 EE_CHAR_FONTINFO ); 1727 sal_uInt16 nScriptBreak = pBreakIt->GetAllScriptsOfText( sSym ); 1728 if( SCRIPTTYPE_LATIN & nScriptBreak ) 1729 aSetFont.Put( aFontItem, EE_CHAR_FONTINFO ); 1730 if( SCRIPTTYPE_ASIAN & nScriptBreak ) 1731 aSetFont.Put( aFontItem, EE_CHAR_FONTINFO_CJK ); 1732 if( SCRIPTTYPE_COMPLEX & nScriptBreak ) 1733 aSetFont.Put( aFontItem, EE_CHAR_FONTINFO_CTL ); 1734 pOLV->SetAttribs(aSetFont); 1735 1736 // Selektion loeschen 1737 ESelection aSel(pOLV->GetSelection()); 1738 aSel.nStartPara = aSel.nEndPara; 1739 aSel.nStartPos = aSel.nEndPos; 1740 pOLV->SetSelection(aSel); 1741 1742 // Alten Font restaurieren 1743 pOLV->SetAttribs( aFontSet ); 1744 1745 // ab jetzt wieder anzeigen 1746 pOutliner->SetUpdateMode(sal_True); 1747 pOLV->ShowCursor(); 1748 1749 rReq.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP), sSym ) ); 1750 if(aFont.GetName().Len()) 1751 rReq.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR, aFont.GetName() ) ); 1752 rReq.Done(); 1753 } 1754 } 1755