1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #include <config_features.h>
22 #include "DrawViewShell.hxx"
23 #include <vcl/wrkwin.hxx>
24 #include <svx/xgrad.hxx>
25 #include <svx/svdpagv.hxx>
26 #include <svx/xlnwtit.hxx>
27 #include <svx/xlndsit.hxx>
28 #include <svx/xflhtit.hxx>
29 #include <svx/xflgrit.hxx>
30 #include <svx/xlnclit.hxx>
31 #include <svx/xflclit.hxx>
32 #include <sfx2/bindings.hxx>
34 #include <sfx2/dispatch.hxx>
35 #include <svl/intitem.hxx>
36 #include <sfx2/app.hxx>
37 #include <sfx2/request.hxx>
38 #include <svl/stritem.hxx>
39 #include <svx/svxids.hrc>
40 #include <svx/xtable.hxx>
41 #include <svx/gallery.hxx>
42 #include <vcl/graph.hxx>
43 #include <svx/svdograf.hxx>
44 #include <svx/svdoole2.hxx>
45 #include <sot/storage.hxx>
46 #include <svl/whiter.hxx>
47 #include <basic/sbstar.hxx>
49 #include <sfx2/viewfrm.hxx>
52 #include "strings.hrc"
54 #include "drawdoc.hxx"
55 #include "drawview.hxx"
56 #include "DrawDocShell.hxx"
57 #include "sdresid.hxx"
60 #include <svx/galleryitem.hxx>
61 #include <com/sun/star/gallery/GalleryItemType.hpp>
62 #include <com/sun/star/drawing/LineStyle.hpp>
63 #include <boost/scoped_ptr.hpp>
65 using namespace com::sun::star
;
69 void DrawViewShell::ExecGallery(SfxRequest
& rReq
)
71 // nothing is executed during a slide show!
72 if(HasCurrentFunction(SID_PRESENTATION
))
75 const SfxItemSet
* pArgs
= rReq
.GetArgs();
77 SFX_ITEMSET_ARG( pArgs
, pGalleryItem
, SvxGalleryItem
, SID_GALLERY_FORMATS
, false );
81 GetDocSh()->SetWaitCursor( true );
83 sal_Int8
nType( pGalleryItem
->GetType() );
85 if (nType
== com::sun::star::gallery::GalleryItemType::GRAPHIC
)
87 Graphic
aGraphic( pGalleryItem
->GetGraphic() );
89 // reduce size if necessary
90 ScopedVclPtrInstance
< Window
> aWindow(GetActiveWindow());
91 aWindow
->SetMapMode(aGraphic
.GetPrefMapMode());
92 Size aSizePix
= aWindow
->LogicToPixel(aGraphic
.GetPrefSize());
93 aWindow
->SetMapMode( MapMode(MAP_100TH_MM
) );
94 Size aSize
= aWindow
->PixelToLogic(aSizePix
);
96 // constrain size to page size if necessary
97 SdrPage
* pPage
= mpDrawView
->GetSdrPageView()->GetPage();
98 Size aPageSize
= pPage
->GetSize();
99 aPageSize
.Width() -= pPage
->GetLftBorder() + pPage
->GetRgtBorder();
100 aPageSize
.Height() -= pPage
->GetUppBorder() + pPage
->GetLwrBorder();
102 // If the image is too large we make it fit into the page
103 if ( ( ( aSize
.Height() > aPageSize
.Height() ) || ( aSize
.Width() > aPageSize
.Width() ) ) &&
104 aSize
.Height() && aPageSize
.Height() )
106 float fGrfWH
= (float)aSize
.Width() /
107 (float)aSize
.Height();
108 float fWinWH
= (float)aPageSize
.Width() /
109 (float)aPageSize
.Height();
111 // constrain size to page size if necessary
112 if ((fGrfWH
!= 0.F
) && (fGrfWH
< fWinWH
))
114 aSize
.Width() = (long)(aPageSize
.Height() * fGrfWH
);
115 aSize
.Height()= aPageSize
.Height();
119 aSize
.Width() = aPageSize
.Width();
120 aSize
.Height()= (long)(aPageSize
.Width() / fGrfWH
);
124 // set output rectangle for graphic
125 Point
aPnt ((aPageSize
.Width() - aSize
.Width()) / 2,
126 (aPageSize
.Height() - aSize
.Height()) / 2);
127 aPnt
+= Point(pPage
->GetLftBorder(), pPage
->GetUppBorder());
128 Rectangle
aRect (aPnt
, aSize
);
130 SdrGrafObj
* pGrafObj
= NULL
;
132 bool bInsertNewObject
= true;
134 if ( mpDrawView
->AreObjectsMarked() )
136 // is there a empty graphic object?
137 const SdrMarkList
& rMarkList
= mpDrawView
->GetMarkedObjectList();
139 if (rMarkList
.GetMarkCount() == 1)
141 SdrMark
* pMark
= rMarkList
.GetMark(0);
142 SdrObject
* pObj
= pMark
->GetMarkedSdrObj();
144 if (pObj
->GetObjInventor() == SdrInventor
&& pObj
->GetObjIdentifier() == OBJ_GRAF
)
146 pGrafObj
= static_cast<SdrGrafObj
*>(pObj
);
148 if( pGrafObj
->IsEmptyPresObj() )
150 // the empty graphic object gets a new graphic
151 bInsertNewObject
= false;
153 SdrGrafObj
* pNewGrafObj
= pGrafObj
->Clone();
154 pNewGrafObj
->SetEmptyPresObj(false);
155 pNewGrafObj
->SetOutlinerParaObject(NULL
);
156 pNewGrafObj
->SetGraphic(aGraphic
);
158 OUString
aStr(mpDrawView
->GetDescriptionOfMarkedObjects());
159 aStr
+= " " + SD_RESSTR(STR_UNDO_REPLACE
);
160 mpDrawView
->BegUndo(aStr
);
161 SdrPageView
* pPV
= mpDrawView
->GetSdrPageView();
162 mpDrawView
->ReplaceObjectAtView(pGrafObj
, *pPV
, pNewGrafObj
);
163 mpDrawView
->EndUndo();
169 if( bInsertNewObject
)
171 pGrafObj
= new SdrGrafObj(aGraphic
, aRect
);
172 SdrPageView
* pPV
= mpDrawView
->GetSdrPageView();
173 mpDrawView
->InsertObjectAtView(pGrafObj
, *pPV
, SdrInsertFlags::SETDEFLAYER
);
177 else if( nType
== com::sun::star::gallery::GalleryItemType::MEDIA
)
179 const SfxStringItem
aMediaURLItem( SID_INSERT_AVMEDIA
, pGalleryItem
->GetURL() );
180 GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA
, SfxCallMode::SYNCHRON
, &aMediaURLItem
, 0L );
183 GetDocSh()->SetWaitCursor( false );
187 * Edit macros for attribute configuration
190 /* the work flow to adjust the attributes is nearly everywhere the same
191 1. read existing attributes
192 2. read parameter from the basic-set
193 3. delete selected item from the attribute-set
194 4. create new attribute-item
195 5. insert item into set */
196 void DrawViewShell::AttrExec (SfxRequest
&rReq
)
198 // nothing is executed during a slide show!
199 if(HasCurrentFunction(SID_PRESENTATION
))
204 SfxBindings
& rBindings
= GetViewFrame()->GetBindings();
205 boost::scoped_ptr
<SfxItemSet
> pAttr(new SfxItemSet ( GetDoc()->GetPool() ));
207 GetView()->GetAttributes( *pAttr
);
208 const SfxItemSet
* pArgs
= rReq
.GetArgs();
210 switch (rReq
.GetSlot ())
212 // set new fill-style
213 case SID_SETFILLSTYLE
:
215 if (pArgs
->Count () == 1)
217 SFX_REQUEST_ARG (rReq
, pFillStyle
, SfxUInt32Item
, ID_VAL_STYLE
, false);
218 if (CHECK_RANGE (drawing::FillStyle_NONE
, (sal_Int32
)pFillStyle
->GetValue (), drawing::FillStyle_BITMAP
))
220 pAttr
->ClearItem (XATTR_FILLSTYLE
);
221 pAttr
->Put (XFillStyleItem ((drawing::FillStyle
) pFillStyle
->GetValue ()), XATTR_FILLSTYLE
);
222 rBindings
.Invalidate (SID_ATTR_FILL_STYLE
);
224 #if HAVE_FEATURE_SCRIPTING
225 else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE
);
229 #if HAVE_FEATURE_SCRIPTING
230 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
234 // determine new line style
235 case SID_SETLINESTYLE
:
237 if (pArgs
->Count () == 1)
239 SFX_REQUEST_ARG (rReq
, pLineStyle
, SfxUInt32Item
, ID_VAL_STYLE
, false);
240 if (CHECK_RANGE (drawing::LineStyle_NONE
, (sal_Int32
)pLineStyle
->GetValue (), drawing::LineStyle_DASH
))
242 pAttr
->ClearItem (XATTR_LINESTYLE
);
243 pAttr
->Put (XLineStyleItem ((drawing::LineStyle
) pLineStyle
->GetValue ()), XATTR_LINESTYLE
);
244 rBindings
.Invalidate (SID_ATTR_LINE_STYLE
);
246 #if HAVE_FEATURE_SCRIPTING
247 else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE
);
251 #if HAVE_FEATURE_SCRIPTING
252 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
257 case SID_SETLINEWIDTH
:
259 if (pArgs
->Count () == 1)
261 SFX_REQUEST_ARG (rReq
, pLineWidth
, SfxUInt32Item
, ID_VAL_WIDTH
, false);
262 pAttr
->ClearItem (XATTR_LINEWIDTH
);
263 pAttr
->Put (XLineWidthItem (pLineWidth
->GetValue ()), XATTR_LINEWIDTH
);
264 rBindings
.Invalidate (SID_ATTR_LINE_WIDTH
);
267 #if HAVE_FEATURE_SCRIPTING
268 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
272 case SID_SETFILLCOLOR
:
274 if (pArgs
->Count () == 3)
276 SFX_REQUEST_ARG (rReq
, pRed
, SfxUInt32Item
, ID_VAL_RED
, false);
277 SFX_REQUEST_ARG (rReq
, pGreen
, SfxUInt32Item
, ID_VAL_GREEN
, false);
278 SFX_REQUEST_ARG (rReq
, pBlue
, SfxUInt32Item
, ID_VAL_BLUE
, false);
280 pAttr
->ClearItem (XATTR_FILLCOLOR
);
281 pAttr
->ClearItem (XATTR_FILLSTYLE
);
282 pAttr
->Put (XFillColorItem (-1, Color ((sal_uInt8
) pRed
->GetValue (),
283 (sal_uInt8
) pGreen
->GetValue (),
284 (sal_uInt8
) pBlue
->GetValue ())),
286 pAttr
->Put (XFillStyleItem (drawing::FillStyle_SOLID
), XATTR_FILLSTYLE
);
287 rBindings
.Invalidate (SID_ATTR_FILL_COLOR
);
288 rBindings
.Invalidate (SID_ATTR_FILL_STYLE
);
291 #if HAVE_FEATURE_SCRIPTING
292 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
296 case SID_SETLINECOLOR
:
298 if (pArgs
->Count () == 3)
300 SFX_REQUEST_ARG (rReq
, pRed
, SfxUInt32Item
, ID_VAL_RED
, false);
301 SFX_REQUEST_ARG (rReq
, pGreen
, SfxUInt32Item
, ID_VAL_GREEN
, false);
302 SFX_REQUEST_ARG (rReq
, pBlue
, SfxUInt32Item
, ID_VAL_BLUE
, false);
304 pAttr
->ClearItem (XATTR_LINECOLOR
);
305 pAttr
->Put (XLineColorItem (-1, Color ((sal_uInt8
) pRed
->GetValue (),
306 (sal_uInt8
) pGreen
->GetValue (),
307 (sal_uInt8
) pBlue
->GetValue ())),
309 rBindings
.Invalidate (SID_ATTR_LINE_COLOR
);
312 #if HAVE_FEATURE_SCRIPTING
313 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
317 case SID_SETGRADSTARTCOLOR
:
318 case SID_SETGRADENDCOLOR
:
320 if (pArgs
->Count () == 4)
322 SFX_REQUEST_ARG (rReq
, pName
, SfxStringItem
, ID_VAL_INDEX
, false);
323 SFX_REQUEST_ARG (rReq
, pRed
, SfxUInt32Item
, ID_VAL_RED
, false);
324 SFX_REQUEST_ARG (rReq
, pGreen
, SfxUInt32Item
, ID_VAL_GREEN
, false);
325 SFX_REQUEST_ARG (rReq
, pBlue
, SfxUInt32Item
, ID_VAL_BLUE
, false);
327 XGradientListRef pGradientList
= GetDoc()->GetGradientList ();
328 long nCounts
= pGradientList
->Count ();
329 Color
aColor ((sal_uInt8
) pRed
->GetValue (),
330 (sal_uInt8
) pGreen
->GetValue (),
331 (sal_uInt8
) pBlue
->GetValue ());
334 pAttr
->ClearItem (XATTR_FILLGRADIENT
);
335 pAttr
->ClearItem (XATTR_FILLSTYLE
);
337 for ( i
= 0; i
< nCounts
; i
++)
339 XGradientEntry
*pEntry
= pGradientList
->GetGradient (i
);
341 if (pEntry
->GetName () == pName
->GetValue ())
343 XGradient
aGradient(pEntry
->GetGradient());
345 if (rReq
.GetSlot () == SID_SETGRADSTARTCOLOR
) aGradient
.SetStartColor (aColor
);
346 else aGradient
.SetEndColor (aColor
);
348 pAttr
->Put (XFillStyleItem (drawing::FillStyle_GRADIENT
), XATTR_FILLSTYLE
);
349 pAttr
->Put (XFillGradientItem (pName
->GetValue (), aGradient
), XATTR_FILLGRADIENT
);
356 Color
aBlack (0, 0, 0);
357 XGradient
aGradient ((rReq
.GetSlot () == SID_SETGRADSTARTCOLOR
)
360 (rReq
.GetSlot () == SID_SETGRADENDCOLOR
)
364 GetDoc()->GetGradientList ()->Insert (new XGradientEntry (aGradient
, pName
->GetValue ()));
366 pAttr
->Put (XFillStyleItem (drawing::FillStyle_GRADIENT
), XATTR_FILLSTYLE
);
367 pAttr
->Put (XFillGradientItem (pName
->GetValue (), aGradient
), XATTR_FILLGRADIENT
);
370 rBindings
.Invalidate (SID_ATTR_FILL_STYLE
);
371 rBindings
.Invalidate (SID_ATTR_FILL_GRADIENT
);
374 #if HAVE_FEATURE_SCRIPTING
375 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
379 case SID_SETHATCHCOLOR
:
381 if (pArgs
->Count () == 4)
383 SFX_REQUEST_ARG (rReq
, pName
, SfxStringItem
, ID_VAL_INDEX
, false);
384 SFX_REQUEST_ARG (rReq
, pRed
, SfxUInt32Item
, ID_VAL_RED
, false);
385 SFX_REQUEST_ARG (rReq
, pGreen
, SfxUInt32Item
, ID_VAL_GREEN
, false);
386 SFX_REQUEST_ARG (rReq
, pBlue
, SfxUInt32Item
, ID_VAL_BLUE
, false);
388 XHatchListRef pHatchList
= GetDoc()->GetHatchList ();
389 long nCounts
= pHatchList
->Count ();
390 Color
aColor ((sal_uInt8
) pRed
->GetValue (),
391 (sal_uInt8
) pGreen
->GetValue (),
392 (sal_uInt8
) pBlue
->GetValue ());
395 pAttr
->ClearItem (XATTR_FILLHATCH
);
396 pAttr
->ClearItem (XATTR_FILLSTYLE
);
398 for ( i
= 0; i
< nCounts
; i
++)
400 XHatchEntry
*pEntry
= pHatchList
->GetHatch (i
);
402 if (pEntry
->GetName () == pName
->GetValue ())
404 XHatch
aHatch(pEntry
->GetHatch());
406 aHatch
.SetColor (aColor
);
408 pAttr
->Put (XFillStyleItem (drawing::FillStyle_HATCH
), XATTR_FILLSTYLE
);
409 pAttr
->Put (XFillHatchItem (pName
->GetValue (), aHatch
), XATTR_FILLHATCH
);
416 XHatch
aHatch (aColor
);
418 GetDoc()->GetHatchList ()->Insert (new XHatchEntry (aHatch
, pName
->GetValue ()));
420 pAttr
->Put (XFillStyleItem (drawing::FillStyle_HATCH
), XATTR_FILLSTYLE
);
421 pAttr
->Put (XFillHatchItem (pName
->GetValue (), aHatch
), XATTR_FILLHATCH
);
424 rBindings
.Invalidate (SID_ATTR_FILL_HATCH
);
425 rBindings
.Invalidate (SID_ATTR_FILL_STYLE
);
428 #if HAVE_FEATURE_SCRIPTING
429 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
433 // configuration for line-dash
436 if (pArgs
->Count () == 7)
438 SFX_REQUEST_ARG (rReq
, pName
, SfxStringItem
, ID_VAL_INDEX
, false);
439 SFX_REQUEST_ARG (rReq
, pStyle
, SfxUInt32Item
, ID_VAL_STYLE
, false);
440 SFX_REQUEST_ARG (rReq
, pDots
, SfxUInt32Item
, ID_VAL_DOTS
, false);
441 SFX_REQUEST_ARG (rReq
, pDotLen
, SfxUInt32Item
, ID_VAL_DOTLEN
, false);
442 SFX_REQUEST_ARG (rReq
, pDashes
, SfxUInt32Item
, ID_VAL_DASHES
, false);
443 SFX_REQUEST_ARG (rReq
, pDashLen
, SfxUInt32Item
, ID_VAL_DASHLEN
, false);
444 SFX_REQUEST_ARG (rReq
, pDistance
, SfxUInt32Item
, ID_VAL_DISTANCE
, false);
446 if (CHECK_RANGE (css::drawing::DashStyle_RECT
, (sal_Int32
)pStyle
->GetValue (), css::drawing::DashStyle_ROUNDRELATIVE
))
448 XDash
aNewDash ((css::drawing::DashStyle
) pStyle
->GetValue (), (short) pDots
->GetValue (), pDotLen
->GetValue (),
449 (short) pDashes
->GetValue (), pDashLen
->GetValue (), pDistance
->GetValue ());
451 pAttr
->ClearItem (XATTR_LINEDASH
);
452 pAttr
->ClearItem (XATTR_LINESTYLE
);
454 XDashListRef pDashList
= GetDoc()->GetDashList();
455 long nCounts
= pDashList
->Count ();
456 XDashEntry
*pEntry
= new XDashEntry (aNewDash
, pName
->GetValue ());
459 for ( i
= 0; i
< nCounts
; i
++ )
460 if (pDashList
->GetDash (i
)->GetName () == pName
->GetValue ())
464 pDashList
->Replace (pEntry
, i
);
466 pDashList
->Insert (pEntry
);
468 pAttr
->Put (XLineDashItem (pName
->GetValue (), aNewDash
), XATTR_LINEDASH
);
469 pAttr
->Put (XLineStyleItem (drawing::LineStyle_DASH
), XATTR_LINESTYLE
);
470 rBindings
.Invalidate (SID_ATTR_LINE_DASH
);
471 rBindings
.Invalidate (SID_ATTR_FILL_STYLE
);
473 #if HAVE_FEATURE_SCRIPTING
474 else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE
);
478 #if HAVE_FEATURE_SCRIPTING
479 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
483 // configuration for gradients
486 if (pArgs
->Count () == 8)
488 SFX_REQUEST_ARG (rReq
, pName
, SfxStringItem
, ID_VAL_INDEX
, false);
489 SFX_REQUEST_ARG (rReq
, pStyle
, SfxUInt32Item
, ID_VAL_STYLE
, false);
490 SFX_REQUEST_ARG (rReq
, pAngle
, SfxUInt32Item
, ID_VAL_ANGLE
, false);
491 SFX_REQUEST_ARG (rReq
, pBorder
, SfxUInt32Item
, ID_VAL_BORDER
, false);
492 SFX_REQUEST_ARG (rReq
, pCenterX
, SfxUInt32Item
, ID_VAL_CENTER_X
, false);
493 SFX_REQUEST_ARG (rReq
, pCenterY
, SfxUInt32Item
, ID_VAL_CENTER_Y
, false);
494 SFX_REQUEST_ARG (rReq
, pStart
, SfxUInt32Item
, ID_VAL_STARTINTENS
, false);
495 SFX_REQUEST_ARG (rReq
, pEnd
, SfxUInt32Item
, ID_VAL_ENDINTENS
, false);
497 if (CHECK_RANGE (css::awt::GradientStyle_LINEAR
, (sal_Int32
)pStyle
->GetValue (), css::awt::GradientStyle_RECT
) &&
498 CHECK_RANGE (0, (sal_Int32
)pAngle
->GetValue (), 360) &&
499 CHECK_RANGE (0, (sal_Int32
)pBorder
->GetValue (), 100) &&
500 CHECK_RANGE (0, (sal_Int32
)pCenterX
->GetValue (), 100) &&
501 CHECK_RANGE (0, (sal_Int32
)pCenterY
->GetValue (), 100) &&
502 CHECK_RANGE (0, (sal_Int32
)pStart
->GetValue (), 100) &&
503 CHECK_RANGE (0, (sal_Int32
)pEnd
->GetValue (), 100))
505 pAttr
->ClearItem (XATTR_FILLGRADIENT
);
506 pAttr
->ClearItem (XATTR_FILLSTYLE
);
508 XGradientListRef pGradientList
= GetDoc()->GetGradientList ();
509 long nCounts
= pGradientList
->Count ();
512 for ( i
= 0; i
< nCounts
; i
++ )
514 XGradientEntry
*pEntry
= pGradientList
->GetGradient (i
);
516 if (pEntry
->GetName () == pName
->GetValue ())
518 XGradient
aGradient(pEntry
->GetGradient());
520 aGradient
.SetGradientStyle ((css::awt::GradientStyle
) pStyle
->GetValue ());
521 aGradient
.SetAngle (pAngle
->GetValue () * 10);
522 aGradient
.SetBorder ((short) pBorder
->GetValue ());
523 aGradient
.SetXOffset ((short) pCenterX
->GetValue ());
524 aGradient
.SetYOffset ((short) pCenterY
->GetValue ());
525 aGradient
.SetStartIntens ((short) pStart
->GetValue ());
526 aGradient
.SetEndIntens ((short) pEnd
->GetValue ());
528 pAttr
->Put (XFillStyleItem (drawing::FillStyle_GRADIENT
), XATTR_FILLSTYLE
);
529 pAttr
->Put (XFillGradientItem (pName
->GetValue (), aGradient
), XATTR_FILLGRADIENT
);
536 Color
aBlack (0, 0, 0);
537 XGradient
aGradient (aBlack
, aBlack
, (css::awt::GradientStyle
) pStyle
->GetValue (),
538 pAngle
->GetValue () * 10, (short) pCenterX
->GetValue (),
539 (short) pCenterY
->GetValue (), (short) pBorder
->GetValue (),
540 (short) pStart
->GetValue (), (short) pEnd
->GetValue ());
542 pGradientList
->Insert (new XGradientEntry (aGradient
, pName
->GetValue ()));
543 pAttr
->Put (XFillStyleItem (drawing::FillStyle_GRADIENT
), XATTR_FILLSTYLE
);
544 pAttr
->Put (XFillGradientItem (pName
->GetValue (), aGradient
), XATTR_FILLGRADIENT
);
547 rBindings
.Invalidate (SID_ATTR_FILL_GRADIENT
);
548 rBindings
.Invalidate (SID_ATTR_FILL_STYLE
);
550 #if HAVE_FEATURE_SCRIPTING
551 else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE
);
555 #if HAVE_FEATURE_SCRIPTING
556 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
560 // configuration for hatch
563 if (pArgs
->Count () == 4)
565 SFX_REQUEST_ARG (rReq
, pName
, SfxStringItem
, ID_VAL_INDEX
, false);
566 SFX_REQUEST_ARG (rReq
, pStyle
, SfxUInt32Item
, ID_VAL_STYLE
, false);
567 SFX_REQUEST_ARG (rReq
, pDistance
, SfxUInt32Item
, ID_VAL_DISTANCE
, false);
568 SFX_REQUEST_ARG (rReq
, pAngle
, SfxUInt32Item
, ID_VAL_ANGLE
, false);
570 if (CHECK_RANGE (css::drawing::HatchStyle_SINGLE
, (sal_Int32
)pStyle
->GetValue (), css::drawing::HatchStyle_TRIPLE
) &&
571 CHECK_RANGE (0, (sal_Int32
)pAngle
->GetValue (), 360))
573 pAttr
->ClearItem (XATTR_FILLHATCH
);
574 pAttr
->ClearItem (XATTR_FILLSTYLE
);
576 XHatchListRef pHatchList
= GetDoc()->GetHatchList ();
577 long nCounts
= pHatchList
->Count ();
580 for ( i
= 0; i
< nCounts
; i
++ )
582 XHatchEntry
*pEntry
= pHatchList
->GetHatch (i
);
584 if (pEntry
->GetName () == pName
->GetValue ())
586 XHatch
aHatch(pEntry
->GetHatch());
588 aHatch
.SetHatchStyle ((css::drawing::HatchStyle
) pStyle
->GetValue ());
589 aHatch
.SetDistance (pDistance
->GetValue ());
590 aHatch
.SetAngle (pAngle
->GetValue () * 10);
592 pAttr
->Put (XFillStyleItem (drawing::FillStyle_HATCH
), XATTR_FILLSTYLE
);
593 pAttr
->Put (XFillHatchItem (pName
->GetValue (), aHatch
), XATTR_FILLHATCH
);
600 Color
aBlack (0, 0, 0);
601 XHatch
aHatch (aBlack
, (css::drawing::HatchStyle
) pStyle
->GetValue (), pDistance
->GetValue (),
602 pAngle
->GetValue () * 10);
604 pHatchList
->Insert (new XHatchEntry (aHatch
, pName
->GetValue ()));
605 pAttr
->Put (XFillStyleItem (drawing::FillStyle_HATCH
), XATTR_FILLSTYLE
);
606 pAttr
->Put (XFillHatchItem (pName
->GetValue (), aHatch
), XATTR_FILLHATCH
);
609 rBindings
.Invalidate (SID_ATTR_FILL_HATCH
);
610 rBindings
.Invalidate (SID_ATTR_FILL_STYLE
);
612 #if HAVE_FEATURE_SCRIPTING
613 else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE
);
617 #if HAVE_FEATURE_SCRIPTING
618 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
622 case SID_SELECTGRADIENT
:
624 if (pArgs
->Count () == 1)
626 SFX_REQUEST_ARG (rReq
, pName
, SfxStringItem
, ID_VAL_INDEX
, false);
628 XGradientListRef pGradientList
= GetDoc()->GetGradientList ();
629 long nCounts
= pGradientList
->Count ();
635 XGradientEntry
*pEntry
= pGradientList
->GetGradient (i
);
637 if (pEntry
->GetName () == pName
->GetValue ())
639 pAttr
->ClearItem (XATTR_FILLGRADIENT
);
640 pAttr
->ClearItem (XATTR_FILLSTYLE
);
641 pAttr
->Put (XFillStyleItem (drawing::FillStyle_GRADIENT
), XATTR_FILLSTYLE
);
642 pAttr
->Put (XFillGradientItem (pName
->GetValue (), pEntry
->GetGradient ()), XATTR_FILLGRADIENT
);
644 rBindings
.Invalidate (SID_ATTR_FILL_GRADIENT
);
645 rBindings
.Invalidate (SID_ATTR_FILL_STYLE
);
652 #if HAVE_FEATURE_SCRIPTING
653 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
657 case SID_SELECTHATCH
:
659 if (pArgs
->Count () == 1)
661 SFX_REQUEST_ARG (rReq
, pName
, SfxStringItem
, ID_VAL_INDEX
, false);
663 XHatchListRef pHatchList
= GetDoc()->GetHatchList ();
664 long nCounts
= pHatchList
->Count ();
670 XHatchEntry
*pEntry
= pHatchList
->GetHatch (i
);
672 if (pEntry
->GetName () == pName
->GetValue ())
674 pAttr
->ClearItem (XATTR_FILLHATCH
);
675 pAttr
->ClearItem (XATTR_FILLSTYLE
);
676 pAttr
->Put (XFillStyleItem (drawing::FillStyle_HATCH
), XATTR_FILLSTYLE
);
677 pAttr
->Put (XFillHatchItem (pName
->GetValue (), pEntry
->GetHatch ()), XATTR_FILLHATCH
);
679 rBindings
.Invalidate (SID_ATTR_FILL_HATCH
);
680 rBindings
.Invalidate (SID_ATTR_FILL_STYLE
);
687 #if HAVE_FEATURE_SCRIPTING
688 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
693 mpDrawView
->UnmarkAll ();
698 if (pArgs
->Count () == 1)
702 #if HAVE_FEATURE_SCRIPTING
703 StarBASIC::FatalError (SbERR_WRONG_ARGS
);
707 /* case SID_SETFONTFAMILYNAME :
708 case SID_SETFONTSTYLENAME :
709 case SID_SETFONTFAMILY :
710 case SID_SETFONTPITCH :
711 case SID_SETFONTCHARSET :
712 case SID_SETFONTPOSTURE :
713 case SID_SETFONTWEIGHT :
714 case SID_SETFONTUNDERLINE :
715 case SID_SETFONTCROSSEDOUT :
716 case SID_SETFONTSHADOWED :
717 case SID_SETFONTCONTOUR :
718 case SID_SETFONTCOLOR :
719 case SID_SETFONTLANGUAGE :
720 case SID_SETFONTWORDLINE :
721 case SID_SETFONTCASEMAP :
722 case SID_SETFONTESCAPE :
723 case SID_SETFONTKERNING :
730 mpDrawView
->SetAttributes (*(const SfxItemSet
*) pAttr
.get());
735 * Edit macros for attribute configuration
737 void DrawViewShell::AttrState (SfxItemSet
& rSet
)
739 SfxWhichIter
aIter (rSet
);
740 sal_uInt16 nWhich
= aIter
.FirstWhich ();
741 SfxItemSet
aAttr( GetDoc()->GetPool() );
742 mpDrawView
->GetAttributes( aAttr
);
748 case SID_GETFILLSTYLE
:
750 const XFillStyleItem
&rFillStyleItem
= static_cast<const XFillStyleItem
&>(aAttr
.Get (XATTR_FILLSTYLE
));
752 rSet
.Put (SfxUInt32Item (nWhich
, (long) rFillStyleItem
.GetValue ()));
756 case SID_GETLINESTYLE
:
758 const XLineStyleItem
&rLineStyleItem
= static_cast<const XLineStyleItem
&>( aAttr
.Get (XATTR_LINESTYLE
) );
760 rSet
.Put (SfxUInt32Item (nWhich
, (long) rLineStyleItem
.GetValue ()));
764 case SID_GETLINEWIDTH
:
766 const XLineWidthItem
&rLineWidthItem
= static_cast<const XLineWidthItem
&>( aAttr
.Get (XATTR_LINEWIDTH
) );
768 rSet
.Put (SfxUInt32Item (nWhich
, (long) rLineWidthItem
.GetValue ()));
776 const SfxUInt32Item
&rWhatKind
= static_cast<const SfxUInt32Item
&>( rSet
.Get (ID_VAL_WHATKIND
) );
779 switch (rWhatKind
.GetValue ())
783 const XLineColorItem
&rLineColorItem
= static_cast<const XLineColorItem
&>( aAttr
.Get (XATTR_LINECOLOR
) );
785 aColor
= rLineColorItem
.GetColorValue ();
791 const XFillColorItem
&rFillColorItem
= static_cast<const XFillColorItem
&>( aAttr
.Get (XATTR_FILLCOLOR
) );
793 aColor
= rFillColorItem
.GetColorValue ();
800 const XFillGradientItem
&rFillGradientItem
= static_cast<const XFillGradientItem
&>( aAttr
.Get (XATTR_FILLGRADIENT
) );
801 const XGradient
&rGradient
= rFillGradientItem
.GetGradientValue ();
803 aColor
= (rWhatKind
.GetValue () == 3)
804 ? rGradient
.GetStartColor ()
805 : rGradient
.GetEndColor ();
811 const XFillHatchItem
&rFillHatchItem
= static_cast<const XFillHatchItem
&>( aAttr
.Get (XATTR_FILLHATCH
) );
812 const XHatch
&rHatch
= rFillHatchItem
.GetHatchValue ();
814 aColor
= rHatch
.GetColor ();
822 rSet
.Put (SfxUInt32Item (nWhich
, (long) ((nWhich
== SID_GETRED
)
824 : (nWhich
== SID_GETGREEN
)
826 : aColor
.GetBlue ())));
834 nWhich
= aIter
.NextWhich ();
838 } // end of namespace sd
840 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */