diff options
Diffstat (limited to 'cui/source/tabpages/swpossizetabpage.cxx')
-rw-r--r-- | cui/source/tabpages/swpossizetabpage.cxx | 371 |
1 files changed, 199 insertions, 172 deletions
diff --git a/cui/source/tabpages/swpossizetabpage.cxx b/cui/source/tabpages/swpossizetabpage.cxx index 2b9c8c70a4b4..6789caaf477f 100644 --- a/cui/source/tabpages/swpossizetabpage.cxx +++ b/cui/source/tabpages/swpossizetabpage.cxx @@ -19,6 +19,7 @@ #include <memory> #include <cstddef> +#include <type_traits> #include <swpossizetabpage.hxx> #include <svx/dlgutil.hxx> #include <svx/anchorid.hxx> @@ -35,6 +36,10 @@ #include <com/sun/star/text/RelOrientation.hpp> #include <svx/svxids.hrc> #include <svtools/unitconv.hxx> +#include <osl/diagnose.h> +#include <svl/grabbagitem.hxx> + +#include <bitmaps.hlst> using namespace ::com::sun::star::text; @@ -204,7 +209,7 @@ FrmMap const aHFlyHtmlMap[] = // #i18732# - own vertical alignment map for to frame anchored objects // #i22305# -#define VERT_FRAME_REL (LB::VertFrame|LB::FlyVertPrintArea) +#define VERT_FRAME_REL (LB::FlyVertFrame|LB::FlyVertPrintArea) FrmMap const aVFrameMap[] = { @@ -378,66 +383,67 @@ FrmMap const aVAsCharHtmlMap[] = static std::size_t lcl_GetFrmMapCount(const FrmMap* pMap) { - if( pMap ) - { - if( pMap == aVParaHtmlMap ) - return SAL_N_ELEMENTS(aVParaHtmlMap); - if( pMap == aVAsCharHtmlMap ) - return SAL_N_ELEMENTS( aVAsCharHtmlMap ); - if( pMap == aHParaHtmlMap ) - return SAL_N_ELEMENTS( aHParaHtmlMap ); - if( pMap == aHParaHtmlAbsMap ) - return SAL_N_ELEMENTS( aHParaHtmlAbsMap ); - if( pMap == aVPageMap ) - return SAL_N_ELEMENTS( aVPageMap ); - if( pMap == aVPageHtmlMap ) - return SAL_N_ELEMENTS( aVPageHtmlMap ); - if( pMap == aVAsCharMap ) - return SAL_N_ELEMENTS( aVAsCharMap ); - if( pMap == aVParaMap ) - return SAL_N_ELEMENTS( aVParaMap ); - if( pMap == aHParaMap ) - return SAL_N_ELEMENTS( aHParaMap ); - if( pMap == aHFrameMap ) - return SAL_N_ELEMENTS( aHFrameMap ); - if( pMap == aVFrameMap ) - return SAL_N_ELEMENTS( aVFrameMap ); - if( pMap == aHCharMap ) - return SAL_N_ELEMENTS( aHCharMap ); - if( pMap == aHCharHtmlMap ) - return SAL_N_ELEMENTS( aHCharHtmlMap ); - if( pMap == aHCharHtmlAbsMap ) - return SAL_N_ELEMENTS( aHCharHtmlAbsMap ); - if( pMap == aVCharMap ) - return SAL_N_ELEMENTS( aVCharMap ); - if( pMap == aVCharHtmlMap ) - return SAL_N_ELEMENTS( aVCharHtmlMap ); - if( pMap == aVCharHtmlAbsMap ) - return SAL_N_ELEMENTS( aVCharHtmlAbsMap ); - if( pMap == aHPageHtmlMap ) - return SAL_N_ELEMENTS( aHPageHtmlMap ); - if( pMap == aHFlyHtmlMap ) - return SAL_N_ELEMENTS( aHFlyHtmlMap ); - if( pMap == aVFlyHtmlMap ) - return SAL_N_ELEMENTS( aVFlyHtmlMap ); - if( pMap == aVMultiSelectionMap ) - return SAL_N_ELEMENTS( aVMultiSelectionMap ); - if( pMap == aHMultiSelectionMap ) - return SAL_N_ELEMENTS( aHMultiSelectionMap ); - return SAL_N_ELEMENTS(aHPageMap); - } - return 0; + if( !pMap ) + return 0; + + if( pMap == aVParaHtmlMap ) + return std::size(aVParaHtmlMap); + if( pMap == aVAsCharHtmlMap ) + return std::size( aVAsCharHtmlMap ); + if( pMap == aHParaHtmlMap ) + return std::size( aHParaHtmlMap ); + if( pMap == aHParaHtmlAbsMap ) + return std::size( aHParaHtmlAbsMap ); + if( pMap == aVPageMap ) + return std::size( aVPageMap ); + if( pMap == aVPageHtmlMap ) + return std::size( aVPageHtmlMap ); + if( pMap == aVAsCharMap ) + return std::size( aVAsCharMap ); + if( pMap == aVParaMap ) + return std::size( aVParaMap ); + if( pMap == aHParaMap ) + return std::size( aHParaMap ); + if( pMap == aHFrameMap ) + return std::size( aHFrameMap ); + if( pMap == aVFrameMap ) + return std::size( aVFrameMap ); + if( pMap == aHCharMap ) + return std::size( aHCharMap ); + if( pMap == aHCharHtmlMap ) + return std::size( aHCharHtmlMap ); + if( pMap == aHCharHtmlAbsMap ) + return std::size( aHCharHtmlAbsMap ); + if( pMap == aVCharMap ) + return std::size( aVCharMap ); + if( pMap == aVCharHtmlMap ) + return std::size( aVCharHtmlMap ); + if( pMap == aVCharHtmlAbsMap ) + return std::size( aVCharHtmlAbsMap ); + if( pMap == aHPageHtmlMap ) + return std::size( aHPageHtmlMap ); + if( pMap == aHFlyHtmlMap ) + return std::size( aHFlyHtmlMap ); + if( pMap == aVFlyHtmlMap ) + return std::size( aVFlyHtmlMap ); + if( pMap == aVMultiSelectionMap ) + return std::size( aVMultiSelectionMap ); + if( pMap == aHMultiSelectionMap ) + return std::size( aHMultiSelectionMap ); + return std::size(aHPageMap); } static SvxSwFramePosString::StringId lcl_ChangeResIdToVerticalOrRTL( - SvxSwFramePosString::StringId eStringId, bool bVertical, bool bRTL) + SvxSwFramePosString::StringId eStringId, bool bVertical, bool bRTL, bool bDontMirrorRTL) { //special handling of STR_FROMLEFT if(SvxSwFramePosString::FROMLEFT == eStringId) { + bool bMirrorRtlDrawObjs = !bDontMirrorRTL; + bool bSwapLR = bRTL && bMirrorRtlDrawObjs; eStringId = bVertical ? bRTL ? SvxSwFramePosString::FROMBOTTOM : SvxSwFramePosString::FROMTOP : - bRTL ? SvxSwFramePosString::FROMRIGHT : SvxSwFramePosString::FROMLEFT; + bSwapLR ? SvxSwFramePosString::FROMRIGHT : SvxSwFramePosString::FROMLEFT; return eStringId; } if(bVertical) @@ -465,19 +471,19 @@ static SvxSwFramePosString::StringId lcl_ChangeResIdToVerticalOrRTL( {SvxSwFramePosString::REL_FRM_TOP, SvxSwFramePosString::REL_FRM_LEFT }, {SvxSwFramePosString::REL_FRM_BOTTOM, SvxSwFramePosString::REL_FRM_RIGHT } }; - for(size_t nIndex = 0; nIndex < SAL_N_ELEMENTS(aHoriIds); ++nIndex) + for(const auto &a : aHoriIds) { - if(aHoriIds[nIndex].eHori == eStringId) + if(a.eHori == eStringId) { - eStringId = aHoriIds[nIndex].eVert; + eStringId = a.eVert; return eStringId; } } - for(size_t nIndex = 0; nIndex < SAL_N_ELEMENTS(aVertIds); ++nIndex) + for(const auto &a : aVertIds) { - if(aVertIds[nIndex].eHori == eStringId) + if(a.eHori == eStringId) { - eStringId = aVertIds[nIndex].eVert; + eStringId = a.eVert; break; } } @@ -523,7 +529,7 @@ static LB lcl_GetLBRelationsForStrID(const FrmMap* _pMap, } SvxSwPosSizeTabPage::SvxSwPosSizeTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) - : SfxTabPage(pPage, pController, "cui/ui/swpossizepage.ui", "SwPosSizePage", &rInAttrs) + : SfxTabPage(pPage, pController, u"cui/ui/swpossizepage.ui"_ustr, u"SwPosSizePage"_ustr, &rInAttrs) , m_pVMap(nullptr) , m_pHMap(nullptr) , m_pSdrView(nullptr) @@ -538,32 +544,37 @@ SvxSwPosSizeTabPage::SvxSwPosSizeTabPage(weld::Container* pPage, weld::DialogCon , m_bIsMultiSelection(false) , m_bIsInRightToLeft(false) , m_nProtectSizeState(TRISTATE_FALSE) - , m_xWidthMF(m_xBuilder->weld_metric_spin_button("width", FieldUnit::CM)) - , m_xHeightMF(m_xBuilder->weld_metric_spin_button("height", FieldUnit::CM)) - , m_xKeepRatioCB(m_xBuilder->weld_check_button("ratio")) - , m_xToPageRB(m_xBuilder->weld_radio_button("topage")) - , m_xToParaRB(m_xBuilder->weld_radio_button("topara")) - , m_xToCharRB(m_xBuilder->weld_radio_button("tochar")) - , m_xAsCharRB(m_xBuilder->weld_radio_button("aschar")) - , m_xToFrameRB(m_xBuilder->weld_radio_button("toframe")) - , m_xPositionCB(m_xBuilder->weld_check_button("pos")) - , m_xSizeCB(m_xBuilder->weld_check_button("size")) - , m_xPosFrame(m_xBuilder->weld_widget("posframe")) - , m_xHoriFT(m_xBuilder->weld_label("horiposft")) - , m_xHoriLB(m_xBuilder->weld_combo_box("horipos")) - , m_xHoriByFT(m_xBuilder->weld_label("horibyft")) - , m_xHoriByMF(m_xBuilder->weld_metric_spin_button("byhori", FieldUnit::CM)) - , m_xHoriToFT(m_xBuilder->weld_label("horitoft")) - , m_xHoriToLB(m_xBuilder->weld_combo_box("horianchor")) - , m_xHoriMirrorCB(m_xBuilder->weld_check_button("mirror")) - , m_xVertFT(m_xBuilder->weld_label("vertposft")) - , m_xVertLB(m_xBuilder->weld_combo_box("vertpos")) - , m_xVertByFT(m_xBuilder->weld_label("vertbyft")) - , m_xVertByMF(m_xBuilder->weld_metric_spin_button("byvert", FieldUnit::CM)) - , m_xVertToFT(m_xBuilder->weld_label("verttoft")) - , m_xVertToLB(m_xBuilder->weld_combo_box("vertanchor")) - , m_xFollowCB(m_xBuilder->weld_check_button("followtextflow")) - , m_xExampleWN(new weld::CustomWeld(*m_xBuilder, "preview", m_aExampleWN)) + , m_aRatioTop(ConnectorType::Top) + , m_aRatioBottom(ConnectorType::Bottom) + , m_xWidthMF(m_xBuilder->weld_metric_spin_button(u"width"_ustr, FieldUnit::CM)) + , m_xHeightMF(m_xBuilder->weld_metric_spin_button(u"height"_ustr, FieldUnit::CM)) + , m_xKeepRatioCB(m_xBuilder->weld_check_button(u"ratio"_ustr)) + , m_xCbxScaleImg(m_xBuilder->weld_image(u"imRatio"_ustr)) + , m_xImgRatioTop(new weld::CustomWeld(*m_xBuilder, u"daRatioTop"_ustr, m_aRatioTop)) + , m_xImgRatioBottom(new weld::CustomWeld(*m_xBuilder, u"daRatioBottom"_ustr, m_aRatioBottom)) + , m_xToPageRB(m_xBuilder->weld_radio_button(u"topage"_ustr)) + , m_xToParaRB(m_xBuilder->weld_radio_button(u"topara"_ustr)) + , m_xToCharRB(m_xBuilder->weld_radio_button(u"tochar"_ustr)) + , m_xAsCharRB(m_xBuilder->weld_radio_button(u"aschar"_ustr)) + , m_xToFrameRB(m_xBuilder->weld_radio_button(u"toframe"_ustr)) + , m_xPositionCB(m_xBuilder->weld_check_button(u"pos"_ustr)) + , m_xSizeCB(m_xBuilder->weld_check_button(u"size"_ustr)) + , m_xPosFrame(m_xBuilder->weld_widget(u"posframe"_ustr)) + , m_xHoriFT(m_xBuilder->weld_label(u"horiposft"_ustr)) + , m_xHoriLB(m_xBuilder->weld_combo_box(u"horipos"_ustr)) + , m_xHoriByFT(m_xBuilder->weld_label(u"horibyft"_ustr)) + , m_xHoriByMF(m_xBuilder->weld_metric_spin_button(u"byhori"_ustr, FieldUnit::CM)) + , m_xHoriToFT(m_xBuilder->weld_label(u"horitoft"_ustr)) + , m_xHoriToLB(m_xBuilder->weld_combo_box(u"horianchor"_ustr)) + , m_xHoriMirrorCB(m_xBuilder->weld_check_button(u"mirror"_ustr)) + , m_xVertFT(m_xBuilder->weld_label(u"vertposft"_ustr)) + , m_xVertLB(m_xBuilder->weld_combo_box(u"vertpos"_ustr)) + , m_xVertByFT(m_xBuilder->weld_label(u"vertbyft"_ustr)) + , m_xVertByMF(m_xBuilder->weld_metric_spin_button(u"byvert"_ustr, FieldUnit::CM)) + , m_xVertToFT(m_xBuilder->weld_label(u"verttoft"_ustr)) + , m_xVertToLB(m_xBuilder->weld_combo_box(u"vertanchor"_ustr)) + , m_xFollowCB(m_xBuilder->weld_check_button(u"followtextflow"_ustr)) + , m_xExampleWN(new weld::CustomWeld(*m_xBuilder, u"preview"_ustr, m_aExampleWN)) { setOptimalFrmWidth(); setOptimalRelWidth(); @@ -574,6 +585,20 @@ SvxSwPosSizeTabPage::SvxSwPosSizeTabPage(weld::Container* pPage, weld::DialogCon SetFieldUnit(*m_xWidthMF , eDlgUnit, true); SetFieldUnit(*m_xHeightMF, eDlgUnit, true); + // vertical alignment = fill makes the drawingarea expand the associated spinedits so we have to size it here + const sal_Int16 aHeight + = static_cast<sal_Int16>(std::max(int(m_xKeepRatioCB->get_preferred_size().getHeight() / 2 + - m_xWidthMF->get_preferred_size().getHeight() / 2), + 12)); + const sal_Int16 aWidth + = static_cast<sal_Int16>(m_xKeepRatioCB->get_preferred_size().getWidth() / 2); + m_xImgRatioTop->set_size_request(aWidth, aHeight); + m_xImgRatioBottom->set_size_request(aWidth, aHeight); + //init needed for gtk3 + m_xCbxScaleImg->set_from_icon_name(m_xKeepRatioCB->get_active() ? RID_SVXBMP_LOCKED + : RID_SVXBMP_UNLOCKED); + m_xKeepRatioCB->connect_toggled(LINK(this, SvxSwPosSizeTabPage, RatioHdl_Impl)); + SetExchangeSupport(); Link<weld::Widget&,void> aLk3 = LINK(this, SvxSwPosSizeTabPage, RangeModifyHdl); @@ -589,7 +614,7 @@ SvxSwPosSizeTabPage::SvxSwPosSizeTabPage(weld::Container* pPage, weld::DialogCon m_xHoriByMF->connect_value_changed( aLk ); m_xVertByMF->connect_value_changed( aLk ); - Link<weld::ToggleButton&,void> aLk2 = LINK(this, SvxSwPosSizeTabPage, AnchorTypeHdl); + Link<weld::Toggleable&,void> aLk2 = LINK(this, SvxSwPosSizeTabPage, AnchorTypeHdl); m_xToPageRB->connect_toggled( aLk2 ); m_xToParaRB->connect_toggled( aLk2 ); m_xToCharRB->connect_toggled( aLk2 ); @@ -626,27 +651,27 @@ namespace void SvxSwPosSizeTabPage::setOptimalFrmWidth() { static const FrmMaps aMaps[] = { - { aHPageMap, SAL_N_ELEMENTS(aHPageMap) }, - { aHPageHtmlMap, SAL_N_ELEMENTS(aHPageHtmlMap) }, - { aVPageMap, SAL_N_ELEMENTS(aVPageMap) }, - { aVPageHtmlMap, SAL_N_ELEMENTS(aVPageHtmlMap) }, - { aHFrameMap, SAL_N_ELEMENTS(aHFrameMap) }, - { aHFlyHtmlMap, SAL_N_ELEMENTS(aHFlyHtmlMap) }, - { aVFrameMap, SAL_N_ELEMENTS(aVFrameMap) }, - { aVFlyHtmlMap, SAL_N_ELEMENTS(aVFlyHtmlMap) }, - { aHParaMap, SAL_N_ELEMENTS(aHParaMap) }, - { aHParaHtmlMap, SAL_N_ELEMENTS(aHParaHtmlMap) }, - { aHParaHtmlAbsMap, SAL_N_ELEMENTS(aHParaHtmlAbsMap) }, - { aVParaMap, SAL_N_ELEMENTS(aVParaMap) }, - { aVParaHtmlMap, SAL_N_ELEMENTS(aVParaHtmlMap) }, - { aHCharMap, SAL_N_ELEMENTS(aHCharMap) }, - { aHCharHtmlMap, SAL_N_ELEMENTS(aHCharHtmlMap) }, - { aHCharHtmlAbsMap, SAL_N_ELEMENTS(aHCharHtmlAbsMap) }, - { aVCharMap, SAL_N_ELEMENTS(aVCharMap) }, - { aVCharHtmlMap, SAL_N_ELEMENTS(aVCharHtmlMap) }, - { aVCharHtmlAbsMap, SAL_N_ELEMENTS(aVCharHtmlAbsMap) }, - { aVAsCharMap, SAL_N_ELEMENTS(aVAsCharMap) }, - { aVAsCharHtmlMap, SAL_N_ELEMENTS(aVAsCharHtmlMap) } + { aHPageMap, std::size(aHPageMap) }, + { aHPageHtmlMap, std::size(aHPageHtmlMap) }, + { aVPageMap, std::size(aVPageMap) }, + { aVPageHtmlMap, std::size(aVPageHtmlMap) }, + { aHFrameMap, std::size(aHFrameMap) }, + { aHFlyHtmlMap, std::size(aHFlyHtmlMap) }, + { aVFrameMap, std::size(aVFrameMap) }, + { aVFlyHtmlMap, std::size(aVFlyHtmlMap) }, + { aHParaMap, std::size(aHParaMap) }, + { aHParaHtmlMap, std::size(aHParaHtmlMap) }, + { aHParaHtmlAbsMap, std::size(aHParaHtmlAbsMap) }, + { aVParaMap, std::size(aVParaMap) }, + { aVParaHtmlMap, std::size(aVParaHtmlMap) }, + { aHCharMap, std::size(aHCharMap) }, + { aHCharHtmlMap, std::size(aHCharHtmlMap) }, + { aHCharHtmlAbsMap, std::size(aHCharHtmlAbsMap) }, + { aVCharMap, std::size(aVCharMap) }, + { aVCharHtmlMap, std::size(aVCharHtmlMap) }, + { aVCharHtmlAbsMap, std::size(aVCharHtmlAbsMap) }, + { aVAsCharMap, std::size(aVAsCharMap) }, + { aVAsCharHtmlMap, std::size(aVAsCharHtmlMap) } }; std::vector<SvxSwFramePosString::StringId> aFrames; @@ -685,8 +710,8 @@ namespace void SvxSwPosSizeTabPage::setOptimalRelWidth() { static const RelationMaps aMaps[] = { - { aRelationMap, SAL_N_ELEMENTS(aRelationMap) }, - { aAsCharRelationMap, SAL_N_ELEMENTS(aAsCharRelationMap) } + { aRelationMap, std::size(aRelationMap) }, + { aAsCharRelationMap, std::size(aAsCharRelationMap) } }; std::vector<SvxSwFramePosString::StringId> aRels; @@ -718,33 +743,19 @@ std::unique_ptr<SfxTabPage> SvxSwPosSizeTabPage::Create(weld::Container* pPage, return std::make_unique<SvxSwPosSizeTabPage>(pPage, pController, *rSet); } -const sal_uInt16* SvxSwPosSizeTabPage::GetRanges() +WhichRangesContainer SvxSwPosSizeTabPage::GetRanges() { - static const sal_uInt16 pSwPosRanges[] = - { - SID_ATTR_TRANSFORM_POS_X, - SID_ATTR_TRANSFORM_POS_Y, - SID_ATTR_TRANSFORM_PROTECT_POS, - SID_ATTR_TRANSFORM_PROTECT_POS, - SID_ATTR_TRANSFORM_INTERN, - SID_ATTR_TRANSFORM_INTERN, - SID_ATTR_TRANSFORM_ANCHOR, - SID_ATTR_TRANSFORM_VERT_ORIENT, - SID_ATTR_TRANSFORM_WIDTH, - SID_ATTR_TRANSFORM_SIZE_POINT, - SID_ATTR_TRANSFORM_PROTECT_POS, - SID_ATTR_TRANSFORM_INTERN, - SID_ATTR_TRANSFORM_AUTOWIDTH, - SID_ATTR_TRANSFORM_VERT_ORIENT, - SID_HTML_MODE, - SID_HTML_MODE, - SID_SW_FOLLOW_TEXT_FLOW, - SID_SW_FOLLOW_TEXT_FLOW, - SID_ATTR_TRANSFORM_HORI_POSITION, - SID_ATTR_TRANSFORM_VERT_POSITION, - 0 - }; - return pSwPosRanges; + static const WhichRangesContainer ranges(svl::Items< + SID_ATTR_TRANSFORM_POS_X, SID_ATTR_TRANSFORM_POS_Y, + SID_ATTR_TRANSFORM_WIDTH, SID_ATTR_TRANSFORM_SIZE_POINT, + SID_ATTR_TRANSFORM_PROTECT_POS, SID_ATTR_TRANSFORM_INTERN, + SID_ATTR_TRANSFORM_AUTOWIDTH, SID_ATTR_TRANSFORM_VERT_ORIENT, + SID_HTML_MODE, SID_HTML_MODE, + SID_SW_FOLLOW_TEXT_FLOW, SID_SW_FOLLOW_TEXT_FLOW, + SID_ATTR_TRANSFORM_HORI_POSITION, SID_ATTR_TRANSFORM_VERT_POSITION, + SID_ATTR_CHAR_GRABBAG, SID_ATTR_CHAR_GRABBAG + >); + return ranges; } bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) @@ -763,7 +774,7 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) rSet->InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_POS ); else rSet->Put( - SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS ), + SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_POS, m_xPositionCB->get_state() == TRISTATE_TRUE ) ); bModified = true; } @@ -774,7 +785,7 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) rSet->InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_SIZE ); else rSet->Put( - SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE ), + SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE, m_xSizeCB->get_state() == TRISTATE_TRUE ) ); bModified = true; } @@ -798,8 +809,8 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) nHoriByPos += m_aAnchorPos.X(); nVertByPos += m_aAnchorPos.Y(); - rSet->Put( SfxInt32Item( GetWhich( SID_ATTR_TRANSFORM_POS_X ), nHoriByPos ) ); - rSet->Put( SfxInt32Item( GetWhich( SID_ATTR_TRANSFORM_POS_Y ), nVertByPos ) ); + rSet->Put( SfxInt32Item( SID_ATTR_TRANSFORM_POS_X, nHoriByPos ) ); + rSet->Put( SfxInt32Item( SID_ATTR_TRANSFORM_POS_Y, nVertByPos ) ); bModified = true; } @@ -809,11 +820,11 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) if ( m_pHMap ) { const SfxInt16Item& rHoriOrient = - static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_HORI_ORIENT)); + rOldSet.Get( SID_ATTR_TRANSFORM_HORI_ORIENT ); const SfxInt16Item& rHoriRelation = - static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_HORI_RELATION)); + rOldSet.Get( SID_ATTR_TRANSFORM_HORI_RELATION); const SfxInt32Item& rHoriPosition = - static_cast<const SfxInt32Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_HORI_POSITION)) ; + rOldSet.Get( SID_ATTR_TRANSFORM_HORI_POSITION); sal_uInt16 nMapPos = GetMapPos(m_pHMap, *m_xHoriLB); short nAlign = GetAlignment(m_pHMap, nMapPos, *m_xHoriToLB); @@ -838,11 +849,11 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) if ( m_pVMap ) { const SfxInt16Item& rVertOrient = - static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_VERT_ORIENT)); + rOldSet.Get( SID_ATTR_TRANSFORM_VERT_ORIENT); const SfxInt16Item& rVertRelation = - static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_VERT_RELATION)); + rOldSet.Get( SID_ATTR_TRANSFORM_VERT_RELATION); const SfxInt32Item& rVertPosition = - static_cast<const SfxInt32Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_VERT_POSITION)); + rOldSet.Get( SID_ATTR_TRANSFORM_VERT_POSITION); sal_uInt16 nMapPos = GetMapPos(m_pVMap, *m_xVertLB); short nAlign = GetAlignment(m_pVMap, nMapPos, *m_xVertToLB); @@ -876,7 +887,7 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) { std::unique_ptr<SfxBoolItem> pFollow(static_cast<SfxBoolItem*>(pItem->Clone())); pFollow->SetValue(m_xFollowCB->get_active()); - bModified |= nullptr != rSet->Put(*pFollow); + bModified |= nullptr != rSet->Put(std::move(pFollow)); } } } @@ -885,10 +896,10 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) { sal_uInt32 nWidth = static_cast<sal_uInt32>(m_xWidthMF->denormalize(m_xWidthMF->get_value(FieldUnit::TWIP))); sal_uInt32 nHeight = static_cast<sal_uInt32>(m_xHeightMF->denormalize(m_xHeightMF->get_value(FieldUnit::TWIP))); - rSet->Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_WIDTH ), nWidth ) ); - rSet->Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_HEIGHT ), nHeight ) ); + rSet->Put( SfxUInt32Item( SID_ATTR_TRANSFORM_WIDTH, nWidth ) ); + rSet->Put( SfxUInt32Item( SID_ATTR_TRANSFORM_HEIGHT, nHeight ) ); //this item is required by SdrEditView::SetGeoAttrToMarked() - rSet->Put( SfxUInt16Item( GetWhich( SID_ATTR_TRANSFORM_SIZE_POINT ), sal_uInt16(RectPoint::LT) ) ); + rSet->Put( SfxUInt16Item( SID_ATTR_TRANSFORM_SIZE_POINT, sal_uInt16(RectPoint::LT) ) ); bModified = true; } @@ -981,6 +992,17 @@ void SvxSwPosSizeTabPage::Reset( const SfxItemSet* rSet) } m_xFollowCB->save_state(); + const SfxGrabBagItem* pGrabBag = GetItem(*rSet, SID_ATTR_CHAR_GRABBAG); + if (pGrabBag) + { + const std::map<OUString, css::uno::Any>& rMap = pGrabBag->GetGrabBag(); + auto it = rMap.find(u"DoNotMirrorRtlDrawObjs"_ustr); + if (it != rMap.end()) + { + it->second >>= m_bDoNotMirrorRtlDrawObjs; + } + } + if(m_bHtmlMode) { m_xHoriMirrorCB->hide(); @@ -1064,9 +1086,9 @@ DeactivateRC SvxSwPosSizeTabPage::DeactivatePage( SfxItemSet* _pSet ) { if( _pSet ) { - _pSet->Put(SfxBoolItem(GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS ), + _pSet->Put(SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_POS, m_xPositionCB->get_active())); - _pSet->Put(SfxBoolItem(GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE ), + _pSet->Put(SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE, m_xSizeCB->get_active())); FillItemSet( _pSet ); } @@ -1123,7 +1145,12 @@ RndStdIds SvxSwPosSizeTabPage::GetAnchorType(bool* pbHasChanged) return nRet; } -IMPL_LINK_NOARG(SvxSwPosSizeTabPage, RangeModifyClickHdl, weld::ToggleButton&, void) +IMPL_LINK_NOARG(SvxSwPosSizeTabPage, RatioHdl_Impl, weld::Toggleable&, void) +{ + m_xCbxScaleImg->set_from_icon_name(m_xKeepRatioCB->get_active() ? RID_SVXBMP_LOCKED : RID_SVXBMP_UNLOCKED); +} + +IMPL_LINK_NOARG(SvxSwPosSizeTabPage, RangeModifyClickHdl, weld::Toggleable&, void) { RangeModifyHdl(m_xWidthMF->get_widget()); } @@ -1203,7 +1230,7 @@ IMPL_LINK_NOARG(SvxSwPosSizeTabPage, RangeModifyHdl, weld::Widget&, void) m_xVertByMF->set_value(m_xVertByMF->normalize(aVal.nVPos), FieldUnit::TWIP); } -IMPL_LINK_NOARG(SvxSwPosSizeTabPage, AnchorTypeHdl, weld::ToggleButton&, void) +IMPL_LINK_NOARG(SvxSwPosSizeTabPage, AnchorTypeHdl, weld::Toggleable&, void) { m_xHoriMirrorCB->set_sensitive(!m_xAsCharRB->get_active() && !m_bIsMultiSelection); @@ -1223,7 +1250,7 @@ IMPL_LINK_NOARG(SvxSwPosSizeTabPage, AnchorTypeHdl, weld::ToggleButton&, void) } } -IMPL_LINK_NOARG(SvxSwPosSizeTabPage, MirrorHdl, weld::ToggleButton&, void) +IMPL_LINK_NOARG(SvxSwPosSizeTabPage, MirrorHdl, weld::Toggleable&, void) { RndStdIds nId = GetAnchorType(); InitPos( nId, USHRT_MAX, 0, USHRT_MAX, 0, LONG_MAX, LONG_MAX); @@ -1283,7 +1310,7 @@ IMPL_LINK(SvxSwPosSizeTabPage, PosHdl, weld::ComboBox&, rLB, void) if (rLB.get_active() != -1) { if (pRelLB->get_active() != -1) - nRel = reinterpret_cast<RelationMap*>(pRelLB->get_active_id().toUInt64())->nRelation; + nRel = weld::fromId<RelationMap*>(pRelLB->get_active_id())->nRelation; FillRelLB(pMap, nMapPos, nAlign, nRel, *pRelLB, *pRelFT); } @@ -1369,7 +1396,7 @@ IMPL_LINK( SvxSwPosSizeTabPage, ModifyHdl, weld::MetricSpinButton&, rEdit, void UpdateExample(); } -IMPL_LINK_NOARG(SvxSwPosSizeTabPage, ProtectHdl, weld::ToggleButton&, void) +IMPL_LINK_NOARG(SvxSwPosSizeTabPage, ProtectHdl, weld::Toggleable&, void) { if (m_xSizeCB->get_sensitive()) { @@ -1386,7 +1413,7 @@ short SvxSwPosSizeTabPage::GetRelation(const weld::ComboBox& rRelationLB) int nPos = rRelationLB.get_active(); if (nPos != -1) { - RelationMap *pEntry = reinterpret_cast<RelationMap*>(rRelationLB.get_id(nPos).toUInt64()); + RelationMap *pEntry = weld::fromId<RelationMap*>(rRelationLB.get_id(nPos)); nRel = pEntry->nRelation; } @@ -1404,7 +1431,7 @@ short SvxSwPosSizeTabPage::GetAlignment(FrmMap const *pMap, sal_uInt16 nMapPos, { if (rRelationLB.get_active() != -1) { - LB nRel = reinterpret_cast<RelationMap*>(rRelationLB.get_active_id().toUInt64())->nLBRelation; + LB nRel = weld::fromId<RelationMap*>(rRelationLB.get_active_id())->nLBRelation; std::size_t nMapCount = ::lcl_GetFrmMapCount(pMap); SvxSwFramePosString::StringId eStrId = pMap[nMapPos].eStrId; @@ -1474,7 +1501,7 @@ void SvxSwPosSizeTabPage::InitPos(RndStdIds nAnchor, m_nOldV = m_pVMap[nPos].nAlign; nPos = m_xVertToLB->get_active(); if (nPos != -1) - m_nOldVRel = reinterpret_cast<RelationMap*>(m_xVertToLB->get_id(nPos).toUInt64())->nRelation; + m_nOldVRel = weld::fromId<RelationMap*>(m_xVertToLB->get_id(nPos))->nRelation; } nPos = m_xHoriLB->get_active(); @@ -1484,7 +1511,7 @@ void SvxSwPosSizeTabPage::InitPos(RndStdIds nAnchor, nPos = m_xHoriToLB->get_active(); if (nPos != -1) - m_nOldHRel = reinterpret_cast<RelationMap*>(m_xHoriToLB->get_id(nPos).toUInt64())->nRelation; + m_nOldHRel = weld::fromId<RelationMap*>(m_xHoriToLB->get_id(nPos))->nRelation; } bool bEnable = true; @@ -1659,15 +1686,15 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ if (pMap[_nMapPos].eStrId == eStrId) { nLBRelations = pMap[_nMapPos].nLBRelations; - for (size_t nRelPos = 0; nRelPos < SAL_N_ELEMENTS(aAsCharRelationMap); nRelPos++) + for (size_t nRelPos = 0; nRelPos < std::size(aAsCharRelationMap); nRelPos++) { if (nLBRelations & aAsCharRelationMap[nRelPos].nLBRelation) { SvxSwFramePosString::StringId sStrId1 = aAsCharRelationMap[nRelPos].eStrId; - sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, m_bIsVerticalFrame, m_bIsInRightToLeft); + sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, m_bIsVerticalFrame, m_bIsInRightToLeft, m_bDoNotMirrorRtlDrawObjs); OUString sEntry = SvxSwFramePosString::GetString(sStrId1); - rLB.append(OUString::number(reinterpret_cast<sal_uInt64>(&aAsCharRelationMap[nRelPos])), sEntry); + rLB.append(weld::toId(&aAsCharRelationMap[nRelPos]), sEntry); if (pMap[_nMapPos].nAlign == nAlign) sSelEntry = sEntry; break; @@ -1684,7 +1711,7 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ { for (int i = 0; i < rLB.get_count(); i++) { - RelationMap *pEntry = reinterpret_cast<RelationMap*>(rLB.get_id(i).toUInt64()); + RelationMap *pEntry = weld::fromId<RelationMap*>(rLB.get_id(i)); if (pEntry->nLBRelation == LB::RelChar) // Default { rLB.set_active(i); @@ -1711,18 +1738,18 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ nLBRelations = pMap[nMapPos].nLBRelations; } - for (sal_uLong nBit = 1; nBit < sal_uLong(LB::LAST); nBit <<= 1) + for (std::underlying_type_t<LB> nBit = 1; nBit < o3tl::to_underlying(LB::LAST) ; nBit <<= 1) { if (nLBRelations & static_cast<LB>(nBit)) { - for (size_t nRelPos = 0; nRelPos < SAL_N_ELEMENTS(aRelationMap); nRelPos++) + for (size_t nRelPos = 0; nRelPos < std::size(aRelationMap); nRelPos++) { if (aRelationMap[nRelPos].nLBRelation == static_cast<LB>(nBit)) { SvxSwFramePosString::StringId sStrId1 = m_xHoriMirrorCB->get_active() ? aRelationMap[nRelPos].eMirrorStrId : aRelationMap[nRelPos].eStrId; - sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, m_bIsVerticalFrame, m_bIsInRightToLeft); + sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, m_bIsVerticalFrame, m_bIsInRightToLeft, m_bDoNotMirrorRtlDrawObjs); OUString sEntry = SvxSwFramePosString::GetString(sStrId1); - rLB.append(OUString::number(reinterpret_cast<sal_uInt64>(&aRelationMap[nRelPos])), sEntry); + rLB.append(weld::toId(&aRelationMap[nRelPos]), sEntry); if (sSelEntry.isEmpty() && aRelationMap[nRelPos].nRelation == nRel) sSelEntry = sEntry; } @@ -1748,7 +1775,7 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ default: if (rLB.get_count()) { - RelationMap *pEntry = reinterpret_cast<RelationMap*>(rLB.get_id(rLB.get_count() - 1).toUInt64()); + RelationMap *pEntry = weld::fromId<RelationMap*>(rLB.get_id(rLB.get_count() - 1)); nRel = pEntry->nRelation; } break; @@ -1756,7 +1783,7 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ for (int i = 0; i < rLB.get_count(); ++i) { - RelationMap *pEntry = reinterpret_cast<RelationMap*>(rLB.get_id(i).toUInt64()); + RelationMap *pEntry = weld::fromId<RelationMap*>(rLB.get_id(i)); if (pEntry->nRelation == nRel) { rLB.set_active(i); @@ -1797,7 +1824,7 @@ sal_uInt16 SvxSwPosSizeTabPage::FillPosLB(FrmMap const *_pMap, for (std::size_t i = 0; _pMap && i < nCount; ++i) { SvxSwFramePosString::StringId eStrId = m_xHoriMirrorCB->get_active() ? _pMap[i].eMirrorStrId : _pMap[i].eStrId; - eStrId = lcl_ChangeResIdToVerticalOrRTL(eStrId, m_bIsVerticalFrame, m_bIsInRightToLeft); + eStrId = lcl_ChangeResIdToVerticalOrRTL(eStrId, m_bIsVerticalFrame, m_bIsInRightToLeft, m_bDoNotMirrorRtlDrawObjs); OUString sEntry(SvxSwFramePosString::GetString(eStrId)); if (_rLB.find_text(sEntry) == -1) { @@ -1881,7 +1908,7 @@ void SvxSwPosSizeTabPage::SetView( const SdrView* pSdrView ) const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier(); if( ( pObj->GetObjInventor() == SdrInventor::Default ) && - ( eKind==OBJ_TEXT || eKind==OBJ_TITLETEXT || eKind==OBJ_OUTLINETEXT) && + ( eKind==SdrObjKind::Text || eKind==SdrObjKind::TitleText || eKind==SdrObjKind::OutlineText) && pObj->HasText() ) { OSL_FAIL("AutoWidth/AutoHeight should be enabled"); |