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_sc.hxx" 26 27 28 29 //------------------------------------------------------------------------- 30 31 #include <com/sun/star/linguistic2/XThesaurus.hpp> 32 #include <com/sun/star/lang/Locale.hpp> 33 34 #include "scitems.hxx" 35 36 #include <editeng/adjitem.hxx> 37 #include <svx/clipfmtitem.hxx> 38 #include <editeng/cntritem.hxx> 39 #include <editeng/crsditem.hxx> 40 #include <editeng/editeng.hxx> 41 #include <editeng/escpitem.hxx> 42 #include <editeng/flditem.hxx> 43 #include <editeng/fontitem.hxx> 44 #include <editeng/frmdiritem.hxx> 45 #include <editeng/lrspitem.hxx> 46 #include <editeng/lspcitem.hxx> 47 #include <editeng/ulspitem.hxx> 48 #include <svx/hlnkitem.hxx> 49 #include <editeng/lspcitem.hxx> 50 #include <svx/svdoutl.hxx> 51 #include <editeng/unolingu.hxx> 52 #include <editeng/outlobj.hxx> 53 #include <editeng/postitem.hxx> 54 #include <editeng/scripttypeitem.hxx> 55 #include <editeng/shdditem.hxx> 56 #include <svl/srchitem.hxx> 57 #include <editeng/udlnitem.hxx> 58 #include <editeng/wghtitem.hxx> 59 #include <editeng/writingmodeitem.hxx> 60 #include <sfx2/app.hxx> 61 #include <sfx2/dispatch.hxx> 62 #include <sfx2/objface.hxx> 63 #include <sfx2/objsh.hxx> 64 #include <sfx2/request.hxx> 65 #include <sfx2/viewfrm.hxx> 66 #include <svtools/cliplistener.hxx> 67 #include <svtools/transfer.hxx> 68 #include <svl/whiter.hxx> 69 #include <svl/languageoptions.hxx> 70 #include <vcl/msgbox.hxx> 71 72 #include <svx/svxdlg.hxx> 73 #include <svx/dialogs.hrc> 74 #include <sfx2/sidebar/EnumContext.hxx> 75 76 #include "sc.hrc" 77 #include "globstr.hrc" 78 #include "scmod.hxx" 79 #include "drtxtob.hxx" 80 #include "fudraw.hxx" 81 #include "viewdata.hxx" 82 #include "document.hxx" 83 #include "drawview.hxx" 84 #include "viewutil.hxx" 85 #include "scresid.hxx" 86 #include "tabvwsh.hxx" 87 88 #define ScDrawTextObjectBar 89 #include "scslots.hxx" 90 91 92 using namespace ::com::sun::star; 93 94 95 SFX_IMPL_INTERFACE( ScDrawTextObjectBar, SfxShell, ScResId(SCSTR_DRAWTEXTSHELL) ) 96 { 97 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER, 98 ScResId(RID_TEXT_TOOLBOX) ); 99 SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_DRAWTEXT) ); 100 SFX_CHILDWINDOW_REGISTRATION( ScGetFontWorkId() ); 101 } 102 103 TYPEINIT1( ScDrawTextObjectBar, SfxShell ); 104 105 106 107 // abschalten der nicht erwuenschten Acceleratoren: 108 109 void ScDrawTextObjectBar::StateDisableItems( SfxItemSet &rSet ) 110 { 111 SfxWhichIter aIter(rSet); 112 sal_uInt16 nWhich = aIter.FirstWhich(); 113 114 while (nWhich) 115 { 116 rSet.DisableItem( nWhich ); 117 nWhich = aIter.NextWhich(); 118 } 119 } 120 121 ScDrawTextObjectBar::ScDrawTextObjectBar(ScViewData* pData) : 122 SfxShell(pData->GetViewShell()), 123 pViewData(pData), 124 pClipEvtLstnr(NULL), 125 bPastePossible(sal_False) 126 { 127 SetPool( pViewData->GetScDrawView()->GetDefaultAttr().GetPool() ); 128 129 // UndoManager wird beim Umschalten in den Edit-Modus umgesetzt... 130 ::svl::IUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager(); 131 SetUndoManager( pMgr ); 132 if ( !pViewData->GetDocument()->IsUndoEnabled() ) 133 { 134 pMgr->SetMaxUndoActionCount( 0 ); 135 } 136 137 SetHelpId( HID_SCSHELL_DRTXTOB ); 138 SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("DrawText"))); 139 SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_DrawText)); 140 } 141 142 __EXPORT ScDrawTextObjectBar::~ScDrawTextObjectBar() 143 { 144 if ( pClipEvtLstnr ) 145 { 146 pClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), sal_False ); 147 148 // #122057# The listener may just now be waiting for the SolarMutex and call the link 149 // afterwards, in spite of RemoveListener. So the link has to be reset, too. 150 pClipEvtLstnr->ClearCallbackLink(); 151 152 pClipEvtLstnr->release(); 153 } 154 } 155 156 //======================================================================== 157 // 158 // Funktionen 159 // 160 //======================================================================== 161 162 void __EXPORT ScDrawTextObjectBar::Execute( SfxRequest &rReq ) 163 { 164 ScDrawView* pView = pViewData->GetScDrawView(); 165 OutlinerView* pOutView = pView->GetTextEditOutlinerView(); 166 Outliner* pOutliner = pView->GetTextEditOutliner(); 167 168 if (!pOutView || !pOutliner) 169 { 170 ExecuteGlobal( rReq ); // auf ganze Objekte 171 return; 172 } 173 174 const SfxItemSet* pReqArgs = rReq.GetArgs(); 175 sal_uInt16 nSlot = rReq.GetSlot(); 176 switch ( nSlot ) 177 { 178 case SID_COPY: 179 pOutView->Copy(); 180 break; 181 182 case SID_CUT: 183 pOutView->Cut(); 184 break; 185 186 case SID_PASTE: 187 pOutView->PasteSpecial(); 188 break; 189 190 case SID_CLIPBOARD_FORMAT_ITEMS: 191 { 192 sal_uLong nFormat = 0; 193 const SfxPoolItem* pItem; 194 if ( pReqArgs && 195 pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET && 196 pItem->ISA(SfxUInt32Item) ) 197 { 198 nFormat = ((const SfxUInt32Item*)pItem)->GetValue(); 199 } 200 201 if ( nFormat ) 202 { 203 if (nFormat == SOT_FORMAT_STRING) 204 pOutView->Paste(); 205 else 206 pOutView->PasteSpecial(); 207 } 208 } 209 break; 210 211 case SID_PASTE_SPECIAL: 212 ExecutePasteContents( rReq ); 213 break; 214 215 case SID_SELECTALL: 216 { 217 sal_uLong nCount = pOutliner->GetParagraphCount(); 218 ESelection aSel( 0,0,(sal_uInt16)nCount,0 ); 219 pOutView->SetSelection( aSel ); 220 } 221 break; 222 223 case SID_CHARMAP: 224 { 225 const SvxFontItem& rItem = (const SvxFontItem&) 226 pOutView->GetAttribs().Get(EE_CHAR_FONTINFO); 227 228 String aString; 229 SvxFontItem aNewItem( EE_CHAR_FONTINFO ); 230 231 const SfxItemSet *pArgs = rReq.GetArgs(); 232 const SfxPoolItem* pItem = 0; 233 if( pArgs ) 234 pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), sal_False, &pItem); 235 236 if ( pItem ) 237 { 238 aString = ((const SfxStringItem*)pItem)->GetValue(); 239 const SfxPoolItem* pFtItem = NULL; 240 pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), sal_False, &pFtItem); 241 const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem ); 242 if ( pFontItem ) 243 { 244 String aFontName(pFontItem->GetValue()); 245 Font aFont(aFontName, Size(1,1)); // Size nur wg. CTOR 246 aNewItem = SvxFontItem( aFont.GetFamily(), aFont.GetName(), 247 aFont.GetStyleName(), aFont.GetPitch(), 248 aFont.GetCharSet(), ATTR_FONT ); 249 } 250 else 251 aNewItem = rItem; 252 } 253 else 254 ScViewUtil::ExecuteCharMap( rItem, *pViewData->GetViewShell()->GetViewFrame(), aNewItem, aString ); 255 256 if ( aString.Len() ) 257 { 258 SfxItemSet aSet( pOutliner->GetEmptyItemSet() ); 259 aSet.Put( aNewItem ); 260 // SetAttribs an der View selektiert ein Wort, wenn nichts selektiert ist 261 pOutView->GetOutliner()->QuickSetAttribs( aSet, pOutView->GetSelection() ); 262 pOutView->InsertText(aString); 263 } 264 265 Invalidate( SID_ATTR_CHAR_FONT ); 266 } 267 break; 268 269 case SID_HYPERLINK_SETLINK: 270 if( pReqArgs ) 271 { 272 const SfxPoolItem* pItem; 273 if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, sal_True, &pItem ) == SFX_ITEM_SET ) 274 { 275 const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem; 276 const String& rName = pHyper->GetName(); 277 const String& rURL = pHyper->GetURL(); 278 const String& rTarget = pHyper->GetTargetFrame(); 279 SvxLinkInsertMode eMode = pHyper->GetInsertMode(); 280 281 sal_Bool bDone = sal_False; 282 if ( pOutView && ( eMode == HLINK_DEFAULT || eMode == HLINK_FIELD ) ) 283 { 284 const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection(); 285 if (pFieldItem) 286 { 287 const SvxFieldData* pField = pFieldItem->GetField(); 288 if ( pField && pField->ISA(SvxURLField) ) 289 { 290 // altes Feld selektieren 291 292 ESelection aSel = pOutView->GetSelection(); 293 aSel.Adjust(); 294 aSel.nEndPara = aSel.nStartPara; 295 aSel.nEndPos = aSel.nStartPos + 1; 296 pOutView->SetSelection( aSel ); 297 } 298 } 299 300 // neues Feld einfuegen 301 302 SvxURLField aURLField( rURL, rName, SVXURLFORMAT_REPR ); 303 aURLField.SetTargetFrame( rTarget ); 304 SvxFieldItem aURLItem( aURLField, EE_FEATURE_FIELD ); 305 pOutView->InsertField( aURLItem ); 306 307 // select new field 308 309 ESelection aSel = pOutView->GetSelection(); 310 if ( aSel.nStartPos == aSel.nEndPos && aSel.nStartPos > 0 ) 311 { 312 // Cursor is behind the inserted field -> extend selection to the left 313 314 --aSel.nStartPos; 315 pOutView->SetSelection( aSel ); 316 } 317 318 bDone = sal_True; 319 } 320 321 if (!bDone) 322 ExecuteGlobal( rReq ); // normal an der View 323 324 // InsertURL an der ViewShell schaltet bei "Text" die DrawShell ab !!! 325 } 326 } 327 break; 328 329 case SID_OPEN_HYPERLINK: 330 { 331 if ( pOutView ) 332 { 333 const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection(); 334 if ( pFieldItem ) 335 { 336 const SvxFieldData* pField = pFieldItem->GetField(); 337 if( pField && pField->ISA( SvxURLField ) ) 338 { 339 const SvxURLField* pURLField = static_cast< const SvxURLField* >( pField ); 340 ScGlobal::OpenURL( pURLField->GetURL(), pURLField->GetTargetFrame() ); 341 } 342 } 343 } 344 } 345 break; 346 347 case SID_ENABLE_HYPHENATION: 348 case SID_TEXTDIRECTION_LEFT_TO_RIGHT: 349 case SID_TEXTDIRECTION_TOP_TO_BOTTOM: 350 #if 0 // DR 351 if (IsNoteEdit()) 352 { 353 pView->CaptionTextDirection( rReq.GetSlot()); // process Notes before we end the text edit. 354 ExecuteGlobal( rReq ); 355 pViewData->GetDispatcher().Execute(pViewData->GetView()->GetDrawFuncPtr()->GetSlotID(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); 356 } 357 else 358 #endif 359 { 360 pView->ScEndTextEdit(); // end text edit before switching direction 361 ExecuteGlobal( rReq ); 362 // restore consistent state between shells and functions: 363 pViewData->GetDispatcher().Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); 364 } 365 break; 366 367 #if 0 368 // Hyphenation is handled above - text edit is ended 369 case SID_ENABLE_HYPHENATION: 370 // force loading of hyphenator (object is skipped in repaint) 371 ((ScDrawLayer*)pView->GetModel())->UseHyphenator(); 372 pOutliner->SetHyphenator( LinguMgr::GetHyphenator() ); 373 ExecuteGlobal( rReq ); 374 break; 375 #endif 376 377 case SID_THES: 378 { 379 String aReplaceText; 380 SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES, sal_False ); 381 if (pItem2) 382 aReplaceText = pItem2->GetValue(); 383 if (aReplaceText.Len() > 0) 384 ReplaceTextWithSynonym( pOutView->GetEditView(), aReplaceText ); 385 } 386 break; 387 388 case SID_THESAURUS: 389 { 390 pOutView->StartThesaurus(); 391 } 392 break; 393 394 } 395 } 396 397 void __EXPORT ScDrawTextObjectBar::GetState( SfxItemSet& rSet ) 398 { 399 SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame(); 400 sal_Bool bHasFontWork = pViewFrm->HasChildWindow(SID_FONTWORK); 401 sal_Bool bDisableFontWork = sal_False; 402 403 if (IsNoteEdit()) 404 { 405 // #i21255# notes now support rich text formatting (#i74140# but not fontwork) 406 bDisableFontWork = sal_True; 407 } 408 409 if ( bDisableFontWork ) 410 rSet.DisableItem( SID_FONTWORK ); 411 else 412 rSet.Put(SfxBoolItem(SID_FONTWORK, bHasFontWork)); 413 414 if ( rSet.GetItemState( SID_HYPERLINK_GETLINK ) != SFX_ITEM_UNKNOWN ) 415 { 416 SvxHyperlinkItem aHLinkItem; 417 SdrView* pView = pViewData->GetScDrawView(); 418 OutlinerView* pOutView = pView->GetTextEditOutlinerView(); 419 if ( pOutView ) 420 { 421 sal_Bool bField = sal_False; 422 const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection(); 423 if (pFieldItem) 424 { 425 const SvxFieldData* pField = pFieldItem->GetField(); 426 if ( pField && pField->ISA(SvxURLField) ) 427 { 428 const SvxURLField* pURLField = (const SvxURLField*) pField; 429 aHLinkItem.SetName( pURLField->GetRepresentation() ); 430 aHLinkItem.SetURL( pURLField->GetURL() ); 431 aHLinkItem.SetTargetFrame( pURLField->GetTargetFrame() ); 432 bField = sal_True; 433 } 434 } 435 if (!bField) 436 { 437 // use selected text as name for urls 438 String sReturn = pOutView->GetSelected(); 439 sReturn.Erase(255); 440 sReturn.EraseTrailingChars(); 441 aHLinkItem.SetName(sReturn); 442 } 443 } 444 rSet.Put(aHLinkItem); 445 } 446 447 if ( rSet.GetItemState( SID_OPEN_HYPERLINK ) != SFX_ITEM_UNKNOWN ) 448 { 449 SdrView* pView = pViewData->GetScDrawView(); 450 OutlinerView* pOutView = pView->GetTextEditOutlinerView(); 451 bool bEnable = false; 452 if ( pOutView ) 453 { 454 const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection(); 455 if ( pFieldItem ) 456 { 457 const SvxFieldData* pField = pFieldItem->GetField(); 458 bEnable = pField && pField->ISA( SvxURLField ); 459 } 460 } 461 if( !bEnable ) 462 rSet.DisableItem( SID_OPEN_HYPERLINK ); 463 } 464 465 if( rSet.GetItemState( SID_TRANSLITERATE_HALFWIDTH ) != SFX_ITEM_UNKNOWN ) 466 ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_HALFWIDTH ); 467 if( rSet.GetItemState( SID_TRANSLITERATE_FULLWIDTH ) != SFX_ITEM_UNKNOWN ) 468 ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_FULLWIDTH ); 469 if( rSet.GetItemState( SID_TRANSLITERATE_HIRAGANA ) != SFX_ITEM_UNKNOWN ) 470 ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_HIRAGANA ); 471 if( rSet.GetItemState( SID_TRANSLITERATE_KATAGANA ) != SFX_ITEM_UNKNOWN ) 472 ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_KATAGANA ); 473 474 if ( rSet.GetItemState( SID_ENABLE_HYPHENATION ) != SFX_ITEM_UNKNOWN ) 475 { 476 SdrView* pView = pViewData->GetScDrawView(); 477 SfxItemSet aAttrs( pView->GetModel()->GetItemPool() ); 478 pView->GetAttributes( aAttrs ); 479 if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SFX_ITEM_AVAILABLE ) 480 { 481 sal_Bool bValue = ( (const SfxBoolItem&) aAttrs.Get( EE_PARA_HYPHENATE ) ).GetValue(); 482 rSet.Put( SfxBoolItem( SID_ENABLE_HYPHENATION, bValue ) ); 483 } 484 } 485 486 if ( rSet.GetItemState( SID_THES ) != SFX_ITEM_UNKNOWN || 487 rSet.GetItemState( SID_THESAURUS ) != SFX_ITEM_UNKNOWN ) 488 { 489 SdrView * pView = pViewData->GetScDrawView(); 490 OutlinerView* pOutView = pView->GetTextEditOutlinerView(); 491 492 String aStatusVal; 493 LanguageType nLang = LANGUAGE_NONE; 494 bool bIsLookUpWord = false; 495 if ( pOutView ) 496 { 497 EditView& rEditView = pOutView->GetEditView(); 498 bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView ); 499 } 500 rSet.Put( SfxStringItem( SID_THES, aStatusVal ) ); 501 502 // disable thesaurus main menu and context menu entry if there is nothing to look up 503 sal_Bool bCanDoThesaurus = ScModule::HasThesaurusLanguage( nLang ); 504 if (!bIsLookUpWord || !bCanDoThesaurus) 505 rSet.DisableItem( SID_THES ); 506 if (!bCanDoThesaurus) 507 rSet.DisableItem( SID_THESAURUS ); 508 } 509 } 510 511 IMPL_LINK( ScDrawTextObjectBar, ClipboardChanged, TransferableDataHelper*, pDataHelper ) 512 { 513 if ( pDataHelper ) 514 { 515 bPastePossible = ( pDataHelper->HasFormat( SOT_FORMAT_STRING ) || pDataHelper->HasFormat( SOT_FORMAT_RTF ) ); 516 517 SfxBindings& rBindings = pViewData->GetBindings(); 518 rBindings.Invalidate( SID_PASTE ); 519 rBindings.Invalidate( SID_PASTE_SPECIAL ); 520 rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS ); 521 } 522 return 0; 523 } 524 525 void __EXPORT ScDrawTextObjectBar::GetClipState( SfxItemSet& rSet ) 526 { 527 SdrView* pView = pViewData->GetScDrawView(); 528 if ( !pView->GetTextEditOutlinerView() ) 529 { 530 GetGlobalClipState( rSet ); 531 return; 532 } 533 534 if ( !pClipEvtLstnr ) 535 { 536 // create listener 537 pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScDrawTextObjectBar, ClipboardChanged ) ); 538 pClipEvtLstnr->acquire(); 539 Window* pWin = pViewData->GetActiveWin(); 540 pClipEvtLstnr->AddRemoveListener( pWin, sal_True ); 541 542 // get initial state 543 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) ); 544 bPastePossible = ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) || aDataHelper.HasFormat( SOT_FORMAT_RTF ) ); 545 } 546 547 SfxWhichIter aIter( rSet ); 548 sal_uInt16 nWhich = aIter.FirstWhich(); 549 while (nWhich) 550 { 551 switch (nWhich) 552 { 553 case SID_PASTE: 554 case SID_PASTE_SPECIAL: 555 if( !bPastePossible ) 556 rSet.DisableItem( nWhich ); 557 break; 558 case SID_CLIPBOARD_FORMAT_ITEMS: 559 if ( bPastePossible ) 560 { 561 SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS ); 562 TransferableDataHelper aDataHelper( 563 TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) ); 564 565 if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) ) 566 aFormats.AddClipbrdFormat( SOT_FORMAT_STRING ); 567 if ( aDataHelper.HasFormat( SOT_FORMAT_RTF ) ) 568 aFormats.AddClipbrdFormat( SOT_FORMAT_RTF ); 569 570 rSet.Put( aFormats ); 571 } 572 else 573 rSet.DisableItem( nWhich ); 574 break; 575 } 576 nWhich = aIter.NextWhich(); 577 } 578 } 579 580 //======================================================================== 581 // 582 // Attribute 583 // 584 //======================================================================== 585 586 void __EXPORT ScDrawTextObjectBar::ExecuteToggle( SfxRequest &rReq ) 587 { 588 // Unterstreichung 589 590 SdrView* pView = pViewData->GetScDrawView(); 591 592 sal_uInt16 nSlot = rReq.GetSlot(); 593 594 SfxItemSet aSet( pView->GetDefaultAttr() ); 595 596 SfxItemSet aViewAttr(pView->GetModel()->GetItemPool()); 597 pView->GetAttributes(aViewAttr); 598 599 // Unterstreichung 600 FontUnderline eOld = ((const SvxUnderlineItem&) aViewAttr. 601 Get(EE_CHAR_UNDERLINE)).GetLineStyle(); 602 FontUnderline eNew = eOld; 603 switch (nSlot) 604 { 605 case SID_ULINE_VAL_NONE: 606 eNew = UNDERLINE_NONE; 607 break; 608 case SID_ULINE_VAL_SINGLE: 609 eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE; 610 break; 611 case SID_ULINE_VAL_DOUBLE: 612 eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE; 613 break; 614 case SID_ULINE_VAL_DOTTED: 615 eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED; 616 break; 617 default: 618 break; 619 } 620 aSet.Put( SvxUnderlineItem( eNew, EE_CHAR_UNDERLINE ) ); 621 622 pView->SetAttributes( aSet ); 623 rReq.Done(); 624 pViewData->GetScDrawView()->InvalidateDrawTextAttrs(); 625 } 626 627 void lcl_RemoveFields( OutlinerView& rOutView ) 628 { 629 //! Outliner should have RemoveFields with a selection 630 631 Outliner* pOutliner = rOutView.GetOutliner(); 632 if (!pOutliner) return; 633 634 ESelection aOldSel = rOutView.GetSelection(); 635 ESelection aSel = aOldSel; 636 aSel.Adjust(); 637 xub_StrLen nNewEnd = aSel.nEndPos; 638 639 sal_Bool bUpdate = pOutliner->GetUpdateMode(); 640 sal_Bool bChanged = sal_False; 641 642 //! GetPortions and GetAttribs should be const! 643 EditEngine& rEditEng = (EditEngine&)pOutliner->GetEditEngine(); 644 645 sal_uLong nParCount = pOutliner->GetParagraphCount(); 646 for (sal_uLong nPar=0; nPar<nParCount; nPar++) 647 if ( nPar >= aSel.nStartPara && nPar <= aSel.nEndPara ) 648 { 649 SvUShorts aPortions; 650 rEditEng.GetPortions( (sal_uInt16)nPar, aPortions ); 651 //! GetPortions should use xub_StrLen instead of sal_uInt16 652 653 for ( sal_uInt16 nPos = aPortions.Count(); nPos; ) 654 { 655 --nPos; 656 sal_uInt16 nEnd = aPortions.GetObject( nPos ); 657 sal_uInt16 nStart = nPos ? aPortions.GetObject( nPos - 1 ) : 0; 658 // fields are single characters 659 if ( nEnd == nStart+1 && 660 ( nPar > aSel.nStartPara || nStart >= aSel.nStartPos ) && 661 ( nPar < aSel.nEndPara || nEnd <= aSel.nEndPos ) ) 662 { 663 ESelection aFieldSel( (sal_uInt16)nPar, nStart, (sal_uInt16)nPar, nEnd ); 664 SfxItemSet aSet = rEditEng.GetAttribs( aFieldSel ); 665 if ( aSet.GetItemState( EE_FEATURE_FIELD ) == SFX_ITEM_ON ) 666 { 667 if (!bChanged) 668 { 669 if (bUpdate) 670 pOutliner->SetUpdateMode( sal_False ); 671 String aName = ScGlobal::GetRscString( STR_UNDO_DELETECONTENTS ); 672 pOutliner->GetUndoManager().EnterListAction( aName, aName ); 673 bChanged = sal_True; 674 } 675 676 String aFieldText = rEditEng.GetText( aFieldSel ); 677 pOutliner->QuickInsertText( aFieldText, aFieldSel ); 678 if ( nPar == aSel.nEndPara ) 679 { 680 nNewEnd = sal::static_int_cast<xub_StrLen>( nNewEnd + aFieldText.Len() ); 681 --nNewEnd; 682 } 683 } 684 } 685 } 686 } 687 688 if (bUpdate && bChanged) 689 { 690 pOutliner->GetUndoManager().LeaveListAction(); 691 pOutliner->SetUpdateMode( sal_True ); 692 } 693 694 if ( aOldSel.IsEqual( aSel ) ) // aSel is adjusted 695 aOldSel.nEndPos = nNewEnd; 696 else 697 aOldSel.nStartPos = nNewEnd; // if aOldSel is backwards 698 rOutView.SetSelection( aOldSel ); 699 } 700 701 void __EXPORT ScDrawTextObjectBar::ExecuteAttr( SfxRequest &rReq ) 702 { 703 SdrView* pView = pViewData->GetScDrawView(); 704 const SfxItemSet* pArgs = rReq.GetArgs(); 705 sal_uInt16 nSlot = rReq.GetSlot(); 706 707 sal_Bool bArgsInReq = ( pArgs != NULL ); 708 if ( !bArgsInReq ) 709 { 710 SfxItemSet aEditAttr(pView->GetModel()->GetItemPool()); 711 pView->GetAttributes(aEditAttr); 712 SfxItemSet aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() ); 713 sal_Bool bDone = sal_True; 714 715 switch ( nSlot ) 716 { 717 case SID_TEXT_STANDARD: // Harte Textattributierung loeschen 718 { 719 OutlinerView* pOutView = pView->IsTextEdit() ? 720 pView->GetTextEditOutlinerView() : NULL; 721 if ( pOutView ) 722 pOutView->Paint( Rectangle() ); 723 724 SfxItemSet aEmptyAttr( *aEditAttr.GetPool(), EE_ITEMS_START, EE_ITEMS_END ); 725 pView->SetAttributes( aEmptyAttr, sal_True ); 726 727 if ( pOutView ) 728 { 729 lcl_RemoveFields( *pOutView ); 730 pOutView->ShowCursor(); 731 } 732 733 rReq.Done( aEmptyAttr ); 734 pViewData->GetScDrawView()->InvalidateDrawTextAttrs(); 735 bDone = sal_False; // bereits hier passiert 736 } 737 break; 738 739 case SID_CHAR_DLG_EFFECT: 740 case SID_CHAR_DLG: // Dialog-Button 741 case SID_ATTR_CHAR_FONT: // Controller nicht angezeigt 742 case SID_ATTR_CHAR_FONTHEIGHT: 743 bDone = ExecuteCharDlg( aEditAttr, aNewAttr , nSlot); 744 break; 745 746 case SID_PARA_DLG: 747 bDone = ExecuteParaDlg( aEditAttr, aNewAttr ); 748 break; 749 750 case SID_ATTR_CHAR_WEIGHT: 751 aNewAttr.Put( (const SvxWeightItem&)aEditAttr.Get( EE_CHAR_WEIGHT ) ); 752 break; 753 754 case SID_ATTR_CHAR_POSTURE: 755 aNewAttr.Put( (const SvxPostureItem&)aEditAttr.Get( EE_CHAR_ITALIC ) ); 756 break; 757 758 case SID_ATTR_CHAR_UNDERLINE: 759 aNewAttr.Put( (const SvxUnderlineItem&)aEditAttr.Get( EE_CHAR_UNDERLINE ) ); 760 break; 761 762 case SID_ATTR_CHAR_OVERLINE: 763 aNewAttr.Put( (const SvxOverlineItem&)aEditAttr.Get( EE_CHAR_OVERLINE ) ); 764 break; 765 766 case SID_ATTR_CHAR_CONTOUR: 767 aNewAttr.Put( (const SvxContourItem&)aEditAttr.Get( EE_CHAR_OUTLINE ) ); 768 break; 769 770 case SID_ATTR_CHAR_SHADOWED: 771 aNewAttr.Put( (const SvxShadowedItem&)aEditAttr.Get( EE_CHAR_SHADOW ) ); 772 break; 773 774 case SID_ATTR_CHAR_STRIKEOUT: 775 aNewAttr.Put( (const SvxCrossedOutItem&)aEditAttr.Get( EE_CHAR_STRIKEOUT ) ); 776 break; 777 778 case SID_ALIGNLEFT: 779 case SID_ALIGN_ANY_LEFT: 780 aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) ); 781 break; 782 783 case SID_ALIGNCENTERHOR: 784 case SID_ALIGN_ANY_HCENTER: 785 aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) ); 786 break; 787 788 case SID_ALIGNRIGHT: 789 case SID_ALIGN_ANY_RIGHT: 790 aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) ); 791 break; 792 793 case SID_ALIGNBLOCK: 794 case SID_ALIGN_ANY_JUSTIFIED: 795 aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_BLOCK, EE_PARA_JUST ) ); 796 break; 797 798 case SID_ATTR_PARA_LINESPACE_10: 799 { 800 SvxLineSpacingItem aItem( SVX_LINESPACE_ONE_LINE, EE_PARA_SBL ); 801 aItem.SetPropLineSpace( 100 ); 802 aNewAttr.Put( aItem ); 803 } 804 break; 805 806 case SID_ATTR_PARA_LINESPACE_15: 807 { 808 SvxLineSpacingItem aItem( SVX_LINESPACE_ONE_POINT_FIVE_LINES, EE_PARA_SBL ); 809 aItem.SetPropLineSpace( 150 ); 810 aNewAttr.Put( aItem ); 811 } 812 break; 813 814 case SID_ATTR_PARA_LINESPACE_20: 815 { 816 SvxLineSpacingItem aItem( SVX_LINESPACE_TWO_LINES, EE_PARA_SBL ); 817 aItem.SetPropLineSpace( 200 ); 818 aNewAttr.Put( aItem ); 819 } 820 break; 821 822 case SID_SET_SUPER_SCRIPT: 823 { 824 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); 825 SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&) 826 aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue(); 827 828 if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT ) 829 aItem.SetEscapement( SVX_ESCAPEMENT_OFF ); 830 else 831 aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT ); 832 aNewAttr.Put( aItem ); 833 } 834 break; 835 case SID_SET_SUB_SCRIPT: 836 { 837 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); 838 SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&) 839 aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue(); 840 841 if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT ) 842 aItem.SetEscapement( SVX_ESCAPEMENT_OFF ); 843 else 844 aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT ); 845 aNewAttr.Put( aItem ); 846 } 847 break; 848 849 case SID_DRAWTEXT_ATTR_DLG: 850 { 851 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 852 SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( pViewData->GetDialogParent(), &aEditAttr, pView ); 853 854 bDone = ( RET_OK == pDlg->Execute() ); 855 856 if ( bDone ) 857 aNewAttr.Put( *pDlg->GetOutputItemSet() ); 858 859 delete pDlg; 860 861 SfxBindings& rBindings = pViewData->GetBindings(); 862 rBindings.Invalidate( SID_TABLE_VERT_NONE ); 863 rBindings.Invalidate( SID_TABLE_VERT_CENTER ); 864 rBindings.Invalidate( SID_TABLE_VERT_BOTTOM ); 865 } 866 break; 867 } 868 869 if ( bDone ) // wurden Attribute geaendert? 870 { 871 rReq.Done( aNewAttr ); 872 pArgs = rReq.GetArgs(); 873 } 874 } 875 876 if ( pArgs ) 877 { 878 if ( bArgsInReq && 879 ( nSlot == SID_ATTR_CHAR_FONT || nSlot == SID_ATTR_CHAR_FONTHEIGHT || 880 nSlot == SID_ATTR_CHAR_WEIGHT || nSlot == SID_ATTR_CHAR_POSTURE ) ) 881 { 882 // font items from toolbox controller have to be applied for the right script type 883 884 // #i78017 establish the same behaviour as in Writer 885 sal_uInt16 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX; 886 if (nSlot == SID_ATTR_CHAR_FONT) 887 nScript = pView->GetScriptType(); 888 889 SfxItemPool& rPool = GetPool(); 890 SvxScriptSetItem aSetItem( nSlot, rPool ); 891 sal_uInt16 nWhich = rPool.GetWhich( nSlot ); 892 aSetItem.PutItemForScriptType( nScript, pArgs->Get( nWhich ) ); 893 894 pView->SetAttributes( aSetItem.GetItemSet() ); 895 } 896 else if( nSlot == SID_ATTR_PARA_LRSPACE ) 897 { 898 sal_uInt16 nId = SID_ATTR_PARA_LRSPACE; 899 const SvxLRSpaceItem& rItem = (const SvxLRSpaceItem&) 900 pArgs->Get( nId ); 901 SfxItemSet aEditAttr( GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE ); 902 nId = EE_PARA_LRSPACE; 903 SvxLRSpaceItem aLRSpaceItem( rItem.GetLeft(), 904 rItem.GetRight(), rItem.GetTxtLeft(), 905 rItem.GetTxtFirstLineOfst(), nId ); 906 aEditAttr.Put( aLRSpaceItem ); 907 // rReq.Done( aEditAttr ); 908 // pArgs = rReq.GetArgs(); 909 // pView->SetAttributes( *pArgs ); 910 pView->SetAttributes( aEditAttr ); 911 // Invalidate(SID_ATTR_PARA_LRSPACE); 912 } 913 else if( nSlot == SID_ATTR_PARA_LINESPACE ) 914 { 915 SvxLineSpacingItem aLineSpaceItem = (const SvxLineSpacingItem&)pArgs->Get( 916 GetPool().GetWhich(nSlot)); 917 SfxItemSet aEditAttr( GetPool(), EE_PARA_SBL, EE_PARA_SBL ); 918 aEditAttr.Put( aLineSpaceItem ); 919 // rReq.Done( aEditAttr ); 920 // pArgs = rReq.GetArgs(); 921 // pView->SetAttributes( *pArgs ); 922 pView->SetAttributes( aEditAttr ); 923 // Invalidate(SID_ATTR_PARA_LINESPACE); 924 } 925 else if( nSlot == SID_ATTR_PARA_ULSPACE ) 926 { 927 SvxULSpaceItem aULSpaceItem = (const SvxULSpaceItem&)pArgs->Get( 928 GetPool().GetWhich(nSlot)); 929 SfxItemSet aEditAttr( GetPool(), EE_PARA_ULSPACE, EE_PARA_ULSPACE ); 930 aULSpaceItem.SetWhich(EE_PARA_ULSPACE); 931 aEditAttr.Put( aULSpaceItem ); 932 // rReq.Done( aEditAttr ); 933 // pArgs = rReq.GetArgs(); 934 // pView->SetAttributes( *pArgs ); 935 pView->SetAttributes( aEditAttr ); 936 // Invalidate(SID_ATTR_PARA_ULSPACE); 937 } 938 else if(nSlot == SID_SET_SUPER_SCRIPT ) 939 { 940 SfxItemSet aEditAttr(pView->GetModel()->GetItemPool()); 941 pView->GetAttributes(aEditAttr); 942 SfxItemSet aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() ); 943 944 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); 945 SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&) 946 aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue(); 947 948 if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT ) 949 aItem.SetEscapement( SVX_ESCAPEMENT_OFF ); 950 else 951 aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT ); 952 aNewAttr.Put( aItem ); 953 pView->SetAttributes( aNewAttr ); 954 } 955 else if( nSlot == SID_SET_SUB_SCRIPT ) 956 { 957 SfxItemSet aEditAttr(pView->GetModel()->GetItemPool()); 958 pView->GetAttributes(aEditAttr); 959 SfxItemSet aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() ); 960 961 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); 962 SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&) 963 aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue(); 964 965 if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT ) 966 aItem.SetEscapement( SVX_ESCAPEMENT_OFF ); 967 else 968 aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT ); 969 aNewAttr.Put( aItem ); 970 pView->SetAttributes( aNewAttr ); 971 } 972 973 else if (bArgsInReq && 974 ( nSlot == SID_TABLE_VERT_NONE || nSlot == SID_TABLE_VERT_CENTER || 975 nSlot == SID_TABLE_VERT_BOTTOM ) ) 976 { 977 SdrTextVertAdjust eTVA = SDRTEXTVERTADJUST_TOP; 978 if (nSlot == SID_TABLE_VERT_CENTER) 979 eTVA = SDRTEXTVERTADJUST_CENTER; 980 else if (nSlot == SID_TABLE_VERT_BOTTOM) 981 eTVA = SDRTEXTVERTADJUST_BOTTOM; 982 983 SfxItemSet aEditAttr(pView->GetModel()->GetItemPool()); 984 SfxItemSet aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() ); 985 aNewAttr.Put(SdrTextVertAdjustItem(eTVA)); 986 pView->SetAttributes(aNewAttr); 987 } 988 else if (bArgsInReq && 989 (nSlot == SID_ATTR_PARA_ADJUST_LEFT || nSlot == SID_ATTR_PARA_ADJUST_CENTER || nSlot == SID_ATTR_PARA_ADJUST_RIGHT || nSlot == SID_ATTR_PARA_ADJUST_BLOCK )) 990 { 991 SfxItemSet aEditAttr(pView->GetModel()->GetItemPool()); 992 SfxItemSet aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() ); 993 switch ( nSlot ) 994 { 995 case SID_ATTR_PARA_ADJUST_LEFT: 996 aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) ); 997 break; 998 case SID_ATTR_PARA_ADJUST_CENTER: 999 aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) ); 1000 break; 1001 case SID_ATTR_PARA_ADJUST_RIGHT: 1002 aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) ); 1003 break; 1004 case SID_ATTR_PARA_ADJUST_BLOCK: 1005 aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_BLOCK, EE_PARA_JUST ) ); 1006 break; 1007 } 1008 pView->SetAttributes(aNewAttr); 1009 } 1010 else 1011 { 1012 // use args directly 1013 1014 pView->SetAttributes( *pArgs ); 1015 } 1016 pViewData->GetScDrawView()->InvalidateDrawTextAttrs(); 1017 } 1018 } 1019 1020 void __EXPORT ScDrawTextObjectBar::GetAttrState( SfxItemSet& rDestSet ) 1021 { 1022 if ( IsNoteEdit() ) 1023 { 1024 // issue 21255 - Notes now support rich text formatting. 1025 } 1026 1027 SvtLanguageOptions aLangOpt; 1028 sal_Bool bDisableCTLFont = !aLangOpt.IsCTLFontEnabled(); 1029 sal_Bool bDisableVerticalText = !aLangOpt.IsVerticalTextEnabled(); 1030 1031 SdrView* pView = pViewData->GetScDrawView(); 1032 SfxItemSet aAttrSet(pView->GetModel()->GetItemPool()); 1033 pView->GetAttributes(aAttrSet); 1034 1035 // direkte Attribute 1036 1037 rDestSet.Put( aAttrSet ); 1038 1039 // choose font info according to selection script type 1040 1041 sal_uInt16 nScript = pView->GetScriptType(); 1042 1043 // #i55929# input-language-dependent script type (depends on input language if nothing selected) 1044 sal_uInt16 nInputScript = nScript; 1045 OutlinerView* pOutView = pView->GetTextEditOutlinerView(); 1046 if (pOutView && !pOutView->GetSelection().HasRange()) 1047 { 1048 LanguageType nInputLang = pViewData->GetActiveWin()->GetInputLanguage(); 1049 if (nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM) 1050 nInputScript = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang ); 1051 } 1052 1053 // #i55929# according to spec, nInputScript is used for font and font height only 1054 if ( rDestSet.GetItemState( EE_CHAR_FONTINFO ) != SFX_ITEM_UNKNOWN ) 1055 ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_FONTINFO, nInputScript ); 1056 if ( rDestSet.GetItemState( EE_CHAR_FONTHEIGHT ) != SFX_ITEM_UNKNOWN ) 1057 ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_FONTHEIGHT, nInputScript ); 1058 if ( rDestSet.GetItemState( EE_CHAR_WEIGHT ) != SFX_ITEM_UNKNOWN ) 1059 ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_WEIGHT, nScript ); 1060 if ( rDestSet.GetItemState( EE_CHAR_ITALIC ) != SFX_ITEM_UNKNOWN ) 1061 ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_ITALIC, nScript ); 1062 // Ausrichtung 1063 1064 SvxAdjust eAdj = ((const SvxAdjustItem&)aAttrSet.Get(EE_PARA_JUST)).GetAdjust(); 1065 switch( eAdj ) 1066 { 1067 case SVX_ADJUST_LEFT: 1068 { 1069 rDestSet.Put( SfxBoolItem( SID_ALIGNLEFT, sal_True ) ); 1070 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, sal_True ) ); 1071 } 1072 break; 1073 case SVX_ADJUST_CENTER: 1074 { 1075 rDestSet.Put( SfxBoolItem( SID_ALIGNCENTERHOR, sal_True ) ); 1076 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, sal_True ) ); 1077 } 1078 break; 1079 case SVX_ADJUST_RIGHT: 1080 { 1081 rDestSet.Put( SfxBoolItem( SID_ALIGNRIGHT, sal_True ) ); 1082 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, sal_True ) ); 1083 } 1084 break; 1085 case SVX_ADJUST_BLOCK: 1086 { 1087 rDestSet.Put( SfxBoolItem( SID_ALIGNBLOCK, sal_True ) ); 1088 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, sal_True ) ); 1089 } 1090 break; 1091 default: 1092 { 1093 // added to avoid warnings 1094 } 1095 } 1096 // pseudo slots for Format menu 1097 rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_LEFT, eAdj == SVX_ADJUST_LEFT ) ); 1098 rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_HCENTER, eAdj == SVX_ADJUST_CENTER ) ); 1099 rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_RIGHT, eAdj == SVX_ADJUST_RIGHT ) ); 1100 rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_JUSTIFIED, eAdj == SVX_ADJUST_BLOCK ) ); 1101 1102 SvxLRSpaceItem aLR = ((const SvxLRSpaceItem&)aAttrSet.Get( EE_PARA_LRSPACE )); 1103 aLR.SetWhich(SID_ATTR_PARA_LRSPACE); 1104 rDestSet.Put(aLR); 1105 Invalidate( SID_ATTR_PARA_LRSPACE ); 1106 SfxItemState eState = aAttrSet.GetItemState( EE_PARA_LRSPACE ); 1107 if ( eState == SFX_ITEM_DONTCARE ) 1108 rDestSet.InvalidateItem(SID_ATTR_PARA_LRSPACE); 1109 //xuxu for Line Space 1110 SvxLineSpacingItem aLineSP = ((const SvxLineSpacingItem&)aAttrSet. 1111 Get( EE_PARA_SBL )); 1112 aLineSP.SetWhich(SID_ATTR_PARA_LINESPACE); 1113 rDestSet.Put(aLineSP); 1114 Invalidate(SID_ATTR_PARA_LINESPACE); 1115 eState = aAttrSet.GetItemState( EE_PARA_SBL ); 1116 if ( eState == SFX_ITEM_DONTCARE ) 1117 rDestSet.InvalidateItem(SID_ATTR_PARA_LINESPACE); 1118 //xuxu for UL Space 1119 SvxULSpaceItem aULSP = ((const SvxULSpaceItem&)aAttrSet. 1120 Get( EE_PARA_ULSPACE )); 1121 aULSP.SetWhich(SID_ATTR_PARA_ULSPACE); 1122 rDestSet.Put(aULSP); 1123 Invalidate(SID_ATTR_PARA_ULSPACE); 1124 eState = aAttrSet.GetItemState( EE_PARA_ULSPACE ); 1125 if ( eState == SFX_ITEM_DONTCARE ) 1126 rDestSet.InvalidateItem(SID_ATTR_PARA_ULSPACE); 1127 1128 // Zeilenabstand 1129 1130 sal_uInt16 nLineSpace = (sal_uInt16) 1131 ((const SvxLineSpacingItem&)aAttrSet. 1132 Get( EE_PARA_SBL )).GetPropLineSpace(); 1133 switch( nLineSpace ) 1134 { 1135 case 100: 1136 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_10, sal_True ) ); 1137 break; 1138 case 150: 1139 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_15, sal_True ) ); 1140 break; 1141 case 200: 1142 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_20, sal_True ) ); 1143 break; 1144 } 1145 1146 // hoch-/tiefgestellt 1147 1148 SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&) 1149 aAttrSet.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue(); 1150 if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT ) 1151 rDestSet.Put( SfxBoolItem( SID_SET_SUPER_SCRIPT, sal_True ) ); 1152 else if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT ) 1153 rDestSet.Put( SfxBoolItem( SID_SET_SUB_SCRIPT, sal_True ) ); 1154 1155 // Unterstreichung 1156 1157 eState = aAttrSet.GetItemState( EE_CHAR_UNDERLINE, sal_True ); 1158 if ( eState == SFX_ITEM_DONTCARE ) 1159 { 1160 rDestSet.InvalidateItem( SID_ULINE_VAL_NONE ); 1161 rDestSet.InvalidateItem( SID_ULINE_VAL_SINGLE ); 1162 rDestSet.InvalidateItem( SID_ULINE_VAL_DOUBLE ); 1163 rDestSet.InvalidateItem( SID_ULINE_VAL_DOTTED ); 1164 } 1165 else 1166 { 1167 FontUnderline eUnderline = ((const SvxUnderlineItem&) 1168 aAttrSet.Get(EE_CHAR_UNDERLINE)).GetLineStyle(); 1169 sal_uInt16 nId = SID_ULINE_VAL_NONE; 1170 switch (eUnderline) 1171 { 1172 case UNDERLINE_SINGLE: nId = SID_ULINE_VAL_SINGLE; break; 1173 case UNDERLINE_DOUBLE: nId = SID_ULINE_VAL_DOUBLE; break; 1174 case UNDERLINE_DOTTED: nId = SID_ULINE_VAL_DOTTED; break; 1175 default: 1176 break; 1177 } 1178 rDestSet.Put( SfxBoolItem( nId, sal_True ) ); 1179 } 1180 1181 // horizontal / vertical 1182 1183 sal_Bool bLeftToRight = sal_True; 1184 1185 SdrOutliner* pOutl = pView->GetTextEditOutliner(); 1186 if( pOutl ) 1187 { 1188 if( pOutl->IsVertical() ) 1189 bLeftToRight = sal_False; 1190 } 1191 else 1192 bLeftToRight = ( (const SvxWritingModeItem&) aAttrSet.Get( SDRATTR_TEXTDIRECTION ) ).GetValue() == com::sun::star::text::WritingMode_LR_TB; 1193 1194 if ( bDisableVerticalText ) 1195 { 1196 rDestSet.DisableItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT ); 1197 rDestSet.DisableItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM ); 1198 } 1199 else 1200 { 1201 rDestSet.Put( SfxBoolItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT, bLeftToRight ) ); 1202 rDestSet.Put( SfxBoolItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM, !bLeftToRight ) ); 1203 } 1204 1205 // left-to-right or right-to-left 1206 1207 if ( !bLeftToRight || bDisableCTLFont ) 1208 { 1209 // disabled if vertical 1210 rDestSet.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT ); 1211 rDestSet.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT ); 1212 } 1213 else if ( aAttrSet.GetItemState( EE_PARA_WRITINGDIR ) == SFX_ITEM_DONTCARE ) 1214 { 1215 rDestSet.InvalidateItem( SID_ATTR_PARA_LEFT_TO_RIGHT ); 1216 rDestSet.InvalidateItem( SID_ATTR_PARA_RIGHT_TO_LEFT ); 1217 } 1218 else 1219 { 1220 SvxFrameDirection eAttrDir = (SvxFrameDirection)((const SvxFrameDirectionItem&) 1221 aAttrSet.Get( EE_PARA_WRITINGDIR )).GetValue(); 1222 if ( eAttrDir == FRMDIR_ENVIRONMENT ) 1223 { 1224 // get "environment" direction from page style 1225 if ( pViewData->GetDocument()->GetEditTextDirection( pViewData->GetTabNo() ) == EE_HTEXTDIR_R2L ) 1226 eAttrDir = FRMDIR_HORI_RIGHT_TOP; 1227 else 1228 eAttrDir = FRMDIR_HORI_LEFT_TOP; 1229 } 1230 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT, ( eAttrDir == FRMDIR_HORI_LEFT_TOP ) ) ); 1231 rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT, ( eAttrDir == FRMDIR_HORI_RIGHT_TOP ) ) ); 1232 } 1233 } 1234 1235 void ScDrawTextObjectBar::ExecuteTrans( SfxRequest& rReq ) 1236 { 1237 sal_Int32 nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() ); 1238 if ( nType ) 1239 { 1240 ScDrawView* pView = pViewData->GetScDrawView(); 1241 OutlinerView* pOutView = pView->GetTextEditOutlinerView(); 1242 if ( pOutView ) 1243 { 1244 // change selected text in object 1245 pOutView->TransliterateText( nType ); 1246 } 1247 else 1248 { 1249 //! apply to whole objects? 1250 } 1251 } 1252 } 1253 1254 void ScDrawTextObjectBar::GetStatePropPanelAttr(SfxItemSet &rSet) 1255 { 1256 SfxWhichIter aIter( rSet ); 1257 sal_uInt16 nWhich = aIter.FirstWhich(); 1258 1259 SdrView* pView = pViewData->GetScDrawView(); 1260 1261 SfxItemSet aEditAttr(pView->GetModel()->GetItemPool()); 1262 pView->GetAttributes(aEditAttr); 1263 //SfxItemSet aAttrs( *aEditAttr.GetPool(), aEditAttr.GetRanges() ); 1264 1265 while ( nWhich ) 1266 { 1267 sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich) 1268 ? GetPool().GetSlotId(nWhich) 1269 : nWhich; 1270 switch ( nSlotId ) 1271 { 1272 case SID_TABLE_VERT_NONE: 1273 case SID_TABLE_VERT_CENTER: 1274 case SID_TABLE_VERT_BOTTOM: 1275 sal_Bool bContour = sal_False; 1276 SfxItemState eConState = aEditAttr.GetItemState( SDRATTR_TEXT_CONTOURFRAME ); 1277 if( eConState != SFX_ITEM_DONTCARE ) 1278 { 1279 bContour = ( ( const SdrTextContourFrameItem& )aEditAttr.Get( SDRATTR_TEXT_CONTOURFRAME ) ).GetValue(); 1280 } 1281 if (bContour) break; 1282 1283 SfxItemState eVState = aEditAttr.GetItemState( SDRATTR_TEXT_VERTADJUST ); 1284 //SfxItemState eHState = aAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ); 1285 1286 //if(SFX_ITEM_DONTCARE != eVState && SFX_ITEM_DONTCARE != eHState) 1287 if(SFX_ITEM_DONTCARE != eVState) 1288 { 1289 SdrTextVertAdjust eTVA = (SdrTextVertAdjust)((const SdrTextVertAdjustItem&)aEditAttr.Get(SDRATTR_TEXT_VERTADJUST)).GetValue(); 1290 sal_Bool bSet = nSlotId == SID_TABLE_VERT_NONE && eTVA == SDRTEXTVERTADJUST_TOP|| 1291 nSlotId == SID_TABLE_VERT_CENTER && eTVA == SDRTEXTVERTADJUST_CENTER || 1292 nSlotId == SID_TABLE_VERT_BOTTOM && eTVA == SDRTEXTVERTADJUST_BOTTOM; 1293 rSet.Put(SfxBoolItem(nSlotId, bSet)); 1294 } 1295 else 1296 { 1297 rSet.Put(SfxBoolItem(nSlotId, sal_False)); 1298 } 1299 break; 1300 } 1301 nWhich = aIter.NextWhich(); 1302 } 1303 } 1304 1305