20#include <config_features.h>
38#include <svx/svxids.hrc>
52#include <drawview.hxx>
57#include <com/sun/star/gallery/GalleryItemType.hpp>
58#include <com/sun/star/drawing/LineStyle.hpp>
73 const SvxGalleryItem* pGalleryItem = SfxItemSet::GetItem<SvxGalleryItem>(pArgs, SID_GALLERY_FORMATS,
false);
81 if (
nType == css::gallery::GalleryItemType::GRAPHIC)
89 aWindow->SetMapMode(
MapMode(MapUnit::Map100thMM) );
90 Size aSize = aWindow->PixelToLogic(aSizePix);
102 float fGrfWH =
static_cast<float>(aSize.
Width()) /
103 static_cast<float>(aSize.
Height());
104 float fWinWH =
static_cast<float>(aPageSize.
Width()) /
105 static_cast<float>(aPageSize.
Height());
108 if ((fGrfWH != 0.F) && (fGrfWH < fWinWH))
128 bool bInsertNewObject =
true;
144 if( pGrafObj->IsEmptyPresObj() )
147 bInsertNewObject =
false;
150 pNewGrafObj->SetEmptyPresObj(
false);
151 pNewGrafObj->SetOutlinerParaObject(std::nullopt);
152 pNewGrafObj->SetGraphic(aGraphic);
155 " " +
SdResId(STR_UNDO_REPLACE);
158 mpDrawView->ReplaceObjectAtView(pGrafObj.get(), *pPV, pNewGrafObj.get());
165 if( bInsertNewObject )
168 GetView()->getSdrModelFromSdrView(),
172 mpDrawView->InsertObjectAtView(pGrafObj.get(), *pPV, SdrInsertFlags::SETDEFLAYER);
176 else if(
nType == css::gallery::GalleryItemType::MEDIA )
180 SfxCallMode::SYNCHRON, { &aMediaURLItem });
213 case SID_SETFILLSTYLE :
214 if (pArgs && pArgs->
Count () == 1)
217 if (
CHECK_RANGE (drawing::FillStyle_NONE,
static_cast<drawing::FillStyle
>(pFillStyle->
GetValue ()), drawing::FillStyle_BITMAP))
222 aAttr.
Put (aStyleItem);
224 rBindings.
Invalidate (SID_ATTR_PAGE_FILLSTYLE);
226#if HAVE_FEATURE_SCRIPTING
231#if HAVE_FEATURE_SCRIPTING
237 case SID_SETLINESTYLE :
238 if (pArgs && pArgs->
Count () == 1)
241 if (
CHECK_RANGE (sal_Int32(drawing::LineStyle_NONE),
static_cast<sal_Int32
>(pLineStyle->
GetValue()), sal_Int32(drawing::LineStyle_DASH)))
246 aAttr.
Put(aStyleItem);
249#if HAVE_FEATURE_SCRIPTING
254#if HAVE_FEATURE_SCRIPTING
260 case SID_SETLINEWIDTH :
261 if (pArgs && pArgs->
Count () == 1)
267 aAttr.
Put(aWidthItem);
271#if HAVE_FEATURE_SCRIPTING
276 case SID_SETFILLCOLOR :
277 if (pArgs && pArgs->
Count () == 3)
286 static_cast<sal_uInt8>(pGreen->GetValue ()),
287 static_cast<sal_uInt8>(pBlue->GetValue ())));
289 aAttr.
Put(aColorItem);
293 rBindings.
Invalidate (SID_ATTR_PAGE_FILLSTYLE);
296#if HAVE_FEATURE_SCRIPTING
301 case SID_SETLINECOLOR :
302 if (pArgs && pArgs->
Count () == 3)
310 static_cast<sal_uInt8>(pGreen->GetValue()),
311 static_cast<sal_uInt8>(pBlue->GetValue())));
313 aAttr.
Put(aColorItem);
317#if HAVE_FEATURE_SCRIPTING
322 case SID_SETGRADSTARTCOLOR :
323 case SID_SETGRADENDCOLOR :
324 if (pArgs && pArgs->
Count () == 4)
330 assert(
pName && pRed && pGreen && pBlue &&
"must be present");
335 static_cast<sal_uInt8>(pGreen->GetValue ()),
336 static_cast<sal_uInt8>(pBlue->GetValue ()));
342 for (
i = 0;
i < nCounts;
i ++)
351 if (SID_SETGRADSTARTCOLOR == rReq.
GetSlot ())
364 aAttr.
Put(aStyleItem);
367 aAttr.
Put(aGradientItem);
374 Color aBlack (0, 0, 0);
377 (rReq.
GetSlot () == SID_SETGRADSTARTCOLOR)
380 (rReq.
GetSlot () == SID_SETGRADENDCOLOR)
388 aAttr.
Put(aStyleItem);
391 aAttr.
Put(aGradientItem);
395 rBindings.
Invalidate (SID_ATTR_PAGE_FILLSTYLE);
396 rBindings.
Invalidate (SID_ATTR_FILL_GRADIENT);
397 rBindings.
Invalidate (SID_ATTR_PAGE_GRADIENT);
400#if HAVE_FEATURE_SCRIPTING
405 case SID_SETHATCHCOLOR :
406 if (pArgs && pArgs->
Count () == 4)
412 assert(
pName && pRed && pGreen && pBlue &&
"must be present");
417 static_cast<sal_uInt8>(pGreen->GetValue ()),
418 static_cast<sal_uInt8>(pBlue->GetValue ()));
424 for (
i = 0;
i < nCounts;
i ++)
436 aAttr.
Put(aStyleItem);
439 aAttr.
Put(aHatchItem);
452 aAttr.
Put(aStyleItem);
455 aAttr.
Put(aHatchItem);
461 rBindings.
Invalidate (SID_ATTR_PAGE_FILLSTYLE);
464#if HAVE_FEATURE_SCRIPTING
471 if (pArgs && pArgs->
Count () == 7)
480 assert(
pName && pStyle && pDots && pDotLen && pDashes && pDashLen && pDistance &&
"must be present");
482 if (
CHECK_RANGE (sal_Int32(css::drawing::DashStyle_RECT),
static_cast<sal_Int32
>(pStyle->GetValue()), sal_Int32(css::drawing::DashStyle_ROUNDRELATIVE)))
484 XDash aNewDash (
static_cast<css::drawing::DashStyle
>(pStyle->GetValue ()),
static_cast<short>(pDots->GetValue ()), pDotLen->GetValue (),
485 static_cast<short>(pDashes->GetValue ()), pDashLen->GetValue (), pDistance->GetValue ());
492 std::unique_ptr<XDashEntry> pEntry = std::make_unique<XDashEntry>(aNewDash,
pName->GetValue());
495 for (
i = 0;
i < nCounts;
i++ )
496 if (pDashList->GetDash (
i)->GetName () ==
pName->GetValue ())
500 pDashList->Replace(std::move(pEntry),
i);
502 pDashList->Insert(std::move(pEntry));
506 aAttr.
Put(aDashItem);
509 aAttr.
Put(aStyleItem);
513#if HAVE_FEATURE_SCRIPTING
518#if HAVE_FEATURE_SCRIPTING
525 if (pArgs && pArgs->
Count () == 8)
535 assert(
pName && pStyle && pAngle && pBorder && pCenterX && pCenterY && pStart && pEnd &&
"must be present");
537 if (
CHECK_RANGE (sal_Int32(css::awt::GradientStyle_LINEAR),
static_cast<sal_Int32
>(pStyle->GetValue()), sal_Int32(css::awt::GradientStyle_RECT)) &&
538 CHECK_RANGE (0,
static_cast<sal_Int32
>(pAngle->GetValue ()), 360) &&
539 CHECK_RANGE (0,
static_cast<sal_Int32
>(pBorder->GetValue ()), 100) &&
540 CHECK_RANGE (0,
static_cast<sal_Int32
>(pCenterX->GetValue ()), 100) &&
541 CHECK_RANGE (0,
static_cast<sal_Int32
>(pCenterY->GetValue ()), 100) &&
542 CHECK_RANGE (0,
static_cast<sal_Int32
>(pStart->GetValue ()), 100) &&
543 CHECK_RANGE (0,
static_cast<sal_Int32
>(pEnd->GetValue ()), 100))
552 for (
i = 0;
i < nCounts;
i++ )
560 aGradient.
SetGradientStyle (
static_cast<css::awt::GradientStyle
>(pStyle->GetValue ()));
562 aGradient.
SetBorder (
static_cast<short>(pBorder->GetValue ()));
563 aGradient.
SetXOffset (
static_cast<short>(pCenterX->GetValue ()));
564 aGradient.
SetYOffset (
static_cast<short>(pCenterY->GetValue ()));
565 aGradient.
SetStartIntens (
static_cast<short>(pStart->GetValue ()));
566 aGradient.
SetEndIntens (
static_cast<short>(pEnd->GetValue ()));
570 aAttr.
Put(aStyleItem);
573 aAttr.
Put(aGradientItem);
580 Color aBlack (0, 0, 0);
583 static_cast<css::awt::GradientStyle
>(pStyle->GetValue ()),
584 Degree10(pAngle->GetValue () * 10),
static_cast<short>(pCenterX->GetValue ()),
585 static_cast<short>(pCenterY->GetValue ()),
static_cast<short>(pBorder->GetValue ()),
586 static_cast<short>(pStart->GetValue ()),
static_cast<short>(pEnd->GetValue ()));
588 pGradientList->Insert(std::make_unique<XGradientEntry>(aGradient,
pName->GetValue()));
591 aAttr.
Put(aStyleItem);
594 aAttr.
Put(aGradientItem);
597 rBindings.
Invalidate (SID_ATTR_FILL_GRADIENT);
598 rBindings.
Invalidate (SID_ATTR_PAGE_GRADIENT);
600 rBindings.
Invalidate (SID_ATTR_PAGE_FILLSTYLE);
602#if HAVE_FEATURE_SCRIPTING
607#if HAVE_FEATURE_SCRIPTING
614 if (pArgs && pArgs->
Count () == 4)
620 assert(
pName && pStyle && pDistance && pAngle &&
"must be present");
622 if (
CHECK_RANGE (sal_Int32(css::drawing::HatchStyle_SINGLE),
static_cast<sal_Int32
>(pStyle->GetValue()), sal_Int32(css::drawing::HatchStyle_TRIPLE)) &&
623 CHECK_RANGE (0,
static_cast<sal_Int32
>(pAngle->GetValue ()), 360))
632 for (
i = 0;
i < nCounts;
i++ )
640 aHatch.
SetHatchStyle (
static_cast<css::drawing::HatchStyle
>(pStyle->GetValue ()));
646 aAttr.
Put(aStyleItem);
649 aAttr.
Put(aHatchItem);
656 XHatch aHatch (
Color(0),
static_cast<css::drawing::HatchStyle
>(pStyle->GetValue ()), pDistance->GetValue (),
657 Degree10(pAngle->GetValue () * 10));
659 pHatchList->Insert(std::make_unique<XHatchEntry>(aHatch,
pName->GetValue()));
662 aAttr.
Put(aStyleItem);
665 aAttr.
Put(aHatchItem);
671#if HAVE_FEATURE_SCRIPTING
676#if HAVE_FEATURE_SCRIPTING
681 case SID_SELECTGRADIENT :
682 if (pArgs && (pArgs->
Count() == 1))
685 assert(
pName &&
"must be present");
700 aAttr.
Put(aStyleItem);
703 aAttr.
Put(aGradientItem);
704 rBindings.
Invalidate (SID_ATTR_FILL_GRADIENT);
705 rBindings.
Invalidate (SID_ATTR_PAGE_GRADIENT);
707 rBindings.
Invalidate (SID_ATTR_PAGE_FILLSTYLE);
714#if HAVE_FEATURE_SCRIPTING
719 case SID_SELECTHATCH :
720 if (pArgs && pArgs->
Count() == 1)
723 assert(
pName &&
"must be present");
738 aAttr.
Put(aStyleItem);
741 aAttr.
Put(aHatchItem);
746 rBindings.
Invalidate (SID_ATTR_PAGE_FILLSTYLE);
753#if HAVE_FEATURE_SCRIPTING
763 if (pArgs && pArgs->
Count () == 1)
767#if HAVE_FEATURE_SCRIPTING
813 case SID_GETFILLSTYLE :
821 case SID_GETLINESTYLE :
829 case SID_GETLINEWIDTH :
868 aColor = (rWhatKind.
GetValue () == 3)
889 : (nWhich == SID_GETGREEN)
#define CHECK_RANGE(nMin, nValue, nMax)
sal_uInt32 GetValue() const
sal_uInt8 GetBlue() const
basegfx::BColor getBColor() const
sal_uInt8 GetGreen() const
MapMode GetPrefMapMode() const
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
SdrObject * GetMarkedSdrObj() const
XDashListRef GetDashList() const
XGradientListRef GetGradientList() const
XHatchListRef GetHatchList() const
virtual SdrInventor GetObjInventor() const
static rtl::Reference< T > Clone(T const &rObj, SdrModel &rTargetModel)
virtual SdrObjKind GetObjIdentifier() const
sal_Int32 GetUpperBorder() const
sal_Int32 GetRightBorder() const
sal_Int32 GetLeftBorder() const
sal_Int32 GetLowerBorder() const
void Invalidate(sal_uInt16 nId)
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void SetWaitCursor(bool bSet) const
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
const T * GetArg(sal_uInt16 nSlotId) const
SfxItemPool & GetPool() const
SfxBindings & GetBindings()
SfxDispatcher * GetDispatcher()
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
static void FatalError(ErrCode)
const OUString & GetURL() const
const css::uno::Reference< css::graphic::XGraphic > & GetGraphic() const
const Color & GetColorValue() const
const basegfx::BGradient & GetGradientValue() const
const XHatch & GetHatchValue() const
const basegfx::BGradient & GetGradient() const
const XHatch & GetHatch() const
const Color & GetColor() const
void SetDistance(tools::Long nNewDistance)
void SetHatchStyle(css::drawing::HatchStyle eNewStyle)
void SetColor(const Color &rColor)
void SetAngle(Degree10 nNewAngle)
const OUString & GetName() const
void replaceEndColor(const BColor &rEnd)
void replaceStartColor(const BColor &rStart)
void SetGradientStyle(css::awt::GradientStyle eNewStyle)
void SetColorStops(const basegfx::BColorStops &rSteps)
void SetEndIntens(sal_uInt16 nNewIntens)
void SetYOffset(sal_uInt16 nNewOffset)
void SetXOffset(sal_uInt16 nNewOffset)
void SetBorder(sal_uInt16 nNewBorder)
const basegfx::BColorStops & GetColorStops() const
void SetStartIntens(sal_uInt16 nNewIntens)
void SetAngle(Degree10 nNewAngle)
static void CheckLineTo(SfxRequest &rReq)
check if we have to draw a polyline
std::unique_ptr< DrawView > mpDrawView
void AttrExec(SfxRequest &rReq)
Edit macros for attribute configuration.
void ExecGallery(SfxRequest const &rReq)
void AttrState(SfxItemSet &rSet)
Edit macros for attribute configuration.
SD_DLLPUBLIC DrawDocShell * GetDocSh() const
SdDrawDocument * GetDoc() const
::sd::Window * GetActiveWindow() const
The active window is usually the mpContentWindow.
::sd::View * GetView() const
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
bool HasCurrentFunction() const
virtual void GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr=false) const
#define ERRCODE_BASIC_BAD_PROP_VALUE
#define ERRCODE_BASIC_WRONG_ARGS
OUString SdResId(TranslateId aId)
constexpr TypedWhichId< XFillColorItem > XATTR_FILLCOLOR(XATTR_FILL_FIRST+1)
constexpr TypedWhichId< XLineColorItem > XATTR_LINECOLOR(XATTR_LINE_FIRST+3)
constexpr TypedWhichId< XLineDashItem > XATTR_LINEDASH(XATTR_LINE_FIRST+1)
constexpr TypedWhichId< XLineWidthItem > XATTR_LINEWIDTH(XATTR_LINE_FIRST+2)
constexpr TypedWhichId< XFillHatchItem > XATTR_FILLHATCH(XATTR_FILL_FIRST+3)
constexpr TypedWhichId< XLineStyleItem > XATTR_LINESTYLE(XATTR_LINE_FIRST)
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)
constexpr TypedWhichId< XFillGradientItem > XATTR_FILLGRADIENT(XATTR_FILL_FIRST+2)