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 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> 29 #include <com/sun/star/beans/XPropertySet.hpp> 30 #include <com/sun/star/container/XNameAccess.hpp> 31 32 //------------------------------------------------------------------ 33 34 //svdraw.hxx 35 #define _SDR_NOITEMS 36 #define _SDR_NOTOUCH 37 #define _SDR_NOTRANSFORM 38 #define _SI_NOSBXCONTROLS 39 #define _VCONT_HXX 40 #define _SI_NOOTHERFORMS 41 #define _VCTRLS_HXX 42 #define _SI_NOCONTROL 43 #define _SETBRW_HXX 44 #define _VCBRW_HXX 45 #define _SI_NOSBXCONTROLS 46 47 //------------------------------------------------------------------ 48 49 #include "scitems.hxx" 50 #include <editeng/eeitem.hxx> 51 52 #include <sfx2/app.hxx> 53 #include <sfx2/viewfrm.hxx> 54 #include <sfx2/objface.hxx> 55 #include <sfx2/request.hxx> 56 #include <svl/whiter.hxx> 57 #include <vcl/msgbox.hxx> 58 59 #define _ZFORLIST_DECLARE_TABLE 60 #include <svl/stritem.hxx> 61 #include <svl/zformat.hxx> 62 #include <svl/languageoptions.hxx> 63 #include <editeng/boxitem.hxx> 64 #include <editeng/langitem.hxx> 65 #include <svx/numinf.hxx> 66 #include <sfx2/dispatch.hxx> 67 #include <sfx2/templdlg.hxx> 68 #include <sfx2/tplpitem.hxx> 69 #include <editeng/svxenum.hxx> 70 #include <svx/algitem.hxx> 71 #include <editeng/wghtitem.hxx> 72 #include <editeng/postitem.hxx> 73 #include <editeng/udlnitem.hxx> 74 #include <editeng/bolnitem.hxx> 75 #include <editeng/colritem.hxx> 76 #include <editeng/brshitem.hxx> 77 #include <editeng/frmdiritem.hxx> 78 #include <editeng/scripttypeitem.hxx> 79 #include <svtools/colorcfg.hxx> 80 #include <editeng/shaditem.hxx> 81 82 #include "formatsh.hxx" 83 #include "sc.hrc" 84 #include "globstr.hrc" 85 #include "docsh.hxx" 86 #include "patattr.hxx" 87 #include "scmod.hxx" 88 //CHINA001 #include "styledlg.hxx" 89 #include "attrdlg.hrc" 90 #include "stlpool.hxx" 91 #include "stlsheet.hxx" 92 #include "printfun.hxx" 93 #include "docpool.hxx" 94 #include "scresid.hxx" 95 #include "tabvwsh.hxx" 96 #include "undostyl.hxx" 97 98 99 #define ScFormatShell 100 #define TableFont 101 #define FormatForSelection 102 #include "scslots.hxx" 103 104 #include "scabstdlg.hxx" //CHINA001 105 106 namespace { 107 108 SvxCellHorJustify lclConvertSlotToHAlign( sal_uInt16 nSlot ) 109 { 110 SvxCellHorJustify eHJustify = SVX_HOR_JUSTIFY_STANDARD; 111 switch( nSlot ) 112 { 113 case SID_ALIGN_ANY_HDEFAULT: eHJustify = SVX_HOR_JUSTIFY_STANDARD; break; 114 case SID_ALIGN_ANY_LEFT: eHJustify = SVX_HOR_JUSTIFY_LEFT; break; 115 case SID_ALIGN_ANY_HCENTER: eHJustify = SVX_HOR_JUSTIFY_CENTER; break; 116 case SID_ALIGN_ANY_RIGHT: eHJustify = SVX_HOR_JUSTIFY_RIGHT; break; 117 case SID_ALIGN_ANY_JUSTIFIED: eHJustify = SVX_HOR_JUSTIFY_BLOCK; break; 118 default: DBG_ERRORFILE( "lclConvertSlotToHAlign - invalid slot" ); 119 } 120 return eHJustify; 121 } 122 123 SvxCellVerJustify lclConvertSlotToVAlign( sal_uInt16 nSlot ) 124 { 125 SvxCellVerJustify eVJustify = SVX_VER_JUSTIFY_STANDARD; 126 switch( nSlot ) 127 { 128 case SID_ALIGN_ANY_VDEFAULT: eVJustify = SVX_VER_JUSTIFY_STANDARD; break; 129 case SID_ALIGN_ANY_TOP: eVJustify = SVX_VER_JUSTIFY_TOP; break; 130 case SID_ALIGN_ANY_VCENTER: eVJustify = SVX_VER_JUSTIFY_CENTER; break; 131 case SID_ALIGN_ANY_BOTTOM: eVJustify = SVX_VER_JUSTIFY_BOTTOM; break; 132 default: DBG_ERRORFILE( "lclConvertSlotToVAlign - invalid slot" ); 133 } 134 return eVJustify; 135 } 136 137 } // namespace 138 139 TYPEINIT1( ScFormatShell, SfxShell ); 140 141 SFX_IMPL_INTERFACE(ScFormatShell, SfxShell, ScResId(SCSTR_FORMATSHELL) ) 142 { 143 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD | 144 SFX_VISIBILITY_SERVER, 145 ScResId(RID_OBJECTBAR_FORMAT)); 146 147 } 148 149 150 ScFormatShell::ScFormatShell(ScViewData* pData) : 151 SfxShell(pData->GetViewShell()), 152 pViewData(pData) 153 { 154 ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 155 156 SetPool( &pTabViewShell->GetPool() ); 157 ::svl::IUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager(); 158 SetUndoManager( pMgr ); 159 if ( !pViewData->GetDocument()->IsUndoEnabled() ) 160 { 161 pMgr->SetMaxUndoActionCount( 0 ); 162 } 163 SetHelpId(HID_SCSHELL_FORMATSH); 164 SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Format"))); 165 } 166 167 ScFormatShell::~ScFormatShell() 168 { 169 } 170 171 //------------------------------------------------------------------ 172 173 void __EXPORT ScFormatShell::GetStyleState( SfxItemSet& rSet ) 174 { 175 ScDocument* pDoc = GetViewData()->GetDocument(); 176 ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 177 SfxStyleSheetBasePool* pStylePool = pDoc->GetStyleSheetPool(); 178 179 sal_Bool bProtected = sal_False; 180 SCTAB nTabCount = pDoc->GetTableCount(); 181 for (SCTAB i=0; i<nTabCount; i++) 182 if (pDoc->IsTabProtected(i)) // ueberhaupt eine Tabelle geschuetzt? 183 bProtected = sal_True; 184 185 SfxWhichIter aIter(rSet); 186 sal_uInt16 nWhich = aIter.FirstWhich(); 187 sal_uInt16 nSlotId = 0; 188 189 while ( nWhich ) 190 { 191 nSlotId = SfxItemPool::IsWhich( nWhich ) 192 ? GetPool().GetSlotId( nWhich ) 193 : nWhich; 194 195 switch ( nSlotId ) 196 { 197 case SID_STYLE_APPLY: 198 if ( !pStylePool ) 199 rSet.DisableItem( nSlotId ); 200 break; 201 202 case SID_STYLE_FAMILY2: // Zellvorlagen 203 { 204 SfxStyleSheet* pStyleSheet = (SfxStyleSheet*) 205 pTabViewShell->GetStyleSheetFromMarked(); 206 207 if ( pStyleSheet ) 208 rSet.Put( SfxTemplateItem( nSlotId, pStyleSheet->GetName() ) ); 209 else 210 rSet.Put( SfxTemplateItem( nSlotId, String() ) ); 211 } 212 break; 213 214 case SID_STYLE_FAMILY4: // Seitenvorlagen 215 { 216 SCTAB nCurTab = GetViewData()->GetTabNo(); 217 String aPageStyle = pDoc->GetPageStyle( nCurTab ); 218 SfxStyleSheet* pStyleSheet = (SfxStyleSheet*)pStylePool-> 219 Find( aPageStyle, SFX_STYLE_FAMILY_PAGE ); 220 221 if ( pStyleSheet ) 222 rSet.Put( SfxTemplateItem( nSlotId, aPageStyle ) ); 223 else 224 rSet.Put( SfxTemplateItem( nSlotId, String() ) ); 225 } 226 break; 227 228 case SID_STYLE_WATERCAN: 229 { 230 rSet.Put( SfxBoolItem( nSlotId, SC_MOD()->GetIsWaterCan() ) ); 231 } 232 break; 233 234 case SID_STYLE_UPDATE_BY_EXAMPLE: 235 { 236 ISfxTemplateCommon* pDesigner = SFX_APP()-> 237 GetCurrentTemplateCommon(pTabViewShell->GetViewFrame()->GetBindings()); 238 sal_Bool bPage = pDesigner && SFX_STYLE_FAMILY_PAGE == pDesigner->GetActualFamily(); 239 240 if ( bProtected || bPage ) 241 rSet.DisableItem( nSlotId ); 242 } 243 break; 244 245 case SID_STYLE_EDIT: 246 case SID_STYLE_DELETE: 247 { 248 ISfxTemplateCommon* pDesigner = SFX_APP()-> 249 GetCurrentTemplateCommon(pTabViewShell->GetViewFrame()->GetBindings()); 250 sal_Bool bPage = pDesigner && SFX_STYLE_FAMILY_PAGE == pDesigner->GetActualFamily(); 251 252 if ( bProtected && !bPage ) 253 rSet.DisableItem( nSlotId ); 254 } 255 break; 256 257 default: 258 break; 259 } 260 261 nWhich = aIter.NextWhich(); 262 } 263 } 264 265 //------------------------------------------------------------------ 266 267 void __EXPORT ScFormatShell::ExecuteStyle( SfxRequest& rReq ) 268 { 269 // Wenn ToolBar vertikal : 270 if ( !rReq.GetArgs() ) 271 { 272 pViewData->GetDispatcher().Execute( SID_STYLE_DESIGNER, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD ); 273 return; 274 } 275 276 //-------------------------------------------------------------------- 277 SfxBindings& rBindings = pViewData->GetBindings(); 278 const SfxItemSet* pArgs = rReq.GetArgs(); 279 const sal_uInt16 nSlotId = rReq.GetSlot(); 280 const SCTAB nCurTab = GetViewData()->GetTabNo(); 281 ScDocShell* pDocSh = GetViewData()->GetDocShell(); 282 ScTabViewShell* pTabViewShell= GetViewData()->GetViewShell(); 283 ScDocument* pDoc = pDocSh->GetDocument(); 284 ScMarkData& rMark = GetViewData()->GetMarkData(); 285 ScModule* pScMod = SC_MOD(); 286 String aRefName; 287 sal_Bool bUndo = pDoc->IsUndoEnabled(); 288 289 if ( (nSlotId == SID_STYLE_NEW) 290 || (nSlotId == SID_STYLE_EDIT) 291 || (nSlotId == SID_STYLE_DELETE) 292 || (nSlotId == SID_STYLE_APPLY) 293 || (nSlotId == SID_STYLE_WATERCAN) 294 || (nSlotId == SID_STYLE_FAMILY) 295 || (nSlotId == SID_STYLE_NEW_BY_EXAMPLE) 296 || (nSlotId == SID_STYLE_UPDATE_BY_EXAMPLE) ) 297 { 298 SfxStyleSheetBasePool* pStylePool = pDoc->GetStyleSheetPool(); 299 SfxStyleSheetBase* pStyleSheet = NULL; 300 301 sal_Bool bStyleToMarked = sal_False; 302 sal_Bool bListAction = sal_False; 303 sal_Bool bAddUndo = sal_False; // add ScUndoModifyStyle (style modified) 304 ScStyleSaveData aOldData; // for undo/redo 305 ScStyleSaveData aNewData; 306 307 SfxStyleFamily eFamily = SFX_STYLE_FAMILY_PARA; 308 const SfxPoolItem* pFamItem; 309 if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_FAMILY, sal_True, &pFamItem ) ) 310 eFamily = (SfxStyleFamily)((const SfxUInt16Item*)pFamItem)->GetValue(); 311 else 312 if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_FAMILYNAME, sal_True, &pFamItem ) ) 313 { 314 String sFamily = ((const SfxStringItem*)pFamItem)->GetValue(); 315 if (sFamily.CompareToAscii("CellStyles") == COMPARE_EQUAL) 316 eFamily = SFX_STYLE_FAMILY_PARA; 317 else 318 if (sFamily.CompareToAscii("PageStyles") == COMPARE_EQUAL) 319 eFamily = SFX_STYLE_FAMILY_PAGE; 320 } 321 322 String aStyleName; 323 sal_uInt16 nRetMask = 0xffff; 324 // #96983# only stylist sends focus to sheet 325 // sal_Bool bGrabFocus = ( SID_STYLE_APPLY == nSlotId ); 326 327 pStylePool->SetSearchMask( eFamily, SFXSTYLEBIT_ALL ); 328 329 switch ( nSlotId ) 330 { 331 case SID_STYLE_NEW: 332 { 333 const SfxPoolItem* pNameItem; 334 if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( nSlotId, sal_True, &pNameItem )) 335 aStyleName = ((const SfxStringItem*)pNameItem)->GetValue(); 336 337 const SfxPoolItem* pRefItem=NULL; 338 if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_REFERENCE, sal_True, &pRefItem )) 339 { 340 if(pRefItem!=NULL) 341 aRefName = ((const SfxStringItem*)pRefItem)->GetValue(); 342 } 343 344 pStyleSheet = &(pStylePool->Make( aStyleName, eFamily, 345 SFXSTYLEBIT_USERDEF ) ); 346 347 if ( pStyleSheet && pStyleSheet->HasParentSupport() ) 348 pStyleSheet->SetParent(aRefName); 349 } 350 break; 351 352 case SID_STYLE_APPLY: 353 { 354 SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, SID_APPLY_STYLE, sal_False ); 355 SFX_REQUEST_ARG( rReq, pFamilyItem, SfxStringItem, SID_STYLE_FAMILYNAME, sal_False ); 356 if ( pFamilyItem && pNameItem ) 357 { 358 com::sun::star::uno::Reference< com::sun::star::style::XStyleFamiliesSupplier > xModel(pDocSh->GetModel(), com::sun::star::uno::UNO_QUERY); 359 try 360 { 361 com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xStyles; 362 com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xCont = xModel->getStyleFamilies(); 363 xCont->getByName(pFamilyItem->GetValue()) >>= xStyles; 364 com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xInfo; 365 xStyles->getByName( pNameItem->GetValue() ) >>= xInfo; 366 ::rtl::OUString aUIName; 367 xInfo->getPropertyValue( ::rtl::OUString::createFromAscii("DisplayName") ) >>= aUIName; 368 if ( aUIName.getLength() ) 369 rReq.AppendItem( SfxStringItem( SID_STYLE_APPLY, aUIName ) ); 370 } 371 catch( com::sun::star::uno::Exception& ) 372 { 373 } 374 } 375 } 376 case SID_STYLE_EDIT: 377 case SID_STYLE_DELETE: 378 case SID_STYLE_NEW_BY_EXAMPLE: 379 { 380 const SfxPoolItem* pNameItem; 381 if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( nSlotId, sal_True, &pNameItem )) 382 aStyleName = ((const SfxStringItem*)pNameItem)->GetValue(); 383 pStyleSheet = pStylePool->Find( aStyleName, eFamily ); 384 385 aOldData.InitFromStyle( pStyleSheet ); 386 } 387 break; 388 389 case SID_STYLE_WATERCAN: 390 { 391 sal_Bool bWaterCan = pScMod->GetIsWaterCan(); 392 393 if( !bWaterCan ) 394 { 395 const SfxPoolItem* pItem; 396 397 if ( SFX_ITEM_SET == 398 pArgs->GetItemState( nSlotId, sal_True, &pItem ) ) 399 { 400 const SfxStringItem* pStrItem = PTR_CAST(SfxStringItem,pItem); 401 if ( pStrItem ) 402 { 403 aStyleName = pStrItem->GetValue(); 404 pStyleSheet = pStylePool->Find( aStyleName, eFamily ); 405 406 if ( pStyleSheet ) 407 { 408 ((ScStyleSheetPool*)pStylePool)-> 409 SetActualStyleSheet( pStyleSheet ); 410 rReq.Done(); 411 } 412 } 413 } 414 } 415 416 if ( !bWaterCan && pStyleSheet ) 417 { 418 pScMod->SetWaterCan( sal_True ); 419 pTabViewShell->SetActivePointer( Pointer(POINTER_FILL) ); 420 rReq.Done(); 421 } 422 else 423 { 424 pScMod->SetWaterCan( sal_False ); 425 pTabViewShell->SetActivePointer( Pointer(POINTER_ARROW) ); 426 rReq.Done(); 427 } 428 } 429 break; 430 431 default: 432 break; 433 } 434 435 // Neuen Style fuer WaterCan-Mode setzen 436 if ( nSlotId == SID_STYLE_APPLY && pScMod->GetIsWaterCan() && pStyleSheet ) 437 ((ScStyleSheetPool*)pStylePool)->SetActualStyleSheet( pStyleSheet ); 438 439 switch ( eFamily ) 440 { 441 case SFX_STYLE_FAMILY_PARA: 442 { 443 switch ( nSlotId ) 444 { 445 case SID_STYLE_DELETE: 446 { 447 if ( pStyleSheet ) 448 { 449 pTabViewShell->RemoveStyleSheetInUse( pStyleSheet ); 450 pStylePool->Remove( pStyleSheet ); 451 pTabViewShell->InvalidateAttribs(); 452 nRetMask = sal_True; 453 bAddUndo = sal_True; 454 rReq.Done(); 455 } 456 else 457 nRetMask = sal_False; 458 } 459 break; 460 461 case SID_STYLE_APPLY: 462 { 463 if ( pStyleSheet && !pScMod->GetIsWaterCan() ) 464 { 465 // Anwenden der Vorlage auf das Dokument 466 pTabViewShell->SetStyleSheetToMarked( (SfxStyleSheet*)pStyleSheet ); 467 pTabViewShell->InvalidateAttribs(); 468 rReq.Done(); 469 } 470 } 471 break; 472 473 case SID_STYLE_NEW_BY_EXAMPLE: 474 case SID_STYLE_UPDATE_BY_EXAMPLE: 475 { 476 // Vorlage erzeugen/ersetzen durch Attribute 477 // an der Cursor-Position: 478 479 const ScPatternAttr* pAttrItem = NULL; 480 481 // Die Abfrage, ob markiert ist, war hier immer falsch, 482 // darum jetzt gar nicht mehr, und einfach vom Cursor. 483 // Wenn Attribute aus der Selektion genommen werden sollen, 484 // muss noch darauf geachtet werden, Items aus Vorlagen nicht 485 // zu uebernehmen (GetSelectionPattern sammelt auch Items aus 486 // Vorlagen zusammen) (#44748#) 487 // pAttrItem = GetSelectionPattern(); 488 489 // ScViewData* pViewData = GetViewData(); 490 SCCOL nCol = pViewData->GetCurX(); 491 SCROW nRow = pViewData->GetCurY(); 492 pAttrItem = pDoc->GetPattern( nCol, nRow, nCurTab ); 493 494 SfxItemSet aAttrSet = pAttrItem->GetItemSet(); 495 aAttrSet.ClearItem( ATTR_MERGE ); 496 aAttrSet.ClearItem( ATTR_MERGE_FLAG ); 497 // bedingte Formatierung und Gueltigkeit nicht uebernehmen, 498 // weil sie in der Vorlage nicht editiert werden koennen 499 aAttrSet.ClearItem( ATTR_VALIDDATA ); 500 aAttrSet.ClearItem( ATTR_CONDITIONAL ); 501 502 if ( SID_STYLE_NEW_BY_EXAMPLE == nSlotId ) 503 { 504 if ( bUndo ) 505 { 506 String aUndo = ScGlobal::GetRscString( STR_UNDO_EDITCELLSTYLE ); 507 pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo ); 508 bListAction = sal_True; 509 } 510 511 sal_Bool bConvertBack = sal_False; 512 SfxStyleSheet* pSheetInUse = (SfxStyleSheet*) 513 pTabViewShell->GetStyleSheetFromMarked(); 514 515 // wenn neuer Style vorhanden und in der Selektion 516 // verwendet wird, so darf der Parent nicht uebernommen 517 // werden: 518 519 if ( pStyleSheet && pSheetInUse && pStyleSheet == pSheetInUse ) 520 pSheetInUse = NULL; 521 522 // wenn bereits vorhanden, erstmal entfernen... 523 if ( pStyleSheet ) 524 { 525 // Style-Pointer zu Namen vor Erase, 526 // weil Zellen sonst ungueltige Pointer 527 // enthalten. 528 //!!! bei Gelenheit mal eine Methode, die 529 // das fuer einen bestimmten Style macht 530 pDoc->StylesToNames(); 531 bConvertBack = sal_True; 532 pStylePool->Remove(pStyleSheet); 533 } 534 535 // ...und neu anlegen 536 pStyleSheet = &pStylePool->Make( aStyleName, eFamily, 537 SFXSTYLEBIT_USERDEF ); 538 539 // wenn ein Style vorhanden ist, so wird dieser 540 // Parent der neuen Vorlage: 541 if ( pSheetInUse && pStyleSheet->HasParentSupport() ) 542 pStyleSheet->SetParent( pSheetInUse->GetName() ); 543 544 if ( bConvertBack ) 545 // Namen zu Style-Pointer 546 pDoc->UpdStlShtPtrsFrmNms(); 547 else 548 pDoc->GetPool()->CellStyleCreated( aStyleName ); 549 550 // Attribute uebernehmen und Style anwenden 551 pStyleSheet->GetItemSet().Put( aAttrSet ); 552 pTabViewShell->UpdateStyleSheetInUse( pStyleSheet ); 553 554 // call SetStyleSheetToMarked after adding the ScUndoModifyStyle 555 // (pStyleSheet pointer is used!) 556 bStyleToMarked = sal_True; 557 } 558 else // ( nSlotId == SID_STYLE_UPDATE_BY_EXAMPLE ) 559 { 560 pStyleSheet = (SfxStyleSheet*)pTabViewShell->GetStyleSheetFromMarked(); 561 562 if ( pStyleSheet ) 563 { 564 aOldData.InitFromStyle( pStyleSheet ); 565 566 if ( bUndo ) 567 { 568 String aUndo = ScGlobal::GetRscString( STR_UNDO_EDITCELLSTYLE ); 569 pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo ); 570 bListAction = sal_True; 571 } 572 573 pStyleSheet->GetItemSet().Put( aAttrSet ); 574 pTabViewShell->UpdateStyleSheetInUse( pStyleSheet ); 575 576 // call SetStyleSheetToMarked after adding the ScUndoModifyStyle 577 // (pStyleSheet pointer is used!) 578 bStyleToMarked = sal_True; 579 } 580 } 581 582 aNewData.InitFromStyle( pStyleSheet ); 583 bAddUndo = sal_True; 584 rReq.Done(); 585 } 586 break; 587 588 default: 589 break; 590 } 591 } // case SFX_STYLE_FAMILY_PARA: 592 break; 593 594 case SFX_STYLE_FAMILY_PAGE: 595 { 596 switch ( nSlotId ) 597 { 598 case SID_STYLE_DELETE: 599 { 600 nRetMask = ( NULL != pStyleSheet ); 601 if ( pStyleSheet ) 602 { 603 if ( pDoc->RemovePageStyleInUse( pStyleSheet->GetName() ) ) 604 { 605 ScPrintFunc( pDocSh, pTabViewShell->GetPrinter(sal_True), nCurTab ).UpdatePages(); 606 rBindings.Invalidate( SID_STATUS_PAGESTYLE ); 607 rBindings.Invalidate( FID_RESET_PRINTZOOM ); 608 } 609 pStylePool->Remove( pStyleSheet ); 610 rBindings.Invalidate( SID_STYLE_FAMILY4 ); 611 pDocSh->SetDocumentModified(); 612 bAddUndo = sal_True; 613 rReq.Done(); 614 } 615 } 616 break; 617 618 case SID_STYLE_APPLY: 619 { 620 nRetMask = ( NULL != pStyleSheet ); 621 if ( pStyleSheet && !pScMod->GetIsWaterCan() ) 622 { 623 ScUndoApplyPageStyle* pUndoAction = 0; 624 for( SCTAB nTab = 0, nTabCount = pDoc->GetTableCount(); nTab < nTabCount; ++nTab ) 625 { 626 if( rMark.GetTableSelect( nTab ) ) 627 { 628 String aOldName = pDoc->GetPageStyle( nTab ); 629 if ( aOldName != aStyleName ) 630 { 631 pDoc->SetPageStyle( nTab, aStyleName ); 632 ScPrintFunc( pDocSh, pTabViewShell->GetPrinter(sal_True), nTab ).UpdatePages(); 633 if( !pUndoAction ) 634 pUndoAction = new ScUndoApplyPageStyle( pDocSh, aStyleName ); 635 pUndoAction->AddSheetAction( nTab, aOldName ); 636 } 637 } 638 } 639 if( pUndoAction ) 640 { 641 pDocSh->GetUndoManager()->AddUndoAction( pUndoAction ); 642 pDocSh->SetDocumentModified(); 643 rBindings.Invalidate( SID_STYLE_FAMILY4 ); 644 rBindings.Invalidate( SID_STATUS_PAGESTYLE ); 645 rBindings.Invalidate( FID_RESET_PRINTZOOM ); 646 } 647 rReq.Done(); 648 } 649 } 650 break; 651 652 case SID_STYLE_NEW_BY_EXAMPLE: 653 { 654 const String& rStrCurStyle = pDoc->GetPageStyle( nCurTab ); 655 656 if ( rStrCurStyle != aStyleName ) 657 { 658 SfxStyleSheetBase* pCurStyle = pStylePool->Find( rStrCurStyle, eFamily ); 659 SfxItemSet aAttrSet = pCurStyle->GetItemSet(); 660 SCTAB nInTab; 661 sal_Bool bUsed = pDoc->IsPageStyleInUse( aStyleName, &nInTab ); 662 663 // wenn bereits vorhanden, erstmal entfernen... 664 if ( pStyleSheet ) 665 pStylePool->Remove( pStyleSheet ); 666 667 // ...und neu anlegen 668 pStyleSheet = &pStylePool->Make( aStyleName, eFamily, 669 SFXSTYLEBIT_USERDEF ); 670 671 // Attribute uebernehmen 672 pStyleSheet->GetItemSet().Put( aAttrSet ); 673 pDocSh->SetDocumentModified(); 674 675 // wenn in Verwendung -> Update 676 if ( bUsed ) 677 ScPrintFunc( pDocSh, pTabViewShell->GetPrinter(sal_True), nInTab ).UpdatePages(); 678 679 aNewData.InitFromStyle( pStyleSheet ); 680 bAddUndo = sal_True; 681 rReq.Done(); 682 nRetMask = sal_True; 683 } 684 } 685 break; 686 687 default: 688 break; 689 } // switch ( nSlotId ) 690 } // case SFX_STYLE_FAMILY_PAGE: 691 break; 692 693 default: 694 break; 695 } // switch ( eFamily ) 696 697 // Neu anlegen oder bearbeiten ueber Dialog: 698 if ( nSlotId == SID_STYLE_NEW || nSlotId == SID_STYLE_EDIT ) 699 { 700 if ( pStyleSheet ) 701 { 702 SvxNumberInfoItem* pNumberInfoItem = NULL; 703 704 SfxStyleFamily eFam = pStyleSheet->GetFamily(); 705 // ScDocument* pDoc = GetViewData()->GetDocument(); 706 // ScDocShell* pDocSh = GetViewData()->GetDocShell(); 707 //CHINA001 ScStyleDlg* pDlg = NULL; 708 SfxAbstractTabDialog* pDlg = NULL; //CHINA001 709 sal_uInt16 nRsc = 0; 710 711 // #37034#/#37245# alte Items aus der Vorlage merken 712 SfxItemSet aOldSet = pStyleSheet->GetItemSet(); 713 String aOldName = pStyleSheet->GetName(); 714 715 switch ( eFam ) 716 { 717 case SFX_STYLE_FAMILY_PAGE: 718 nRsc = RID_SCDLG_STYLES_PAGE; 719 break; 720 721 case SFX_STYLE_FAMILY_PARA: 722 default: 723 { 724 SfxItemSet& rSet = pStyleSheet->GetItemSet(); 725 726 const SfxPoolItem* pItem; 727 if ( rSet.GetItemState( ATTR_VALUE_FORMAT, 728 sal_False, &pItem ) == SFX_ITEM_SET ) 729 { 730 // NumberFormat Value aus Value und Language 731 // erzeugen und eintueten 732 sal_uLong nFormat = 733 ((SfxUInt32Item*)pItem)->GetValue(); 734 LanguageType eLang = 735 ((SvxLanguageItem*)&rSet.Get( 736 ATTR_LANGUAGE_FORMAT ))->GetLanguage(); 737 sal_uLong nLangFormat = pDoc->GetFormatTable()-> 738 GetFormatForLanguageIfBuiltIn( nFormat, eLang ); 739 if ( nLangFormat != nFormat ) 740 { 741 SfxUInt32Item aNewItem( ATTR_VALUE_FORMAT, nLangFormat ); 742 rSet.Put( aNewItem ); 743 aOldSet.Put( aNewItem ); 744 // auch in aOldSet fuer Vergleich nach dem Dialog, 745 // sonst geht evtl. eine Aenderung der Sprache verloren 746 } 747 } 748 749 pTabViewShell->MakeNumberInfoItem( pDoc, GetViewData(), &pNumberInfoItem ); 750 pDocSh->PutItem( *pNumberInfoItem ); 751 nRsc = RID_SCDLG_STYLES_PAR; 752 753 // auf jeden Fall ein SvxBoxInfoItem mit Table = sal_False im Set: 754 // (wenn gar kein Item da ist, loescht der Dialog auch das 755 // BORDER_OUTER SvxBoxItem aus dem Vorlagen-Set) 756 757 if ( rSet.GetItemState( ATTR_BORDER_INNER, sal_False ) != SFX_ITEM_SET ) 758 { 759 SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER ); 760 aBoxInfoItem.SetTable(sal_False); // keine inneren Linien 761 aBoxInfoItem.SetDist(sal_True); 762 aBoxInfoItem.SetMinDist(sal_False); 763 rSet.Put( aBoxInfoItem ); 764 } 765 } 766 break; 767 } 768 769 // If GetDefDialogParent is a dialog, it must be used 770 // (style catalog) 771 772 Window* pParent = Application::GetDefDialogParent(); 773 if ( !pParent || !pParent->IsDialog() ) 774 { 775 // #107256# GetDefDialogParent currently doesn't return the window 776 // that was set with SetDefDialogParent (but dynamically finds the 777 // topmost parent of the focus window), so IsDialog above is FALSE 778 // even if called from the style catalog. 779 // -> Use NULL if a modal dialog is open, to enable the Dialog's 780 // default parent handling. 781 if ( Application::IsInModalMode() ) 782 pParent = NULL; 783 else 784 pParent = pTabViewShell->GetDialogParent(); 785 } 786 787 pTabViewShell->SetInFormatDialog(sal_True); 788 789 //CHINA001 pDlg = new ScStyleDlg( pParent, *pStyleSheet, nRsc ); 790 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); 791 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001 792 793 pDlg = pFact->CreateScStyleDlg( pParent, *pStyleSheet, nRsc, nRsc ); 794 DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001 795 short nResult = pDlg->Execute(); 796 pTabViewShell->SetInFormatDialog(sal_False); 797 798 if ( nResult == RET_OK ) 799 { 800 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); 801 802 if ( pOutSet ) 803 { 804 nRetMask = pStyleSheet->GetMask(); 805 806 // #37034#/#37245# Attribut-Vergleiche (frueher in ModifyStyleSheet) 807 // jetzt hier mit den alten Werten (Style ist schon veraendert) 808 809 if ( SFX_STYLE_FAMILY_PARA == eFam ) 810 { 811 // pDoc->CellStyleChanged( *pStyleSheet, aOldSet ); 812 813 SfxItemSet& rNewSet = pStyleSheet->GetItemSet(); 814 sal_Bool bNumFormatChanged; 815 if ( ScGlobal::CheckWidthInvalidate( 816 bNumFormatChanged, aOldSet, rNewSet ) ) 817 pDoc->InvalidateTextWidth( NULL, NULL, bNumFormatChanged ); 818 819 SCTAB nTabCount = pDoc->GetTableCount(); 820 for (SCTAB nTab=0; nTab<nTabCount; nTab++) 821 if (pDoc->IsStreamValid(nTab)) 822 pDoc->SetStreamValid(nTab, sal_False); 823 824 sal_uLong nOldFormat = ((const SfxUInt32Item&)aOldSet. 825 Get( ATTR_VALUE_FORMAT )).GetValue(); 826 sal_uLong nNewFormat = ((const SfxUInt32Item&)rNewSet. 827 Get( ATTR_VALUE_FORMAT )).GetValue(); 828 if ( nNewFormat != nOldFormat ) 829 { 830 SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); 831 const SvNumberformat* pOld = pFormatter->GetEntry( nOldFormat ); 832 const SvNumberformat* pNew = pFormatter->GetEntry( nNewFormat ); 833 if ( pOld && pNew && pOld->GetLanguage() != pNew->GetLanguage() ) 834 rNewSet.Put( SvxLanguageItem( 835 pNew->GetLanguage(), ATTR_LANGUAGE_FORMAT ) ); 836 } 837 838 pDoc->GetPool()->CellStyleCreated( pStyleSheet->GetName() ); 839 } 840 else 841 { 842 //! auch fuer Seitenvorlagen die Abfragen hier 843 844 String aNewName = pStyleSheet->GetName(); 845 if ( aNewName != aOldName && 846 pDoc->RenamePageStyleInUse( aOldName, aNewName ) ) 847 { 848 rBindings.Invalidate( SID_STATUS_PAGESTYLE ); 849 rBindings.Invalidate( FID_RESET_PRINTZOOM ); 850 } 851 852 pDoc->ModifyStyleSheet( *pStyleSheet, *pOutSet ); 853 rBindings.Invalidate( FID_RESET_PRINTZOOM ); 854 } 855 856 pDocSh->SetDocumentModified(); 857 858 if ( SFX_STYLE_FAMILY_PARA == eFam ) 859 { 860 pTabViewShell->UpdateNumberFormatter( pDoc, 861 (const SvxNumberInfoItem&) 862 *(pDocSh->GetItem(SID_ATTR_NUMBERFORMAT_INFO)) ); 863 864 pTabViewShell->UpdateStyleSheetInUse( pStyleSheet ); 865 pTabViewShell->InvalidateAttribs(); 866 } 867 868 aNewData.InitFromStyle( pStyleSheet ); 869 bAddUndo = sal_True; 870 } 871 } 872 else 873 { 874 if ( nSlotId == SID_STYLE_NEW ) 875 pStylePool->Remove( pStyleSheet ); 876 else 877 { 878 // falls zwischendurch etwas mit dem temporaer geaenderten 879 // ItemSet gepainted wurde: 880 pDocSh->PostPaintGridAll(); 881 } 882 } 883 delete pDlg; 884 } 885 } 886 887 // if ( nRetMask != 0xffff )// Irgendein Wert MUSS geliefert werden JN 888 rReq.SetReturnValue( SfxUInt16Item( nSlotId, nRetMask ) ); 889 890 // #96983# only stylist sends focus to sheet 891 // if ( bGrabFocus ) 892 // pTabViewShell->GetActiveWin()->GrabFocus(); 893 894 if ( bAddUndo && bUndo) 895 pDocSh->GetUndoManager()->AddUndoAction( 896 new ScUndoModifyStyle( pDocSh, eFamily, aOldData, aNewData ) ); 897 898 if ( bStyleToMarked ) 899 { 900 // call SetStyleSheetToMarked after adding the ScUndoModifyStyle, 901 // so redo will find the modified style 902 pTabViewShell->SetStyleSheetToMarked( (SfxStyleSheet*)pStyleSheet ); 903 pTabViewShell->InvalidateAttribs(); 904 } 905 906 if ( bListAction ) 907 pDocSh->GetUndoManager()->LeaveListAction(); 908 } 909 else 910 { 911 DBG_ERROR( "Unknown slot (ScViewShell::ExecuteStyle)" ); 912 } 913 } 914 915 void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq ) 916 { 917 ScModule* pScMod = SC_MOD(); 918 ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 919 const SfxItemSet* pReqArgs = rReq.GetArgs(); 920 sal_uInt16 nSlot = rReq.GetSlot(); 921 922 pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox 923 924 // Eingabe beenden 925 if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) ) 926 { 927 switch ( nSlot ) 928 { 929 case SID_NUMBER_TWODEC: 930 case SID_NUMBER_SCIENTIFIC: 931 case SID_NUMBER_DATE: 932 case SID_NUMBER_CURRENCY: 933 case SID_NUMBER_PERCENT: 934 case SID_NUMBER_STANDARD: 935 case SID_NUMBER_FORMAT: 936 case SID_NUMBER_INCDEC: 937 case SID_NUMBER_DECDEC: 938 case FID_DEFINE_NAME: 939 case FID_USE_NAME: 940 case FID_INSERT_NAME: 941 case SID_SPELL_DIALOG: 942 case SID_HANGUL_HANJA_CONVERSION: 943 944 pScMod->InputEnterHandler(); 945 pTabViewShell->UpdateInputHandler(); 946 break; 947 948 default: 949 break; 950 } 951 } 952 953 switch ( nSlot ) 954 { 955 case SID_NUMBER_TWODEC: 956 pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER, 4 ); // Standard+4 = #.##0,00 957 rReq.Done(); 958 break; 959 case SID_NUMBER_SCIENTIFIC: 960 pTabViewShell->SetNumberFormat( NUMBERFORMAT_SCIENTIFIC ); 961 rReq.Done(); 962 break; 963 case SID_NUMBER_DATE: 964 pTabViewShell->SetNumberFormat( NUMBERFORMAT_DATE ); 965 rReq.Done(); 966 break; 967 case SID_NUMBER_TIME: 968 pTabViewShell->SetNumberFormat( NUMBERFORMAT_TIME ); 969 rReq.Done(); 970 break; 971 case SID_NUMBER_CURRENCY: 972 pTabViewShell->SetNumberFormat( NUMBERFORMAT_CURRENCY ); 973 rReq.Done(); 974 break; 975 case SID_NUMBER_PERCENT: 976 pTabViewShell->SetNumberFormat( NUMBERFORMAT_PERCENT ); 977 rReq.Done(); 978 break; 979 case SID_NUMBER_STANDARD: 980 pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER ); 981 rReq.Done(); 982 break; 983 case SID_NUMBER_INCDEC: 984 pTabViewShell->ChangeNumFmtDecimals( sal_True ); 985 rReq.Done(); 986 break; 987 case SID_NUMBER_DECDEC: 988 pTabViewShell->ChangeNumFmtDecimals( sal_False ); 989 rReq.Done(); 990 break; 991 992 case SID_NUMBER_FORMAT: 993 //if ( pReqArgs ) 994 //{ 995 // const SfxPoolItem* pItem; 996 // if(pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET) 997 // { 998 // String aCode = ((const SfxStringItem*)pItem)->GetValue(); 999 // pTabViewShell->SetNumFmtByStr( aCode ); 1000 // } 1001 //} 1002 1003 // symphony version with format interpretation 1004 if(pReqArgs) 1005 { 1006 const SfxPoolItem* pItem; 1007 ScDocument* pDoc = pViewData->GetDocument(); 1008 SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); 1009 LanguageType eLanguage = ScGlobal::eLnge; 1010 sal_Int16 eType = -1; 1011 sal_uInt32 nCurrentNumberFormat; 1012 1013 pDoc->GetNumberFormat(pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo(), nCurrentNumberFormat); 1014 const SvNumberformat* pEntry = pFormatter->GetEntry(nCurrentNumberFormat); 1015 1016 if(pEntry) 1017 { 1018 eLanguage = pEntry->GetLanguage(); 1019 eType = pEntry->GetType(); 1020 } 1021 1022 //Just use eType to judge whether the command is fired for NUMBER/PERCENT/CURRENCY 1023 //In sidebar, users can fire SID_NUMBER_FORMAT command by operating the related UI controls before they are disable 1024 switch(eType) 1025 { 1026 case NUMBERFORMAT_ALL: 1027 case NUMBERFORMAT_NUMBER: 1028 case NUMBERFORMAT_NUMBER| NUMBERFORMAT_DEFINED: 1029 case NUMBERFORMAT_PERCENT: 1030 case NUMBERFORMAT_PERCENT| NUMBERFORMAT_DEFINED: 1031 case NUMBERFORMAT_CURRENCY: 1032 case NUMBERFORMAT_CURRENCY|NUMBERFORMAT_DEFINED: 1033 eType = 0; 1034 break; 1035 default: 1036 eType =-1; 1037 } 1038 1039 if(SFX_ITEM_SET == pReqArgs->GetItemState(nSlot, true, &pItem) && eType != -1) 1040 { 1041 String aCode = ((const SfxStringItem*)pItem)->GetValue(); 1042 sal_uInt16 aLen = aCode.Len(); 1043 String* sFormat = new String[4]; 1044 String sTmpStr = String::CreateFromAscii(""); 1045 sal_uInt16 nCount(0); 1046 sal_uInt16 nStrCount(0); 1047 1048 while(nCount < aLen) 1049 { 1050 sal_Unicode cChar = aCode.GetChar(nCount); 1051 1052 if(cChar == sal_Unicode(',')) 1053 { 1054 sFormat[nStrCount] = sTmpStr; 1055 sTmpStr = String::CreateFromAscii(""); 1056 nStrCount++; 1057 } 1058 else 1059 { 1060 sTmpStr += cChar; 1061 } 1062 1063 nCount++; 1064 1065 if(nStrCount > 3) 1066 break; 1067 } 1068 1069 const sal_Bool bThousand = (sal_Bool)sFormat[0].ToInt32(); 1070 const sal_Bool bNegRed = (sal_Bool)sFormat[1].ToInt32(); 1071 const sal_uInt16 nPrecision = (sal_uInt16)sFormat[2].ToInt32(); 1072 const sal_uInt16 nLeadZeroes = (sal_uInt16)sFormat[3].ToInt32(); 1073 1074 pFormatter->GenerateFormat( 1075 aCode, 1076 nCurrentNumberFormat,//modify 1077 eLanguage, 1078 bThousand, 1079 bNegRed, 1080 nPrecision, 1081 nLeadZeroes); 1082 pTabViewShell->SetNumFmtByStr(aCode); 1083 delete[] sFormat; 1084 } 1085 } 1086 break; 1087 1088 case SID_ATTR_NUMBERFORMAT_VALUE: 1089 if ( pReqArgs ) 1090 { 1091 const SfxPoolItem* pItem; 1092 if ( pReqArgs->GetItemState( ATTR_VALUE_FORMAT, sal_True, &pItem ) == SFX_ITEM_SET ) 1093 { 1094 // We have to accomplish this using ApplyAttributes() 1095 // because we also need the language information to be 1096 // considered. 1097 const SfxItemSet& rOldSet = 1098 pTabViewShell->GetSelectionPattern()->GetItemSet(); 1099 SfxItemPool* pDocPool = GetViewData()->GetDocument()->GetPool(); 1100 SfxItemSet aNewSet( *pDocPool, ATTR_PATTERN_START, ATTR_PATTERN_END ); 1101 aNewSet.Put( *pItem ); 1102 pTabViewShell->ApplyAttributes( &aNewSet, &rOldSet, sal_True ); 1103 } 1104 } 1105 break; 1106 1107 case SID_NUMBER_TYPE_FORMAT: 1108 if ( pReqArgs ) 1109 { 1110 const SfxPoolItem* pItem; 1111 if ( pReqArgs->GetItemState( nSlot, sal_True, &pItem ) == SFX_ITEM_SET ) 1112 { 1113 sal_uInt16 nFormat = ((SfxInt16Item *)pItem)->GetValue(); 1114 switch(nFormat) 1115 { 1116 case 0: 1117 pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER); //Modify 1118 break; 1119 case 1: 1120 pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER, 2 ); //Modify 1121 break; 1122 case 2: 1123 pTabViewShell->SetNumberFormat( NUMBERFORMAT_PERCENT ); 1124 break; 1125 case 3: 1126 pTabViewShell->SetNumberFormat( NUMBERFORMAT_CURRENCY ); 1127 break; 1128 case 4: 1129 pTabViewShell->SetNumberFormat( NUMBERFORMAT_DATE ); 1130 break; 1131 case 5: 1132 pTabViewShell->SetNumberFormat( NUMBERFORMAT_TIME ); 1133 break; 1134 case 6: 1135 pTabViewShell->SetNumberFormat( NUMBERFORMAT_SCIENTIFIC ); 1136 break; 1137 case 7: 1138 pTabViewShell->SetNumberFormat( NUMBERFORMAT_FRACTION ); 1139 break; 1140 case 8: 1141 pTabViewShell->SetNumberFormat( NUMBERFORMAT_LOGICAL ); 1142 break; 1143 case 9: 1144 pTabViewShell->SetNumberFormat( NUMBERFORMAT_TEXT ); 1145 break; 1146 default: 1147 ; 1148 } 1149 rReq.Done(); 1150 } 1151 } 1152 break; 1153 1154 default: 1155 DBG_ERROR("falscher Slot bei ExecuteEdit"); 1156 break; 1157 } 1158 } 1159 1160 1161 //------------------------------------------------------------------ 1162 1163 #define APPLY_HOR_JUSTIFY(j) \ 1164 { \ 1165 if ( !pHorJustify || (eHorJustify != (j) ) ) \ 1166 pTabViewShell->ApplyAttr( SvxHorJustifyItem( (j) ) ); \ 1167 else \ 1168 pTabViewShell->ApplyAttr( SvxHorJustifyItem( SVX_HOR_JUSTIFY_STANDARD ) ); \ 1169 } 1170 1171 #define APPLY_VER_JUSTIFY(j) \ 1172 { \ 1173 if ( !pVerJustify || (eVerJustify != (j) ) ) \ 1174 pTabViewShell->ApplyAttr( SvxVerJustifyItem( (j) ) ); \ 1175 else \ 1176 pTabViewShell->ApplyAttr( SvxVerJustifyItem( SVX_VER_JUSTIFY_STANDARD ) ); \ 1177 } 1178 1179 void ScFormatShell::ExecuteAlignment( SfxRequest& rReq ) 1180 { 1181 ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 1182 SfxBindings& rBindings = pViewData->GetBindings(); 1183 const SfxItemSet* pSet = rReq.GetArgs(); 1184 sal_uInt16 nSlot = rReq.GetSlot(); 1185 1186 pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox 1187 1188 switch( nSlot ) 1189 { 1190 // pseudo slots for Format menu 1191 case SID_ALIGN_ANY_HDEFAULT: 1192 case SID_ALIGN_ANY_LEFT: 1193 case SID_ALIGN_ANY_HCENTER: 1194 case SID_ALIGN_ANY_RIGHT: 1195 case SID_ALIGN_ANY_JUSTIFIED: 1196 pTabViewShell->ApplyAttr( SvxHorJustifyItem( lclConvertSlotToHAlign( nSlot ), ATTR_HOR_JUSTIFY ) ); 1197 break; 1198 case SID_ALIGN_ANY_VDEFAULT: 1199 case SID_ALIGN_ANY_TOP: 1200 case SID_ALIGN_ANY_VCENTER: 1201 case SID_ALIGN_ANY_BOTTOM: 1202 pTabViewShell->ApplyAttr( SvxVerJustifyItem( lclConvertSlotToVAlign( nSlot ), ATTR_VER_JUSTIFY ) ); 1203 break; 1204 1205 default: 1206 if( pSet ) 1207 { 1208 const SfxPoolItem* pItem = NULL; 1209 if( pSet->GetItemState(GetPool().GetWhich(nSlot), sal_True, &pItem ) == SFX_ITEM_SET ) 1210 { 1211 1212 switch ( nSlot ) 1213 { 1214 case SID_ATTR_ALIGN_HOR_JUSTIFY: 1215 case SID_ATTR_ALIGN_VER_JUSTIFY: 1216 case SID_ATTR_ALIGN_INDENT: 1217 case SID_ATTR_ALIGN_HYPHENATION: 1218 case SID_ATTR_ALIGN_DEGREES: 1219 case SID_ATTR_ALIGN_LOCKPOS: 1220 case SID_ATTR_ALIGN_MARGIN: 1221 case SID_ATTR_ALIGN_STACKED: 1222 pTabViewShell->ApplyAttr( *pItem ); 1223 break; 1224 1225 case SID_H_ALIGNCELL: 1226 { 1227 SvxCellHorJustify eJust = (SvxCellHorJustify)((const SvxHorJustifyItem*)pItem)->GetValue(); 1228 // #i78476# update alignment of text in cell edit mode 1229 pTabViewShell->UpdateInputHandlerCellAdjust( eJust ); 1230 pTabViewShell->ApplyAttr( SvxHorJustifyItem( eJust, ATTR_HOR_JUSTIFY ) ); 1231 } 1232 break; 1233 case SID_V_ALIGNCELL: 1234 pTabViewShell->ApplyAttr( SvxVerJustifyItem( (SvxCellVerJustify)((const SvxVerJustifyItem*)pItem)->GetValue(), ATTR_VER_JUSTIFY ) ); 1235 break; 1236 default: 1237 DBG_ERROR( "ExecuteAlignment: invalid slot" ); 1238 return; 1239 } 1240 } 1241 } 1242 } 1243 rBindings.Invalidate( SID_ATTR_PARA_ADJUST_LEFT ); 1244 rBindings.Invalidate( SID_ATTR_PARA_ADJUST_RIGHT ); 1245 rBindings.Invalidate( SID_ATTR_PARA_ADJUST_BLOCK ); 1246 rBindings.Invalidate( SID_ATTR_PARA_ADJUST_CENTER); 1247 rBindings.Invalidate( SID_ALIGNLEFT ); 1248 rBindings.Invalidate( SID_ALIGNRIGHT ); 1249 rBindings.Invalidate( SID_ALIGNCENTERHOR ); 1250 rBindings.Invalidate( SID_ALIGNBLOCK ); 1251 rBindings.Invalidate( SID_ALIGNTOP ); 1252 rBindings.Invalidate( SID_ALIGNBOTTOM ); 1253 rBindings.Invalidate( SID_ALIGNCENTERVER ); 1254 rBindings.Invalidate( SID_V_ALIGNCELL ); 1255 rBindings.Invalidate( SID_H_ALIGNCELL ); 1256 // pseudo slots for Format menu 1257 rBindings.Invalidate( SID_ALIGN_ANY_HDEFAULT ); 1258 rBindings.Invalidate( SID_ALIGN_ANY_LEFT ); 1259 rBindings.Invalidate( SID_ALIGN_ANY_HCENTER ); 1260 rBindings.Invalidate( SID_ALIGN_ANY_RIGHT ); 1261 rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED ); 1262 rBindings.Invalidate( SID_ALIGN_ANY_VDEFAULT ); 1263 rBindings.Invalidate( SID_ALIGN_ANY_TOP ); 1264 rBindings.Invalidate( SID_ALIGN_ANY_VCENTER ); 1265 rBindings.Invalidate( SID_ALIGN_ANY_BOTTOM ); 1266 rBindings.Update(); 1267 1268 if( ! rReq.IsAPI() ) 1269 rReq.Done(); 1270 } 1271 1272 void ScFormatShell::ExecuteTextAttr( SfxRequest& rReq ) 1273 { 1274 ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 1275 SfxBindings& rBindings = pViewData->GetBindings(); 1276 const ScPatternAttr* pAttrs = pTabViewShell->GetSelectionPattern(); 1277 const SfxItemSet* pSet = rReq.GetArgs(); 1278 sal_uInt16 nSlot = rReq.GetSlot(); 1279 SfxAllItemSet* pNewSet = 0; 1280 1281 pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox 1282 1283 if ( (nSlot == SID_ATTR_CHAR_WEIGHT) 1284 ||(nSlot == SID_ATTR_CHAR_POSTURE) 1285 ||(nSlot == SID_ATTR_CHAR_UNDERLINE) 1286 ||(nSlot == SID_ULINE_VAL_NONE) 1287 ||(nSlot == SID_ULINE_VAL_SINGLE) 1288 ||(nSlot == SID_ULINE_VAL_DOUBLE) 1289 ||(nSlot == SID_ULINE_VAL_DOTTED) ) 1290 { 1291 pNewSet = new SfxAllItemSet( GetPool() ); 1292 1293 switch ( nSlot ) 1294 { 1295 case SID_ATTR_CHAR_WEIGHT: 1296 { 1297 // #i78017 establish the same behaviour as in Writer 1298 sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX; 1299 1300 SfxItemPool& rPool = GetPool(); 1301 SvxScriptSetItem aSetItem( nSlot, rPool ); 1302 if ( pSet ) 1303 aSetItem.PutItemForScriptType( nScript, pSet->Get( ATTR_FONT_WEIGHT ) ); 1304 else 1305 { 1306 // toggle manually 1307 1308 FontWeight eWeight = WEIGHT_BOLD; 1309 SvxScriptSetItem aOldSetItem( nSlot, rPool ); 1310 aOldSetItem.GetItemSet().Put( pAttrs->GetItemSet(), sal_False ); 1311 const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript ); 1312 if ( pCore && ((const SvxWeightItem*)pCore)->GetWeight() == WEIGHT_BOLD ) 1313 eWeight = WEIGHT_NORMAL; 1314 1315 aSetItem.PutItemForScriptType( nScript, SvxWeightItem( eWeight, ATTR_FONT_WEIGHT ) ); 1316 } 1317 pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() ); 1318 pNewSet->Put( aSetItem.GetItemSet(), sal_False ); 1319 } 1320 break; 1321 1322 case SID_ATTR_CHAR_POSTURE: 1323 { 1324 // #i78017 establish the same behaviour as in Writer 1325 sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX; 1326 1327 SfxItemPool& rPool = GetPool(); 1328 SvxScriptSetItem aSetItem( nSlot, rPool ); 1329 if ( pSet ) 1330 aSetItem.PutItemForScriptType( nScript, pSet->Get( ATTR_FONT_POSTURE ) ); 1331 else 1332 { 1333 // toggle manually 1334 1335 FontItalic eItalic = ITALIC_NORMAL; 1336 SvxScriptSetItem aOldSetItem( nSlot, rPool ); 1337 aOldSetItem.GetItemSet().Put( pAttrs->GetItemSet(), sal_False ); 1338 const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript ); 1339 if ( pCore && ((const SvxPostureItem*)pCore)->GetPosture() == ITALIC_NORMAL ) 1340 eItalic = ITALIC_NONE; 1341 1342 aSetItem.PutItemForScriptType( nScript, SvxPostureItem( eItalic, ATTR_FONT_POSTURE ) ); 1343 } 1344 pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() ); 1345 pNewSet->Put( aSetItem.GetItemSet(), sal_False ); 1346 } 1347 break; 1348 1349 case SID_ATTR_CHAR_UNDERLINE: 1350 { 1351 FontUnderline eUnderline; 1352 1353 if( pSet ) 1354 { 1355 const SfxPoolItem& rUnderline = pSet->Get( ATTR_FONT_UNDERLINE ); 1356 1357 if( rUnderline.ISA(SvxUnderlineItem) ) 1358 { 1359 pTabViewShell->ApplyAttr( rUnderline ); 1360 pNewSet->Put( rUnderline,rUnderline.Which() ); 1361 } 1362 else if ( rUnderline.ISA(SvxTextLineItem) ) 1363 { 1364 // #i106580# also allow SvxTextLineItem (base class of SvxUnderlineItem) 1365 const SvxTextLineItem& rTextLineItem = static_cast<const SvxTextLineItem&>(rUnderline); 1366 SvxUnderlineItem aNewItem( rTextLineItem.GetLineStyle(), rTextLineItem.Which() ); 1367 aNewItem.SetColor( rTextLineItem.GetColor() ); 1368 pTabViewShell->ApplyAttr( aNewItem ); 1369 pNewSet->Put( aNewItem, aNewItem.Which() ); 1370 } 1371 } 1372 else 1373 { 1374 SvxUnderlineItem aUnderline( (const SvxUnderlineItem&) 1375 pAttrs->GetItem( 1376 ATTR_FONT_UNDERLINE ) ); 1377 eUnderline = (UNDERLINE_NONE != aUnderline.GetLineStyle()) 1378 ? UNDERLINE_NONE 1379 : UNDERLINE_SINGLE; 1380 aUnderline.SetLineStyle( eUnderline ); 1381 pTabViewShell->ApplyAttr( aUnderline ); 1382 pNewSet->Put( aUnderline,aUnderline.Which() ); 1383 } 1384 } 1385 break; 1386 1387 case SID_ULINE_VAL_NONE: 1388 pTabViewShell->ApplyAttr( SvxUnderlineItem( UNDERLINE_NONE, ATTR_FONT_UNDERLINE ) ); 1389 break; 1390 case SID_ULINE_VAL_SINGLE: // Toggles 1391 case SID_ULINE_VAL_DOUBLE: 1392 case SID_ULINE_VAL_DOTTED: 1393 { 1394 FontUnderline eOld = ((const SvxUnderlineItem&) 1395 pAttrs->GetItem(ATTR_FONT_UNDERLINE)).GetLineStyle(); 1396 FontUnderline eNew = eOld; 1397 switch (nSlot) 1398 { 1399 case SID_ULINE_VAL_SINGLE: 1400 eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE; 1401 break; 1402 case SID_ULINE_VAL_DOUBLE: 1403 eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE; 1404 break; 1405 case SID_ULINE_VAL_DOTTED: 1406 eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED; 1407 break; 1408 } 1409 pTabViewShell->ApplyAttr( SvxUnderlineItem( eNew, ATTR_FONT_UNDERLINE ) ); 1410 } 1411 break; 1412 1413 default: 1414 break; 1415 } 1416 rBindings.Invalidate( nSlot ); 1417 } 1418 else 1419 { 1420 /* 1421 * "Selbstgemachte" RadioButton-Funktionalitaet 1422 * Beim Toggle gibt es den Standard-State, d.h. kein 1423 * Button ist gedrueckt 1424 */ 1425 1426 const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); 1427 const SfxPoolItem* pItem = NULL; 1428 const SvxHorJustifyItem* pHorJustify = NULL; 1429 const SvxVerJustifyItem* pVerJustify = NULL; 1430 SvxCellHorJustify eHorJustify = SVX_HOR_JUSTIFY_STANDARD; 1431 SvxCellVerJustify eVerJustify = SVX_VER_JUSTIFY_STANDARD; 1432 1433 if (rAttrSet.GetItemState(ATTR_HOR_JUSTIFY, sal_True,&pItem ) == SFX_ITEM_SET) 1434 { 1435 pHorJustify = (const SvxHorJustifyItem*)pItem; 1436 eHorJustify = SvxCellHorJustify( pHorJustify->GetValue() ); 1437 } 1438 if (rAttrSet.GetItemState(ATTR_VER_JUSTIFY, sal_True,&pItem ) == SFX_ITEM_SET) 1439 { 1440 pVerJustify = (const SvxVerJustifyItem*)pItem; 1441 eVerJustify = SvxCellVerJustify( pVerJustify->GetValue() ); 1442 } 1443 1444 switch ( nSlot ) 1445 { 1446 case SID_ALIGNLEFT: 1447 rReq.SetSlot( SID_H_ALIGNCELL ); 1448 rReq.AppendItem( SvxHorJustifyItem( 1449 !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_LEFT) ? 1450 SVX_HOR_JUSTIFY_LEFT : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) ); 1451 ExecuteSlot( rReq, GetInterface() ); 1452 return; 1453 // APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_LEFT ); 1454 //break; 1455 1456 case SID_ALIGNRIGHT: 1457 rReq.SetSlot( SID_H_ALIGNCELL ); 1458 rReq.AppendItem( SvxHorJustifyItem( 1459 !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_RIGHT) ? 1460 SVX_HOR_JUSTIFY_RIGHT : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) ); 1461 ExecuteSlot( rReq, GetInterface() ); 1462 return; 1463 // APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_RIGHT ); 1464 //break; 1465 1466 case SID_ALIGNCENTERHOR: 1467 rReq.SetSlot( SID_H_ALIGNCELL ); 1468 rReq.AppendItem( SvxHorJustifyItem( 1469 !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_CENTER) ? 1470 SVX_HOR_JUSTIFY_CENTER : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) ); 1471 ExecuteSlot( rReq, GetInterface() ); 1472 return; 1473 // APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_CENTER ); 1474 //break; 1475 1476 case SID_ALIGNBLOCK: 1477 rReq.SetSlot( SID_H_ALIGNCELL ); 1478 rReq.AppendItem( SvxHorJustifyItem( 1479 !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_BLOCK) ? 1480 SVX_HOR_JUSTIFY_BLOCK : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) ); 1481 ExecuteSlot( rReq, GetInterface() ); 1482 return; 1483 // APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_BLOCK ); 1484 //break; 1485 1486 case SID_ALIGNTOP: 1487 rReq.SetSlot( SID_V_ALIGNCELL ); 1488 rReq.AppendItem( SvxVerJustifyItem( 1489 !pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_TOP) ? 1490 SVX_VER_JUSTIFY_TOP : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) ); 1491 ExecuteSlot( rReq, GetInterface() ); 1492 return; 1493 // APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_TOP ); 1494 //break; 1495 1496 case SID_ALIGNBOTTOM: 1497 rReq.SetSlot( SID_V_ALIGNCELL ); 1498 rReq.AppendItem( SvxVerJustifyItem( 1499 !pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_BOTTOM) ? 1500 SVX_VER_JUSTIFY_BOTTOM : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) ); 1501 ExecuteSlot( rReq, GetInterface() ); 1502 return; 1503 // APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_BOTTOM ); 1504 //break; 1505 1506 case SID_ALIGNCENTERVER: 1507 rReq.SetSlot( SID_V_ALIGNCELL ); 1508 rReq.AppendItem( SvxVerJustifyItem( 1509 !pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_CENTER) ? 1510 SVX_VER_JUSTIFY_CENTER : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) ); 1511 ExecuteSlot( rReq, GetInterface() ); 1512 return; 1513 // APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_CENTER ); 1514 //break; 1515 1516 default: 1517 break; 1518 } 1519 1520 } 1521 1522 rBindings.Update(); 1523 // rReq.Done(); 1524 1525 if( pNewSet ) 1526 { 1527 rReq.Done( *pNewSet ); 1528 delete pNewSet; 1529 } 1530 else 1531 { 1532 rReq.Done(); 1533 } 1534 1535 } 1536 1537 #undef APPLY_HOR_JUSTIFY 1538 #undef APPLY_VER_JUSTIFY 1539 1540 //------------------------------------------------------------------ 1541 1542 void ScFormatShell::ExecuteAttr( SfxRequest& rReq ) 1543 { 1544 ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 1545 SfxBindings& rBindings = pViewData->GetBindings(); 1546 const SfxItemSet* pNewAttrs = rReq.GetArgs(); 1547 1548 pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox 1549 1550 if ( !pNewAttrs ) 1551 { 1552 sal_uInt16 nSlot = rReq.GetSlot(); 1553 1554 switch ( nSlot ) 1555 { 1556 case SID_ATTR_CHAR_FONT: 1557 case SID_ATTR_CHAR_FONTHEIGHT: 1558 pTabViewShell->ExecuteCellFormatDlg( rReq, TP_FONT ); // wenn ToolBar vertikal 1559 break; 1560 1561 case SID_ATTR_ALIGN_LINEBREAK: // ohne Parameter als Toggle 1562 { 1563 const ScPatternAttr* pAttrs = pTabViewShell->GetSelectionPattern(); 1564 sal_Bool bOld = ((const SfxBoolItem&)pAttrs->GetItem(ATTR_LINEBREAK)).GetValue(); 1565 SfxBoolItem aBreakItem( ATTR_LINEBREAK, !bOld ); 1566 pTabViewShell->ApplyAttr( aBreakItem ); 1567 1568 SfxAllItemSet aNewSet( GetPool() ); 1569 aNewSet.Put( aBreakItem,aBreakItem.Which() ); 1570 rReq.Done( aNewSet ); 1571 1572 rBindings.Invalidate( nSlot ); 1573 } 1574 break; 1575 1576 case SID_BACKGROUND_COLOR: 1577 { 1578 // SID_BACKGROUND_COLOR without arguments -> set transparent background 1579 1580 SvxBrushItem aBrushItem( (const SvxBrushItem&) 1581 pTabViewShell->GetSelectionPattern()-> 1582 GetItem( ATTR_BACKGROUND ) ); 1583 1584 aBrushItem.SetColor( COL_TRANSPARENT ); 1585 1586 pTabViewShell->ApplyAttr( aBrushItem ); 1587 } 1588 break; 1589 } 1590 } 1591 else 1592 { 1593 sal_uInt16 nSlot = rReq.GetSlot(); 1594 1595 switch ( nSlot ) 1596 { 1597 case SID_ATTR_CHAR_OVERLINE: 1598 case SID_ATTR_CHAR_STRIKEOUT: 1599 case SID_ATTR_ALIGN_LINEBREAK: 1600 case SID_ATTR_CHAR_COLOR: 1601 case SID_ATTR_CHAR_CONTOUR: 1602 case SID_ATTR_CHAR_SHADOWED: 1603 case SID_ATTR_CHAR_RELIEF: 1604 case SID_SCATTR_PROTECTION : 1605 pTabViewShell->ApplyAttr( pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich( nSlot ) ) ); 1606 rBindings.Invalidate( nSlot ); 1607 rBindings.Update( nSlot ); 1608 break; 1609 1610 case SID_ATTR_CHAR_FONT: 1611 case SID_ATTR_CHAR_FONTHEIGHT: 1612 { 1613 // #i78017 establish the same behaviour as in Writer 1614 sal_uInt8 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX; 1615 if (nSlot == SID_ATTR_CHAR_FONT) 1616 nScript = pTabViewShell->GetSelectionScriptType(); 1617 1618 SfxItemPool& rPool = GetPool(); 1619 SvxScriptSetItem aSetItem( nSlot, rPool ); 1620 sal_uInt16 nWhich = rPool.GetWhich( nSlot ); 1621 aSetItem.PutItemForScriptType( nScript, pNewAttrs->Get( nWhich ) ); 1622 1623 pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() ); 1624 1625 rBindings.Invalidate( nSlot ); 1626 rBindings.Update( nSlot ); 1627 } 1628 break; 1629 1630 case SID_FRAME_LINESTYLE: 1631 { 1632 // Default-Linie aktualisieren 1633 const SvxBorderLine* pLine = 1634 ((const SvxLineItem&) 1635 pNewAttrs->Get( SID_FRAME_LINESTYLE )). 1636 GetLine(); 1637 1638 if ( pLine ) 1639 { 1640 SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine(); 1641 1642 if ( pDefLine ) 1643 { 1644 pDefLine->SetOutWidth( pLine->GetOutWidth() ); 1645 pDefLine->SetInWidth ( pLine->GetInWidth() ); 1646 pDefLine->SetDistance( pLine->GetDistance() ); 1647 pTabViewShell->SetSelectionFrameLines( pDefLine, sal_False ); 1648 } 1649 else 1650 { 1651 pTabViewShell->SetDefaultFrameLine( pLine ); 1652 pTabViewShell->GetDefaultFrameLine()->SetColor( COL_BLACK ); 1653 pTabViewShell->SetSelectionFrameLines( pLine, sal_False ); 1654 } 1655 } 1656 else 1657 { 1658 Color aColorBlack( COL_BLACK ); 1659 SvxBorderLine aDefLine( &aColorBlack, 20, 0, 0 ); 1660 pTabViewShell->SetDefaultFrameLine( &aDefLine ); 1661 pTabViewShell->SetSelectionFrameLines( NULL, sal_False ); 1662 } 1663 } 1664 break; 1665 1666 case SID_FRAME_LINECOLOR: 1667 { 1668 SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine(); 1669 const Color& rColor = ((const SvxColorItem&) 1670 pNewAttrs->Get( SID_FRAME_LINECOLOR )). 1671 GetValue(); 1672 1673 // Default-Linie aktualisieren 1674 if ( pDefLine ) 1675 { 1676 pDefLine->SetColor( rColor ); 1677 pTabViewShell->SetSelectionFrameLines( pDefLine, sal_True ); 1678 } 1679 else 1680 { 1681 SvxBorderLine aDefLine( &rColor, 20, 0, 0 ); 1682 pTabViewShell->SetDefaultFrameLine( &aDefLine ); 1683 pTabViewShell->SetSelectionFrameLines( &aDefLine, sal_False ); 1684 } 1685 } 1686 break; 1687 1688 case SID_ATTR_BORDER_OUTER: 1689 case SID_ATTR_BORDER: 1690 { 1691 SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine(); 1692 const ScPatternAttr* pOldAttrs = pTabViewShell->GetSelectionPattern(); 1693 ScDocument* pDoc = GetViewData()->GetDocument(); 1694 SfxItemSet* pOldSet = 1695 new SfxItemSet( 1696 *(pDoc->GetPool()), 1697 ATTR_PATTERN_START, 1698 ATTR_PATTERN_END ); 1699 SfxItemSet* pNewSet = 1700 new SfxItemSet( 1701 *(pDoc->GetPool()), 1702 ATTR_PATTERN_START, 1703 ATTR_PATTERN_END ); 1704 const SfxPoolItem& rBorderAttr = 1705 pOldAttrs->GetItemSet(). 1706 Get( ATTR_BORDER ); 1707 1708 // Border-Items vom Controller auswerten: 1709 const SfxPoolItem* pItem = 0; 1710 1711 if ( pNewAttrs->GetItemState( ATTR_BORDER, sal_True, &pItem ) 1712 == SFX_ITEM_SET ) 1713 { 1714 // #100959# The SvxFrameToolBoxControl toolbox controller uses a default 1715 // SvxBorderLine (all widths 0) to mark the lines that should be set. 1716 // Macro recording uses a SvxBoxItem with the real values (OutWidth > 0) 1717 // or NULL pointers for no lines. 1718 // -> Substitute existing lines with pDefLine only if widths are 0. 1719 SvxBoxItem aBoxItem ( *(const SvxBoxItem*)pItem ); 1720 if ( aBoxItem.GetTop() && aBoxItem.GetTop()->GetOutWidth() == 0 ) 1721 aBoxItem.SetLine( pDefLine, BOX_LINE_TOP ); 1722 if ( aBoxItem.GetBottom() && aBoxItem.GetBottom()->GetOutWidth() == 0 ) 1723 aBoxItem.SetLine( pDefLine, BOX_LINE_BOTTOM ); 1724 if ( aBoxItem.GetLeft() && aBoxItem.GetLeft()->GetOutWidth() == 0 ) 1725 aBoxItem.SetLine( pDefLine, BOX_LINE_LEFT ); 1726 if ( aBoxItem.GetRight() && aBoxItem.GetRight()->GetOutWidth() == 0 ) 1727 aBoxItem.SetLine( pDefLine, BOX_LINE_RIGHT ); 1728 pNewSet->Put( aBoxItem ); 1729 rReq.AppendItem( aBoxItem ); 1730 } 1731 1732 if ( pNewAttrs->GetItemState( ATTR_BORDER_INNER, sal_True, &pItem ) 1733 == SFX_ITEM_SET ) 1734 { 1735 SvxBoxInfoItem aBoxInfoItem( *(const SvxBoxInfoItem*)pItem ); 1736 if ( aBoxInfoItem.GetHori() && aBoxInfoItem.GetHori()->GetOutWidth() == 0 ) 1737 aBoxInfoItem.SetLine( pDefLine, BOXINFO_LINE_HORI ); 1738 if ( aBoxInfoItem.GetVert() && aBoxInfoItem.GetVert()->GetOutWidth() == 0 ) 1739 aBoxInfoItem.SetLine( pDefLine, BOXINFO_LINE_VERT ); 1740 pNewSet->Put( aBoxInfoItem ); 1741 rReq.AppendItem( aBoxInfoItem ); 1742 } 1743 else 1744 { 1745 SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER ); 1746 aBoxInfoItem.SetLine( NULL, BOXINFO_LINE_HORI ); 1747 aBoxInfoItem.SetLine( NULL, BOXINFO_LINE_VERT ); 1748 pNewSet->Put( aBoxInfoItem ); 1749 } 1750 1751 pOldSet->Put( rBorderAttr ); 1752 pTabViewShell->ApplyAttributes( pNewSet, pOldSet ); 1753 1754 delete pOldSet; 1755 delete pNewSet; 1756 } 1757 break; 1758 1759 case SID_ATTR_BORDER_DIAG_TLBR: 1760 case SID_ATTR_BORDER_DIAG_BLTR: 1761 { 1762 // ScDocument* pDoc = GetViewData()->GetDocument(); 1763 const ScPatternAttr* pOldAttrs = pTabViewShell->GetSelectionPattern(); 1764 SfxItemSet* pOldSet = new SfxItemSet(pOldAttrs->GetItemSet()); 1765 SfxItemSet* pNewSet = new SfxItemSet(pOldAttrs->GetItemSet()); 1766 const SfxPoolItem* pItem = 0; 1767 1768 if(SID_ATTR_BORDER_DIAG_TLBR == nSlot) 1769 { 1770 if(SFX_ITEM_SET == pNewAttrs->GetItemState(ATTR_BORDER_TLBR, true, &pItem)) 1771 { 1772 SvxLineItem aItem(ATTR_BORDER_TLBR); 1773 aItem.SetLine(((const SvxLineItem&)pNewAttrs->Get(ATTR_BORDER_TLBR)).GetLine()); 1774 pNewSet->Put(aItem); 1775 rReq.AppendItem(aItem); 1776 pTabViewShell->ApplyAttributes(pNewSet, pOldSet); 1777 } 1778 } 1779 else // if( nSlot == SID_ATTR_BORDER_DIAG_BLTR ) 1780 { 1781 if(SFX_ITEM_SET == pNewAttrs->GetItemState(ATTR_BORDER_BLTR, true, &pItem )) 1782 { 1783 SvxLineItem aItem(ATTR_BORDER_BLTR); 1784 aItem.SetLine(((const SvxLineItem&)pNewAttrs->Get(ATTR_BORDER_BLTR)).GetLine()); 1785 pNewSet->Put(aItem); 1786 rReq.AppendItem(aItem); 1787 pTabViewShell->ApplyAttributes(pNewSet, pOldSet); 1788 } 1789 } 1790 1791 delete pOldSet; 1792 delete pNewSet; 1793 rBindings.Invalidate(nSlot); 1794 } 1795 break; 1796 1797 // ATTR_BACKGROUND (=SID_ATTR_BRUSH) muss ueber zwei IDs 1798 // gesetzt werden: 1799 case SID_BACKGROUND_COLOR: 1800 { 1801 const SvxColorItem rNewColorItem = (const SvxColorItem&) 1802 pNewAttrs->Get( SID_BACKGROUND_COLOR ); 1803 1804 SvxBrushItem aBrushItem( (const SvxBrushItem&) 1805 pTabViewShell->GetSelectionPattern()-> 1806 GetItem( ATTR_BACKGROUND ) ); 1807 1808 aBrushItem.SetColor( rNewColorItem.GetValue() ); 1809 1810 pTabViewShell->ApplyAttr( aBrushItem ); 1811 } 1812 break; 1813 1814 case SID_ATTR_BRUSH: 1815 { 1816 SvxBrushItem aBrushItem( (const SvxBrushItem&) 1817 pTabViewShell->GetSelectionPattern()-> 1818 GetItem( ATTR_BACKGROUND ) ); 1819 const SvxBrushItem& rNewBrushItem = (const SvxBrushItem&) 1820 pNewAttrs->Get( GetPool().GetWhich(nSlot) ); 1821 aBrushItem.SetColor(rNewBrushItem.GetColor()); 1822 pTabViewShell->ApplyAttr( aBrushItem ); 1823 } 1824 break; 1825 1826 case SID_ATTR_BORDER_SHADOW: 1827 { 1828 const SvxShadowItem& rNewShadowItem = (const SvxShadowItem&) 1829 pNewAttrs->Get( ATTR_SHADOW ); 1830 pTabViewShell->ApplyAttr( rNewShadowItem ); 1831 } 1832 break; 1833 1834 default: 1835 break; 1836 } 1837 1838 if( ! rReq.IsAPI() ) 1839 if( ! rReq.IsDone() ) 1840 rReq.Done(); 1841 } 1842 } 1843 1844 void ScFormatShell::GetAttrState( SfxItemSet& rSet ) 1845 { 1846 ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 1847 const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); 1848 // const SvxBorderLine* pLine = pTabViewShell->GetDefaultFrameLine(); 1849 const SvxBrushItem& rBrushItem = (const SvxBrushItem&)rAttrSet.Get( ATTR_BACKGROUND ); 1850 SfxWhichIter aIter( rSet ); 1851 sal_uInt16 nWhich = aIter.FirstWhich(); 1852 1853 rSet.Put( rAttrSet, sal_False ); 1854 1855 // choose font info according to selection script type 1856 sal_uInt8 nScript = 0; // GetSelectionScriptType never returns 0 1857 if ( rSet.GetItemState( ATTR_FONT ) != SFX_ITEM_UNKNOWN ) 1858 { 1859 if (!nScript) nScript = pTabViewShell->GetSelectionScriptType(); 1860 ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT, nScript ); 1861 } 1862 if ( rSet.GetItemState( ATTR_FONT_HEIGHT ) != SFX_ITEM_UNKNOWN ) 1863 { 1864 if (!nScript) nScript = pTabViewShell->GetSelectionScriptType(); 1865 ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_HEIGHT, nScript ); 1866 } 1867 1868 while ( nWhich ) 1869 { 1870 switch(nWhich) 1871 { 1872 case SID_BACKGROUND_COLOR: 1873 { 1874 rSet.Put( SvxColorItem( rBrushItem.GetColor(), SID_BACKGROUND_COLOR ) ); 1875 1876 if(SFX_ITEM_DONTCARE == rAttrSet.GetItemState(ATTR_BACKGROUND)) 1877 { 1878 rSet.InvalidateItem(SID_BACKGROUND_COLOR); 1879 } 1880 } 1881 break; 1882 case SID_FRAME_LINESTYLE: 1883 case SID_FRAME_LINECOLOR: 1884 { 1885 // handled together because both need the cell border information for decisions 1886 // rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR ) ); 1887 Color aCol = 0; 1888 // sal_uInt16 nOut = 0, nIn = 0, nDis = 0; 1889 SvxBorderLine aLine(0,0,0,0); 1890 bool bCol = 0; 1891 bool bColDisable = 0, bStyleDisable = 0; 1892 SvxBoxItem aBoxItem(ATTR_BORDER); 1893 SvxBoxInfoItem aInfoItem(ATTR_BORDER_INNER); 1894 1895 pTabViewShell->GetSelectionFrame(aBoxItem, aInfoItem); 1896 1897 if( aBoxItem.GetTop() ) 1898 { 1899 bCol = 1; 1900 aCol = aBoxItem.GetTop()->GetColor() ; 1901 aLine.SetColor(aCol); 1902 aLine.SetOutWidth( aBoxItem.GetTop()->GetOutWidth()); 1903 aLine.SetInWidth( aBoxItem.GetTop()->GetInWidth()); 1904 aLine.SetDistance( aBoxItem.GetTop()->GetDistance()); 1905 } 1906 1907 if( aBoxItem.GetBottom() ) 1908 { 1909 if(bCol == 0) 1910 { 1911 bCol = 1; 1912 aCol = aBoxItem.GetBottom()->GetColor() ; 1913 aLine.SetColor(aCol); 1914 aLine.SetOutWidth( aBoxItem.GetBottom()->GetOutWidth()); 1915 aLine.SetInWidth( aBoxItem.GetBottom()->GetInWidth()); 1916 aLine.SetDistance( aBoxItem.GetBottom()->GetDistance()); 1917 } 1918 else 1919 { 1920 if(aCol != aBoxItem.GetBottom()->GetColor() ) 1921 bColDisable = 1; 1922 if(!( aLine == *(aBoxItem.GetBottom())) ) 1923 bStyleDisable = 1; 1924 } 1925 } 1926 1927 if( aBoxItem.GetLeft() ) 1928 { 1929 if(bCol == 0) 1930 { 1931 bCol = 1; 1932 aCol = aBoxItem.GetLeft()->GetColor() ; 1933 aLine.SetColor(aCol); 1934 aLine.SetOutWidth( aBoxItem.GetLeft()->GetOutWidth()); 1935 aLine.SetInWidth( aBoxItem.GetLeft()->GetInWidth()); 1936 aLine.SetDistance( aBoxItem.GetLeft()->GetDistance()); 1937 } 1938 else 1939 { 1940 if(aCol != aBoxItem.GetLeft()->GetColor() ) 1941 bColDisable = 1; 1942 if(!( aLine == *(aBoxItem.GetLeft())) ) 1943 bStyleDisable = 1; 1944 } 1945 } 1946 1947 if( aBoxItem.GetRight() ) 1948 { 1949 if(bCol == 0) 1950 { 1951 bCol = 1; 1952 aCol = aBoxItem.GetRight()->GetColor() ; 1953 aLine.SetColor(aCol); 1954 aLine.SetOutWidth( aBoxItem.GetRight()->GetOutWidth()); 1955 aLine.SetInWidth( aBoxItem.GetRight()->GetInWidth()); 1956 aLine.SetDistance( aBoxItem.GetRight()->GetDistance()); 1957 } 1958 else 1959 { 1960 if(aCol != aBoxItem.GetRight()->GetColor() ) 1961 bColDisable = 1; 1962 if(!( aLine == *(aBoxItem.GetRight())) ) 1963 bStyleDisable = 1; 1964 } 1965 } 1966 1967 if( aInfoItem.GetVert()) 1968 { 1969 if(bCol == 0) 1970 { 1971 bCol = 1; 1972 aCol = aInfoItem.GetVert()->GetColor() ; 1973 aLine.SetColor(aCol); 1974 aLine.SetOutWidth( aInfoItem.GetVert()->GetOutWidth()); 1975 aLine.SetInWidth( aInfoItem.GetVert()->GetInWidth()); 1976 aLine.SetDistance( aInfoItem.GetVert()->GetDistance()); 1977 } 1978 else 1979 { 1980 if(aCol != aInfoItem.GetVert()->GetColor() ) 1981 bColDisable = 1; 1982 if(!( aLine == *(aInfoItem.GetVert())) ) 1983 bStyleDisable = 1; 1984 } 1985 } 1986 1987 if( aInfoItem.GetHori()) 1988 { 1989 if(bCol == 0) 1990 { 1991 bCol = 1; 1992 aCol = aInfoItem.GetHori()->GetColor() ; 1993 aLine.SetColor(aCol); 1994 aLine.SetOutWidth( aInfoItem.GetHori()->GetOutWidth()); 1995 aLine.SetInWidth( aInfoItem.GetHori()->GetInWidth()); 1996 aLine.SetDistance( aInfoItem.GetHori()->GetDistance()); 1997 } 1998 else 1999 { 2000 if(aCol != aInfoItem.GetHori()->GetColor() ) 2001 bColDisable = 1; 2002 if(!( aLine == *(aInfoItem.GetHori())) ) 2003 bStyleDisable = 1; 2004 } 2005 } 2006 2007 if( !aInfoItem.IsValid( VALID_VERT ) 2008 || !aInfoItem.IsValid( VALID_HORI ) 2009 || !aInfoItem.IsValid( VALID_LEFT ) 2010 || !aInfoItem.IsValid( VALID_RIGHT ) 2011 || !aInfoItem.IsValid( VALID_TOP ) 2012 || !aInfoItem.IsValid( VALID_BOTTOM ) ) 2013 { 2014 bColDisable = 1; 2015 bStyleDisable = 1; 2016 } 2017 2018 if(SID_FRAME_LINECOLOR == nWhich) 2019 { 2020 if(bColDisable) // if different lines have differernt colors 2021 { 2022 aCol = COL_TRANSPARENT; 2023 rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) ); 2024 rSet.InvalidateItem(SID_FRAME_LINECOLOR); 2025 } 2026 else if( bCol == 0 && bColDisable == 0) // if no line available 2027 { 2028 aCol = COL_AUTO; 2029 rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) ); 2030 } 2031 else 2032 rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) ); 2033 } 2034 else // if( nWhich == SID_FRAME_LINESTYLE) 2035 { 2036 if(bStyleDisable) // if have several lines but don't have same style 2037 { 2038 aLine.SetOutWidth( 1 ); 2039 aLine.SetInWidth( 0 ); 2040 aLine.SetDistance( 0 ); 2041 SvxLineItem aItem(SID_FRAME_LINESTYLE); 2042 aItem.SetLine(&aLine); 2043 rSet.Put( aItem ); 2044 rSet.InvalidateItem(SID_FRAME_LINESTYLE); 2045 } 2046 else // all the lines have same style or no line availavle, use initial value (0,0,0,0) 2047 { 2048 SvxLineItem aItem(SID_FRAME_LINESTYLE); 2049 aItem.SetLine(&aLine); 2050 rSet.Put( aItem ); 2051 } 2052 } 2053 } 2054 break; 2055 case SID_ATTR_BRUSH: 2056 { 2057 rSet.Put( rBrushItem, GetPool().GetWhich(nWhich) ); 2058 } 2059 break; 2060 /* case SID_ATTR_ALIGN_LINEBREAK: 2061 { 2062 const SfxBoolItem& rBreakItem = (const SfxBoolItem&)rAttrSet.Get( ATTR_LINEBREAK ); 2063 rSet.Put( rBreakItem, GetPool().GetWhich(nWhich) ); 2064 } 2065 break; 2066 */ 2067 } 2068 nWhich = aIter.NextWhich(); 2069 } 2070 2071 if(nWhich) 2072 { 2073 // stuff for sidebar panels 2074 Invalidate(SID_ATTR_ALIGN_DEGREES); 2075 Invalidate(SID_ATTR_ALIGN_STACKED); 2076 } 2077 } 2078 2079 //------------------------------------------------------------------ 2080 2081 void ScFormatShell::GetTextAttrState( SfxItemSet& rSet ) 2082 { 2083 ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 2084 const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); 2085 rSet.Put( rAttrSet, sal_False ); // ItemStates mitkopieren 2086 2087 // choose font info according to selection script type 2088 sal_uInt8 nScript = 0; // GetSelectionScriptType never returns 0 2089 if ( rSet.GetItemState( ATTR_FONT_WEIGHT ) != SFX_ITEM_UNKNOWN ) 2090 { 2091 if (!nScript) nScript = pTabViewShell->GetSelectionScriptType(); 2092 ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_WEIGHT, nScript ); 2093 } 2094 if ( rSet.GetItemState( ATTR_FONT_POSTURE ) != SFX_ITEM_UNKNOWN ) 2095 { 2096 if (!nScript) nScript = pTabViewShell->GetSelectionScriptType(); 2097 ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_POSTURE, nScript ); 2098 } 2099 2100 SfxItemState eState; 2101 // const SfxPoolItem* pItem; 2102 2103 //-------------------------------------------------------------------- 2104 // eigene Kontrolle ueber RadioButton-Funktionalitaet: 2105 //-------------------------------------------------------------------- 2106 // Unterstreichung 2107 //------------------------ 2108 2109 eState = rAttrSet.GetItemState( ATTR_FONT_UNDERLINE, sal_True ); 2110 if ( eState == SFX_ITEM_DONTCARE ) 2111 { 2112 rSet.InvalidateItem( SID_ULINE_VAL_NONE ); 2113 rSet.InvalidateItem( SID_ULINE_VAL_SINGLE ); 2114 rSet.InvalidateItem( SID_ULINE_VAL_DOUBLE ); 2115 rSet.InvalidateItem( SID_ULINE_VAL_DOTTED ); 2116 } 2117 else 2118 { 2119 FontUnderline eUnderline = ((const SvxUnderlineItem&) 2120 rAttrSet.Get(ATTR_FONT_UNDERLINE)).GetLineStyle(); 2121 sal_uInt16 nId = SID_ULINE_VAL_NONE; 2122 switch (eUnderline) 2123 { 2124 case UNDERLINE_SINGLE: nId = SID_ULINE_VAL_SINGLE; break; 2125 case UNDERLINE_DOUBLE: nId = SID_ULINE_VAL_DOUBLE; break; 2126 case UNDERLINE_DOTTED: nId = SID_ULINE_VAL_DOTTED; break; 2127 default: 2128 break; 2129 } 2130 rSet.Put( SfxBoolItem( nId, sal_True ) ); 2131 } 2132 2133 //------------------------ 2134 // horizontale Ausrichtung 2135 //------------------------ 2136 2137 const SvxHorJustifyItem* pHorJustify = NULL; 2138 const SvxVerJustifyItem* pVerJustify = NULL; 2139 SvxCellHorJustify eHorJustify = SVX_HOR_JUSTIFY_STANDARD; 2140 SvxCellVerJustify eVerJustify = SVX_VER_JUSTIFY_STANDARD; 2141 sal_uInt16 nWhich = 0; 2142 sal_Bool bJustifyStd = sal_False; 2143 SfxBoolItem aBoolItem ( 0, sal_True ); 2144 2145 eState = rAttrSet.GetItemState( ATTR_HOR_JUSTIFY, sal_True, 2146 (const SfxPoolItem**)&pHorJustify ); 2147 switch ( eState ) 2148 { 2149 case SFX_ITEM_SET: 2150 { 2151 eHorJustify = SvxCellHorJustify( pHorJustify->GetValue() ); 2152 2153 switch ( SvxCellHorJustify( pHorJustify->GetValue() ) ) 2154 { 2155 case SVX_HOR_JUSTIFY_STANDARD: 2156 break; 2157 2158 case SVX_HOR_JUSTIFY_LEFT: 2159 nWhich = SID_ALIGNLEFT; 2160 break; 2161 2162 case SVX_HOR_JUSTIFY_RIGHT: 2163 nWhich = SID_ALIGNRIGHT; 2164 break; 2165 2166 case SVX_HOR_JUSTIFY_CENTER: 2167 nWhich = SID_ALIGNCENTERHOR; 2168 break; 2169 2170 case SVX_HOR_JUSTIFY_BLOCK: 2171 nWhich = SID_ALIGNBLOCK; 2172 break; 2173 2174 case SVX_HOR_JUSTIFY_REPEAT: 2175 default: 2176 bJustifyStd = sal_True; 2177 break; 2178 } 2179 } 2180 break; 2181 2182 case SFX_ITEM_DONTCARE: 2183 rSet.InvalidateItem( SID_ALIGNLEFT ); 2184 rSet.InvalidateItem( SID_ALIGNRIGHT ); 2185 rSet.InvalidateItem( SID_ALIGNCENTERHOR ); 2186 rSet.InvalidateItem( SID_ALIGNBLOCK ); 2187 break; 2188 2189 default: 2190 bJustifyStd = sal_True; 2191 break; 2192 } 2193 2194 if ( nWhich ) 2195 { 2196 aBoolItem.SetWhich( nWhich ); 2197 rSet.Put( aBoolItem ); 2198 } 2199 else if ( bJustifyStd ) 2200 { 2201 aBoolItem.SetValue( sal_False ); 2202 aBoolItem.SetWhich( SID_ALIGNLEFT ); rSet.Put( aBoolItem ); 2203 aBoolItem.SetWhich( SID_ALIGNRIGHT ); rSet.Put( aBoolItem ); 2204 aBoolItem.SetWhich( SID_ALIGNCENTERHOR ); rSet.Put( aBoolItem ); 2205 aBoolItem.SetWhich( SID_ALIGNBLOCK ); rSet.Put( aBoolItem ); 2206 bJustifyStd = sal_False; 2207 } 2208 2209 //------------------------ 2210 // vertikale Ausrichtung 2211 //------------------------ 2212 2213 nWhich = 0; 2214 aBoolItem.SetValue( sal_True ); 2215 2216 eState = rAttrSet.GetItemState( ATTR_VER_JUSTIFY, sal_True, 2217 (const SfxPoolItem**)&pVerJustify ); 2218 2219 switch ( eState ) 2220 { 2221 case SFX_ITEM_SET: 2222 { 2223 eVerJustify = SvxCellVerJustify( pVerJustify->GetValue() ); 2224 2225 switch ( eVerJustify ) 2226 { 2227 case SVX_VER_JUSTIFY_TOP: 2228 nWhich = SID_ALIGNTOP; 2229 break; 2230 2231 case SVX_VER_JUSTIFY_BOTTOM: 2232 nWhich = SID_ALIGNBOTTOM; 2233 break; 2234 2235 case SVX_VER_JUSTIFY_CENTER: 2236 nWhich = SID_ALIGNCENTERVER; 2237 break; 2238 2239 case SVX_VER_JUSTIFY_STANDARD: 2240 default: 2241 bJustifyStd = sal_True; 2242 break; 2243 } 2244 } 2245 break; 2246 2247 case SFX_ITEM_DONTCARE: 2248 rSet.InvalidateItem( SID_ALIGNTOP ); 2249 rSet.InvalidateItem( SID_ALIGNBOTTOM ); 2250 rSet.InvalidateItem( SID_ALIGNCENTERVER ); 2251 break; 2252 2253 default: 2254 bJustifyStd = sal_True; 2255 break; 2256 } 2257 2258 if ( nWhich ) 2259 { 2260 aBoolItem.SetWhich( nWhich ); 2261 rSet.Put( aBoolItem ); 2262 } 2263 else if ( bJustifyStd ) 2264 { 2265 aBoolItem.SetValue( sal_False ); 2266 aBoolItem.SetWhich( SID_ALIGNTOP ); rSet.Put( aBoolItem ); 2267 aBoolItem.SetWhich( SID_ALIGNBOTTOM ); rSet.Put( aBoolItem ); 2268 aBoolItem.SetWhich( SID_ALIGNCENTERVER ); rSet.Put( aBoolItem ); 2269 } 2270 } 2271 2272 2273 //------------------------------------------------------------------ 2274 2275 void ScFormatShell::GetBorderState( SfxItemSet& rSet ) 2276 { 2277 ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 2278 SvxBoxItem aBoxItem( ATTR_BORDER ); 2279 SvxBoxInfoItem aInfoItem( ATTR_BORDER_INNER ); 2280 2281 pTabViewShell->GetSelectionFrame( aBoxItem, aInfoItem ); 2282 2283 if ( rSet.GetItemState( ATTR_BORDER ) != SFX_ITEM_UNKNOWN ) 2284 rSet.Put( aBoxItem ); 2285 if ( rSet.GetItemState( ATTR_BORDER_INNER ) != SFX_ITEM_UNKNOWN ) 2286 rSet.Put( aInfoItem ); 2287 } 2288 2289 //------------------------------------------------------------------ 2290 2291 void ScFormatShell::GetAlignState( SfxItemSet& rSet ) 2292 { 2293 ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 2294 const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); 2295 SfxWhichIter aIter(rSet); 2296 sal_uInt16 nWhich = aIter.FirstWhich(); 2297 2298 SvxCellHorJustify eHAlign = SVX_HOR_JUSTIFY_STANDARD; 2299 bool bHasHAlign = rAttrSet.GetItemState( ATTR_HOR_JUSTIFY ) != SFX_ITEM_DONTCARE; 2300 if( bHasHAlign ) 2301 eHAlign = (SvxCellHorJustify)((const SvxHorJustifyItem&) rAttrSet.Get( ATTR_HOR_JUSTIFY )).GetValue(); 2302 2303 SvxCellVerJustify eVAlign = SVX_VER_JUSTIFY_STANDARD; 2304 bool bHasVAlign = rAttrSet.GetItemState( ATTR_VER_JUSTIFY ) != SFX_ITEM_DONTCARE; 2305 if( bHasVAlign ) 2306 eVAlign = (SvxCellVerJustify)((const SvxVerJustifyItem&) rAttrSet.Get( ATTR_VER_JUSTIFY )).GetValue(); 2307 2308 while ( nWhich ) 2309 { 2310 switch ( nWhich ) 2311 { 2312 case SID_H_ALIGNCELL: 2313 if ( bHasHAlign ) 2314 rSet.Put( SvxHorJustifyItem( eHAlign, nWhich )); 2315 break; 2316 case SID_V_ALIGNCELL: 2317 if ( bHasVAlign ) 2318 rSet.Put( SvxVerJustifyItem( eVAlign, nWhich )); 2319 break; 2320 2321 // pseudo slots for Format menu 2322 case SID_ALIGN_ANY_HDEFAULT: 2323 case SID_ALIGN_ANY_LEFT: 2324 case SID_ALIGN_ANY_HCENTER: 2325 case SID_ALIGN_ANY_RIGHT: 2326 case SID_ALIGN_ANY_JUSTIFIED: 2327 rSet.Put( SfxBoolItem( nWhich, bHasHAlign && (eHAlign == lclConvertSlotToHAlign( nWhich )) ) ); 2328 break; 2329 case SID_ALIGN_ANY_VDEFAULT: 2330 case SID_ALIGN_ANY_TOP: 2331 case SID_ALIGN_ANY_VCENTER: 2332 case SID_ALIGN_ANY_BOTTOM: 2333 rSet.Put( SfxBoolItem( nWhich, bHasVAlign && (eVAlign == lclConvertSlotToVAlign( nWhich )) ) ); 2334 break; 2335 } 2336 nWhich = aIter.NextWhich(); 2337 } 2338 } 2339 2340 void ScFormatShell::GetNumFormatState( SfxItemSet& rSet ) 2341 { 2342 ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 2343 2344 // ScViewData* pViewData = GetViewData(); 2345 ScDocument* pDoc = pViewData->GetDocument(); 2346 2347 SfxWhichIter aIter(rSet); 2348 sal_uInt16 nWhich = aIter.FirstWhich(); 2349 while ( nWhich ) 2350 { 2351 switch ( nWhich ) 2352 { 2353 case SID_NUMBER_FORMAT: 2354 //{ 2355 // String aFormatCode; // bleibt leer, wenn dont-care 2356 // 2357 // const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); 2358 // if ( rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) != SFX_ITEM_DONTCARE ) 2359 // { 2360 // sal_uLong nNumberFormat = ((const SfxUInt32Item&)rAttrSet.Get( 2361 // ATTR_VALUE_FORMAT )).GetValue(); 2362 // 2363 // SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); 2364 // const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat ); 2365 // if ( pFormatEntry ) 2366 // aFormatCode = pFormatEntry->GetFormatstring(); 2367 // } 2368 // 2369 // rSet.Put( SfxStringItem( nWhich, aFormatCode ) ); 2370 //} 2371 2372 // symphony version with format interpretation 2373 { 2374 const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); 2375 2376 if(SFX_ITEM_DONTCARE != rAttrSet.GetItemState(ATTR_VALUE_FORMAT)) 2377 { 2378 SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); 2379 sal_uInt32 nNumberFormat = ((const SfxUInt32Item&)rAttrSet.Get(ATTR_VALUE_FORMAT)).GetValue(); 2380 sal_Bool bThousand(false); 2381 sal_Bool bNegRed(false); 2382 sal_uInt16 nPrecision(0); 2383 sal_uInt16 nLeadZeroes(0); 2384 2385 pFormatter->GetFormatSpecialInfo(nNumberFormat,bThousand, bNegRed, nPrecision, nLeadZeroes); 2386 String aFormat; 2387 static String sBreak = String::CreateFromAscii(","); 2388 const String sThousand = String::CreateFromInt32(bThousand); 2389 const String sNegRed = String::CreateFromInt32(bNegRed); 2390 const String sPrecision = String::CreateFromInt32(nPrecision); 2391 const String sLeadZeroes = String::CreateFromInt32(nLeadZeroes); 2392 2393 aFormat += sThousand; 2394 aFormat += sBreak; 2395 aFormat += sNegRed; 2396 aFormat += sBreak; 2397 aFormat += sPrecision; 2398 aFormat += sBreak; 2399 aFormat += sLeadZeroes; 2400 aFormat += sBreak; 2401 2402 rSet.Put(SfxStringItem(nWhich, aFormat)); 2403 } 2404 else 2405 { 2406 rSet.InvalidateItem( nWhich ); 2407 } 2408 } 2409 break; 2410 2411 case SID_NUMBER_TYPE_FORMAT: 2412 { 2413 sal_Int16 aFormatCode = -1; 2414 const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); 2415 if ( rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) >= SFX_ITEM_AVAILABLE ) //Modify for more robust 2416 { 2417 SvNumberFormatter* pFormatter = pDoc->GetFormatTable(); 2418 sal_uInt32 nNumberFormat = pTabViewShell->GetSelectionPattern()->GetNumberFormat( pFormatter ); 2419 const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat ); 2420 bool bStandard = false; 2421 2422 if ( pFormatEntry ) 2423 { 2424 aFormatCode = pFormatEntry->GetType(); 2425 bStandard = pFormatEntry->IsStandard(); 2426 } 2427 2428 switch(aFormatCode) 2429 { 2430 case NUMBERFORMAT_NUMBER: 2431 case NUMBERFORMAT_NUMBER| NUMBERFORMAT_DEFINED: 2432 //use format code and standard format code to judge whether it is General, 2433 //if (nNumberFormat == nStandardNumberFormat) 2434 if (bStandard) 2435 aFormatCode = 0; 2436 else 2437 aFormatCode = 1; 2438 break; 2439 case NUMBERFORMAT_PERCENT: 2440 case NUMBERFORMAT_PERCENT| NUMBERFORMAT_DEFINED: 2441 aFormatCode = 2; 2442 break; 2443 case NUMBERFORMAT_CURRENCY: 2444 case NUMBERFORMAT_CURRENCY| NUMBERFORMAT_DEFINED: 2445 aFormatCode = 3; 2446 break; 2447 case NUMBERFORMAT_DATE: 2448 case NUMBERFORMAT_DATE| NUMBERFORMAT_DEFINED: 2449 //Add 2450 case NUMBERFORMAT_DATETIME: 2451 case NUMBERFORMAT_DATETIME | NUMBERFORMAT_DEFINED: 2452 aFormatCode = 4; 2453 break; 2454 case NUMBERFORMAT_TIME: 2455 case NUMBERFORMAT_TIME| NUMBERFORMAT_DEFINED: 2456 aFormatCode = 5; 2457 break; 2458 case NUMBERFORMAT_SCIENTIFIC: 2459 case NUMBERFORMAT_SCIENTIFIC| NUMBERFORMAT_DEFINED: 2460 aFormatCode = 6; 2461 break; 2462 case NUMBERFORMAT_FRACTION: 2463 case NUMBERFORMAT_FRACTION| NUMBERFORMAT_DEFINED: 2464 aFormatCode = 7; 2465 break; 2466 case NUMBERFORMAT_LOGICAL: 2467 case NUMBERFORMAT_LOGICAL| NUMBERFORMAT_DEFINED: 2468 aFormatCode = 8; 2469 break; 2470 case NUMBERFORMAT_TEXT: 2471 case NUMBERFORMAT_TEXT| NUMBERFORMAT_DEFINED: 2472 aFormatCode = 9; 2473 break; 2474 default: 2475 aFormatCode = -1; //for more roburst 2476 } 2477 if( aFormatCode == -1 ) 2478 rSet.InvalidateItem( nWhich ); 2479 else 2480 rSet.Put( SfxInt16Item( nWhich, aFormatCode ) ); 2481 } 2482 else 2483 { 2484 rSet.InvalidateItem( nWhich ); 2485 } 2486 2487 } 2488 break; 2489 } 2490 nWhich = aIter.NextWhich(); 2491 } 2492 } 2493 2494 2495 void ScFormatShell::ExecuteTextDirection( SfxRequest& rReq ) 2496 { 2497 ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 2498 pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox 2499 if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) ) 2500 { 2501 SC_MOD()->InputEnterHandler(); 2502 pTabViewShell->UpdateInputHandler(); 2503 } 2504 2505 sal_uInt16 nSlot = rReq.GetSlot(); 2506 switch( nSlot ) 2507 { 2508 case SID_TEXTDIRECTION_LEFT_TO_RIGHT: 2509 case SID_TEXTDIRECTION_TOP_TO_BOTTOM: 2510 { 2511 sal_Bool bVert = (nSlot == SID_TEXTDIRECTION_TOP_TO_BOTTOM); 2512 ScPatternAttr aAttr( GetViewData()->GetDocument()->GetPool() ); 2513 SfxItemSet& rItemSet = aAttr.GetItemSet(); 2514 rItemSet.Put( SfxBoolItem( ATTR_STACKED, bVert ) ); 2515 rItemSet.Put( SfxBoolItem( ATTR_VERTICAL_ASIAN, bVert ) ); 2516 pTabViewShell->ApplySelectionPattern( aAttr ); 2517 pTabViewShell->AdjustBlockHeight(); 2518 } 2519 break; 2520 2521 case SID_ATTR_PARA_LEFT_TO_RIGHT: 2522 case SID_ATTR_PARA_RIGHT_TO_LEFT: 2523 { 2524 SvxFrameDirection eDirection = ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT ) ? 2525 FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP; 2526 pTabViewShell->ApplyAttr( SvxFrameDirectionItem( eDirection, ATTR_WRITINGDIR ) ); 2527 } 2528 break; 2529 } 2530 } 2531 2532 void ScFormatShell::GetTextDirectionState( SfxItemSet& rSet ) 2533 { 2534 ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 2535 const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet(); 2536 2537 sal_Bool bVertDontCare = 2538 (rAttrSet.GetItemState( ATTR_VERTICAL_ASIAN ) == SFX_ITEM_DONTCARE) || 2539 (rAttrSet.GetItemState( ATTR_STACKED ) == SFX_ITEM_DONTCARE); 2540 sal_Bool bLeftRight = !bVertDontCare && 2541 !((const SfxBoolItem&) rAttrSet.Get( ATTR_STACKED )).GetValue(); 2542 sal_Bool bTopBottom = !bVertDontCare && !bLeftRight && 2543 ((const SfxBoolItem&) rAttrSet.Get( ATTR_VERTICAL_ASIAN )).GetValue(); 2544 2545 sal_Bool bBidiDontCare = (rAttrSet.GetItemState( ATTR_WRITINGDIR ) == SFX_ITEM_DONTCARE); 2546 EEHorizontalTextDirection eBidiDir = EE_HTEXTDIR_DEFAULT; 2547 if ( !bBidiDontCare ) 2548 { 2549 SvxFrameDirection eCellDir = (SvxFrameDirection)((const SvxFrameDirectionItem&) 2550 rAttrSet.Get( ATTR_WRITINGDIR )).GetValue(); 2551 if ( eCellDir == FRMDIR_ENVIRONMENT ) 2552 eBidiDir = (EEHorizontalTextDirection)GetViewData()->GetDocument()-> 2553 GetEditTextDirection( GetViewData()->GetTabNo() ); 2554 else if ( eCellDir == FRMDIR_HORI_RIGHT_TOP ) 2555 eBidiDir = EE_HTEXTDIR_R2L; 2556 else 2557 eBidiDir = EE_HTEXTDIR_L2R; 2558 } 2559 2560 SvtLanguageOptions aLangOpt; 2561 sal_Bool bDisableCTLFont = !aLangOpt.IsCTLFontEnabled(); 2562 sal_Bool bDisableVerticalText = !aLangOpt.IsVerticalTextEnabled(); 2563 2564 SfxWhichIter aIter( rSet ); 2565 sal_uInt16 nWhich = aIter.FirstWhich(); 2566 while( nWhich ) 2567 { 2568 switch( nWhich ) 2569 { 2570 case SID_TEXTDIRECTION_LEFT_TO_RIGHT: 2571 case SID_TEXTDIRECTION_TOP_TO_BOTTOM: 2572 if ( bDisableVerticalText ) 2573 rSet.DisableItem( nWhich ); 2574 else 2575 { 2576 if( bVertDontCare ) 2577 rSet.InvalidateItem( nWhich ); 2578 else if ( nWhich == SID_TEXTDIRECTION_LEFT_TO_RIGHT ) 2579 rSet.Put( SfxBoolItem( nWhich, bLeftRight ) ); 2580 else 2581 rSet.Put( SfxBoolItem( nWhich, bTopBottom ) ); 2582 } 2583 break; 2584 2585 case SID_ATTR_PARA_LEFT_TO_RIGHT: 2586 case SID_ATTR_PARA_RIGHT_TO_LEFT: 2587 if ( bDisableCTLFont ) 2588 rSet.DisableItem( nWhich ); 2589 else 2590 { 2591 if ( bTopBottom ) 2592 rSet.DisableItem( nWhich ); 2593 else if ( bBidiDontCare ) 2594 rSet.InvalidateItem( nWhich ); 2595 else if ( nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT ) 2596 rSet.Put( SfxBoolItem( nWhich, eBidiDir == EE_HTEXTDIR_L2R ) ); 2597 else 2598 rSet.Put( SfxBoolItem( nWhich, eBidiDir == EE_HTEXTDIR_R2L ) ); 2599 } 2600 } 2601 nWhich = aIter.NextWhich(); 2602 } 2603 } 2604 2605 void ScFormatShell::ExecFormatPaintbrush( SfxRequest& rReq ) 2606 { 2607 ScViewFunc* pView = pViewData->GetView(); 2608 if ( pView->HasPaintBrush() ) 2609 { 2610 // cancel paintbrush mode 2611 pView->ResetBrushDocument(); 2612 } 2613 else 2614 { 2615 sal_Bool bLock = sal_False; 2616 const SfxItemSet *pArgs = rReq.GetArgs(); 2617 if( pArgs && pArgs->Count() >= 1 ) 2618 bLock = static_cast<const SfxBoolItem&>(pArgs->Get(SID_FORMATPAINTBRUSH)).GetValue(); 2619 2620 // in case of multi selection, deselect all and use the cursor position 2621 ScRange aDummy; 2622 if ( pViewData->GetSimpleArea(aDummy) != SC_MARK_SIMPLE ) 2623 pView->Unmark(); 2624 2625 ScDocument* pBrushDoc = new ScDocument( SCDOCMODE_CLIP ); 2626 pView->CopyToClip( pBrushDoc, sal_False, sal_True ); 2627 pView->SetBrushDocument( pBrushDoc, bLock ); 2628 } 2629 } 2630 2631 void ScFormatShell::StateFormatPaintbrush( SfxItemSet& rSet ) 2632 { 2633 if ( pViewData->HasEditView( pViewData->GetActivePart() ) ) 2634 rSet.DisableItem( SID_FORMATPAINTBRUSH ); 2635 else 2636 rSet.Put( SfxBoolItem( SID_FORMATPAINTBRUSH, pViewData->GetView()->HasPaintBrush() ) ); 2637 } 2638 2639 void ScFormatShell::ExecViewOptions( SfxRequest& rReq ) 2640 { 2641 ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 2642 SfxBindings& rBindings = pViewData->GetBindings(); 2643 const SfxItemSet* pNewAttrs = rReq.GetArgs(); 2644 2645 if ( pNewAttrs ) 2646 { 2647 sal_uInt16 nSlot = rReq.GetSlot(); 2648 2649 if( nSlot == SID_SCGRIDSHOW) 2650 { 2651 2652 ScViewData* pViewData = pTabViewShell->GetViewData(); 2653 const ScViewOptions& rOldOpt = pViewData->GetOptions(); 2654 ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current()); 2655 bool bState = ((const SfxBoolItem &)pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich( nSlot ) )).GetValue(); 2656 2657 if ( (bool)rOldOpt.GetOption( VOPT_GRID ) != bState) 2658 { 2659 ScViewOptions rNewOpt(rOldOpt); 2660 rNewOpt.SetOption( VOPT_GRID, bState); 2661 pViewData->SetOptions( rNewOpt ); 2662 pViewData->GetDocument()->SetViewOptions( rNewOpt ); 2663 pDocSh->SetDocumentModified(); 2664 //add , write the change to sc view config 2665 ScModule* pScMod = SC_MOD(); 2666 pScMod->SetViewOptions( rNewOpt ); 2667 //add end 2668 rBindings.Invalidate( nSlot ); 2669 } 2670 } 2671 } 2672 2673 } 2674 2675 void ScFormatShell::GetViewOptions( SfxItemSet& rSet ) 2676 { 2677 ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); 2678 if( pTabViewShell ) 2679 { 2680 ScViewOptions aViewOpt = pTabViewShell->GetViewData()->GetOptions(); 2681 rSet.ClearItem(SID_SCGRIDSHOW); 2682 SfxBoolItem aItem( SID_SCGRIDSHOW, aViewOpt.GetOption( VOPT_GRID ) ); 2683 rSet.Put(aItem); 2684 } 2685 } 2686 2687 // eof 2688