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