29#include <rtl/ustring.hxx>
32#include <svx/svxids.hrc>
57 :
SfxTabPage(pPage, pController,
"cui/ui/croppage.ui",
"CropPage", &
rSet)
60 , m_bSetOrigSize(false)
62 , m_xCropFrame(m_xBuilder->weld_widget(
"cropframe"))
63 , m_xZoomConstRB(m_xBuilder->weld_radio_button(
"keepscale"))
64 , m_xSizeConstRB(m_xBuilder->weld_radio_button(
"keepsize"))
65 , m_xLeftMF(m_xBuilder->weld_metric_spin_button(
"left",
FieldUnit::
CM))
66 , m_xRightMF(m_xBuilder->weld_metric_spin_button(
"right",
FieldUnit::
CM))
67 , m_xTopMF(m_xBuilder->weld_metric_spin_button(
"top",
FieldUnit::
CM))
68 , m_xBottomMF(m_xBuilder->weld_metric_spin_button(
"bottom",
FieldUnit::
CM))
69 , m_xScaleFrame(m_xBuilder->weld_widget(
"scaleframe"))
70 , m_xWidthZoomMF(m_xBuilder->weld_metric_spin_button(
"widthzoom",
FieldUnit::
PERCENT))
71 , m_xHeightZoomMF(m_xBuilder->weld_metric_spin_button(
"heightzoom",
FieldUnit::
PERCENT))
72 , m_xSizeFrame(m_xBuilder->weld_widget(
"sizeframe"))
73 , m_xWidthMF(m_xBuilder->weld_metric_spin_button(
"width",
FieldUnit::
CM))
74 , m_xHeightMF(m_xBuilder->weld_metric_spin_button(
"height",
FieldUnit::
CM))
75 , m_xOrigSizeGrid(m_xBuilder->weld_widget(
"origsizegrid"))
76 , m_xOrigSizeFT(m_xBuilder->weld_label(
"origsizeft"))
77 , m_xOrigSizePB(m_xBuilder->weld_button(
"origsize"))
78 , m_xExampleWN(new
weld::CustomWeld(*m_xBuilder,
"preview", m_aExampleWN))
103 m_xTopMF->connect_value_changed( aLk );
116 return std::make_unique<SvxGrfCropPage>(pPage, pController, *
rSet);
125 SID_ATTR_GRAF_KEEP_ZOOM ),
true, &pItem ))
134 sal_uInt16 nW = rPool.
GetWhich( SID_ATTR_GRAF_CROP );
153 m_xLeftMF->set_value(0, FieldUnit::NONE);
155 m_xTopMF->set_value(0, FieldUnit::NONE);
164 nW = rPool.
GetWhich( SID_ATTR_PAGE_SIZE );
195 const Graphic* pGrf = pGraphicItem->GetGraphic(referer);
211 if( !pGraphicItem->GetGraphicLink().isEmpty() )
224 bool bModified =
false;
225 if(
m_xWidthMF->get_value_changed_from_saved() ||
231 std::shared_ptr<SvxSizeItem> aSz(std::make_shared<SvxSizeItem>(nW));
236 if( pExSet && (pSizeItem = pExSet->
GetItemIfSet( nW,
false )) )
238 aSz.reset(pSizeItem->
Clone());
245 Size aTmpSz( aSz->GetSize() );
246 if(
m_xWidthMF->get_value_changed_from_saved() )
250 aSz->SetSize( aTmpSz );
254 bModified |=
nullptr !=
rSet->
Put( *aSz );
259 SID_ATTR_GRAF_FRMSIZE_PERCENT ),
Size( 0, 0 )) );
262 if(
m_xLeftMF->get_value_changed_from_saved() ||
m_xRightMF->get_value_changed_from_saved() ||
265 sal_uInt16 nW = rPool.
GetWhich( SID_ATTR_GRAF_CROP );
273 bModified |=
nullptr !=
rSet->
Put( std::move(pNew) );
302 aSize = pFrmSizeItem->GetSize();
310 if (nWidth !=
m_xWidthMF->get_value(FieldUnit::TWIP))
311 m_xWidthMF->set_value(nWidth, FieldUnit::TWIP);
314 if (nHeight !=
m_xHeightMF->get_value(FieldUnit::TWIP))
320 if( !pBrushItem->GetGraphicLink().isEmpty() &&
330 const Graphic* pGrf = pBrushItem->GetGraphic(referer);
353 return DeactivateRC::LeavePage;
365 SID_ATTR_GRAF_CROP ) ) );
367 if (&rField == m_xWidthZoomMF.get())
371 m_xWidthMF->set_value( m_xWidthMF->normalize(
372 ((m_aOrigSize.Width() - nLRBorders) * rField.get_value(FieldUnit::NONE))/100),
379 m_xHeightMF->set_value( m_xHeightMF->normalize(
380 ((m_aOrigSize.Height() - nULBorders ) * rField.get_value(FieldUnit::NONE))/100) ,
394 SID_ATTR_GRAF_CROP ) ) );
399 if(&rField == m_xWidthMF.get())
406 sal_uInt16 nZoom =
static_cast<sal_uInt16
>( aSize.
Width() * 100 / nWidth);
407 m_xWidthZoomMF->set_value(nZoom, FieldUnit::NONE);
416 sal_uInt16 nZoom =
static_cast<sal_uInt16
>( aSize.
Height() * 100 / nHeight);
417 m_xHeightZoomMF->set_value(nZoom, FieldUnit::NONE);
430 SID_ATTR_GRAF_CROP ) ) );
432 bool bZoom = m_xZoomConstRB->get_active();
433 if (&rField == m_xLeftMF.get() || &rField == m_xRightMF.get())
438 if (bZoom && nWidthZoom != 0 && ( ( ( m_aOrigSize.Width() - (nLeft + nRight )) * nWidthZoom )
439 / 100 >= m_aPageSize.Width() ) )
441 if (&rField == m_xLeftMF.get())
443 nLeft = m_aOrigSize.Width() -
444 ( m_aPageSize.Width() * 100 / nWidthZoom + nRight );
445 m_xLeftMF->set_value( m_xLeftMF->normalize( nLeft ), eUnit );
449 nRight = m_aOrigSize.Width() -
450 ( m_aPageSize.Width() * 100 / nWidthZoom + nLeft );
451 m_xRightMF->set_value( m_xRightMF->normalize( nRight ), eUnit );
456 m_aExampleWN.SetLeft(nRight);
457 m_aExampleWN.SetRight(nLeft);
461 m_aExampleWN.SetLeft(nLeft);
462 m_aExampleWN.SetRight(nRight);
467 ZoomHdl(*m_xWidthZoomMF);
475 if(bZoom && ( ( ( m_aOrigSize.Height() - (nTop + nBottom )) * nHeightZoom)
476 / 100 >= m_aPageSize.Height()))
478 assert(nHeightZoom &&
"div-by-zero");
479 if(&rField == m_xTopMF.get())
481 nTop = m_aOrigSize.Height() -
482 ( m_aPageSize.Height() * 100 / nHeightZoom + nBottom);
483 m_xTopMF->set_value( m_xWidthMF->normalize( nTop ), eUnit );
487 nBottom = m_aOrigSize.Height() -
488 ( m_aPageSize.Height() * 100 / nHeightZoom + nTop);
489 m_xBottomMF->set_value( m_xWidthMF->normalize( nBottom ), eUnit );
492 m_aExampleWN.SetTop( nTop );
493 m_aExampleWN.SetBottom( nBottom );
497 ZoomHdl(*m_xHeightZoomMF);
500 m_aExampleWN.Invalidate();
515 SID_ATTR_GRAF_CROP ) ) );
520 m_xWidthMF->set_value( m_xWidthMF->normalize( nWidth ), eUnit );
524 m_xHeightMF->set_value( m_xHeightMF->normalize( nHeight ), eUnit );
525 m_xWidthZoomMF->set_value(100, FieldUnit::NONE);
526 m_xHeightZoomMF->set_value(100, FieldUnit::NONE);
527 m_bSetOrigSize =
true;
538 SID_ATTR_GRAF_CROP ) ) );
546 sal_uInt16 nZoom = 0;
549 nZoom =
static_cast<sal_uInt16
>((( nWidth * 1000 / nDen )+5)/10);
552 nZoom =
static_cast<sal_uInt16
>((( nHeight * 1000 / nDen )+5)/10);
567 SID_ATTR_GRAF_CROP ) ) );
574 nMin = nMinWidth - (nL >= 0 ? nL : 0);
579 nMin = nMinHeight - (nUp >= 0 ? nUp : 0);
583 nMin = nMinHeight - (nLow >= 0 ? nLow : 0);
598 SID_ATTR_GRAF_CROP ) ));
626 m_xLeftMF->set_increments(nSpin, nSpin * 10, FieldUnit::NONE);
627 m_xRightMF->set_increments(nSpin, nSpin * 10, FieldUnit::NONE);
631 m_xTopMF->set_increments(nSpin, nSpin * 10, FieldUnit::NONE);
632 m_xBottomMF->set_increments(nSpin, nSpin * 10, FieldUnit::NONE);
640 std::unique_ptr<weld::Dialog> xTopLevel(xBuilder->weld_dialog(
"SpinDialog"));
641 std::unique_ptr<weld::MetricSpinButton> xFld(xBuilder->weld_metric_spin_button(
"spin", FieldUnit::CM));
644 xFld->set_max(INT_MAX - 1, FieldUnit::NONE);
647 sTemp = xFld->get_text();
650 sTemp +=
u"\u00D7" + xFld->get_text();
660 OUString sPPI = OUString::number(ax);
661 if (
abs(ax - ay) > 1) {
662 sPPI +=
u"\u00D7" + OUString::number(ay);
664 sTemp +=
" " +
CuiResId(RID_CUISTR_PPI).replaceAll(
"%1", sPPI);
688 aSize =
Size(fWidth, fHeight);
692 const MapMode aMapTwip( MapUnit::MapTwip );
707 , m_aBottomRight(0, 0)
713 CustomWidgetController::SetDrawingArea(pDrawingArea);
753 const double fLogicDashLength(aDashVector.
getX());
765 std::vector< double >(2, fLogicDashLength),
768 rRenderContext.SetLineColor(aColA);
769 rRenderContext.DrawPolyLine(rSnippet);
773 rRenderContext.SetLineColor(aColB);
774 rRenderContext.DrawPolyLine(rSnippet);
776 2.0 * fLogicDashLength);
778 rRenderContext.
Pop();
797 if( aYScale < aXScale )
PropertiesInfo aProperties
const StyleSettings & GetStyleSettings() const
static bool GetLayoutRTL()
static OutputDevice * GetDefaultDevice()
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
const OUString & GetValue() const
GraphicType GetType() const
MapMode GetPrefMapMode() const
Size GetSizePixel(const OutputDevice *pRefDevice=nullptr) const
void Draw(OutputDevice &rOutDev, const Point &rDestPt) const
void SetScaleY(const Fraction &rScaleY)
MapUnit GetMapUnit() const
void SetScaleX(const Fraction &rScaleX)
void SetAntialiasing(AntialiasingFlags nMode)
basegfx::B2DHomMatrix GetInverseViewTransformation() const
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
void DrawRect(const tools::Rectangle &rRect)
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
const MapMode & GetMapMode() const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
const AllSettings & GetSettings() const
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
SfxItemPool * GetPool() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const=0
const SfxItemSet & GetItemSet() const
void SetExchangeSupport()
std::unordered_map< OString, css::uno::Any > & getAdditionalProperties()
const SfxItemSet * GetDialogExampleSet() const
weld::Window * GetFrameWeld() const
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
const Color & GetWindowColor() const
void SetBottom(tools::Long nVal)
void SetLeft(tools::Long nVal)
void SetTop(tools::Long nVal)
void SetFrameSize(const Size &rSz)
virtual void Resize() override
virtual void Paint(vcl::RenderContext &rRenderContext, const ::tools::Rectangle &rRect) override
void SetGraphic(const Graphic &rGrf)
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
void SetRight(tools::Long nVal)
std::unique_ptr< weld::Widget > m_xCropFrame
std::unique_ptr< weld::MetricSpinButton > m_xWidthMF
std::unique_ptr< weld::Widget > m_xSizeFrame
std::unique_ptr< weld::MetricSpinButton > m_xRightMF
std::unique_ptr< weld::RadioButton > m_xSizeConstRB
virtual void Reset(const SfxItemSet *rSet) override
std::unique_ptr< weld::MetricSpinButton > m_xWidthZoomMF
std::unique_ptr< weld::CustomWeld > m_xExampleWN
std::unique_ptr< weld::RadioButton > m_xZoomConstRB
std::unique_ptr< weld::Widget > m_xScaleFrame
std::unique_ptr< weld::Widget > m_xOrigSizeGrid
sal_Int32 m_aPreferredDPI
std::unique_ptr< weld::MetricSpinButton > m_xTopMF
std::unique_ptr< weld::Label > m_xOrigSizeFT
virtual bool FillItemSet(SfxItemSet *rSet) override
std::unique_ptr< weld::MetricSpinButton > m_xHeightMF
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
std::unique_ptr< weld::MetricSpinButton > m_xHeightZoomMF
std::unique_ptr< weld::MetricSpinButton > m_xLeftMF
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
std::unique_ptr< weld::Button > m_xOrigSizePB
SvxCropExample m_aExampleWN
virtual void ActivatePage(const SfxItemSet &rSet) override
std::unique_ptr< weld::MetricSpinButton > m_xBottomMF
void GraphicHasChanged(bool bFound)
virtual ~SvxGrfCropPage() override
Size GetGrfOrigSize(const Graphic &rGraphic)
SvxGrfCropPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
sal_Int32 GetRight() const
sal_Int32 GetLeft() const
sal_Int32 GetBottom() const
virtual SvxSizeItem * Clone(SfxItemPool *pPool=nullptr) const override
virtual OutputDevice & get_ref_device()=0
OUString CuiResId(TranslateId aKey)
#define DBG_ASSERT(sCon, aError)
virtual tools::Long GetValue() const override
SVXCORE_DLLPUBLIC FieldUnit GetModuleFieldUnit(const SfxItemSet &)
IMPL_LINK(SvxGrfCropPage, ZoomHdl, weld::MetricSpinButton &, rField, void)
static int lcl_GetValue(const weld::MetricSpinButton &rMetric, FieldUnit eUnit)
IMPL_LINK_NOARG(SvxGrfCropPage, OrigSizeHdl, weld::Button &, void)
constexpr auto CM_1_TO_TWIP
#define LINK(Instance, Class, Member)
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
sal_uInt16 GetStripeLength()
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
void applyLineDashing(const B2DPolygon &rCandidate, const std::vector< double > &rDotDashArray, B2DPolyPolygon *pLineTarget, B2DPolyPolygon *pGapTarget, double fDotDashLength)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
css::uno::Reference< css::animations::XAnimationNode > Clone(const css::uno::Reference< css::animations::XAnimationNode > &xSourceNode, const SdPage *pSource=nullptr, const SdPage *pTarget=nullptr)
sal_Int64 ConvertValue(sal_Int64 nValue, sal_Int64 mnBaseValue, sal_uInt16 nDecDigits, FieldUnit eInUnit, FieldUnit eOutUnit)
SwNodeOffset abs(const SwNodeOffset &a)
SVT_DLLPUBLIC void SetFieldUnit(weld::MetricSpinButton &rCtrl, FieldUnit eUnit, bool bAll=false)
SVT_DLLPUBLIC FieldUnit MapToFieldUnit(const MapUnit eUnit)
constexpr OUStringLiteral PERCENT(u"Percent")