1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #include <sfx2/sidebar/propertypanel.hrc>
23 #include <sfx2/sidebar/Theme.hxx>
24 #include <sfx2/sidebar/ControlFactory.hxx>
25 #include <LinePropertyPanel.hxx>
26 #include <LinePropertyPanel.hrc>
27 #include <svx/dialogs.hrc>
28 #include <svx/dialmgr.hxx>
29 #include <sfx2/objsh.hxx>
30 #include <sfx2/bindings.hxx>
31 #include <sfx2/dispatch.hxx>
32 #include <svx/xlnclit.hxx>
33 #include <svx/xtable.hxx>
34 #include <svx/xdash.hxx>
35 #include <svx/drawitem.hxx>
36 #include <svx/svxitems.hrc>
37 #include <svtools/valueset.hxx>
38 #include <unotools/pathoptions.hxx>
39 #include <unotools/viewoptions.hxx>
40 #include <comphelper/processfactory.hxx>
41 #include <i18npool/mslangid.hxx>
42 #include <svx/xlineit0.hxx>
43 #include <svx/xlndsit.hxx>
44 #include <vcl/svapp.hxx>
45 #include <svx/xlnwtit.hxx>
46 #include <vcl/lstbox.hxx>
47 #include <svx/tbxcolorupdate.hxx>
48 #include <vcl/toolbox.hxx>
49 #include <svx/xlntrit.hxx>
50 #include <svx/xlnstit.hxx>
51 #include <svx/xlnedit.hxx>
52 #include <svx/xlncapit.hxx>
53 #include <svx/xlinjoit.hxx>
54 #include "svx/sidebar/PopupContainer.hxx"
55 #include "svx/sidebar/PopupControl.hxx"
56 #include "sidebar/ColorControl.hxx"
57 #include "LineStyleControl.hxx"
58 #include "LineWidthControl.hxx"
59 #include <boost/bind.hpp>
60 
61 using namespace css;
62 using namespace cssu;
63 using ::sfx2::sidebar::Theme;
64 
65 #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
66 
67 namespace {
68     short GetItemId_Impl_line( ValueSet& rValueSet, const Color& rCol )
69     {
70         if(rCol == COL_AUTO)
71             return 0;
72 
73         bool	bFound = false;
74         sal_uInt16 nCount = rValueSet.GetItemCount();
75         sal_uInt16	n	   = 1;
76 
77         while ( !bFound && n <= nCount )
78         {
79             Color aValCol = rValueSet.GetItemColor(n);
80 
81             bFound = (   aValCol.GetRed()   == rCol.GetRed()
82                 && aValCol.GetGreen() == rCol.GetGreen()
83                 && aValCol.GetBlue()  == rCol.GetBlue() );
84 
85             if ( !bFound )
86                 n++;
87         }
88         return bFound ? n : -1;
89     }
90 
91     Color GetTransparentColor (void)
92     {
93         return COL_TRANSPARENT;
94     }
95 
96 } // end of anonymous namespace
97 
98 
99 class LineEndLB_LPP : public ListBox
100 {
101 
102 public:
103 		 LineEndLB_LPP( Window* pParent, ResId Id ) : ListBox( pParent, Id ) {}
104 		 LineEndLB_LPP( Window* pParent, WinBits aWB ) : ListBox( pParent, aWB ) {}
105 
106 	void Fill( const XLineEndList* pList, bool bStart = true );
107 
108 	void	Append( XLineEndEntry* pEntry, Bitmap* pBmp = NULL,
109 					bool bStart = true );
110 	void	Modify( XLineEndEntry* pEntry, sal_uInt16 nPos, Bitmap* pBmp = NULL,
111 					bool bStart = true );
112 };
113 
114 void LineEndLB_LPP::Fill( const XLineEndList* pList, bool bStart )
115 {
116 	long nCount = pList->Count();
117 	XLineEndEntry* pEntry;
118 	VirtualDevice aVD;
119 	SetUpdateMode( false );
120 
121 	for( long i = 0; i < nCount; i++ )
122 	{
123         pEntry = pList->GetLineEnd( i );
124 		Bitmap* pBitmap = const_cast<XLineEndList*>(pList)->CreateBitmapForUI( i );
125 		if( pBitmap )
126 		{
127 			Size aBmpSize( pBitmap->GetSizePixel() );
128 			aVD.SetOutputSizePixel( aBmpSize, false );
129 			aVD.DrawBitmap( Point(), *pBitmap );
130 			InsertEntry( pEntry->GetName(),
131 				aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ),
132 					Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ) );
133 
134 			delete pBitmap;
135 		}
136 		else
137 			InsertEntry( pEntry->GetName() );
138 	}
139 	SetUpdateMode( true );
140 }
141 
142 void LineEndLB_LPP::Append( XLineEndEntry* pEntry, Bitmap* pBmp, bool bStart )
143 {
144 	if( pBmp )
145 	{
146 		VirtualDevice aVD;
147 		Size aBmpSize( pBmp->GetSizePixel() );
148 
149 		aVD.SetOutputSizePixel( aBmpSize, false );
150 		aVD.DrawBitmap( Point(), *pBmp );
151 		InsertEntry( pEntry->GetName(),
152 			aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ),
153 				Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ) );
154 	}
155 	else
156 		InsertEntry( pEntry->GetName() );
157 }
158 
159 void LineEndLB_LPP::Modify( XLineEndEntry* pEntry, sal_uInt16 nPos, Bitmap* pBmp, bool bStart )
160 {
161 	RemoveEntry( nPos );
162 
163 	if( pBmp )
164 	{
165 		VirtualDevice aVD;
166 		Size aBmpSize( pBmp->GetSizePixel() );
167 
168 		aVD.SetOutputSizePixel( aBmpSize, false );
169 		aVD.DrawBitmap( Point(), *pBmp );
170 		InsertEntry( pEntry->GetName(),
171 			aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ),
172 				Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ), nPos );
173 	}
174 	else
175 		InsertEntry( pEntry->GetName(), nPos );
176 }
177 
178 
179 // namespace open
180 
181 namespace svx { namespace sidebar {
182 
183 
184 
185 LinePropertyPanel::LinePropertyPanel(
186     Window* pParent,
187     const cssu::Reference<css::frame::XFrame>& rxFrame,
188     SfxBindings* pBindings)
189 :   Control(
190         pParent,
191         SVX_RES(RID_SIDEBAR_LINE_PANEL)),
192     mpFTWidth(new FixedText(this, SVX_RES(FT_WIDTH))),
193     mpTBWidthBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)),
194     mpTBWidth(sfx2::sidebar::ControlFactory::CreateToolBox(mpTBWidthBackground.get(), SVX_RES(TB_WIDTH))),
195     mpFTColor(new FixedText(this, SVX_RES(FT_COLOR))),
196     mpTBColorBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)),
197     mpTBColor(sfx2::sidebar::ControlFactory::CreateToolBox(mpTBColorBackground.get(), SVX_RES(TB_COLOR))),
198     mpFTStyle(new FixedText(this, SVX_RES(FT_STYLE))),
199     mpTBStyleBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)),
200     mpTBStyle(sfx2::sidebar::ControlFactory::CreateToolBox(mpTBStyleBackground.get(), SVX_RES(TB_STYLE))),
201     mpFTTrancparency(new FixedText(this, SVX_RES(FT_TRANSPARENT))),
202     mpMFTransparent(new MetricField(this, SVX_RES(MF_TRANSPARENT))),
203     mpFTArrow(new FixedText(this, SVX_RES(FT_ARROW))),
204     mpLBStart(new LineEndLB_LPP(this, SVX_RES(LB_START))),
205     mpLBEnd(new LineEndLB_LPP(this, SVX_RES(LB_END))),
206     mpFTEdgeStyle(new FixedText(this, SVX_RES(FT_EDGESTYLE))),
207     mpLBEdgeStyle(new ListBox(this, SVX_RES(LB_EDGESTYLE))),
208     mpFTCapStyle(new FixedText(this, SVX_RES(FT_CAPSTYLE))),
209     mpLBCapStyle(new ListBox(this, SVX_RES(LB_CAPSTYLE))),
210     maStyleControl(SID_ATTR_LINE_STYLE, *pBindings, *this),             // ( SID_SVX_START + 169 )
211     maDashControl (SID_ATTR_LINE_DASH, *pBindings, *this),              // ( SID_SVX_START + 170 )
212     maWidthControl(SID_ATTR_LINE_WIDTH, *pBindings, *this),             // ( SID_SVX_START + 171 )
213     maColorControl(SID_ATTR_LINE_COLOR, *pBindings, *this),             // ( SID_SVX_START + 172 )
214     maStartControl(SID_ATTR_LINE_START, *pBindings, *this),             // ( SID_SVX_START + 173 )
215     maEndControl(SID_ATTR_LINE_END, *pBindings, *this),                 // ( SID_SVX_START + 174 )
216     maLineEndListControl(SID_LINEEND_LIST, *pBindings, *this),          // ( SID_SVX_START + 184 )
217     maTransControl(SID_ATTR_LINE_TRANSPARENCE, *pBindings, *this),      // (SID_SVX_START+1107)
218     maEdgeStyle(SID_ATTR_LINE_JOINT, *pBindings, *this),                // (SID_SVX_START+1110)
219     maCapStyle(SID_ATTR_LINE_CAP, *pBindings, *this),                   // (SID_SVX_START+1111)
220     maColor(COL_BLACK),
221     mpColorUpdater(new ::svx::ToolboxButtonColorUpdater(SID_ATTR_LINE_COLOR, TBI_COLOR, mpTBColor.get(), TBX_UPDATER_MODE_CHAR_COLOR_NEW)),
222     mpStyleItem(),
223     mpDashItem(),
224     mnTrans(0),
225     meMapUnit(SFX_MAPUNIT_MM),
226     mnWidthCoreValue(0),
227     mpLineEndList(0),
228     mpStartItem(0),
229     mpEndItem(0),
230     maColorPopup(this, ::boost::bind(&LinePropertyPanel::CreateColorPopupControl, this, _1)),
231     maLineStylePopup(this, ::boost::bind(&LinePropertyPanel::CreateLineStylePopupControl, this, _1)),
232     maLineWidthPopup(this, ::boost::bind(&LinePropertyPanel::CreateLineWidthPopupControl, this, _1)),
233     maIMGColor(SVX_RES(IMG_COLOR)),
234     maIMGNone(SVX_RES(IMG_NONE_ICON)),
235     mpIMGStyleIcon(),
236     mpIMGWidthIcon(),
237     mpIMGStyleIconH(),
238     mpIMGWidthIconH(),
239     mxFrame(rxFrame),
240     maContext(),
241     mpBindings(pBindings),
242     mbColorAvailable(true),
243     mbStyleAvailable(false),
244     mbDashAvailable(false),
245     mbTransAvailable(true),
246     mbWidthValuable(true),
247     mbStartAvailable(true),
248     mbEndAvailable(true)
249 {
250     Initialize();
251     FreeResource();
252 }
253 
254 
255 
256 LinePropertyPanel::~LinePropertyPanel()
257 {
258     // Destroy the toolboxes, then their background windows.
259     mpTBWidth.reset();
260     mpTBColor.reset();
261     mpTBStyle.reset();
262     mpTBWidthBackground.reset();
263     mpTBColorBackground.reset();
264     mpTBStyleBackground.reset();
265 }
266 
267 
268 
269 void LinePropertyPanel::ShowMenu (void)
270 {
271     if (mpBindings != NULL)
272     {
273         SfxDispatcher* pDispatcher = mpBindings->GetDispatcher();
274         if (pDispatcher != NULL)
275             pDispatcher->Execute(SID_ATTRIBUTES_LINE, SFX_CALLMODE_ASYNCHRON);
276     }
277 }
278 
279 
280 
281 void LinePropertyPanel::Initialize()
282 {
283     mpIMGStyleIcon.reset(new Image[11]);
284 	mpIMGStyleIcon[0] = Image(SVX_RES(IMG_LINE1_ICON));
285 	mpIMGStyleIcon[1] = Image(SVX_RES(IMG_LINE2_ICON));
286 	mpIMGStyleIcon[2] = Image(SVX_RES(IMG_LINE3_ICON));
287 	mpIMGStyleIcon[3] = Image(SVX_RES(IMG_LINE4_ICON));
288 	mpIMGStyleIcon[4] = Image(SVX_RES(IMG_LINE5_ICON));
289 	mpIMGStyleIcon[5] = Image(SVX_RES(IMG_LINE6_ICON));
290 	mpIMGStyleIcon[6] = Image(SVX_RES(IMG_LINE7_ICON));
291 	mpIMGStyleIcon[7] = Image(SVX_RES(IMG_LINE8_ICON));
292 	mpIMGStyleIcon[8] = Image(SVX_RES(IMG_LINE9_ICON));
293 	mpIMGStyleIcon[9] = Image(SVX_RES(IMG_LINE10_ICON));
294 	mpIMGStyleIcon[10] = Image(SVX_RES(IMG_LINE11_ICON));
295 
296     mpIMGWidthIcon.reset(new Image[8]);
297 	mpIMGWidthIcon[0] = Image(SVX_RES(IMG_WIDTH1_ICON));
298 	mpIMGWidthIcon[1] = Image(SVX_RES(IMG_WIDTH2_ICON));
299 	mpIMGWidthIcon[2] = Image(SVX_RES(IMG_WIDTH3_ICON));
300 	mpIMGWidthIcon[3] = Image(SVX_RES(IMG_WIDTH4_ICON));
301 	mpIMGWidthIcon[4] = Image(SVX_RES(IMG_WIDTH5_ICON));
302 	mpIMGWidthIcon[5] = Image(SVX_RES(IMG_WIDTH6_ICON));
303 	mpIMGWidthIcon[6] = Image(SVX_RES(IMG_WIDTH7_ICON));
304 	mpIMGWidthIcon[7] = Image(SVX_RES(IMG_WIDTH8_ICON));
305 
306 	//high contrast
307     mpIMGStyleIconH.reset(new Image[11]);
308 	mpIMGStyleIconH[0] = Image(SVX_RES(IMG_LINE1_ICON_H));
309 	mpIMGStyleIconH[1] = Image(SVX_RES(IMG_LINE2_ICON_H));
310 	mpIMGStyleIconH[2] = Image(SVX_RES(IMG_LINE3_ICON_H));
311 	mpIMGStyleIconH[3] = Image(SVX_RES(IMG_LINE4_ICON_H));
312 	mpIMGStyleIconH[4] = Image(SVX_RES(IMG_LINE5_ICON_H));
313 	mpIMGStyleIconH[5] = Image(SVX_RES(IMG_LINE6_ICON_H));
314 	mpIMGStyleIconH[6] = Image(SVX_RES(IMG_LINE7_ICON_H));
315 	mpIMGStyleIconH[7] = Image(SVX_RES(IMG_LINE8_ICON_H));
316 	mpIMGStyleIconH[8] = Image(SVX_RES(IMG_LINE9_ICON_H));
317 	mpIMGStyleIconH[9] = Image(SVX_RES(IMG_LINE10_ICON_H));
318 	mpIMGStyleIconH[10] = Image(SVX_RES(IMG_LINE11_ICON_H));
319 
320     mpIMGWidthIconH.reset(new Image[8]);
321 	mpIMGWidthIconH[0] = Image(SVX_RES(IMG_WIDTH1_ICON_H));
322 	mpIMGWidthIconH[1] = Image(SVX_RES(IMG_WIDTH2_ICON_H));
323 	mpIMGWidthIconH[2] = Image(SVX_RES(IMG_WIDTH3_ICON_H));
324 	mpIMGWidthIconH[3] = Image(SVX_RES(IMG_WIDTH4_ICON_H));
325 	mpIMGWidthIconH[4] = Image(SVX_RES(IMG_WIDTH5_ICON_H));
326 	mpIMGWidthIconH[5] = Image(SVX_RES(IMG_WIDTH6_ICON_H));
327 	mpIMGWidthIconH[6] = Image(SVX_RES(IMG_WIDTH7_ICON_H));
328 	mpIMGWidthIconH[7] = Image(SVX_RES(IMG_WIDTH8_ICON_H));
329 	//end
330 
331 	meMapUnit = maWidthControl.GetCoreMetric();
332 
333 	mpTBColor->SetItemImage(TBI_COLOR, maIMGColor);
334 	Size aTbxSize( mpTBColor->CalcWindowSizePixel() );
335 	mpTBColor->SetOutputSizePixel( aTbxSize );
336 	mpTBColor->SetItemBits( TBI_COLOR, mpTBColor->GetItemBits( TBI_COLOR ) | TIB_DROPDOWNONLY );
337 	mpTBColor->SetQuickHelpText(TBI_COLOR,String(SVX_RES(STR_QH_TB_COLOR))); //Add
338 	mpTBColor->SetBackground(Wallpaper());
339 	mpTBColor->SetPaintTransparent(true);
340 	Link aLink = LINK(this, LinePropertyPanel, ToolboxColorSelectHdl);
341 	mpTBColor->SetDropdownClickHdl ( aLink );
342 	mpTBColor->SetSelectHdl ( aLink );
343 
344 	mpTBStyle->SetItemImage(TBI_STYLE, mpIMGStyleIcon[0]);
345 	aTbxSize = mpTBStyle->CalcWindowSizePixel() ;
346 	mpTBStyle->SetOutputSizePixel( aTbxSize );
347 	mpTBStyle->SetItemBits( TBI_STYLE, mpTBStyle->GetItemBits( TBI_STYLE ) | TIB_DROPDOWNONLY );
348 	mpTBStyle->SetQuickHelpText(TBI_STYLE,String(SVX_RES(STR_QH_TB_STYLE))); //Add
349 	mpTBStyle->SetBackground(Wallpaper());
350 	mpTBStyle->SetPaintTransparent(true);
351 	aLink = LINK(this, LinePropertyPanel, ToolboxStyleSelectHdl);
352 	mpTBStyle->SetDropdownClickHdl ( aLink );
353 	mpTBStyle->SetSelectHdl ( aLink );
354 
355 	mpTBWidth->SetItemImage(TBI_WIDTH, mpIMGWidthIcon[0]);
356 	aTbxSize = mpTBWidth->CalcWindowSizePixel() ;
357 	mpTBWidth->SetOutputSizePixel( aTbxSize );
358 	mpTBWidth->SetItemBits( TBI_WIDTH, mpTBWidth->GetItemBits( TBI_WIDTH ) | TIB_DROPDOWNONLY );
359 	mpTBWidth->SetQuickHelpText(TBI_WIDTH,String(SVX_RES(STR_QH_TB_WIDTH))); //Add
360 	mpTBWidth->SetBackground(Wallpaper());
361 	mpTBWidth->SetPaintTransparent(true);
362 	aLink = LINK(this, LinePropertyPanel, ToolboxWidthSelectHdl);
363 	mpTBWidth->SetDropdownClickHdl ( aLink );
364 	mpTBWidth->SetSelectHdl ( aLink );
365 
366 	FillLineEndList();
367 	SelectEndStyle(true);
368 	SelectEndStyle(false);
369 	aLink = LINK( this, LinePropertyPanel, ChangeStartHdl );
370 	mpLBStart->SetSelectHdl( aLink );
371 	mpLBStart->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Beginning Style")));	//wj acc
372 	aLink = LINK( this, LinePropertyPanel, ChangeEndHdl );
373 	mpLBEnd->SetSelectHdl( aLink );
374 	mpLBEnd->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Ending Style")));	//wj acc
375 
376 	aLink = LINK(this, LinePropertyPanel, ChangeTransparentHdl);
377 	mpMFTransparent->SetModifyHdl(aLink);
378 	mpMFTransparent->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Transparency")));	//wj acc
379 
380 	mpTBWidth->SetAccessibleRelationLabeledBy(mpFTWidth.get());
381 	mpTBColor->SetAccessibleRelationLabeledBy(mpFTColor.get());
382 	mpTBStyle->SetAccessibleRelationLabeledBy(mpFTStyle.get());
383 	mpMFTransparent->SetAccessibleRelationLabeledBy(mpFTTrancparency.get());
384 	mpLBStart->SetAccessibleRelationLabeledBy(mpFTArrow.get());
385 	mpLBEnd->SetAccessibleRelationLabeledBy(mpLBEnd.get());
386 
387     aLink = LINK( this, LinePropertyPanel, ChangeEdgeStyleHdl );
388     mpLBEdgeStyle->SetSelectHdl( aLink );
389     mpLBEdgeStyle->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Corner Style")));
390 
391     aLink = LINK( this, LinePropertyPanel, ChangeCapStyleHdl );
392     mpLBCapStyle->SetSelectHdl( aLink );
393     mpLBCapStyle->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Cap Style")));
394 }
395 
396 
397 
398 void LinePropertyPanel::SetupIcons(void)
399 {
400     if(Theme::GetBoolean(Theme::Bool_UseSymphonyIcons))
401     {
402         // todo
403     }
404     else
405     {
406         // todo
407     }
408 }
409 
410 
411 
412 LinePropertyPanel* LinePropertyPanel::Create (
413     Window* pParent,
414     const cssu::Reference<css::frame::XFrame>& rxFrame,
415     SfxBindings* pBindings)
416 {
417     if (pParent == NULL)
418         throw lang::IllegalArgumentException(A2S("no parent Window given to LinePropertyPanel::Create"), NULL, 0);
419     if ( ! rxFrame.is())
420         throw lang::IllegalArgumentException(A2S("no XFrame given to LinePropertyPanel::Create"), NULL, 1);
421     if (pBindings == NULL)
422         throw lang::IllegalArgumentException(A2S("no SfxBindings given to LinePropertyPanel::Create"), NULL, 2);
423 
424     return new LinePropertyPanel(
425         pParent,
426         rxFrame,
427         pBindings);
428 }
429 
430 
431 
432 void LinePropertyPanel::DataChanged(
433     const DataChangedEvent& rEvent)
434 {
435     (void)rEvent;
436 
437     SetupIcons();
438 }
439 
440 
441 
442 void LinePropertyPanel::HandleContextChange(
443     const ::sfx2::sidebar::EnumContext aContext)
444 {
445     if(maContext == aContext)
446     {
447         // Nothing to do.
448         return;
449     }
450 
451     maContext = aContext;
452 
453 
454 
455     // todo
456 }
457 
458 
459 
460 void LinePropertyPanel::NotifyItemUpdate(
461     sal_uInt16 nSID,
462     SfxItemState eState,
463     const SfxPoolItem* pState)
464 {
465 	switch(nSID)
466 	{
467     	case SID_ATTR_LINE_COLOR:
468         {
469 		    if( eState == SFX_ITEM_DISABLED)
470 		    {
471 			    mpFTColor->Disable();
472 			    mpTBColor->Disable();
473 			    mbColorAvailable = false;
474 			    mpColorUpdater->Update(COL_WHITE);
475 		    }
476 		    else
477 		    {
478 			    mpFTColor->Enable();
479 			    mpTBColor->Enable();
480                 const XLineColorItem* pItem = dynamic_cast< const XLineColorItem* >(pState);
481 
482 			    if(eState >= SFX_ITEM_DEFAULT && pItem)
483 			    {
484 				    maColor = pItem->GetColorValue();
485 				    mbColorAvailable = true;
486 				    mpColorUpdater->Update(maColor);
487 			    }
488 			    else
489 			    {
490 				    mbColorAvailable = false;
491 				    mpColorUpdater->Update(COL_WHITE);
492 			    }
493 		    }
494 		    break;
495         }
496 	    case SID_ATTR_LINE_STYLE:
497 	    case SID_ATTR_LINE_DASH:
498         {
499 		    if( eState == SFX_ITEM_DISABLED)
500 		    {
501 			    mpFTStyle->Disable();
502 			    mpTBStyle->Disable();
503 			    mpTBStyle->SetItemImage(TBI_STYLE,maIMGNone);
504 		    }
505 		    else
506 		    {
507 			    mpFTStyle->Enable();
508 			    mpTBStyle->Enable();
509 			    if( eState  >= SFX_ITEM_DEFAULT )
510 			    {
511 				    if(nSID == SID_ATTR_LINE_STYLE)
512 				    {
513                         const XLineStyleItem* pItem = dynamic_cast< const XLineStyleItem* >(pState);
514 
515                         if(pItem)
516                         {
517 					        mbStyleAvailable =true;
518     					    mpStyleItem.reset(pState ? (XLineStyleItem*)pItem->Clone() : 0);
519                         }
520 				    }
521 				    else if(nSID == SID_ATTR_LINE_DASH)
522 				    {
523                         const XLineDashItem* pItem = dynamic_cast< const XLineDashItem* >(pState);
524 
525                         if(pItem)
526                         {
527     					    mbDashAvailable = true;
528 	    				    mpDashItem.reset(pState ? (XLineDashItem*)pItem->Clone() : 0);
529                         }
530 				    }
531 			    }
532 			    else
533 			    {
534 				    if(nSID == SID_ATTR_LINE_STYLE)
535 					    mbStyleAvailable = false;
536 				    else
537 					    mbDashAvailable = false;
538 			    }
539 			    SetStyleIcon();
540 		    }
541 		    break;
542         }
543     	case SID_ATTR_LINE_TRANSPARENCE:
544         {
545 		    if( eState == SFX_ITEM_DISABLED )
546 		    {
547 			    mpFTTrancparency->Disable();
548 			    mpMFTransparent->Disable();
549 			    mpMFTransparent->SetValue(0);//add
550 			    mpMFTransparent->SetText(String());
551 			    mbTransAvailable = false;
552 		    }
553 		    else
554 		    {
555 			    mpFTTrancparency->Enable();
556 			    mpMFTransparent->Enable();
557 			    mbTransAvailable = true;
558                 const XLineTransparenceItem* pItem = dynamic_cast< const XLineTransparenceItem* >(pState);
559 
560                 if(eState != SFX_ITEM_DONTCARE && pItem)
561 			    {
562 				    mnTrans = pItem->GetValue();
563 				    mpMFTransparent->SetValue(mnTrans);
564 			    }
565 			    else
566 			    {
567 				    mpMFTransparent->SetValue(0);//add
568 				    mpMFTransparent->SetText(String());
569 			    }
570 		    }
571 		    break;
572         }
573     	case SID_ATTR_LINE_WIDTH:
574         {
575 		    if(eState == SFX_ITEM_DISABLED)
576 		    {
577 			    mpTBWidth->Disable();
578 			    mpFTWidth->Disable();
579 		    }
580 		    else
581 		    {
582 			    //enable
583 			    mpTBWidth->Enable();
584 			    mpFTWidth->Enable();
585                 const XLineWidthItem* pItem = dynamic_cast< const XLineWidthItem* >(pState);
586 
587 			    if(eState >= SFX_ITEM_AVAILABLE && pItem)
588 			    {
589 				    mnWidthCoreValue = pItem->GetValue();
590 				    mbWidthValuable = true;
591 			    }
592 			    else
593 			    {
594 				    mbWidthValuable = false;
595 			    }
596 		    }
597 		    SetWidthIcon();
598 		    break;
599         }
600     	case SID_ATTR_LINE_START:
601         {
602             const XLineStartItem* pItem = dynamic_cast< const XLineStartItem* >(pState);
603 
604 		    if(eState != SFX_ITEM_DONTCARE && pItem)
605 		    {
606 			    mbStartAvailable = true;	//add
607 			    mpStartItem.reset(pItem ? (XLineStartItem*)pItem->Clone() : 0);
608 			    SelectEndStyle(true);
609 		    }
610 		    else
611 		    {
612 			    mpLBStart->SetNoSelection();
613 			    mbStartAvailable = false;	//add
614 		    }
615 		    break;
616         }
617     	case SID_ATTR_LINE_END:
618         {
619 		    mpFTArrow->Enable();
620 		    mpLBEnd->Enable();
621             const XLineEndItem* pItem = dynamic_cast< const XLineEndItem* >(pState);
622 
623 		    if(eState != SFX_ITEM_DONTCARE && pItem)
624 		    {
625 			    mbEndAvailable = true;		//add
626 			    mpEndItem.reset(pItem ? (XLineEndItem*)pItem->Clone() : 0);
627 			    SelectEndStyle(false);
628 		    }
629 		    else
630 		    {
631 			    mpLBEnd->SetNoSelection();
632 			    mbEndAvailable = false;		//add
633 		    }
634 		    break;
635         }
636     	case SID_LINEEND_LIST:
637         {
638 		    FillLineEndList();
639 		    SelectEndStyle(true);
640 		    SelectEndStyle(false);
641 		    break;
642         }
643         case SID_ATTR_LINE_JOINT:
644         {
645             if(eState == SFX_ITEM_DISABLED)
646             {
647                 mpLBEdgeStyle->Disable();
648             }
649             else
650             {
651                 mpLBEdgeStyle->Enable();
652                 const XLineJointItem* pItem = dynamic_cast< const XLineJointItem* >(pState);
653                 sal_uInt16 nEntryPos(0);
654 
655                 if(eState >= SFX_ITEM_AVAILABLE && pItem)
656                 {
657                     switch(pItem->GetValue())
658                     {
659                         case com::sun::star::drawing::LineJoint_MIDDLE:
660                         case com::sun::star::drawing::LineJoint_ROUND:
661                         {
662                             nEntryPos = 1;
663                             break;
664                         }
665                         case com::sun::star::drawing::LineJoint_NONE:
666                         {
667                             nEntryPos = 2;
668                             break;
669                         }
670                         case com::sun::star::drawing::LineJoint_MITER:
671                         {
672                             nEntryPos = 3;
673                             break;
674                         }
675                         case com::sun::star::drawing::LineJoint_BEVEL:
676                         {
677                             nEntryPos = 4;
678                             break;
679                         }
680 
681                         default:
682                             break;
683                     }
684                 }
685 
686                 if(nEntryPos)
687                 {
688                     mpLBEdgeStyle->SelectEntryPos(nEntryPos - 1);
689                 }
690                 else
691                 {
692                     mpLBEdgeStyle->SetNoSelection();
693                 }
694             }
695             break;
696         }
697         case SID_ATTR_LINE_CAP:
698         {
699             if(eState == SFX_ITEM_DISABLED)
700             {
701                 mpLBCapStyle->Disable();
702             }
703             else
704             {
705                 mpLBCapStyle->Enable();
706                 const XLineCapItem* pItem = dynamic_cast< const XLineCapItem* >(pState);
707                 sal_uInt16 nEntryPos(0);
708 
709                 if(eState >= SFX_ITEM_AVAILABLE && pItem)
710                 {
711                     switch(pItem->GetValue())
712                     {
713                         case com::sun::star::drawing::LineCap_BUTT:
714                         {
715                             nEntryPos = 1;
716                             break;
717                         }
718                         case com::sun::star::drawing::LineCap_ROUND:
719                         {
720                             nEntryPos = 2;
721                             break;
722                         }
723                         case com::sun::star::drawing::LineCap_SQUARE:
724                         {
725                             nEntryPos = 3;
726                             break;
727                         }
728 
729                         default:
730                             break;
731                     }
732                 }
733 
734                 if(nEntryPos)
735                 {
736                     mpLBCapStyle->SelectEntryPos(nEntryPos - 1);
737                 }
738                 else
739                 {
740                     mpLBCapStyle->SetNoSelection();
741                 }
742             }
743             break;
744         }
745     }
746 }
747 
748 
749 
750 SfxBindings* LinePropertyPanel::GetBindings()
751 {
752     return mpBindings;
753 }
754 
755 
756 
757 IMPL_LINK( LinePropertyPanel, ImplPopupModeEndHdl, FloatingWindow*, EMPTYARG )
758 {
759 	return 0;
760 }
761 
762 
763 
764 
765 IMPL_LINK(LinePropertyPanel, ToolboxColorSelectHdl,ToolBox*, pToolBox)
766 {
767 	sal_uInt16 nId = pToolBox->GetCurItemId();
768 	if(nId == TBI_COLOR)
769 	{
770         maColorPopup.Show(*pToolBox);
771         maColorPopup.SetCurrentColor(maColor, mbColorAvailable);
772 	}
773 	return 0;
774 }
775 
776 
777 
778 
779 IMPL_LINK(LinePropertyPanel, ToolboxStyleSelectHdl,ToolBox*, pToolBox)
780 {
781 	if (pToolBox->GetCurItemId() == TBI_STYLE)
782 	{
783         maLineStylePopup.SetStyleSelect(mpStyleItem.get(), mpDashItem.get(), mbStyleAvailable, mbDashAvailable);
784         maLineStylePopup.Show(*pToolBox);
785 	}
786 	return 0;
787 }
788 
789 
790 
791 
792 IMPL_LINK(LinePropertyPanel, ChangeStartHdl, void*, EMPTYARG)
793 {
794 	sal_uInt16	nPos = mpLBStart->GetSelectEntryPos();
795 	if( nPos != LISTBOX_ENTRY_NOTFOUND && nPos != mpLBStart->GetSavedValue() )
796 	{
797 		XLineStartItem* pItem = NULL;
798 		if( nPos == 0 )
799 			pItem = new XLineStartItem();
800 		else if( mpLineEndList && mpLineEndList->Count() > (long) ( nPos - 1 ) )
801 			pItem = new XLineStartItem( mpLBStart->GetSelectEntry(),mpLineEndList->GetLineEnd( nPos - 1 )->GetLineEnd() );
802 		GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINEEND_STYLE, SFX_CALLMODE_RECORD, pItem,  0L);
803 		delete pItem;
804 	}
805 	return 0;
806 }
807 
808 
809 
810 
811 IMPL_LINK(LinePropertyPanel, ChangeEndHdl, void*, EMPTYARG)
812 {
813 	sal_uInt16	nPos = mpLBEnd->GetSelectEntryPos();
814 	if( nPos != LISTBOX_ENTRY_NOTFOUND && nPos != mpLBEnd->GetSavedValue() )
815 	{
816 		XLineEndItem* pItem = NULL;
817 		if( nPos == 0 )
818 			pItem = new XLineEndItem();
819 		else if( mpLineEndList && mpLineEndList->Count() > (long) ( nPos - 1 ) )
820 			pItem = new XLineEndItem( mpLBEnd->GetSelectEntry(), mpLineEndList->GetLineEnd( nPos - 1 )->GetLineEnd() );
821 		GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINEEND_STYLE, SFX_CALLMODE_RECORD, pItem,  0L);
822 		delete pItem;
823 	}
824 	return 0;
825 }
826 
827 
828 
829 
830 IMPL_LINK(LinePropertyPanel, ChangeEdgeStyleHdl, void*, EMPTYARG)
831 {
832     const sal_uInt16 nPos(mpLBEdgeStyle->GetSelectEntryPos());
833 
834     if(LISTBOX_ENTRY_NOTFOUND != nPos && nPos != mpLBEdgeStyle->GetSavedValue())
835     {
836         XLineJointItem* pItem = 0;
837 
838         switch(nPos)
839         {
840             case 0: // rounded
841             {
842                 pItem = new XLineJointItem(com::sun::star::drawing::LineJoint_ROUND);
843                 break;
844             }
845             case 1: // none
846             {
847                 pItem = new XLineJointItem(com::sun::star::drawing::LineJoint_NONE);
848                 break;
849             }
850             case 2: // mitered
851             {
852                 pItem = new XLineJointItem(com::sun::star::drawing::LineJoint_MITER);
853                 break;
854             }
855             case 3: // beveled
856             {
857                 pItem = new XLineJointItem(com::sun::star::drawing::LineJoint_BEVEL);
858                 break;
859             }
860         }
861 
862         GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_JOINT, SFX_CALLMODE_RECORD, pItem,  0L);
863         delete pItem;
864     }
865     return 0;
866 }
867 
868 
869 
870 
871 IMPL_LINK(LinePropertyPanel, ChangeCapStyleHdl, void*, EMPTYARG)
872 {
873     const sal_uInt16 nPos(mpLBCapStyle->GetSelectEntryPos());
874 
875     if(LISTBOX_ENTRY_NOTFOUND != nPos && nPos != mpLBCapStyle->GetSavedValue())
876     {
877         XLineCapItem* pItem = 0;
878 
879         switch(nPos)
880         {
881             case 0: // flat
882             {
883                 pItem = new XLineCapItem(com::sun::star::drawing::LineCap_BUTT);
884                 break;
885             }
886             case 1: // round
887             {
888                 pItem = new XLineCapItem(com::sun::star::drawing::LineCap_ROUND);
889                 break;
890             }
891             case 2: // square
892             {
893                 pItem = new XLineCapItem(com::sun::star::drawing::LineCap_SQUARE);
894                 break;
895             }
896         }
897 
898         GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_CAP, SFX_CALLMODE_RECORD, pItem,  0L);
899         delete pItem;
900     }
901     return 0;
902 }
903 
904 
905 
906 
907 IMPL_LINK(LinePropertyPanel, ToolboxWidthSelectHdl,ToolBox*, pToolBox)
908 {
909 	if (pToolBox->GetCurItemId() == TBI_WIDTH)
910 	{
911 		maLineWidthPopup.SetWidthSelect(mnWidthCoreValue, mbWidthValuable, meMapUnit);
912         maLineWidthPopup.Show(*pToolBox);
913 	}
914 	return 0;
915 }
916 
917 
918 
919 
920 IMPL_LINK( LinePropertyPanel, ChangeTransparentHdl, void *, EMPTYARG )
921 {
922 	sal_uInt16 nVal = (sal_uInt16)mpMFTransparent->GetValue();
923 	XLineTransparenceItem aItem( nVal );
924 
925 	GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_STYLE, SFX_CALLMODE_RECORD, &aItem, 0L);
926 	return( 0L );
927 }
928 
929 
930 
931 
932 PopupControl* LinePropertyPanel::CreateColorPopupControl (PopupContainer* pParent)
933 {
934     return new ColorControl(
935         pParent,
936         mpBindings,
937         SVX_RES(RID_POPUPPANEL_LINEPAGE_COLOR),
938         SVX_RES(VS_COLOR),
939         ::boost::bind(GetTransparentColor),
940         ::boost::bind(&LinePropertyPanel::SetColor, this, _1, _2),
941         pParent,
942         STR_AUTOMATICE);
943 }
944 
945 
946 
947 
948 PopupControl* LinePropertyPanel::CreateLineStylePopupControl (PopupContainer* pParent)
949 {
950     return new LineStyleControl (pParent, *this);
951 }
952 
953 
954 
955 
956 PopupControl* LinePropertyPanel::CreateLineWidthPopupControl (PopupContainer* pParent)
957 {
958     return new LineWidthControl(pParent, *this);
959 }
960 
961 
962 
963 
964 void LinePropertyPanel::EndLineStylePopupMode (void)
965 {
966     maLineStylePopup.Hide();
967 }
968 
969 
970 
971 
972 void LinePropertyPanel::EndLineWidthPopupMode (void)
973 {
974     maLineWidthPopup.Hide();
975 }
976 
977 
978 
979 
980 void  LinePropertyPanel::SetStyleIcon()
981 {
982 	if(!mbStyleAvailable)
983 	{	//custome style that not listed in panel
984 		mpTBStyle->SetItemImage(TBI_STYLE,maIMGNone);
985 		return;
986 	}
987 
988     const XLineStyle eXLS(mpStyleItem ? (XLineStyle)mpStyleItem->GetValue() : XLINE_NONE);
989 
990 	switch(eXLS)
991 	{
992 	case XLINE_NONE:
993 		mpTBStyle->SetItemImage(TBI_STYLE,maIMGNone);
994 		break;
995 	case XLINE_SOLID:
996 		mpTBStyle->SetItemImage(TBI_STYLE, GetDisplayBackground().GetColor().IsDark() ? mpIMGStyleIconH[0] : mpIMGStyleIcon[0]);
997 		break;
998 	case XLINE_DASH:
999 		if(mpDashItem && mbDashAvailable)
1000 		{
1001 			XDash aDash = mpDashItem->GetDashValue();
1002 			sal_uInt16 n = 0;
1003 			for( ; n < 10; n++ )
1004 			{
1005 				if( Dash_Set[n] == aDash )
1006 				{
1007 					mpTBStyle->SetItemImage(TBI_STYLE, GetDisplayBackground().GetColor().IsDark() ? mpIMGStyleIconH[n+1] :mpIMGStyleIcon[n+1]);
1008 					break;
1009 				}
1010 			}
1011 			if(n == 10)
1012 				mpTBStyle->SetItemImage(TBI_STYLE,maIMGNone);
1013 		}
1014 		else
1015 		{
1016 			mpTBStyle->SetItemImage(TBI_STYLE,maIMGNone);
1017 		}
1018 		break;
1019 	}
1020 }
1021 
1022 
1023 
1024 void LinePropertyPanel::SetWidthIcon(int n)
1025 {
1026 	if(n==0)
1027 		mpTBWidth->SetItemImage( TBI_WIDTH, maIMGNone);
1028 	else
1029 		mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[n-1] : mpIMGWidthIcon[n-1]);
1030 }
1031 
1032 
1033 
1034 void LinePropertyPanel::SetWidthIcon()
1035 {
1036 	if(!mbWidthValuable)
1037 	{
1038 		mpTBWidth->SetItemImage( TBI_WIDTH, maIMGNone);
1039 		return;
1040 	}
1041 
1042 	long nVal = LogicToLogic(mnWidthCoreValue * 10,(MapUnit)meMapUnit , MAP_POINT);
1043 
1044 	if(nVal <= 6)
1045 		mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[0] : mpIMGWidthIcon[0]);
1046 	else if(nVal > 6 && nVal <= 9)
1047 		mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[1] : mpIMGWidthIcon[1]);
1048 	else if(nVal > 9 && nVal <= 12)
1049 		mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[2] : mpIMGWidthIcon[2]);
1050 	else if(nVal > 12 && nVal <= 19)
1051 		mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[3] : mpIMGWidthIcon[3]);
1052 	else if(nVal > 19 && nVal <= 26)
1053 		mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[4] : mpIMGWidthIcon[4]);
1054 	else if(nVal > 26 && nVal <= 37)
1055 		mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[5] : mpIMGWidthIcon[5]);
1056 	else if(nVal > 37 && nVal <=52)
1057 		mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[6] : mpIMGWidthIcon[6]);
1058 	else if(nVal > 52)
1059 		mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[7] : mpIMGWidthIcon[7]);
1060 
1061 }
1062 
1063 
1064 
1065 void LinePropertyPanel::SetLineStyleItem(XLineStyleItem* pStyle)
1066 {
1067     mpStyleItem.reset(pStyle ? (XLineStyleItem*)pStyle->Clone() : 0);
1068 }
1069 
1070 
1071 
1072 void LinePropertyPanel::SetLineDashItem(XLineDashItem* pDash)
1073 {
1074     mpDashItem.reset(pDash ? (XLineDashItem*)pDash->Clone() : 0);
1075 }
1076 
1077 
1078 
1079 void LinePropertyPanel::SetColor (
1080     const String& rsColorName,
1081     const Color aColor)
1082 {
1083     XLineColorItem aColorItem(rsColorName, aColor);
1084     mpBindings->GetDispatcher()->Execute(SID_ATTR_LINE_COLOR, SFX_CALLMODE_RECORD, &aColorItem, 0L);
1085     maColor = aColor;
1086 }
1087 
1088 
1089 
1090 void LinePropertyPanel::SetWidth(long nWidth)
1091 {
1092     mnWidthCoreValue = nWidth;
1093     mbWidthValuable = true;
1094 }
1095 
1096 
1097 
1098 void  LinePropertyPanel::FillLineEndList()
1099 {
1100 	SfxObjectShell* pSh = SfxObjectShell::Current();
1101 	if ( pSh && pSh->GetItem( SID_LINEEND_LIST ) )
1102 	{
1103 		mpLBStart->Enable();
1104 		SvxLineEndListItem aItem( *(const SvxLineEndListItem*)(pSh->GetItem( SID_LINEEND_LIST ) ) );
1105 		mpLineEndList = aItem.GetLineEndList();
1106 		String sNone( SVX_RES( RID_SVXSTR_NONE ) );
1107 		//
1108 		mpLBStart->Clear();
1109 		mpLBEnd->Clear();
1110 
1111         if(mpLineEndList)
1112 		{
1113 			mpLBStart->InsertEntry( sNone );
1114 			mpLBStart->Fill( mpLineEndList );
1115 			mpLBStart->SelectEntryPos(0);
1116 
1117 			mpLBEnd->InsertEntry( sNone );
1118 			mpLBEnd->Fill( mpLineEndList, false);
1119 			mpLBEnd->SelectEntryPos(0);
1120 		}
1121 	}
1122 	else
1123 	{
1124 		mpLBStart->Disable();
1125 		mpLBEnd->Disable();
1126 	}
1127 }
1128 
1129 
1130 
1131 void LinePropertyPanel::SelectEndStyle(bool bStart)
1132 {
1133 	sal_Bool bSelected(false);
1134 
1135 	if(bStart)
1136 	{
1137 		//<<add
1138 		if( !mbStartAvailable )
1139 		{
1140 			mpLBStart->SetNoSelection();
1141 			return;
1142 		}
1143 		//add end>>
1144 		if(mpStartItem && mpLineEndList)
1145 		{
1146 			const basegfx::B2DPolyPolygon& rItemPolygon = mpStartItem->GetLineStartValue();
1147 			for(sal_Int32 a(0);!bSelected &&  a < mpLineEndList->Count(); a++)
1148 			{
1149 				XLineEndEntry* pEntry = mpLineEndList->GetLineEnd(a);
1150 				const basegfx::B2DPolyPolygon& rEntryPolygon = pEntry->GetLineEnd();
1151 				if(rItemPolygon == rEntryPolygon)
1152 				{
1153 					mpLBStart->SelectEntryPos((sal_uInt16)a + 1);
1154 					bSelected = true;
1155 				}
1156 			}
1157 		}
1158 		if(!bSelected)
1159 			mpLBStart->SelectEntryPos( 0 );
1160 	}
1161 	else
1162 	{
1163 		//<<add
1164 		if( !mbEndAvailable )
1165 		{
1166 			mpLBEnd->SetNoSelection();
1167 			return;
1168 		}
1169 		//add end>>
1170 		if(mpEndItem && mpLineEndList)
1171 		{
1172 			const basegfx::B2DPolyPolygon& rItemPolygon = mpEndItem->GetLineEndValue();
1173 			for(sal_Int32 a(0);!bSelected &&  a < mpLineEndList->Count(); a++)
1174 			{
1175 				XLineEndEntry* pEntry = mpLineEndList->GetLineEnd(a);
1176 				const basegfx::B2DPolyPolygon& rEntryPolygon = pEntry->GetLineEnd();
1177 				if(rItemPolygon == rEntryPolygon)
1178 				{
1179 					mpLBEnd->SelectEntryPos((sal_uInt16)a + 1);
1180 					bSelected = true;
1181 				}
1182 			}
1183 		}
1184 		if(!bSelected)
1185 			mpLBEnd->SelectEntryPos( 0 );
1186 	}
1187 }
1188 
1189 
1190 } } // end of namespace svx::sidebar
1191