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