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 );
194 const Graphic* pGrf = pGraphicItem->GetGraphic(referer);
210 if( !pGraphicItem->GetGraphicLink().isEmpty() )
223 bool bModified =
false;
224 if(
m_xWidthMF->get_value_changed_from_saved() ||
230 std::shared_ptr<SvxSizeItem> aSz(std::make_shared<SvxSizeItem>(nW));
235 if( pExSet && (pSizeItem = pExSet->
GetItemIfSet( nW,
false )) )
237 aSz.reset(pSizeItem->
Clone());
244 Size aTmpSz( aSz->GetSize() );
245 if(
m_xWidthMF->get_value_changed_from_saved() )
249 aSz->SetSize( aTmpSz );
253 bModified |=
nullptr !=
rSet->
Put( *aSz );
258 SID_ATTR_GRAF_FRMSIZE_PERCENT ),
Size( 0, 0 )) );
261 if(
m_xLeftMF->get_value_changed_from_saved() ||
m_xRightMF->get_value_changed_from_saved() ||
264 sal_uInt16 nW = rPool.
GetWhich( SID_ATTR_GRAF_CROP );
272 bModified |=
nullptr !=
rSet->
Put( std::move(pNew) );
301 aSize = pFrmSizeItem->GetSize();
309 if (nWidth !=
m_xWidthMF->get_value(FieldUnit::TWIP))
310 m_xWidthMF->set_value(nWidth, FieldUnit::TWIP);
313 if (nHeight !=
m_xHeightMF->get_value(FieldUnit::TWIP))
319 if( !pBrushItem->GetGraphicLink().isEmpty() &&
328 const Graphic* pGrf = pBrushItem->GetGraphic(referer);
351 return DeactivateRC::LeavePage;
363 SID_ATTR_GRAF_CROP ) ) );
365 if (&rField == m_xWidthZoomMF.get())
369 m_xWidthMF->set_value( m_xWidthMF->normalize(
370 ((m_aOrigSize.Width() - nLRBorders) * rField.get_value(FieldUnit::NONE))/100),
377 m_xHeightMF->set_value( m_xHeightMF->normalize(
378 ((m_aOrigSize.Height() - nULBorders ) * rField.get_value(FieldUnit::NONE))/100) ,
392 SID_ATTR_GRAF_CROP ) ) );
397 if(&rField == m_xWidthMF.get())
404 sal_uInt16 nZoom =
static_cast<sal_uInt16
>( aSize.
Width() * 100 / nWidth);
405 m_xWidthZoomMF->set_value(nZoom, FieldUnit::NONE);
414 sal_uInt16 nZoom =
static_cast<sal_uInt16
>( aSize.
Height() * 100 / nHeight);
415 m_xHeightZoomMF->set_value(nZoom, FieldUnit::NONE);
428 SID_ATTR_GRAF_CROP ) ) );
430 bool bZoom = m_xZoomConstRB->get_active();
431 if (&rField == m_xLeftMF.get() || &rField == m_xRightMF.get())
436 if (bZoom && nWidthZoom != 0 && ( ( ( m_aOrigSize.Width() - (nLeft + nRight )) * nWidthZoom )
437 / 100 >= m_aPageSize.Width() ) )
439 if (&rField == m_xLeftMF.get())
441 nLeft = m_aOrigSize.Width() -
442 ( m_aPageSize.Width() * 100 / nWidthZoom + nRight );
443 m_xLeftMF->set_value( m_xLeftMF->normalize( nLeft ), eUnit );
447 nRight = m_aOrigSize.Width() -
448 ( m_aPageSize.Width() * 100 / nWidthZoom + nLeft );
449 m_xRightMF->set_value( m_xRightMF->normalize( nRight ), eUnit );
454 m_aExampleWN.SetLeft(nRight);
455 m_aExampleWN.SetRight(nLeft);
459 m_aExampleWN.SetLeft(nLeft);
460 m_aExampleWN.SetRight(nRight);
465 ZoomHdl(*m_xWidthZoomMF);
473 if(bZoom && ( ( ( m_aOrigSize.Height() - (nTop + nBottom )) * nHeightZoom)
474 / 100 >= m_aPageSize.Height()))
476 assert(nHeightZoom &&
"div-by-zero");
477 if(&rField == m_xTopMF.get())
479 nTop = m_aOrigSize.Height() -
480 ( m_aPageSize.Height() * 100 / nHeightZoom + nBottom);
481 m_xTopMF->set_value( m_xWidthMF->normalize( nTop ), eUnit );
485 nBottom = m_aOrigSize.Height() -
486 ( m_aPageSize.Height() * 100 / nHeightZoom + nTop);
487 m_xBottomMF->set_value( m_xWidthMF->normalize( nBottom ), eUnit );
490 m_aExampleWN.SetTop( nTop );
491 m_aExampleWN.SetBottom( nBottom );
495 ZoomHdl(*m_xHeightZoomMF);
498 m_aExampleWN.Invalidate();
513 SID_ATTR_GRAF_CROP ) ) );
518 m_xWidthMF->set_value( m_xWidthMF->normalize( nWidth ), eUnit );
522 m_xHeightMF->set_value( m_xHeightMF->normalize( nHeight ), eUnit );
523 m_xWidthZoomMF->set_value(100, FieldUnit::NONE);
524 m_xHeightZoomMF->set_value(100, FieldUnit::NONE);
525 m_bSetOrigSize =
true;
536 SID_ATTR_GRAF_CROP ) ) );
544 sal_uInt16 nZoom = 0;
547 nZoom =
static_cast<sal_uInt16
>((( nWidth * 1000 / nDen )+5)/10);
550 nZoom =
static_cast<sal_uInt16
>((( nHeight * 1000 / nDen )+5)/10);
565 SID_ATTR_GRAF_CROP ) ) );
572 nMin = nMinWidth - (nL >= 0 ? nL : 0);
577 nMin = nMinHeight - (nUp >= 0 ? nUp : 0);
581 nMin = nMinHeight - (nLow >= 0 ? nLow : 0);
596 SID_ATTR_GRAF_CROP ) ));
624 m_xLeftMF->set_increments(nSpin, nSpin * 10, FieldUnit::NONE);
625 m_xRightMF->set_increments(nSpin, nSpin * 10, FieldUnit::NONE);
629 m_xTopMF->set_increments(nSpin, nSpin * 10, FieldUnit::NONE);
630 m_xBottomMF->set_increments(nSpin, nSpin * 10, FieldUnit::NONE);
638 std::unique_ptr<weld::Dialog> xTopLevel(xBuilder->weld_dialog(
"SpinDialog"));
639 std::unique_ptr<weld::MetricSpinButton> xFld(xBuilder->weld_metric_spin_button(
"spin", FieldUnit::CM));
642 xFld->set_max(INT_MAX - 1, FieldUnit::NONE);
645 sTemp = xFld->get_text();
648 sTemp +=
u"\u00D7" + xFld->get_text();
658 OUString sPPI = OUString::number(ax);
659 if (
abs(ax - ay) > 1) {
660 sPPI +=
u"\u00D7" + OUString::number(ay);
662 sTemp +=
" " +
CuiResId(RID_CUISTR_PPI).replaceAll(
"%1", sPPI);
686 aSize =
Size(fWidth, fHeight);
690 const MapMode aMapTwip( MapUnit::MapTwip );
705 , m_aBottomRight(0, 0)
711 CustomWidgetController::SetDrawingArea(pDrawingArea);
751 const double fLogicDashLength(aDashVector.
getX());
763 std::vector< double >(2, fLogicDashLength),
766 rRenderContext.SetLineColor(aColA);
767 rRenderContext.DrawPolyLine(rSnippet);
771 rRenderContext.SetLineColor(aColB);
772 rRenderContext.DrawPolyLine(rSnippet);
774 2.0 * fLogicDashLength);
776 rRenderContext.
Pop();
795 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
constexpr tools::Long Y() const
constexpr tools::Long X() 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()
const SfxItemSet * GetDialogExampleSet() const
std::unordered_map< OUString, css::uno::Any > & getAdditionalProperties()
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")