merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / view / drviews9.cxx
blob57064c6a7c3b4d8da5db36a9fa757e06dad25d66
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drviews9.cxx,v $
10 * $Revision: 1.22 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "DrawViewShell.hxx"
35 #include <vcl/wrkwin.hxx>
36 #include <svx/xgrad.hxx>
37 #include <svx/svdpagv.hxx>
38 #include <svx/xlnwtit.hxx>
39 #include <svx/xlndsit.hxx>
40 #include <svx/xflhtit.hxx>
41 #include <svx/xflgrit.hxx>
42 #include <svx/xlnclit.hxx>
43 #include <svx/xflclit.hxx>
44 #include <svx/xlnwtit.hxx>
45 #include <sfx2/bindings.hxx>
47 #ifndef _SFX_DISPATCH_HXX //autogen
48 #include <sfx2/dispatch.hxx>
49 #endif
50 #include <svtools/intitem.hxx>
51 #include <sfx2/app.hxx>
52 #include <sfx2/request.hxx>
53 #include <svtools/stritem.hxx>
54 #ifndef _SVXIDS_HXX
55 #include <svx/svxids.hrc>
56 #endif
57 #include <svx/xtable.hxx>
58 #include <svx/gallery.hxx>
59 #include <vcl/graph.hxx>
60 #include <svx/svdograf.hxx>
61 #include <svx/svdoole2.hxx>
62 #include <sot/storage.hxx>
63 #include <svtools/whiter.hxx>
64 #include <basic/sbstar.hxx>
66 #include <sfx2/viewfrm.hxx>
69 #include "app.hrc"
70 #include "strings.hrc"
71 #include "Window.hxx"
72 #include "drawdoc.hxx"
73 #include "drawview.hxx"
74 #include "DrawDocShell.hxx"
75 #include "sdresid.hxx"
76 #include "fupoor.hxx"
78 namespace sd {
80 #ifndef SO2_DECL_SVINPLACEOBJECT_DEFINED
81 #define SO2_DECL_SVINPLACEOBJECT_DEFINED
82 SO2_DECL_REF(SvInPlaceObject)
83 #endif
84 #ifndef SO2_DECL_SVSTORAGE_DEFINED
85 #define SO2_DECL_SVSTORAGE_DEFINED
86 SO2_DECL_REF(SvStorage)
87 #endif
90 /*************************************************************************
92 |* SfxRequests fuer Gallery bearbeiten
94 \************************************************************************/
96 void DrawViewShell::ExecGallery(SfxRequest& rReq)
98 // waehrend einer Diashow wird nichts ausgefuehrt!
99 if(HasCurrentFunction(SID_PRESENTATION))
100 return;
102 const SfxItemSet* pArgs = rReq.GetArgs();
104 if ( pArgs )
106 const UINT32 nFormats = ( (SfxUInt32Item&) pArgs->Get( SID_GALLERY_FORMATS ) ).GetValue();
107 GalleryExplorer* pGal = SVX_GALLERY();
109 if ( pGal )
111 GetDocSh()->SetWaitCursor( TRUE );
113 // Graphik einfuegen
114 if (nFormats & SGA_FORMAT_GRAPHIC)
116 Graphic aGraphic = pGal->GetGraphic();
118 // Ggf. Groesse reduzieren
119 Window aWindow (GetActiveWindow());
120 aWindow.SetMapMode(aGraphic.GetPrefMapMode());
121 Size aSizePix = aWindow.LogicToPixel(aGraphic.GetPrefSize());
122 aWindow.SetMapMode( MapMode(MAP_100TH_MM) );
123 Size aSize = aWindow.PixelToLogic(aSizePix);
125 // Groesse ggf. auf Seitengroesse begrenzen
126 SdrPage* pPage = mpDrawView->GetSdrPageView()->GetPage();
127 Size aPageSize = pPage->GetSize();
128 aPageSize.Width() -= pPage->GetLftBorder() + pPage->GetRgtBorder();
129 aPageSize.Height() -= pPage->GetUppBorder() + pPage->GetLwrBorder();
132 // Falls Grafik zu gross, wird die Grafik
133 // in die Seite eingepasst
134 if ( ( ( aSize.Height() > aPageSize.Height() ) || ( aSize.Width() > aPageSize.Width() ) ) &&
135 aSize.Height() && aPageSize.Height() )
137 float fGrfWH = (float)aSize.Width() /
138 (float)aSize.Height();
139 float fWinWH = (float)aPageSize.Width() /
140 (float)aPageSize.Height();
142 // Grafik an Pagesize anpassen (skaliert)
143 if ((fGrfWH != 0.F) && (fGrfWH < fWinWH))
145 aSize.Width() = (long)(aPageSize.Height() * fGrfWH);
146 aSize.Height()= aPageSize.Height();
148 else
150 aSize.Width() = aPageSize.Width();
151 aSize.Height()= (long)(aPageSize.Width() / fGrfWH);
156 // Ausgaberechteck fuer Grafik setzen
157 Point aPnt ((aPageSize.Width() - aSize.Width()) / 2,
158 (aPageSize.Height() - aSize.Height()) / 2);
159 aPnt += Point(pPage->GetLftBorder(), pPage->GetUppBorder());
160 Rectangle aRect (aPnt, aSize);
162 SdrGrafObj* pGrafObj = NULL;
164 BOOL bInsertNewObject = TRUE;
166 if ( mpDrawView->AreObjectsMarked() )
168 /******************************************************
169 * Ist ein leeres Graphik-Objekt vorhanden?
170 ******************************************************/
171 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
173 if (rMarkList.GetMarkCount() == 1)
175 SdrMark* pMark = rMarkList.GetMark(0);
176 SdrObject* pObj = pMark->GetMarkedSdrObj();
178 if (pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_GRAF)
180 pGrafObj = (SdrGrafObj*) pObj;
182 if( pGrafObj->IsEmptyPresObj() )
184 /******************************************
185 * Das leere Graphik-Objekt bekommt eine neue
186 * Graphik
187 ******************************************/
188 bInsertNewObject = FALSE;
190 SdrGrafObj* pNewGrafObj = (SdrGrafObj*) pGrafObj->Clone();
191 pNewGrafObj->SetEmptyPresObj(FALSE);
192 pNewGrafObj->SetOutlinerParaObject(NULL);
193 pNewGrafObj->SetGraphic(aGraphic);
195 String aStr(mpDrawView->GetDescriptionOfMarkedObjects());
196 aStr += sal_Unicode(' ');
197 aStr += String(SdResId(STR_UNDO_REPLACE));
198 mpDrawView->BegUndo(aStr);
199 SdrPageView* pPV = mpDrawView->GetSdrPageView();
200 mpDrawView->ReplaceObjectAtView(pGrafObj, *pPV, pNewGrafObj);
201 mpDrawView->EndUndo();
208 if( bInsertNewObject )
210 pGrafObj = new SdrGrafObj(aGraphic, aRect);
211 SdrPageView* pPV = mpDrawView->GetSdrPageView();
212 mpDrawView->InsertObjectAtView(pGrafObj, *pPV, SDRINSERT_SETDEFLAYER);
215 // Soll nur ein Link benutzt werden?
216 if( pGrafObj && pGal->IsLinkage() )
217 pGrafObj->SetGraphicLink( pGal->GetURL().GetMainURL( INetURLObject::NO_DECODE ), pGal->GetFilterName() );
219 // insert sound
220 else if( nFormats & SGA_FORMAT_SOUND )
222 const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGal->GetURL().GetMainURL( INetURLObject::NO_DECODE ) );
223 GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, 0L );
226 GetDocSh()->SetWaitCursor( FALSE );
232 /*************************************************************************
234 |* Statuswerte fuer Gallery zurueckgeben
236 \************************************************************************/
238 void DrawViewShell::GetGalleryState(SfxItemSet& )
242 /*************************************************************************
244 |* Makros fuer die Attributeinstellungen bearbeiten
246 \************************************************************************/
249 // die vorgehensweise fuer die attributaenderung ist praktisch ueberall identisch
250 // 1. bisherige attribute auslesen
251 // 2. parameter aus dem basic-set auslesen
252 // 3. gewaehltes item aus dem attribut-set loeschen
253 // 4. neues attribut-item erzeugen
254 // 5. item in den set eintragen
256 void DrawViewShell::AttrExec (SfxRequest &rReq)
258 // waehrend einer Diashow wird nichts ausgefuehrt!
259 if(HasCurrentFunction(SID_PRESENTATION))
260 return;
262 CheckLineTo (rReq);
264 SfxBindings& rBindings = GetViewFrame()->GetBindings();
265 SfxItemSet* pAttr = new SfxItemSet ( GetDoc()->GetPool() );
267 GetView()->GetAttributes( *pAttr );
268 const SfxItemSet* pArgs = rReq.GetArgs();
270 switch (rReq.GetSlot ())
272 // neuen fuellstil setzen
273 case SID_SETFILLSTYLE :
274 if (pArgs)
275 if (pArgs->Count () == 1)
277 SFX_REQUEST_ARG (rReq, pFillStyle, SfxUInt32Item, ID_VAL_STYLE, FALSE);
278 if (CHECK_RANGE (XFILL_NONE, (sal_Int32)pFillStyle->GetValue (), XFILL_BITMAP))
280 pAttr->ClearItem (XATTR_FILLSTYLE);
281 pAttr->Put (XFillStyleItem ((XFillStyle) pFillStyle->GetValue ()), XATTR_FILLSTYLE);
282 rBindings.Invalidate (SID_ATTR_FILL_STYLE);
284 else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
286 break;
289 StarBASIC::FatalError (SbERR_WRONG_ARGS);
290 break;
292 // linienstil neu bestimmen
293 case SID_SETLINESTYLE :
294 if (pArgs)
295 if (pArgs->Count () == 1)
297 SFX_REQUEST_ARG (rReq, pLineStyle, SfxUInt32Item, ID_VAL_STYLE, FALSE);
298 if (CHECK_RANGE (XLINE_NONE, (sal_Int32)pLineStyle->GetValue (), XLINE_DASH))
300 pAttr->ClearItem (XATTR_LINESTYLE);
301 pAttr->Put (XLineStyleItem ((XLineStyle) pLineStyle->GetValue ()), XATTR_LINESTYLE);
302 rBindings.Invalidate (SID_ATTR_LINE_STYLE);
304 else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
306 break;
309 StarBASIC::FatalError (SbERR_WRONG_ARGS);
310 break;
312 // linienbreite setzen
313 case SID_SETLINEWIDTH :
314 if (pArgs)
315 if (pArgs->Count () == 1)
317 SFX_REQUEST_ARG (rReq, pLineWidth, SfxUInt32Item, ID_VAL_WIDTH, FALSE);
318 pAttr->ClearItem (XATTR_LINEWIDTH);
319 pAttr->Put (XLineWidthItem (pLineWidth->GetValue ()), XATTR_LINEWIDTH);
320 rBindings.Invalidate (SID_ATTR_LINE_WIDTH);
321 break;
324 StarBASIC::FatalError (SbERR_WRONG_ARGS);
325 break;
327 case SID_SETFILLCOLOR :
328 if (pArgs)
329 if (pArgs->Count () == 3)
331 SFX_REQUEST_ARG (rReq, pRed, SfxUInt32Item, ID_VAL_RED, FALSE);
332 SFX_REQUEST_ARG (rReq, pGreen, SfxUInt32Item, ID_VAL_GREEN, FALSE);
333 SFX_REQUEST_ARG (rReq, pBlue, SfxUInt32Item, ID_VAL_BLUE, FALSE);
335 pAttr->ClearItem (XATTR_FILLCOLOR);
336 pAttr->ClearItem (XATTR_FILLSTYLE);
337 pAttr->Put (XFillColorItem (-1, Color ((BYTE) pRed->GetValue (),
338 (BYTE) pGreen->GetValue (),
339 (BYTE) pBlue->GetValue ())),
340 XATTR_FILLCOLOR);
341 pAttr->Put (XFillStyleItem (XFILL_SOLID), XATTR_FILLSTYLE);
342 rBindings.Invalidate (SID_ATTR_FILL_COLOR);
343 rBindings.Invalidate (SID_ATTR_FILL_STYLE);
344 break;
347 StarBASIC::FatalError (SbERR_WRONG_ARGS);
348 break;
350 case SID_SETLINECOLOR :
351 if (pArgs)
352 if (pArgs->Count () == 3)
354 SFX_REQUEST_ARG (rReq, pRed, SfxUInt32Item, ID_VAL_RED, FALSE);
355 SFX_REQUEST_ARG (rReq, pGreen, SfxUInt32Item, ID_VAL_GREEN, FALSE);
356 SFX_REQUEST_ARG (rReq, pBlue, SfxUInt32Item, ID_VAL_BLUE, FALSE);
358 pAttr->ClearItem (XATTR_LINECOLOR);
359 pAttr->Put (XLineColorItem (-1, Color ((BYTE) pRed->GetValue (),
360 (BYTE) pGreen->GetValue (),
361 (BYTE) pBlue->GetValue ())),
362 XATTR_LINECOLOR);
363 rBindings.Invalidate (SID_ATTR_LINE_COLOR);
364 break;
367 StarBASIC::FatalError (SbERR_WRONG_ARGS);
368 break;
370 case SID_SETGRADSTARTCOLOR :
371 case SID_SETGRADENDCOLOR :
372 if (pArgs)
373 if (pArgs->Count () == 4)
375 SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, FALSE);
376 SFX_REQUEST_ARG (rReq, pRed, SfxUInt32Item, ID_VAL_RED, FALSE);
377 SFX_REQUEST_ARG (rReq, pGreen, SfxUInt32Item, ID_VAL_GREEN, FALSE);
378 SFX_REQUEST_ARG (rReq, pBlue, SfxUInt32Item, ID_VAL_BLUE, FALSE);
380 XGradientList *pGradientList = GetDoc()->GetGradientList ();
381 long nCounts = pGradientList->Count ();
382 Color aColor ((BYTE) pRed->GetValue (),
383 (BYTE) pGreen->GetValue (),
384 (BYTE) pBlue->GetValue ());
385 long i;
387 pAttr->ClearItem (XATTR_FILLGRADIENT);
388 pAttr->ClearItem (XATTR_FILLSTYLE);
390 for ( i = 0; i < nCounts; i ++)
392 XGradientEntry *pEntry = pGradientList->GetGradient (i);
394 if (pEntry->GetName () == pName->GetValue ())
396 XGradient &rGradient = pEntry->GetGradient ();
398 if (rReq.GetSlot () == SID_SETGRADSTARTCOLOR) rGradient.SetStartColor (aColor);
399 else rGradient.SetEndColor (aColor);
401 pAttr->Put (XFillStyleItem (XFILL_GRADIENT), XATTR_FILLSTYLE);
402 pAttr->Put (XFillGradientItem (pName->GetValue (), rGradient), XATTR_FILLGRADIENT);
403 break;
407 if (i >= nCounts)
409 Color aBlack (0, 0, 0);
410 XGradient aGradient ((rReq.GetSlot () == SID_SETGRADSTARTCOLOR)
411 ? aColor
412 : aBlack,
413 (rReq.GetSlot () == SID_SETGRADENDCOLOR)
414 ? aColor
415 : aBlack);
417 GetDoc()->GetGradientList ()->Insert (new XGradientEntry (aGradient, pName->GetValue ()));
419 pAttr->Put (XFillStyleItem (XFILL_GRADIENT), XATTR_FILLSTYLE);
420 pAttr->Put (XFillGradientItem (pName->GetValue (), aGradient), XATTR_FILLGRADIENT);
423 rBindings.Invalidate (SID_ATTR_FILL_STYLE);
424 rBindings.Invalidate (SID_ATTR_FILL_GRADIENT);
425 break;
428 StarBASIC::FatalError (SbERR_WRONG_ARGS);
429 break;
431 case SID_SETHATCHCOLOR :
432 if (pArgs)
433 if (pArgs->Count () == 4)
435 SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, FALSE);
436 SFX_REQUEST_ARG (rReq, pRed, SfxUInt32Item, ID_VAL_RED, FALSE);
437 SFX_REQUEST_ARG (rReq, pGreen, SfxUInt32Item, ID_VAL_GREEN, FALSE);
438 SFX_REQUEST_ARG (rReq, pBlue, SfxUInt32Item, ID_VAL_BLUE, FALSE);
440 XHatchList *pHatchList = GetDoc()->GetHatchList ();
441 long nCounts = pHatchList->Count ();
442 Color aColor ((BYTE) pRed->GetValue (),
443 (BYTE) pGreen->GetValue (),
444 (BYTE) pBlue->GetValue ());
445 long i;
447 pAttr->ClearItem (XATTR_FILLHATCH);
448 pAttr->ClearItem (XATTR_FILLSTYLE);
450 for ( i = 0; i < nCounts; i ++)
452 XHatchEntry *pEntry = pHatchList->GetHatch (i);
454 if (pEntry->GetName () == pName->GetValue ())
456 XHatch &rHatch = pEntry->GetHatch ();
458 rHatch.SetColor (aColor);
460 pAttr->Put (XFillStyleItem (XFILL_HATCH), XATTR_FILLSTYLE);
461 pAttr->Put (XFillHatchItem (pName->GetValue (), rHatch), XATTR_FILLHATCH);
462 break;
466 if (i >= nCounts)
468 XHatch aHatch (aColor);
470 GetDoc()->GetHatchList ()->Insert (new XHatchEntry (aHatch, pName->GetValue ()));
472 pAttr->Put (XFillStyleItem (XFILL_HATCH), XATTR_FILLSTYLE);
473 pAttr->Put (XFillHatchItem (pName->GetValue (), aHatch), XATTR_FILLHATCH);
476 rBindings.Invalidate (SID_ATTR_FILL_HATCH);
477 rBindings.Invalidate (SID_ATTR_FILL_STYLE);
478 break;
481 StarBASIC::FatalError (SbERR_WRONG_ARGS);
482 break;
484 // einstellungen fuer liniendash
485 case SID_DASH :
486 if (pArgs)
487 if (pArgs->Count () == 7)
489 SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, FALSE);
490 SFX_REQUEST_ARG (rReq, pStyle, SfxUInt32Item, ID_VAL_STYLE, FALSE);
491 SFX_REQUEST_ARG (rReq, pDots, SfxUInt32Item, ID_VAL_DOTS, FALSE);
492 SFX_REQUEST_ARG (rReq, pDotLen, SfxUInt32Item, ID_VAL_DOTLEN, FALSE);
493 SFX_REQUEST_ARG (rReq, pDashes, SfxUInt32Item, ID_VAL_DASHES, FALSE);
494 SFX_REQUEST_ARG (rReq, pDashLen, SfxUInt32Item, ID_VAL_DASHLEN, FALSE);
495 SFX_REQUEST_ARG (rReq, pDistance, SfxUInt32Item, ID_VAL_DISTANCE, FALSE);
497 if (CHECK_RANGE (XDASH_RECT, (sal_Int32)pStyle->GetValue (), XDASH_ROUNDRELATIVE))
499 XDash aNewDash ((XDashStyle) pStyle->GetValue (), (short) pDots->GetValue (), pDotLen->GetValue (),
500 (short) pDashes->GetValue (), pDashLen->GetValue (), pDistance->GetValue ());
502 pAttr->ClearItem (XATTR_LINEDASH);
503 pAttr->ClearItem (XATTR_LINESTYLE);
505 XDashList *pDashList = GetDoc()->GetDashList ();
506 long nCounts = pDashList->Count ();
507 XDashEntry *pEntry = new XDashEntry (aNewDash, pName->GetValue ());
508 long i;
510 for ( i = 0; i < nCounts; i++ )
511 if (pDashList->GetDash (i)->GetName () == pName->GetValue ())
512 break;
514 if (i < nCounts)
515 pDashList->Replace (pEntry, i);
516 else
517 pDashList->Insert (pEntry);
519 pAttr->Put (XLineDashItem (pName->GetValue (), aNewDash), XATTR_LINEDASH);
520 pAttr->Put (XLineStyleItem (XLINE_DASH), XATTR_LINESTYLE);
521 rBindings.Invalidate (SID_ATTR_LINE_DASH);
522 rBindings.Invalidate (SID_ATTR_FILL_STYLE);
524 else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
526 break;
529 StarBASIC::FatalError (SbERR_WRONG_ARGS);
530 break;
532 // einstellungen fuer farbverlauf
533 case SID_GRADIENT :
534 if (pArgs)
535 if (pArgs->Count () == 8)
537 SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, FALSE);
538 SFX_REQUEST_ARG (rReq, pStyle, SfxUInt32Item, ID_VAL_STYLE, FALSE);
539 SFX_REQUEST_ARG (rReq, pAngle, SfxUInt32Item, ID_VAL_ANGLE, FALSE);
540 SFX_REQUEST_ARG (rReq, pBorder, SfxUInt32Item, ID_VAL_BORDER, FALSE);
541 SFX_REQUEST_ARG (rReq, pCenterX, SfxUInt32Item, ID_VAL_CENTER_X, FALSE);
542 SFX_REQUEST_ARG (rReq, pCenterY, SfxUInt32Item, ID_VAL_CENTER_Y, FALSE);
543 SFX_REQUEST_ARG (rReq, pStart, SfxUInt32Item, ID_VAL_STARTINTENS, FALSE);
544 SFX_REQUEST_ARG (rReq, pEnd, SfxUInt32Item, ID_VAL_ENDINTENS, FALSE);
546 if (CHECK_RANGE (XGRAD_LINEAR, (sal_Int32)pStyle->GetValue (), XGRAD_RECT) &&
547 CHECK_RANGE (0, (sal_Int32)pAngle->GetValue (), 360) &&
548 CHECK_RANGE (0, (sal_Int32)pBorder->GetValue (), 100) &&
549 CHECK_RANGE (0, (sal_Int32)pCenterX->GetValue (), 100) &&
550 CHECK_RANGE (0, (sal_Int32)pCenterY->GetValue (), 100) &&
551 CHECK_RANGE (0, (sal_Int32)pStart->GetValue (), 100) &&
552 CHECK_RANGE (0, (sal_Int32)pEnd->GetValue (), 100))
554 pAttr->ClearItem (XATTR_FILLGRADIENT);
555 pAttr->ClearItem (XATTR_FILLSTYLE);
557 XGradientList *pGradientList = GetDoc()->GetGradientList ();
558 long nCounts = pGradientList->Count ();
559 long i;
561 for ( i = 0; i < nCounts; i++ )
563 XGradientEntry *pEntry = pGradientList->GetGradient (i);
565 if (pEntry->GetName () == pName->GetValue ())
567 XGradient &rGradient = pEntry->GetGradient ();
569 rGradient.SetGradientStyle ((XGradientStyle) pStyle->GetValue ());
570 rGradient.SetAngle (pAngle->GetValue () * 10);
571 rGradient.SetBorder ((short) pBorder->GetValue ());
572 rGradient.SetXOffset ((short) pCenterX->GetValue ());
573 rGradient.SetYOffset ((short) pCenterY->GetValue ());
574 rGradient.SetStartIntens ((short) pStart->GetValue ());
575 rGradient.SetEndIntens ((short) pEnd->GetValue ());
577 pAttr->Put (XFillStyleItem (XFILL_GRADIENT), XATTR_FILLSTYLE);
578 pAttr->Put (XFillGradientItem (pName->GetValue (), rGradient), XATTR_FILLGRADIENT);
579 break;
583 if (i >= nCounts)
585 Color aBlack (0, 0, 0);
586 XGradient aGradient (aBlack, aBlack, (XGradientStyle) pStyle->GetValue (),
587 pAngle->GetValue () * 10, (short) pCenterX->GetValue (),
588 (short) pCenterY->GetValue (), (short) pBorder->GetValue (),
589 (short) pStart->GetValue (), (short) pEnd->GetValue ());
591 pGradientList->Insert (new XGradientEntry (aGradient, pName->GetValue ()));
592 pAttr->Put (XFillStyleItem (XFILL_GRADIENT), XATTR_FILLSTYLE);
593 pAttr->Put (XFillGradientItem (pName->GetValue (), aGradient), XATTR_FILLGRADIENT);
596 rBindings.Invalidate (SID_ATTR_FILL_GRADIENT);
597 rBindings.Invalidate (SID_ATTR_FILL_STYLE);
599 else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
601 break;
604 StarBASIC::FatalError (SbERR_WRONG_ARGS);
605 break;
607 // einstellungen fuer schraffur
608 case SID_HATCH :
609 if (pArgs)
610 if (pArgs->Count () == 4)
612 SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, FALSE);
613 SFX_REQUEST_ARG (rReq, pStyle, SfxUInt32Item, ID_VAL_STYLE, FALSE);
614 SFX_REQUEST_ARG (rReq, pDistance, SfxUInt32Item, ID_VAL_DISTANCE, FALSE);
615 SFX_REQUEST_ARG (rReq, pAngle, SfxUInt32Item, ID_VAL_ANGLE, FALSE);
617 if (CHECK_RANGE (XHATCH_SINGLE, (sal_Int32)pStyle->GetValue (), XHATCH_TRIPLE) &&
618 CHECK_RANGE (0, (sal_Int32)pAngle->GetValue (), 360))
620 pAttr->ClearItem (XATTR_FILLHATCH);
621 pAttr->ClearItem (XATTR_FILLSTYLE);
623 XHatchList *pHatchList = GetDoc()->GetHatchList ();
624 long nCounts = pHatchList->Count ();
625 long i;
627 for ( i = 0; i < nCounts; i++ )
629 XHatchEntry *pEntry = pHatchList->GetHatch (i);
631 if (pEntry->GetName () == pName->GetValue ())
633 XHatch &rHatch = pEntry->GetHatch ();
635 rHatch.SetHatchStyle ((XHatchStyle) pStyle->GetValue ());
636 rHatch.SetDistance (pDistance->GetValue ());
637 rHatch.SetAngle (pAngle->GetValue () * 10);
639 pAttr->Put (XFillStyleItem (XFILL_HATCH), XATTR_FILLSTYLE);
640 pAttr->Put (XFillHatchItem (pName->GetValue (), rHatch), XATTR_FILLHATCH);
641 break;
645 if (i >= nCounts)
647 Color aBlack (0, 0, 0);
648 XHatch aHatch (aBlack, (XHatchStyle) pStyle->GetValue (), pDistance->GetValue (),
649 pAngle->GetValue () * 10);
651 pHatchList->Insert (new XHatchEntry (aHatch, pName->GetValue ()));
652 pAttr->Put (XFillStyleItem (XFILL_HATCH), XATTR_FILLSTYLE);
653 pAttr->Put (XFillHatchItem (pName->GetValue (), aHatch), XATTR_FILLHATCH);
656 rBindings.Invalidate (SID_ATTR_FILL_HATCH);
657 rBindings.Invalidate (SID_ATTR_FILL_STYLE);
659 else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
661 break;
664 StarBASIC::FatalError (SbERR_WRONG_ARGS);
665 break;
667 case SID_SELECTGRADIENT :
668 if (pArgs)
669 if (pArgs->Count () == 1)
671 SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, FALSE);
673 XGradientList *pGradientList = GetDoc()->GetGradientList ();
674 long nCounts = pGradientList->Count ();
676 for (long i = 0;
677 i < nCounts;
678 i ++)
680 XGradientEntry *pEntry = pGradientList->GetGradient (i);
682 if (pEntry->GetName () == pName->GetValue ())
684 pAttr->ClearItem (XATTR_FILLGRADIENT);
685 pAttr->ClearItem (XATTR_FILLSTYLE);
686 pAttr->Put (XFillStyleItem (XFILL_GRADIENT), XATTR_FILLSTYLE);
687 pAttr->Put (XFillGradientItem (pName->GetValue (), pEntry->GetGradient ()), XATTR_FILLGRADIENT);
689 rBindings.Invalidate (SID_ATTR_FILL_GRADIENT);
690 rBindings.Invalidate (SID_ATTR_FILL_STYLE);
691 break;
695 break;
698 StarBASIC::FatalError (SbERR_WRONG_ARGS);
699 break;
701 case SID_SELECTHATCH :
702 if (pArgs)
703 if (pArgs->Count () == 1)
705 SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, FALSE);
707 XHatchList *pHatchList = GetDoc()->GetHatchList ();
708 long nCounts = pHatchList->Count ();
710 for (long i = 0;
711 i < nCounts;
712 i ++)
714 XHatchEntry *pEntry = pHatchList->GetHatch (i);
716 if (pEntry->GetName () == pName->GetValue ())
718 pAttr->ClearItem (XATTR_FILLHATCH);
719 pAttr->ClearItem (XATTR_FILLSTYLE);
720 pAttr->Put (XFillStyleItem (XFILL_HATCH), XATTR_FILLSTYLE);
721 pAttr->Put (XFillHatchItem (pName->GetValue (), pEntry->GetHatch ()), XATTR_FILLHATCH);
723 rBindings.Invalidate (SID_ATTR_FILL_HATCH);
724 rBindings.Invalidate (SID_ATTR_FILL_STYLE);
725 break;
729 break;
732 StarBASIC::FatalError (SbERR_WRONG_ARGS);
733 break;
735 case SID_UNSELECT :
736 mpDrawView->UnmarkAll ();
737 break;
739 case SID_GETRED :
740 if (pArgs)
741 if (pArgs->Count () == 1)
743 break;
746 StarBASIC::FatalError (SbERR_WRONG_ARGS);
747 break;
749 /* case SID_SETFONTFAMILYNAME :
750 case SID_SETFONTSTYLENAME :
751 case SID_SETFONTFAMILY :
752 case SID_SETFONTPITCH :
753 case SID_SETFONTCHARSET :
754 case SID_SETFONTPOSTURE :
755 case SID_SETFONTWEIGHT :
756 case SID_SETFONTUNDERLINE :
757 case SID_SETFONTCROSSEDOUT :
758 case SID_SETFONTSHADOWED :
759 case SID_SETFONTCONTOUR :
760 case SID_SETFONTCOLOR :
761 case SID_SETFONTLANGUAGE :
762 case SID_SETFONTWORDLINE :
763 case SID_SETFONTCASEMAP :
764 case SID_SETFONTESCAPE :
765 case SID_SETFONTKERNING :
766 break;*/
768 default :
772 mpDrawView->SetAttributes (*(const SfxItemSet *) pAttr);
773 rReq.Ignore ();
774 delete pAttr;
777 /*************************************************************************
779 |* Makros fuer die Attributeinstellungen bearbeiten
781 \************************************************************************/
783 void DrawViewShell::AttrState (SfxItemSet& rSet)
785 SfxWhichIter aIter (rSet);
786 USHORT nWhich = aIter.FirstWhich ();
787 SfxItemSet aAttr( GetDoc()->GetPool() );
788 mpDrawView->GetAttributes( aAttr );
790 while (nWhich)
792 switch (nWhich)
794 case SID_GETFILLSTYLE :
796 const XFillStyleItem &rFillStyleItem = (const XFillStyleItem &) aAttr.Get (XATTR_FILLSTYLE);
798 rSet.Put (SfxUInt32Item (nWhich, (long) rFillStyleItem.GetValue ()));
799 break;
802 case SID_GETLINESTYLE :
804 const XLineStyleItem &rLineStyleItem = (const XLineStyleItem &) aAttr.Get (XATTR_LINESTYLE);
806 rSet.Put (SfxUInt32Item (nWhich, (long) rLineStyleItem.GetValue ()));
807 break;
810 case SID_GETLINEWIDTH :
812 const XLineWidthItem &rLineWidthItem = (const XLineWidthItem &) aAttr.Get (XATTR_LINEWIDTH);
814 rSet.Put (SfxUInt32Item (nWhich, (long) rLineWidthItem.GetValue ()));
815 break;
818 case SID_GETGREEN :
819 case SID_GETRED :
820 case SID_GETBLUE :
822 const SfxUInt32Item &rWhatKind = (const SfxUInt32Item &) rSet.Get (ID_VAL_WHATKIND);
823 Color aColor;
825 switch (rWhatKind.GetValue ())
827 case 1 :
829 const XLineColorItem &rLineColorItem = (const XLineColorItem &) aAttr.Get (XATTR_LINECOLOR);
831 aColor = rLineColorItem.GetColorValue ();
832 break;
835 case 2 :
837 const XFillColorItem &rFillColorItem = (const XFillColorItem &) aAttr.Get (XATTR_FILLCOLOR);
839 aColor = rFillColorItem.GetColorValue ();
840 break;
843 case 3 :
844 case 4 :
846 const XFillGradientItem &rFillGradientItem = (const XFillGradientItem &) aAttr.Get (XATTR_FILLGRADIENT);
847 const XGradient &rGradient = rFillGradientItem.GetGradientValue ();
849 aColor = (rWhatKind.GetValue () == 3)
850 ? rGradient.GetStartColor ()
851 : rGradient.GetEndColor ();
852 break;
855 case 5:
857 const XFillHatchItem &rFillHatchItem = (const XFillHatchItem &) aAttr.Get (XATTR_FILLHATCH);
858 const XHatch &rHatch = rFillHatchItem.GetHatchValue ();
860 aColor = rHatch.GetColor ();
861 break;
864 default :
868 rSet.Put (SfxUInt32Item (nWhich, (long) ((nWhich == SID_GETRED)
869 ? aColor.GetRed ()
870 : (nWhich == SID_GETGREEN)
871 ? aColor.GetGreen ()
872 : aColor.GetBlue ())));
873 break;
876 default :
880 nWhich = aIter.NextWhich ();
884 } // end of namespace sd