24#include <svx/svxids.hrc>
70 :
SfxTabPage(pPage, pController,
"cui/ui/imagetabpage.ui",
"ImageTabPage", &rInAttrs)
71 , m_rOutAttrs(rInAttrs)
72 , m_pnBitmapListState(nullptr)
74 , m_fObjectHeight(0.0)
75 , m_bLogicalSize(false)
76 , m_aXFillAttr(rInAttrs.GetPool())
79 , m_xBitmapLB(new
SvxPresetListBox(m_xBuilder->weld_scrolled_window(
"imagewin", true)))
80 , m_xBitmapStyleLB(m_xBuilder->weld_combo_box(
"imagestyle"))
81 , m_xSizeBox(m_xBuilder->weld_container(
"sizebox"))
82 , m_xTsbScale(m_xBuilder->weld_check_button(
"scaletsb"))
83 , m_xBitmapWidth(m_xBuilder->weld_metric_spin_button(
"width",
FieldUnit::
PERCENT))
84 , m_xBitmapHeight(m_xBuilder->weld_metric_spin_button(
"height",
FieldUnit::
PERCENT))
85 , m_xPositionBox(m_xBuilder->weld_container(
"posbox"))
86 , m_xPositionLB(m_xBuilder->weld_combo_box(
"positionlb"))
87 , m_xPositionOffBox(m_xBuilder->weld_container(
"posoffbox"))
88 , m_xPositionOffX(m_xBuilder->weld_metric_spin_button(
"posoffx",
FieldUnit::
PERCENT))
89 , m_xPositionOffY(m_xBuilder->weld_metric_spin_button(
"posoffy",
FieldUnit::
PERCENT))
90 , m_xTileOffBox(m_xBuilder->weld_container(
"tileoffbox"))
91 , m_xTileOffLB(m_xBuilder->weld_combo_box(
"tileofflb"))
92 , m_xTileOffset(m_xBuilder->weld_metric_spin_button(
"tileoffmtr",
FieldUnit::
PERCENT))
93 , m_xBtnImport(m_xBuilder->weld_button(
"BTN_IMPORT"))
94 , m_xCtlBitmapPreview(new
weld::CustomWeld(*m_xBuilder,
"CTL_IMAGE_PREVIEW", m_aCtlBitmapPreview))
95 , m_xBitmapLBWin(new
weld::CustomWeld(*m_xBuilder,
"IMAGE", *m_xBitmapLB))
178 return DeactivateRC::LeavePage;
193 BitmapStyle eStylePos =
static_cast<BitmapStyle
>(
m_xBitmapStyleLB->get_active());
194 bool bIsStretched( eStylePos == STRETCHED );
195 bool bIsTiled( eStylePos == TILED );
208 sal_Int64 nWidthPercent =
m_xBitmapWidth->get_value(FieldUnit::NONE);
209 sal_Int64 nHeightPercent =
m_xBitmapHeight->get_value(FieldUnit::NONE);
212 aSetBitmapSize.
setWidth( -nWidthPercent );
213 aSetBitmapSize.
setHeight( -nHeightPercent );
245 TileOffset eValue =
static_cast<TileOffset
>(
m_xTileOffLB->get_active());
246 sal_uInt16 nOffsetValue =
static_cast<sal_uInt16
>(
m_xTileOffset->get_value(FieldUnit::PERCENT));
247 sal_uInt16 nRowOff = (eValue ==
ROW) ? nOffsetValue : 0;
248 sal_uInt16 nColOff = (eValue ==
COLUMN) ? nOffsetValue : 0;
258 double transfWidth = 0.0;
259 double transfHeight = 0.0;
260 double fUIScale = 1.0;
269 transfWidth =
static_cast<double>(
GetItem( rGeoAttr, SID_ATTR_TRANSFORM_WIDTH )->GetValue());
270 transfHeight=
static_cast<double>(
GetItem( rGeoAttr, SID_ATTR_TRANSFORM_HEIGHT )->GetValue());
292 std::unique_ptr<GraphicObject> pGraphicObject;
295 BitmapEx aBmpEx(pGraphicObject->GetGraphic().GetBitmapEx());
300 bool bTiled =
false;
bool bStretched =
false;
336 nWidth = std::abs(nWidth);
349 nHeight = std::abs(nHeight);
373 m_xPositionLB->set_active(
static_cast< sal_Int32
>(eValue) );
417 return std::make_unique<SvxBitmapTabPage>(pPage, pController, *rAttrs);
454 std::unique_ptr<GraphicObject> pGraphicObject;
455 size_t nPos = m_xBitmapLB->GetSelectItemPos();
459 pGraphicObject.reset(
new GraphicObject(m_pBitmapList->GetBitmap(
static_cast<sal_uInt16
>(
nPos) )->GetGraphicObject()));
465 const drawing::FillStyle eXFS(pFillStyleItem->GetValue());
476 sal_uInt16
nId = m_xBitmapLB->GetItemId(0);
477 m_xBitmapLB->SelectItem(
nId);
481 pGraphicObject.reset(
new GraphicObject(m_pBitmapList->GetBitmap(0)->GetGraphicObject()));
488 BitmapEx aBmpEx(pGraphicObject->GetGraphic().GetBitmapEx());
490 const double fUIScale =
mpView ? double(
mpView->GetModel().GetUIScale()) : 1.0;
493 rBitmapSize.setWidth(aBitmapSize100mm.
Width() / fUIScale);
494 rBitmapSize.setHeight(aBitmapSize100mm.
Height() / fUIScale);
495 CalculateBitmapPresetSize();
496 ModifyBitmapStyleHdl( *m_xBitmapStyleLB );
497 ModifyBitmapPositionHdl( *m_xPositionLB );
503 m_aCtlBitmapPreview.SetAttributes( m_aXFillAttr.GetItemSet() );
504 m_aCtlBitmapPreview.Invalidate();
508 SAL_WARN(
"cui.tabpages",
"SvxBitmapTabPage::ModifyBitmapHdl(): null pGraphicObject");
515 sal_uInt16
nId = m_xBitmapLB->GetSelectedItemId();
516 size_t nPos = m_xBitmapLB->GetSelectItemPos();
521 OUString aDesc(
CuiResId( RID_CUISTR_DESC_NEW_BITMAP ) );
522 OUString
aName( m_pBitmapList->GetBitmap(
nPos )->GetName() );
528 while( bLoop && pDlg->Execute() ==
RET_OK )
530 pDlg->GetName(
aName );
531 sal_Int32 nBitmapPos = SearchBitmapList(
aName );
532 bool bValidBitmapName = (nBitmapPos ==
static_cast<sal_Int32
>(
nPos) ) || (nBitmapPos == -1);
537 m_pBitmapList->GetBitmap(
nPos)->SetName(
aName);
539 m_xBitmapLB->SetItemText(
nId,
aName);
540 m_xBitmapLB->SelectItem(
nId );
542 *m_pnBitmapListState |= ChangeType::MODIFIED;
547 std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(
"DuplicateNameDialog"));
555 sal_uInt16
nId = m_xBitmapLB->GetSelectedItemId();
556 size_t nPos = m_xBitmapLB->GetSelectItemPos();
562 std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog(
"AskDelBitmapDialog"));
564 if (xQueryBox->run() !=
RET_YES)
567 sal_uInt16 nNextId = m_xBitmapLB->GetItemId(
nPos + 1);
569 nNextId = m_xBitmapLB->GetItemId(
nPos - 1);
571 m_pBitmapList->Remove(
static_cast<sal_uInt16
>(
nPos) );
572 m_xBitmapLB->RemoveItem(
nId );
574 m_xBitmapLB->SelectItem(nNextId);
576 m_aCtlBitmapPreview.Invalidate();
577 ModifyBitmapHdl(m_xBitmapLB.get());
578 *m_pnBitmapListState |= ChangeType::MODIFIED;
583 m_bLogicalSize =
false;
584 if (m_xTsbScale->get_state() !=
TRISTATE_TRUE &&
static_cast<BitmapStyle
>(m_xBitmapStyleLB->get_active()) != TILED)
586 sal_Int64 nWidthPercent = m_xBitmapWidth->denormalize(m_xBitmapWidth->get_value(FieldUnit::NONE));
587 sal_Int64 nHeightPercent = m_xBitmapHeight->denormalize(m_xBitmapHeight->get_value(FieldUnit::NONE));
588 if (nWidthPercent == 100 && nHeightPercent == 100)
589 m_xBitmapStyleLB->set_active(
static_cast<sal_Int32
>(
CUSTOM));
591 ModifyBitmapStyleHdl(*m_xBitmapStyleLB);
593 m_aCtlBitmapPreview.SetAttributes( m_aXFillAttr.GetItemSet() );
594 m_aCtlBitmapPreview.Invalidate();
601 m_xBitmapWidth->set_digits( 0 );
602 m_xBitmapWidth->set_unit(FieldUnit::PERCENT);
603 m_xBitmapWidth->set_value(100, FieldUnit::NONE);
604 m_xBitmapWidth->set_range(0, 100, FieldUnit::NONE);
606 m_xBitmapHeight->set_digits( 0 );
607 m_xBitmapHeight->set_unit(FieldUnit::PERCENT);
608 m_xBitmapHeight->set_value(100, FieldUnit::NONE);
609 m_xBitmapHeight->set_range(0, 100, FieldUnit::NONE);
613 m_xBitmapWidth->set_digits( 2 );
614 m_xBitmapWidth->set_unit(meFieldUnit);
615 m_xBitmapWidth->set_value(100, FieldUnit::NONE);
616 m_xBitmapWidth->set_range(0, 999900, FieldUnit::NONE);
618 m_xBitmapHeight->set_digits( 2 );
619 m_xBitmapHeight->set_unit(meFieldUnit);
620 m_xBitmapHeight->set_value(100, FieldUnit::NONE);
621 m_xBitmapHeight->set_range(0, 999900, FieldUnit::NONE);
624 ModifyBitmapStyleHdl( *m_xBitmapStyleLB );
629 BitmapStyle eStylePos =
static_cast<BitmapStyle
>(m_xBitmapStyleLB->get_active());
630 bool bIsStretched( eStylePos == STRETCHED );
631 bool bIsTiled( eStylePos == TILED );
633 m_xSizeBox->set_sensitive( !bIsStretched );
634 m_xPositionBox->set_sensitive( !bIsStretched );
635 m_xPositionOffBox->set_sensitive( bIsTiled );
636 m_xTileOffBox->set_sensitive( bIsTiled );
649 if (m_xTsbScale->get_sensitive() && m_xTsbScale->get_state() ==
TRISTATE_TRUE)
651 aSetBitmapSize.
setWidth(-m_xBitmapWidth->get_value(FieldUnit::NONE));
652 aSetBitmapSize.
setHeight(-m_xBitmapHeight->get_value(FieldUnit::NONE));
669 m_aCtlBitmapPreview.SetAttributes( m_aXFillAttr.GetItemSet() );
670 m_aCtlBitmapPreview.Invalidate();
675 if (m_xPositionLB->get_sensitive())
678 m_aCtlBitmapPreview.SetAttributes( m_aXFillAttr.GetItemSet() );
679 m_aCtlBitmapPreview.Invalidate();
684 if (m_xPositionOffX->get_sensitive())
687 if (m_xPositionOffY->get_sensitive())
690 m_aCtlBitmapPreview.SetAttributes( m_aXFillAttr.GetItemSet() );
691 m_aCtlBitmapPreview.Invalidate();
696 sal_uInt16 nTileXOff = 0;
697 sal_uInt16 nTileYOff = 0;
699 if(m_xTileOffLB->get_active() ==
static_cast<sal_Int32
>(
ROW))
700 nTileXOff = m_xTileOffset->get_value(FieldUnit::PERCENT);
702 if(m_xTileOffLB->get_active() ==
static_cast<sal_Int32
>(
COLUMN))
703 nTileYOff = m_xTileOffset->get_value(FieldUnit::PERCENT);
708 m_aCtlBitmapPreview.SetAttributes( m_aXFillAttr.GetItemSet() );
709 m_aCtlBitmapPreview.Invalidate();
725 std::unique_ptr<weld::WaitObject> xWait(
new weld::WaitObject(pDialogFrameWeld));
731 OUString aDesc(
CuiResId(RID_CUISTR_DESC_EXT_BITMAP));
738 pDialogFrameWeld,
aURL.GetLastName().getToken(0,
'.'), aDesc));
741 while( pDlg->Execute() ==
RET_OK )
743 pDlg->GetName(
aName );
745 bool bDifferent =
true;
748 if(
aName == m_pBitmapList->GetBitmap(
i )->GetName() )
757 std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(
"DuplicateNameDialog"));
758 if (xBox->run() !=
RET_OK)
766 m_pBitmapList->Insert(std::make_unique<XBitmapEntry>(aGraphic,
aName),
nCount);
768 sal_Int32
nId = m_xBitmapLB->GetItemId(
nCount - 1 );
769 BitmapEx aBitmap = m_pBitmapList->GetBitmapForPreview(
nCount, m_xBitmapLB->GetIconSize() );
772 m_xBitmapLB->SelectItem(
nId + 1 );
773 *m_pnBitmapListState |= ChangeType::MODIFIED;
775 ModifyBitmapHdl(m_xBitmapLB.get());
782 std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog(
"NoLoadedFileDialog"));
806 bool bValidBitmapName =
true;
814 bValidBitmapName =
false;
static OutputDevice * GetDefaultDevice()
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
const Size & GetSizePixel() const
OString GetUniqueID() const
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
SfxItemSet GetGeoAttrFromMarked() const
bool AreObjectsMarked() const
const Fraction & GetUIScale() const
SdrModel & GetModel() const
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
SfxItemPool * GetPool() const
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
static const SfxPoolItem * GetItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
virtual SdrView * GetDrawView() const
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
virtual VclPtr< AbstractSvxNameDialog > CreateSvxNameDialog(weld::Window *pParent, const OUString &rName, const OUString &rDesc)=0
static SvxAbstractDialogFactory * Create()
std::unique_ptr< weld::Button > m_xBtnImport
std::unique_ptr< SvxPresetListBox > m_xBitmapLB
std::unique_ptr< weld::MetricSpinButton > m_xBitmapWidth
std::unique_ptr< weld::MetricSpinButton > m_xPositionOffY
std::unique_ptr< weld::CheckButton > m_xTsbScale
XBitmapListRef m_pBitmapList
SvxXRectPreview m_aCtlBitmapPreview
std::unique_ptr< weld::MetricSpinButton > m_xPositionOffX
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
sal_Int32 SearchBitmapList(std::u16string_view rBitmapName)
virtual bool FillItemSet(SfxItemSet *) override
SvxBitmapTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rInAttrs)
std::unique_ptr< weld::ComboBox > m_xTileOffLB
std::unique_ptr< weld::MetricSpinButton > m_xTileOffset
std::unique_ptr< weld::ComboBox > m_xBitmapStyleLB
std::unique_ptr< weld::CustomWeld > m_xBitmapLBWin
std::unique_ptr< weld::MetricSpinButton > m_xBitmapHeight
XFillAttrSetItem m_aXFillAttr
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *)
std::unique_ptr< weld::ComboBox > m_xPositionLB
std::unique_ptr< weld::Container > m_xTileOffBox
virtual ~SvxBitmapTabPage() override
void ClickBitmapHdl_Impl()
virtual void Reset(const SfxItemSet *) override
void CalculateBitmapPresetSize()
std::unique_ptr< weld::CustomWeld > m_xCtlBitmapPreview
virtual void ActivatePage(const SfxItemSet &rSet) override
ErrCode GetGraphic(Graphic &) const
void SetAttributes(const SfxItemSet &rItemSet)
const GraphicObject & GetGraphicObject() const
const GraphicObject & GetGraphicObject() const
OUString CuiResId(TranslateId aKey)
#define DBG_ASSERT(sCon, aError)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Size SFX2_DLLPUBLIC getDrawPreviewOptimalSize(const OutputDevice &rReference)
virtual tools::Long GetValue() const override
SVXCORE_DLLPUBLIC FieldUnit GetModuleFieldUnit(const SfxItemSet &)
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
IMPL_LINK_NOARG(SvxBitmapTabPage, ModifyBitmapHdl, ValueSet *, void)
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)
#define VALUESET_ITEM_NOTFOUND
#define WB_NO_DIRECTSELECT
constexpr OUStringLiteral PERCENT(u"Percent")
constexpr TypedWhichId< XFillBmpPosOffsetYItem > XATTR_FILLBMP_POSOFFSETY(XATTR_FILL_FIRST+18)
constexpr TypedWhichId< XFillBmpPosItem > XATTR_FILLBMP_POS(XATTR_FILL_FIRST+8)
constexpr TypedWhichId< XFillBmpTileOffsetXItem > XATTR_FILLBMP_TILEOFFSETX(XATTR_FILL_FIRST+14)
constexpr TypedWhichId< SfxMetricItem > XATTR_FILLBMP_SIZEX(XATTR_FILL_FIRST+9)
constexpr TypedWhichId< XFillBmpPosOffsetXItem > XATTR_FILLBMP_POSOFFSETX(XATTR_FILL_FIRST+17)
constexpr TypedWhichId< XFillBmpTileOffsetYItem > XATTR_FILLBMP_TILEOFFSETY(XATTR_FILL_FIRST+15)
constexpr TypedWhichId< XFillBmpSizeYItem > XATTR_FILLBMP_SIZEY(XATTR_FILL_FIRST+10)
constexpr TypedWhichId< XFillBmpStretchItem > XATTR_FILLBMP_STRETCH(XATTR_FILL_FIRST+16)
constexpr TypedWhichId< XFillBmpSizeLogItem > XATTR_FILLBMP_SIZELOG(XATTR_FILL_FIRST+13)
constexpr TypedWhichId< XFillBmpTileItem > XATTR_FILLBMP_TILE(XATTR_FILL_FIRST+7)
constexpr TypedWhichId< XFillBitmapItem > XATTR_FILLBITMAP(XATTR_FILL_FIRST+4)
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)