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 <svx/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::Initialize() 270 { 271 mpIMGStyleIcon.reset(new Image[11]); 272 mpIMGStyleIcon[0] = Image(SVX_RES(IMG_LINE1_ICON)); 273 mpIMGStyleIcon[1] = Image(SVX_RES(IMG_LINE2_ICON)); 274 mpIMGStyleIcon[2] = Image(SVX_RES(IMG_LINE3_ICON)); 275 mpIMGStyleIcon[3] = Image(SVX_RES(IMG_LINE4_ICON)); 276 mpIMGStyleIcon[4] = Image(SVX_RES(IMG_LINE5_ICON)); 277 mpIMGStyleIcon[5] = Image(SVX_RES(IMG_LINE6_ICON)); 278 mpIMGStyleIcon[6] = Image(SVX_RES(IMG_LINE7_ICON)); 279 mpIMGStyleIcon[7] = Image(SVX_RES(IMG_LINE8_ICON)); 280 mpIMGStyleIcon[8] = Image(SVX_RES(IMG_LINE9_ICON)); 281 mpIMGStyleIcon[9] = Image(SVX_RES(IMG_LINE10_ICON)); 282 mpIMGStyleIcon[10] = Image(SVX_RES(IMG_LINE11_ICON)); 283 284 mpIMGWidthIcon.reset(new Image[8]); 285 mpIMGWidthIcon[0] = Image(SVX_RES(IMG_WIDTH1_ICON)); 286 mpIMGWidthIcon[1] = Image(SVX_RES(IMG_WIDTH2_ICON)); 287 mpIMGWidthIcon[2] = Image(SVX_RES(IMG_WIDTH3_ICON)); 288 mpIMGWidthIcon[3] = Image(SVX_RES(IMG_WIDTH4_ICON)); 289 mpIMGWidthIcon[4] = Image(SVX_RES(IMG_WIDTH5_ICON)); 290 mpIMGWidthIcon[5] = Image(SVX_RES(IMG_WIDTH6_ICON)); 291 mpIMGWidthIcon[6] = Image(SVX_RES(IMG_WIDTH7_ICON)); 292 mpIMGWidthIcon[7] = Image(SVX_RES(IMG_WIDTH8_ICON)); 293 294 //high contrast 295 mpIMGStyleIconH.reset(new Image[11]); 296 mpIMGStyleIconH[0] = Image(SVX_RES(IMG_LINE1_ICON_H)); 297 mpIMGStyleIconH[1] = Image(SVX_RES(IMG_LINE2_ICON_H)); 298 mpIMGStyleIconH[2] = Image(SVX_RES(IMG_LINE3_ICON_H)); 299 mpIMGStyleIconH[3] = Image(SVX_RES(IMG_LINE4_ICON_H)); 300 mpIMGStyleIconH[4] = Image(SVX_RES(IMG_LINE5_ICON_H)); 301 mpIMGStyleIconH[5] = Image(SVX_RES(IMG_LINE6_ICON_H)); 302 mpIMGStyleIconH[6] = Image(SVX_RES(IMG_LINE7_ICON_H)); 303 mpIMGStyleIconH[7] = Image(SVX_RES(IMG_LINE8_ICON_H)); 304 mpIMGStyleIconH[8] = Image(SVX_RES(IMG_LINE9_ICON_H)); 305 mpIMGStyleIconH[9] = Image(SVX_RES(IMG_LINE10_ICON_H)); 306 mpIMGStyleIconH[10] = Image(SVX_RES(IMG_LINE11_ICON_H)); 307 308 mpIMGWidthIconH.reset(new Image[8]); 309 mpIMGWidthIconH[0] = Image(SVX_RES(IMG_WIDTH1_ICON_H)); 310 mpIMGWidthIconH[1] = Image(SVX_RES(IMG_WIDTH2_ICON_H)); 311 mpIMGWidthIconH[2] = Image(SVX_RES(IMG_WIDTH3_ICON_H)); 312 mpIMGWidthIconH[3] = Image(SVX_RES(IMG_WIDTH4_ICON_H)); 313 mpIMGWidthIconH[4] = Image(SVX_RES(IMG_WIDTH5_ICON_H)); 314 mpIMGWidthIconH[5] = Image(SVX_RES(IMG_WIDTH6_ICON_H)); 315 mpIMGWidthIconH[6] = Image(SVX_RES(IMG_WIDTH7_ICON_H)); 316 mpIMGWidthIconH[7] = Image(SVX_RES(IMG_WIDTH8_ICON_H)); 317 //end 318 319 meMapUnit = maWidthControl.GetCoreMetric(); 320 321 mpTBColor->SetItemImage(TBI_COLOR, maIMGColor); 322 Size aTbxSize( mpTBColor->CalcWindowSizePixel() ); 323 mpTBColor->SetOutputSizePixel( aTbxSize ); 324 mpTBColor->SetItemBits( TBI_COLOR, mpTBColor->GetItemBits( TBI_COLOR ) | TIB_DROPDOWNONLY ); 325 mpTBColor->SetQuickHelpText(TBI_COLOR,String(SVX_RES(STR_QH_TB_COLOR))); //Add 326 mpTBColor->SetBackground(Wallpaper()); 327 mpTBColor->SetPaintTransparent(true); 328 Link aLink = LINK(this, LinePropertyPanel, ToolboxColorSelectHdl); 329 mpTBColor->SetDropdownClickHdl ( aLink ); 330 mpTBColor->SetSelectHdl ( aLink ); 331 332 mpTBStyle->SetItemImage(TBI_STYLE, mpIMGStyleIcon[0]); 333 aTbxSize = mpTBStyle->CalcWindowSizePixel() ; 334 mpTBStyle->SetOutputSizePixel( aTbxSize ); 335 mpTBStyle->SetItemBits( TBI_STYLE, mpTBStyle->GetItemBits( TBI_STYLE ) | TIB_DROPDOWNONLY ); 336 mpTBStyle->SetQuickHelpText(TBI_STYLE,String(SVX_RES(STR_QH_TB_STYLE))); //Add 337 mpTBStyle->SetBackground(Wallpaper()); 338 mpTBStyle->SetPaintTransparent(true); 339 aLink = LINK(this, LinePropertyPanel, ToolboxStyleSelectHdl); 340 mpTBStyle->SetDropdownClickHdl ( aLink ); 341 mpTBStyle->SetSelectHdl ( aLink ); 342 343 mpTBWidth->SetItemImage(TBI_WIDTH, mpIMGWidthIcon[0]); 344 aTbxSize = mpTBWidth->CalcWindowSizePixel() ; 345 mpTBWidth->SetOutputSizePixel( aTbxSize ); 346 mpTBWidth->SetItemBits( TBI_WIDTH, mpTBWidth->GetItemBits( TBI_WIDTH ) | TIB_DROPDOWNONLY ); 347 mpTBWidth->SetQuickHelpText(TBI_WIDTH,String(SVX_RES(STR_QH_TB_WIDTH))); //Add 348 mpTBWidth->SetBackground(Wallpaper()); 349 mpTBWidth->SetPaintTransparent(true); 350 aLink = LINK(this, LinePropertyPanel, ToolboxWidthSelectHdl); 351 mpTBWidth->SetDropdownClickHdl ( aLink ); 352 mpTBWidth->SetSelectHdl ( aLink ); 353 354 FillLineEndList(); 355 SelectEndStyle(true); 356 SelectEndStyle(false); 357 aLink = LINK( this, LinePropertyPanel, ChangeStartHdl ); 358 mpLBStart->SetSelectHdl( aLink ); 359 mpLBStart->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Beginning Style"))); //wj acc 360 mpLBStart->SetDropDownLineCount(std::min(sal_uInt16(20), mpLBStart->GetEntryCount())); 361 aLink = LINK( this, LinePropertyPanel, ChangeEndHdl ); 362 mpLBEnd->SetSelectHdl( aLink ); 363 mpLBEnd->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Ending Style"))); //wj acc 364 mpLBEnd->SetDropDownLineCount(std::min(sal_uInt16(20), mpLBEnd->GetEntryCount())); 365 366 aLink = LINK(this, LinePropertyPanel, ChangeTransparentHdl); 367 mpMFTransparent->SetModifyHdl(aLink); 368 mpMFTransparent->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Transparency"))); //wj acc 369 370 mpTBWidth->SetAccessibleRelationLabeledBy(mpFTWidth.get()); 371 mpTBColor->SetAccessibleRelationLabeledBy(mpFTColor.get()); 372 mpTBStyle->SetAccessibleRelationLabeledBy(mpFTStyle.get()); 373 mpMFTransparent->SetAccessibleRelationLabeledBy(mpFTTrancparency.get()); 374 mpLBStart->SetAccessibleRelationLabeledBy(mpFTArrow.get()); 375 mpLBEnd->SetAccessibleRelationLabeledBy(mpLBEnd.get()); 376 377 aLink = LINK( this, LinePropertyPanel, ChangeEdgeStyleHdl ); 378 mpLBEdgeStyle->SetSelectHdl( aLink ); 379 mpLBEdgeStyle->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Corner Style"))); 380 381 aLink = LINK( this, LinePropertyPanel, ChangeCapStyleHdl ); 382 mpLBCapStyle->SetSelectHdl( aLink ); 383 mpLBCapStyle->SetAccessibleName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Cap Style"))); 384 } 385 386 387 388 void LinePropertyPanel::SetupIcons(void) 389 { 390 if(Theme::GetBoolean(Theme::Bool_UseSymphonyIcons)) 391 { 392 // todo 393 } 394 else 395 { 396 // todo 397 } 398 } 399 400 401 402 LinePropertyPanel* LinePropertyPanel::Create ( 403 Window* pParent, 404 const cssu::Reference<css::frame::XFrame>& rxFrame, 405 SfxBindings* pBindings) 406 { 407 if (pParent == NULL) 408 throw lang::IllegalArgumentException(A2S("no parent Window given to LinePropertyPanel::Create"), NULL, 0); 409 if ( ! rxFrame.is()) 410 throw lang::IllegalArgumentException(A2S("no XFrame given to LinePropertyPanel::Create"), NULL, 1); 411 if (pBindings == NULL) 412 throw lang::IllegalArgumentException(A2S("no SfxBindings given to LinePropertyPanel::Create"), NULL, 2); 413 414 return new LinePropertyPanel( 415 pParent, 416 rxFrame, 417 pBindings); 418 } 419 420 421 422 void LinePropertyPanel::DataChanged( 423 const DataChangedEvent& rEvent) 424 { 425 (void)rEvent; 426 427 SetupIcons(); 428 } 429 430 431 432 void LinePropertyPanel::HandleContextChange( 433 const ::sfx2::sidebar::EnumContext aContext) 434 { 435 if(maContext == aContext) 436 { 437 // Nothing to do. 438 return; 439 } 440 441 maContext = aContext; 442 443 444 445 // todo 446 } 447 448 449 450 void LinePropertyPanel::NotifyItemUpdate( 451 sal_uInt16 nSID, 452 SfxItemState eState, 453 const SfxPoolItem* pState) 454 { 455 switch(nSID) 456 { 457 case SID_ATTR_LINE_COLOR: 458 { 459 if( eState == SFX_ITEM_DISABLED) 460 { 461 mpFTColor->Disable(); 462 mpTBColor->Disable(); 463 mbColorAvailable = false; 464 mpColorUpdater->Update(COL_WHITE); 465 } 466 else 467 { 468 mpFTColor->Enable(); 469 mpTBColor->Enable(); 470 const XLineColorItem* pItem = dynamic_cast< const XLineColorItem* >(pState); 471 472 if(eState >= SFX_ITEM_DEFAULT && pItem) 473 { 474 maColor = pItem->GetColorValue(); 475 mbColorAvailable = true; 476 mpColorUpdater->Update(maColor); 477 } 478 else 479 { 480 mbColorAvailable = false; 481 mpColorUpdater->Update(COL_WHITE); 482 } 483 } 484 break; 485 } 486 case SID_ATTR_LINE_STYLE: 487 case SID_ATTR_LINE_DASH: 488 { 489 if( eState == SFX_ITEM_DISABLED) 490 { 491 mpFTStyle->Disable(); 492 mpTBStyle->Disable(); 493 mpTBStyle->SetItemImage(TBI_STYLE,maIMGNone); 494 } 495 else 496 { 497 mpFTStyle->Enable(); 498 mpTBStyle->Enable(); 499 if( eState >= SFX_ITEM_DEFAULT ) 500 { 501 if(nSID == SID_ATTR_LINE_STYLE) 502 { 503 const XLineStyleItem* pItem = dynamic_cast< const XLineStyleItem* >(pState); 504 505 if(pItem) 506 { 507 mbStyleAvailable =true; 508 mpStyleItem.reset(pState ? (XLineStyleItem*)pItem->Clone() : 0); 509 } 510 } 511 else if(nSID == SID_ATTR_LINE_DASH) 512 { 513 const XLineDashItem* pItem = dynamic_cast< const XLineDashItem* >(pState); 514 515 if(pItem) 516 { 517 mbDashAvailable = true; 518 mpDashItem.reset(pState ? (XLineDashItem*)pItem->Clone() : 0); 519 } 520 } 521 } 522 else 523 { 524 if(nSID == SID_ATTR_LINE_STYLE) 525 mbStyleAvailable = false; 526 else 527 mbDashAvailable = false; 528 } 529 SetStyleIcon(); 530 } 531 break; 532 } 533 case SID_ATTR_LINE_TRANSPARENCE: 534 { 535 if( eState == SFX_ITEM_DISABLED ) 536 { 537 mpFTTrancparency->Disable(); 538 mpMFTransparent->Disable(); 539 mpMFTransparent->SetValue(0);//add 540 mpMFTransparent->SetText(String()); 541 mbTransAvailable = false; 542 } 543 else 544 { 545 mpFTTrancparency->Enable(); 546 mpMFTransparent->Enable(); 547 mbTransAvailable = true; 548 const XLineTransparenceItem* pItem = dynamic_cast< const XLineTransparenceItem* >(pState); 549 550 if(eState != SFX_ITEM_DONTCARE && pItem) 551 { 552 mnTrans = pItem->GetValue(); 553 mpMFTransparent->SetValue(mnTrans); 554 } 555 else 556 { 557 mpMFTransparent->SetValue(0);//add 558 mpMFTransparent->SetText(String()); 559 } 560 } 561 break; 562 } 563 case SID_ATTR_LINE_WIDTH: 564 { 565 if(eState == SFX_ITEM_DISABLED) 566 { 567 mpTBWidth->Disable(); 568 mpFTWidth->Disable(); 569 } 570 else 571 { 572 //enable 573 mpTBWidth->Enable(); 574 mpFTWidth->Enable(); 575 const XLineWidthItem* pItem = dynamic_cast< const XLineWidthItem* >(pState); 576 577 if(eState >= SFX_ITEM_AVAILABLE && pItem) 578 { 579 mnWidthCoreValue = pItem->GetValue(); 580 mbWidthValuable = true; 581 } 582 else 583 { 584 mbWidthValuable = false; 585 } 586 } 587 SetWidthIcon(); 588 break; 589 } 590 case SID_ATTR_LINE_START: 591 { 592 const XLineStartItem* pItem = dynamic_cast< const XLineStartItem* >(pState); 593 594 if(eState != SFX_ITEM_DONTCARE && pItem) 595 { 596 mbStartAvailable = true; //add 597 mpStartItem.reset(pItem ? (XLineStartItem*)pItem->Clone() : 0); 598 SelectEndStyle(true); 599 } 600 else 601 { 602 mpLBStart->SetNoSelection(); 603 mbStartAvailable = false; //add 604 } 605 break; 606 } 607 case SID_ATTR_LINE_END: 608 { 609 mpFTArrow->Enable(); 610 mpLBEnd->Enable(); 611 const XLineEndItem* pItem = dynamic_cast< const XLineEndItem* >(pState); 612 613 if(eState != SFX_ITEM_DONTCARE && pItem) 614 { 615 mbEndAvailable = true; //add 616 mpEndItem.reset(pItem ? (XLineEndItem*)pItem->Clone() : 0); 617 SelectEndStyle(false); 618 } 619 else 620 { 621 mpLBEnd->SetNoSelection(); 622 mbEndAvailable = false; //add 623 } 624 break; 625 } 626 case SID_LINEEND_LIST: 627 { 628 FillLineEndList(); 629 SelectEndStyle(true); 630 SelectEndStyle(false); 631 break; 632 } 633 case SID_ATTR_LINE_JOINT: 634 { 635 if(eState == SFX_ITEM_DISABLED) 636 { 637 mpLBEdgeStyle->Disable(); 638 } 639 else 640 { 641 mpLBEdgeStyle->Enable(); 642 const XLineJointItem* pItem = dynamic_cast< const XLineJointItem* >(pState); 643 sal_uInt16 nEntryPos(0); 644 645 if(eState >= SFX_ITEM_AVAILABLE && pItem) 646 { 647 switch(pItem->GetValue()) 648 { 649 case com::sun::star::drawing::LineJoint_MIDDLE: 650 case com::sun::star::drawing::LineJoint_ROUND: 651 { 652 nEntryPos = 1; 653 break; 654 } 655 case com::sun::star::drawing::LineJoint_NONE: 656 { 657 nEntryPos = 2; 658 break; 659 } 660 case com::sun::star::drawing::LineJoint_MITER: 661 { 662 nEntryPos = 3; 663 break; 664 } 665 case com::sun::star::drawing::LineJoint_BEVEL: 666 { 667 nEntryPos = 4; 668 break; 669 } 670 671 default: 672 break; 673 } 674 } 675 676 if(nEntryPos) 677 { 678 mpLBEdgeStyle->SelectEntryPos(nEntryPos - 1); 679 } 680 else 681 { 682 mpLBEdgeStyle->SetNoSelection(); 683 } 684 } 685 break; 686 } 687 case SID_ATTR_LINE_CAP: 688 { 689 if(eState == SFX_ITEM_DISABLED) 690 { 691 mpLBCapStyle->Disable(); 692 } 693 else 694 { 695 mpLBCapStyle->Enable(); 696 const XLineCapItem* pItem = dynamic_cast< const XLineCapItem* >(pState); 697 sal_uInt16 nEntryPos(0); 698 699 if(eState >= SFX_ITEM_AVAILABLE && pItem) 700 { 701 switch(pItem->GetValue()) 702 { 703 case com::sun::star::drawing::LineCap_BUTT: 704 { 705 nEntryPos = 1; 706 break; 707 } 708 case com::sun::star::drawing::LineCap_ROUND: 709 { 710 nEntryPos = 2; 711 break; 712 } 713 case com::sun::star::drawing::LineCap_SQUARE: 714 { 715 nEntryPos = 3; 716 break; 717 } 718 719 default: 720 break; 721 } 722 } 723 724 if(nEntryPos) 725 { 726 mpLBCapStyle->SelectEntryPos(nEntryPos - 1); 727 } 728 else 729 { 730 mpLBCapStyle->SetNoSelection(); 731 } 732 } 733 break; 734 } 735 } 736 } 737 738 739 740 SfxBindings* LinePropertyPanel::GetBindings() 741 { 742 return mpBindings; 743 } 744 745 746 747 IMPL_LINK( LinePropertyPanel, ImplPopupModeEndHdl, FloatingWindow*, EMPTYARG ) 748 { 749 return 0; 750 } 751 752 753 754 755 IMPL_LINK(LinePropertyPanel, ToolboxColorSelectHdl,ToolBox*, pToolBox) 756 { 757 sal_uInt16 nId = pToolBox->GetCurItemId(); 758 if(nId == TBI_COLOR) 759 { 760 maColorPopup.Show(*pToolBox); 761 maColorPopup.SetCurrentColor(maColor, mbColorAvailable); 762 } 763 return 0; 764 } 765 766 767 768 769 IMPL_LINK(LinePropertyPanel, ToolboxStyleSelectHdl,ToolBox*, pToolBox) 770 { 771 if (pToolBox->GetCurItemId() == TBI_STYLE) 772 { 773 maLineStylePopup.SetStyleSelect(mpStyleItem.get(), mpDashItem.get(), mbStyleAvailable, mbDashAvailable); 774 maLineStylePopup.Show(*pToolBox); 775 } 776 return 0; 777 } 778 779 780 781 782 IMPL_LINK(LinePropertyPanel, ChangeStartHdl, void*, EMPTYARG) 783 { 784 sal_uInt16 nPos = mpLBStart->GetSelectEntryPos(); 785 if( nPos != LISTBOX_ENTRY_NOTFOUND && nPos != mpLBStart->GetSavedValue() ) 786 { 787 XLineStartItem* pItem = NULL; 788 if( nPos == 0 ) 789 pItem = new XLineStartItem(); 790 else if( mpLineEndList && mpLineEndList->Count() > (long) ( nPos - 1 ) ) 791 pItem = new XLineStartItem( mpLBStart->GetSelectEntry(),mpLineEndList->GetLineEnd( nPos - 1 )->GetLineEnd() ); 792 GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINEEND_STYLE, SFX_CALLMODE_RECORD, pItem, 0L); 793 delete pItem; 794 } 795 return 0; 796 } 797 798 799 800 801 IMPL_LINK(LinePropertyPanel, ChangeEndHdl, void*, EMPTYARG) 802 { 803 sal_uInt16 nPos = mpLBEnd->GetSelectEntryPos(); 804 if( nPos != LISTBOX_ENTRY_NOTFOUND && nPos != mpLBEnd->GetSavedValue() ) 805 { 806 XLineEndItem* pItem = NULL; 807 if( nPos == 0 ) 808 pItem = new XLineEndItem(); 809 else if( mpLineEndList && mpLineEndList->Count() > (long) ( nPos - 1 ) ) 810 pItem = new XLineEndItem( mpLBEnd->GetSelectEntry(), mpLineEndList->GetLineEnd( nPos - 1 )->GetLineEnd() ); 811 GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINEEND_STYLE, SFX_CALLMODE_RECORD, pItem, 0L); 812 delete pItem; 813 } 814 return 0; 815 } 816 817 818 819 820 IMPL_LINK(LinePropertyPanel, ChangeEdgeStyleHdl, void*, EMPTYARG) 821 { 822 const sal_uInt16 nPos(mpLBEdgeStyle->GetSelectEntryPos()); 823 824 if(LISTBOX_ENTRY_NOTFOUND != nPos && nPos != mpLBEdgeStyle->GetSavedValue()) 825 { 826 XLineJointItem* pItem = 0; 827 828 switch(nPos) 829 { 830 case 0: // rounded 831 { 832 pItem = new XLineJointItem(com::sun::star::drawing::LineJoint_ROUND); 833 break; 834 } 835 case 1: // none 836 { 837 pItem = new XLineJointItem(com::sun::star::drawing::LineJoint_NONE); 838 break; 839 } 840 case 2: // mitered 841 { 842 pItem = new XLineJointItem(com::sun::star::drawing::LineJoint_MITER); 843 break; 844 } 845 case 3: // beveled 846 { 847 pItem = new XLineJointItem(com::sun::star::drawing::LineJoint_BEVEL); 848 break; 849 } 850 } 851 852 GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_JOINT, SFX_CALLMODE_RECORD, pItem, 0L); 853 delete pItem; 854 } 855 return 0; 856 } 857 858 859 860 861 IMPL_LINK(LinePropertyPanel, ChangeCapStyleHdl, void*, EMPTYARG) 862 { 863 const sal_uInt16 nPos(mpLBCapStyle->GetSelectEntryPos()); 864 865 if(LISTBOX_ENTRY_NOTFOUND != nPos && nPos != mpLBCapStyle->GetSavedValue()) 866 { 867 XLineCapItem* pItem = 0; 868 869 switch(nPos) 870 { 871 case 0: // flat 872 { 873 pItem = new XLineCapItem(com::sun::star::drawing::LineCap_BUTT); 874 break; 875 } 876 case 1: // round 877 { 878 pItem = new XLineCapItem(com::sun::star::drawing::LineCap_ROUND); 879 break; 880 } 881 case 2: // square 882 { 883 pItem = new XLineCapItem(com::sun::star::drawing::LineCap_SQUARE); 884 break; 885 } 886 } 887 888 GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_CAP, SFX_CALLMODE_RECORD, pItem, 0L); 889 delete pItem; 890 } 891 return 0; 892 } 893 894 895 896 897 IMPL_LINK(LinePropertyPanel, ToolboxWidthSelectHdl,ToolBox*, pToolBox) 898 { 899 if (pToolBox->GetCurItemId() == TBI_WIDTH) 900 { 901 maLineWidthPopup.SetWidthSelect(mnWidthCoreValue, mbWidthValuable, meMapUnit); 902 maLineWidthPopup.Show(*pToolBox); 903 } 904 return 0; 905 } 906 907 908 909 910 IMPL_LINK( LinePropertyPanel, ChangeTransparentHdl, void *, EMPTYARG ) 911 { 912 sal_uInt16 nVal = (sal_uInt16)mpMFTransparent->GetValue(); 913 XLineTransparenceItem aItem( nVal ); 914 915 GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_STYLE, SFX_CALLMODE_RECORD, &aItem, 0L); 916 return( 0L ); 917 } 918 919 920 921 922 PopupControl* LinePropertyPanel::CreateColorPopupControl (PopupContainer* pParent) 923 { 924 const ResId aResId(SVX_RES(STR_AUTOMATICE)); 925 926 return new ColorControl( 927 pParent, 928 mpBindings, 929 SVX_RES(RID_POPUPPANEL_LINEPAGE_COLOR), 930 SVX_RES(VS_COLOR), 931 ::boost::bind(GetTransparentColor), 932 ::boost::bind(&LinePropertyPanel::SetColor, this, _1, _2), 933 pParent, 934 &aResId); 935 } 936 937 938 939 940 PopupControl* LinePropertyPanel::CreateLineStylePopupControl (PopupContainer* pParent) 941 { 942 return new LineStyleControl (pParent, *this); 943 } 944 945 946 947 948 PopupControl* LinePropertyPanel::CreateLineWidthPopupControl (PopupContainer* pParent) 949 { 950 return new LineWidthControl(pParent, *this); 951 } 952 953 954 955 956 void LinePropertyPanel::EndLineStylePopupMode (void) 957 { 958 maLineStylePopup.Hide(); 959 } 960 961 962 963 964 void LinePropertyPanel::EndLineWidthPopupMode (void) 965 { 966 maLineWidthPopup.Hide(); 967 } 968 969 970 971 972 void LinePropertyPanel::SetStyleIcon() 973 { 974 if(!mbStyleAvailable) 975 { //custome style that not listed in panel 976 mpTBStyle->SetItemImage(TBI_STYLE,maIMGNone); 977 return; 978 } 979 980 const XLineStyle eXLS(mpStyleItem ? (XLineStyle)mpStyleItem->GetValue() : XLINE_NONE); 981 982 switch(eXLS) 983 { 984 case XLINE_NONE: 985 mpTBStyle->SetItemImage(TBI_STYLE,maIMGNone); 986 break; 987 case XLINE_SOLID: 988 mpTBStyle->SetItemImage(TBI_STYLE, GetDisplayBackground().GetColor().IsDark() ? mpIMGStyleIconH[0] : mpIMGStyleIcon[0]); 989 break; 990 case XLINE_DASH: 991 if(mpDashItem && mbDashAvailable) 992 { 993 XDash aDash = mpDashItem->GetDashValue(); 994 sal_uInt16 n = 0; 995 for( ; n < 10; n++ ) 996 { 997 if( Dash_Set[n] == aDash ) 998 { 999 mpTBStyle->SetItemImage(TBI_STYLE, GetDisplayBackground().GetColor().IsDark() ? mpIMGStyleIconH[n+1] :mpIMGStyleIcon[n+1]); 1000 break; 1001 } 1002 } 1003 if(n == 10) 1004 mpTBStyle->SetItemImage(TBI_STYLE,maIMGNone); 1005 } 1006 else 1007 { 1008 mpTBStyle->SetItemImage(TBI_STYLE,maIMGNone); 1009 } 1010 break; 1011 } 1012 } 1013 1014 1015 1016 void LinePropertyPanel::SetWidthIcon(int n) 1017 { 1018 if(n==0) 1019 mpTBWidth->SetItemImage( TBI_WIDTH, maIMGNone); 1020 else 1021 mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[n-1] : mpIMGWidthIcon[n-1]); 1022 } 1023 1024 1025 1026 void LinePropertyPanel::SetWidthIcon() 1027 { 1028 if(!mbWidthValuable) 1029 { 1030 mpTBWidth->SetItemImage( TBI_WIDTH, maIMGNone); 1031 return; 1032 } 1033 1034 long nVal = LogicToLogic(mnWidthCoreValue * 10,(MapUnit)meMapUnit , MAP_POINT); 1035 1036 if(nVal <= 6) 1037 mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[0] : mpIMGWidthIcon[0]); 1038 else if(nVal > 6 && nVal <= 9) 1039 mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[1] : mpIMGWidthIcon[1]); 1040 else if(nVal > 9 && nVal <= 12) 1041 mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[2] : mpIMGWidthIcon[2]); 1042 else if(nVal > 12 && nVal <= 19) 1043 mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[3] : mpIMGWidthIcon[3]); 1044 else if(nVal > 19 && nVal <= 26) 1045 mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[4] : mpIMGWidthIcon[4]); 1046 else if(nVal > 26 && nVal <= 37) 1047 mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[5] : mpIMGWidthIcon[5]); 1048 else if(nVal > 37 && nVal <=52) 1049 mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[6] : mpIMGWidthIcon[6]); 1050 else if(nVal > 52) 1051 mpTBWidth->SetItemImage( TBI_WIDTH, GetDisplayBackground().GetColor().IsDark() ? mpIMGWidthIconH[7] : mpIMGWidthIcon[7]); 1052 1053 } 1054 1055 1056 1057 void LinePropertyPanel::SetLineStyleItem(XLineStyleItem* pStyle) 1058 { 1059 mpStyleItem.reset(pStyle ? (XLineStyleItem*)pStyle->Clone() : 0); 1060 } 1061 1062 1063 1064 void LinePropertyPanel::SetLineDashItem(XLineDashItem* pDash) 1065 { 1066 mpDashItem.reset(pDash ? (XLineDashItem*)pDash->Clone() : 0); 1067 } 1068 1069 1070 1071 void LinePropertyPanel::SetColor ( 1072 const String& rsColorName, 1073 const Color aColor) 1074 { 1075 XLineColorItem aColorItem(rsColorName, aColor); 1076 mpBindings->GetDispatcher()->Execute(SID_ATTR_LINE_COLOR, SFX_CALLMODE_RECORD, &aColorItem, 0L); 1077 maColor = aColor; 1078 } 1079 1080 1081 1082 void LinePropertyPanel::SetWidth(long nWidth) 1083 { 1084 mnWidthCoreValue = nWidth; 1085 mbWidthValuable = true; 1086 } 1087 1088 1089 1090 void LinePropertyPanel::FillLineEndList() 1091 { 1092 SfxObjectShell* pSh = SfxObjectShell::Current(); 1093 if ( pSh && pSh->GetItem( SID_LINEEND_LIST ) ) 1094 { 1095 mpLBStart->Enable(); 1096 SvxLineEndListItem aItem( *(const SvxLineEndListItem*)(pSh->GetItem( SID_LINEEND_LIST ) ) ); 1097 mpLineEndList = aItem.GetLineEndList(); 1098 String sNone( SVX_RES( RID_SVXSTR_NONE ) ); 1099 // 1100 mpLBStart->Clear(); 1101 mpLBEnd->Clear(); 1102 1103 if(mpLineEndList) 1104 { 1105 mpLBStart->InsertEntry( sNone ); 1106 mpLBStart->Fill( mpLineEndList ); 1107 mpLBStart->SelectEntryPos(0); 1108 1109 mpLBEnd->InsertEntry( sNone ); 1110 mpLBEnd->Fill( mpLineEndList, false); 1111 mpLBEnd->SelectEntryPos(0); 1112 } 1113 } 1114 else 1115 { 1116 mpLBStart->Disable(); 1117 mpLBEnd->Disable(); 1118 } 1119 } 1120 1121 1122 1123 void LinePropertyPanel::SelectEndStyle(bool bStart) 1124 { 1125 sal_Bool bSelected(false); 1126 1127 if(bStart) 1128 { 1129 //<<add 1130 if( !mbStartAvailable ) 1131 { 1132 mpLBStart->SetNoSelection(); 1133 return; 1134 } 1135 //add end>> 1136 if(mpStartItem && mpLineEndList) 1137 { 1138 const basegfx::B2DPolyPolygon& rItemPolygon = mpStartItem->GetLineStartValue(); 1139 for(sal_Int32 a(0);!bSelected && a < mpLineEndList->Count(); a++) 1140 { 1141 XLineEndEntry* pEntry = mpLineEndList->GetLineEnd(a); 1142 const basegfx::B2DPolyPolygon& rEntryPolygon = pEntry->GetLineEnd(); 1143 if(rItemPolygon == rEntryPolygon) 1144 { 1145 mpLBStart->SelectEntryPos((sal_uInt16)a + 1); 1146 bSelected = true; 1147 } 1148 } 1149 } 1150 if(!bSelected) 1151 mpLBStart->SelectEntryPos( 0 ); 1152 } 1153 else 1154 { 1155 //<<add 1156 if( !mbEndAvailable ) 1157 { 1158 mpLBEnd->SetNoSelection(); 1159 return; 1160 } 1161 //add end>> 1162 if(mpEndItem && mpLineEndList) 1163 { 1164 const basegfx::B2DPolyPolygon& rItemPolygon = mpEndItem->GetLineEndValue(); 1165 for(sal_Int32 a(0);!bSelected && a < mpLineEndList->Count(); a++) 1166 { 1167 XLineEndEntry* pEntry = mpLineEndList->GetLineEnd(a); 1168 const basegfx::B2DPolyPolygon& rEntryPolygon = pEntry->GetLineEnd(); 1169 if(rItemPolygon == rEntryPolygon) 1170 { 1171 mpLBEnd->SelectEntryPos((sal_uInt16)a + 1); 1172 bSelected = true; 1173 } 1174 } 1175 } 1176 if(!bSelected) 1177 mpLBEnd->SelectEntryPos( 0 ); 1178 } 1179 } 1180 1181 1182 } } // end of namespace svx::sidebar 1183 1184 // eof 1185