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