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 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sd.hxx" 26 27 #include "DrawViewShell.hxx" 28 #include <vcl/wrkwin.hxx> 29 #include <svx/xgrad.hxx> 30 #include <svx/svdpagv.hxx> 31 #include <svx/xlnwtit.hxx> 32 #include <svx/xlndsit.hxx> 33 #include <svx/xflhtit.hxx> 34 #include <svx/xflgrit.hxx> 35 #include <svx/xlnclit.hxx> 36 #include <svx/xflclit.hxx> 37 #include <svx/xlnwtit.hxx> 38 #include <sfx2/bindings.hxx> 39 40 #ifndef _SFX_DISPATCH_HXX //autogen 41 #include <sfx2/dispatch.hxx> 42 #endif 43 #include <svl/intitem.hxx> 44 #include <sfx2/app.hxx> 45 #include <sfx2/request.hxx> 46 #include <svl/stritem.hxx> 47 #ifndef _SVXIDS_HXX 48 #include <svx/svxids.hrc> 49 #endif 50 #include <svx/xtable.hxx> 51 #include <svx/gallery.hxx> 52 #include <vcl/graph.hxx> 53 #include <svx/svdograf.hxx> 54 #include <svx/svdoole2.hxx> 55 #include <sot/storage.hxx> 56 #include <svl/whiter.hxx> 57 #include <basic/sbstar.hxx> 58 59 #include <sfx2/viewfrm.hxx> 60 61 62 #include "app.hrc" 63 #include "strings.hrc" 64 #include "Window.hxx" 65 #include "drawdoc.hxx" 66 #include "drawview.hxx" 67 #include "DrawDocShell.hxx" 68 #include "sdresid.hxx" 69 #include "fupoor.hxx" 70 71 #include <svx/galleryitem.hxx> 72 #include <com/sun/star/gallery/GalleryItemType.hpp> 73 74 namespace sd { 75 76 #ifndef SO2_DECL_SVINPLACEOBJECT_DEFINED 77 #define SO2_DECL_SVINPLACEOBJECT_DEFINED 78 SO2_DECL_REF(SvInPlaceObject) 79 #endif 80 #ifndef SO2_DECL_SVSTORAGE_DEFINED 81 #define SO2_DECL_SVSTORAGE_DEFINED 82 SO2_DECL_REF(SvStorage) 83 #endif 84 85 86 /************************************************************************* 87 |* 88 |* SfxRequests fuer Gallery bearbeiten 89 |* 90 \************************************************************************/ 91 92 void DrawViewShell::ExecGallery(SfxRequest& rReq) 93 { 94 // waehrend einer Diashow wird nichts ausgefuehrt! 95 if(HasCurrentFunction(SID_PRESENTATION)) 96 return; 97 98 const SfxItemSet* pArgs = rReq.GetArgs(); 99 100 SFX_ITEMSET_ARG( pArgs, pGalleryItem, SvxGalleryItem, SID_GALLERY_FORMATS, sal_False ); 101 if ( !pGalleryItem ) 102 return; 103 104 GetDocSh()->SetWaitCursor( sal_True ); 105 106 sal_Int8 nType( pGalleryItem->GetType() ); 107 // Graphik einfuegen 108 if (nType == com::sun::star::gallery::GalleryItemType::GRAPHIC) 109 { 110 Graphic aGraphic( pGalleryItem->GetGraphic() ); 111 112 // Ggf. Groesse reduzieren 113 Window aWindow (GetActiveWindow()); 114 aWindow.SetMapMode(aGraphic.GetPrefMapMode()); 115 Size aSizePix = aWindow.LogicToPixel(aGraphic.GetPrefSize()); 116 aWindow.SetMapMode( MapMode(MAP_100TH_MM) ); 117 Size aSize = aWindow.PixelToLogic(aSizePix); 118 119 // Groesse ggf. auf Seitengroesse begrenzen 120 SdrPage* pPage = mpDrawView->GetSdrPageView()->GetPage(); 121 Size aPageSize = pPage->GetSize(); 122 aPageSize.Width() -= pPage->GetLftBorder() + pPage->GetRgtBorder(); 123 aPageSize.Height() -= pPage->GetUppBorder() + pPage->GetLwrBorder(); 124 125 126 // Falls Grafik zu gross, wird die Grafik 127 // in die Seite eingepasst 128 if ( ( ( aSize.Height() > aPageSize.Height() ) || ( aSize.Width() > aPageSize.Width() ) ) && 129 aSize.Height() && aPageSize.Height() ) 130 { 131 float fGrfWH = (float)aSize.Width() / 132 (float)aSize.Height(); 133 float fWinWH = (float)aPageSize.Width() / 134 (float)aPageSize.Height(); 135 136 // Grafik an Pagesize anpassen (skaliert) 137 if ((fGrfWH != 0.F) && (fGrfWH < fWinWH)) 138 { 139 aSize.Width() = (long)(aPageSize.Height() * fGrfWH); 140 aSize.Height()= aPageSize.Height(); 141 } 142 else 143 { 144 aSize.Width() = aPageSize.Width(); 145 aSize.Height()= (long)(aPageSize.Width() / fGrfWH); 146 } 147 } 148 149 150 // Ausgaberechteck fuer Grafik setzen 151 Point aPnt ((aPageSize.Width() - aSize.Width()) / 2, 152 (aPageSize.Height() - aSize.Height()) / 2); 153 aPnt += Point(pPage->GetLftBorder(), pPage->GetUppBorder()); 154 Rectangle aRect (aPnt, aSize); 155 156 SdrGrafObj* pGrafObj = NULL; 157 158 sal_Bool bInsertNewObject = sal_True; 159 160 if ( mpDrawView->AreObjectsMarked() ) 161 { 162 /****************************************************** 163 * Ist ein leeres Graphik-Objekt vorhanden? 164 ******************************************************/ 165 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList(); 166 167 if (rMarkList.GetMarkCount() == 1) 168 { 169 SdrMark* pMark = rMarkList.GetMark(0); 170 SdrObject* pObj = pMark->GetMarkedSdrObj(); 171 172 if (pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_GRAF) 173 { 174 pGrafObj = (SdrGrafObj*) pObj; 175 176 if( pGrafObj->IsEmptyPresObj() ) 177 { 178 /****************************************** 179 * Das leere Graphik-Objekt bekommt eine neue 180 * Graphik 181 ******************************************/ 182 bInsertNewObject = sal_False; 183 184 SdrGrafObj* pNewGrafObj = (SdrGrafObj*) pGrafObj->Clone(); 185 pNewGrafObj->SetEmptyPresObj(sal_False); 186 pNewGrafObj->SetOutlinerParaObject(NULL); 187 pNewGrafObj->SetGraphic(aGraphic); 188 189 String aStr(mpDrawView->GetDescriptionOfMarkedObjects()); 190 aStr += sal_Unicode(' '); 191 aStr += String(SdResId(STR_UNDO_REPLACE)); 192 mpDrawView->BegUndo(aStr); 193 SdrPageView* pPV = mpDrawView->GetSdrPageView(); 194 mpDrawView->ReplaceObjectAtView(pGrafObj, *pPV, pNewGrafObj); 195 mpDrawView->EndUndo(); 196 } 197 } 198 } 199 } 200 201 202 if( bInsertNewObject ) 203 { 204 pGrafObj = new SdrGrafObj(aGraphic, aRect); 205 SdrPageView* pPV = mpDrawView->GetSdrPageView(); 206 mpDrawView->InsertObjectAtView(pGrafObj, *pPV, SDRINSERT_SETDEFLAYER); 207 } 208 209 // Soll nur ein Link benutzt werden? 210 if( pGrafObj && pGalleryItem->IsLink() ) 211 pGrafObj->SetGraphicLink( pGalleryItem->GetURL(), pGalleryItem->GetFilterName() ); 212 } 213 // insert sound 214 else if( nType == com::sun::star::gallery::GalleryItemType::MEDIA ) 215 { 216 const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGalleryItem->GetURL() ); 217 GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, 0L ); 218 } 219 220 GetDocSh()->SetWaitCursor( sal_False ); 221 } 222 223 224 /************************************************************************* 225 |* 226 |* Statuswerte fuer Gallery zurueckgeben 227 |* 228 \************************************************************************/ 229 230 void DrawViewShell::GetGalleryState(SfxItemSet& ) 231 { 232 } 233 234 /************************************************************************* 235 |* 236 |* Makros fuer die Attributeinstellungen bearbeiten 237 |* 238 \************************************************************************/ 239 240 // 241 // die vorgehensweise fuer die attributaenderung ist praktisch ueberall identisch 242 // 1. bisherige attribute auslesen 243 // 2. parameter aus dem basic-set auslesen 244 // 3. gewaehltes item aus dem attribut-set loeschen 245 // 4. neues attribut-item erzeugen 246 // 5. item in den set eintragen 247 // 248 void DrawViewShell::AttrExec (SfxRequest &rReq) 249 { 250 // waehrend einer Diashow wird nichts ausgefuehrt! 251 if(HasCurrentFunction(SID_PRESENTATION)) 252 return; 253 254 CheckLineTo (rReq); 255 256 SfxBindings& rBindings = GetViewFrame()->GetBindings(); 257 SfxItemSet* pAttr = new SfxItemSet ( GetDoc()->GetPool() ); 258 259 GetView()->GetAttributes( *pAttr ); 260 const SfxItemSet* pArgs = rReq.GetArgs(); 261 262 switch (rReq.GetSlot ()) 263 { 264 // neuen fuellstil setzen 265 case SID_SETFILLSTYLE : 266 if (pArgs) 267 if (pArgs->Count () == 1) 268 { 269 SFX_REQUEST_ARG (rReq, pFillStyle, SfxUInt32Item, ID_VAL_STYLE, sal_False); 270 if (CHECK_RANGE (XFILL_NONE, (sal_Int32)pFillStyle->GetValue (), XFILL_BITMAP)) 271 { 272 pAttr->ClearItem (XATTR_FILLSTYLE); 273 pAttr->Put (XFillStyleItem ((XFillStyle) pFillStyle->GetValue ()), XATTR_FILLSTYLE); 274 rBindings.Invalidate (SID_ATTR_FILL_STYLE); 275 } 276 else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE); 277 278 break; 279 } 280 281 StarBASIC::FatalError (SbERR_WRONG_ARGS); 282 break; 283 284 // linienstil neu bestimmen 285 case SID_SETLINESTYLE : 286 if (pArgs) 287 if (pArgs->Count () == 1) 288 { 289 SFX_REQUEST_ARG (rReq, pLineStyle, SfxUInt32Item, ID_VAL_STYLE, sal_False); 290 if (CHECK_RANGE (XLINE_NONE, (sal_Int32)pLineStyle->GetValue (), XLINE_DASH)) 291 { 292 pAttr->ClearItem (XATTR_LINESTYLE); 293 pAttr->Put (XLineStyleItem ((XLineStyle) pLineStyle->GetValue ()), XATTR_LINESTYLE); 294 rBindings.Invalidate (SID_ATTR_LINE_STYLE); 295 } 296 else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE); 297 298 break; 299 } 300 301 StarBASIC::FatalError (SbERR_WRONG_ARGS); 302 break; 303 304 // linienbreite setzen 305 case SID_SETLINEWIDTH : 306 if (pArgs) 307 if (pArgs->Count () == 1) 308 { 309 SFX_REQUEST_ARG (rReq, pLineWidth, SfxUInt32Item, ID_VAL_WIDTH, sal_False); 310 pAttr->ClearItem (XATTR_LINEWIDTH); 311 pAttr->Put (XLineWidthItem (pLineWidth->GetValue ()), XATTR_LINEWIDTH); 312 rBindings.Invalidate (SID_ATTR_LINE_WIDTH); 313 break; 314 } 315 316 StarBASIC::FatalError (SbERR_WRONG_ARGS); 317 break; 318 319 case SID_SETFILLCOLOR : 320 if (pArgs) 321 if (pArgs->Count () == 3) 322 { 323 SFX_REQUEST_ARG (rReq, pRed, SfxUInt32Item, ID_VAL_RED, sal_False); 324 SFX_REQUEST_ARG (rReq, pGreen, SfxUInt32Item, ID_VAL_GREEN, sal_False); 325 SFX_REQUEST_ARG (rReq, pBlue, SfxUInt32Item, ID_VAL_BLUE, sal_False); 326 327 pAttr->ClearItem (XATTR_FILLCOLOR); 328 pAttr->ClearItem (XATTR_FILLSTYLE); 329 pAttr->Put (XFillColorItem (-1, Color ((sal_uInt8) pRed->GetValue (), 330 (sal_uInt8) pGreen->GetValue (), 331 (sal_uInt8) pBlue->GetValue ())), 332 XATTR_FILLCOLOR); 333 pAttr->Put (XFillStyleItem (XFILL_SOLID), XATTR_FILLSTYLE); 334 rBindings.Invalidate (SID_ATTR_FILL_COLOR); 335 rBindings.Invalidate (SID_ATTR_FILL_STYLE); 336 break; 337 } 338 339 StarBASIC::FatalError (SbERR_WRONG_ARGS); 340 break; 341 342 case SID_SETLINECOLOR : 343 if (pArgs) 344 if (pArgs->Count () == 3) 345 { 346 SFX_REQUEST_ARG (rReq, pRed, SfxUInt32Item, ID_VAL_RED, sal_False); 347 SFX_REQUEST_ARG (rReq, pGreen, SfxUInt32Item, ID_VAL_GREEN, sal_False); 348 SFX_REQUEST_ARG (rReq, pBlue, SfxUInt32Item, ID_VAL_BLUE, sal_False); 349 350 pAttr->ClearItem (XATTR_LINECOLOR); 351 pAttr->Put (XLineColorItem (-1, Color ((sal_uInt8) pRed->GetValue (), 352 (sal_uInt8) pGreen->GetValue (), 353 (sal_uInt8) pBlue->GetValue ())), 354 XATTR_LINECOLOR); 355 rBindings.Invalidate (SID_ATTR_LINE_COLOR); 356 break; 357 } 358 359 StarBASIC::FatalError (SbERR_WRONG_ARGS); 360 break; 361 362 case SID_SETGRADSTARTCOLOR : 363 case SID_SETGRADENDCOLOR : 364 if (pArgs) 365 if (pArgs->Count () == 4) 366 { 367 SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, sal_False); 368 SFX_REQUEST_ARG (rReq, pRed, SfxUInt32Item, ID_VAL_RED, sal_False); 369 SFX_REQUEST_ARG (rReq, pGreen, SfxUInt32Item, ID_VAL_GREEN, sal_False); 370 SFX_REQUEST_ARG (rReq, pBlue, SfxUInt32Item, ID_VAL_BLUE, sal_False); 371 372 XGradientListSharedPtr aGradientList = GetDoc()->GetGradientListFromSdrModel(); 373 long nCounts = aGradientList->Count (); 374 Color aColor ((sal_uInt8) pRed->GetValue (), 375 (sal_uInt8) pGreen->GetValue (), 376 (sal_uInt8) pBlue->GetValue ()); 377 long i; 378 379 pAttr->ClearItem (XATTR_FILLGRADIENT); 380 pAttr->ClearItem (XATTR_FILLSTYLE); 381 382 for ( i = 0; i < nCounts; i ++) 383 { 384 XGradientEntry *pEntry = aGradientList->GetGradient (i); 385 386 if (pEntry->GetName () == pName->GetValue ()) 387 { 388 XGradient aGradient(pEntry->GetGradient()); 389 390 if (rReq.GetSlot () == SID_SETGRADSTARTCOLOR) aGradient.SetStartColor (aColor); 391 else aGradient.SetEndColor (aColor); 392 393 pAttr->Put (XFillStyleItem (XFILL_GRADIENT), XATTR_FILLSTYLE); 394 pAttr->Put (XFillGradientItem (pName->GetValue (), aGradient), XATTR_FILLGRADIENT); 395 break; 396 } 397 } 398 399 if (i >= nCounts) 400 { 401 Color aBlack (0, 0, 0); 402 XGradient aGradient ((rReq.GetSlot () == SID_SETGRADSTARTCOLOR) 403 ? aColor 404 : aBlack, 405 (rReq.GetSlot () == SID_SETGRADENDCOLOR) 406 ? aColor 407 : aBlack); 408 409 GetDoc()->GetGradientListFromSdrModel()->Insert (new XGradientEntry (aGradient, pName->GetValue ())); 410 411 pAttr->Put (XFillStyleItem (XFILL_GRADIENT), XATTR_FILLSTYLE); 412 pAttr->Put (XFillGradientItem (pName->GetValue (), aGradient), XATTR_FILLGRADIENT); 413 } 414 415 rBindings.Invalidate (SID_ATTR_FILL_STYLE); 416 rBindings.Invalidate (SID_ATTR_FILL_GRADIENT); 417 break; 418 } 419 420 StarBASIC::FatalError (SbERR_WRONG_ARGS); 421 break; 422 423 case SID_SETHATCHCOLOR : 424 if (pArgs) 425 if (pArgs->Count () == 4) 426 { 427 SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, sal_False); 428 SFX_REQUEST_ARG (rReq, pRed, SfxUInt32Item, ID_VAL_RED, sal_False); 429 SFX_REQUEST_ARG (rReq, pGreen, SfxUInt32Item, ID_VAL_GREEN, sal_False); 430 SFX_REQUEST_ARG (rReq, pBlue, SfxUInt32Item, ID_VAL_BLUE, sal_False); 431 432 XHatchListSharedPtr aHatchList = GetDoc()->GetHatchListFromSdrModel(); 433 long nCounts = aHatchList.get() ? aHatchList->Count() : 0; 434 Color aColor ((sal_uInt8) pRed->GetValue (), 435 (sal_uInt8) pGreen->GetValue (), 436 (sal_uInt8) pBlue->GetValue ()); 437 long i; 438 439 pAttr->ClearItem (XATTR_FILLHATCH); 440 pAttr->ClearItem (XATTR_FILLSTYLE); 441 442 for ( i = 0; i < nCounts; i ++) 443 { 444 XHatchEntry *pEntry = aHatchList->GetHatch (i); 445 446 if (pEntry->GetName () == pName->GetValue ()) 447 { 448 XHatch aHatch(pEntry->GetHatch()); 449 450 aHatch.SetColor (aColor); 451 452 pAttr->Put (XFillStyleItem (XFILL_HATCH), XATTR_FILLSTYLE); 453 pAttr->Put (XFillHatchItem (pName->GetValue (), aHatch), XATTR_FILLHATCH); 454 break; 455 } 456 } 457 458 if (i >= nCounts) 459 { 460 XHatch aHatch (aColor); 461 462 GetDoc()->GetHatchListFromSdrModel()->Insert (new XHatchEntry (aHatch, pName->GetValue ())); 463 464 pAttr->Put (XFillStyleItem (XFILL_HATCH), XATTR_FILLSTYLE); 465 pAttr->Put (XFillHatchItem (pName->GetValue (), aHatch), XATTR_FILLHATCH); 466 } 467 468 rBindings.Invalidate (SID_ATTR_FILL_HATCH); 469 rBindings.Invalidate (SID_ATTR_FILL_STYLE); 470 break; 471 } 472 473 StarBASIC::FatalError (SbERR_WRONG_ARGS); 474 break; 475 476 // einstellungen fuer liniendash 477 case SID_DASH : 478 if (pArgs) 479 if (pArgs->Count () == 7) 480 { 481 SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, sal_False); 482 SFX_REQUEST_ARG (rReq, pStyle, SfxUInt32Item, ID_VAL_STYLE, sal_False); 483 SFX_REQUEST_ARG (rReq, pDots, SfxUInt32Item, ID_VAL_DOTS, sal_False); 484 SFX_REQUEST_ARG (rReq, pDotLen, SfxUInt32Item, ID_VAL_DOTLEN, sal_False); 485 SFX_REQUEST_ARG (rReq, pDashes, SfxUInt32Item, ID_VAL_DASHES, sal_False); 486 SFX_REQUEST_ARG (rReq, pDashLen, SfxUInt32Item, ID_VAL_DASHLEN, sal_False); 487 SFX_REQUEST_ARG (rReq, pDistance, SfxUInt32Item, ID_VAL_DISTANCE, sal_False); 488 489 if (CHECK_RANGE (XDASH_RECT, (sal_Int32)pStyle->GetValue (), XDASH_ROUNDRELATIVE)) 490 { 491 XDash aNewDash ((XDashStyle) pStyle->GetValue (), (short) pDots->GetValue (), pDotLen->GetValue (), 492 (short) pDashes->GetValue (), pDashLen->GetValue (), pDistance->GetValue ()); 493 494 pAttr->ClearItem (XATTR_LINEDASH); 495 pAttr->ClearItem (XATTR_LINESTYLE); 496 497 XDashListSharedPtr aDashList = GetDoc()->GetDashListFromSdrModel(); 498 long nCounts = aDashList.get() ? aDashList->Count() : 0; 499 XDashEntry *pEntry = new XDashEntry (aNewDash, pName->GetValue ()); 500 long i; 501 502 for ( i = 0; i < nCounts; i++ ) 503 if (aDashList->GetDash (i)->GetName () == pName->GetValue ()) 504 break; 505 506 if (i < nCounts) 507 aDashList->Replace (pEntry, i); 508 else 509 aDashList->Insert (pEntry); 510 511 pAttr->Put (XLineDashItem (pName->GetValue (), aNewDash), XATTR_LINEDASH); 512 pAttr->Put (XLineStyleItem (XLINE_DASH), XATTR_LINESTYLE); 513 rBindings.Invalidate (SID_ATTR_LINE_DASH); 514 rBindings.Invalidate (SID_ATTR_FILL_STYLE); 515 } 516 else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE); 517 518 break; 519 } 520 521 StarBASIC::FatalError (SbERR_WRONG_ARGS); 522 break; 523 524 // einstellungen fuer farbverlauf 525 case SID_GRADIENT : 526 if (pArgs) 527 if (pArgs->Count () == 8) 528 { 529 SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, sal_False); 530 SFX_REQUEST_ARG (rReq, pStyle, SfxUInt32Item, ID_VAL_STYLE, sal_False); 531 SFX_REQUEST_ARG (rReq, pAngle, SfxUInt32Item, ID_VAL_ANGLE, sal_False); 532 SFX_REQUEST_ARG (rReq, pBorder, SfxUInt32Item, ID_VAL_BORDER, sal_False); 533 SFX_REQUEST_ARG (rReq, pCenterX, SfxUInt32Item, ID_VAL_CENTER_X, sal_False); 534 SFX_REQUEST_ARG (rReq, pCenterY, SfxUInt32Item, ID_VAL_CENTER_Y, sal_False); 535 SFX_REQUEST_ARG (rReq, pStart, SfxUInt32Item, ID_VAL_STARTINTENS, sal_False); 536 SFX_REQUEST_ARG (rReq, pEnd, SfxUInt32Item, ID_VAL_ENDINTENS, sal_False); 537 538 if (CHECK_RANGE (XGRAD_LINEAR, (sal_Int32)pStyle->GetValue (), XGRAD_RECT) && 539 CHECK_RANGE (0, (sal_Int32)pAngle->GetValue (), 360) && 540 CHECK_RANGE (0, (sal_Int32)pBorder->GetValue (), 100) && 541 CHECK_RANGE (0, (sal_Int32)pCenterX->GetValue (), 100) && 542 CHECK_RANGE (0, (sal_Int32)pCenterY->GetValue (), 100) && 543 CHECK_RANGE (0, (sal_Int32)pStart->GetValue (), 100) && 544 CHECK_RANGE (0, (sal_Int32)pEnd->GetValue (), 100)) 545 { 546 pAttr->ClearItem (XATTR_FILLGRADIENT); 547 pAttr->ClearItem (XATTR_FILLSTYLE); 548 549 XGradientListSharedPtr aGradientList = GetDoc()->GetGradientListFromSdrModel(); 550 long nCounts = aGradientList->Count (); 551 long i; 552 553 for ( i = 0; i < nCounts; i++ ) 554 { 555 XGradientEntry *pEntry = aGradientList->GetGradient (i); 556 557 if (pEntry->GetName () == pName->GetValue ()) 558 { 559 XGradient aGradient(pEntry->GetGradient()); 560 561 aGradient.SetGradientStyle ((XGradientStyle) pStyle->GetValue ()); 562 aGradient.SetAngle (pAngle->GetValue () * 10); 563 aGradient.SetBorder ((short) pBorder->GetValue ()); 564 aGradient.SetXOffset ((short) pCenterX->GetValue ()); 565 aGradient.SetYOffset ((short) pCenterY->GetValue ()); 566 aGradient.SetStartIntens ((short) pStart->GetValue ()); 567 aGradient.SetEndIntens ((short) pEnd->GetValue ()); 568 569 pAttr->Put (XFillStyleItem (XFILL_GRADIENT), XATTR_FILLSTYLE); 570 pAttr->Put (XFillGradientItem (pName->GetValue (), aGradient), XATTR_FILLGRADIENT); 571 break; 572 } 573 } 574 575 if (i >= nCounts) 576 { 577 Color aBlack (0, 0, 0); 578 XGradient aGradient (aBlack, aBlack, (XGradientStyle) pStyle->GetValue (), 579 pAngle->GetValue () * 10, (short) pCenterX->GetValue (), 580 (short) pCenterY->GetValue (), (short) pBorder->GetValue (), 581 (short) pStart->GetValue (), (short) pEnd->GetValue ()); 582 583 aGradientList->Insert (new XGradientEntry (aGradient, pName->GetValue ())); 584 pAttr->Put (XFillStyleItem (XFILL_GRADIENT), XATTR_FILLSTYLE); 585 pAttr->Put (XFillGradientItem (pName->GetValue (), aGradient), XATTR_FILLGRADIENT); 586 } 587 588 rBindings.Invalidate (SID_ATTR_FILL_GRADIENT); 589 rBindings.Invalidate (SID_ATTR_FILL_STYLE); 590 } 591 else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE); 592 593 break; 594 } 595 596 StarBASIC::FatalError (SbERR_WRONG_ARGS); 597 break; 598 599 // einstellungen fuer schraffur 600 case SID_HATCH : 601 if (pArgs) 602 if (pArgs->Count () == 4) 603 { 604 SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, sal_False); 605 SFX_REQUEST_ARG (rReq, pStyle, SfxUInt32Item, ID_VAL_STYLE, sal_False); 606 SFX_REQUEST_ARG (rReq, pDistance, SfxUInt32Item, ID_VAL_DISTANCE, sal_False); 607 SFX_REQUEST_ARG (rReq, pAngle, SfxUInt32Item, ID_VAL_ANGLE, sal_False); 608 609 if (CHECK_RANGE (XHATCH_SINGLE, (sal_Int32)pStyle->GetValue (), XHATCH_TRIPLE) && 610 CHECK_RANGE (0, (sal_Int32)pAngle->GetValue (), 360)) 611 { 612 pAttr->ClearItem (XATTR_FILLHATCH); 613 pAttr->ClearItem (XATTR_FILLSTYLE); 614 615 XHatchListSharedPtr aHatchList = GetDoc()->GetHatchListFromSdrModel(); 616 long nCounts = aHatchList.get() ? aHatchList->Count() : 0; 617 long i; 618 619 for ( i = 0; i < nCounts; i++ ) 620 { 621 XHatchEntry *pEntry = aHatchList->GetHatch (i); 622 623 if (pEntry->GetName () == pName->GetValue ()) 624 { 625 XHatch aHatch(pEntry->GetHatch()); 626 627 aHatch.SetHatchStyle ((XHatchStyle) pStyle->GetValue ()); 628 aHatch.SetDistance (pDistance->GetValue ()); 629 aHatch.SetAngle (pAngle->GetValue () * 10); 630 631 pAttr->Put (XFillStyleItem (XFILL_HATCH), XATTR_FILLSTYLE); 632 pAttr->Put (XFillHatchItem (pName->GetValue (), aHatch), XATTR_FILLHATCH); 633 break; 634 } 635 } 636 637 if (i >= nCounts) 638 { 639 Color aBlack (0, 0, 0); 640 XHatch aHatch (aBlack, (XHatchStyle) pStyle->GetValue (), pDistance->GetValue (), 641 pAngle->GetValue () * 10); 642 643 aHatchList->Insert (new XHatchEntry (aHatch, pName->GetValue ())); 644 pAttr->Put (XFillStyleItem (XFILL_HATCH), XATTR_FILLSTYLE); 645 pAttr->Put (XFillHatchItem (pName->GetValue (), aHatch), XATTR_FILLHATCH); 646 } 647 648 rBindings.Invalidate (SID_ATTR_FILL_HATCH); 649 rBindings.Invalidate (SID_ATTR_FILL_STYLE); 650 } 651 else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE); 652 653 break; 654 } 655 656 StarBASIC::FatalError (SbERR_WRONG_ARGS); 657 break; 658 659 case SID_SELECTGRADIENT : 660 if (pArgs) 661 if (pArgs->Count () == 1) 662 { 663 SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, sal_False); 664 665 XGradientListSharedPtr aGradientList = GetDoc()->GetGradientListFromSdrModel(); 666 long nCounts = aGradientList->Count (); 667 668 for (long i = 0; 669 i < nCounts; 670 i ++) 671 { 672 XGradientEntry *pEntry = aGradientList->GetGradient (i); 673 674 if (pEntry->GetName () == pName->GetValue ()) 675 { 676 pAttr->ClearItem (XATTR_FILLGRADIENT); 677 pAttr->ClearItem (XATTR_FILLSTYLE); 678 pAttr->Put (XFillStyleItem (XFILL_GRADIENT), XATTR_FILLSTYLE); 679 pAttr->Put (XFillGradientItem (pName->GetValue (), pEntry->GetGradient ()), XATTR_FILLGRADIENT); 680 681 rBindings.Invalidate (SID_ATTR_FILL_GRADIENT); 682 rBindings.Invalidate (SID_ATTR_FILL_STYLE); 683 break; 684 } 685 } 686 687 break; 688 } 689 690 StarBASIC::FatalError (SbERR_WRONG_ARGS); 691 break; 692 693 case SID_SELECTHATCH : 694 if (pArgs) 695 if (pArgs->Count () == 1) 696 { 697 SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, sal_False); 698 699 XHatchListSharedPtr aHatchList = GetDoc()->GetHatchListFromSdrModel(); 700 long nCounts = aHatchList.get() ? aHatchList->Count() : 0; 701 702 for (long i = 0; 703 i < nCounts; 704 i ++) 705 { 706 XHatchEntry *pEntry = aHatchList->GetHatch (i); 707 708 if (pEntry->GetName () == pName->GetValue ()) 709 { 710 pAttr->ClearItem (XATTR_FILLHATCH); 711 pAttr->ClearItem (XATTR_FILLSTYLE); 712 pAttr->Put (XFillStyleItem (XFILL_HATCH), XATTR_FILLSTYLE); 713 pAttr->Put (XFillHatchItem (pName->GetValue (), pEntry->GetHatch ()), XATTR_FILLHATCH); 714 715 rBindings.Invalidate (SID_ATTR_FILL_HATCH); 716 rBindings.Invalidate (SID_ATTR_FILL_STYLE); 717 break; 718 } 719 } 720 721 break; 722 } 723 724 StarBASIC::FatalError (SbERR_WRONG_ARGS); 725 break; 726 727 case SID_UNSELECT : 728 mpDrawView->UnmarkAll (); 729 break; 730 731 case SID_GETRED : 732 if (pArgs) 733 if (pArgs->Count () == 1) 734 { 735 break; 736 } 737 738 StarBASIC::FatalError (SbERR_WRONG_ARGS); 739 break; 740 741 /* case SID_SETFONTFAMILYNAME : 742 case SID_SETFONTSTYLENAME : 743 case SID_SETFONTFAMILY : 744 case SID_SETFONTPITCH : 745 case SID_SETFONTCHARSET : 746 case SID_SETFONTPOSTURE : 747 case SID_SETFONTWEIGHT : 748 case SID_SETFONTUNDERLINE : 749 case SID_SETFONTCROSSEDOUT : 750 case SID_SETFONTSHADOWED : 751 case SID_SETFONTCONTOUR : 752 case SID_SETFONTCOLOR : 753 case SID_SETFONTLANGUAGE : 754 case SID_SETFONTWORDLINE : 755 case SID_SETFONTCASEMAP : 756 case SID_SETFONTESCAPE : 757 case SID_SETFONTKERNING : 758 break;*/ 759 760 default : 761 ; 762 } 763 764 mpDrawView->SetAttributes (*(const SfxItemSet *) pAttr); 765 rReq.Ignore (); 766 delete pAttr; 767 } 768 769 /************************************************************************* 770 |* 771 |* Makros fuer die Attributeinstellungen bearbeiten 772 |* 773 \************************************************************************/ 774 775 void DrawViewShell::AttrState (SfxItemSet& rSet) 776 { 777 SfxWhichIter aIter (rSet); 778 sal_uInt16 nWhich = aIter.FirstWhich (); 779 SfxItemSet aAttr( GetDoc()->GetPool() ); 780 mpDrawView->GetAttributes( aAttr ); 781 782 while (nWhich) 783 { 784 switch (nWhich) 785 { 786 case SID_GETFILLSTYLE : 787 { 788 const XFillStyleItem &rFillStyleItem = (const XFillStyleItem &) aAttr.Get (XATTR_FILLSTYLE); 789 790 rSet.Put (SfxUInt32Item (nWhich, (long) rFillStyleItem.GetValue ())); 791 break; 792 } 793 794 case SID_GETLINESTYLE : 795 { 796 const XLineStyleItem &rLineStyleItem = (const XLineStyleItem &) aAttr.Get (XATTR_LINESTYLE); 797 798 rSet.Put (SfxUInt32Item (nWhich, (long) rLineStyleItem.GetValue ())); 799 break; 800 } 801 802 case SID_GETLINEWIDTH : 803 { 804 const XLineWidthItem &rLineWidthItem = (const XLineWidthItem &) aAttr.Get (XATTR_LINEWIDTH); 805 806 rSet.Put (SfxUInt32Item (nWhich, (long) rLineWidthItem.GetValue ())); 807 break; 808 } 809 810 case SID_GETGREEN : 811 case SID_GETRED : 812 case SID_GETBLUE : 813 { 814 const SfxUInt32Item &rWhatKind = (const SfxUInt32Item &) rSet.Get (ID_VAL_WHATKIND); 815 Color aColor; 816 817 switch (rWhatKind.GetValue ()) 818 { 819 case 1 : 820 { 821 const XLineColorItem &rLineColorItem = (const XLineColorItem &) aAttr.Get (XATTR_LINECOLOR); 822 823 aColor = rLineColorItem.GetColorValue (); 824 break; 825 } 826 827 case 2 : 828 { 829 const XFillColorItem &rFillColorItem = (const XFillColorItem &) aAttr.Get (XATTR_FILLCOLOR); 830 831 aColor = rFillColorItem.GetColorValue (); 832 break; 833 } 834 835 case 3 : 836 case 4 : 837 { 838 const XFillGradientItem &rFillGradientItem = (const XFillGradientItem &) aAttr.Get (XATTR_FILLGRADIENT); 839 const XGradient &rGradient = rFillGradientItem.GetGradientValue (); 840 841 aColor = (rWhatKind.GetValue () == 3) 842 ? rGradient.GetStartColor () 843 : rGradient.GetEndColor (); 844 break; 845 } 846 847 case 5: 848 { 849 const XFillHatchItem &rFillHatchItem = (const XFillHatchItem &) aAttr.Get (XATTR_FILLHATCH); 850 const XHatch &rHatch = rFillHatchItem.GetHatchValue (); 851 852 aColor = rHatch.GetColor (); 853 break; 854 } 855 856 default : 857 ; 858 } 859 860 rSet.Put (SfxUInt32Item (nWhich, (long) ((nWhich == SID_GETRED) 861 ? aColor.GetRed () 862 : (nWhich == SID_GETGREEN) 863 ? aColor.GetGreen () 864 : aColor.GetBlue ()))); 865 break; 866 } 867 868 default : 869 ; 870 } 871 872 nWhich = aIter.NextWhich (); 873 } 874 } 875 876 } // end of namespace sd 877