37#include <svx/dialogs.hrc>
38#include <svx/svxids.hrc>
39#include <svx/strings.hrc>
57#include <bitmaps.hlst>
59#include <com/sun/star/frame/XDispatchProvider.hpp>
68#define RID_SVXSTR_UNDO_GRAFCROP RID_SVXSTR_GRAFCROP
76 Reference<XFrame> mxFrame;
77 std::unique_ptr<weld::Image> mxImage;
78 std::unique_ptr<weld::MetricSpinButton> mxField;
85 ImplGrafControl(
vcl::Window* pParent,
const OUString& rCmd,
const Reference< XFrame >& rFrame );
86 virtual ~ImplGrafControl()
override;
87 virtual void dispose()
override;
90 void set_field_text(
const OUString& rStr) { mxField->set_text(rStr); }
91 void set_sensitive(
bool bSensitive)
94 mxImage->set_sensitive(bSensitive);
95 mxField->set_sensitive(bSensitive);
106void ImplGrafControl::ImplModify()
108 const sal_Int64 nVal = mxField->get_value(FieldUnit::NONE);
112 if ( maCommand ==
".uno:GrafRed" ||
113 maCommand ==
".uno:GrafGreen" ||
114 maCommand ==
".uno:GrafBlue" ||
115 maCommand ==
".uno:GrafLuminance" ||
116 maCommand ==
".uno:GrafContrast" )
117 a <<= sal_Int16( nVal );
118 else if ( maCommand ==
".uno:GrafGamma" ||
119 maCommand ==
".uno:GrafTransparence" )
120 a <<= sal_Int32( nVal );
130 Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
135void ImplGrafControl::Update(
const SfxPoolItem* pItem )
141 if ( maCommand ==
".uno:GrafTransparence" )
143 else if ( maCommand ==
".uno:GrafGamma" )
148 mxField->set_value(
nValue, FieldUnit::NONE);
151 mxField->set_text(OUString());
158 const char* pCommand;
159 rtl::OUStringConstExpr sResId;
166 static constexpr OUStringLiteral
EMPTY =
u"";
167 static const CommandToRID aImplCommandToResMap[] =
169 {
".uno:GrafRed", RID_SVXBMP_GRAF_RED },
170 {
".uno:GrafGreen", RID_SVXBMP_GRAF_GREEN },
171 {
".uno:GrafBlue", RID_SVXBMP_GRAF_BLUE },
172 {
".uno:GrafLuminance", RID_SVXBMP_GRAF_LUMINANCE },
173 {
".uno:GrafContrast", RID_SVXBMP_GRAF_CONTRAST },
174 {
".uno:GrafGamma", RID_SVXBMP_GRAF_GAMMA },
175 {
".uno:GrafTransparence", RID_SVXBMP_GRAF_TRANSPARENCE },
182 while ( aImplCommandToResMap[
i ].pCommand )
186 sRID = aImplCommandToResMap[
i].sResId;
195ImplGrafControl::ImplGrafControl(
197 const OUString& rCmd,
198 const Reference< XFrame >& rFrame)
202 , mxImage(m_xBuilder->weld_image(
"image"))
203 , mxField(m_xBuilder->weld_metric_spin_button(
"spinfield",
FieldUnit::
NONE))
205 InitControlBase(&mxField->get_widget());
208 mxImage->set_from_icon_name(sResId);
209 mxImage->set_toolbar_background();
213 mxField->set_help_id(rCmd);
214 mxField->get_widget().connect_key_press(
LINK(
this, ImplGrafControl, KeyInputHdl));
215 mxField->connect_value_changed(
LINK(
this, ImplGrafControl, ValueChangedHdl));
217 if (maCommand ==
".uno:GrafGamma")
219 mxField->set_digits(2);
221 mxField->set_range(10, 1000, FieldUnit::NONE);
222 mxField->set_increments(10, 100, FieldUnit::NONE);
226 const tools::Long nMinVal = maCommand ==
".uno:GrafTransparence" ? 0 : -100;
228 mxField->set_unit(FieldUnit::PERCENT);
229 mxField->set_digits(0);
231 mxField->set_range(nMinVal, 100, FieldUnit::PERCENT);
232 mxField->set_increments(1, 10, FieldUnit::PERCENT);
240 return ChildKeyInput(rKEvt);
243ImplGrafControl::~ImplGrafControl()
248void ImplGrafControl::dispose()
261 Reference< XFrame > mxFrame;
262 std::unique_ptr<weld::ComboBox>
m_xWidget;
268 static void ImplReleaseFocus();
271 ImplGrafModeControl(
vcl::Window* pParent,
const Reference< XFrame >& rFrame );
272 virtual void dispose()
override;
273 virtual ~ImplGrafModeControl()
override;
275 void set_sensitive(
bool bSensitive)
281 void set_active(
int nActive)
291ImplGrafModeControl::ImplGrafModeControl(
vcl::Window* pParent,
const Reference<XFrame>& rFrame)
295 ,
m_xWidget(m_xBuilder->weld_combo_box(
"grafmode"))
304 m_xWidget->connect_changed(
LINK(
this, ImplGrafModeControl, SelectHdl));
305 m_xWidget->connect_key_press(
LINK(
this, ImplGrafModeControl, KeyInputHdl));
306 m_xWidget->connect_focus_in(
LINK(
this, ImplGrafModeControl, FocusInHdl));
308 SetSizePixel(
m_xWidget->get_preferred_size());
311void ImplGrafModeControl::dispose()
317ImplGrafModeControl::~ImplGrafModeControl()
325 sal_Int16(rBox.get_active())) };
333 Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
340 bool bHandled(
false);
342 if (rKEvt.GetKeyCode().GetCode() ==
KEY_ESCAPE)
349 return bHandled || ChildKeyInput(rKEvt);
357void ImplGrafModeControl::ImplReleaseFocus()
368void ImplGrafModeControl::Update(
const SfxPoolItem* pItem )
392 if( eState == SfxItemState::DISABLED )
394 pCtrl->set_sensitive(
false);
395 pCtrl->set_field_text( OUString() );
399 pCtrl->set_sensitive(
true);
401 if( eState == SfxItemState::DEFAULT )
402 pCtrl->Update( pState );
404 pCtrl->Update(
nullptr );
479 if( eState == SfxItemState::DISABLED )
481 pCtrl->set_sensitive(
false);
482 pCtrl->set_active(-1);
486 pCtrl->set_sensitive(
true);
488 if( eState == SfxItemState::DEFAULT )
489 pCtrl->Update( pState );
491 pCtrl->Update(
nullptr );
514 sal_uInt16 nSlot = rReq.
GetSlot();
516 if( !pArgs || SfxItemState::SET != pArgs->
GetItemState( nSlot,
false, &pItem ))
521 case SID_ATTR_GRAF_RED:
527 aUndoStr +=
SvxResId( RID_SVXSTR_UNDO_GRAFRED );
532 case SID_ATTR_GRAF_GREEN:
538 aUndoStr +=
SvxResId( RID_SVXSTR_UNDO_GRAFGREEN );
543 case SID_ATTR_GRAF_BLUE:
549 aUndoStr +=
SvxResId( RID_SVXSTR_UNDO_GRAFBLUE );
554 case SID_ATTR_GRAF_LUMINANCE:
560 aUndoStr +=
SvxResId( RID_SVXSTR_UNDO_GRAFLUMINANCE );
565 case SID_ATTR_GRAF_CONTRAST:
571 aUndoStr +=
SvxResId( RID_SVXSTR_UNDO_GRAFCONTRAST );
576 case SID_ATTR_GRAF_GAMMA:
582 aUndoStr +=
SvxResId( RID_SVXSTR_UNDO_GRAFGAMMA );
587 case SID_ATTR_GRAF_TRANSPARENCE:
593 aUndoStr +=
SvxResId( RID_SVXSTR_UNDO_GRAFTRANSPARENCY );
598 case SID_ATTR_GRAF_MODE:
604 aUndoStr +=
SvxResId( RID_SVXSTR_UNDO_GRAFMODE );
609 case SID_ATTR_GRAF_CROP:
628 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
629 SID_ATTR_GRAF_CROP, SID_ATTR_GRAF_FRMSIZE,
630 SID_ATTR_GRAF_GRAPHIC, SID_ATTR_GRAF_GRAPHIC>
636 aCropDlgAttr.Put(
SvxSizeItem( SID_ATTR_GRAF_FRMSIZE,
643 aCropDlgAttr.Put( SdrGrafCropItem( aLTSize.
Width(), aLTSize.
Height(),
649 const OUString aCropStr(
SvxResId(RID_SVXSTR_GRAFCROP));
653 std::unique_ptr<SfxTabPage> xTabPage = (*fnCreatePage)(aCropDialog.
get_content_area(), &aCropDialog, &aCropDlgAttr);
655 xTabPage->getAdditionalProperties().emplace(
"PreferredDPI", css::uno::Any(nPreferredDPI));
656 xTabPage->SetPageTitle(aCropStr);
659 if (aCropDialog.run() ==
RET_OK)
678 if( SfxItemState::SET <= pOutAttr->GetItemState( SID_ATTR_GRAF_FRMSIZE ) )
681 const Size& rGrfSize = pOutAttr->
Get( SID_ATTR_GRAF_FRMSIZE ).GetSize();
713 aPol.
Move( -aOffset.
X(), -aOffset.
Y() );
718 aNewRect.
Move( -aOffset.
X(), -aOffset.
Y() );
747 case SID_COLOR_SETTINGS:
778 bool bEnableColors =
true;
779 bool bEnableTransparency =
true;
790 bEnableColors = bEnableTransparency = bEnableCrop =
false;
795 bEnableTransparency =
false;
807 case SID_ATTR_GRAF_MODE:
824 case SID_ATTR_GRAF_RED:
840 case SID_ATTR_GRAF_GREEN:
856 case SID_ATTR_GRAF_BLUE:
872 case SID_ATTR_GRAF_LUMINANCE:
888 case SID_ATTR_GRAF_CONTRAST:
905 case SID_ATTR_GRAF_GAMMA:
922 case SID_ATTR_GRAF_TRANSPARENCE:
926 if( bEnableTransparency )
939 case SID_ATTR_GRAF_CROP:
946 case SID_COLOR_SETTINGS :
css::uno::Reference< css::lang::XComponent > m_xFrame
The transformation of a rectangle into a polygon, by using angle parameters from GeoStat.
double mfCosRotationAngle
double mfSinRotationAngle
Degree100 m_nRotationAngle
virtual void dispose() override
constexpr tools::Long Y() const
constexpr tools::Long X() const
bool IsUndoEnabled() const
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
void SetMarkedObjRect(const tools::Rectangle &rRect)
This class represents an embedded or linked bitmap graphic object.
bool HasGDIMetaFile() const
const Graphic & GetGraphic() const
GraphicType GetGraphicType() const
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
const SdrMarkList & GetMarkedObjectList() const
OUString const & GetDescriptionOfMarkedObjects() const
SdrObject * GetMarkedSdrObj() const
const SfxItemPool & GetItemPool() const
virtual sal_Int32 getImagePreferredDPI() const
SdrUndoFactory & GetSdrUndoFactory() const
returns the models undo factory.
virtual void SetSnapRect(const tools::Rectangle &rRect)
const SfxItemSet & GetMergedItemSet() const
SdrModel & getSdrModelFromSdrView() const
SdrModel & GetModel() const
virtual const tools::Rectangle & GetLogicRect() const override
const GeoStat & GetGeoStat() const
virtual std::unique_ptr< SdrUndoAction > CreateUndoGeoObject(SdrObject &rObject)
bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll=false)
void GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr=false) const
static SfxAbstractDialogFactory * Create()
virtual CreateTabPage GetTabPageCreatorFunc(sal_uInt16 nId)=0
sal_uInt16 GetSlotId(sal_uInt16 nWhich) const
static bool IsWhich(sal_uInt16 nId)
void SetDefaultMetric(MapUnit eNewMetric)
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void DisableItem(sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
void Done(bool bRemove=false)
const SfxItemSet * GetOutputItemSet() const
void SetTabPage(std::unique_ptr< SfxTabPage > xTabPage)
weld::Container * get_content_area()
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
vcl::Window * GetWindow() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
static void ExecuteGrafAttr(SfxRequest &rReq, SdrView &rView)
static void GetGrafAttrState(SfxItemSet &rSet, SdrView const &rView)
static VclPtr< reference_type > Create(Arg &&... arg)
void Enable(bool bEnable=true, bool bChild=true)
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
weld::Window * GetFrameWeld() const
#define DBG_ASSERT(sCon, aError)
OUString SvxResId(TranslateId aId)
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
IMPL_LINK_NOARG(ImplGrafControl, ValueChangedHdl, weld::MetricSpinButton &, void)
SFX_IMPL_TOOLBOX_CONTROL(SvxGrafRedToolBoxControl, SfxInt16Item)
constexpr OUStringLiteral TOOLBOX_NAME
static OUString ImplGetRID(std::u16string_view aCommand)
#define RID_SVXSTR_UNDO_GRAFCROP
IMPL_LINK(ImplGrafControl, KeyInputHdl, const KeyEvent &, rKEvt, bool)
constexpr sal_uInt16 KEY_ESCAPE
#define LINK(Instance, Class, Member)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
bool equalsAscii(std::u16string_view s1, std::string_view s2)
constexpr OUStringLiteral EMPTY
Reference< XNameAccess > m_xContainer
constexpr TypedWhichId< SdrGrafGreenItem > SDRATTR_GRAFGREEN(SDRATTR_GRAF_FIRST+1)
constexpr TypedWhichId< SdrGrafLuminanceItem > SDRATTR_GRAFLUMINANCE(SDRATTR_GRAF_FIRST+3)
constexpr TypedWhichId< SdrGrafRedItem > SDRATTR_GRAFRED(SDRATTR_GRAF_FIRST+0)
constexpr TypedWhichId< SdrGrafModeItem > SDRATTR_GRAFMODE(SDRATTR_GRAF_FIRST+8)
constexpr TypedWhichId< SdrGrafContrastItem > SDRATTR_GRAFCONTRAST(SDRATTR_GRAF_FIRST+4)
constexpr TypedWhichId< SdrGrafGamma100Item > SDRATTR_GRAFGAMMA(SDRATTR_GRAF_FIRST+5)
constexpr TypedWhichId< SdrGrafCropItem > SDRATTR_GRAFCROP(SDRATTR_GRAF_FIRST+9)
constexpr TypedWhichId< SdrGrafTransparenceItem > SDRATTR_GRAFTRANSPARENCE(SDRATTR_GRAF_FIRST+6)
constexpr TypedWhichId< SdrGrafBlueItem > SDRATTR_GRAFBLUE(SDRATTR_GRAF_FIRST+2)
void RotatePoly(tools::Polygon &rPoly, const Point &rRef, double sn, double cs)
void ShearPoly(tools::Polygon &rPoly, const Point &rRef, double tn)
void ShearPoint(Point &rPnt, const Point &rRef, double tn, bool bVShear=false)
void RotatePoint(Point &rPnt, const Point &rRef, double sn, double cs)