26#include <svx/svxids.hrc>
44#include <svx/strings.hrc>
48#include <boost/property_tree/ptree.hpp>
53using namespace css::uno;
61 const css::uno::Reference<css::frame::XFrame>& rxFrame,
63 css::uno::Reference<css::ui::XSidebar> xSidebar)
64:
PanelLayout(pParent,
"PosSizePropertyPanel",
"svx/ui/sidebarpossize.ui"),
65 mxFtPosX(m_xBuilder->weld_label(
"horizontallabel")),
66 mxMtrPosX(m_xBuilder->weld_metric_spin_button(
"horizontalpos",
FieldUnit::
CM)),
67 mxFtPosY(m_xBuilder->weld_label(
"verticallabel")),
68 mxMtrPosY(m_xBuilder->weld_metric_spin_button(
"verticalpos",
FieldUnit::
CM)),
69 mxFtWidth(m_xBuilder->weld_label(
"widthlabel")),
70 mxMtrWidth(m_xBuilder->weld_metric_spin_button(
"selectwidth",
FieldUnit::
CM)),
71 mxFtHeight(m_xBuilder->weld_label(
"heightlabel")),
72 mxMtrHeight(m_xBuilder->weld_metric_spin_button(
"selectheight",
FieldUnit::
CM)),
73 mxCbxScale(m_xBuilder->weld_check_button(
"ratio")),
74 mxFtAngle(m_xBuilder->weld_label(
"rotationlabel")),
75 mxMtrAngle(m_xBuilder->weld_metric_spin_button(
"rotation",
FieldUnit::
DEGREE)),
77 mxDial(new
weld::CustomWeld(*m_xBuilder,
"orientationcontrol", *mxCtrlDial)),
78 mxFtFlip(m_xBuilder->weld_label(
"fliplabel")),
79 mxFlipTbx(m_xBuilder->weld_toolbar(
"selectrotationtype")),
81 mxArrangeTbx(m_xBuilder->weld_toolbar(
"arrangetoolbar")),
83 mxArrangeTbx2(m_xBuilder->weld_toolbar(
"arrangetoolbar2")),
85 mxAlignTbx(m_xBuilder->weld_toolbar(
"aligntoolbar")),
87 mxAlignTbx2(m_xBuilder->weld_toolbar(
"aligntoolbar2")),
89 mxBtnEditOLEObject(m_xBuilder->weld_button(
"btnEditObject")),
97 maTransfPosXControl(SID_ATTR_TRANSFORM_POS_X, *pBindings, *this),
98 maTransfPosYControl(SID_ATTR_TRANSFORM_POS_Y, *pBindings, *this),
99 maTransfWidthControl(SID_ATTR_TRANSFORM_WIDTH, *pBindings, *this),
100 maTransfHeightControl(SID_ATTR_TRANSFORM_HEIGHT, *pBindings, *this),
101 maSvxAngleControl( SID_ATTR_TRANSFORM_ANGLE, *pBindings, *this),
102 maRotXControl(SID_ATTR_TRANSFORM_ROT_X, *pBindings, *this),
103 maRotYControl(SID_ATTR_TRANSFORM_ROT_Y, *pBindings, *this),
104 maProPosControl(SID_ATTR_TRANSFORM_PROTECT_POS, *pBindings, *this),
105 maProSizeControl(SID_ATTR_TRANSFORM_PROTECT_SIZE, *pBindings, *this),
106 maAutoWidthControl(SID_ATTR_TRANSFORM_AUTOWIDTH, *pBindings, *this),
107 maAutoHeightControl(SID_ATTR_TRANSFORM_AUTOHEIGHT, *pBindings, *this),
108 m_aMetricCtl(SID_ATTR_METRIC, *pBindings, *this),
109 mpBindings(pBindings),
110 mbSizeProtected(false),
111 mbPositionProtected(false),
114 mbAdjustEnabled(false),
115 mxSidebar(
std::move(xSidebar))
122 auto nWidth =
mxFtWidth->get_preferred_size().Width();
123 OUString sLabel =
mxFtWidth->get_label();
125 nWidth = std::max(nWidth,
mxFtWidth->get_preferred_size().Width());;
180 bool hasText(
const SdrView& rSdrView)
193 if(pSdrTextObj && pSdrTextObj->
HasText())
226 Size aSize(nDim, nDim);
249 const css::uno::Reference<css::frame::XFrame>& rxFrame,
251 const css::uno::Reference<css::ui::XSidebar>& rxSidebar)
253 if (pParent ==
nullptr)
254 throw lang::IllegalArgumentException(
"no parent Window given to PosSizePropertyPanel::Create",
nullptr, 0);
256 throw lang::IllegalArgumentException(
"no XFrame given to PosSizePropertyPanel::Create",
nullptr, 1);
257 if (pBindings ==
nullptr)
258 throw lang::IllegalArgumentException(
"no SfxBindings given to PosSizePropertyPanel::Create",
nullptr, 2);
260 return std::make_unique<PosSizePropertyPanel>(pParent, rxFrame, pBindings, rxSidebar);
274 bool bShowPosition =
false;
275 bool bShowAngle =
false;
276 bool bShowFlip =
false;
277 bool bShowEditObject =
false;
278 bool bShowArrangeTbx2 =
false;
285 bShowArrangeTbx2 =
true;
300 bShowPosition =
true;
306 bShowEditObject =
true;
311 bShowPosition =
true;
312 bShowEditObject =
true;
323 bShowPosition =
true;
328 mxFtPosX->set_visible(bShowPosition);
330 mxFtPosY->set_visible(bShowPosition);
355 if( mxCbxScale->get_active() &&
356 mxCbxScale->get_sensitive() )
358 tools::Long nHeight =
static_cast<tools::Long>( (
static_cast<double>(mlOldHeight) *
static_cast<double>(mxMtrWidth->get_value(FieldUnit::NONE))) /
static_cast<double>(mlOldWidth) );
359 if( nHeight <= mxMtrHeight->get_max( FieldUnit::NONE ) )
361 mxMtrHeight->set_value( nHeight, FieldUnit::NONE );
365 nHeight =
static_cast<tools::Long>(mxMtrHeight->get_max( FieldUnit::NONE ));
366 mxMtrHeight->set_value(nHeight, FieldUnit::NONE);
367 const tools::Long nWidth =
static_cast<tools::Long>( (
static_cast<double>(mlOldWidth) *
static_cast<double>(nHeight)) /
static_cast<double>(mlOldHeight) );
368 mxMtrWidth->set_value( nWidth, FieldUnit::NONE );
377 if( mxCbxScale->get_active() &&
378 mxCbxScale->get_sensitive() )
380 tools::Long nWidth =
static_cast<tools::Long>( (
static_cast<double>(mlOldWidth) *
static_cast<double>(mxMtrHeight->get_value(FieldUnit::NONE))) /
static_cast<double>(mlOldHeight) );
381 if( nWidth <= mxMtrWidth->get_max( FieldUnit::NONE ) )
383 mxMtrWidth->set_value( nWidth, FieldUnit::NONE );
387 nWidth =
static_cast<tools::Long>(mxMtrWidth->get_max( FieldUnit::NONE ));
388 mxMtrWidth->set_value( nWidth, FieldUnit::NONE );
389 const tools::Long nHeight =
static_cast<tools::Long>( (
static_cast<double>(mlOldHeight) *
static_cast<double>(nWidth)) /
static_cast<double>(mlOldWidth) );
390 mxMtrHeight->set_value( nHeight, FieldUnit::NONE );
399 if ( mxMtrPosX->get_value_changed_from_saved())
406 SfxInt32Item aPosXItem( SID_ATTR_TRANSFORM_POS_X,
static_cast<sal_uInt32
>(lX));
409 SID_ATTR_TRANSFORM, SfxCallMode::RECORD, { &aPosXItem });
415 if ( mxMtrPosY->get_value_changed_from_saved() )
422 SfxInt32Item aPosYItem( SID_ATTR_TRANSFORM_POS_Y,
static_cast<sal_uInt32
>(lY));
425 SID_ATTR_TRANSFORM, SfxCallMode::RECORD, { &aPosYItem });
431 if ( mxCbxScale->get_active() )
433 mlOldWidth = std::max(
GetCoreValue(*mxMtrWidth, mePoolUnit), SAL_CONST_INT64(1));
434 mlOldHeight = std::max(
GetCoreValue(*mxMtrHeight, mePoolUnit), SAL_CONST_INT64(1));
438 SvtViewOptions aPageOpt(EViewType::TabPage,
"cui/ui/possizetabpage/PositionAndSize");
444 Degree100 nTmp = mxCtrlDial->GetRotation();
447 const double fUIScale(
mpView ?
double(
mpView->GetModel().GetUIScale()) : 1.0);
448 SdrAngleItem aAngleItem( SID_ATTR_TRANSFORM_ANGLE, nTmp);
453 SfxCallMode::RECORD, { &aAngleItem, &aRotXItem, &aRotYItem });
470 const int nMaxDigits = 7;
484 mxDial->set_sensitive(
true);
508 case SID_ATTR_TRANSFORM_WIDTH:
509 if ( SfxItemState::DEFAULT == eState )
528 case SID_ATTR_TRANSFORM_HEIGHT:
529 if ( SfxItemState::DEFAULT == eState )
548 case SID_ATTR_TRANSFORM_POS_X:
549 if(SfxItemState::DEFAULT == eState)
567 case SID_ATTR_TRANSFORM_POS_Y:
568 if(SfxItemState::DEFAULT == eState)
586 case SID_ATTR_TRANSFORM_ROT_X:
587 if (SfxItemState::DEFAULT == eState)
599 case SID_ATTR_TRANSFORM_ROT_Y:
600 if (SfxItemState::DEFAULT == eState)
612 case SID_ATTR_TRANSFORM_PROTECT_POS:
613 if(SfxItemState::DEFAULT == eState)
628 case SID_ATTR_TRANSFORM_PROTECT_SIZE:
629 if(SfxItemState::DEFAULT == eState)
644 case SID_ATTR_TRANSFORM_AUTOWIDTH:
645 if(SfxItemState::DEFAULT == eState)
656 case SID_ATTR_TRANSFORM_AUTOHEIGHT:
657 if(SfxItemState::DEFAULT == eState)
668 case SID_ATTR_TRANSFORM_ANGLE:
669 if (eState >= SfxItemState::DEFAULT)
688 case SID_ATTR_METRIC:
717 mxDial->set_sensitive(
false);
726 sal_uInt16 nMarkObj = 0;
727 bool isNoEdge =
true;
729 while(isNoEdge && rMarkList.
GetMark(nMarkObj))
749 mxDial->set_sensitive(
false);
766 SvtViewOptions aPageOpt(EViewType::TabPage,
"cui/ui/possizetabpage/PositionAndSize");
770 if ( aUserItem >>= aTemp )
772 mxCbxScale->set_active(
static_cast<bool>(sUserData.toInt32()));
780 case SID_ATTR_TRANSFORM_POS_X:
783 case SID_ATTR_TRANSFORM_POS_Y:
786 case SID_ATTR_TRANSFORM_WIDTH:
789 case SID_ATTR_TRANSFORM_HEIGHT:
794 if (pControl && !pControl->
get_text().isEmpty())
798 rState.put(pControl->
get_buildable_name().toUtf8().getStr(), sValue.toUtf8().getStr());
810 double nWidth =
static_cast<double>(
mxMtrWidth->get_value(FieldUnit::MM_100TH));
816 double nHeight =
static_cast<double>(
mxMtrHeight->get_value(FieldUnit::MM_100TH));
822 SfxUInt32Item aWidthItem( SID_ATTR_TRANSFORM_WIDTH,
static_cast<sal_uInt32
>(lWidth));
823 SfxUInt32Item aHeightItem( SID_ATTR_TRANSFORM_HEIGHT,
static_cast<sal_uInt32
>(lHeight));
832 SfxCallMode::RECORD, { &aWidthItem, &aHeightItem, &aPointItem });
838 SfxCallMode::RECORD, { &aWidthItem, &aHeightItem, &aPointItem });
839 else if(
mxMtrWidth->get_value_changed_from_saved())
841 SfxCallMode::RECORD, { &aWidthItem, &aPointItem });
842 else if (
mxMtrHeight->get_value_changed_from_saved())
844 SfxCallMode::RECORD, { &aHeightItem, &aPointItem });
860 bool bPosXBlank =
false;
861 bool bPosYBlank =
false;
862 bool bWidthBlank =
false;
863 bool bHeightBlank =
false;
903 if ( pState && eState >= SfxItemState::DEFAULT )
924 SAL_WARN(
"svx.sidebar",
"GetModuleFieldUnit(): no module found");
945 mxDial->set_sensitive(
false);
1028 const sal_uInt16 nDigits(
mxMtrPosX->get_digits());
1043 fLeft = std::clamp(fLeft, -fMaxLong, fMaxLong);
1044 fRight = std::clamp(fRight, -fMaxLong, fMaxLong);
1045 fTop = std::clamp(fTop, - fMaxLong, fMaxLong);
1046 fBottom = std::clamp(fBottom, -fMaxLong, fMaxLong);
#define CombinedEnumContext(a, e)
constexpr OUStringLiteral USERITEM_NAME
const LocaleDataWrapper & GetNeutralLocaleDataWrapper() const
static const AllSettings & GetSettings()
sal_Int32 GetValue() const
sal_uInt32 GetValue() const
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
virtual void DumpAsPropertyTree(tools::JsonWriter &)
Degree100 GetValue() const
const tools::Rectangle & GetWorkArea() const
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
const SdrMarkList & GetMarkedObjectList() const
const tools::Rectangle & GetAllMarkedRect() const
SdrObject * GetMarkedSdrObj() const
const Fraction & GetUIScale() const
virtual SdrInventor GetObjInventor() const
virtual SdrObjKind GetObjIdentifier() const
void LogicToPagePos(Point &rPnt) const
SdrPageView * GetSdrPageView() const
SdrModel & GetModel() const
virtual bool HasText() const override
void Update(sal_uInt16 nId)
SfxDispatcher * GetDispatcher() const
void Invalidate(sal_uInt16 nId)
MapUnit GetCoreMetric() const
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 * >())
SfxModule * GetModule() const
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
virtual SfxObjectShell * GetObjectShell() override
virtual ErrCode DoVerb(sal_Int32 nVerb)
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
virtual SdrView * GetDrawView() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
css::uno::Any GetUserItem(const OUString &sName) const
void SetUserItem(const OUString &sName, const css::uno::Any &aValue)
This control allows to input a rotation angle, visualized by a dial.
sal_Int32 GetCombinedContext_DI() const
virtual int get_width_chars() const=0
virtual void set_width_chars(int nChars)=0
OUString SvxResId(TranslateId aId)
virtual SfxBindings & GetBindings() override
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
void ConvertRect(basegfx::B2DRange &rRange, const sal_uInt16 nDigits, const MapUnit ePoolUnit, const FieldUnit eDlgUnit)
void ScaleRect(basegfx::B2DRange &rRange, const Fraction &rUIScale)
B2IRange fround(const B2DRange &rRange)
sal_Int64 fround64(double fVal)
sal_Int64 ConvertValue(sal_Int64 nValue, sal_Int64 mnBaseValue, sal_uInt16 nDecDigits, FieldUnit eInUnit, FieldUnit eOutUnit)
UNDERLYING_TYPE get() const
SdrTextObj * DynCastSdrTextObj(SdrObject *pObj)
@ Caption
connector object
@ Text
closed free-hand line
@ OutlineText
TitleText, special text object for StarDraw.
Degree100 NormAngle36000(Degree100 a)
Normalize angle to -180.00..179.99.
SVT_DLLPUBLIC sal_Int64 GetCoreValue(const weld::MetricSpinButton &rField, MapUnit eUnit)
SVT_DLLPUBLIC void SetMetricValue(weld::MetricSpinButton &rField, sal_Int64 nCoreValue, MapUnit eUnit)
SVT_DLLPUBLIC void SetFieldUnit(weld::MetricSpinButton &rCtrl, FieldUnit eUnit, bool bAll=false)