1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drviews9.cxx,v $
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>
50 #include <svtools/intitem.hxx>
51 #include <sfx2/app.hxx>
52 #include <sfx2/request.hxx>
53 #include <svtools/stritem.hxx>
55 #include <svx/svxids.hrc>
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>
70 #include "strings.hrc"
72 #include "drawdoc.hxx"
73 #include "drawview.hxx"
74 #include "DrawDocShell.hxx"
75 #include "sdresid.hxx"
80 #ifndef SO2_DECL_SVINPLACEOBJECT_DEFINED
81 #define SO2_DECL_SVINPLACEOBJECT_DEFINED
82 SO2_DECL_REF(SvInPlaceObject
)
84 #ifndef SO2_DECL_SVSTORAGE_DEFINED
85 #define SO2_DECL_SVSTORAGE_DEFINED
86 SO2_DECL_REF(SvStorage
)
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
))
102 const SfxItemSet
* pArgs
= rReq
.GetArgs();
106 const UINT32 nFormats
= ( (SfxUInt32Item
&) pArgs
->Get( SID_GALLERY_FORMATS
) ).GetValue();
107 GalleryExplorer
* pGal
= SVX_GALLERY();
111 GetDocSh()->SetWaitCursor( TRUE
);
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();
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
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() );
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
))
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
:
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
);
289 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
292 // linienstil neu bestimmen
293 case SID_SETLINESTYLE
:
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
);
309 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
312 // linienbreite setzen
313 case SID_SETLINEWIDTH
:
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
);
324 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
327 case SID_SETFILLCOLOR
:
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 ())),
341 pAttr
->Put (XFillStyleItem (XFILL_SOLID
), XATTR_FILLSTYLE
);
342 rBindings
.Invalidate (SID_ATTR_FILL_COLOR
);
343 rBindings
.Invalidate (SID_ATTR_FILL_STYLE
);
347 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
350 case SID_SETLINECOLOR
:
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 ())),
363 rBindings
.Invalidate (SID_ATTR_LINE_COLOR
);
367 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
370 case SID_SETGRADSTARTCOLOR
:
371 case SID_SETGRADENDCOLOR
:
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 ());
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
);
409 Color
aBlack (0, 0, 0);
410 XGradient
aGradient ((rReq
.GetSlot () == SID_SETGRADSTARTCOLOR
)
413 (rReq
.GetSlot () == SID_SETGRADENDCOLOR
)
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
);
428 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
431 case SID_SETHATCHCOLOR
:
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 ());
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
);
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
);
481 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
484 // einstellungen fuer liniendash
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 ());
510 for ( i
= 0; i
< nCounts
; i
++ )
511 if (pDashList
->GetDash (i
)->GetName () == pName
->GetValue ())
515 pDashList
->Replace (pEntry
, i
);
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
);
529 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
532 // einstellungen fuer farbverlauf
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 ();
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
);
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
);
604 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
607 // einstellungen fuer schraffur
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 ();
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
);
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
);
664 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
667 case SID_SELECTGRADIENT
:
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 ();
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
);
698 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
701 case SID_SELECTHATCH
:
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 ();
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
);
732 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
736 mpDrawView
->UnmarkAll ();
741 if (pArgs
->Count () == 1)
746 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
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 :
772 mpDrawView
->SetAttributes (*(const SfxItemSet
*) 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
);
794 case SID_GETFILLSTYLE
:
796 const XFillStyleItem
&rFillStyleItem
= (const XFillStyleItem
&) aAttr
.Get (XATTR_FILLSTYLE
);
798 rSet
.Put (SfxUInt32Item (nWhich
, (long) rFillStyleItem
.GetValue ()));
802 case SID_GETLINESTYLE
:
804 const XLineStyleItem
&rLineStyleItem
= (const XLineStyleItem
&) aAttr
.Get (XATTR_LINESTYLE
);
806 rSet
.Put (SfxUInt32Item (nWhich
, (long) rLineStyleItem
.GetValue ()));
810 case SID_GETLINEWIDTH
:
812 const XLineWidthItem
&rLineWidthItem
= (const XLineWidthItem
&) aAttr
.Get (XATTR_LINEWIDTH
);
814 rSet
.Put (SfxUInt32Item (nWhich
, (long) rLineWidthItem
.GetValue ()));
822 const SfxUInt32Item
&rWhatKind
= (const SfxUInt32Item
&) rSet
.Get (ID_VAL_WHATKIND
);
825 switch (rWhatKind
.GetValue ())
829 const XLineColorItem
&rLineColorItem
= (const XLineColorItem
&) aAttr
.Get (XATTR_LINECOLOR
);
831 aColor
= rLineColorItem
.GetColorValue ();
837 const XFillColorItem
&rFillColorItem
= (const XFillColorItem
&) aAttr
.Get (XATTR_FILLCOLOR
);
839 aColor
= rFillColorItem
.GetColorValue ();
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 ();
857 const XFillHatchItem
&rFillHatchItem
= (const XFillHatchItem
&) aAttr
.Get (XATTR_FILLHATCH
);
858 const XHatch
&rHatch
= rFillHatchItem
.GetHatchValue ();
860 aColor
= rHatch
.GetColor ();
868 rSet
.Put (SfxUInt32Item (nWhich
, (long) ((nWhich
== SID_GETRED
)
870 : (nWhich
== SID_GETGREEN
)
872 : aColor
.GetBlue ())));
880 nWhich
= aIter
.NextWhich ();
884 } // end of namespace sd