fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / ui / view / drviews9.cxx
blobb69db95ada57512600e4d1fe14efa6b5aade99a2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "DrawViewShell.hxx"
22 #include <vcl/wrkwin.hxx>
23 #include <svx/xgrad.hxx>
24 #include <svx/svdpagv.hxx>
25 #include <svx/xlnwtit.hxx>
26 #include <svx/xlndsit.hxx>
27 #include <svx/xflhtit.hxx>
28 #include <svx/xflgrit.hxx>
29 #include <svx/xlnclit.hxx>
30 #include <svx/xflclit.hxx>
31 #include <sfx2/bindings.hxx>
33 #include <sfx2/dispatch.hxx>
34 #include <svl/intitem.hxx>
35 #include <sfx2/app.hxx>
36 #include <sfx2/request.hxx>
37 #include <svl/stritem.hxx>
38 #include <svx/svxids.hrc>
39 #include <svx/xtable.hxx>
40 #include <svx/gallery.hxx>
41 #include <vcl/graph.hxx>
42 #include <svx/svdograf.hxx>
43 #include <svx/svdoole2.hxx>
44 #include <sot/storage.hxx>
45 #include <svl/whiter.hxx>
46 #include <basic/sbstar.hxx>
48 #include <sfx2/viewfrm.hxx>
51 #include "app.hrc"
52 #include "strings.hrc"
53 #include "Window.hxx"
54 #include "drawdoc.hxx"
55 #include "drawview.hxx"
56 #include "DrawDocShell.hxx"
57 #include "sdresid.hxx"
58 #include "fupoor.hxx"
60 namespace sd {
63 void DrawViewShell::ExecGallery(SfxRequest& rReq)
65 // nothing is executed during a slide show!
66 if(HasCurrentFunction(SID_PRESENTATION))
67 return;
69 const SfxItemSet* pArgs = rReq.GetArgs();
71 if ( pArgs )
73 const sal_uInt32 nFormats = ( (SfxUInt32Item&) pArgs->Get( SID_GALLERY_FORMATS ) ).GetValue();
74 GalleryExplorer* pGal = SVX_GALLERY();
76 if ( pGal )
78 GetDocSh()->SetWaitCursor( sal_True );
80 // insert graphic
81 if (nFormats & SGA_FORMAT_GRAPHIC)
83 Graphic aGraphic = pGal->GetGraphic();
85 // reduce size if necessary
86 Window aWindow (GetActiveWindow());
87 aWindow.SetMapMode(aGraphic.GetPrefMapMode());
88 Size aSizePix = aWindow.LogicToPixel(aGraphic.GetPrefSize());
89 aWindow.SetMapMode( MapMode(MAP_100TH_MM) );
90 Size aSize = aWindow.PixelToLogic(aSizePix);
92 // constrain size to page size if necessary
93 SdrPage* pPage = mpDrawView->GetSdrPageView()->GetPage();
94 Size aPageSize = pPage->GetSize();
95 aPageSize.Width() -= pPage->GetLftBorder() + pPage->GetRgtBorder();
96 aPageSize.Height() -= pPage->GetUppBorder() + pPage->GetLwrBorder();
99 // if the graphic is to big, we fit it into the page
100 if ( ( ( aSize.Height() > aPageSize.Height() ) || ( aSize.Width() > aPageSize.Width() ) ) &&
101 aSize.Height() && aPageSize.Height() )
103 float fGrfWH = (float)aSize.Width() /
104 (float)aSize.Height();
105 float fWinWH = (float)aPageSize.Width() /
106 (float)aPageSize.Height();
108 // adjust graphic to page size (scales)
109 if ((fGrfWH != 0.F) && (fGrfWH < fWinWH))
111 aSize.Width() = (long)(aPageSize.Height() * fGrfWH);
112 aSize.Height()= aPageSize.Height();
114 else
116 aSize.Width() = aPageSize.Width();
117 aSize.Height()= (long)(aPageSize.Width() / fGrfWH);
122 // set output rectangle for graphic
123 Point aPnt ((aPageSize.Width() - aSize.Width()) / 2,
124 (aPageSize.Height() - aSize.Height()) / 2);
125 aPnt += Point(pPage->GetLftBorder(), pPage->GetUppBorder());
126 Rectangle aRect (aPnt, aSize);
128 SdrGrafObj* pGrafObj = NULL;
130 sal_Bool bInsertNewObject = sal_True;
132 if ( mpDrawView->AreObjectsMarked() )
134 // is there a empty graphic object?
135 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
137 if (rMarkList.GetMarkCount() == 1)
139 SdrMark* pMark = rMarkList.GetMark(0);
140 SdrObject* pObj = pMark->GetMarkedSdrObj();
142 if (pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_GRAF)
144 pGrafObj = (SdrGrafObj*) pObj;
146 if( pGrafObj->IsEmptyPresObj() )
148 // the empty graphic object gets a new graphic
149 bInsertNewObject = sal_False;
151 SdrGrafObj* pNewGrafObj = (SdrGrafObj*) pGrafObj->Clone();
152 pNewGrafObj->SetEmptyPresObj(sal_False);
153 pNewGrafObj->SetOutlinerParaObject(NULL);
154 pNewGrafObj->SetGraphic(aGraphic);
156 String aStr(mpDrawView->GetDescriptionOfMarkedObjects());
157 aStr += sal_Unicode(' ');
158 aStr += String(SdResId(STR_UNDO_REPLACE));
159 mpDrawView->BegUndo(aStr);
160 SdrPageView* pPV = mpDrawView->GetSdrPageView();
161 mpDrawView->ReplaceObjectAtView(pGrafObj, *pPV, pNewGrafObj);
162 mpDrawView->EndUndo();
169 if( bInsertNewObject )
171 pGrafObj = new SdrGrafObj(aGraphic, aRect);
172 SdrPageView* pPV = mpDrawView->GetSdrPageView();
173 mpDrawView->InsertObjectAtView(pGrafObj, *pPV, SDRINSERT_SETDEFLAYER);
176 // should we just use a link?
177 if( pGrafObj && pGal->IsLinkage() )
178 pGrafObj->SetGraphicLink( pGal->GetURL().GetMainURL( INetURLObject::NO_DECODE ), pGal->GetFilterName() );
180 // insert sound
181 else if( nFormats & SGA_FORMAT_SOUND )
183 const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGal->GetURL().GetMainURL( INetURLObject::NO_DECODE ) );
184 GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, 0L );
187 GetDocSh()->SetWaitCursor( sal_False );
194 void DrawViewShell::GetGalleryState(SfxItemSet& )
199 * Edit macros for attribute configuration
202 /* the work flow to adjust the attributes is nearly everywhere the same
203 1. read existing attributes
204 2. read parameter from the basic-set
205 3. delete selected item from the attribute-set
206 4. create new attribute-item
207 5. insert item into set */
208 void DrawViewShell::AttrExec (SfxRequest &rReq)
210 // nothing is executed during a slide show!
211 if(HasCurrentFunction(SID_PRESENTATION))
212 return;
214 CheckLineTo (rReq);
216 SfxBindings& rBindings = GetViewFrame()->GetBindings();
217 SfxItemSet* pAttr = new SfxItemSet ( GetDoc()->GetPool() );
219 GetView()->GetAttributes( *pAttr );
220 const SfxItemSet* pArgs = rReq.GetArgs();
222 switch (rReq.GetSlot ())
224 // set new fill-style
225 case SID_SETFILLSTYLE :
226 if (pArgs)
227 if (pArgs->Count () == 1)
229 SFX_REQUEST_ARG (rReq, pFillStyle, SfxUInt32Item, ID_VAL_STYLE, sal_False);
230 if (CHECK_RANGE (XFILL_NONE, (sal_Int32)pFillStyle->GetValue (), XFILL_BITMAP))
232 pAttr->ClearItem (XATTR_FILLSTYLE);
233 pAttr->Put (XFillStyleItem ((XFillStyle) pFillStyle->GetValue ()), XATTR_FILLSTYLE);
234 rBindings.Invalidate (SID_ATTR_FILL_STYLE);
236 #ifndef DISABLE_SCRIPTING
237 else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
238 #endif
239 break;
241 #ifndef DISABLE_SCRIPTING
242 StarBASIC::FatalError (SbERR_WRONG_ARGS);
243 #endif
244 break;
246 // determine new line style
247 case SID_SETLINESTYLE :
248 if (pArgs)
249 if (pArgs->Count () == 1)
251 SFX_REQUEST_ARG (rReq, pLineStyle, SfxUInt32Item, ID_VAL_STYLE, sal_False);
252 if (CHECK_RANGE (XLINE_NONE, (sal_Int32)pLineStyle->GetValue (), XLINE_DASH))
254 pAttr->ClearItem (XATTR_LINESTYLE);
255 pAttr->Put (XLineStyleItem ((XLineStyle) pLineStyle->GetValue ()), XATTR_LINESTYLE);
256 rBindings.Invalidate (SID_ATTR_LINE_STYLE);
258 #ifndef DISABLE_SCRIPTING
259 else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
260 #endif
261 break;
263 #ifndef DISABLE_SCRIPTING
264 StarBASIC::FatalError (SbERR_WRONG_ARGS);
265 #endif
266 break;
268 // set line width
269 case SID_SETLINEWIDTH :
270 if (pArgs)
271 if (pArgs->Count () == 1)
273 SFX_REQUEST_ARG (rReq, pLineWidth, SfxUInt32Item, ID_VAL_WIDTH, sal_False);
274 pAttr->ClearItem (XATTR_LINEWIDTH);
275 pAttr->Put (XLineWidthItem (pLineWidth->GetValue ()), XATTR_LINEWIDTH);
276 rBindings.Invalidate (SID_ATTR_LINE_WIDTH);
277 break;
279 #ifndef DISABLE_SCRIPTING
280 StarBASIC::FatalError (SbERR_WRONG_ARGS);
281 #endif
282 break;
284 case SID_SETFILLCOLOR :
285 if (pArgs)
286 if (pArgs->Count () == 3)
288 SFX_REQUEST_ARG (rReq, pRed, SfxUInt32Item, ID_VAL_RED, sal_False);
289 SFX_REQUEST_ARG (rReq, pGreen, SfxUInt32Item, ID_VAL_GREEN, sal_False);
290 SFX_REQUEST_ARG (rReq, pBlue, SfxUInt32Item, ID_VAL_BLUE, sal_False);
292 pAttr->ClearItem (XATTR_FILLCOLOR);
293 pAttr->ClearItem (XATTR_FILLSTYLE);
294 pAttr->Put (XFillColorItem (-1, Color ((sal_uInt8) pRed->GetValue (),
295 (sal_uInt8) pGreen->GetValue (),
296 (sal_uInt8) pBlue->GetValue ())),
297 XATTR_FILLCOLOR);
298 pAttr->Put (XFillStyleItem (XFILL_SOLID), XATTR_FILLSTYLE);
299 rBindings.Invalidate (SID_ATTR_FILL_COLOR);
300 rBindings.Invalidate (SID_ATTR_FILL_STYLE);
301 break;
303 #ifndef DISABLE_SCRIPTING
304 StarBASIC::FatalError (SbERR_WRONG_ARGS);
305 #endif
306 break;
308 case SID_SETLINECOLOR :
309 if (pArgs)
310 if (pArgs->Count () == 3)
312 SFX_REQUEST_ARG (rReq, pRed, SfxUInt32Item, ID_VAL_RED, sal_False);
313 SFX_REQUEST_ARG (rReq, pGreen, SfxUInt32Item, ID_VAL_GREEN, sal_False);
314 SFX_REQUEST_ARG (rReq, pBlue, SfxUInt32Item, ID_VAL_BLUE, sal_False);
316 pAttr->ClearItem (XATTR_LINECOLOR);
317 pAttr->Put (XLineColorItem (-1, Color ((sal_uInt8) pRed->GetValue (),
318 (sal_uInt8) pGreen->GetValue (),
319 (sal_uInt8) pBlue->GetValue ())),
320 XATTR_LINECOLOR);
321 rBindings.Invalidate (SID_ATTR_LINE_COLOR);
322 break;
324 #ifndef DISABLE_SCRIPTING
325 StarBASIC::FatalError (SbERR_WRONG_ARGS);
326 #endif
327 break;
329 case SID_SETGRADSTARTCOLOR :
330 case SID_SETGRADENDCOLOR :
331 if (pArgs)
332 if (pArgs->Count () == 4)
334 SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, sal_False);
335 SFX_REQUEST_ARG (rReq, pRed, SfxUInt32Item, ID_VAL_RED, sal_False);
336 SFX_REQUEST_ARG (rReq, pGreen, SfxUInt32Item, ID_VAL_GREEN, sal_False);
337 SFX_REQUEST_ARG (rReq, pBlue, SfxUInt32Item, ID_VAL_BLUE, sal_False);
339 XGradientListRef pGradientList = GetDoc()->GetGradientList ();
340 long nCounts = pGradientList->Count ();
341 Color aColor ((sal_uInt8) pRed->GetValue (),
342 (sal_uInt8) pGreen->GetValue (),
343 (sal_uInt8) pBlue->GetValue ());
344 long i;
346 pAttr->ClearItem (XATTR_FILLGRADIENT);
347 pAttr->ClearItem (XATTR_FILLSTYLE);
349 for ( i = 0; i < nCounts; i ++)
351 XGradientEntry *pEntry = pGradientList->GetGradient (i);
353 if (pEntry->GetName () == pName->GetValue ())
355 XGradient aGradient(pEntry->GetGradient());
357 if (rReq.GetSlot () == SID_SETGRADSTARTCOLOR) aGradient.SetStartColor (aColor);
358 else aGradient.SetEndColor (aColor);
360 pAttr->Put (XFillStyleItem (XFILL_GRADIENT), XATTR_FILLSTYLE);
361 pAttr->Put (XFillGradientItem (pName->GetValue (), aGradient), XATTR_FILLGRADIENT);
362 break;
366 if (i >= nCounts)
368 Color aBlack (0, 0, 0);
369 XGradient aGradient ((rReq.GetSlot () == SID_SETGRADSTARTCOLOR)
370 ? aColor
371 : aBlack,
372 (rReq.GetSlot () == SID_SETGRADENDCOLOR)
373 ? aColor
374 : aBlack);
376 GetDoc()->GetGradientList ()->Insert (new XGradientEntry (aGradient, pName->GetValue ()));
378 pAttr->Put (XFillStyleItem (XFILL_GRADIENT), XATTR_FILLSTYLE);
379 pAttr->Put (XFillGradientItem (pName->GetValue (), aGradient), XATTR_FILLGRADIENT);
382 rBindings.Invalidate (SID_ATTR_FILL_STYLE);
383 rBindings.Invalidate (SID_ATTR_FILL_GRADIENT);
384 break;
386 #ifndef DISABLE_SCRIPTING
387 StarBASIC::FatalError (SbERR_WRONG_ARGS);
388 #endif
389 break;
391 case SID_SETHATCHCOLOR :
392 if (pArgs)
393 if (pArgs->Count () == 4)
395 SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, sal_False);
396 SFX_REQUEST_ARG (rReq, pRed, SfxUInt32Item, ID_VAL_RED, sal_False);
397 SFX_REQUEST_ARG (rReq, pGreen, SfxUInt32Item, ID_VAL_GREEN, sal_False);
398 SFX_REQUEST_ARG (rReq, pBlue, SfxUInt32Item, ID_VAL_BLUE, sal_False);
400 XHatchListRef pHatchList = GetDoc()->GetHatchList ();
401 long nCounts = pHatchList->Count ();
402 Color aColor ((sal_uInt8) pRed->GetValue (),
403 (sal_uInt8) pGreen->GetValue (),
404 (sal_uInt8) pBlue->GetValue ());
405 long i;
407 pAttr->ClearItem (XATTR_FILLHATCH);
408 pAttr->ClearItem (XATTR_FILLSTYLE);
410 for ( i = 0; i < nCounts; i ++)
412 XHatchEntry *pEntry = pHatchList->GetHatch (i);
414 if (pEntry->GetName () == pName->GetValue ())
416 XHatch aHatch(pEntry->GetHatch());
418 aHatch.SetColor (aColor);
420 pAttr->Put (XFillStyleItem (XFILL_HATCH), XATTR_FILLSTYLE);
421 pAttr->Put (XFillHatchItem (pName->GetValue (), aHatch), XATTR_FILLHATCH);
422 break;
426 if (i >= nCounts)
428 XHatch aHatch (aColor);
430 GetDoc()->GetHatchList ()->Insert (new XHatchEntry (aHatch, pName->GetValue ()));
432 pAttr->Put (XFillStyleItem (XFILL_HATCH), XATTR_FILLSTYLE);
433 pAttr->Put (XFillHatchItem (pName->GetValue (), aHatch), XATTR_FILLHATCH);
436 rBindings.Invalidate (SID_ATTR_FILL_HATCH);
437 rBindings.Invalidate (SID_ATTR_FILL_STYLE);
438 break;
440 #ifndef DISABLE_SCRIPTING
441 StarBASIC::FatalError (SbERR_WRONG_ARGS);
442 #endif
443 break;
445 // einstellungen fuer liniendash
446 case SID_DASH :
447 if (pArgs)
448 if (pArgs->Count () == 7)
450 SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, sal_False);
451 SFX_REQUEST_ARG (rReq, pStyle, SfxUInt32Item, ID_VAL_STYLE, sal_False);
452 SFX_REQUEST_ARG (rReq, pDots, SfxUInt32Item, ID_VAL_DOTS, sal_False);
453 SFX_REQUEST_ARG (rReq, pDotLen, SfxUInt32Item, ID_VAL_DOTLEN, sal_False);
454 SFX_REQUEST_ARG (rReq, pDashes, SfxUInt32Item, ID_VAL_DASHES, sal_False);
455 SFX_REQUEST_ARG (rReq, pDashLen, SfxUInt32Item, ID_VAL_DASHLEN, sal_False);
456 SFX_REQUEST_ARG (rReq, pDistance, SfxUInt32Item, ID_VAL_DISTANCE, sal_False);
458 if (CHECK_RANGE (XDASH_RECT, (sal_Int32)pStyle->GetValue (), XDASH_ROUNDRELATIVE))
460 XDash aNewDash ((XDashStyle) pStyle->GetValue (), (short) pDots->GetValue (), pDotLen->GetValue (),
461 (short) pDashes->GetValue (), pDashLen->GetValue (), pDistance->GetValue ());
463 pAttr->ClearItem (XATTR_LINEDASH);
464 pAttr->ClearItem (XATTR_LINESTYLE);
466 XDashListRef pDashList = GetDoc()->GetDashList();
467 long nCounts = pDashList->Count ();
468 XDashEntry *pEntry = new XDashEntry (aNewDash, pName->GetValue ());
469 long i;
471 for ( i = 0; i < nCounts; i++ )
472 if (pDashList->GetDash (i)->GetName () == pName->GetValue ())
473 break;
475 if (i < nCounts)
476 pDashList->Replace (pEntry, i);
477 else
478 pDashList->Insert (pEntry);
480 pAttr->Put (XLineDashItem (pName->GetValue (), aNewDash), XATTR_LINEDASH);
481 pAttr->Put (XLineStyleItem (XLINE_DASH), XATTR_LINESTYLE);
482 rBindings.Invalidate (SID_ATTR_LINE_DASH);
483 rBindings.Invalidate (SID_ATTR_FILL_STYLE);
485 #ifndef DISABLE_SCRIPTING
486 else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
487 #endif
488 break;
490 #ifndef DISABLE_SCRIPTING
491 StarBASIC::FatalError (SbERR_WRONG_ARGS);
492 #endif
493 break;
495 // configuration for gradients
496 case SID_GRADIENT :
497 if (pArgs)
498 if (pArgs->Count () == 8)
500 SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, sal_False);
501 SFX_REQUEST_ARG (rReq, pStyle, SfxUInt32Item, ID_VAL_STYLE, sal_False);
502 SFX_REQUEST_ARG (rReq, pAngle, SfxUInt32Item, ID_VAL_ANGLE, sal_False);
503 SFX_REQUEST_ARG (rReq, pBorder, SfxUInt32Item, ID_VAL_BORDER, sal_False);
504 SFX_REQUEST_ARG (rReq, pCenterX, SfxUInt32Item, ID_VAL_CENTER_X, sal_False);
505 SFX_REQUEST_ARG (rReq, pCenterY, SfxUInt32Item, ID_VAL_CENTER_Y, sal_False);
506 SFX_REQUEST_ARG (rReq, pStart, SfxUInt32Item, ID_VAL_STARTINTENS, sal_False);
507 SFX_REQUEST_ARG (rReq, pEnd, SfxUInt32Item, ID_VAL_ENDINTENS, sal_False);
509 if (CHECK_RANGE (XGRAD_LINEAR, (sal_Int32)pStyle->GetValue (), XGRAD_RECT) &&
510 CHECK_RANGE (0, (sal_Int32)pAngle->GetValue (), 360) &&
511 CHECK_RANGE (0, (sal_Int32)pBorder->GetValue (), 100) &&
512 CHECK_RANGE (0, (sal_Int32)pCenterX->GetValue (), 100) &&
513 CHECK_RANGE (0, (sal_Int32)pCenterY->GetValue (), 100) &&
514 CHECK_RANGE (0, (sal_Int32)pStart->GetValue (), 100) &&
515 CHECK_RANGE (0, (sal_Int32)pEnd->GetValue (), 100))
517 pAttr->ClearItem (XATTR_FILLGRADIENT);
518 pAttr->ClearItem (XATTR_FILLSTYLE);
520 XGradientListRef pGradientList = GetDoc()->GetGradientList ();
521 long nCounts = pGradientList->Count ();
522 long i;
524 for ( i = 0; i < nCounts; i++ )
526 XGradientEntry *pEntry = pGradientList->GetGradient (i);
528 if (pEntry->GetName () == pName->GetValue ())
530 XGradient aGradient(pEntry->GetGradient());
532 aGradient.SetGradientStyle ((XGradientStyle) pStyle->GetValue ());
533 aGradient.SetAngle (pAngle->GetValue () * 10);
534 aGradient.SetBorder ((short) pBorder->GetValue ());
535 aGradient.SetXOffset ((short) pCenterX->GetValue ());
536 aGradient.SetYOffset ((short) pCenterY->GetValue ());
537 aGradient.SetStartIntens ((short) pStart->GetValue ());
538 aGradient.SetEndIntens ((short) pEnd->GetValue ());
540 pAttr->Put (XFillStyleItem (XFILL_GRADIENT), XATTR_FILLSTYLE);
541 pAttr->Put (XFillGradientItem (pName->GetValue (), aGradient), XATTR_FILLGRADIENT);
542 break;
546 if (i >= nCounts)
548 Color aBlack (0, 0, 0);
549 XGradient aGradient (aBlack, aBlack, (XGradientStyle) pStyle->GetValue (),
550 pAngle->GetValue () * 10, (short) pCenterX->GetValue (),
551 (short) pCenterY->GetValue (), (short) pBorder->GetValue (),
552 (short) pStart->GetValue (), (short) pEnd->GetValue ());
554 pGradientList->Insert (new XGradientEntry (aGradient, pName->GetValue ()));
555 pAttr->Put (XFillStyleItem (XFILL_GRADIENT), XATTR_FILLSTYLE);
556 pAttr->Put (XFillGradientItem (pName->GetValue (), aGradient), XATTR_FILLGRADIENT);
559 rBindings.Invalidate (SID_ATTR_FILL_GRADIENT);
560 rBindings.Invalidate (SID_ATTR_FILL_STYLE);
562 #ifndef DISABLE_SCRIPTING
563 else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
564 #endif
565 break;
567 #ifndef DISABLE_SCRIPTING
568 StarBASIC::FatalError (SbERR_WRONG_ARGS);
569 #endif
570 break;
572 // configuration for hatch
573 case SID_HATCH :
574 if (pArgs)
575 if (pArgs->Count () == 4)
577 SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, sal_False);
578 SFX_REQUEST_ARG (rReq, pStyle, SfxUInt32Item, ID_VAL_STYLE, sal_False);
579 SFX_REQUEST_ARG (rReq, pDistance, SfxUInt32Item, ID_VAL_DISTANCE, sal_False);
580 SFX_REQUEST_ARG (rReq, pAngle, SfxUInt32Item, ID_VAL_ANGLE, sal_False);
582 if (CHECK_RANGE (XHATCH_SINGLE, (sal_Int32)pStyle->GetValue (), XHATCH_TRIPLE) &&
583 CHECK_RANGE (0, (sal_Int32)pAngle->GetValue (), 360))
585 pAttr->ClearItem (XATTR_FILLHATCH);
586 pAttr->ClearItem (XATTR_FILLSTYLE);
588 XHatchListRef pHatchList = GetDoc()->GetHatchList ();
589 long nCounts = pHatchList->Count ();
590 long i;
592 for ( i = 0; i < nCounts; i++ )
594 XHatchEntry *pEntry = pHatchList->GetHatch (i);
596 if (pEntry->GetName () == pName->GetValue ())
598 XHatch aHatch(pEntry->GetHatch());
600 aHatch.SetHatchStyle ((XHatchStyle) pStyle->GetValue ());
601 aHatch.SetDistance (pDistance->GetValue ());
602 aHatch.SetAngle (pAngle->GetValue () * 10);
604 pAttr->Put (XFillStyleItem (XFILL_HATCH), XATTR_FILLSTYLE);
605 pAttr->Put (XFillHatchItem (pName->GetValue (), aHatch), XATTR_FILLHATCH);
606 break;
610 if (i >= nCounts)
612 Color aBlack (0, 0, 0);
613 XHatch aHatch (aBlack, (XHatchStyle) pStyle->GetValue (), pDistance->GetValue (),
614 pAngle->GetValue () * 10);
616 pHatchList->Insert (new XHatchEntry (aHatch, pName->GetValue ()));
617 pAttr->Put (XFillStyleItem (XFILL_HATCH), XATTR_FILLSTYLE);
618 pAttr->Put (XFillHatchItem (pName->GetValue (), aHatch), XATTR_FILLHATCH);
621 rBindings.Invalidate (SID_ATTR_FILL_HATCH);
622 rBindings.Invalidate (SID_ATTR_FILL_STYLE);
624 #ifndef DISABLE_SCRIPTING
625 else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
626 #endif
627 break;
629 #ifndef DISABLE_SCRIPTING
630 StarBASIC::FatalError (SbERR_WRONG_ARGS);
631 #endif
632 break;
634 case SID_SELECTGRADIENT :
635 if (pArgs)
636 if (pArgs->Count () == 1)
638 SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, sal_False);
640 XGradientListRef pGradientList = GetDoc()->GetGradientList ();
641 long nCounts = pGradientList->Count ();
643 for (long i = 0;
644 i < nCounts;
645 i ++)
647 XGradientEntry *pEntry = pGradientList->GetGradient (i);
649 if (pEntry->GetName () == pName->GetValue ())
651 pAttr->ClearItem (XATTR_FILLGRADIENT);
652 pAttr->ClearItem (XATTR_FILLSTYLE);
653 pAttr->Put (XFillStyleItem (XFILL_GRADIENT), XATTR_FILLSTYLE);
654 pAttr->Put (XFillGradientItem (pName->GetValue (), pEntry->GetGradient ()), XATTR_FILLGRADIENT);
656 rBindings.Invalidate (SID_ATTR_FILL_GRADIENT);
657 rBindings.Invalidate (SID_ATTR_FILL_STYLE);
658 break;
662 break;
664 #ifndef DISABLE_SCRIPTING
665 StarBASIC::FatalError (SbERR_WRONG_ARGS);
666 #endif
667 break;
669 case SID_SELECTHATCH :
670 if (pArgs)
671 if (pArgs->Count () == 1)
673 SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, sal_False);
675 XHatchListRef pHatchList = GetDoc()->GetHatchList ();
676 long nCounts = pHatchList->Count ();
678 for (long i = 0;
679 i < nCounts;
680 i ++)
682 XHatchEntry *pEntry = pHatchList->GetHatch (i);
684 if (pEntry->GetName () == pName->GetValue ())
686 pAttr->ClearItem (XATTR_FILLHATCH);
687 pAttr->ClearItem (XATTR_FILLSTYLE);
688 pAttr->Put (XFillStyleItem (XFILL_HATCH), XATTR_FILLSTYLE);
689 pAttr->Put (XFillHatchItem (pName->GetValue (), pEntry->GetHatch ()), XATTR_FILLHATCH);
691 rBindings.Invalidate (SID_ATTR_FILL_HATCH);
692 rBindings.Invalidate (SID_ATTR_FILL_STYLE);
693 break;
697 break;
699 #ifndef DISABLE_SCRIPTING
700 StarBASIC::FatalError (SbERR_WRONG_ARGS);
701 #endif
702 break;
704 case SID_UNSELECT :
705 mpDrawView->UnmarkAll ();
706 break;
708 case SID_GETRED :
709 if (pArgs)
710 if (pArgs->Count () == 1)
712 break;
714 #ifndef DISABLE_SCRIPTING
715 StarBASIC::FatalError (SbERR_WRONG_ARGS);
716 #endif
717 break;
719 /* case SID_SETFONTFAMILYNAME :
720 case SID_SETFONTSTYLENAME :
721 case SID_SETFONTFAMILY :
722 case SID_SETFONTPITCH :
723 case SID_SETFONTCHARSET :
724 case SID_SETFONTPOSTURE :
725 case SID_SETFONTWEIGHT :
726 case SID_SETFONTUNDERLINE :
727 case SID_SETFONTCROSSEDOUT :
728 case SID_SETFONTSHADOWED :
729 case SID_SETFONTCONTOUR :
730 case SID_SETFONTCOLOR :
731 case SID_SETFONTLANGUAGE :
732 case SID_SETFONTWORDLINE :
733 case SID_SETFONTCASEMAP :
734 case SID_SETFONTESCAPE :
735 case SID_SETFONTKERNING :
736 break;*/
738 default :
742 mpDrawView->SetAttributes (*(const SfxItemSet *) pAttr);
743 rReq.Ignore ();
744 delete pAttr;
748 * Edit macros for attribute configuration
750 void DrawViewShell::AttrState (SfxItemSet& rSet)
752 SfxWhichIter aIter (rSet);
753 sal_uInt16 nWhich = aIter.FirstWhich ();
754 SfxItemSet aAttr( GetDoc()->GetPool() );
755 mpDrawView->GetAttributes( aAttr );
757 while (nWhich)
759 switch (nWhich)
761 case SID_GETFILLSTYLE :
763 const XFillStyleItem &rFillStyleItem = (const XFillStyleItem &) aAttr.Get (XATTR_FILLSTYLE);
765 rSet.Put (SfxUInt32Item (nWhich, (long) rFillStyleItem.GetValue ()));
766 break;
769 case SID_GETLINESTYLE :
771 const XLineStyleItem &rLineStyleItem = (const XLineStyleItem &) aAttr.Get (XATTR_LINESTYLE);
773 rSet.Put (SfxUInt32Item (nWhich, (long) rLineStyleItem.GetValue ()));
774 break;
777 case SID_GETLINEWIDTH :
779 const XLineWidthItem &rLineWidthItem = (const XLineWidthItem &) aAttr.Get (XATTR_LINEWIDTH);
781 rSet.Put (SfxUInt32Item (nWhich, (long) rLineWidthItem.GetValue ()));
782 break;
785 case SID_GETGREEN :
786 case SID_GETRED :
787 case SID_GETBLUE :
789 const SfxUInt32Item &rWhatKind = (const SfxUInt32Item &) rSet.Get (ID_VAL_WHATKIND);
790 Color aColor;
792 switch (rWhatKind.GetValue ())
794 case 1 :
796 const XLineColorItem &rLineColorItem = (const XLineColorItem &) aAttr.Get (XATTR_LINECOLOR);
798 aColor = rLineColorItem.GetColorValue ();
799 break;
802 case 2 :
804 const XFillColorItem &rFillColorItem = (const XFillColorItem &) aAttr.Get (XATTR_FILLCOLOR);
806 aColor = rFillColorItem.GetColorValue ();
807 break;
810 case 3 :
811 case 4 :
813 const XFillGradientItem &rFillGradientItem = (const XFillGradientItem &) aAttr.Get (XATTR_FILLGRADIENT);
814 const XGradient &rGradient = rFillGradientItem.GetGradientValue ();
816 aColor = (rWhatKind.GetValue () == 3)
817 ? rGradient.GetStartColor ()
818 : rGradient.GetEndColor ();
819 break;
822 case 5:
824 const XFillHatchItem &rFillHatchItem = (const XFillHatchItem &) aAttr.Get (XATTR_FILLHATCH);
825 const XHatch &rHatch = rFillHatchItem.GetHatchValue ();
827 aColor = rHatch.GetColor ();
828 break;
831 default :
835 rSet.Put (SfxUInt32Item (nWhich, (long) ((nWhich == SID_GETRED)
836 ? aColor.GetRed ()
837 : (nWhich == SID_GETGREEN)
838 ? aColor.GetGreen ()
839 : aColor.GetBlue ())));
840 break;
843 default :
847 nWhich = aIter.NextWhich ();
851 } // end of namespace sd
853 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */