1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svx.hxx" 30 #include <editeng/eeitem.hxx> 31 32 #include "svdibrow.hxx" 33 34 #ifndef _STDLIB_H 35 #include <stdlib.h> 36 #define _STDLIB_H 37 #endif 38 39 #include "svx/svditext.hxx" 40 #include <editeng/flditem.hxx> 41 #include <editeng/editdata.hxx> 42 #include <svx/svdpool.hxx> 43 #include <svx/svdattr.hxx> 44 #include <svx/svdattrx.hxx> 45 #include <svx/svdview.hxx> 46 #include <svx/xenum.hxx> 47 #include <svx/xlineit0.hxx> 48 #include <svx/xlnstwit.hxx> 49 #include <svx/xlnedwit.hxx> 50 #include <svx/xfillit0.hxx> 51 #include <svx/xflbmtit.hxx> 52 #include <svx/xtextit0.hxx> 53 #include <svx/xflbstit.hxx> 54 #include <svx/xflbtoxy.hxx> 55 #include <svx/xftshit.hxx> 56 #include <editeng/colritem.hxx> 57 58 59 #include "editeng/fontitem.hxx" 60 #include <editeng/fhgtitem.hxx> 61 62 #include <editeng/charscaleitem.hxx> 63 #include <svl/whiter.hxx> 64 #include <svl/flagitem.hxx> 65 #include <svl/ptitem.hxx> 66 #include <svl/rectitem.hxx> 67 68 #include <svl/rngitem.hxx> 69 #include <svx/sdrpaintwindow.hxx> 70 71 //////////////////////////////////////////////////////////////////////////////////////////////////// 72 73 #define ITEMBROWSER_WHICHCOL_ID 1 74 #define ITEMBROWSER_STATECOL_ID 2 75 #define ITEMBROWSER_TYPECOL_ID 3 76 #define ITEMBROWSER_NAMECOL_ID 4 77 #define ITEMBROWSER_VALUECOL_ID 5 78 79 enum ItemType { 80 ITEM_DONTKNOW, ITEM_BYTE, ITEM_INT16, ITEM_UINT16, ITEM_INT32, ITEM_UINT32, 81 ITEM_ENUM, ITEM_BOOL, ITEM_FLAG, ITEM_STRING, ITEM_POINT, ITEM_RECT, ITEM_RANGE, ITEM_LRANGE, 82 ITEM_FRACTION, 83 ITEM_XCOLOR, 84 ITEM_COLOR, 85 ITEM_FONT, ITEM_FONTHEIGHT, ITEM_FONTWIDTH, ITEM_FIELD 86 }; 87 88 class ImpItemListRow 89 { 90 public: 91 XubString aName; 92 XubString aValue; 93 SfxItemState eState; 94 sal_uInt16 nWhichId; 95 96 TypeId pType; 97 ItemType eItemType; 98 99 sal_Int32 nVal; 100 sal_Int32 nMin; 101 sal_Int32 nMax; 102 103 sal_Bool bComment; 104 sal_Bool bIsNum; 105 sal_Bool bCanNum; 106 107 public: 108 ImpItemListRow() 109 : eState(SFX_ITEM_UNKNOWN), 110 nWhichId(0), 111 pType(NULL), 112 eItemType(ITEM_DONTKNOW), 113 nVal(0), 114 nMin(0), 115 nMax(0), 116 bComment(sal_False), 117 bIsNum(sal_False), 118 bCanNum(sal_False) 119 {} 120 121 XubString GetItemTypeStr() const; 122 sal_Bool operator==(const ImpItemListRow& rEntry) const; 123 sal_Bool operator!=(const ImpItemListRow& rEntry) const { return !operator==(rEntry); } 124 }; 125 126 XubString ImpItemListRow::GetItemTypeStr() const 127 { 128 XubString aStr; 129 130 switch(eItemType) 131 { 132 case ITEM_BYTE : aStr.AppendAscii("Byte"); break; 133 case ITEM_INT16 : aStr.AppendAscii("Int16"); break; 134 case ITEM_UINT16 : aStr.AppendAscii("UInt16"); break; 135 case ITEM_INT32 : aStr.AppendAscii("Int32"); break; 136 case ITEM_UINT32 : aStr.AppendAscii("UInt32"); break; 137 case ITEM_ENUM : aStr.AppendAscii("Enum"); break; 138 case ITEM_BOOL : aStr.AppendAscii("Bool"); break; 139 case ITEM_FLAG : aStr.AppendAscii("Flag"); break; 140 case ITEM_STRING : aStr.AppendAscii("String"); break; 141 case ITEM_POINT : aStr.AppendAscii("Point"); break; 142 case ITEM_RECT : aStr.AppendAscii("Rectangle");break; 143 case ITEM_RANGE : aStr.AppendAscii("Range"); break; 144 case ITEM_LRANGE : aStr.AppendAscii("LRange"); break; 145 case ITEM_FRACTION : aStr.AppendAscii("Fraction"); break; 146 case ITEM_XCOLOR : aStr.AppendAscii("XColor"); break; 147 case ITEM_COLOR : aStr.AppendAscii("Color"); break; 148 case ITEM_FONT : aStr.AppendAscii("Font"); break; 149 case ITEM_FONTHEIGHT:aStr.AppendAscii("FontHeight");break; 150 case ITEM_FONTWIDTH :aStr.AppendAscii("FontWidth"); break; 151 case ITEM_FIELD :aStr.AppendAscii("Field"); break; 152 default: break; 153 } 154 155 return aStr; 156 } 157 158 sal_Bool ImpItemListRow::operator==(const ImpItemListRow& rEntry) const 159 { 160 return (aName.Equals(rEntry.aName) 161 && aValue.Equals(rEntry.aValue) 162 && eState==rEntry.eState 163 && nWhichId==rEntry.nWhichId 164 && bComment==rEntry.bComment 165 && bIsNum==rEntry.bIsNum 166 && bCanNum==rEntry.bCanNum 167 && pType==rEntry.pType 168 && eItemType==rEntry.eItemType 169 && nVal==rEntry.nVal 170 && nMin==rEntry.nMin 171 && nMax==rEntry.nMax); 172 } 173 174 //////////////////////////////////////////////////////////////////////////////////////////////////// 175 176 class ImpItemEdit: public Edit 177 { 178 _SdrItemBrowserControl* pBrowse; 179 180 public: 181 ImpItemEdit(Window* pParent, _SdrItemBrowserControl* pBrowse_, WinBits nBits=0) 182 : Edit(pParent, nBits), 183 pBrowse(pBrowse_) 184 {} 185 186 virtual ~ImpItemEdit(); 187 virtual void KeyInput(const KeyEvent& rEvt); 188 }; 189 190 __EXPORT ImpItemEdit::~ImpItemEdit() 191 { 192 } 193 194 void __EXPORT ImpItemEdit::KeyInput(const KeyEvent& rKEvt) 195 { 196 _SdrItemBrowserControl* pBrowseMerk = pBrowse; 197 198 sal_uInt16 nKeyCode(rKEvt.GetKeyCode().GetCode() + rKEvt.GetKeyCode().GetModifier()); 199 200 if(nKeyCode == KEY_RETURN) 201 { 202 pBrowseMerk->EndChangeEntry(); 203 pBrowseMerk->GrabFocus(); 204 } 205 else if(nKeyCode == KEY_ESCAPE) 206 { 207 pBrowseMerk->BrkChangeEntry(); 208 pBrowseMerk->GrabFocus(); 209 } 210 else if(nKeyCode == KEY_UP || nKeyCode == KEY_DOWN) 211 { 212 pBrowseMerk->EndChangeEntry(); 213 pBrowseMerk->GrabFocus(); 214 pBrowseMerk->KeyInput(rKEvt); 215 } 216 else 217 Edit::KeyInput(rKEvt); 218 } 219 220 //////////////////////////////////////////////////////////////////////////////////////////////////// 221 222 #define MYBROWSEMODE (BROWSER_THUMBDRAGGING|BROWSER_KEEPHIGHLIGHT|BROWSER_NO_HSCROLL|BROWSER_HIDECURSOR) 223 224 _SdrItemBrowserControl::_SdrItemBrowserControl(Window* pParent, WinBits nBits): 225 BrowseBox(pParent,nBits,MYBROWSEMODE), 226 aList(1024,16,16) 227 { 228 ImpCtor(); 229 } 230 231 __EXPORT _SdrItemBrowserControl::~_SdrItemBrowserControl() 232 { 233 if(pEditControl) 234 delete pEditControl; 235 236 if(pAktChangeEntry) 237 delete pAktChangeEntry; 238 239 Clear(); 240 } 241 242 void _SdrItemBrowserControl::ImpCtor() 243 { 244 pEditControl = NULL; 245 pAktChangeEntry = NULL; 246 nLastWhichOfs = 0; 247 nLastWhich = 0; 248 nLastWhichOben = 0; // not implemented yet 249 nLastWhichUnten = 0; // not implemented yet 250 bWhichesButNames = sal_False; 251 bDontHideIneffectiveItems = sal_False; 252 bDontSortItems = sal_False; 253 bShowWhichIds = sal_False; 254 bShowRealValues = sal_False; 255 bShowWhichIds = sal_True; // not implemented yet 256 bShowRealValues = sal_True; // not implemented yet 257 258 rtl_TextEncoding aTextEncoding = gsl_getSystemTextEncoding(); 259 260 InsertDataColumn( 261 ITEMBROWSER_WHICHCOL_ID, 262 String("Which", aTextEncoding), 263 GetTextWidth(String(" Which ", aTextEncoding)) + 2); 264 InsertDataColumn( 265 ITEMBROWSER_STATECOL_ID, 266 String("State", aTextEncoding), 267 Max(GetTextWidth(String(" State ", aTextEncoding)) + 2 , 268 GetTextWidth(String("DontCare", aTextEncoding)) + 2)); 269 InsertDataColumn( 270 ITEMBROWSER_TYPECOL_ID , 271 String("Type", aTextEncoding), 272 GetTextWidth(String(" Type_ ", aTextEncoding)) + 2); 273 InsertDataColumn( 274 ITEMBROWSER_NAMECOL_ID , 275 String("Name", aTextEncoding), 276 150); 277 InsertDataColumn( 278 ITEMBROWSER_VALUECOL_ID, 279 String("Value", aTextEncoding), 280 GetTextWidth(String("12345678901234567890", aTextEncoding))); 281 SetDataRowHeight( 282 GetTextHeight()); 283 284 long nWdt=GetColumnWidth(ITEMBROWSER_WHICHCOL_ID)+ 285 GetColumnWidth(ITEMBROWSER_STATECOL_ID)+ 286 GetColumnWidth(ITEMBROWSER_TYPECOL_ID )+ 287 GetColumnWidth(ITEMBROWSER_NAMECOL_ID )+ 288 GetColumnWidth(ITEMBROWSER_VALUECOL_ID); 289 290 long nHgt=GetTitleHeight()+16*GetDataRowHeight(); 291 292 SetOutputSizePixel(Size(nWdt,nHgt)); 293 } 294 295 void _SdrItemBrowserControl::Clear() 296 { 297 sal_uIntPtr nAnz=aList.Count(); 298 for (sal_uIntPtr nNum=0; nNum<nAnz; nNum++) { 299 delete ImpGetEntry(nNum); 300 } 301 aList.Clear(); 302 BrowseBox::Clear(); 303 } 304 305 long __EXPORT _SdrItemBrowserControl::GetRowCount() const 306 { 307 return aList.Count(); 308 } 309 310 sal_Bool __EXPORT _SdrItemBrowserControl::SeekRow(long nRow) 311 { 312 nAktPaintRow=nRow; 313 return sal_True; 314 } 315 316 String _SdrItemBrowserControl::GetCellText(long _nRow, sal_uInt16 _nColId) const 317 { 318 String sRet; 319 if ( _nRow >= 0 && _nRow < (sal_Int32)aList.Count() ) 320 { 321 ImpItemListRow* pEntry = ImpGetEntry(_nRow); 322 if ( pEntry ) 323 { 324 if ( pEntry->bComment ) 325 { 326 if (_nColId == ITEMBROWSER_NAMECOL_ID) 327 sRet = pEntry->aName; 328 } 329 else 330 { 331 rtl_TextEncoding aTextEncoding = gsl_getSystemTextEncoding(); 332 333 sRet = XubString("???", aTextEncoding); 334 switch (_nColId) 335 { 336 case ITEMBROWSER_WHICHCOL_ID: 337 sRet = UniString::CreateFromInt32(pEntry->nWhichId); break; 338 case ITEMBROWSER_STATECOL_ID: 339 { 340 switch (pEntry->eState) 341 { 342 case SFX_ITEM_UNKNOWN : sRet=String("Uknown", aTextEncoding); break; 343 case SFX_ITEM_DISABLED: sRet=String("Disabled", aTextEncoding); break; 344 case SFX_ITEM_DONTCARE: sRet=String("DontCare", aTextEncoding); break; 345 case SFX_ITEM_SET : sRet=String("Set", aTextEncoding); break; 346 case SFX_ITEM_DEFAULT : sRet=String("Default", aTextEncoding); break; 347 } // switch 348 } break; 349 case ITEMBROWSER_TYPECOL_ID: sRet = pEntry->GetItemTypeStr(); break; 350 case ITEMBROWSER_NAMECOL_ID: sRet = pEntry->aName; break; 351 case ITEMBROWSER_VALUECOL_ID: sRet = pEntry->aValue; break; 352 } // switch 353 } 354 } 355 } 356 return sRet; 357 } 358 359 void __EXPORT _SdrItemBrowserControl::PaintField(OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId) const 360 { 361 if (nAktPaintRow<0 || (sal_uIntPtr)nAktPaintRow>=aList.Count()) { 362 return; 363 } 364 Rectangle aR(rRect); 365 aR.Bottom()++; 366 ImpItemListRow* pEntry=ImpGetEntry(nAktPaintRow); 367 if (pEntry->bComment) 368 { 369 if (nColumnId==ITEMBROWSER_NAMECOL_ID) 370 { 371 rDev.SetLineColor(); 372 rDev.SetFillColor( Color( COL_LIGHTGRAY ) ); 373 aR.Left()=0; 374 aR.Right()=rDev.GetOutputSize().Width(); 375 rDev.DrawRect(aR); 376 rDev.DrawText(rRect.TopLeft(),pEntry->aName); 377 } 378 } else { 379 rDev.SetClipRegion(aR); 380 rDev.DrawText(aR.TopLeft(),GetCellText(nAktPaintRow,nColumnId)); 381 rDev.SetClipRegion(); 382 } 383 } 384 385 sal_uIntPtr _SdrItemBrowserControl::GetCurrentPos() const 386 { 387 sal_uIntPtr nRet=CONTAINER_ENTRY_NOTFOUND; 388 if (GetSelectRowCount()==1) { 389 long nPos=((BrowseBox*)this)->FirstSelectedRow(); 390 if (nPos>=0 && (sal_uIntPtr)nPos<aList.Count()) { 391 nRet=(sal_uIntPtr)nPos; 392 } 393 } 394 return nRet; 395 } 396 397 sal_uInt16 _SdrItemBrowserControl::GetCurrentWhich() const 398 { 399 sal_uInt16 nRet=0; 400 sal_uIntPtr nPos=GetCurrentPos(); 401 if (nPos!=CONTAINER_ENTRY_NOTFOUND) { 402 nRet=ImpGetEntry(nPos)->nWhichId; 403 } 404 return nRet; 405 } 406 407 void __EXPORT _SdrItemBrowserControl::DoubleClick(const BrowserMouseEvent&) 408 { 409 sal_uIntPtr nPos=GetCurrentPos(); 410 if (nPos!=CONTAINER_ENTRY_NOTFOUND) { 411 BegChangeEntry(nPos); 412 } 413 } 414 415 void __EXPORT _SdrItemBrowserControl::KeyInput(const KeyEvent& rKEvt) 416 { 417 sal_uInt16 nKeyCode=rKEvt.GetKeyCode().GetCode()+rKEvt.GetKeyCode().GetModifier(); 418 FASTBOOL bAusgewertet=sal_False; 419 sal_uIntPtr nPos=GetCurrentPos(); 420 if (nPos!=CONTAINER_ENTRY_NOTFOUND) { 421 if (nKeyCode==KEY_RETURN) { 422 if (BegChangeEntry(nPos)) bAusgewertet=sal_True; 423 } else if (nKeyCode==KEY_ESCAPE) { 424 // ... 425 } else if (rKEvt.GetKeyCode().GetModifier()==KEY_SHIFT+KEY_MOD1+KEY_MOD2) { // Strg 426 if (nKeyCode==KEY_SHIFT+KEY_MOD1+KEY_MOD2+KEY_W) { 427 bWhichesButNames=!bWhichesButNames; 428 SetDirty(); 429 } 430 if (nKeyCode==KEY_SHIFT+KEY_MOD1+KEY_MOD2+KEY_I) { 431 bDontHideIneffectiveItems=!bDontHideIneffectiveItems; 432 SetDirty(); 433 } 434 if (nKeyCode==KEY_SHIFT+KEY_MOD1+KEY_MOD2+KEY_S) { 435 bDontSortItems=!bDontSortItems; 436 SetDirty(); 437 } 438 } 439 } 440 if (!bAusgewertet) BrowseBox::KeyInput(rKEvt); 441 } 442 443 void _SdrItemBrowserControl::SetDirty() 444 { 445 aSetDirtyHdl.Call(this); 446 } 447 448 Rectangle _SdrItemBrowserControl::GetFieldCharacterBounds(sal_Int32 /*_nRow*/,sal_Int32 /*_nColumnPos*/,sal_Int32 /*nIndex*/) 449 { 450 // no accessibility implementation required 451 return Rectangle(); 452 } 453 454 sal_Int32 _SdrItemBrowserControl::GetFieldIndexAtPoint(sal_Int32 /*_nRow*/,sal_Int32 /*_nColumnPos*/,const Point& /*_rPoint*/) 455 { 456 // no accessibility implementation required 457 return -1; 458 } 459 460 void __EXPORT _SdrItemBrowserControl::Select() 461 { 462 EndChangeEntry(); 463 BrowseBox::Select(); 464 ImpSaveWhich(); 465 } 466 467 void _SdrItemBrowserControl::ImpSaveWhich() 468 { 469 sal_uInt16 nWh=GetCurrentWhich(); 470 if (nWh!=0) { 471 long nPos=GetCurrentPos(); 472 long nTop=GetTopRow(); 473 long nBtm=GetTopRow()+GetVisibleRows()+1; 474 nLastWhich=nWh; 475 nLastWhichOfs=nPos-nTop; 476 if (nTop<0) nTop=0; 477 if (nBtm>=(long)aList.Count()) nBtm=aList.Count()-1; 478 nLastWhichOben=ImpGetEntry(nTop)->nWhichId; 479 nLastWhichUnten=ImpGetEntry(nBtm)->nWhichId; 480 } 481 } 482 483 void _SdrItemBrowserControl::ImpRestoreWhich() 484 { 485 if (nLastWhich!=0) { 486 FASTBOOL bFnd=sal_False; 487 sal_uInt16 nBestMinWh=0,nBestMaxWh=0xFFFF; // not implemented yet 488 sal_uIntPtr nBestMinPos=0,nBestMaxPos=0xFFFFFFFF; // not implemented yet 489 sal_uIntPtr nAnz=aList.Count(); 490 sal_uIntPtr nNum; 491 for (nNum=0; nNum<nAnz && !bFnd; nNum++) { 492 ImpItemListRow* pEntry=ImpGetEntry(nNum); 493 if (!pEntry->bComment) { 494 sal_uInt16 nWh=pEntry->nWhichId; 495 if (nWh==nLastWhich) bFnd=sal_True; 496 else if (nWh<nLastWhich && nWh>nBestMinWh) nBestMinPos=nNum; 497 else if (nWh>nLastWhich && nWh<nBestMaxWh) nBestMaxPos=nNum; 498 } 499 } 500 if (bFnd) { 501 long nPos=nNum-1; 502 long nWhichOfs=nPos-GetTopRow(); 503 if (nWhichOfs!=nLastWhichOfs) { 504 ScrollRows(nWhichOfs-nLastWhichOfs); 505 } 506 GoToRow(nPos); 507 } 508 } 509 } 510 511 FASTBOOL _SdrItemBrowserControl::BegChangeEntry(sal_uIntPtr nPos) 512 { 513 BrkChangeEntry(); 514 FASTBOOL bRet=sal_False; 515 ImpItemListRow* pEntry=ImpGetEntry(nPos); 516 if (pEntry!=NULL && !pEntry->bComment) { 517 SetMode(MYBROWSEMODE & ~BROWSER_KEEPHIGHLIGHT); 518 pEditControl=new ImpItemEdit(&GetDataWindow(),this,0/*|WB_BORDER|WB_3DLOOK*/); 519 Rectangle aRect(GetFieldRectPixel(nPos,ITEMBROWSER_VALUECOL_ID,sal_False)); 520 aRect.Left()+=2; // Kleiner Offset fuer's Edit, damit's pixelgenau stimmt 521 aRect.Right()--; 522 pEditControl->SetPosSizePixel(aRect.TopLeft(),aRect.GetSize()); 523 pEditControl->SetText(pEntry->aValue); 524 pEditControl->SetBackground( Wallpaper(Color(COL_LIGHTGRAY))); 525 Font aFont(pEditControl->GetFont()); 526 aFont.SetFillColor(Color(COL_LIGHTGRAY)); 527 pEditControl->SetFont(aFont); 528 pEditControl->Show(); 529 pEditControl->GrabFocus(); 530 pEditControl->SetSelection(Selection(SELECTION_MIN,SELECTION_MAX)); 531 Window* pParent=GetParent(); 532 aWNamMerk=pParent->GetText(); 533 XubString aNeuNam(aWNamMerk); 534 aNeuNam += sal_Unicode(' '); 535 aNeuNam += pEntry->GetItemTypeStr(); 536 if (pEntry->bCanNum) { 537 aNeuNam.AppendAscii(": "); 538 aNeuNam += UniString::CreateFromInt32(pEntry->nMin); 539 aNeuNam.AppendAscii(".."); 540 aNeuNam += UniString::CreateFromInt32(pEntry->nMax); 541 } 542 aNeuNam.AppendAscii(" - Type 'del' to reset to default."); 543 pParent->SetText(aNeuNam); 544 pAktChangeEntry=new ImpItemListRow(*pEntry); 545 bRet=sal_True; 546 } 547 return bRet; 548 } 549 550 FASTBOOL _SdrItemBrowserControl::EndChangeEntry() 551 { 552 FASTBOOL bRet=sal_False; 553 if (pEditControl!=NULL) { 554 aEntryChangedHdl.Call(this); 555 delete pEditControl; 556 pEditControl=NULL; 557 delete pAktChangeEntry; 558 pAktChangeEntry=NULL; 559 Window* pParent=GetParent(); 560 pParent->SetText(aWNamMerk); 561 SetMode(MYBROWSEMODE); 562 bRet=sal_True; 563 } 564 return bRet; 565 } 566 567 void _SdrItemBrowserControl::BrkChangeEntry() 568 { 569 if (pEditControl!=NULL) { 570 delete pEditControl; 571 pEditControl=NULL; 572 delete pAktChangeEntry; 573 pAktChangeEntry=NULL; 574 Window* pParent=GetParent(); 575 pParent->SetText(aWNamMerk); 576 SetMode(MYBROWSEMODE); 577 } 578 } 579 580 void _SdrItemBrowserControl::ImpSetEntry(const ImpItemListRow& rEntry, sal_uIntPtr nEntryNum) 581 { 582 ImpItemListRow* pAktEntry=ImpGetEntry(nEntryNum); 583 if (pAktEntry==NULL) { 584 aList.Insert(new ImpItemListRow(rEntry),CONTAINER_APPEND); 585 RowInserted(nEntryNum); 586 } else if (*pAktEntry!=rEntry) { 587 FASTBOOL bStateDiff=rEntry.eState!=pAktEntry->eState; 588 FASTBOOL bValueDiff=!rEntry.aValue.Equals(pAktEntry->aValue); 589 FASTBOOL bAllDiff=sal_True; 590 if (bStateDiff || bValueDiff) { 591 // Checken, ob nur State und/oder Value geaendert 592 ImpItemListRow aTest(rEntry); 593 aTest.eState=pAktEntry->eState; 594 aTest.aValue=pAktEntry->aValue; 595 if (aTest==*pAktEntry) bAllDiff=sal_False; 596 } 597 *pAktEntry=rEntry; 598 if (bAllDiff) { 599 RowModified(nEntryNum); 600 } else { 601 if (bStateDiff) RowModified(nEntryNum,ITEMBROWSER_STATECOL_ID); 602 if (bValueDiff) RowModified(nEntryNum,ITEMBROWSER_VALUECOL_ID); 603 } 604 } 605 } 606 607 FASTBOOL ImpGetItem(const SfxItemSet& rSet, sal_uInt16 nWhich, const SfxPoolItem*& rpItem) 608 { 609 SfxItemState eState=rSet.GetItemState(nWhich,sal_True,&rpItem); 610 if (eState==SFX_ITEM_DEFAULT) { 611 rpItem=&rSet.Get(nWhich); 612 } 613 return (eState==SFX_ITEM_DEFAULT || eState==SFX_ITEM_SET) && rpItem!=NULL; 614 } 615 616 FASTBOOL IsItemIneffective(sal_uInt16 nWhich, const SfxItemSet* pSet, sal_uInt16& rIndent) 617 { 618 rIndent=0; 619 if (pSet==NULL) return sal_False; 620 const SfxPoolItem* pItem=NULL; 621 FASTBOOL bRet=sal_False; 622 switch (nWhich) { 623 case XATTR_LINEDASH : 624 case XATTR_LINEWIDTH : 625 case XATTR_LINECOLOR : 626 case XATTR_LINESTART : 627 case XATTR_LINEEND : 628 case XATTR_LINESTARTWIDTH : 629 case XATTR_LINEENDWIDTH : 630 case XATTR_LINESTARTCENTER : 631 case XATTR_LINEENDCENTER : 632 case XATTR_LINETRANSPARENCE : { 633 rIndent=1; 634 if (ImpGetItem(*pSet,XATTR_LINESTYLE,pItem)) { 635 XLineStyle eLineStyle=((const XLineStyleItem*)pItem)->GetValue(); 636 if (eLineStyle==XLINE_NONE) return sal_True; 637 if (eLineStyle!=XLINE_DASH && nWhich==XATTR_LINEDASH) return sal_True; 638 } 639 if (nWhich==XATTR_LINESTART || nWhich==XATTR_LINESTARTCENTER) { 640 rIndent=2; 641 if (ImpGetItem(*pSet,XATTR_LINESTARTWIDTH,pItem)) { 642 sal_Int32 nWdt=((const XLineStartWidthItem*)pItem)->GetValue(); 643 if (nWdt==0) return sal_True; 644 } 645 } 646 if (nWhich==XATTR_LINEEND || nWhich==XATTR_LINEENDCENTER) { 647 rIndent=2; 648 if (ImpGetItem(*pSet,XATTR_LINEENDWIDTH,pItem)) { 649 sal_Int32 nWdt=((const XLineEndWidthItem*)pItem)->GetValue(); 650 if (nWdt==0) return sal_True; 651 } 652 } 653 } break; 654 case XATTR_FILLCOLOR : /*nur bei Style=Color*/ 655 case XATTR_FILLGRADIENT : /*nur bei Style=Gradient*/ 656 case XATTR_FILLHATCH : /*nur bei Style=Hatch*/ 657 case XATTR_FILLTRANSPARENCE : /*nur bei Style=Color*/ 658 case XATTR_GRADIENTSTEPCOUNT : /*nur bei Style=Gradient*/ 659 case XATTR_FILLBACKGROUND : /*nur bei Style=Hatch*/ 660 { 661 rIndent=1; 662 if (ImpGetItem(*pSet,XATTR_FILLSTYLE,pItem)) { 663 XFillStyle eFillStyle=((const XFillStyleItem*)pItem)->GetValue(); 664 if (eFillStyle==XFILL_NONE) return sal_True; 665 // Transparenz z.Zt. nur fuer SolidFill 666 if (eFillStyle!=XFILL_SOLID && (nWhich==XATTR_FILLCOLOR || nWhich==XATTR_FILLTRANSPARENCE)) return sal_True; 667 if (eFillStyle!=XFILL_GRADIENT && (nWhich==XATTR_FILLGRADIENT || nWhich==XATTR_GRADIENTSTEPCOUNT)) return sal_True; 668 if (eFillStyle!=XFILL_HATCH && (nWhich==XATTR_FILLHATCH || nWhich==XATTR_FILLBACKGROUND)) return sal_True; 669 } 670 } break; 671 case XATTR_FILLBITMAP : 672 case XATTR_FILLBMP_TILE : 673 case XATTR_FILLBMP_POS : /* z.Zt. nur wenn TILE=sal_True */ 674 case XATTR_FILLBMP_SIZEX : /* nur wenn nicht Stretch */ 675 case XATTR_FILLBMP_SIZEY : /* nur wenn nicht Stretch */ 676 case XATTR_FILLBMP_SIZELOG : /* nur wenn SIZELOG=sal_False zum ruecksetzen auf sal_True (alt) -> doch noch in Gebrauch */ 677 case XATTR_FILLBMP_TILEOFFSETX : /* nur wenn TILE=sal_True */ 678 case XATTR_FILLBMP_TILEOFFSETY : /* nur wenn TILE=sal_True */ 679 case XATTR_FILLBMP_STRETCH : /* nur wenn TILE=sal_False */ 680 case XATTR_FILLBMP_POSOFFSETX : /* nur wenn TILE=sal_True*/ 681 case XATTR_FILLBMP_POSOFFSETY : { /* nur wenn TILE=sal_True*/ 682 rIndent=1; 683 if (ImpGetItem(*pSet,XATTR_FILLSTYLE,pItem)) { 684 XFillStyle eFillStyle=((const XFillStyleItem*)pItem)->GetValue(); 685 if (eFillStyle!=XFILL_BITMAP) return sal_True; 686 } 687 if (nWhich==XATTR_FILLBITMAP || nWhich==XATTR_FILLBMP_TILE) { 688 return sal_False; // immer anwaehlbar 689 } 690 FASTBOOL bTileTRUE=sal_False; 691 FASTBOOL bTileFALSE=sal_False; 692 FASTBOOL bStretchTRUE=sal_False; 693 FASTBOOL bStretchFALSE=sal_False; 694 if (ImpGetItem(*pSet,XATTR_FILLBMP_TILE,pItem)) { 695 bTileTRUE=((const XFillBmpTileItem*)pItem)->GetValue(); 696 bTileFALSE=!bTileTRUE; 697 } 698 if (ImpGetItem(*pSet,XATTR_FILLBMP_STRETCH,pItem)) { 699 bStretchTRUE=((const XFillBmpStretchItem*)pItem)->GetValue(); 700 bStretchFALSE=!bStretchTRUE; 701 } 702 // Stretch nicht anwaehlbar, wenn Tile=TRUE 703 if (nWhich==XATTR_FILLBMP_STRETCH) return bTileTRUE; 704 // und uebrig bleiben 7+1 Item (Unterattribute) 705 rIndent=2; 706 // Pos (enum) nicht anwaehlbar, wenn Tile=FALSE 707 if (nWhich==XATTR_FILLBMP_POS) return bTileFALSE; 708 // SizeXY nicht anwaehlbar bei Stretch=TRUE 709 if (nWhich==XATTR_FILLBMP_SIZEX || nWhich==XATTR_FILLBMP_SIZEY) { 710 return bTileFALSE && bStretchTRUE; 711 } 712 // 2 Items speziell fuer Tile 713 if (nWhich==XATTR_FILLBMP_POSOFFSETX || nWhich==XATTR_FILLBMP_POSOFFSETY) { 714 return bTileFALSE; 715 } 716 // Noch 2 Items speziell fuer Tile die sich jedoch gegenseitig ausschliessen 717 if (nWhich==XATTR_FILLBMP_TILEOFFSETX || nWhich==XATTR_FILLBMP_TILEOFFSETY) { 718 if (bTileFALSE) return sal_True; 719 sal_uInt16 nX=0,nY=0; 720 FASTBOOL bX=sal_False,bY=sal_False; 721 if (ImpGetItem(*pSet,XATTR_FILLBMP_TILEOFFSETX,pItem)) { 722 nX=((const XFillBmpTileOffsetXItem*)pItem)->GetValue(); 723 bX=sal_True; 724 } 725 if (ImpGetItem(*pSet,XATTR_FILLBMP_TILEOFFSETY,pItem)) { 726 nY=((const XFillBmpTileOffsetYItem*)pItem)->GetValue(); 727 bY=sal_True; 728 } 729 if (nWhich==XATTR_FILLBMP_TILEOFFSETX) { 730 if (nX!=0 || !bX) return sal_False; 731 if (nY!=0) return sal_True; 732 } else { 733 if (nY!=0 || !bY) return sal_False; 734 if (nX!=0) return sal_True; 735 } 736 } 737 // SizeLog nicht anwaehlbar bei Stretch=TRUE 738 // und sonst auch nur wenn es auf SizeLog=sal_False gesetzt ist. 739 // -> wohl doch noch in Gebrauch 740 // (sal_True ist der statische PoolDefault) 741 if (nWhich==XATTR_FILLBMP_SIZELOG) { 742 if (bTileFALSE && bStretchTRUE) return sal_True; 743 } 744 } break; 745 746 case XATTR_FORMTXTADJUST : 747 case XATTR_FORMTXTDISTANCE : 748 case XATTR_FORMTXTSTART : 749 case XATTR_FORMTXTMIRROR : 750 case XATTR_FORMTXTOUTLINE : 751 case XATTR_FORMTXTSHADOW : 752 case XATTR_FORMTXTSHDWCOLOR : 753 case XATTR_FORMTXTSHDWXVAL : 754 case XATTR_FORMTXTSHDWYVAL : 755 case XATTR_FORMTXTSTDFORM : 756 case XATTR_FORMTXTHIDEFORM : 757 case XATTR_FORMTXTSHDWTRANSP: { 758 rIndent=1; 759 if (ImpGetItem(*pSet,XATTR_FORMTXTSTYLE,pItem)) { 760 XFormTextStyle eStyle=((const XFormTextStyleItem*)pItem)->GetValue(); 761 if (eStyle==XFT_NONE) return sal_True; 762 } 763 if ((nWhich>=XATTR_FORMTXTSHDWCOLOR && nWhich<=XATTR_FORMTXTSHDWYVAL) || nWhich>=XATTR_FORMTXTSHDWTRANSP) { 764 rIndent=2; 765 if (ImpGetItem(*pSet,XATTR_FORMTXTSHADOW,pItem)) { 766 XFormTextShadow eShadow=((const XFormTextShadowItem*)pItem)->GetValue(); 767 if (eShadow==XFTSHADOW_NONE) return sal_True; 768 } 769 } 770 } break; 771 772 case SDRATTR_SHADOWCOLOR : 773 case SDRATTR_SHADOWXDIST : 774 case SDRATTR_SHADOWYDIST : 775 case SDRATTR_SHADOWTRANSPARENCE: 776 case SDRATTR_SHADOW3D : 777 case SDRATTR_SHADOWPERSP : { 778 rIndent=1; 779 if (ImpGetItem(*pSet,SDRATTR_SHADOW,pItem)) { 780 FASTBOOL bShadow=((const SdrShadowItem*)pItem)->GetValue(); 781 if (!bShadow) return sal_True; 782 } 783 } break; 784 785 case SDRATTR_CAPTIONANGLE: { 786 rIndent=1; 787 if (ImpGetItem(*pSet,SDRATTR_CAPTIONFIXEDANGLE,pItem)) { 788 FASTBOOL bFixed=((const SdrCaptionFixedAngleItem*)pItem)->GetValue(); 789 if (!bFixed) return sal_True; 790 } 791 } break; 792 case SDRATTR_CAPTIONESCREL: 793 case SDRATTR_CAPTIONESCABS: { 794 rIndent=1; 795 if (ImpGetItem(*pSet,SDRATTR_CAPTIONESCISREL,pItem)) { 796 FASTBOOL bRel=((const SdrCaptionEscIsRelItem*)pItem)->GetValue(); 797 if (bRel && nWhich==SDRATTR_CAPTIONESCABS) return sal_True; 798 if (!bRel && nWhich==SDRATTR_CAPTIONESCREL) return sal_True; 799 } 800 } break; 801 case SDRATTR_CAPTIONLINELEN: { 802 rIndent=1; 803 if (ImpGetItem(*pSet,SDRATTR_CAPTIONFITLINELEN,pItem)) { 804 FASTBOOL bFit=((const SdrCaptionFitLineLenItem*)pItem)->GetValue(); 805 if (bFit) return sal_True; 806 } 807 } break; 808 809 case SDRATTR_TEXT_MINFRAMEHEIGHT: 810 case SDRATTR_TEXT_MAXFRAMEHEIGHT: { 811 rIndent=1; 812 if (ImpGetItem(*pSet,SDRATTR_TEXT_AUTOGROWHEIGHT,pItem)) { 813 FASTBOOL bAutoGrow=((const SdrTextAutoGrowHeightItem*)pItem)->GetValue(); 814 if (!bAutoGrow) return sal_True; 815 } 816 } break; 817 case SDRATTR_TEXT_MINFRAMEWIDTH: 818 case SDRATTR_TEXT_MAXFRAMEWIDTH: { 819 rIndent=1; 820 if (ImpGetItem(*pSet,SDRATTR_TEXT_AUTOGROWWIDTH,pItem)) { 821 FASTBOOL bAutoGrow=((const SdrTextAutoGrowWidthItem*)pItem)->GetValue(); 822 if (!bAutoGrow) return sal_True; 823 } 824 } break; 825 case SDRATTR_TEXT_VERTADJUST: 826 case SDRATTR_TEXT_HORZADJUST: { 827 if (ImpGetItem(*pSet,SDRATTR_TEXT_FITTOSIZE,pItem)) { 828 SdrFitToSizeType eFit=((const SdrTextFitToSizeTypeItem*)pItem)->GetValue(); 829 if (eFit!=SDRTEXTFIT_NONE) return sal_True; 830 } 831 } break; 832 833 case SDRATTR_TEXT_ANIDIRECTION : 834 case SDRATTR_TEXT_ANISTARTINSIDE: 835 case SDRATTR_TEXT_ANISTOPINSIDE : 836 case SDRATTR_TEXT_ANICOUNT : 837 case SDRATTR_TEXT_ANIDELAY : 838 case SDRATTR_TEXT_ANIAMOUNT : { 839 rIndent=1; 840 if (ImpGetItem(*pSet,SDRATTR_TEXT_ANIKIND,pItem)) { 841 SdrTextAniKind eAniKind=((const SdrTextAniKindItem*)pItem)->GetValue(); 842 if (eAniKind==SDRTEXTANI_NONE) return sal_True; 843 if (eAniKind==SDRTEXTANI_BLINK && (nWhich==SDRATTR_TEXT_ANIDIRECTION || nWhich==SDRATTR_TEXT_ANIAMOUNT)) return sal_True; 844 if (eAniKind==SDRTEXTANI_SLIDE && (nWhich==SDRATTR_TEXT_ANISTARTINSIDE || nWhich==SDRATTR_TEXT_ANISTOPINSIDE)) return sal_True; 845 } 846 } break; 847 848 case SDRATTR_EDGELINEDELTAANZ: return sal_True; 849 case SDRATTR_EDGELINE1DELTA: 850 case SDRATTR_EDGELINE2DELTA: 851 case SDRATTR_EDGELINE3DELTA: { 852 if (ImpGetItem(*pSet,SDRATTR_EDGEKIND,pItem)) { 853 SdrEdgeKind eKind=((const SdrEdgeKindItem*)pItem)->GetValue(); 854 if (eKind==SDREDGE_THREELINES) { 855 if (nWhich>SDRATTR_EDGELINE2DELTA) return sal_True; 856 else return sal_False; 857 } 858 if (eKind!=SDREDGE_ORTHOLINES && eKind!=SDREDGE_BEZIER) return sal_True; 859 } 860 if (ImpGetItem(*pSet,SDRATTR_EDGELINEDELTAANZ,pItem)) { 861 sal_uInt16 nAnz=((const SdrEdgeLineDeltaAnzItem*)pItem)->GetValue(); 862 if (nAnz==0) return sal_True; 863 if (nAnz==1 && nWhich>SDRATTR_EDGELINE1DELTA) return sal_True; 864 if (nAnz==2 && nWhich>SDRATTR_EDGELINE2DELTA) return sal_True; 865 if (nAnz==3 && nWhich>SDRATTR_EDGELINE3DELTA) return sal_True; 866 } 867 } break; 868 869 case SDRATTR_CIRCSTARTANGLE: 870 case SDRATTR_CIRCENDANGLE : { 871 rIndent=1; 872 if (ImpGetItem(*pSet,SDRATTR_CIRCKIND,pItem)) { 873 SdrCircKind eKind=((const SdrCircKindItem*)pItem)->GetValue(); 874 if (eKind==SDRCIRC_FULL) return sal_True; 875 } 876 } break; 877 } // switch 878 return bRet; 879 } 880 881 sal_uInt16 ImpSortWhich(sal_uInt16 nWhich) 882 { 883 switch (nWhich) { 884 // Line 885 case XATTR_LINESTART : nWhich=XATTR_LINETRANSPARENCE ; break; 886 case XATTR_LINEEND : nWhich=XATTR_LINESTARTWIDTH ; break; 887 case XATTR_LINESTARTWIDTH : nWhich=XATTR_LINESTART ; break; 888 case XATTR_LINEENDWIDTH : nWhich=XATTR_LINESTARTCENTER ; break; 889 case XATTR_LINESTARTCENTER : nWhich=XATTR_LINEENDWIDTH ; break; 890 case XATTR_LINEENDCENTER : nWhich=XATTR_LINEEND ; break; 891 case XATTR_LINETRANSPARENCE : nWhich=XATTR_LINEENDCENTER ; break; 892 893 // Fill 894 case XATTR_FILLBMP_POS : nWhich=XATTR_FILLBMP_STRETCH ; break; 895 case XATTR_FILLBMP_SIZEX : nWhich=XATTR_FILLBMP_POS ; break; 896 case XATTR_FILLBMP_SIZEY : nWhich=XATTR_FILLBMP_SIZEX ; break; 897 case XATTR_FILLBMP_SIZELOG : nWhich=XATTR_FILLBMP_SIZEY ; break; 898 case XATTR_FILLBMP_TILEOFFSETX : nWhich=XATTR_FILLBMP_SIZELOG ; break; 899 case XATTR_FILLBMP_TILEOFFSETY : nWhich=XATTR_FILLBMP_TILEOFFSETX ; break; 900 case XATTR_FILLBMP_STRETCH : nWhich=XATTR_FILLBMP_TILEOFFSETY ; break; 901 902 // Fontwork 903 case XATTR_FORMTXTSHADOW : nWhich=XATTR_FORMTXTSTDFORM ; break; 904 case XATTR_FORMTXTSHDWCOLOR : nWhich=XATTR_FORMTXTHIDEFORM ; break; 905 case XATTR_FORMTXTSHDWXVAL : nWhich=XATTR_FORMTXTSHADOW ; break; 906 case XATTR_FORMTXTSHDWYVAL : nWhich=XATTR_FORMTXTSHDWCOLOR ; break; 907 case XATTR_FORMTXTSTDFORM : nWhich=XATTR_FORMTXTSHDWXVAL ; break; 908 case XATTR_FORMTXTHIDEFORM : nWhich=XATTR_FORMTXTSHDWYVAL ; break; 909 910 // Misc 911 case SDRATTR_TEXT_MINFRAMEHEIGHT: nWhich=SDRATTR_TEXT_FITTOSIZE ; break; 912 case SDRATTR_TEXT_AUTOGROWHEIGHT: nWhich=SDRATTR_TEXT_LEFTDIST ; break; 913 case SDRATTR_TEXT_FITTOSIZE : nWhich=SDRATTR_TEXT_RIGHTDIST ; break; 914 case SDRATTR_TEXT_LEFTDIST : nWhich=SDRATTR_TEXT_UPPERDIST ; break; 915 case SDRATTR_TEXT_RIGHTDIST : nWhich=SDRATTR_TEXT_LOWERDIST ; break; 916 case SDRATTR_TEXT_UPPERDIST : nWhich=SDRATTR_TEXT_AUTOGROWWIDTH ; break; 917 case SDRATTR_TEXT_LOWERDIST : nWhich=SDRATTR_TEXT_MINFRAMEWIDTH ; break; 918 case SDRATTR_TEXT_VERTADJUST : nWhich=SDRATTR_TEXT_MAXFRAMEWIDTH ; break; 919 case SDRATTR_TEXT_MAXFRAMEHEIGHT: nWhich=SDRATTR_TEXT_AUTOGROWHEIGHT; break; 920 case SDRATTR_TEXT_MINFRAMEWIDTH : nWhich=SDRATTR_TEXT_MINFRAMEHEIGHT; break; 921 case SDRATTR_TEXT_MAXFRAMEWIDTH : nWhich=SDRATTR_TEXT_MAXFRAMEHEIGHT; break; 922 case SDRATTR_TEXT_AUTOGROWWIDTH : nWhich=SDRATTR_TEXT_HORZADJUST ; break; 923 case SDRATTR_TEXT_HORZADJUST : nWhich=SDRATTR_TEXT_VERTADJUST ; break; 924 } // switch 925 return nWhich; 926 } 927 928 #define INSERTCOMMENT(nStartId,nEndId,aStr) \ 929 { if (nWhich0<nStartId && nWhich>=nStartId && nWhich<=nEndId) aCommentStr=aStr; } 930 931 void _SdrItemBrowserControl::SetAttributes(const SfxItemSet* pSet, const SfxItemSet* p2ndSet) 932 { 933 SetMode(MYBROWSEMODE & ~BROWSER_KEEPHIGHLIGHT); 934 if (pSet!=NULL) { 935 rtl_TextEncoding aTextEncoding = gsl_getSystemTextEncoding(); 936 sal_uInt16 nEntryNum=0; 937 SfxWhichIter aIter(*pSet); 938 const SfxItemPool* pPool=pSet->GetPool(); 939 sal_uInt16 nWhich0=0; 940 sal_uInt16 nWhich=aIter.FirstWhich(); 941 while (nWhich!=0) { 942 // Nun erstmal etwas umsortieren 943 // Geht nur, solange keine InvalidItems, d.h. keine Luecken 944 // an dieser Stelle im Set sind 945 if (!bDontSortItems) nWhich=ImpSortWhich(nWhich); 946 SfxItemState eState=pSet->GetItemState(nWhich); 947 if (p2ndSet!=NULL) { 948 SfxItemState e2ndState=p2ndSet->GetItemState(nWhich); 949 if (eState==SFX_ITEM_DEFAULT) eState=SFX_ITEM_DISABLED; 950 else if (e2ndState==SFX_ITEM_DEFAULT) eState=SFX_ITEM_DEFAULT; 951 } 952 if (eState!=SFX_ITEM_DISABLED) { 953 const SfxPoolItem& rItem=pSet->Get(nWhich); 954 sal_uInt16 nIndent=0; 955 if (!HAS_BASE(SfxVoidItem,&rItem) && !HAS_BASE(SfxSetItem,&rItem) && (!IsItemIneffective(nWhich,pSet,nIndent) || bDontHideIneffectiveItems)) { 956 XubString aCommentStr; 957 958 INSERTCOMMENT(XATTR_LINE_FIRST,XATTR_LINE_LAST,String("L I N I E", aTextEncoding)); 959 INSERTCOMMENT(XATTR_FILL_FIRST,XATTR_FILL_LAST,String("F L � C H E", aTextEncoding)); 960 INSERTCOMMENT(XATTR_TEXT_FIRST,XATTR_TEXT_LAST,String("F O N T W O R K", aTextEncoding)); 961 INSERTCOMMENT(SDRATTR_SHADOW_FIRST,SDRATTR_SHADOW_LAST,String("S C H A T T E N", aTextEncoding)); 962 INSERTCOMMENT(SDRATTR_CAPTION_FIRST,SDRATTR_CAPTION_LAST,String("L E G E N D E", aTextEncoding)); 963 INSERTCOMMENT(SDRATTR_MISC_FIRST,SDRATTR_MISC_LAST,String("V E R S C H I E D E N E S", aTextEncoding)); 964 INSERTCOMMENT(SDRATTR_EDGE_FIRST,SDRATTR_EDGE_LAST,String("V E R B I N D E R", aTextEncoding)); 965 INSERTCOMMENT(SDRATTR_MEASURE_FIRST,SDRATTR_MEASURE_LAST,String("B E M A S S U N G", aTextEncoding)); 966 INSERTCOMMENT(SDRATTR_CIRC_FIRST,SDRATTR_CIRC_LAST,String("K R E I S", aTextEncoding)); 967 INSERTCOMMENT(SDRATTR_NOTPERSIST_FIRST,SDRATTR_NOTPERSIST_LAST,String("N O T P E R S I S T", aTextEncoding)); 968 INSERTCOMMENT(SDRATTR_MOVEX,SDRATTR_VERTSHEARONE,String("Transformationen auf alle Objekte einzeln", aTextEncoding)); 969 INSERTCOMMENT(SDRATTR_RESIZEXALL,SDRATTR_VERTSHEARALL,String("Transformationen auf alle Objekte gemeinsam", aTextEncoding)); 970 INSERTCOMMENT(SDRATTR_TRANSFORMREF1X,SDRATTR_TRANSFORMREF2Y,String("View-Referenzpunkte", aTextEncoding)); 971 INSERTCOMMENT(SDRATTR_GRAF_FIRST,SDRATTR_GRAF_LAST,String("G R A F I K", aTextEncoding)); 972 INSERTCOMMENT(EE_ITEMS_START,EE_ITEMS_END,String("E D I T E N G I N E", aTextEncoding)); 973 INSERTCOMMENT(EE_ITEMS_END+1,EE_ITEMS_END+1,String("... by Joe Merten, JME Engineering Berlin ...", aTextEncoding)); 974 975 if(aCommentStr.Len()) 976 { 977 ImpItemListRow aEntry; 978 aEntry.bComment=sal_True; 979 aEntry.aName=aCommentStr; 980 ImpSetEntry(aEntry,nEntryNum); 981 nEntryNum++; 982 } 983 nWhich0=nWhich; 984 ImpItemListRow aEntry; 985 SdrItemPool::TakeItemName(nWhich, aEntry.aName); 986 nIndent*=2; 987 988 while(nIndent > 0) 989 { 990 aEntry.aName.Insert(sal_Unicode(' '), 0); 991 nIndent--; 992 } 993 994 aEntry.eState=eState; 995 aEntry.nWhichId=nWhich; 996 if (!IsInvalidItem(&rItem)) { 997 aEntry.pType=rItem.Type(); 998 aEntry.nMax=0x7FFFFFFF; 999 aEntry.nMin=-aEntry.nMax; 1000 aEntry.nVal=-4711; 1001 if (HAS_BASE(SfxByteItem ,&rItem)) aEntry.eItemType=ITEM_BYTE; 1002 else if (HAS_BASE(SfxInt16Item ,&rItem)) aEntry.eItemType=ITEM_INT16; 1003 else if (HAS_BASE(SfxUInt16Item ,&rItem)) aEntry.eItemType=ITEM_UINT16; 1004 else if (HAS_BASE(SfxInt32Item ,&rItem)) aEntry.eItemType=ITEM_INT32; 1005 else if (HAS_BASE(SfxUInt32Item ,&rItem)) aEntry.eItemType=ITEM_UINT32; 1006 else if (HAS_BASE(SfxEnumItemInterface,&rItem)) aEntry.eItemType=ITEM_ENUM; 1007 else if (HAS_BASE(SfxBoolItem ,&rItem)) aEntry.eItemType=ITEM_BOOL; 1008 else if (HAS_BASE(SfxFlagItem ,&rItem)) aEntry.eItemType=ITEM_FLAG; 1009 else if (HAS_BASE(XColorItem ,&rItem)) aEntry.eItemType=ITEM_XCOLOR; 1010 else if (HAS_BASE(SfxStringItem ,&rItem)) aEntry.eItemType=ITEM_STRING; 1011 else if (HAS_BASE(SfxPointItem ,&rItem)) aEntry.eItemType=ITEM_POINT; 1012 else if (HAS_BASE(SfxRectangleItem,&rItem)) aEntry.eItemType=ITEM_RECT; 1013 else if (HAS_BASE(SfxRangeItem ,&rItem)) aEntry.eItemType=ITEM_RANGE; 1014 else if (HAS_BASE(SdrFractionItem ,&rItem)) aEntry.eItemType=ITEM_FRACTION; 1015 else if (HAS_BASE(SvxColorItem ,&rItem)) aEntry.eItemType=ITEM_COLOR; 1016 else if (HAS_BASE(SvxFontItem ,&rItem)) aEntry.eItemType=ITEM_FONT; 1017 else if (HAS_BASE(SvxFontHeightItem,&rItem))aEntry.eItemType=ITEM_FONTHEIGHT; 1018 else if (HAS_BASE(SvxCharScaleWidthItem,&rItem)) aEntry.eItemType=ITEM_FONTWIDTH; 1019 else if (HAS_BASE(SvxFieldItem ,&rItem)) aEntry.eItemType=ITEM_FIELD; 1020 switch (aEntry.eItemType) { 1021 case ITEM_BYTE : aEntry.bIsNum=sal_True; aEntry.nVal=((SfxByteItem &)rItem).GetValue(); aEntry.nMin=0; aEntry.nMax=255; break; 1022 case ITEM_INT16 : aEntry.bIsNum=sal_True; aEntry.nVal=((SfxInt16Item &)rItem).GetValue(); aEntry.nMin=-32767; aEntry.nMax=32767; break; 1023 case ITEM_UINT16 : aEntry.bIsNum=sal_True; aEntry.nVal=((SfxUInt16Item&)rItem).GetValue(); aEntry.nMin=0; aEntry.nMax=65535; break; 1024 case ITEM_INT32 : aEntry.bIsNum=sal_True; aEntry.nVal=((SfxInt32Item &)rItem).GetValue(); break; 1025 case ITEM_UINT32 : aEntry.bIsNum=sal_True; aEntry.nVal=((SfxUInt32Item&)rItem).GetValue(); aEntry.nMin=0; /*aEntry.nMax=0xFF...*/;break; 1026 case ITEM_ENUM : aEntry.bCanNum=sal_True; aEntry.nVal=((SfxEnumItemInterface&)rItem).GetEnumValue(); aEntry.nMin=0; aEntry.nMax=((SfxEnumItemInterface&)rItem).GetValueCount()-1; break; 1027 case ITEM_BOOL : aEntry.bCanNum=sal_True; aEntry.nVal=((SfxBoolItem &)rItem).GetValue(); aEntry.nMin=0; aEntry.nMax=1; break; 1028 case ITEM_FLAG : aEntry.bCanNum=sal_True; aEntry.nVal=((SfxFlagItem &)rItem).GetValue(); aEntry.nMin=0; aEntry.nMax=0xFFFF; break; 1029 case ITEM_FONTHEIGHT: aEntry.bCanNum=sal_True; aEntry.nVal=((SvxFontHeightItem&)rItem).GetHeight(); aEntry.nMin=0; break; 1030 case ITEM_FONTWIDTH : aEntry.bCanNum=sal_True; aEntry.nVal=((SvxCharScaleWidthItem&)rItem).GetValue(); aEntry.nMin=0; aEntry.nMax=0xFFFF;break; 1031 default: break; 1032 } // switch 1033 if (aEntry.bIsNum) aEntry.bCanNum=sal_True; 1034 FASTBOOL bGetPres=sal_True; 1035 if (bGetPres) { 1036 rItem.GetPresentation(SFX_ITEM_PRESENTATION_NAMELESS, 1037 pPool->GetMetric(nWhich), 1038 SFX_MAPUNIT_MM,aEntry.aValue); 1039 if (aEntry.bCanNum) { 1040 aEntry.aValue.InsertAscii(": ",0); 1041 aEntry.aValue.Insert(UniString::CreateFromInt32(aEntry.nVal),0); 1042 } 1043 } else { 1044 if (aEntry.eItemType==ITEM_BOOL) aEntry.aValue.AppendAscii(aEntry.nVal!=0 ? "True" : "False"); 1045 else if (aEntry.bCanNum) aEntry.aValue = UniString::CreateFromInt32(aEntry.nVal); 1046 else if (aEntry.eItemType==ITEM_STRING) aEntry.aValue=((SfxStringItem&)rItem).GetValue(); 1047 else if (aEntry.eItemType==ITEM_ENUM && nWhich!=EE_CHAR_WEIGHT) aEntry.aValue=((SfxEnumItemInterface&)rItem).GetValueTextByPos((sal_Bool)aEntry.nVal); 1048 else aEntry.aValue = String("GPF", aTextEncoding); 1049 } 1050 } else { 1051 aEntry.aValue = String("InvalidItem", aTextEncoding); 1052 } 1053 ImpSetEntry(aEntry,nEntryNum); 1054 nEntryNum++; 1055 } 1056 } 1057 nWhich=aIter.NextWhich(); 1058 } // while 1059 1060 if (aList.Count()>nEntryNum) { // evtl. noch zuviele Eintraege 1061 sal_uIntPtr nTooMuch=aList.Count()-nEntryNum; 1062 for (sal_uIntPtr nNum=0; nNum<nTooMuch; nNum++) { 1063 delete ImpGetEntry(nEntryNum); 1064 aList.Remove(nEntryNum); 1065 } 1066 RowRemoved(nEntryNum,nTooMuch); 1067 } 1068 } else { 1069 Clear(); // wenn pSet==NULL 1070 } 1071 ImpRestoreWhich(); 1072 SetMode(MYBROWSEMODE); 1073 } 1074 1075 //////////////////////////////////////////////////////////////////////////////////////////////////// 1076 1077 _SdrItemBrowserWindow::_SdrItemBrowserWindow(Window* pParent, WinBits nBits): 1078 FloatingWindow(pParent,nBits), 1079 aBrowse(this) 1080 { 1081 SetOutputSizePixel(aBrowse.GetSizePixel()); 1082 SetText(String("Joe's ItemBrowser", gsl_getSystemTextEncoding())); 1083 aBrowse.Show(); 1084 } 1085 1086 __EXPORT _SdrItemBrowserWindow::~_SdrItemBrowserWindow() 1087 { 1088 } 1089 1090 void __EXPORT _SdrItemBrowserWindow::Resize() 1091 { 1092 aBrowse.SetSizePixel(GetOutputSizePixel()); 1093 } 1094 1095 void __EXPORT _SdrItemBrowserWindow::GetFocus() 1096 { 1097 aBrowse.GrabFocus(); 1098 } 1099 1100 //////////////////////////////////////////////////////////////////////////////////////////////////// 1101 1102 SdrItemBrowser::SdrItemBrowser(SdrView& rView): 1103 _SdrItemBrowserWindow(ImpGetViewWin(rView)), 1104 pView(&rView), 1105 bDirty(sal_False) 1106 { 1107 aIdleTimer.SetTimeoutHdl(LINK(this,SdrItemBrowser,IdleHdl)); 1108 GetBrowserControl().SetEntryChangedHdl(LINK(this,SdrItemBrowser,ChangedHdl)); 1109 GetBrowserControl().SetSetDirtyHdl(LINK(this,SdrItemBrowser,SetDirtyHdl)); 1110 SetDirty(); 1111 } 1112 1113 Window* SdrItemBrowser::ImpGetViewWin(SdrView& rView) 1114 { 1115 const sal_uInt32 nWinCount(rView.PaintWindowCount()); 1116 1117 for(sal_uInt32 a(0L); a < nWinCount; a++) 1118 { 1119 SdrPaintWindow* pCandidate = rView.GetPaintWindow(a); 1120 1121 if(OUTDEV_WINDOW == pCandidate->GetOutputDevice().GetOutDevType()) 1122 { 1123 return (Window*)(&pCandidate->GetOutputDevice()); 1124 } 1125 } 1126 1127 return 0L; 1128 } 1129 1130 void SdrItemBrowser::ForceParent() 1131 { 1132 Window* pWin=ImpGetViewWin(*pView); 1133 if (pWin!=NULL) SetParent(pWin); 1134 } 1135 1136 void SdrItemBrowser::SetDirty() 1137 { 1138 if (!bDirty) { 1139 bDirty=sal_True; 1140 aIdleTimer.SetTimeout(1); 1141 aIdleTimer.Start(); 1142 } 1143 } 1144 1145 void SdrItemBrowser::Undirty() 1146 { 1147 aIdleTimer.Stop(); 1148 bDirty = sal_False; 1149 1150 // SfxItemSet aSet(pView->GetAttributes()); 1151 SfxItemSet aSet(pView->GetModel()->GetItemPool()); 1152 pView->GetAttributes(aSet); 1153 1154 if(pView->AreObjectsMarked()) 1155 { 1156 // SfxItemSet a2ndSet(pView->GetAttributes(sal_True)); 1157 SfxItemSet a2ndSet(pView->GetModel()->GetItemPool()); 1158 pView->GetAttributes(a2ndSet, sal_True); 1159 1160 SetAttributes(&aSet,&a2ndSet); 1161 } 1162 else 1163 { 1164 SetAttributes(&aSet); 1165 } 1166 } 1167 1168 IMPL_LINK(SdrItemBrowser,IdleHdl,Timer*,EMPTYARG) 1169 { 1170 Undirty(); 1171 return 0; 1172 } 1173 1174 IMPL_LINK(SdrItemBrowser,ChangedHdl,_SdrItemBrowserControl*,pBrowse) 1175 { 1176 const ImpItemListRow* pEntry=pBrowse->GetAktChangeEntry(); 1177 if (pEntry!=NULL) 1178 { 1179 // SfxItemSet aSet(pView->GetAttributes()); 1180 SfxItemSet aSet(pView->GetModel()->GetItemPool()); 1181 pView->GetAttributes(aSet); 1182 1183 SfxItemSet aNewSet(*aSet.GetPool(),pEntry->nWhichId,pEntry->nWhichId); 1184 XubString aNewText(pBrowse->GetNewEntryValue()); 1185 sal_Bool bDel( aNewText.EqualsAscii("del") 1186 || aNewText.EqualsAscii("Del") 1187 || aNewText.EqualsAscii("DEL") 1188 || aNewText.EqualsAscii("default") 1189 || aNewText.EqualsAscii("Default") 1190 || aNewText.EqualsAscii("DEFAULT")); 1191 1192 if (!bDel) { 1193 SfxPoolItem* pNewItem=aSet.Get(pEntry->nWhichId).Clone(); 1194 long nLongVal=0; 1195 nLongVal = aNewText.ToInt32(); 1196 if (pEntry->bCanNum) { 1197 if (nLongVal>pEntry->nMax) nLongVal=pEntry->nMax; 1198 if (nLongVal<pEntry->nMin) nLongVal=pEntry->nMin; 1199 } 1200 FASTBOOL bPair=sal_False; 1201 FASTBOOL bPairX=sal_True; 1202 FASTBOOL bPairY=sal_False; 1203 sal_uInt16 nSepLen=1; 1204 long nLongX = aNewText.ToInt32(); 1205 long nLongY=0; 1206 xub_StrLen nPos = aNewText.Search(sal_Unicode('/')); 1207 if (nPos==STRING_NOTFOUND) nPos=aNewText.Search(sal_Unicode(':')); 1208 if (nPos==STRING_NOTFOUND) nPos=aNewText.Search(sal_Unicode(' ')); 1209 if (nPos==STRING_NOTFOUND) { nPos=aNewText.SearchAscii(".."); if (nPos!=STRING_NOTFOUND) nSepLen=2; } 1210 if (nPos!=STRING_NOTFOUND) { 1211 bPair=sal_True; 1212 bPairX=nPos>0; 1213 XubString s(aNewText); 1214 s.Erase(0,nPos+nSepLen); 1215 bPairY = (sal_Bool)aNewText.Len(); 1216 nLongY = s.ToInt32(); 1217 } 1218 switch (pEntry->eItemType) { 1219 case ITEM_BYTE : ((SfxByteItem *)pNewItem)->SetValue((sal_uInt8 )nLongVal); break; 1220 case ITEM_INT16 : ((SfxInt16Item *)pNewItem)->SetValue((sal_Int16 )nLongVal); break; 1221 case ITEM_UINT16: ((SfxUInt16Item*)pNewItem)->SetValue((sal_uInt16)nLongVal); break; 1222 case ITEM_INT32: { 1223 if(HAS_BASE(SdrAngleItem, pNewItem)) 1224 { 1225 aNewText.SearchAndReplace(sal_Unicode(','), sal_Unicode('.')); 1226 double nVal = aNewText.ToFloat(); 1227 nLongVal = (long)(nVal * 100 + 0.5); 1228 } 1229 ((SfxInt32Item *)pNewItem)->SetValue((sal_Int32)nLongVal); 1230 } break; 1231 case ITEM_UINT32: ((SfxUInt32Item*)pNewItem)->SetValue(aNewText.ToInt32()); break; 1232 case ITEM_ENUM : ((SfxEnumItemInterface*)pNewItem)->SetEnumValue((sal_uInt16)nLongVal); break; 1233 case ITEM_BOOL: { 1234 aNewText.ToUpperAscii(); 1235 if (aNewText.EqualsAscii("TRUE")) nLongVal=1; 1236 if (aNewText.EqualsAscii("JA")) nLongVal=1; 1237 if (aNewText.EqualsAscii("AN")) nLongVal=1; 1238 if (aNewText.EqualsAscii("EIN")) nLongVal=1; 1239 if (aNewText.EqualsAscii("ON")) nLongVal=1; 1240 if (aNewText.EqualsAscii("YES")) nLongVal=1; 1241 ((SfxBoolItem*)pNewItem)->SetValue((sal_Bool)nLongVal); 1242 } break; 1243 case ITEM_FLAG : ((SfxFlagItem *)pNewItem)->SetValue((sal_uInt16)nLongVal); break; 1244 case ITEM_STRING: ((SfxStringItem*)pNewItem)->SetValue(aNewText); break; 1245 case ITEM_POINT : ((SfxPointItem*)pNewItem)->SetValue(Point(nLongX,nLongY)); break; 1246 case ITEM_RECT : break; 1247 case ITEM_RANGE : { 1248 ((SfxRangeItem*)pNewItem)->From()=(sal_uInt16)nLongX; 1249 ((SfxRangeItem*)pNewItem)->From()=(sal_uInt16)nLongY; 1250 } break; 1251 case ITEM_LRANGE : { 1252 } break; 1253 case ITEM_FRACTION: { 1254 if (!bPairX) nLongX=1; 1255 if (!bPairY) nLongY=1; 1256 ((SdrFractionItem*)pNewItem)->SetValue(Fraction(nLongX,nLongY)); 1257 } break; 1258 case ITEM_XCOLOR: break; 1259 case ITEM_COLOR: break; 1260 case ITEM_FONT: { 1261 ((SvxFontItem*)pNewItem)->SetFamily( FAMILY_DONTKNOW ); 1262 ((SvxFontItem*)pNewItem)->SetFamilyName(aNewText); 1263 ((SvxFontItem*)pNewItem)->SetStyleName( String() ); 1264 } break; 1265 case ITEM_FONTHEIGHT: { 1266 sal_uIntPtr nHgt=0; 1267 sal_uInt16 nProp=100; 1268 if (aNewText.Search(sal_Unicode('%'))!=STRING_NOTFOUND) { 1269 nProp=(sal_uInt16)nLongVal; 1270 } else { 1271 nHgt=nLongVal; 1272 } 1273 ((SvxFontHeightItem*)pNewItem)->SetHeight(nHgt,nProp); 1274 } break; 1275 case ITEM_FONTWIDTH: { 1276 sal_uInt16 nProp=100; 1277 if (aNewText.Search(sal_Unicode('%'))!=STRING_NOTFOUND) { 1278 nProp=(sal_uInt16)nLongVal; 1279 } 1280 ((SvxCharScaleWidthItem*)pNewItem)->SetValue(nProp); 1281 } break; 1282 case ITEM_FIELD: break; 1283 default: break; 1284 } // switch 1285 aNewSet.Put(*pNewItem); 1286 delete pNewItem; 1287 } 1288 pView->SetAttributes(aNewSet,bDel); 1289 } 1290 return 0; 1291 } 1292 1293 IMPL_LINK(SdrItemBrowser,SetDirtyHdl,_SdrItemBrowserControl*,EMPTYARG) 1294 { 1295 SetDirty(); 1296 return 0; 1297 } 1298 1299 1300