bump product version to 4.1.6.2
[LibreOffice.git] / svx / source / svdraw / svdibrow.cxx
blob75a3c79e38a7f3f8819da49bf3e1abc6704f2ef9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <editeng/eeitem.hxx>
22 #include "svdibrow.hxx"
24 #include <stdlib.h>
26 #include <editeng/flditem.hxx>
27 #include <editeng/editdata.hxx>
28 #include <svx/svdpool.hxx>
29 #include <svx/svdattr.hxx>
30 #include <svx/svdattrx.hxx>
31 #include <svx/svdview.hxx>
32 #include <svx/xenum.hxx>
33 #include <svx/xlineit0.hxx>
34 #include <svx/xlnstwit.hxx>
35 #include <svx/xlnedwit.hxx>
36 #include <svx/xfillit0.hxx>
37 #include <svx/xflbmtit.hxx>
38 #include <svx/xtextit0.hxx>
39 #include <svx/xflbstit.hxx>
40 #include <svx/xflbtoxy.hxx>
41 #include <svx/xftshit.hxx>
42 #include <editeng/colritem.hxx>
45 #include "editeng/fontitem.hxx"
46 #include <editeng/fhgtitem.hxx>
48 #include <editeng/charscaleitem.hxx>
49 #include <svl/whiter.hxx>
50 #include <svl/flagitem.hxx>
51 #include <svl/ptitem.hxx>
52 #include <svl/rectitem.hxx>
54 #include <svl/rngitem.hxx>
55 #include <svx/sdrpaintwindow.hxx>
57 ////////////////////////////////////////////////////////////////////////////////////////////////////
59 #define ITEMBROWSER_WHICHCOL_ID 1
60 #define ITEMBROWSER_STATECOL_ID 2
61 #define ITEMBROWSER_TYPECOL_ID 3
62 #define ITEMBROWSER_NAMECOL_ID 4
63 #define ITEMBROWSER_VALUECOL_ID 5
65 enum ItemType {
66 ITEM_DONTKNOW, ITEM_BYTE, ITEM_INT16, ITEM_UINT16, ITEM_INT32, ITEM_UINT32,
67 ITEM_ENUM, ITEM_BOOL, ITEM_FLAG, ITEM_STRING, ITEM_POINT, ITEM_RECT, ITEM_RANGE, ITEM_LRANGE,
68 ITEM_FRACTION,
69 ITEM_XCOLOR,
70 ITEM_COLOR,
71 ITEM_FONT, ITEM_FONTHEIGHT, ITEM_FONTWIDTH, ITEM_FIELD
74 class ImpItemListRow
76 public:
77 OUString aName;
78 OUString aValue;
79 SfxItemState eState;
80 sal_uInt16 nWhichId;
82 TypeId pType;
83 ItemType eItemType;
85 sal_Int32 nVal;
86 sal_Int32 nMin;
87 sal_Int32 nMax;
89 bool bComment;
90 bool bIsNum;
91 bool bCanNum;
93 public:
94 ImpItemListRow()
95 : eState(SFX_ITEM_UNKNOWN),
96 nWhichId(0),
97 pType(NULL),
98 eItemType(ITEM_DONTKNOW),
99 nVal(0),
100 nMin(0),
101 nMax(0),
102 bComment(false),
103 bIsNum(false),
104 bCanNum(false)
107 XubString GetItemTypeStr() const;
108 bool operator==(const ImpItemListRow& rEntry) const;
109 bool operator!=(const ImpItemListRow& rEntry) const { return !operator==(rEntry); }
112 XubString ImpItemListRow::GetItemTypeStr() const
114 XubString aStr;
116 switch(eItemType)
118 case ITEM_BYTE : aStr.AppendAscii("Byte"); break;
119 case ITEM_INT16 : aStr.AppendAscii("Int16"); break;
120 case ITEM_UINT16 : aStr.AppendAscii("UInt16"); break;
121 case ITEM_INT32 : aStr.AppendAscii("Int32"); break;
122 case ITEM_UINT32 : aStr.AppendAscii("UInt32"); break;
123 case ITEM_ENUM : aStr.AppendAscii("Enum"); break;
124 case ITEM_BOOL : aStr.AppendAscii("Bool"); break;
125 case ITEM_FLAG : aStr.AppendAscii("Flag"); break;
126 case ITEM_STRING : aStr.AppendAscii("String"); break;
127 case ITEM_POINT : aStr.AppendAscii("Point"); break;
128 case ITEM_RECT : aStr.AppendAscii("Rectangle");break;
129 case ITEM_RANGE : aStr.AppendAscii("Range"); break;
130 case ITEM_LRANGE : aStr.AppendAscii("LRange"); break;
131 case ITEM_FRACTION : aStr.AppendAscii("Fraction"); break;
132 case ITEM_XCOLOR : aStr.AppendAscii("XColor"); break;
133 case ITEM_COLOR : aStr.AppendAscii("Color"); break;
134 case ITEM_FONT : aStr.AppendAscii("Font"); break;
135 case ITEM_FONTHEIGHT:aStr.AppendAscii("FontHeight");break;
136 case ITEM_FONTWIDTH :aStr.AppendAscii("FontWidth"); break;
137 case ITEM_FIELD :aStr.AppendAscii("Field"); break;
138 default: break;
141 return aStr;
144 bool ImpItemListRow::operator==(const ImpItemListRow& rEntry) const
146 return (aName.equals(rEntry.aName)
147 && aValue.equals(rEntry.aValue)
148 && eState==rEntry.eState
149 && nWhichId==rEntry.nWhichId
150 && bComment==rEntry.bComment
151 && bIsNum==rEntry.bIsNum
152 && bCanNum==rEntry.bCanNum
153 && pType==rEntry.pType
154 && eItemType==rEntry.eItemType
155 && nVal==rEntry.nVal
156 && nMin==rEntry.nMin
157 && nMax==rEntry.nMax);
160 ////////////////////////////////////////////////////////////////////////////////////////////////////
162 class ImpItemEdit: public Edit
164 _SdrItemBrowserControl* pBrowse;
166 public:
167 ImpItemEdit(Window* pParent, _SdrItemBrowserControl* pBrowse_, WinBits nBits=0)
168 : Edit(pParent, nBits),
169 pBrowse(pBrowse_)
172 virtual ~ImpItemEdit();
173 virtual void KeyInput(const KeyEvent& rEvt);
176 ImpItemEdit::~ImpItemEdit()
180 void ImpItemEdit::KeyInput(const KeyEvent& rKEvt)
182 _SdrItemBrowserControl* pBrowseMerk = pBrowse;
184 sal_uInt16 nKeyCode(rKEvt.GetKeyCode().GetCode() + rKEvt.GetKeyCode().GetModifier());
186 if(nKeyCode == KEY_RETURN)
188 pBrowseMerk->EndChangeEntry();
189 pBrowseMerk->GrabFocus();
191 else if(nKeyCode == KEY_ESCAPE)
193 pBrowseMerk->BrkChangeEntry();
194 pBrowseMerk->GrabFocus();
196 else if(nKeyCode == KEY_UP || nKeyCode == KEY_DOWN)
198 pBrowseMerk->EndChangeEntry();
199 pBrowseMerk->GrabFocus();
200 pBrowseMerk->KeyInput(rKEvt);
202 else
203 Edit::KeyInput(rKEvt);
206 ////////////////////////////////////////////////////////////////////////////////////////////////////
208 #define MYBROWSEMODE (BROWSER_THUMBDRAGGING|BROWSER_KEEPHIGHLIGHT|BROWSER_NO_HSCROLL|BROWSER_HIDECURSOR)
210 _SdrItemBrowserControl::_SdrItemBrowserControl(Window* pParent, WinBits nBits):
211 BrowseBox(pParent,nBits,MYBROWSEMODE),
212 aList()
214 ImpCtor();
217 _SdrItemBrowserControl::~_SdrItemBrowserControl()
219 delete pEditControl;
221 delete pAktChangeEntry;
223 Clear();
226 void _SdrItemBrowserControl::ImpCtor()
228 pEditControl = NULL;
229 pAktChangeEntry = NULL;
230 nLastWhichOfs = 0;
231 nLastWhich = 0;
232 nLastWhichOben = 0; // not implemented yet
233 nLastWhichUnten = 0; // not implemented yet
234 bWhichesButNames = sal_False;
235 bDontHideIneffectiveItems = sal_False;
236 bDontSortItems = sal_False;
237 bShowWhichIds = sal_False;
238 bShowRealValues = sal_False;
239 bShowWhichIds = sal_True; // not implemented yet
240 bShowRealValues = sal_True; // not implemented yet
242 rtl_TextEncoding aTextEncoding = osl_getThreadTextEncoding();
244 InsertDataColumn(
245 ITEMBROWSER_WHICHCOL_ID,
246 String("Which", aTextEncoding),
247 GetTextWidth(String(" Which ", aTextEncoding)) + 2);
248 InsertDataColumn(
249 ITEMBROWSER_STATECOL_ID,
250 String("State", aTextEncoding),
251 std::max(GetTextWidth(String(" State ", aTextEncoding)) + 2 ,
252 GetTextWidth(String("DontCare", aTextEncoding)) + 2));
253 InsertDataColumn(
254 ITEMBROWSER_TYPECOL_ID ,
255 String("Type", aTextEncoding),
256 GetTextWidth(String(" Type_ ", aTextEncoding)) + 2);
257 InsertDataColumn(
258 ITEMBROWSER_NAMECOL_ID ,
259 String("Name", aTextEncoding),
260 150);
261 InsertDataColumn(
262 ITEMBROWSER_VALUECOL_ID,
263 String("Value", aTextEncoding),
264 GetTextWidth(String("12345678901234567890", aTextEncoding)));
265 SetDataRowHeight(
266 GetTextHeight());
268 long nWdt=GetColumnWidth(ITEMBROWSER_WHICHCOL_ID)+
269 GetColumnWidth(ITEMBROWSER_STATECOL_ID)+
270 GetColumnWidth(ITEMBROWSER_TYPECOL_ID )+
271 GetColumnWidth(ITEMBROWSER_NAMECOL_ID )+
272 GetColumnWidth(ITEMBROWSER_VALUECOL_ID);
274 long nHgt=GetTitleHeight()+16*GetDataRowHeight();
276 SetOutputSizePixel(Size(nWdt,nHgt));
279 void _SdrItemBrowserControl::Clear()
281 sal_uIntPtr nAnz=aList.size();
282 for (sal_uIntPtr nNum=0; nNum<nAnz; nNum++) {
283 delete ImpGetEntry(nNum);
285 aList.clear();
286 BrowseBox::Clear();
289 long _SdrItemBrowserControl::GetRowCount() const
291 return aList.size();
294 sal_Bool _SdrItemBrowserControl::SeekRow(long nRow)
296 nAktPaintRow=nRow;
297 return sal_True;
300 String _SdrItemBrowserControl::GetCellText(long _nRow, sal_uInt16 _nColId) const
302 String sRet;
303 if ( _nRow >= 0 && _nRow < (sal_Int32)aList.size() )
305 ImpItemListRow* pEntry = ImpGetEntry(_nRow);
306 if ( pEntry )
308 if ( pEntry->bComment )
310 if (_nColId == ITEMBROWSER_NAMECOL_ID)
311 sRet = pEntry->aName;
313 else
315 rtl_TextEncoding aTextEncoding = osl_getThreadTextEncoding();
317 sRet = XubString("???", aTextEncoding);
318 switch (_nColId)
320 case ITEMBROWSER_WHICHCOL_ID:
321 sRet = OUString::valueOf( static_cast<sal_Int32>(pEntry->nWhichId) ); break;
322 case ITEMBROWSER_STATECOL_ID:
324 switch (pEntry->eState)
326 case SFX_ITEM_UNKNOWN : sRet=String("Uknown", aTextEncoding); break;
327 case SFX_ITEM_DISABLED: sRet=String("Disabled", aTextEncoding); break;
328 case SFX_ITEM_DONTCARE: sRet=String("DontCare", aTextEncoding); break;
329 case SFX_ITEM_SET : sRet=String("Set", aTextEncoding); break;
330 case SFX_ITEM_DEFAULT : sRet=String("Default", aTextEncoding); break;
331 } // switch
332 } break;
333 case ITEMBROWSER_TYPECOL_ID: sRet = pEntry->GetItemTypeStr(); break;
334 case ITEMBROWSER_NAMECOL_ID: sRet = pEntry->aName; break;
335 case ITEMBROWSER_VALUECOL_ID: sRet = pEntry->aValue; break;
336 } // switch
340 return sRet;
343 void _SdrItemBrowserControl::PaintField(OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId) const
345 if (nAktPaintRow<0 || (sal_uIntPtr)nAktPaintRow>=aList.size()) {
346 return;
348 Rectangle aR(rRect);
349 aR.Bottom()++;
350 ImpItemListRow* pEntry=ImpGetEntry(nAktPaintRow);
351 if (pEntry->bComment)
353 if (nColumnId==ITEMBROWSER_NAMECOL_ID)
355 rDev.SetLineColor();
356 rDev.SetFillColor( Color( COL_LIGHTGRAY ) );
357 aR.Left()=0;
358 aR.Right()=rDev.GetOutputSize().Width();
359 rDev.DrawRect(aR);
360 rDev.DrawText(rRect.TopLeft(),pEntry->aName);
362 } else {
363 rDev.SetClipRegion(Region(aR));
364 rDev.DrawText(aR.TopLeft(),GetCellText(nAktPaintRow,nColumnId));
365 rDev.SetClipRegion();
369 sal_uIntPtr _SdrItemBrowserControl::GetCurrentPos() const
371 sal_uIntPtr nRet=CONTAINER_ENTRY_NOTFOUND;
372 if (GetSelectRowCount()==1) {
373 long nPos=((BrowseBox*)this)->FirstSelectedRow();
374 if (nPos>=0 && (sal_uIntPtr)nPos<aList.size()) {
375 nRet=(sal_uIntPtr)nPos;
378 return nRet;
381 sal_uInt16 _SdrItemBrowserControl::GetCurrentWhich() const
383 sal_uInt16 nRet=0;
384 sal_uIntPtr nPos=GetCurrentPos();
385 if (nPos!=CONTAINER_ENTRY_NOTFOUND) {
386 nRet=ImpGetEntry(nPos)->nWhichId;
388 return nRet;
391 void _SdrItemBrowserControl::DoubleClick(const BrowserMouseEvent&)
393 sal_uIntPtr nPos=GetCurrentPos();
394 if (nPos!=CONTAINER_ENTRY_NOTFOUND) {
395 BegChangeEntry(nPos);
399 void _SdrItemBrowserControl::KeyInput(const KeyEvent& rKEvt)
401 sal_uInt16 nKeyCode=rKEvt.GetKeyCode().GetCode()+rKEvt.GetKeyCode().GetModifier();
402 bool bAusgewertet = false;
403 sal_uIntPtr nPos=GetCurrentPos();
404 if (nPos!=CONTAINER_ENTRY_NOTFOUND) {
405 if (nKeyCode==KEY_RETURN) {
406 if (BegChangeEntry(nPos)) bAusgewertet = true;
407 } else if (nKeyCode==KEY_ESCAPE) {
408 // ...
409 } else if (rKEvt.GetKeyCode().GetModifier()==KEY_SHIFT+KEY_MOD1+KEY_MOD2) { // Ctrl
410 if (nKeyCode==KEY_SHIFT+KEY_MOD1+KEY_MOD2+KEY_W) {
411 bWhichesButNames=!bWhichesButNames;
412 SetDirty();
414 if (nKeyCode==KEY_SHIFT+KEY_MOD1+KEY_MOD2+KEY_I) {
415 bDontHideIneffectiveItems=!bDontHideIneffectiveItems;
416 SetDirty();
418 if (nKeyCode==KEY_SHIFT+KEY_MOD1+KEY_MOD2+KEY_S) {
419 bDontSortItems=!bDontSortItems;
420 SetDirty();
424 if (!bAusgewertet) BrowseBox::KeyInput(rKEvt);
427 void _SdrItemBrowserControl::SetDirty()
429 aSetDirtyHdl.Call(this);
432 Rectangle _SdrItemBrowserControl::GetFieldCharacterBounds(sal_Int32 /*_nRow*/,sal_Int32 /*_nColumnPos*/,sal_Int32 /*nIndex*/)
434 // no accessibility implementation required
435 return Rectangle();
438 sal_Int32 _SdrItemBrowserControl::GetFieldIndexAtPoint(sal_Int32 /*_nRow*/,sal_Int32 /*_nColumnPos*/,const Point& /*_rPoint*/)
440 // no accessibility implementation required
441 return -1;
444 void _SdrItemBrowserControl::Select()
446 EndChangeEntry();
447 BrowseBox::Select();
448 ImpSaveWhich();
451 void _SdrItemBrowserControl::ImpSaveWhich()
453 sal_uInt16 nWh=GetCurrentWhich();
454 if (nWh!=0) {
455 long nPos=GetCurrentPos();
456 long nTop=GetTopRow();
457 long nBtm=GetTopRow()+GetVisibleRows()+1;
458 nLastWhich=nWh;
459 nLastWhichOfs=nPos-nTop;
460 if (nTop<0) nTop=0;
461 if (nBtm>=(long)aList.size()) nBtm=aList.size()-1;
462 nLastWhichOben=ImpGetEntry(nTop)->nWhichId;
463 nLastWhichUnten=ImpGetEntry(nBtm)->nWhichId;
467 void _SdrItemBrowserControl::ImpRestoreWhich()
469 if (nLastWhich!=0) {
470 bool bFnd = false;
471 sal_uIntPtr nAnz=aList.size();
472 sal_uIntPtr nNum;
473 for (nNum=0; nNum<nAnz && !bFnd; nNum++) {
474 ImpItemListRow* pEntry=ImpGetEntry(nNum);
475 if (!pEntry->bComment) {
476 sal_uInt16 nWh=pEntry->nWhichId;
477 if (nWh==nLastWhich) bFnd = true;
480 if (bFnd) {
481 long nPos=nNum-1;
482 long nWhichOfs=nPos-GetTopRow();
483 if (nWhichOfs!=nLastWhichOfs) {
484 ScrollRows(nWhichOfs-nLastWhichOfs);
486 GoToRow(nPos);
491 bool _SdrItemBrowserControl::BegChangeEntry(sal_uIntPtr nPos)
493 BrkChangeEntry();
494 bool bRet = false;
495 ImpItemListRow* pEntry=ImpGetEntry(nPos);
496 if (pEntry!=NULL && !pEntry->bComment) {
497 SetMode(MYBROWSEMODE & ~BROWSER_KEEPHIGHLIGHT);
498 pEditControl=new ImpItemEdit(&GetDataWindow(),this,0);
499 Rectangle aRect(GetFieldRectPixel(nPos,ITEMBROWSER_VALUECOL_ID,sal_False));
500 aRect.Left()+=2; // little offset for the Edit, so it's exact to the pixel
501 aRect.Right()--;
502 pEditControl->SetPosSizePixel(aRect.TopLeft(),aRect.GetSize());
503 pEditControl->SetText(pEntry->aValue);
504 pEditControl->SetBackground( Wallpaper(Color(COL_LIGHTGRAY)));
505 Font aFont(pEditControl->GetFont());
506 aFont.SetFillColor(Color(COL_LIGHTGRAY));
507 pEditControl->SetFont(aFont);
508 pEditControl->Show();
509 pEditControl->GrabFocus();
510 pEditControl->SetSelection(Selection(SELECTION_MIN,SELECTION_MAX));
511 Window* pParent=GetParent();
512 aWNamMerk=pParent->GetText();
513 XubString aNeuNam(aWNamMerk);
514 aNeuNam += sal_Unicode(' ');
515 aNeuNam += pEntry->GetItemTypeStr();
516 if (pEntry->bCanNum) {
517 aNeuNam.AppendAscii(": ");
518 aNeuNam += OUString::valueOf(pEntry->nMin);
519 aNeuNam.AppendAscii("..");
520 aNeuNam += OUString::valueOf(pEntry->nMax);
522 aNeuNam.AppendAscii(" - Type 'del' to reset to default.");
523 pParent->SetText(aNeuNam);
524 pAktChangeEntry=new ImpItemListRow(*pEntry);
525 bRet = true;
527 return bRet;
530 bool _SdrItemBrowserControl::EndChangeEntry()
532 bool bRet = false;
533 if (pEditControl!=NULL) {
534 aEntryChangedHdl.Call(this);
535 delete pEditControl;
536 pEditControl=NULL;
537 delete pAktChangeEntry;
538 pAktChangeEntry=NULL;
539 Window* pParent=GetParent();
540 pParent->SetText(aWNamMerk);
541 SetMode(MYBROWSEMODE);
542 bRet = true;
544 return bRet;
547 void _SdrItemBrowserControl::BrkChangeEntry()
549 if (pEditControl!=NULL) {
550 delete pEditControl;
551 pEditControl=NULL;
552 delete pAktChangeEntry;
553 pAktChangeEntry=NULL;
554 Window* pParent=GetParent();
555 pParent->SetText(aWNamMerk);
556 SetMode(MYBROWSEMODE);
560 void _SdrItemBrowserControl::ImpSetEntry(const ImpItemListRow& rEntry, sal_uIntPtr nEntryNum)
562 SAL_WARN_IF(nEntryNum > aList.size(), "svx", "trying to set item " << nEntryNum << "in a vector of size " << aList.size());
563 if (nEntryNum >= aList.size()) {
564 nEntryNum = aList.size();
565 aList.push_back(new ImpItemListRow(rEntry));
566 RowInserted(nEntryNum);
567 } else {
568 ImpItemListRow* pAktEntry=ImpGetEntry(nEntryNum);
569 if (*pAktEntry!=rEntry) {
570 bool bStateDiff=rEntry.eState!=pAktEntry->eState;
571 bool bValueDiff=!rEntry.aValue.equals(pAktEntry->aValue);
572 bool bAllDiff = true;
573 if (bStateDiff || bValueDiff) {
574 // check whether only state and/or value have changed
575 ImpItemListRow aTest(rEntry);
576 aTest.eState=pAktEntry->eState;
577 aTest.aValue=pAktEntry->aValue;
578 if (aTest==*pAktEntry) bAllDiff = false;
580 *pAktEntry=rEntry;
581 if (bAllDiff) {
582 RowModified(nEntryNum);
583 } else {
584 if (bStateDiff) RowModified(nEntryNum,ITEMBROWSER_STATECOL_ID);
585 if (bValueDiff) RowModified(nEntryNum,ITEMBROWSER_VALUECOL_ID);
591 bool ImpGetItem(const SfxItemSet& rSet, sal_uInt16 nWhich, const SfxPoolItem*& rpItem)
593 SfxItemState eState=rSet.GetItemState(nWhich,sal_True,&rpItem);
594 if (eState==SFX_ITEM_DEFAULT) {
595 rpItem=&rSet.Get(nWhich);
597 return (eState==SFX_ITEM_DEFAULT || eState==SFX_ITEM_SET) && rpItem!=NULL;
600 bool IsItemIneffective(sal_uInt16 nWhich, const SfxItemSet* pSet, sal_uInt16& rIndent)
602 rIndent=0;
603 if (pSet==NULL) return sal_False;
604 const SfxPoolItem* pItem=NULL;
605 bool bRet = false;
606 switch (nWhich) {
607 case XATTR_LINEDASH :
608 case XATTR_LINEWIDTH :
609 case XATTR_LINECOLOR :
610 case XATTR_LINESTART :
611 case XATTR_LINEEND :
612 case XATTR_LINESTARTWIDTH :
613 case XATTR_LINEENDWIDTH :
614 case XATTR_LINESTARTCENTER :
615 case XATTR_LINEENDCENTER :
616 case XATTR_LINETRANSPARENCE : {
617 rIndent=1;
618 if (ImpGetItem(*pSet,XATTR_LINESTYLE,pItem)) {
619 XLineStyle eLineStyle=((const XLineStyleItem*)pItem)->GetValue();
620 if (eLineStyle==XLINE_NONE) return sal_True;
621 if (eLineStyle!=XLINE_DASH && nWhich==XATTR_LINEDASH) return sal_True;
623 if (nWhich==XATTR_LINESTART || nWhich==XATTR_LINESTARTCENTER) {
624 rIndent=2;
625 if (ImpGetItem(*pSet,XATTR_LINESTARTWIDTH,pItem)) {
626 sal_Int32 nWdt=((const XLineStartWidthItem*)pItem)->GetValue();
627 if (nWdt==0) return sal_True;
630 if (nWhich==XATTR_LINEEND || nWhich==XATTR_LINEENDCENTER) {
631 rIndent=2;
632 if (ImpGetItem(*pSet,XATTR_LINEENDWIDTH,pItem)) {
633 sal_Int32 nWdt=((const XLineEndWidthItem*)pItem)->GetValue();
634 if (nWdt==0) return sal_True;
637 } break;
638 case XATTR_FILLCOLOR : /* only for Style=Color */
639 case XATTR_FILLGRADIENT : /* only for Style=Gradient */
640 case XATTR_FILLHATCH : /* only for Style=Hatch */
641 case XATTR_FILLTRANSPARENCE : /* only for Style=Color */
642 case XATTR_GRADIENTSTEPCOUNT : /* only for Style=Gradient */
643 case XATTR_FILLBACKGROUND : /* only for Style=Hatch */
645 rIndent=1;
646 if (ImpGetItem(*pSet,XATTR_FILLSTYLE,pItem)) {
647 XFillStyle eFillStyle=((const XFillStyleItem*)pItem)->GetValue();
648 if (eFillStyle==XFILL_NONE) return sal_True;
649 // transparency currently only for SolidFill
650 if (eFillStyle!=XFILL_SOLID && (nWhich==XATTR_FILLCOLOR || nWhich==XATTR_FILLTRANSPARENCE)) return sal_True;
651 if (eFillStyle!=XFILL_GRADIENT && (nWhich==XATTR_FILLGRADIENT || nWhich==XATTR_GRADIENTSTEPCOUNT)) return sal_True;
652 if (eFillStyle!=XFILL_HATCH && (nWhich==XATTR_FILLHATCH || nWhich==XATTR_FILLBACKGROUND)) return sal_True;
654 } break;
655 case XATTR_FILLBITMAP :
656 case XATTR_FILLBMP_TILE :
657 case XATTR_FILLBMP_POS : /* currently only if TILE=sal_True */
658 case XATTR_FILLBMP_SIZEX : /* only if not Stretch */
659 case XATTR_FILLBMP_SIZEY : /* only if not Stretch */
660 case XATTR_FILLBMP_SIZELOG : /* only if SIZELOG=sal_False to reset to sal_True (old) -> but is still in use */
661 case XATTR_FILLBMP_TILEOFFSETX : /* only if TILE=sal_True */
662 case XATTR_FILLBMP_TILEOFFSETY : /* only if TILE=sal_True */
663 case XATTR_FILLBMP_STRETCH : /* only if TILE=sal_False */
664 case XATTR_FILLBMP_POSOFFSETX : /* only if TILE=sal_True*/
665 case XATTR_FILLBMP_POSOFFSETY : { /* only if TILE=sal_True*/
666 rIndent=1;
667 if (ImpGetItem(*pSet,XATTR_FILLSTYLE,pItem)) {
668 XFillStyle eFillStyle=((const XFillStyleItem*)pItem)->GetValue();
669 if (eFillStyle!=XFILL_BITMAP) return sal_True;
671 if (nWhich==XATTR_FILLBITMAP || nWhich==XATTR_FILLBMP_TILE) {
672 return sal_False; // always selectable
674 bool bTileTRUE = false;
675 bool bTileFALSE = false;
676 bool bStretchTRUE = false;
677 if (ImpGetItem(*pSet,XATTR_FILLBMP_TILE,pItem)) {
678 bTileTRUE=((const XFillBmpTileItem*)pItem)->GetValue();
679 bTileFALSE=!bTileTRUE;
681 if (ImpGetItem(*pSet,XATTR_FILLBMP_STRETCH,pItem)) {
682 bStretchTRUE=((const XFillBmpStretchItem*)pItem)->GetValue();
684 // Stretch not selectable if Tile=TRUE
685 if (nWhich==XATTR_FILLBMP_STRETCH) return bTileTRUE;
686 // and 7+1 items (sub-attributes) remain
687 rIndent=2;
688 // Pos (enum) not selectable if Tile=FALSE
689 if (nWhich==XATTR_FILLBMP_POS) return bTileFALSE;
690 // SizeXY not selectable if Stretch=TRUE
691 if (nWhich==XATTR_FILLBMP_SIZEX || nWhich==XATTR_FILLBMP_SIZEY) {
692 return bTileFALSE && bStretchTRUE;
694 // 2 items specially for Tile
695 if (nWhich==XATTR_FILLBMP_POSOFFSETX || nWhich==XATTR_FILLBMP_POSOFFSETY) {
696 return bTileFALSE;
698 // another 2 items specially for Tile -- however, these exclude each other
699 if (nWhich==XATTR_FILLBMP_TILEOFFSETX || nWhich==XATTR_FILLBMP_TILEOFFSETY) {
700 if (bTileFALSE) return sal_True;
701 sal_uInt16 nX=0,nY=0;
702 bool bX = false,bY = false;
703 if (ImpGetItem(*pSet,XATTR_FILLBMP_TILEOFFSETX,pItem)) {
704 nX=((const XFillBmpTileOffsetXItem*)pItem)->GetValue();
705 bX = true;
707 if (ImpGetItem(*pSet,XATTR_FILLBMP_TILEOFFSETY,pItem)) {
708 nY=((const XFillBmpTileOffsetYItem*)pItem)->GetValue();
709 bY = true;
711 if (nWhich==XATTR_FILLBMP_TILEOFFSETX) {
712 if (nX!=0 || !bX) return sal_False;
713 if (nY!=0) return sal_True;
714 } else {
715 if (nY!=0 || !bY) return sal_False;
716 if (nX!=0) return sal_True;
719 // SizeLog not selectable if Stretch=TRUE and/or
720 // if SizeLog=sal_False.
721 // -> apparently still in use
722 // (sal_True is the static PoolDefault)
723 if (nWhich==XATTR_FILLBMP_SIZELOG) {
724 if (bTileFALSE && bStretchTRUE) return sal_True;
726 } break;
728 case XATTR_FORMTXTADJUST :
729 case XATTR_FORMTXTDISTANCE :
730 case XATTR_FORMTXTSTART :
731 case XATTR_FORMTXTMIRROR :
732 case XATTR_FORMTXTOUTLINE :
733 case XATTR_FORMTXTSHADOW :
734 case XATTR_FORMTXTSHDWCOLOR :
735 case XATTR_FORMTXTSHDWXVAL :
736 case XATTR_FORMTXTSHDWYVAL :
737 case XATTR_FORMTXTSTDFORM :
738 case XATTR_FORMTXTHIDEFORM :
739 case XATTR_FORMTXTSHDWTRANSP: {
740 rIndent=1;
741 if (ImpGetItem(*pSet,XATTR_FORMTXTSTYLE,pItem)) {
742 XFormTextStyle eStyle=((const XFormTextStyleItem*)pItem)->GetValue();
743 if (eStyle==XFT_NONE) return sal_True;
745 if ((nWhich>=XATTR_FORMTXTSHDWCOLOR && nWhich<=XATTR_FORMTXTSHDWYVAL) || nWhich>=XATTR_FORMTXTSHDWTRANSP) {
746 rIndent=2;
747 if (ImpGetItem(*pSet,XATTR_FORMTXTSHADOW,pItem)) {
748 XFormTextShadow eShadow=((const XFormTextShadowItem*)pItem)->GetValue();
749 if (eShadow==XFTSHADOW_NONE) return sal_True;
752 } break;
754 case SDRATTR_SHADOWCOLOR :
755 case SDRATTR_SHADOWXDIST :
756 case SDRATTR_SHADOWYDIST :
757 case SDRATTR_SHADOWTRANSPARENCE:
758 case SDRATTR_SHADOW3D :
759 case SDRATTR_SHADOWPERSP : {
760 rIndent=1;
761 if (ImpGetItem(*pSet,SDRATTR_SHADOW,pItem)) {
762 bool bShadow=((const SdrShadowItem*)pItem)->GetValue();
763 if (!bShadow) return sal_True;
765 } break;
767 case SDRATTR_CAPTIONANGLE: {
768 rIndent=1;
769 if (ImpGetItem(*pSet,SDRATTR_CAPTIONFIXEDANGLE,pItem)) {
770 bool bFixed=((const SdrCaptionFixedAngleItem*)pItem)->GetValue();
771 if (!bFixed) return sal_True;
773 } break;
774 case SDRATTR_CAPTIONESCREL:
775 case SDRATTR_CAPTIONESCABS: {
776 rIndent=1;
777 if (ImpGetItem(*pSet,SDRATTR_CAPTIONESCISREL,pItem)) {
778 bool bRel=((const SdrCaptionEscIsRelItem*)pItem)->GetValue();
779 if (bRel && nWhich==SDRATTR_CAPTIONESCABS) return sal_True;
780 if (!bRel && nWhich==SDRATTR_CAPTIONESCREL) return sal_True;
782 } break;
783 case SDRATTR_CAPTIONLINELEN: {
784 rIndent=1;
785 if (ImpGetItem(*pSet,SDRATTR_CAPTIONFITLINELEN,pItem)) {
786 bool bFit=((const SdrCaptionFitLineLenItem*)pItem)->GetValue();
787 if (bFit) return sal_True;
789 } break;
791 case SDRATTR_TEXT_MINFRAMEHEIGHT:
792 case SDRATTR_TEXT_MAXFRAMEHEIGHT: {
793 rIndent=1;
794 if (ImpGetItem(*pSet,SDRATTR_TEXT_AUTOGROWHEIGHT,pItem)) {
795 bool bAutoGrow=((const SdrTextAutoGrowHeightItem*)pItem)->GetValue();
796 if (!bAutoGrow) return sal_True;
798 } break;
799 case SDRATTR_TEXT_MINFRAMEWIDTH:
800 case SDRATTR_TEXT_MAXFRAMEWIDTH: {
801 rIndent=1;
802 if (ImpGetItem(*pSet,SDRATTR_TEXT_AUTOGROWWIDTH,pItem)) {
803 bool bAutoGrow=((const SdrTextAutoGrowWidthItem*)pItem)->GetValue();
804 if (!bAutoGrow) return sal_True;
806 } break;
807 case SDRATTR_TEXT_VERTADJUST:
808 case SDRATTR_TEXT_HORZADJUST: {
809 if (ImpGetItem(*pSet,SDRATTR_TEXT_FITTOSIZE,pItem)) {
810 SdrFitToSizeType eFit=((const SdrTextFitToSizeTypeItem*)pItem)->GetValue();
811 if (eFit!=SDRTEXTFIT_NONE) return sal_True;
813 } break;
815 case SDRATTR_TEXT_ANIDIRECTION :
816 case SDRATTR_TEXT_ANISTARTINSIDE:
817 case SDRATTR_TEXT_ANISTOPINSIDE :
818 case SDRATTR_TEXT_ANICOUNT :
819 case SDRATTR_TEXT_ANIDELAY :
820 case SDRATTR_TEXT_ANIAMOUNT : {
821 rIndent=1;
822 if (ImpGetItem(*pSet,SDRATTR_TEXT_ANIKIND,pItem)) {
823 SdrTextAniKind eAniKind=((const SdrTextAniKindItem*)pItem)->GetValue();
824 if (eAniKind==SDRTEXTANI_NONE) return sal_True;
825 if (eAniKind==SDRTEXTANI_BLINK && (nWhich==SDRATTR_TEXT_ANIDIRECTION || nWhich==SDRATTR_TEXT_ANIAMOUNT)) return sal_True;
826 if (eAniKind==SDRTEXTANI_SLIDE && (nWhich==SDRATTR_TEXT_ANISTARTINSIDE || nWhich==SDRATTR_TEXT_ANISTOPINSIDE)) return sal_True;
828 } break;
830 case SDRATTR_EDGELINEDELTAANZ: return sal_True;
831 case SDRATTR_EDGELINE1DELTA:
832 case SDRATTR_EDGELINE2DELTA:
833 case SDRATTR_EDGELINE3DELTA: {
834 if (ImpGetItem(*pSet,SDRATTR_EDGEKIND,pItem)) {
835 SdrEdgeKind eKind=((const SdrEdgeKindItem*)pItem)->GetValue();
836 if (eKind==SDREDGE_THREELINES) {
837 if (nWhich>SDRATTR_EDGELINE2DELTA) return sal_True;
838 else return sal_False;
840 if (eKind!=SDREDGE_ORTHOLINES && eKind!=SDREDGE_BEZIER) return sal_True;
842 if (ImpGetItem(*pSet,SDRATTR_EDGELINEDELTAANZ,pItem)) {
843 sal_uInt16 nAnz=((const SdrEdgeLineDeltaAnzItem*)pItem)->GetValue();
844 if (nAnz==0) return sal_True;
845 if (nAnz==1 && nWhich>SDRATTR_EDGELINE1DELTA) return sal_True;
846 if (nAnz==2 && nWhich>SDRATTR_EDGELINE2DELTA) return sal_True;
847 if (nAnz==3 && nWhich>SDRATTR_EDGELINE3DELTA) return sal_True;
849 } break;
851 case SDRATTR_CIRCSTARTANGLE:
852 case SDRATTR_CIRCENDANGLE : {
853 rIndent=1;
854 if (ImpGetItem(*pSet,SDRATTR_CIRCKIND,pItem)) {
855 SdrCircKind eKind=((const SdrCircKindItem*)pItem)->GetValue();
856 if (eKind==SDRCIRC_FULL) return sal_True;
858 } break;
859 } // switch
860 return bRet;
863 sal_uInt16 ImpSortWhich(sal_uInt16 nWhich)
865 switch (nWhich) {
866 // Line
867 case XATTR_LINESTART : nWhich=XATTR_LINETRANSPARENCE ; break;
868 case XATTR_LINEEND : nWhich=XATTR_LINESTARTWIDTH ; break;
869 case XATTR_LINESTARTWIDTH : nWhich=XATTR_LINESTART ; break;
870 case XATTR_LINEENDWIDTH : nWhich=XATTR_LINESTARTCENTER ; break;
871 case XATTR_LINESTARTCENTER : nWhich=XATTR_LINEENDWIDTH ; break;
872 case XATTR_LINEENDCENTER : nWhich=XATTR_LINEEND ; break;
873 case XATTR_LINETRANSPARENCE : nWhich=XATTR_LINEENDCENTER ; break;
875 // Fill
876 case XATTR_FILLBMP_POS : nWhich=XATTR_FILLBMP_STRETCH ; break;
877 case XATTR_FILLBMP_SIZEX : nWhich=XATTR_FILLBMP_POS ; break;
878 case XATTR_FILLBMP_SIZEY : nWhich=XATTR_FILLBMP_SIZEX ; break;
879 case XATTR_FILLBMP_SIZELOG : nWhich=XATTR_FILLBMP_SIZEY ; break;
880 case XATTR_FILLBMP_TILEOFFSETX : nWhich=XATTR_FILLBMP_SIZELOG ; break;
881 case XATTR_FILLBMP_TILEOFFSETY : nWhich=XATTR_FILLBMP_TILEOFFSETX ; break;
882 case XATTR_FILLBMP_STRETCH : nWhich=XATTR_FILLBMP_TILEOFFSETY ; break;
884 // Fontwork
885 case XATTR_FORMTXTSHADOW : nWhich=XATTR_FORMTXTSTDFORM ; break;
886 case XATTR_FORMTXTSHDWCOLOR : nWhich=XATTR_FORMTXTHIDEFORM ; break;
887 case XATTR_FORMTXTSHDWXVAL : nWhich=XATTR_FORMTXTSHADOW ; break;
888 case XATTR_FORMTXTSHDWYVAL : nWhich=XATTR_FORMTXTSHDWCOLOR ; break;
889 case XATTR_FORMTXTSTDFORM : nWhich=XATTR_FORMTXTSHDWXVAL ; break;
890 case XATTR_FORMTXTHIDEFORM : nWhich=XATTR_FORMTXTSHDWYVAL ; break;
892 // Misc
893 case SDRATTR_TEXT_MINFRAMEHEIGHT: nWhich=SDRATTR_TEXT_FITTOSIZE ; break;
894 case SDRATTR_TEXT_AUTOGROWHEIGHT: nWhich=SDRATTR_TEXT_LEFTDIST ; break;
895 case SDRATTR_TEXT_FITTOSIZE : nWhich=SDRATTR_TEXT_RIGHTDIST ; break;
896 case SDRATTR_TEXT_LEFTDIST : nWhich=SDRATTR_TEXT_UPPERDIST ; break;
897 case SDRATTR_TEXT_RIGHTDIST : nWhich=SDRATTR_TEXT_LOWERDIST ; break;
898 case SDRATTR_TEXT_UPPERDIST : nWhich=SDRATTR_TEXT_AUTOGROWWIDTH ; break;
899 case SDRATTR_TEXT_LOWERDIST : nWhich=SDRATTR_TEXT_MINFRAMEWIDTH ; break;
900 case SDRATTR_TEXT_VERTADJUST : nWhich=SDRATTR_TEXT_MAXFRAMEWIDTH ; break;
901 case SDRATTR_TEXT_MAXFRAMEHEIGHT: nWhich=SDRATTR_TEXT_AUTOGROWHEIGHT; break;
902 case SDRATTR_TEXT_MINFRAMEWIDTH : nWhich=SDRATTR_TEXT_MINFRAMEHEIGHT; break;
903 case SDRATTR_TEXT_MAXFRAMEWIDTH : nWhich=SDRATTR_TEXT_MAXFRAMEHEIGHT; break;
904 case SDRATTR_TEXT_AUTOGROWWIDTH : nWhich=SDRATTR_TEXT_HORZADJUST ; break;
905 case SDRATTR_TEXT_HORZADJUST : nWhich=SDRATTR_TEXT_VERTADJUST ; break;
906 } // switch
907 return nWhich;
910 #define INSERTCOMMENT(nStartId,nEndId,aStr) \
911 { if (nWhich0<nStartId && nWhich>=nStartId && nWhich<=nEndId) aCommentStr=aStr; }
913 void _SdrItemBrowserControl::SetAttributes(const SfxItemSet* pSet, const SfxItemSet* p2ndSet)
915 SetMode(MYBROWSEMODE & ~BROWSER_KEEPHIGHLIGHT);
916 if (pSet!=NULL) {
917 rtl_TextEncoding aTextEncoding = osl_getThreadTextEncoding();
918 sal_uInt16 nEntryNum=0;
919 SfxWhichIter aIter(*pSet);
920 const SfxItemPool* pPool=pSet->GetPool();
921 sal_uInt16 nWhich0=0;
922 sal_uInt16 nWhich=aIter.FirstWhich();
923 while (nWhich!=0) {
924 // Now sort this a little bit differently.
925 // Only works as long as there are no InvalidItems, i. e. no gaps
926 // at this position in the Set.
927 if (!bDontSortItems) nWhich=ImpSortWhich(nWhich);
928 SfxItemState eState=pSet->GetItemState(nWhich);
929 if (p2ndSet!=NULL) {
930 SfxItemState e2ndState=p2ndSet->GetItemState(nWhich);
931 if (eState==SFX_ITEM_DEFAULT) eState=SFX_ITEM_DISABLED;
932 else if (e2ndState==SFX_ITEM_DEFAULT) eState=SFX_ITEM_DEFAULT;
934 if (eState!=SFX_ITEM_DISABLED) {
935 const SfxPoolItem& rItem=pSet->Get(nWhich);
936 sal_uInt16 nIndent=0;
937 if (!HAS_BASE(SfxVoidItem,&rItem) && !HAS_BASE(SfxSetItem,&rItem) && (!IsItemIneffective(nWhich,pSet,nIndent) || bDontHideIneffectiveItems)) {
938 XubString aCommentStr;
940 INSERTCOMMENT(XATTR_LINE_FIRST,XATTR_LINE_LAST,String("L I N I E", aTextEncoding));
941 INSERTCOMMENT(XATTR_FILL_FIRST,XATTR_FILL_LAST,String("F L � C H E", aTextEncoding));
942 INSERTCOMMENT(XATTR_TEXT_FIRST,XATTR_TEXT_LAST,String("F O N T W O R K", aTextEncoding));
943 INSERTCOMMENT(SDRATTR_SHADOW_FIRST,SDRATTR_SHADOW_LAST,String("S C H A T T E N", aTextEncoding));
944 INSERTCOMMENT(SDRATTR_CAPTION_FIRST,SDRATTR_CAPTION_LAST,String("L E G E N D E", aTextEncoding));
945 INSERTCOMMENT(SDRATTR_MISC_FIRST,SDRATTR_MISC_LAST,String("V E R S C H I E D E N E S", aTextEncoding));
946 INSERTCOMMENT(SDRATTR_EDGE_FIRST,SDRATTR_EDGE_LAST,String("V E R B I N D E R", aTextEncoding));
947 INSERTCOMMENT(SDRATTR_MEASURE_FIRST,SDRATTR_MEASURE_LAST,String("B E M A S S U N G", aTextEncoding));
948 INSERTCOMMENT(SDRATTR_CIRC_FIRST,SDRATTR_CIRC_LAST,String("K R E I S", aTextEncoding));
949 INSERTCOMMENT(SDRATTR_NOTPERSIST_FIRST,SDRATTR_NOTPERSIST_LAST,String("N O T P E R S I S T", aTextEncoding));
950 INSERTCOMMENT(SDRATTR_MOVEX,SDRATTR_VERTSHEARONE,String("Transformationen auf alle Objekte einzeln", aTextEncoding));
951 INSERTCOMMENT(SDRATTR_RESIZEXALL,SDRATTR_VERTSHEARALL,String("Transformationen auf alle Objekte gemeinsam", aTextEncoding));
952 INSERTCOMMENT(SDRATTR_TRANSFORMREF1X,SDRATTR_TRANSFORMREF2Y,String("View-Referenzpunkte", aTextEncoding));
953 INSERTCOMMENT(SDRATTR_GRAF_FIRST,SDRATTR_GRAF_LAST,String("G R A F I K", aTextEncoding));
954 INSERTCOMMENT(EE_ITEMS_START,EE_ITEMS_END,String("E D I T E N G I N E", aTextEncoding));
955 INSERTCOMMENT(EE_ITEMS_END+1,EE_ITEMS_END+1,String("... by Joe Merten, JME Engineering Berlin ...", aTextEncoding));
957 if(aCommentStr.Len())
959 ImpItemListRow aEntry;
960 aEntry.bComment = true;
961 aEntry.aName=aCommentStr;
962 ImpSetEntry(aEntry,nEntryNum);
963 nEntryNum++;
965 nWhich0=nWhich;
966 ImpItemListRow aEntry;
967 SdrItemPool::TakeItemName(nWhich, aEntry.aName);
968 nIndent*=2;
970 while(nIndent > 0)
972 aEntry.aName = " " + aEntry.aName;
973 nIndent--;
976 aEntry.eState=eState;
977 aEntry.nWhichId=nWhich;
978 if (!IsInvalidItem(&rItem)) {
979 aEntry.pType=rItem.Type();
980 aEntry.nMax=0x7FFFFFFF;
981 aEntry.nMin=-aEntry.nMax;
982 aEntry.nVal=-4711;
983 if (HAS_BASE(SfxByteItem ,&rItem)) aEntry.eItemType=ITEM_BYTE;
984 else if (HAS_BASE(SfxInt16Item ,&rItem)) aEntry.eItemType=ITEM_INT16;
985 else if (HAS_BASE(SfxUInt16Item ,&rItem)) aEntry.eItemType=ITEM_UINT16;
986 else if (HAS_BASE(SfxInt32Item ,&rItem)) aEntry.eItemType=ITEM_INT32;
987 else if (HAS_BASE(SfxUInt32Item ,&rItem)) aEntry.eItemType=ITEM_UINT32;
988 else if (HAS_BASE(SfxEnumItemInterface,&rItem)) aEntry.eItemType=ITEM_ENUM;
989 else if (HAS_BASE(SfxBoolItem ,&rItem)) aEntry.eItemType=ITEM_BOOL;
990 else if (HAS_BASE(SfxFlagItem ,&rItem)) aEntry.eItemType=ITEM_FLAG;
991 else if (HAS_BASE(XColorItem ,&rItem)) aEntry.eItemType=ITEM_XCOLOR;
992 else if (HAS_BASE(SfxStringItem ,&rItem)) aEntry.eItemType=ITEM_STRING;
993 else if (HAS_BASE(SfxPointItem ,&rItem)) aEntry.eItemType=ITEM_POINT;
994 else if (HAS_BASE(SfxRectangleItem,&rItem)) aEntry.eItemType=ITEM_RECT;
995 else if (HAS_BASE(SfxRangeItem ,&rItem)) aEntry.eItemType=ITEM_RANGE;
996 else if (HAS_BASE(SdrFractionItem ,&rItem)) aEntry.eItemType=ITEM_FRACTION;
997 else if (HAS_BASE(SvxColorItem ,&rItem)) aEntry.eItemType=ITEM_COLOR;
998 else if (HAS_BASE(SvxFontItem ,&rItem)) aEntry.eItemType=ITEM_FONT;
999 else if (HAS_BASE(SvxFontHeightItem,&rItem))aEntry.eItemType=ITEM_FONTHEIGHT;
1000 else if (HAS_BASE(SvxCharScaleWidthItem,&rItem)) aEntry.eItemType=ITEM_FONTWIDTH;
1001 else if (HAS_BASE(SvxFieldItem ,&rItem)) aEntry.eItemType=ITEM_FIELD;
1002 switch (aEntry.eItemType) {
1003 case ITEM_BYTE : aEntry.bIsNum = true; aEntry.nVal=((SfxByteItem &)rItem).GetValue(); aEntry.nMin=0; aEntry.nMax=255; break;
1004 case ITEM_INT16 : aEntry.bIsNum = true; aEntry.nVal=((SfxInt16Item &)rItem).GetValue(); aEntry.nMin=-32767; aEntry.nMax=32767; break;
1005 case ITEM_UINT16 : aEntry.bIsNum = true; aEntry.nVal=((SfxUInt16Item&)rItem).GetValue(); aEntry.nMin=0; aEntry.nMax=65535; break;
1006 case ITEM_INT32 : aEntry.bIsNum = true; aEntry.nVal=((SfxInt32Item &)rItem).GetValue(); break;
1007 case ITEM_UINT32 : aEntry.bIsNum = true; aEntry.nVal=((SfxUInt32Item&)rItem).GetValue(); aEntry.nMin=0; /*aEntry.nMax=0xFF...*/;break;
1008 case ITEM_ENUM : aEntry.bCanNum = true; aEntry.nVal=((SfxEnumItemInterface&)rItem).GetEnumValue(); aEntry.nMin=0; aEntry.nMax=((SfxEnumItemInterface&)rItem).GetValueCount()-1; break;
1009 case ITEM_BOOL : aEntry.bCanNum = true; aEntry.nVal=((SfxBoolItem &)rItem).GetValue(); aEntry.nMin=0; aEntry.nMax=1; break;
1010 case ITEM_FLAG : aEntry.bCanNum = true; aEntry.nVal=((SfxFlagItem &)rItem).GetValue(); aEntry.nMin=0; aEntry.nMax=0xFFFF; break;
1011 case ITEM_FONTHEIGHT: aEntry.bCanNum = true; aEntry.nVal=((SvxFontHeightItem&)rItem).GetHeight(); aEntry.nMin=0; break;
1012 case ITEM_FONTWIDTH : aEntry.bCanNum = true; aEntry.nVal=((SvxCharScaleWidthItem&)rItem).GetValue(); aEntry.nMin=0; aEntry.nMax=0xFFFF;break;
1013 default: break;
1014 } // switch
1015 if (aEntry.bIsNum) aEntry.bCanNum = true;
1017 rItem.GetPresentation(SFX_ITEM_PRESENTATION_NAMELESS,
1018 pPool->GetMetric(nWhich),
1019 SFX_MAPUNIT_MM, aEntry.aValue);
1020 if (aEntry.bCanNum)
1022 aEntry.aValue = OUString::number(aEntry.nVal) + ": " + aEntry.aValue;
1025 else
1027 aEntry.aValue = String("InvalidItem", aTextEncoding);
1029 ImpSetEntry(aEntry,nEntryNum);
1030 nEntryNum++;
1033 nWhich=aIter.NextWhich();
1034 } // while
1036 if (aList.size()>nEntryNum) { // maybe still too many entries
1037 size_t const nTooMuch = aList.size() - nEntryNum;
1038 for (size_t n = nEntryNum; n < aList.size(); ++n) {
1039 delete aList[n];
1041 aList.erase(aList.begin() + nEntryNum, aList.end());
1042 RowRemoved(nEntryNum,nTooMuch);
1044 } else {
1045 Clear(); // if pSet==NULL
1047 ImpRestoreWhich();
1048 SetMode(MYBROWSEMODE);
1051 ////////////////////////////////////////////////////////////////////////////////////////////////////
1053 _SdrItemBrowserWindow::_SdrItemBrowserWindow(Window* pParent, WinBits nBits):
1054 FloatingWindow(pParent,nBits),
1055 aBrowse(this)
1057 SetOutputSizePixel(aBrowse.GetSizePixel());
1058 SetText(String("Joe's ItemBrowser", osl_getThreadTextEncoding()));
1059 aBrowse.Show();
1062 _SdrItemBrowserWindow::~_SdrItemBrowserWindow()
1066 void _SdrItemBrowserWindow::Resize()
1068 aBrowse.SetSizePixel(GetOutputSizePixel());
1071 void _SdrItemBrowserWindow::GetFocus()
1073 aBrowse.GrabFocus();
1076 ////////////////////////////////////////////////////////////////////////////////////////////////////
1078 SdrItemBrowser::SdrItemBrowser(SdrView& rView):
1079 _SdrItemBrowserWindow(ImpGetViewWin(rView)),
1080 pView(&rView),
1081 bDirty(sal_False)
1083 aIdleTimer.SetTimeoutHdl(LINK(this,SdrItemBrowser,IdleHdl));
1084 GetBrowserControl().SetEntryChangedHdl(LINK(this,SdrItemBrowser,ChangedHdl));
1085 GetBrowserControl().SetSetDirtyHdl(LINK(this,SdrItemBrowser,SetDirtyHdl));
1086 SetDirty();
1089 Window* SdrItemBrowser::ImpGetViewWin(SdrView& rView)
1091 const sal_uInt32 nWinCount(rView.PaintWindowCount());
1093 for(sal_uInt32 a(0L); a < nWinCount; a++)
1095 SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
1097 if(OUTDEV_WINDOW == pCandidate->GetOutputDevice().GetOutDevType())
1099 return (Window*)(&pCandidate->GetOutputDevice());
1103 return 0L;
1106 void SdrItemBrowser::ForceParent()
1108 Window* pWin=ImpGetViewWin(*pView);
1109 if (pWin!=NULL) SetParent(pWin);
1112 void SdrItemBrowser::SetDirty()
1114 if (!bDirty) {
1115 bDirty = true;
1116 aIdleTimer.SetTimeout(1);
1117 aIdleTimer.Start();
1121 void SdrItemBrowser::Undirty()
1123 aIdleTimer.Stop();
1124 bDirty = sal_False;
1126 SfxItemSet aSet(pView->GetModel()->GetItemPool());
1127 pView->GetAttributes(aSet);
1129 if(pView->AreObjectsMarked())
1131 SfxItemSet a2ndSet(pView->GetModel()->GetItemPool());
1132 pView->GetAttributes(a2ndSet, sal_True);
1134 SetAttributes(&aSet,&a2ndSet);
1136 else
1138 SetAttributes(&aSet);
1142 IMPL_LINK_NOARG(SdrItemBrowser, IdleHdl)
1144 Undirty();
1145 return 0;
1148 IMPL_LINK(SdrItemBrowser,ChangedHdl,_SdrItemBrowserControl*,pBrowse)
1150 const ImpItemListRow* pEntry=pBrowse->GetAktChangeEntry();
1151 if (pEntry!=NULL)
1153 SfxItemSet aSet(pView->GetModel()->GetItemPool());
1154 pView->GetAttributes(aSet);
1156 SfxItemSet aNewSet(*aSet.GetPool(),pEntry->nWhichId,pEntry->nWhichId);
1157 OUString aNewText(pBrowse->GetNewEntryValue());
1158 sal_Bool bDel( aNewText == "del"
1159 || aNewText == "Del"
1160 || aNewText == "DEL"
1161 || aNewText == "default"
1162 || aNewText == "Default"
1163 || aNewText == "DEFAULT" );
1165 if (!bDel) {
1166 SfxPoolItem* pNewItem=aSet.Get(pEntry->nWhichId).Clone();
1167 long nLongVal = aNewText.toInt32();
1168 if (pEntry->bCanNum) {
1169 if (nLongVal>pEntry->nMax) nLongVal=pEntry->nMax;
1170 if (nLongVal<pEntry->nMin) nLongVal=pEntry->nMin;
1172 bool bPairX = true;
1173 bool bPairY = false;
1174 sal_uInt16 nSepLen=1;
1175 long nLongX = aNewText.toInt32();
1176 long nLongY=0;
1177 sal_Int32 nPos = aNewText.indexOf(sal_Unicode('/'));
1178 if (nPos==-1) nPos=aNewText.indexOf(sal_Unicode(':'));
1179 if (nPos==-1) nPos=aNewText.indexOf(sal_Unicode(' '));
1180 if (nPos==-1) { nPos=aNewText.indexOf(".."); if (nPos!=-1) nSepLen=2; }
1181 if (nPos!=01)
1183 bPairX=nPos>0;
1184 OUString s(aNewText.copy(nPos+nSepLen));
1185 bPairY = !aNewText.isEmpty();
1186 nLongY = s.toInt32();
1188 switch (pEntry->eItemType) {
1189 case ITEM_BYTE : ((SfxByteItem *)pNewItem)->SetValue((sal_uInt8 )nLongVal); break;
1190 case ITEM_INT16 : ((SfxInt16Item *)pNewItem)->SetValue((sal_Int16 )nLongVal); break;
1191 case ITEM_UINT16: ((SfxUInt16Item*)pNewItem)->SetValue((sal_uInt16)nLongVal); break;
1192 case ITEM_INT32: {
1193 if(HAS_BASE(SdrAngleItem, pNewItem))
1195 aNewText = aNewText.replace(',', '.');
1196 double nVal = aNewText.toFloat();
1197 nLongVal = (long)(nVal * 100 + 0.5);
1199 ((SfxInt32Item *)pNewItem)->SetValue((sal_Int32)nLongVal);
1200 } break;
1201 case ITEM_UINT32: ((SfxUInt32Item*)pNewItem)->SetValue(aNewText.toInt32()); break;
1202 case ITEM_ENUM : ((SfxEnumItemInterface*)pNewItem)->SetEnumValue((sal_uInt16)nLongVal); break;
1203 case ITEM_BOOL: {
1204 aNewText = aNewText.toAsciiUpperCase();
1205 if (aNewText == "TRUE") nLongVal=1;
1206 if (aNewText == "JA") nLongVal=1;
1207 if (aNewText == "AN") nLongVal=1;
1208 if (aNewText == "EIN") nLongVal=1;
1209 if (aNewText == "ON") nLongVal=1;
1210 if (aNewText == "YES") nLongVal=1;
1211 ((SfxBoolItem*)pNewItem)->SetValue((sal_Bool)nLongVal);
1212 } break;
1213 case ITEM_FLAG : ((SfxFlagItem *)pNewItem)->SetValue((sal_uInt16)nLongVal); break;
1214 case ITEM_STRING: ((SfxStringItem*)pNewItem)->SetValue(aNewText); break;
1215 case ITEM_POINT : ((SfxPointItem*)pNewItem)->SetValue(Point(nLongX,nLongY)); break;
1216 case ITEM_RECT : break;
1217 case ITEM_RANGE : {
1218 ((SfxRangeItem*)pNewItem)->From()=(sal_uInt16)nLongX;
1219 ((SfxRangeItem*)pNewItem)->From()=(sal_uInt16)nLongY;
1220 } break;
1221 case ITEM_LRANGE : {
1222 } break;
1223 case ITEM_FRACTION: {
1224 if (!bPairX) nLongX=1;
1225 if (!bPairY) nLongY=1;
1226 ((SdrFractionItem*)pNewItem)->SetValue(Fraction(nLongX,nLongY));
1227 } break;
1228 case ITEM_XCOLOR: break;
1229 case ITEM_COLOR: break;
1230 case ITEM_FONT: {
1231 ((SvxFontItem*)pNewItem)->SetFamily( FAMILY_DONTKNOW );
1232 ((SvxFontItem*)pNewItem)->SetFamilyName(aNewText);
1233 ((SvxFontItem*)pNewItem)->SetStyleName( String() );
1234 } break;
1235 case ITEM_FONTHEIGHT: {
1236 sal_uIntPtr nHgt=0;
1237 sal_uInt16 nProp=100;
1238 if (aNewText.indexOf(sal_Unicode('%')) != -1) {
1239 nProp=(sal_uInt16)nLongVal;
1240 } else {
1241 nHgt=nLongVal;
1243 ((SvxFontHeightItem*)pNewItem)->SetHeight(nHgt,nProp);
1244 } break;
1245 case ITEM_FONTWIDTH: {
1246 sal_uInt16 nProp=100;
1247 if (aNewText.indexOf(sal_Unicode('%')) != -1) {
1248 nProp=(sal_uInt16)nLongVal;
1250 ((SvxCharScaleWidthItem*)pNewItem)->SetValue(nProp);
1251 } break;
1252 case ITEM_FIELD: break;
1253 default: break;
1254 } // switch
1255 aNewSet.Put(*pNewItem);
1256 delete pNewItem;
1258 pView->SetAttributes(aNewSet,bDel);
1260 return 0;
1263 IMPL_LINK_NOARG(SdrItemBrowser, SetDirtyHdl)
1265 SetDirty();
1266 return 0;
1270 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */