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