diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-05-28 14:33:42 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-05-29 10:07:40 +0200 |
commit | c4041a3b6c703254ee3977eef1a989992506772b (patch) | |
tree | f696f93baa565d865fd8a883da6d6e9d689e9eb2 | |
parent | 66cd438e3545edecaa05aa27beb289c6a6df53fc (diff) |
weld SvxSwPosSizeTabPage
Change-Id: I51c83ec801884a07f7920309535a58b55171b0be
Reviewed-on: https://gerrit.libreoffice.org/54934
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | cui/source/inc/swpossizetabpage.hxx | 97 | ||||
-rw-r--r-- | cui/source/tabpages/swpossizetabpage.cxx | 746 | ||||
-rw-r--r-- | cui/uiconfig/ui/swpossizepage.ui | 64 | ||||
-rw-r--r-- | include/svx/swframeexample.hxx | 65 | ||||
-rw-r--r-- | include/vcl/weld.hxx | 4 | ||||
-rw-r--r-- | starmath/source/dialog.cxx | 8 | ||||
-rw-r--r-- | svx/source/dialog/swframeexample.cxx | 666 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 5 |
8 files changed, 1168 insertions, 487 deletions
diff --git a/cui/source/inc/swpossizetabpage.hxx b/cui/source/inc/swpossizetabpage.hxx index b10e2ca7617f..d9e326dee456 100644 --- a/cui/source/inc/swpossizetabpage.hxx +++ b/cui/source/inc/swpossizetabpage.hxx @@ -20,12 +20,9 @@ #define INCLUDED_CUI_SOURCE_INC_SWPOSSIZETABPAGE_HXX #include <sfx2/tabdlg.hxx> -#include <vcl/fixed.hxx> -#include <vcl/field.hxx> -#include <vcl/layout.hxx> -#include <vcl/lstbox.hxx> #include <svx/swframeposstrings.hxx> #include <svx/swframeexample.hxx> +#include <vcl/weld.hxx> // SvxSwPosSizeTabPage - position and size page for Writer drawing objects struct FrmMap; @@ -37,40 +34,6 @@ class SvxSwPosSizeTabPage : public SfxTabPage { using TabPage::DeactivatePage; - VclPtr<MetricField> m_pWidthMF; - VclPtr<MetricField> m_pHeightMF; - VclPtr<CheckBox> m_pKeepRatioCB; - - VclPtr<RadioButton> m_pToPageRB; - VclPtr<RadioButton> m_pToParaRB; - VclPtr<RadioButton> m_pToCharRB; - VclPtr<RadioButton> m_pAsCharRB; - VclPtr<RadioButton> m_pToFrameRB; - - VclPtr<TriStateBox> m_pPositionCB; - VclPtr<TriStateBox> m_pSizeCB; - - VclPtr<VclContainer> m_pPosFrame; - VclPtr<FixedText> m_pHoriFT; - VclPtr<ListBox> m_pHoriLB; - VclPtr<FixedText> m_pHoriByFT; - VclPtr<MetricField> m_pHoriByMF; - VclPtr<FixedText> m_pHoriToFT; - VclPtr<ListBox> m_pHoriToLB; - - VclPtr<CheckBox> m_pHoriMirrorCB; - - VclPtr<FixedText> m_pVertFT; - VclPtr<ListBox> m_pVertLB; - VclPtr<FixedText> m_pVertByFT; - VclPtr<MetricField> m_pVertByMF; - VclPtr<FixedText> m_pVertToFT; - VclPtr<ListBox> m_pVertToLB; - - VclPtr<CheckBox> m_pFollowCB; - - VclPtr<SvxSwFrameExample> m_pExampleWN; - Link<SvxSwFrameValidation&,void> m_aValidateLink; ::tools::Rectangle m_aRect; //size of all selected objects @@ -95,24 +58,53 @@ class SvxSwPosSizeTabPage : public SfxTabPage bool m_bIsInRightToLeft; TriState m_nProtectSizeState; - DECL_LINK(RangeModifyHdl, Control&, void); - DECL_LINK(RangeModifyClickHdl, Button*, void); - DECL_LINK(AnchorTypeHdl, Button*, void); - DECL_LINK( PosHdl, ListBox&, void ); - DECL_LINK( RelHdl, ListBox&, void ); - DECL_LINK(MirrorHdl, Button*, void); - DECL_LINK( ModifyHdl, Edit&, void ); - DECL_LINK(ProtectHdl, Button*, void); + SwFrameExample m_aExampleWN; + + std::unique_ptr<weld::MetricSpinButton> m_xWidthMF; + std::unique_ptr<weld::MetricSpinButton> m_xHeightMF; + std::unique_ptr<weld::CheckButton> m_xKeepRatioCB; + std::unique_ptr<weld::RadioButton> m_xToPageRB; + std::unique_ptr<weld::RadioButton> m_xToParaRB; + std::unique_ptr<weld::RadioButton> m_xToCharRB; + std::unique_ptr<weld::RadioButton> m_xAsCharRB; + std::unique_ptr<weld::RadioButton> m_xToFrameRB; + std::unique_ptr<weld::CheckButton> m_xPositionCB; + std::unique_ptr<weld::CheckButton> m_xSizeCB; + std::unique_ptr<weld::Widget> m_xPosFrame; + std::unique_ptr<weld::Label> m_xHoriFT; + std::unique_ptr<weld::ComboBoxText> m_xHoriLB; + std::unique_ptr<weld::Label> m_xHoriByFT; + std::unique_ptr<weld::MetricSpinButton> m_xHoriByMF; + std::unique_ptr<weld::Label> m_xHoriToFT; + std::unique_ptr<weld::ComboBoxText> m_xHoriToLB; + std::unique_ptr<weld::CheckButton> m_xHoriMirrorCB; + std::unique_ptr<weld::Label> m_xVertFT; + std::unique_ptr<weld::ComboBoxText> m_xVertLB; + std::unique_ptr<weld::Label> m_xVertByFT; + std::unique_ptr<weld::MetricSpinButton> m_xVertByMF; + std::unique_ptr<weld::Label> m_xVertToFT; + std::unique_ptr<weld::ComboBoxText> m_xVertToLB; + std::unique_ptr<weld::CheckButton> m_xFollowCB; + std::unique_ptr<weld::CustomWeld> m_xExampleWN; + + DECL_LINK(RangeModifyHdl, weld::Widget&, void); + DECL_LINK(RangeModifyClickHdl, weld::ToggleButton&, void); + DECL_LINK(AnchorTypeHdl, weld::ToggleButton&, void); + DECL_LINK(PosHdl, weld::ComboBoxText&, void); + DECL_LINK(RelHdl, weld::ComboBoxText&, void); + DECL_LINK(MirrorHdl, weld::ToggleButton&, void); + DECL_LINK(ModifyHdl, weld::MetricSpinButton&, void); + DECL_LINK(ProtectHdl, weld::ToggleButton&, void); void InitPos(RndStdIds nAnchorType, sal_uInt16 nH, sal_uInt16 nHRel, sal_uInt16 nV, sal_uInt16 nVRel, long nX, long nY); - static sal_uInt16 GetMapPos(FrmMap const *pMap, ListBox const &rAlignLB); - static short GetAlignment(FrmMap const *pMap, sal_uInt16 nMapPos, ListBox const &rRelationLB); - static short GetRelation(ListBox const &rRelationLB); + static sal_uInt16 GetMapPos(FrmMap const *pMap, const weld::ComboBoxText& rAlignLB); + static short GetAlignment(FrmMap const *pMap, sal_uInt16 nMapPos, const weld::ComboBoxText& rRelationLB); + static short GetRelation(const weld::ComboBoxText& rRelationLB); RndStdIds GetAnchorType(bool* pbHasChanged = nullptr); - void FillRelLB(FrmMap const *pMap, sal_uInt16 nLBSelPos, sal_uInt16 nAlign, sal_uInt16 nRel, ListBox &rLB, FixedText &rFT); - sal_uInt16 FillPosLB(FrmMap const *pMap, sal_uInt16 nAlign, const sal_uInt16 _nRel, ListBox &rLB); + void FillRelLB(FrmMap const *pMap, sal_uInt16 nLBSelPos, sal_uInt16 nAlign, sal_uInt16 nRel, weld::ComboBoxText& rLB, weld::Label& rFT); + sal_uInt16 FillPosLB(FrmMap const *pMap, sal_uInt16 nAlign, const sal_uInt16 _nRel, weld::ComboBoxText& rLB); void UpdateExample(); @@ -120,9 +112,8 @@ class SvxSwPosSizeTabPage : public SfxTabPage void setOptimalRelWidth(); public: - SvxSwPosSizeTabPage( vcl::Window* pParent, const SfxItemSet& rInAttrs ); + SvxSwPosSizeTabPage(TabPageParent pParent, const SfxItemSet& rInAttrs); virtual ~SvxSwPosSizeTabPage() override; - virtual void dispose() override; static VclPtr<SfxTabPage> Create( TabPageParent, const SfxItemSet* ); static const sal_uInt16* GetRanges(); diff --git a/cui/source/tabpages/swpossizetabpage.cxx b/cui/source/tabpages/swpossizetabpage.cxx index d870f8ea77f1..7c9282ab7614 100644 --- a/cui/source/tabpages/swpossizetabpage.cxx +++ b/cui/source/tabpages/swpossizetabpage.cxx @@ -490,9 +490,9 @@ static LB lcl_GetLBRelationsForRelations( const sal_uInt16 _nRel ) // #i22341# - helper method on order to determine all possible // listbox relations in a relation map for a given string ID -static LB lcl_GetLBRelationsForStrID( const FrmMap* _pMap, - const SvxSwFramePosString::StringId _eStrId, - const bool _bUseMirrorStr ) +static LB lcl_GetLBRelationsForStrID(const FrmMap* _pMap, + const SvxSwFramePosString::StringId _eStrId, + const bool _bUseMirrorStr ) { LB nLBRelations = LB::NONE; @@ -509,8 +509,8 @@ static LB lcl_GetLBRelationsForStrID( const FrmMap* _pMap, return nLBRelations; } -SvxSwPosSizeTabPage::SvxSwPosSizeTabPage(vcl::Window* pParent, const SfxItemSet& rInAttrs) - : SfxTabPage(pParent, "SwPosSizePage", "cui/ui/swpossizepage.ui", &rInAttrs) +SvxSwPosSizeTabPage::SvxSwPosSizeTabPage(TabPageParent pParent, const SfxItemSet& rInAttrs) + : SfxTabPage(pParent, "cui/ui/swpossizepage.ui", "SwPosSizePage", &rInAttrs) , m_pVMap(nullptr) , m_pHMap(nullptr) , m_pSdrView(nullptr) @@ -525,112 +525,78 @@ SvxSwPosSizeTabPage::SvxSwPosSizeTabPage(vcl::Window* pParent, const SfxItemSet& , m_bIsMultiSelection(false) , m_bIsInRightToLeft(false) , m_nProtectSizeState(TRISTATE_FALSE) + , m_xWidthMF(m_xBuilder->weld_metric_spin_button("width", FUNIT_CM)) + , m_xHeightMF(m_xBuilder->weld_metric_spin_button("height", FUNIT_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_text("horipos")) + , m_xHoriByFT(m_xBuilder->weld_label("horibyft")) + , m_xHoriByMF(m_xBuilder->weld_metric_spin_button("byhori", FUNIT_CM)) + , m_xHoriToFT(m_xBuilder->weld_label("horitoft")) + , m_xHoriToLB(m_xBuilder->weld_combo_box_text("horianchor")) + , m_xHoriMirrorCB(m_xBuilder->weld_check_button("mirror")) + , m_xVertFT(m_xBuilder->weld_label("vertposft")) + , m_xVertLB(m_xBuilder->weld_combo_box_text("vertpos")) + , m_xVertByFT(m_xBuilder->weld_label("vertbyft")) + , m_xVertByMF(m_xBuilder->weld_metric_spin_button("byvert", FUNIT_CM)) + , m_xVertToFT(m_xBuilder->weld_label("verttoft")) + , m_xVertToLB(m_xBuilder->weld_combo_box_text("vertanchor")) + , m_xFollowCB(m_xBuilder->weld_check_button("followtextflow")) + , m_xExampleWN(new weld::CustomWeld(*m_xBuilder, "preview", m_aExampleWN)) { - get(m_pWidthMF, "width"); - get(m_pHeightMF, "height"); - get(m_pKeepRatioCB, "ratio"); - get(m_pToPageRB, "topage"); - get(m_pToParaRB, "topara"); - get(m_pToCharRB, "tochar"); - get(m_pAsCharRB, "aschar"); - get(m_pToFrameRB, "toframe"); - get(m_pPositionCB, "pos"); - get(m_pSizeCB, "size"); - get(m_pPosFrame, "posframe"); - get(m_pHoriFT, "horiposft"); - get(m_pHoriLB, "horipos"); - get(m_pHoriByFT, "horibyft"); - get(m_pHoriByMF, "byhori"); - get(m_pHoriToFT, "horitoft"); - get(m_pHoriToLB, "horianchor"); - get(m_pHoriMirrorCB, "mirror"); - get(m_pVertFT, "vertposft"); - get(m_pVertLB, "vertpos"); - get(m_pVertByFT, "vertbyft"); - get(m_pVertByMF, "byvert"); - get(m_pVertToFT, "verttoft"); - get(m_pVertToLB, "vertanchor"); - get(m_pFollowCB, "followtextflow"); - get(m_pExampleWN, "preview"); - setOptimalFrmWidth(); setOptimalRelWidth(); FieldUnit eDlgUnit = GetModuleFieldUnit( rInAttrs ); - SetFieldUnit( *m_pHoriByMF, eDlgUnit, true ); - SetFieldUnit( *m_pVertByMF, eDlgUnit, true ); - SetFieldUnit( *m_pWidthMF , eDlgUnit, true ); - SetFieldUnit( *m_pHeightMF, eDlgUnit, true ); + SetFieldUnit(*m_xHoriByMF, eDlgUnit, true); + SetFieldUnit(*m_xVertByMF, eDlgUnit, true); + SetFieldUnit(*m_xWidthMF , eDlgUnit, true); + SetFieldUnit(*m_xHeightMF, eDlgUnit, true); SetExchangeSupport(); - Link<Control&,void> aLk3 = LINK(this, SvxSwPosSizeTabPage, RangeModifyHdl); - m_pWidthMF->SetLoseFocusHdl( aLk3 ); - m_pHeightMF->SetLoseFocusHdl( aLk3 ); - m_pHoriByMF->SetLoseFocusHdl( aLk3 ); - m_pVertByMF->SetLoseFocusHdl( aLk3 ); - m_pFollowCB->SetClickHdl( LINK(this, SvxSwPosSizeTabPage, RangeModifyClickHdl) ); - - Link<Edit&,void> aLk = LINK(this, SvxSwPosSizeTabPage, ModifyHdl); - m_pWidthMF->SetModifyHdl( aLk ); - m_pHeightMF->SetModifyHdl( aLk ); - m_pHoriByMF->SetModifyHdl( aLk ); - m_pVertByMF->SetModifyHdl( aLk ); - - Link<Button*,void> aLk2 = LINK(this, SvxSwPosSizeTabPage, AnchorTypeHdl); - m_pToPageRB->SetClickHdl( aLk2 ); - m_pToParaRB->SetClickHdl( aLk2 ); - m_pToCharRB->SetClickHdl( aLk2 ); - m_pAsCharRB->SetClickHdl( aLk2 ); - m_pToFrameRB->SetClickHdl( aLk2 ); - - m_pHoriLB->SetSelectHdl(LINK(this, SvxSwPosSizeTabPage, PosHdl)); - m_pVertLB->SetSelectHdl(LINK(this, SvxSwPosSizeTabPage, PosHdl)); - - m_pHoriToLB->SetSelectHdl(LINK(this, SvxSwPosSizeTabPage, RelHdl)); - m_pVertToLB->SetSelectHdl(LINK(this, SvxSwPosSizeTabPage, RelHdl)); - - m_pHoriMirrorCB->SetClickHdl(LINK(this, SvxSwPosSizeTabPage, MirrorHdl)); - m_pPositionCB->SetClickHdl(LINK(this, SvxSwPosSizeTabPage, ProtectHdl)); + Link<weld::Widget&,void> aLk3 = LINK(this, SvxSwPosSizeTabPage, RangeModifyHdl); + m_xWidthMF->connect_focus_out(aLk3); + m_xHeightMF->connect_focus_out(aLk3); + m_xHoriByMF->connect_focus_out(aLk3); + m_xVertByMF->connect_focus_out(aLk3); + m_xFollowCB->connect_toggled(LINK(this, SvxSwPosSizeTabPage, RangeModifyClickHdl)); + + Link<weld::MetricSpinButton&,void> aLk = LINK(this, SvxSwPosSizeTabPage, ModifyHdl); + m_xWidthMF->connect_value_changed( aLk ); + m_xHeightMF->connect_value_changed( aLk ); + m_xHoriByMF->connect_value_changed( aLk ); + m_xVertByMF->connect_value_changed( aLk ); + + Link<weld::ToggleButton&,void> aLk2 = LINK(this, SvxSwPosSizeTabPage, AnchorTypeHdl); + m_xToPageRB->connect_toggled( aLk2 ); + m_xToParaRB->connect_toggled( aLk2 ); + m_xToCharRB->connect_toggled( aLk2 ); + m_xAsCharRB->connect_toggled( aLk2 ); + m_xToFrameRB->connect_toggled( aLk2 ); + + m_xHoriLB->connect_changed(LINK(this, SvxSwPosSizeTabPage, PosHdl)); + m_xVertLB->connect_changed(LINK(this, SvxSwPosSizeTabPage, PosHdl)); + + m_xHoriToLB->connect_changed(LINK(this, SvxSwPosSizeTabPage, RelHdl)); + m_xVertToLB->connect_changed(LINK(this, SvxSwPosSizeTabPage, RelHdl)); + + m_xHoriMirrorCB->connect_toggled(LINK(this, SvxSwPosSizeTabPage, MirrorHdl)); + m_xPositionCB->connect_toggled(LINK(this, SvxSwPosSizeTabPage, ProtectHdl)); } SvxSwPosSizeTabPage::~SvxSwPosSizeTabPage() { - disposeOnce(); -} - -void SvxSwPosSizeTabPage::dispose() -{ - m_pWidthMF.clear(); - m_pHeightMF.clear(); - m_pKeepRatioCB.clear(); - m_pToPageRB.clear(); - m_pToParaRB.clear(); - m_pToCharRB.clear(); - m_pAsCharRB.clear(); - m_pToFrameRB.clear(); - m_pPositionCB.clear(); - m_pSizeCB.clear(); - m_pPosFrame.clear(); - m_pHoriFT.clear(); - m_pHoriLB.clear(); - m_pHoriByFT.clear(); - m_pHoriByMF.clear(); - m_pHoriToFT.clear(); - m_pHoriToLB.clear(); - m_pHoriMirrorCB.clear(); - m_pVertFT.clear(); - m_pVertLB.clear(); - m_pVertByFT.clear(); - m_pVertByMF.clear(); - m_pVertToFT.clear(); - m_pVertToLB.clear(); - m_pFollowCB.clear(); - m_pExampleWN.clear(); - SfxTabPage::dispose(); } - namespace { struct FrmMaps @@ -681,13 +647,13 @@ void SvxSwPosSizeTabPage::setOptimalFrmWidth() for (auto const& frame : aFrames) { - m_pHoriLB->InsertEntry(SvxSwFramePosString::GetString(frame)); + m_xHoriLB->append_text(SvxSwFramePosString::GetString(frame)); } - Size aBiggest(m_pHoriLB->GetOptimalSize()); - m_pHoriLB->set_width_request(aBiggest.Width()); - m_pVertLB->set_width_request(aBiggest.Width()); - m_pHoriLB->Clear(); + Size aBiggest(m_xHoriLB->get_preferred_size()); + m_xHoriLB->set_size_request(aBiggest.Width(), -1); + m_xVertLB->set_size_request(aBiggest.Width(), -1); + m_xHoriLB->clear(); } namespace @@ -721,18 +687,18 @@ void SvxSwPosSizeTabPage::setOptimalRelWidth() for (auto const& elem : aRels) { - m_pHoriLB->InsertEntry(SvxSwFramePosString::GetString(elem)); + m_xHoriLB->append_text(SvxSwFramePosString::GetString(elem)); } - Size aBiggest(m_pHoriLB->GetOptimalSize()); - m_pHoriLB->set_width_request(aBiggest.Width()); - m_pVertLB->set_width_request(aBiggest.Width()); - m_pHoriLB->Clear(); + Size aBiggest(m_xHoriLB->get_preferred_size()); + m_xHoriLB->set_size_request(aBiggest.Width(), -1); + m_xVertLB->set_size_request(aBiggest.Width(), -1); + m_xHoriLB->clear(); } -VclPtr<SfxTabPage> SvxSwPosSizeTabPage::Create( TabPageParent pParent, const SfxItemSet* rSet) +VclPtr<SfxTabPage> SvxSwPosSizeTabPage::Create(TabPageParent pParent, const SfxItemSet* rSet) { - return VclPtr<SvxSwPosSizeTabPage>::Create(pParent.pParent, *rSet); + return VclPtr<SvxSwPosSizeTabPage>::Create(pParent, *rSet); } const sal_uInt16* SvxSwPosSizeTabPage::GetRanges() @@ -774,25 +740,25 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) rSet->Put(SfxInt16Item(SID_ATTR_TRANSFORM_ANCHOR, static_cast<sal_Int16>(nAnchor))); bModified = true; } - if ( m_pPositionCB->IsValueChangedFromSaved() ) + if (m_xPositionCB->get_state_changed_from_saved()) { - if( m_pPositionCB->GetState() == TRISTATE_INDET ) + if (m_xPositionCB->get_inconsistent()) rSet->InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_POS ); else rSet->Put( SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS ), - m_pPositionCB->GetState() == TRISTATE_TRUE ) ); + m_xPositionCB->get_state() == TRISTATE_TRUE ) ); bModified = true; } - if ( m_pSizeCB->IsValueChangedFromSaved() ) + if (m_xSizeCB->get_state_changed_from_saved()) { - if ( m_pSizeCB->GetState() == TRISTATE_INDET ) + if (m_xSizeCB->get_inconsistent()) rSet->InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_SIZE ); else rSet->Put( SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE ), - m_pSizeCB->GetState() == TRISTATE_TRUE ) ); + m_xSizeCB->get_state() == TRISTATE_TRUE ) ); bModified = true; } @@ -801,14 +767,12 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) if(!m_bPositioningDisabled) { //on multiple selections the positioning is set via SdrView - if(m_bIsMultiSelection) + if (m_bIsMultiSelection) { - if( m_pHoriByMF->IsValueModified() || m_pVertByMF->IsValueModified() ) + if (m_xHoriByMF->get_value_changed_from_saved() || m_xVertByMF->get_value_changed_from_saved()) { - long nHoriByPos = - static_cast<long>(m_pHoriByMF->Denormalize(m_pHoriByMF->GetValue(FUNIT_TWIP))); - long nVertByPos = - static_cast<long>(m_pVertByMF->Denormalize(m_pVertByMF->GetValue(FUNIT_TWIP))); + auto nHoriByPos = m_xHoriByMF->denormalize(m_xHoriByMF->get_value(FUNIT_TWIP)); + auto nVertByPos = m_xVertByMF->denormalize(m_xVertByMF->get_value(FUNIT_TWIP)); // old rectangle with CoreUnit m_aRect = m_pSdrView->GetAllMarkedRect(); @@ -834,26 +798,25 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) const SfxInt32Item& rHoriPosition = static_cast<const SfxInt32Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_HORI_POSITION)) ; - sal_uInt16 nMapPos = GetMapPos(m_pHMap, *m_pHoriLB); - short nAlign = GetAlignment(m_pHMap, nMapPos, *m_pHoriToLB); - short nRel = GetRelation(*m_pHoriToLB); - const long nHoriByPos = - static_cast<long>(m_pHoriByMF->Denormalize(m_pHoriByMF->GetValue(FUNIT_TWIP))); + sal_uInt16 nMapPos = GetMapPos(m_pHMap, *m_xHoriLB); + short nAlign = GetAlignment(m_pHMap, nMapPos, *m_xHoriToLB); + short nRel = GetRelation(*m_xHoriToLB); + const auto nHoriByPos = m_xHoriByMF->denormalize(m_xHoriByMF->get_value(FUNIT_TWIP)); if ( nAlign != rHoriOrient.GetValue() || nRel != rHoriRelation.GetValue() || - (m_pHoriByMF->IsEnabled() && nHoriByPos != rHoriPosition.GetValue()) + (m_xHoriByMF->get_sensitive() && nHoriByPos != rHoriPosition.GetValue()) ) { rSet->Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_ORIENT, nAlign)); rSet->Put(SfxInt16Item(SID_ATTR_TRANSFORM_HORI_RELATION, nRel)); - if(m_pHoriByMF->IsEnabled()) + if(m_xHoriByMF->get_sensitive()) rSet->Put(SfxInt32Item(SID_ATTR_TRANSFORM_HORI_POSITION, nHoriByPos)); bModified = true; } } - if(m_pHoriMirrorCB->IsEnabled() && m_pHoriMirrorCB->IsValueChangedFromSaved()) - bModified |= nullptr != rSet->Put(SfxBoolItem(SID_ATTR_TRANSFORM_HORI_MIRROR, m_pHoriMirrorCB->IsChecked())); + if (m_xHoriMirrorCB->get_sensitive() && m_xHoriMirrorCB->get_state_changed_from_saved()) + bModified |= nullptr != rSet->Put(SfxBoolItem(SID_ATTR_TRANSFORM_HORI_MIRROR, m_xHoriMirrorCB->get_active())); if ( m_pVMap ) { @@ -864,48 +827,47 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) const SfxInt32Item& rVertPosition = static_cast<const SfxInt32Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_VERT_POSITION)); - sal_uInt16 nMapPos = GetMapPos(m_pVMap, *m_pVertLB); - short nAlign = GetAlignment(m_pVMap, nMapPos, *m_pVertToLB); - short nRel = GetRelation(*m_pVertToLB); + sal_uInt16 nMapPos = GetMapPos(m_pVMap, *m_xVertLB); + short nAlign = GetAlignment(m_pVMap, nMapPos, *m_xVertToLB); + short nRel = GetRelation(*m_xVertToLB); // #i34055# - convert vertical position for // as-character anchored objects - long nVertByPos = - static_cast<long>(m_pVertByMF->Denormalize(m_pVertByMF->GetValue(FUNIT_TWIP))); + auto nVertByPos = m_xVertByMF->denormalize(m_xVertByMF->get_value(FUNIT_TWIP)); if (GetAnchorType() == RndStdIds::FLY_AS_CHAR) { nVertByPos *= -1; } if ( nAlign != rVertOrient.GetValue() || nRel != rVertRelation.GetValue() || - ( m_pVertByMF->IsEnabled() && + ( m_xVertByMF->get_sensitive() && nVertByPos != rVertPosition.GetValue() ) ) { rSet->Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_ORIENT, nAlign)); rSet->Put(SfxInt16Item(SID_ATTR_TRANSFORM_VERT_RELATION, nRel)); - if(m_pVertByMF->IsEnabled()) + if(m_xVertByMF->get_sensitive()) rSet->Put(SfxInt32Item(SID_ATTR_TRANSFORM_VERT_POSITION, nVertByPos)); bModified = true; } } // #i18732# - if(m_pFollowCB->IsValueChangedFromSaved()) + if (m_xFollowCB->get_state_changed_from_saved()) { //Writer internal type - based on SfxBoolItem const SfxPoolItem* pItem = GetItem( rOldSet, SID_SW_FOLLOW_TEXT_FLOW); if(pItem) { std::unique_ptr<SfxBoolItem> pFollow(static_cast<SfxBoolItem*>(pItem->Clone())); - pFollow->SetValue(m_pFollowCB->IsChecked()); + pFollow->SetValue(m_xFollowCB->get_active()); bModified |= nullptr != rSet->Put(*pFollow); } } } } - if ( m_pWidthMF->IsValueModified() || m_pHeightMF->IsValueModified() ) + if (m_xWidthMF->get_value_changed_from_saved() || m_xHeightMF->get_value_changed_from_saved()) { - sal_uInt32 nWidth = static_cast<sal_uInt32>(m_pWidthMF->Denormalize(m_pWidthMF->GetValue(FUNIT_TWIP))); - sal_uInt32 nHeight = static_cast<sal_uInt32>(m_pHeightMF->Denormalize(m_pHeightMF->GetValue(FUNIT_TWIP))); + sal_uInt32 nWidth = static_cast<sal_uInt32>(m_xWidthMF->denormalize(m_xWidthMF->get_value(FUNIT_TWIP))); + sal_uInt32 nHeight = static_cast<sal_uInt32>(m_xHeightMF->denormalize(m_xHeightMF->get_value(FUNIT_TWIP))); rSet->Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_WIDTH ), nWidth ) ); rSet->Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_HEIGHT ), nHeight ) ); //this item is required by SdrEditView::SetGeoAttrToMarked() @@ -927,54 +889,51 @@ void SvxSwPosSizeTabPage::Reset( const SfxItemSet* rSet) nAnchorType = static_cast<RndStdIds>(static_cast<const SfxInt16Item*>(pItem)->GetValue()); switch(nAnchorType) { - case RndStdIds::FLY_AT_PAGE: m_pToPageRB->Check(); break; - case RndStdIds::FLY_AT_PARA: m_pToParaRB->Check(); break; - case RndStdIds::FLY_AT_CHAR: m_pToCharRB->Check(); break; - case RndStdIds::FLY_AS_CHAR: m_pAsCharRB->Check(); break; - case RndStdIds::FLY_AT_FLY: m_pToFrameRB->Check(); break; + case RndStdIds::FLY_AT_PAGE: m_xToPageRB->set_active(true); break; + case RndStdIds::FLY_AT_PARA: m_xToParaRB->set_active(true); break; + case RndStdIds::FLY_AT_CHAR: m_xToCharRB->set_active(true); break; + case RndStdIds::FLY_AS_CHAR: m_xAsCharRB->set_active(true); break; + case RndStdIds::FLY_AT_FLY: m_xToFrameRB->set_active(true); break; default : bInvalidateAnchor = true; } - m_pToPageRB->SaveValue(); - m_pToParaRB->SaveValue(); - m_pToCharRB->SaveValue(); - m_pAsCharRB->SaveValue(); - m_pToFrameRB->SaveValue(); + m_xToPageRB->save_state(); + m_xToParaRB->save_state(); + m_xToCharRB->save_state(); + m_xAsCharRB->save_state(); + m_xToFrameRB->save_state(); } - if(bInvalidateAnchor) + if (bInvalidateAnchor) { - m_pToPageRB->Enable( false ); - m_pToParaRB->Enable( false ); - m_pToCharRB->Enable( false ); - m_pAsCharRB->Enable( false ); - m_pToFrameRB->Enable( false ); + m_xToPageRB->set_sensitive( false ); + m_xToParaRB->set_sensitive( false ); + m_xToCharRB->set_sensitive( false ); + m_xAsCharRB->set_sensitive( false ); + m_xToFrameRB->set_sensitive( false ); } pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_PROTECT_POS ); - if ( pItem ) + if (pItem) { bool bProtected = static_cast<const SfxBoolItem*>(pItem)->GetValue(); - m_pPositionCB->SetState( bProtected ? TRISTATE_TRUE : TRISTATE_FALSE ); - m_pPositionCB->EnableTriState( false ); - m_pSizeCB->Enable( !bProtected ); + m_xPositionCB->set_active(bProtected); + m_xSizeCB->set_sensitive(!bProtected); } else { - m_pPositionCB->SetState( TRISTATE_INDET ); + m_xPositionCB->set_inconsistent(true); } - m_pPositionCB->SaveValue(); + m_xPositionCB->save_state(); pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_PROTECT_SIZE ); - if ( pItem ) + if (pItem) { - m_pSizeCB->SetState( static_cast<const SfxBoolItem*>(pItem)->GetValue() - ? TRISTATE_TRUE : TRISTATE_FALSE ); - m_pSizeCB->EnableTriState( false ); + m_xSizeCB->set_active(static_cast<const SfxBoolItem*>(pItem)->GetValue()); } else - m_pSizeCB->SetState( TRISTATE_INDET ); - m_pSizeCB->SaveValue(); + m_xSizeCB->set_inconsistent(true); + m_xSizeCB->save_state(); pItem = GetItem( *rSet, SID_HTML_MODE ); if(pItem) @@ -987,9 +946,9 @@ void SvxSwPosSizeTabPage::Reset( const SfxItemSet* rSet) pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_IN_VERTICAL_TEXT ); if(pItem && static_cast<const SfxBoolItem*>(pItem)->GetValue()) { - OUString sHLabel = m_pHoriFT->GetText(); - m_pHoriFT->SetText(m_pVertFT->GetText()); - m_pVertFT->SetText(sHLabel); + OUString sHLabel = m_xHoriFT->get_label(); + m_xHoriFT->set_label(m_xVertFT->get_label()); + m_xVertFT->set_label(sHLabel); m_bIsVerticalFrame = true; } pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_IN_RTL_TEXT); @@ -1001,35 +960,35 @@ void SvxSwPosSizeTabPage::Reset( const SfxItemSet* rSet) { const bool bFollowTextFlow = static_cast<const SfxBoolItem*>(pItem)->GetValue(); - m_pFollowCB->Check( bFollowTextFlow ); + m_xFollowCB->set_active(bFollowTextFlow); } - m_pFollowCB->SaveValue(); + m_xFollowCB->save_state(); if(m_bHtmlMode) { - m_pHoriMirrorCB->Show(false); - m_pKeepRatioCB->Enable(false); + m_xHoriMirrorCB->show(false); + m_xKeepRatioCB->set_sensitive(false); // #i18732# - hide checkbox in HTML mode - m_pFollowCB->Show(false); + m_xFollowCB->show(false); } else { // #i18732# correct enable/disable of check box 'Mirror on..' - m_pHoriMirrorCB->Enable(!m_pAsCharRB->IsChecked() && !m_bIsMultiSelection); + m_xHoriMirrorCB->set_sensitive(!m_xAsCharRB->get_active() && !m_bIsMultiSelection); // #i18732# - enable/disable check box 'Follow text flow'. - m_pFollowCB->Enable( m_pToParaRB->IsChecked() || - m_pToCharRB->IsChecked() ); + m_xFollowCB->set_sensitive(m_xToParaRB->get_active() || + m_xToCharRB->get_active()); } pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_WIDTH ); sal_Int32 nWidth = std::max( pItem ? ( static_cast<const SfxUInt32Item*>(pItem)->GetValue()) : 0, sal_uInt32(1) ); - m_pWidthMF->SetValue(m_pWidthMF->Normalize(nWidth), FUNIT_TWIP); + m_xWidthMF->set_value(m_xWidthMF->normalize(nWidth), FUNIT_TWIP); pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HEIGHT ); sal_Int32 nHeight = std::max( pItem ? ( static_cast<const SfxUInt32Item*>(pItem)->GetValue()) : 0, sal_uInt32(1) ); - m_pHeightMF->SetValue(m_pHeightMF->Normalize(nHeight), FUNIT_TWIP); + m_xHeightMF->set_value(m_xHeightMF->normalize(nHeight), FUNIT_TWIP); m_fWidthHeightRatio = double(nWidth) / double(nHeight); if(!m_bPositioningDisabled) @@ -1059,8 +1018,8 @@ void SvxSwPosSizeTabPage::Reset( const SfxItemSet* rSet) } pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HORI_MIRROR); if(pItem) - m_pHoriMirrorCB->Check(static_cast<const SfxBoolItem*>(pItem)->GetValue()); - m_pHoriMirrorCB->SaveValue(); + m_xHoriMirrorCB->set_active(static_cast<const SfxBoolItem*>(pItem)->GetValue()); + m_xHoriMirrorCB->save_state(); sal_Int32 nHoriPos = 0; sal_Int32 nVertPos = 0; @@ -1073,12 +1032,12 @@ void SvxSwPosSizeTabPage::Reset( const SfxItemSet* rSet) InitPos(nAnchorType, m_nOldH, m_nOldHRel, m_nOldV, m_nOldVRel, nHoriPos, nVertPos); - m_pVertByMF->SaveValue(); - m_pHoriByMF->SaveValue(); + m_xVertByMF->save_value(); + m_xHoriByMF->save_value(); // #i18732# - m_pFollowCB->SaveValue(); + m_xFollowCB->save_state(); - RangeModifyHdl(*m_pWidthMF); // initially set maximum values + RangeModifyHdl(m_xWidthMF->get_widget()); // initially set maximum values } } @@ -1086,10 +1045,10 @@ DeactivateRC SvxSwPosSizeTabPage::DeactivatePage( SfxItemSet* _pSet ) { if( _pSet ) { - _pSet->Put(SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS ), - m_pPositionCB->GetState() == TRISTATE_TRUE )); - _pSet->Put(SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE ), - m_pSizeCB->GetState() == TRISTATE_TRUE )); + _pSet->Put(SfxBoolItem(GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS ), + m_xPositionCB->get_active())); + _pSet->Put(SfxBoolItem(GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE ), + m_xSizeCB->get_active())); FillItemSet( _pSet ); } return DeactivateRC::LeavePage; @@ -1097,77 +1056,77 @@ DeactivateRC SvxSwPosSizeTabPage::DeactivatePage( SfxItemSet* _pSet ) void SvxSwPosSizeTabPage::EnableAnchorTypes(SvxAnchorIds nAnchorEnable) { - if(nAnchorEnable & SvxAnchorIds::Fly) - m_pToFrameRB->Show(); - if(!(nAnchorEnable & SvxAnchorIds::Page)) - m_pToPageRB->Enable(false); + if (nAnchorEnable & SvxAnchorIds::Fly) + m_xToFrameRB->show(); + if (!(nAnchorEnable & SvxAnchorIds::Page)) + m_xToPageRB->set_sensitive(false); } RndStdIds SvxSwPosSizeTabPage::GetAnchorType(bool* pbHasChanged) { RndStdIds nRet = RndStdIds::UNKNOWN; - RadioButton* pCheckedButton = nullptr; - if(m_pToParaRB->IsEnabled()) + weld::RadioButton* pCheckedButton = nullptr; + if(m_xToParaRB->get_sensitive()) { - if(m_pToPageRB->IsChecked()) + if(m_xToPageRB->get_active()) { nRet = RndStdIds::FLY_AT_PAGE; - pCheckedButton = m_pToPageRB; + pCheckedButton = m_xToPageRB.get(); } - else if(m_pToParaRB->IsChecked()) + else if(m_xToParaRB->get_active()) { nRet = RndStdIds::FLY_AT_PARA; - pCheckedButton = m_pToParaRB; + pCheckedButton = m_xToParaRB.get(); } - else if(m_pToCharRB->IsChecked()) + else if(m_xToCharRB->get_active()) { nRet = RndStdIds::FLY_AT_CHAR; - pCheckedButton = m_pToCharRB; + pCheckedButton = m_xToCharRB.get(); } - else if(m_pAsCharRB->IsChecked()) + else if(m_xAsCharRB->get_active()) { nRet = RndStdIds::FLY_AS_CHAR; - pCheckedButton = m_pAsCharRB; + pCheckedButton = m_xAsCharRB.get(); } - else if(m_pToFrameRB->IsChecked()) + else if(m_xToFrameRB->get_active()) { nRet = RndStdIds::FLY_AT_FLY; - pCheckedButton = m_pToFrameRB; + pCheckedButton = m_xToFrameRB.get(); } } if(pbHasChanged) { if(pCheckedButton) - *pbHasChanged = pCheckedButton->IsValueChangedFromSaved(); + *pbHasChanged = pCheckedButton->get_state_changed_from_saved(); else *pbHasChanged = false; } return nRet; } -IMPL_LINK_NOARG(SvxSwPosSizeTabPage, RangeModifyClickHdl, Button*, void) +IMPL_LINK_NOARG(SvxSwPosSizeTabPage, RangeModifyClickHdl, weld::ToggleButton&, void) { - RangeModifyHdl(*m_pWidthMF); + RangeModifyHdl(m_xWidthMF->get_widget()); } -IMPL_LINK_NOARG(SvxSwPosSizeTabPage, RangeModifyHdl, Control&, void) +IMPL_LINK_NOARG(SvxSwPosSizeTabPage, RangeModifyHdl, weld::Widget&, void) { - if(m_bPositioningDisabled) + if (m_bPositioningDisabled) return; SvxSwFrameValidation aVal; aVal.nAnchorType = GetAnchorType(); aVal.bAutoHeight = false; - aVal.bMirror = m_pHoriMirrorCB->IsChecked(); + aVal.bMirror = m_xHoriMirrorCB->get_active(); // #i18732# - aVal.bFollowTextFlow = m_pFollowCB->IsChecked(); + aVal.bFollowTextFlow = m_xFollowCB->get_active(); if ( m_pHMap ) { // horizontal alignment - sal_uInt16 nMapPos = GetMapPos(m_pHMap, *m_pHoriToLB); - sal_uInt16 nAlign = GetAlignment(m_pHMap, nMapPos, *m_pHoriToLB); - sal_uInt16 nRel = GetRelation(*m_pHoriToLB); + sal_uInt16 nMapPos = GetMapPos(m_pHMap, *m_xHoriToLB); + sal_uInt16 nAlign = GetAlignment(m_pHMap, nMapPos, *m_xHoriToLB); + sal_uInt16 nRel = GetRelation(*m_xHoriToLB); aVal.nHoriOrient = static_cast<short>(nAlign); aVal.nHRelOrient = static_cast<short>(nRel); @@ -1178,9 +1137,9 @@ IMPL_LINK_NOARG(SvxSwPosSizeTabPage, RangeModifyHdl, Control&, void) if ( m_pVMap ) { // vertical alignment - sal_uInt16 nMapPos = GetMapPos(m_pVMap, *m_pVertLB); - sal_uInt16 nAlign = GetAlignment(m_pVMap, nMapPos, *m_pVertToLB); - sal_uInt16 nRel = GetRelation(*m_pVertToLB); + sal_uInt16 nMapPos = GetMapPos(m_pVMap, *m_xVertLB); + sal_uInt16 nAlign = GetAlignment(m_pVMap, nMapPos, *m_xVertToLB); + sal_uInt16 nRel = GetRelation(*m_xVertToLB); aVal.nVertOrient = static_cast<short>(nAlign); aVal.nVRelOrient = static_cast<short>(nRel); @@ -1188,74 +1147,72 @@ IMPL_LINK_NOARG(SvxSwPosSizeTabPage, RangeModifyHdl, Control&, void) else aVal.nVertOrient = VertOrientation::NONE; - const long nAtHorzPosVal = - static_cast<long>(m_pHoriByMF->Denormalize(m_pHoriByMF->GetValue(FUNIT_TWIP))); - const long nAtVertPosVal = - static_cast<long>(m_pVertByMF->Denormalize(m_pVertByMF->GetValue(FUNIT_TWIP))); + const auto nAtHorzPosVal = m_xHoriByMF->denormalize(m_xHoriByMF->get_value(FUNIT_TWIP)); + const auto nAtVertPosVal = m_xVertByMF->denormalize(m_xVertByMF->get_value(FUNIT_TWIP)); aVal.nHPos = nAtHorzPosVal; aVal.nVPos = nAtVertPosVal; - sal_Int32 nWidth = static_cast<sal_uInt32>(m_pWidthMF-> Denormalize(m_pWidthMF->GetValue(FUNIT_TWIP))); - sal_Int32 nHeight = static_cast<sal_uInt32>(m_pHeightMF->Denormalize(m_pHeightMF->GetValue(FUNIT_TWIP))); + sal_Int32 nWidth = static_cast<sal_uInt32>(m_xWidthMF->denormalize(m_xWidthMF->get_value(FUNIT_TWIP))); + sal_Int32 nHeight = static_cast<sal_uInt32>(m_xHeightMF->denormalize(m_xHeightMF->get_value(FUNIT_TWIP))); aVal.nWidth = nWidth; aVal.nHeight = nHeight; m_aValidateLink.Call(aVal); // minimum width also for style - m_pHeightMF->SetMin(m_pHeightMF->Normalize(aVal.nMinHeight), FUNIT_TWIP); - m_pWidthMF-> SetMin(m_pWidthMF->Normalize(aVal.nMinWidth), FUNIT_TWIP); + m_xHeightMF->set_min(m_xHeightMF->normalize(aVal.nMinHeight), FUNIT_TWIP); + m_xWidthMF->set_min(m_xWidthMF->normalize(aVal.nMinWidth), FUNIT_TWIP); sal_Int32 nMaxWidth(aVal.nMaxWidth); sal_Int32 nMaxHeight(aVal.nMaxHeight); - sal_Int64 nTmp = m_pHeightMF->Normalize(nMaxHeight); - m_pHeightMF->SetMax(nTmp, FUNIT_TWIP); + sal_Int64 nTmp = m_xHeightMF->normalize(nMaxHeight); + m_xHeightMF->set_max(nTmp, FUNIT_TWIP); - nTmp = m_pWidthMF->Normalize(nMaxWidth); - m_pWidthMF->SetMax(nTmp, FUNIT_TWIP); + nTmp = m_xWidthMF->normalize(nMaxWidth); + m_xWidthMF->set_max(nTmp, FUNIT_TWIP); - m_pHoriByMF->SetMin(m_pHoriByMF->Normalize(aVal.nMinHPos), FUNIT_TWIP); - m_pHoriByMF->SetMax(m_pHoriByMF->Normalize(aVal.nMaxHPos), FUNIT_TWIP); + m_xHoriByMF->set_range(m_xHoriByMF->normalize(aVal.nMinHPos), + m_xHoriByMF->normalize(aVal.nMaxHPos), FUNIT_TWIP); if ( aVal.nHPos != nAtHorzPosVal ) - m_pHoriByMF->SetValue(m_pHoriByMF->Normalize(aVal.nHPos), FUNIT_TWIP); + m_xHoriByMF->set_value(m_xHoriByMF->normalize(aVal.nHPos), FUNIT_TWIP); - m_pVertByMF->SetMin(m_pVertByMF->Normalize(aVal.nMinVPos ), FUNIT_TWIP); - m_pVertByMF->SetMax(m_pVertByMF->Normalize(aVal.nMaxVPos), FUNIT_TWIP); + m_xVertByMF->set_range(m_xVertByMF->normalize(aVal.nMinVPos), + m_xVertByMF->normalize(aVal.nMaxVPos), FUNIT_TWIP); if ( aVal.nVPos != nAtVertPosVal ) - m_pVertByMF->SetValue(m_pVertByMF->Normalize(aVal.nVPos), FUNIT_TWIP); + m_xVertByMF->set_value(m_xVertByMF->normalize(aVal.nVPos), FUNIT_TWIP); } -IMPL_LINK_NOARG(SvxSwPosSizeTabPage, AnchorTypeHdl, Button*, void) +IMPL_LINK_NOARG(SvxSwPosSizeTabPage, AnchorTypeHdl, weld::ToggleButton&, void) { - m_pHoriMirrorCB->Enable(!m_pAsCharRB->IsChecked() && !m_bIsMultiSelection); + m_xHoriMirrorCB->set_sensitive(!m_xAsCharRB->get_active() && !m_bIsMultiSelection); // #i18732# - enable check box 'Follow text flow' for anchor // type to-paragraph' and to-character - m_pFollowCB->Enable( m_pToParaRB->IsChecked() || m_pToCharRB->IsChecked() ); + m_xFollowCB->set_sensitive(m_xToParaRB->get_active() || m_xToCharRB->get_active()); RndStdIds nId = GetAnchorType(); InitPos( nId, USHRT_MAX, 0, USHRT_MAX, 0, LONG_MAX, LONG_MAX); - RangeModifyHdl(*m_pWidthMF); + RangeModifyHdl(m_xWidthMF->get_widget()); if(m_bHtmlMode) { - PosHdl(*m_pHoriLB); - PosHdl(*m_pVertLB); + PosHdl(*m_xHoriLB); + PosHdl(*m_xVertLB); } } -IMPL_LINK_NOARG(SvxSwPosSizeTabPage, MirrorHdl, Button*, void) +IMPL_LINK_NOARG(SvxSwPosSizeTabPage, MirrorHdl, weld::ToggleButton&, void) { RndStdIds nId = GetAnchorType(); InitPos( nId, USHRT_MAX, 0, USHRT_MAX, 0, LONG_MAX, LONG_MAX); } -IMPL_LINK( SvxSwPosSizeTabPage, RelHdl, ListBox&, rLB, void ) +IMPL_LINK( SvxSwPosSizeTabPage, RelHdl, weld::ComboBoxText&, rLB, void ) { - bool bHori = &rLB == m_pHoriToLB; + bool bHori = &rLB == m_xHoriToLB.get(); UpdateExample(); @@ -1263,25 +1220,25 @@ IMPL_LINK( SvxSwPosSizeTabPage, RelHdl, ListBox&, rLB, void ) { if(bHori) { - sal_uInt16 nRel = GetRelation(*m_pHoriToLB); - if(RelOrientation::PRINT_AREA == nRel && 0 == m_pVertLB->GetSelectedEntryPos()) + sal_uInt16 nRel = GetRelation(*m_xHoriToLB); + if(RelOrientation::PRINT_AREA == nRel && 0 == m_xVertLB->get_active()) { - m_pVertLB->SelectEntryPos(1); + m_xVertLB->set_active(1); } - else if(RelOrientation::CHAR == nRel && 1 == m_pVertLB->GetSelectedEntryPos()) + else if(RelOrientation::CHAR == nRel && 1 == m_xVertLB->get_active()) { - m_pVertLB->SelectEntryPos(0); + m_xVertLB->set_active(0); } } } - RangeModifyHdl(*m_pWidthMF); + RangeModifyHdl(m_xWidthMF->get_widget()); } -IMPL_LINK( SvxSwPosSizeTabPage, PosHdl, ListBox&, rLB, void ) +IMPL_LINK(SvxSwPosSizeTabPage, PosHdl, weld::ComboBoxText&, rLB, void) { - bool bHori = &rLB == m_pHoriLB; - ListBox *pRelLB = bHori ? m_pHoriToLB.get() : m_pVertToLB.get(); - FixedText *pRelFT = bHori ? m_pHoriToFT.get() : m_pVertToFT.get(); + bool bHori = &rLB == m_xHoriLB.get(); + weld::ComboBoxText* pRelLB = bHori ? m_xHoriToLB.get() : m_xVertToLB.get(); + weld::Label* pRelFT = bHori ? m_xHoriToFT.get() : m_xVertToFT.get(); FrmMap *pMap = bHori ? m_pHMap : m_pVMap; @@ -1291,29 +1248,28 @@ IMPL_LINK( SvxSwPosSizeTabPage, PosHdl, ListBox&, rLB, void ) if (bHori) { bool bEnable = HoriOrientation::NONE == nAlign; - m_pHoriByMF->Enable( bEnable ); - m_pHoriByFT->Enable( bEnable ); + m_xHoriByMF->set_sensitive( bEnable ); + m_xHoriByFT->set_sensitive( bEnable ); } else { bool bEnable = VertOrientation::NONE == nAlign; - m_pVertByMF->Enable( bEnable ); - m_pVertByFT->Enable( bEnable ); + m_xVertByMF->set_sensitive( bEnable ); + m_xVertByFT->set_sensitive( bEnable ); } - RangeModifyHdl( *m_pWidthMF ); + RangeModifyHdl(m_xWidthMF->get_widget()); short nRel = 0; - if (rLB.GetSelectedEntryCount()) + if (rLB.get_active() != -1) { - - if (pRelLB->GetSelectedEntryPos() != LISTBOX_ENTRY_NOTFOUND) - nRel = static_cast<RelationMap *>(pRelLB->GetSelectedEntryData())->nRelation; + if (pRelLB->get_active() != -1) + nRel = reinterpret_cast<RelationMap*>(pRelLB->get_active_id().toUInt64())->nRelation; FillRelLB(pMap, nMapPos, nAlign, nRel, *pRelLB, *pRelFT); } else - pRelLB->Clear(); + pRelLB->clear(); UpdateExample(); @@ -1326,101 +1282,100 @@ IMPL_LINK( SvxSwPosSizeTabPage, PosHdl, ListBox&, rLB, void ) // on the right only below is allowed - from the left only at the top // from the left at the character -> below if((HoriOrientation::LEFT == nAlign || HoriOrientation::RIGHT == nAlign) && - 0 == m_pVertLB->GetSelectedEntryPos()) + 0 == m_xVertLB->get_active()) { if(RelOrientation::FRAME == nRel) - m_pVertLB->SelectEntryPos(1); + m_xVertLB->set_active(1); else - m_pVertLB->SelectEntryPos(0); + m_xVertLB->set_active(0); bSet = true; } - else if(HoriOrientation::LEFT == nAlign && 1 == m_pVertLB->GetSelectedEntryPos()) + else if(HoriOrientation::LEFT == nAlign && 1 == m_xVertLB->get_active()) { - m_pVertLB->SelectEntryPos(0); + m_xVertLB->set_active(0); bSet = true; } - else if(HoriOrientation::NONE == nAlign && 1 == m_pVertLB->GetSelectedEntryPos()) + else if(HoriOrientation::NONE == nAlign && 1 == m_xVertLB->get_active()) { - m_pVertLB->SelectEntryPos(0); + m_xVertLB->set_active(0); bSet = true; } if(bSet) - PosHdl(*m_pVertLB); + PosHdl(*m_xVertLB); } else { if(VertOrientation::TOP == nAlign) { - if(1 == m_pHoriLB->GetSelectedEntryPos()) + if(1 == m_xHoriLB->get_active()) { - m_pHoriLB->SelectEntryPos(0); + m_xHoriLB->set_active(0); bSet = true; } - m_pHoriToLB->SelectEntryPos(1); + m_xHoriToLB->set_active(1); } else if(VertOrientation::CHAR_BOTTOM == nAlign) { - if(2 == m_pHoriLB->GetSelectedEntryPos()) + if(2 == m_xHoriLB->get_active()) { - m_pHoriLB->SelectEntryPos(0); + m_xHoriLB->set_active(0); bSet = true; } - m_pHoriToLB->SelectEntryPos(0) ; + m_xHoriToLB->set_active(0) ; } if(bSet) - PosHdl(*m_pHoriLB); + PosHdl(*m_xHoriLB); } } } -IMPL_LINK( SvxSwPosSizeTabPage, ModifyHdl, Edit&, rEdit, void ) +IMPL_LINK( SvxSwPosSizeTabPage, ModifyHdl, weld::MetricSpinButton&, rEdit, void ) { - sal_Int64 nWidth = m_pWidthMF->Denormalize(m_pWidthMF->GetValue(FUNIT_TWIP)); - sal_Int64 nHeight = m_pHeightMF->Denormalize(m_pHeightMF->GetValue(FUNIT_TWIP)); - if ( m_pKeepRatioCB->IsChecked() ) + auto nWidth = m_xWidthMF->denormalize(m_xWidthMF->get_value(FUNIT_TWIP)); + auto nHeight = m_xHeightMF->denormalize(m_xHeightMF->get_value(FUNIT_TWIP)); + if (m_xKeepRatioCB->get_active()) { - if ( &rEdit == m_pWidthMF ) + if ( &rEdit == m_xWidthMF.get() ) { - nHeight = sal_Int64(static_cast<double>(nWidth) / m_fWidthHeightRatio); - m_pHeightMF->SetValue(m_pHeightMF->Normalize(nHeight), FUNIT_TWIP); + nHeight = int(static_cast<double>(nWidth) / m_fWidthHeightRatio); + m_xHeightMF->set_value(m_xHeightMF->normalize(nHeight), FUNIT_TWIP); } - else if(&rEdit == m_pHeightMF) + else if(&rEdit == m_xHeightMF.get()) { - nWidth = sal_Int64(static_cast<double>(nHeight) * m_fWidthHeightRatio); - m_pWidthMF->SetValue(m_pWidthMF->Normalize(nWidth), FUNIT_TWIP); + nWidth = int(static_cast<double>(nHeight) * m_fWidthHeightRatio); + m_xWidthMF->set_value(m_xWidthMF->normalize(nWidth), FUNIT_TWIP); } } m_fWidthHeightRatio = nHeight ? double(nWidth) / double(nHeight) : 1.0; UpdateExample(); } -IMPL_LINK_NOARG(SvxSwPosSizeTabPage, ProtectHdl, Button*, void) +IMPL_LINK_NOARG(SvxSwPosSizeTabPage, ProtectHdl, weld::ToggleButton&, void) { - if( m_pSizeCB->IsEnabled() ) + if (m_xSizeCB->get_sensitive()) { - m_nProtectSizeState = m_pSizeCB->GetState(); + m_nProtectSizeState = m_xSizeCB->get_state(); } - m_pSizeCB->SetState( m_pPositionCB->GetState() == TRISTATE_TRUE ? TRISTATE_TRUE : m_nProtectSizeState ); - m_pSizeCB->Enable(m_pPositionCB->IsEnabled() && !m_pPositionCB->IsChecked()); + m_xSizeCB->set_state(m_xPositionCB->get_state() == TRISTATE_TRUE ? TRISTATE_TRUE : m_nProtectSizeState); + m_xSizeCB->set_sensitive(m_xPositionCB->get_sensitive() && !m_xPositionCB->get_active()); } -short SvxSwPosSizeTabPage::GetRelation(ListBox const &rRelationLB) +short SvxSwPosSizeTabPage::GetRelation(const weld::ComboBoxText& rRelationLB) { short nRel = 0; - sal_Int32 nPos = rRelationLB.GetSelectedEntryPos(); - - if (nPos != LISTBOX_ENTRY_NOTFOUND) + int nPos = rRelationLB.get_active(); + if (nPos != -1) { - RelationMap *pEntry = static_cast<RelationMap *>(rRelationLB.GetEntryData(nPos)); + RelationMap *pEntry = reinterpret_cast<RelationMap*>(rRelationLB.get_id(nPos).toUInt64()); nRel = pEntry->nRelation; } return nRel; } -short SvxSwPosSizeTabPage::GetAlignment(FrmMap const *pMap, sal_uInt16 nMapPos, ListBox const &rRelationLB) +short SvxSwPosSizeTabPage::GetAlignment(FrmMap const *pMap, sal_uInt16 nMapPos, const weld::ComboBoxText& rRelationLB) { short nAlign = 0; @@ -1429,9 +1384,9 @@ short SvxSwPosSizeTabPage::GetAlignment(FrmMap const *pMap, sal_uInt16 nMapPos, if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap || pMap == aVCharMap ) { - if (rRelationLB.GetSelectedEntryPos() != LISTBOX_ENTRY_NOTFOUND) + if (rRelationLB.get_active() != -1) { - LB nRel = static_cast<RelationMap *>(rRelationLB.GetSelectedEntryData())->nLBRelation; + LB nRel = reinterpret_cast<RelationMap*>(rRelationLB.get_active_id().toUInt64())->nLBRelation; std::size_t nMapCount = ::lcl_GetFrmMapCount(pMap); SvxSwFramePosString::StringId eStrId = pMap[nMapPos].eStrId; @@ -1455,17 +1410,17 @@ short SvxSwPosSizeTabPage::GetAlignment(FrmMap const *pMap, sal_uInt16 nMapPos, return nAlign; } -sal_uInt16 SvxSwPosSizeTabPage::GetMapPos(FrmMap const *pMap, ListBox const &rAlignLB) +sal_uInt16 SvxSwPosSizeTabPage::GetMapPos(FrmMap const *pMap, const weld::ComboBoxText& rAlignLB) { sal_uInt16 nMapPos = 0; - sal_Int32 nLBSelPos = rAlignLB.GetSelectedEntryPos(); + int nLBSelPos = rAlignLB.get_active(); - if (nLBSelPos != LISTBOX_ENTRY_NOTFOUND) + if (nLBSelPos != -1) { if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap) { std::size_t nMapCount = ::lcl_GetFrmMapCount(pMap); - OUString sSelEntry(rAlignLB.GetSelectedEntry()); + OUString sSelEntry(rAlignLB.get_active_text()); for (std::size_t i = 0; i < nMapCount; i++) { @@ -1495,23 +1450,23 @@ void SvxSwPosSizeTabPage::InitPos(RndStdIds nAnchor, long nX, long nY) { - sal_Int32 nPos = m_pVertLB->GetSelectedEntryPos(); - if ( nPos != LISTBOX_ENTRY_NOTFOUND && m_pVMap ) + int nPos = m_xVertLB->get_active(); + if (nPos != -1 && m_pVMap) { m_nOldV = m_pVMap[nPos].nAlign; - nPos = m_pVertToLB->GetSelectedEntryPos(); - if (nPos != LISTBOX_ENTRY_NOTFOUND) - m_nOldVRel = static_cast<RelationMap *>(m_pVertToLB->GetEntryData(nPos))->nRelation; + nPos = m_xVertToLB->get_active(); + if (nPos != -1) + m_nOldVRel = reinterpret_cast<RelationMap*>(m_xVertToLB->get_id(nPos).toUInt64())->nRelation; } - nPos = m_pHoriLB->GetSelectedEntryPos(); - if ( nPos != LISTBOX_ENTRY_NOTFOUND && m_pHMap ) + nPos = m_xHoriLB->get_active(); + if (nPos != -1 && m_pHMap) { m_nOldH = m_pHMap[nPos].nAlign; - nPos = m_pHoriToLB->GetSelectedEntryPos(); - if (nPos != LISTBOX_ENTRY_NOTFOUND) - m_nOldHRel = static_cast<RelationMap *>(m_pHoriToLB->GetEntryData(nPos))->nRelation; + nPos = m_xHoriToLB->get_active(); + if (nPos != -1) + m_nOldHRel = reinterpret_cast<RelationMap*>(m_xHoriToLB->get_id(nPos).toUInt64())->nRelation; } bool bEnable = true; @@ -1564,8 +1519,8 @@ void SvxSwPosSizeTabPage::InitPos(RndStdIds nAnchor, m_pHMap = nullptr; bEnable = false; } - m_pHoriLB->Enable( bEnable ); - m_pHoriFT->Enable( bEnable ); + m_xHoriLB->set_sensitive(bEnable); + m_xHoriFT->set_sensitive(bEnable); // select current Pos // horizontal @@ -1575,8 +1530,8 @@ void SvxSwPosSizeTabPage::InitPos(RndStdIds nAnchor, nHRel = m_nOldHRel; } // #i22341# - pass <nHRel> as 3rd parameter to method <FillPosLB> - sal_uInt16 nMapPos = FillPosLB(m_pHMap, nH, nHRel, *m_pHoriLB); - FillRelLB(m_pHMap, nMapPos, nH, nHRel, *m_pHoriToLB, *m_pHoriToFT); + sal_uInt16 nMapPos = FillPosLB(m_pHMap, nH, nHRel, *m_xHoriLB); + FillRelLB(m_pHMap, nMapPos, nH, nHRel, *m_xHoriToLB, *m_xHoriToFT); // vertical if ( nV == USHRT_MAX ) @@ -1585,39 +1540,35 @@ void SvxSwPosSizeTabPage::InitPos(RndStdIds nAnchor, nVRel = m_nOldVRel; } // #i22341# - pass <nVRel> as 3rd parameter to method <FillPosLB> - nMapPos = FillPosLB(m_pVMap, nV, nVRel, *m_pVertLB); - FillRelLB(m_pVMap, nMapPos, nV, nVRel, *m_pVertToLB, *m_pVertToFT); + nMapPos = FillPosLB(m_pVMap, nV, nVRel, *m_xVertLB); + FillRelLB(m_pVMap, nMapPos, nV, nVRel, *m_xVertToLB, *m_xVertToFT); // Edits init bEnable = nH == HoriOrientation::NONE && nAnchor != RndStdIds::FLY_AS_CHAR; //#61359# why not in formats&& !bFormat; if (!bEnable) { - m_pHoriByMF->SetValue( 0, FUNIT_TWIP ); - if (nX != LONG_MAX && m_bHtmlMode) - m_pHoriByMF->SetModifyFlag(); + m_xHoriByMF->set_value(0, FUNIT_TWIP); } else if(m_bIsMultiSelection) { - m_pHoriByMF->SetValue( m_pHoriByMF->Normalize(m_aRect.Left()), FUNIT_TWIP ); + m_xHoriByMF->set_value(m_xHoriByMF->normalize(m_aRect.Left()), FUNIT_TWIP); } else { if (nX != LONG_MAX) - m_pHoriByMF->SetValue( m_pHoriByMF->Normalize(nX), FUNIT_TWIP ); + m_xHoriByMF->set_value(m_xHoriByMF->normalize(nX), FUNIT_TWIP); } - m_pHoriByFT->Enable( bEnable ); - m_pHoriByMF->Enable( bEnable ); + m_xHoriByFT->set_sensitive(bEnable); + m_xHoriByMF->set_sensitive(bEnable); bEnable = nV == VertOrientation::NONE; if ( !bEnable ) { - m_pVertByMF->SetValue( 0, FUNIT_TWIP ); - if(nY != LONG_MAX && m_bHtmlMode) - m_pVertByMF->SetModifyFlag(); + m_xVertByMF->set_value( 0, FUNIT_TWIP ); } else if(m_bIsMultiSelection) { - m_pVertByMF->SetValue( m_pVertByMF->Normalize(m_aRect.Top()), FUNIT_TWIP ); + m_xVertByMF->set_value(m_xVertByMF->normalize(m_aRect.Top()), FUNIT_TWIP); } else { @@ -1629,60 +1580,60 @@ void SvxSwPosSizeTabPage::InitPos(RndStdIds nAnchor, nY *= -1; } if ( nY != LONG_MAX ) - m_pVertByMF->SetValue( m_pVertByMF->Normalize(nY), FUNIT_TWIP ); + m_xVertByMF->set_value( m_xVertByMF->normalize(nY), FUNIT_TWIP ); } - m_pVertByFT->Enable( bEnable ); - m_pVertByMF->Enable( bEnable ); + m_xVertByFT->set_sensitive( bEnable ); + m_xVertByMF->set_sensitive( bEnable ); UpdateExample(); } void SvxSwPosSizeTabPage::UpdateExample() { - sal_Int32 nPos = m_pHoriLB->GetSelectedEntryPos(); - if ( m_pHMap && nPos != LISTBOX_ENTRY_NOTFOUND ) + int nPos = m_xHoriLB->get_active(); + if (m_pHMap && nPos != -1) { - sal_uInt16 nMapPos = GetMapPos(m_pHMap, *m_pHoriLB); - short nAlign = GetAlignment(m_pHMap, nMapPos, *m_pHoriToLB); - short nRel = GetRelation(*m_pHoriToLB); + sal_uInt16 nMapPos = GetMapPos(m_pHMap, *m_xHoriLB); + short nAlign = GetAlignment(m_pHMap, nMapPos, *m_xHoriToLB); + short nRel = GetRelation(*m_xHoriToLB); - m_pExampleWN->SetHAlign(nAlign); - m_pExampleWN->SetHoriRel(nRel); + m_aExampleWN.SetHAlign(nAlign); + m_aExampleWN.SetHoriRel(nRel); } - nPos = m_pVertLB->GetSelectedEntryPos(); - if ( m_pVMap && nPos != LISTBOX_ENTRY_NOTFOUND ) + nPos = m_xVertLB->get_active(); + if (m_pVMap && nPos != -1) { - sal_uInt16 nMapPos = GetMapPos(m_pVMap, *m_pVertLB); - sal_uInt16 nAlign = GetAlignment(m_pVMap, nMapPos, *m_pVertToLB); - sal_uInt16 nRel = GetRelation(*m_pVertToLB); + sal_uInt16 nMapPos = GetMapPos(m_pVMap, *m_xVertLB); + sal_uInt16 nAlign = GetAlignment(m_pVMap, nMapPos, *m_xVertToLB); + sal_uInt16 nRel = GetRelation(*m_xVertToLB); - m_pExampleWN->SetVAlign(nAlign); - m_pExampleWN->SetVertRel(nRel); + m_aExampleWN.SetVAlign(nAlign); + m_aExampleWN.SetVertRel(nRel); } // Size - long nXPos = static_cast<long>(m_pHoriByMF->Denormalize(m_pHoriByMF->GetValue(FUNIT_TWIP))); - long nYPos = static_cast<long>(m_pVertByMF->Denormalize(m_pVertByMF->GetValue(FUNIT_TWIP))); - m_pExampleWN->SetRelPos(Point(nXPos, nYPos)); + auto nXPos = m_xHoriByMF->denormalize(m_xHoriByMF->get_value(FUNIT_TWIP)); + auto nYPos = m_xVertByMF->denormalize(m_xVertByMF->get_value(FUNIT_TWIP)); + m_aExampleWN.SetRelPos(Point(nXPos, nYPos)); - m_pExampleWN->SetAnchor( GetAnchorType() ); - m_pExampleWN->Invalidate(); + m_aExampleWN.SetAnchor( GetAnchorType() ); + m_aExampleWN.Invalidate(); } void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_uInt16 nAlign, - sal_uInt16 nRel, ListBox &rLB, FixedText &rFT) + sal_uInt16 nRel, weld::ComboBoxText& rLB, weld::Label& rFT) { OUString sSelEntry; LB nLBRelations = LB::NONE; std::size_t nMapCount = ::lcl_GetFrmMapCount(pMap); - rLB.Clear(); + rLB.clear(); if (nMapPos < nMapCount) { if (pMap == aVAsCharHtmlMap || pMap == aVAsCharMap) { - OUString sOldEntry(rLB.GetSelectedEntry()); + OUString sOldEntry(rLB.get_active_text()); SvxSwFramePosString::StringId eStrId = pMap[nMapPos].eStrId; for (std::size_t _nMapPos = 0; _nMapPos < nMapCount; _nMapPos++) @@ -1698,8 +1649,7 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, m_bIsVerticalFrame, m_bIsInRightToLeft); OUString sEntry = SvxSwFramePosString::GetString(sStrId1); - sal_Int32 nPos = rLB.InsertEntry(sEntry); - rLB.SetEntryData(nPos, &aAsCharRelationMap[nRelPos]); + rLB.append(OUString::number(reinterpret_cast<sal_uInt64>(&aAsCharRelationMap[nRelPos])), sEntry); if (pMap[_nMapPos].nAlign == nAlign) sSelEntry = sEntry; break; @@ -1708,19 +1658,18 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ } } if (!sSelEntry.isEmpty()) - rLB.SelectEntry(sSelEntry); + rLB.set_active_text(sSelEntry); else { - rLB.SelectEntry(sOldEntry); - - if (!rLB.GetSelectedEntryCount()) + rLB.set_active_text(sOldEntry); + if (rLB.get_active() == -1) { - for (sal_Int32 i = 0; i < rLB.GetEntryCount(); i++) + for (int i = 0; i < rLB.get_count(); i++) { - RelationMap *pEntry = static_cast<RelationMap *>(rLB.GetEntryData(i)); + RelationMap *pEntry = reinterpret_cast<RelationMap*>(rLB.get_id(i).toUInt64()); if (pEntry->nLBRelation == LB::RelChar) // Default { - rLB.SelectEntryPos(i); + rLB.set_active(i); break; } } @@ -1734,10 +1683,10 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ if ( pMap == aVCharMap ) { nLBRelations = ::lcl_GetLBRelationsForStrID( pMap, - ( m_pHoriMirrorCB->IsChecked() + ( m_xHoriMirrorCB->get_active() ? pMap[nMapPos].eMirrorStrId : pMap[nMapPos].eStrId ), - m_pHoriMirrorCB->IsChecked() ); + m_xHoriMirrorCB->get_active() ); } else { @@ -1752,11 +1701,10 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ { if (aRelationMap[nRelPos].nLBRelation == static_cast<LB>(nBit)) { - SvxSwFramePosString::StringId sStrId1 = m_pHoriMirrorCB->IsChecked() ? aRelationMap[nRelPos].eMirrorStrId : aRelationMap[nRelPos].eStrId; + SvxSwFramePosString::StringId sStrId1 = m_xHoriMirrorCB->get_active() ? aRelationMap[nRelPos].eMirrorStrId : aRelationMap[nRelPos].eStrId; sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, m_bIsVerticalFrame, m_bIsInRightToLeft); OUString sEntry = SvxSwFramePosString::GetString(sStrId1); - sal_Int32 nPos = rLB.InsertEntry(sEntry); - rLB.SetEntryData(nPos, &aRelationMap[nRelPos]); + rLB.append(OUString::number(reinterpret_cast<sal_uInt64>(&aRelationMap[nRelPos])), sEntry); if (sSelEntry.isEmpty() && aRelationMap[nRelPos].nRelation == nRel) sSelEntry = sEntry; } @@ -1764,7 +1712,7 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ } } if (!sSelEntry.isEmpty()) - rLB.SelectEntry(sSelEntry); + rLB.set_active_text(sSelEntry); else { // Probably anchor change. So look for a similar relation. @@ -1780,32 +1728,32 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ case RelOrientation::PAGE_PRINT_AREA: nRel = RelOrientation::PRINT_AREA; break; default: - if (rLB.GetEntryCount()) + if (rLB.get_count()) { - RelationMap *pEntry = static_cast<RelationMap *>(rLB.GetEntryData(rLB.GetEntryCount() - 1)); + RelationMap *pEntry = reinterpret_cast<RelationMap*>(rLB.get_id(rLB.get_count() - 1).toUInt64()); nRel = pEntry->nRelation; } break; } - for (sal_Int32 i = 0; i < rLB.GetEntryCount(); i++) + for (int i = 0; i < rLB.get_count(); ++i) { - RelationMap *pEntry = static_cast<RelationMap *>(rLB.GetEntryData(i)); + RelationMap *pEntry = reinterpret_cast<RelationMap*>(rLB.get_id(i).toUInt64()); if (pEntry->nRelation == nRel) { - rLB.SelectEntryPos(i); + rLB.set_active(i); break; } } - if (!rLB.GetSelectedEntryCount()) - rLB.SelectEntryPos(0); + if (rLB.get_active() == -1) + rLB.set_active(0); } } } - rLB.Enable(rLB.GetEntryCount() != 0); - rFT.Enable(rLB.GetEntryCount() != 0); + rLB.set_sensitive(rLB.get_count() != 0); + rFT.set_sensitive(rLB.get_count() != 0); RelHdl(rLB); } @@ -1813,12 +1761,12 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ sal_uInt16 SvxSwPosSizeTabPage::FillPosLB(FrmMap const *_pMap, sal_uInt16 _nAlign, const sal_uInt16 _nRel, - ListBox &_rLB) + weld::ComboBoxText& _rLB) { OUString sSelEntry, sOldEntry; - sOldEntry = _rLB.GetSelectedEntry(); + sOldEntry = _rLB.get_active_text(); - _rLB.Clear(); + _rLB.clear(); // #i22341# - determine all possible listbox relations for // given relation for map <aVCharMap> @@ -1830,13 +1778,13 @@ sal_uInt16 SvxSwPosSizeTabPage::FillPosLB(FrmMap const *_pMap, std::size_t nCount = ::lcl_GetFrmMapCount(_pMap); for (std::size_t i = 0; _pMap && i < nCount; ++i) { - SvxSwFramePosString::StringId eStrId = m_pHoriMirrorCB->IsChecked() ? _pMap[i].eMirrorStrId : _pMap[i].eStrId; + SvxSwFramePosString::StringId eStrId = m_xHoriMirrorCB->get_active() ? _pMap[i].eMirrorStrId : _pMap[i].eStrId; eStrId = lcl_ChangeResIdToVerticalOrRTL(eStrId, m_bIsVerticalFrame, m_bIsInRightToLeft); OUString sEntry(SvxSwFramePosString::GetString(eStrId)); - if (_rLB.GetEntryPos(sEntry) == LISTBOX_ENTRY_NOTFOUND) + if (_rLB.find_text(sEntry) == -1) { // don't insert duplicate entries at character wrapped borders - _rLB.InsertEntry(sEntry); + _rLB.append_text(sEntry); } // #i22341# - add condition to handle map <aVCharMap> // that is ambiguous in the alignment. @@ -1847,12 +1795,12 @@ sal_uInt16 SvxSwPosSizeTabPage::FillPosLB(FrmMap const *_pMap, } } - _rLB.SelectEntry(sSelEntry); - if (!_rLB.GetSelectedEntryCount()) - _rLB.SelectEntry(sOldEntry); + _rLB.set_active_text(sSelEntry); + if (_rLB.get_active() == -1) + _rLB.set_active_text(sOldEntry); - if (!_rLB.GetSelectedEntryCount()) - _rLB.SelectEntryPos(0); + if (_rLB.get_active() == -1) + _rLB.set_active(0); PosHdl(_rLB); @@ -1890,7 +1838,7 @@ void SvxSwPosSizeTabPage::SetView( const SdrView* pSdrView ) if( m_aAnchorPos != pObj->GetAnchorPos() ) { // different anchor positions -> disable positioning - m_pPosFrame->Enable(false); + m_xPosFrame->set_sensitive(false); m_bPositioningDisabled = true; return; } diff --git a/cui/uiconfig/ui/swpossizepage.ui b/cui/uiconfig/ui/swpossizepage.ui index 7cd135683de6..497c178e8ae0 100644 --- a/cui/uiconfig/ui/swpossizepage.ui +++ b/cui/uiconfig/ui/swpossizepage.ui @@ -1,8 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.22.1 --> <interface domain="cui"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> <object class="GtkAdjustment" id="adjustment1"> <property name="lower">0.050000000000000003</property> <property name="upper">99.989999999999995</property> @@ -15,6 +14,18 @@ <property name="step_increment">1</property> <property name="page_increment">10</property> </object> + <object class="GtkAdjustment" id="adjustment3"> + <property name="lower">-99.989999999999995</property> + <property name="upper">99.989999999999995</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustment4"> + <property name="lower">0.050000000000000003</property> + <property name="upper">99.989999999999995</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> <object class="GtkGrid" id="SwPosSizePage"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -55,9 +66,10 @@ <property name="can_focus">False</property> <property name="column_spacing">12</property> <child> - <object class="GtkSpinButton" id="width:0.00cm"> + <object class="GtkSpinButton" id="width"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="activates_default">True</property> <property name="adjustment">adjustment1</property> <property name="digits">2</property> </object> @@ -70,10 +82,10 @@ <object class="GtkLabel" id="widthft"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="swpossizepage|widthft">_Width:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">width:0.00cm</property> + <property name="mnemonic_widget">width</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -92,10 +104,11 @@ <property name="can_focus">False</property> <property name="column_spacing">12</property> <child> - <object class="GtkSpinButton" id="height:0.00cm"> + <object class="GtkSpinButton" id="height"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="adjustment">adjustment1</property> + <property name="activates_default">True</property> + <property name="adjustment">adjustment4</property> <property name="digits">2</property> </object> <packing> @@ -107,10 +120,10 @@ <object class="GtkLabel" id="heightft"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="swpossizepage|heightft">H_eight:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">height:0.00cm</property> + <property name="mnemonic_widget">height</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -163,7 +176,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <child> - <object class="svxlo-SvxSwFrameExample" id="preview"> + <object class="GtkDrawingArea" id="preview"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">center</property> @@ -210,7 +223,6 @@ <property name="xalign">0</property> <property name="active">True</property> <property name="draw_indicator">True</property> - <property name="group">topara</property> </object> <packing> <property name="left_attach">0</property> @@ -226,7 +238,7 @@ <property name="use_underline">True</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> - <property name="group">tochar</property> + <property name="group">topage</property> </object> <packing> <property name="left_attach">0</property> @@ -242,7 +254,7 @@ <property name="use_underline">True</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> - <property name="group">aschar</property> + <property name="group">topage</property> </object> <packing> <property name="left_attach">0</property> @@ -258,7 +270,7 @@ <property name="use_underline">True</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> - <property name="group">toframe</property> + <property name="group">topage</property> </object> <packing> <property name="left_attach">0</property> @@ -329,10 +341,10 @@ <object class="GtkLabel" id="horiposft"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="swpossizepage|horiposft">Hori_zontal:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">horipos</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -343,10 +355,10 @@ <object class="GtkLabel" id="horibyft"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="swpossizepage|horibyft">b_y:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">byhori:0.00cm</property> + <property name="mnemonic_widget">byhori</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">2</property> @@ -357,10 +369,10 @@ <object class="GtkLabel" id="vertbyft"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="swpossizepage|vertbyft">_by:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">byvert:0.00cm</property> + <property name="mnemonic_widget">byvert</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">2</property> @@ -371,10 +383,10 @@ <object class="GtkLabel" id="horitoft"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="swpossizepage|horitoft">_to:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">horianchor</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">4</property> @@ -382,9 +394,10 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="byhori:0.00cm"> + <object class="GtkSpinButton" id="byhori"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="activates_default">True</property> <property name="adjustment">adjustment2</property> <property name="digits">2</property> </object> @@ -417,10 +430,10 @@ <object class="GtkLabel" id="vertposft"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="swpossizepage|vertposft">_Vertical:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">vertpos</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -438,10 +451,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="byvert:0.00cm"> + <object class="GtkSpinButton" id="byvert"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="adjustment">adjustment2</property> + <property name="activates_default">True</property> + <property name="adjustment">adjustment3</property> <property name="digits">2</property> </object> <packing> @@ -453,10 +467,10 @@ <object class="GtkLabel" id="verttoft"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="swpossizepage|verttoft">t_o:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">vertanchor</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">4</property> diff --git a/include/svx/swframeexample.hxx b/include/svx/swframeexample.hxx index 92b0e63add06..c2fbd5cdc198 100644 --- a/include/svx/swframeexample.hxx +++ b/include/svx/swframeexample.hxx @@ -19,11 +19,12 @@ #ifndef INCLUDED_SVX_SWFRAMEEXAMPLE_HXX #define INCLUDED_SVX_SWFRAMEEXAMPLE_HXX -#include <vcl/window.hxx> #include <tools/color.hxx> #include <tools/gen.hxx> #include <svx/svxdllapi.h> #include <svx/swframetypes.hxx> +#include <vcl/customweld.hxx> +#include <vcl/window.hxx> #include <com/sun/star/text/WrapTextMode.hpp> class SVX_DLLPUBLIC SvxSwFrameExample : public vcl::Window @@ -87,6 +88,68 @@ public: void SetRelPos(const Point& rP); }; +class SVX_DLLPUBLIC SwFrameExample : public weld::CustomWidgetController +{ + Color m_aTransColor; ///< transparency + Color m_aBgCol; ///< background + Color m_aFrameColor; ///< graphic frame + Color m_aAlignColor; ///< align anchor + Color m_aBorderCol; ///< frame of doc + Color m_aPrintAreaCol; ///< frame of printable area of doc + Color m_aTxtCol; ///< symbolised text + Color m_aBlankCol; ///< area of symbol for blank + Color m_aBlankFrameCol; ///< frame of symbol for blank + + tools::Rectangle aPage; + tools::Rectangle aPagePrtArea; + tools::Rectangle aTextLine; + tools::Rectangle aPara; + tools::Rectangle aParaPrtArea; + tools::Rectangle aFrameAtFrame; + tools::Rectangle aDrawObj; + tools::Rectangle aAutoCharFrame; + Size aFrmSize; + + short nHAlign; + short nHRel; + + short nVAlign; + short nVRel; + + css::text::WrapTextMode nWrap; + RndStdIds nAnchor; + bool bTrans; + + Point aRelPos; + + void InitColors_Impl(); + void InitAllRects_Impl(vcl::RenderContext& rRenderContext); + void CalcBoundRect_Impl(vcl::RenderContext& rRenderContext, tools::Rectangle &rRect); + tools::Rectangle DrawInnerFrame_Impl(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect, const Color &rFillColor, const Color &rBorderColor); + + virtual void StyleUpdated() override; + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override; +public: + + SwFrameExample(); + + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; + + void SetWrap(css::text::WrapTextMode nW) { nWrap = nW; } + + void SetHAlign(short nH) { nHAlign = nH; } + void SetHoriRel(short nR) { nHRel = nR; } + + void SetVAlign(short nV) { nVAlign = nV; } + void SetVertRel(short nR) { nVRel = nR; } + + void SetTransparent(bool bT) { bTrans = bT; } + void SetAnchor(RndStdIds nA) { nAnchor = nA; } + + void SetRelPos(const Point& rP); +}; + + #endif // INCLUDED_SVX_SWFRAMEEXAMPLE_HXX diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index b890bf197498..fe45e32e0b03 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -684,7 +684,7 @@ public: } void set_help_id(const OString& rName) { m_xSpinButton->set_help_id(rName); } void set_position(int nCursorPos) { m_xSpinButton->set_position(nCursorPos); } - const weld::SpinButton* get_widget() const { return m_xSpinButton.get(); } + weld::SpinButton& get_widget() { return *m_xSpinButton; } }; class VCL_DLLPUBLIC TimeSpinButton @@ -741,7 +741,7 @@ public: return m_xSpinButton->get_value_changed_from_saved(); } void set_position(int nCursorPos) { m_xSpinButton->set_position(nCursorPos); } - weld::SpinButton* get_widget() { return m_xSpinButton.get(); } + weld::SpinButton& get_widget() { return *m_xSpinButton; } }; class VCL_DLLPUBLIC Label : virtual public Widget diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx index 286cb66d6846..ac7269345c0c 100644 --- a/starmath/source/dialog.cxx +++ b/starmath/source/dialog.cxx @@ -635,13 +635,13 @@ IMPL_LINK( SmDistanceDialog, GetFocusHdl, weld::Widget&, rControl, void ) { sal_uInt16 i; - if (&rControl == m_xMetricField1->get_widget()) + if (&rControl == &m_xMetricField1->get_widget()) i = 0; - else if (&rControl == m_xMetricField2->get_widget()) + else if (&rControl == &m_xMetricField2->get_widget()) i = 1; - else if (&rControl == m_xMetricField3->get_widget()) + else if (&rControl == &m_xMetricField3->get_widget()) i = 2; - else if (&rControl == m_xMetricField4->get_widget()) + else if (&rControl == &m_xMetricField4->get_widget()) i = 3; else return; diff --git a/svx/source/dialog/swframeexample.cxx b/svx/source/dialog/swframeexample.cxx index ceacc555d0e6..21bf84dc61c0 100644 --- a/svx/source/dialog/swframeexample.cxx +++ b/svx/source/dialog/swframeexample.cxx @@ -716,4 +716,670 @@ void SvxSwFrameExample::SetRelPos(const Point& rP) aRelPos.setY( -5 ); } +SwFrameExample::SwFrameExample() + : nHAlign(HoriOrientation::CENTER) + , nHRel(RelOrientation::FRAME) + , nVAlign(VertOrientation::TOP) + , nVRel(RelOrientation::PRINT_AREA) + , nWrap(WrapTextMode_NONE) + , nAnchor(RndStdIds::FLY_AT_PAGE) + , bTrans(false) + , aRelPos(Point(0,0)) +{ + InitColors_Impl(); +} + +void SwFrameExample::SetDrawingArea(weld::DrawingArea* pDrawingArea) +{ + pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 16, + pDrawingArea->get_text_height() * 12); + CustomWidgetController::SetDrawingArea(pDrawingArea); +} + +void SwFrameExample::InitColors_Impl() +{ + const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); + m_aBgCol = rSettings.GetWindowColor(); + + bool bHC = rSettings.GetHighContrastMode(); + + m_aFrameColor = COL_LIGHTGREEN; + m_aAlignColor = COL_LIGHTRED; + m_aTransColor = COL_TRANSPARENT; + + m_aTxtCol = bHC? + svtools::ColorConfig().GetColorValue(svtools::FONTCOLOR).nColor : + COL_GRAY; + m_aPrintAreaCol = bHC? m_aTxtCol : COL_GRAY; + m_aBorderCol = m_aTxtCol; + m_aBlankCol = bHC? m_aTxtCol : COL_LIGHTGRAY; + m_aBlankFrameCol = bHC? m_aTxtCol : COL_GRAY; +} + +void SwFrameExample::StyleUpdated() +{ + InitColors_Impl(); + CustomWidgetController::StyleUpdated(); +} + +void SwFrameExample::InitAllRects_Impl(vcl::RenderContext& rRenderContext) +{ + aPage.SetSize(GetOutputSizePixel()); + + sal_uInt32 nOutWPix = aPage.GetWidth(); + sal_uInt32 nOutHPix = aPage.GetHeight(); + + // PrintArea + sal_uInt32 nLBorder; + sal_uInt32 nRBorder; + sal_uInt32 nTBorder; + sal_uInt32 nBBorder; + + sal_uInt32 nLTxtBorder; + sal_uInt32 nRTxtBorder; + sal_uInt32 nTTxtBorder; + sal_uInt32 nBTxtBorder; + + if (nAnchor != RndStdIds::FLY_AS_CHAR) + { + nLBorder = 14; + nRBorder = 10; + nTBorder = 10; + nBBorder = 15; + + nLTxtBorder = 8; + nRTxtBorder = 4; + nTTxtBorder = 2; + nBTxtBorder = 2; + } + else + { + nLBorder = 2; + nRBorder = 2; + nTBorder = 2; + nBBorder = 2; + + nLTxtBorder = 2; + nRTxtBorder = 2; + nTTxtBorder = 2; + nBTxtBorder = 2; + } + aPagePrtArea = tools::Rectangle(Point(nLBorder, nTBorder), Point((nOutWPix - 1) - nRBorder, (nOutHPix - 1) - nBBorder)); + + // Example text: Preparing for the text output + // A line of text + aTextLine = aPagePrtArea; + aTextLine.SetSize(Size(aTextLine.GetWidth(), 2)); + aTextLine.AdjustLeft(nLTxtBorder ); + aTextLine.AdjustRight( -sal_Int32(nRTxtBorder) ); + aTextLine.Move(0, nTTxtBorder); + + // Rectangle to edges including paragraph + sal_uInt16 nLines = static_cast<sal_uInt16>((aPagePrtArea.GetHeight() / 2 - nTTxtBorder - nBTxtBorder) + / (aTextLine.GetHeight() + 2)); + aPara = aPagePrtArea; + aPara.SetSize(Size(aPara.GetWidth(), + (aTextLine.GetHeight() + 2) * nLines + nTTxtBorder + nBTxtBorder)); + + // Rectangle around paragraph without borders + aParaPrtArea = aPara; + aParaPrtArea.AdjustLeft(nLTxtBorder ); + aParaPrtArea.AdjustRight( -sal_Int32(nRTxtBorder) ); + aParaPrtArea.AdjustTop(nTTxtBorder ); + aParaPrtArea.AdjustBottom( -sal_Int32(nBTxtBorder) ); + + if (nAnchor == RndStdIds::FLY_AS_CHAR || nAnchor == RndStdIds::FLY_AT_CHAR) + { + vcl::Font aFont = OutputDevice::GetDefaultFont( + DefaultFontType::LATIN_TEXT, Application::GetSettings().GetLanguageTag().getLanguageType(), + GetDefaultFontFlags::OnlyOne, &rRenderContext ); + aFont.SetColor( m_aTxtCol ); + aFont.SetFillColor( m_aBgCol ); + aFont.SetWeight(WEIGHT_NORMAL); + + if (nAnchor == RndStdIds::FLY_AS_CHAR) + { + aFont.SetFontSize(Size(0, aParaPrtArea.GetHeight() - 2)); + rRenderContext.SetFont(aFont); + aParaPrtArea.SetSize(Size(rRenderContext.GetTextWidth(DEMOTEXT), rRenderContext.GetTextHeight())); + } + else + { + aFont.SetFontSize(Size(0, aParaPrtArea.GetHeight() / 2)); + rRenderContext.SetFont(aFont); + aAutoCharFrame.SetSize(Size(rRenderContext.GetTextWidth(OUString('A')), GetTextHeight())); + aAutoCharFrame.SetPos(Point(aParaPrtArea.Left() + (aParaPrtArea.GetWidth() - aAutoCharFrame.GetWidth()) / 2, + aParaPrtArea.Top() + (aParaPrtArea.GetHeight() - aAutoCharFrame.GetHeight()) / 2)); + } + } + + // Inner Frame anchored at the Frame + aFrameAtFrame = aPara; + aFrameAtFrame.AdjustLeft(9 ); + aFrameAtFrame.AdjustRight( -5 ); + aFrameAtFrame.AdjustBottom(5 ); + aFrameAtFrame.SetPos(Point(aFrameAtFrame.Left() + 2, (aPagePrtArea.Bottom() - aFrameAtFrame.GetHeight()) / 2 + 5)); + + // Size of the frame to be positioned + if (nAnchor != RndStdIds::FLY_AS_CHAR) + { + sal_uInt32 nLFBorder = nAnchor == RndStdIds::FLY_AT_PAGE ? nLBorder : nLTxtBorder; + sal_uInt32 nRFBorder = nAnchor == RndStdIds::FLY_AT_PAGE ? nRBorder : nRTxtBorder; + + switch (nHRel) + { + case RelOrientation::PAGE_LEFT: + case RelOrientation::FRAME_LEFT: + aFrmSize = Size(nLFBorder - 4, (aTextLine.GetHeight() + 2) * 3); + break; + + case RelOrientation::PAGE_RIGHT: + case RelOrientation::FRAME_RIGHT: + aFrmSize = Size(nRFBorder - 4, (aTextLine.GetHeight() + 2) * 3); + break; + + default: + aFrmSize = Size(nLBorder - 3, (aTextLine.GetHeight() + 2) * 3); + break; + } + aFrmSize.setWidth( std::max(5L, aFrmSize.Width()) ); + aFrmSize.setHeight( std::max(5L, aFrmSize.Height()) ); + } + else + { + sal_uInt32 nFreeWidth = aPagePrtArea.GetWidth() - rRenderContext.GetTextWidth(DEMOTEXT); + + aFrmSize = Size(nFreeWidth / 2, (aTextLine.GetHeight() + 2) * 3); + aDrawObj.SetSize(Size(std::max(5L, static_cast<long>(nFreeWidth) / 3L), std::max(5L, aFrmSize.Height() * 3L))); + aDrawObj.SetPos(Point(aParaPrtArea.Right() + 1, aParaPrtArea.Bottom() / 2)); + aParaPrtArea.SetRight( aDrawObj.Right() ); + } +} + +void SwFrameExample::CalcBoundRect_Impl(vcl::RenderContext& rRenderContext, tools::Rectangle &rRect) +{ + switch (nAnchor) + { + case RndStdIds::FLY_AT_PAGE: + { + switch (nHRel) + { + case RelOrientation::FRAME: + case RelOrientation::PAGE_FRAME: + rRect.SetLeft( aPage.Left() ); + rRect.SetRight( aPage.Right() ); + break; + + case RelOrientation::PRINT_AREA: + case RelOrientation::PAGE_PRINT_AREA: + rRect.SetLeft( aPagePrtArea.Left() ); + rRect.SetRight( aPagePrtArea.Right() ); + break; + + case RelOrientation::PAGE_LEFT: + rRect.SetLeft( aPage.Left() ); + rRect.SetRight( aPagePrtArea.Left() ); + break; + + case RelOrientation::PAGE_RIGHT: + rRect.SetLeft( aPagePrtArea.Right() ); + rRect.SetRight( aPage.Right() ); + break; + } + + switch (nVRel) + { + case RelOrientation::PRINT_AREA: + case RelOrientation::PAGE_PRINT_AREA: + rRect.SetTop( aPagePrtArea.Top() ); + rRect.SetBottom( aPagePrtArea.Bottom() ); + break; + + case RelOrientation::FRAME: + case RelOrientation::PAGE_FRAME: + rRect.SetTop( aPage.Top() ); + rRect.SetBottom( aPage.Bottom() ); + break; + } + } + break; + + case RndStdIds::FLY_AT_FLY: + { + switch (nHRel) + { + case RelOrientation::FRAME: + case RelOrientation::PAGE_FRAME: + rRect.SetLeft( aFrameAtFrame.Left() ); + rRect.SetRight( aFrameAtFrame.Right() ); + break; + + case RelOrientation::PRINT_AREA: + case RelOrientation::PAGE_PRINT_AREA: + rRect.SetLeft( aFrameAtFrame.Left() + FLYINFLY_BORDER ); + rRect.SetRight( aFrameAtFrame.Right() - FLYINFLY_BORDER ); + break; + + case RelOrientation::PAGE_RIGHT: + rRect.SetLeft( aFrameAtFrame.Left() ); + rRect.SetRight( aFrameAtFrame.Left() + FLYINFLY_BORDER ); + break; + + case RelOrientation::PAGE_LEFT: + rRect.SetLeft( aFrameAtFrame.Right() ); + rRect.SetRight( aFrameAtFrame.Right() - FLYINFLY_BORDER ); + break; + } + + switch (nVRel) + { + case RelOrientation::FRAME: + case RelOrientation::PAGE_FRAME: + rRect.SetTop( aFrameAtFrame.Top() ); + rRect.SetBottom( aFrameAtFrame.Bottom() ); + break; + + case RelOrientation::PRINT_AREA: + case RelOrientation::PAGE_PRINT_AREA: + rRect.SetTop( aFrameAtFrame.Top() + FLYINFLY_BORDER ); + rRect.SetBottom( aFrameAtFrame.Bottom() - FLYINFLY_BORDER ); + break; + } + } + break; + case RndStdIds::FLY_AT_PARA: + case RndStdIds::FLY_AT_CHAR: + { + switch (nHRel) + { + case RelOrientation::FRAME: + rRect.SetLeft( aPara.Left() ); + rRect.SetRight( aPara.Right() ); + break; + + case RelOrientation::PRINT_AREA: + rRect.SetLeft( aParaPrtArea.Left() ); + rRect.SetRight( aParaPrtArea.Right() ); + break; + + case RelOrientation::PAGE_LEFT: + rRect.SetLeft( aPage.Left() ); + rRect.SetRight( aPagePrtArea.Left() ); + break; + + case RelOrientation::PAGE_RIGHT: + rRect.SetLeft( aPagePrtArea.Right() ); + rRect.SetRight( aPage.Right() ); + break; + + case RelOrientation::PAGE_FRAME: + rRect.SetLeft( aPage.Left() ); + rRect.SetRight( aPage.Right() ); + break; + + case RelOrientation::PAGE_PRINT_AREA: + rRect.SetLeft( aPagePrtArea.Left() ); + rRect.SetRight( aPagePrtArea.Right() ); + break; + + case RelOrientation::FRAME_LEFT: + rRect.SetLeft( aPara.Left() ); + rRect.SetRight( aParaPrtArea.Left() ); + break; + + case RelOrientation::FRAME_RIGHT: + rRect.SetLeft( aParaPrtArea.Right() ); + rRect.SetRight( aPara.Right() ); + break; + + case RelOrientation::CHAR: + rRect.SetLeft( aAutoCharFrame.Left() ); + rRect.SetRight( aAutoCharFrame.Left() ); + break; + } + + switch (nVRel) + { + case RelOrientation::FRAME: + rRect.SetTop( aPara.Top() ); + rRect.SetBottom( aPara.Bottom() ); + break; + + case RelOrientation::PRINT_AREA: + rRect.SetTop( aParaPrtArea.Top() ); + rRect.SetBottom( aParaPrtArea.Bottom() ); + break; + + case RelOrientation::CHAR: + if (nVAlign != VertOrientation::NONE && + nVAlign != VertOrientation::CHAR_BOTTOM) + rRect.SetTop( aAutoCharFrame.Top() ); + else + rRect.SetTop( aAutoCharFrame.Bottom() ); + rRect.SetBottom( aAutoCharFrame.Bottom() ); + break; + // OD 12.11.2003 #i22341# + case RelOrientation::TEXT_LINE: + rRect.SetTop( aAutoCharFrame.Top() ); + rRect.SetBottom( aAutoCharFrame.Top() ); + break; + } + } + break; + + case RndStdIds::FLY_AS_CHAR: + rRect.SetLeft( aParaPrtArea.Left() ); + rRect.SetRight( aParaPrtArea.Right() ); + + switch (nVAlign) + { + case VertOrientation::NONE: + case VertOrientation::TOP: + case VertOrientation::CENTER: + case VertOrientation::BOTTOM: + { + FontMetric aMetric(rRenderContext.GetFontMetric()); + + rRect.SetTop( aParaPrtArea.Bottom() - aMetric.GetDescent() ); + rRect.SetBottom( rRect.Top() ); + } + break; + + default: + + case VertOrientation::LINE_TOP: + case VertOrientation::LINE_CENTER: + case VertOrientation::LINE_BOTTOM: + rRect.SetTop( aParaPrtArea.Top() ); + rRect.SetBottom( aDrawObj.Bottom() ); + break; + + case VertOrientation::CHAR_TOP: + case VertOrientation::CHAR_CENTER: + case VertOrientation::CHAR_BOTTOM: + rRect.SetTop( aParaPrtArea.Top() ); + rRect.SetBottom( aParaPrtArea.Bottom() ); + break; + } + break; + + default: + break; + } +} + +tools::Rectangle SwFrameExample::DrawInnerFrame_Impl(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect, + const Color &rFillColor, const Color &rBorderColor) +{ + DrawRect_Impl(rRenderContext, rRect, rFillColor, rBorderColor); + + // determine the area relative to which the positioning happens + tools::Rectangle aRect(rRect); // aPagePrtArea = Default + CalcBoundRect_Impl(rRenderContext, aRect); + + if (nAnchor == RndStdIds::FLY_AT_FLY && &rRect == &aPagePrtArea) + { + // draw text paragraph + tools::Rectangle aTxt(aTextLine); + sal_Int32 nStep = aTxt.GetHeight() + 2; + sal_uInt16 nLines = static_cast<sal_uInt16>(aParaPrtArea.GetHeight() / (aTextLine.GetHeight() + 2)); + + for (sal_uInt16 i = 0; i < nLines; i++) + { + if (i == nLines - 1) + aTxt.SetSize(Size(aTxt.GetWidth() / 2, aTxt.GetHeight())); + DrawRect_Impl(rRenderContext, aTxt, m_aTxtCol, m_aTransColor); + aTxt.Move(0, nStep); + } + } + + return aRect; +} + +void SwFrameExample::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) +{ + rRenderContext.SetMapMode(MapMode(MapUnit::MapPixel)); + + InitAllRects_Impl(rRenderContext); + + // Draw page + DrawRect_Impl(rRenderContext, aPage, m_aBgCol, m_aBorderCol); + + // Draw PrintArea + tools::Rectangle aRect = DrawInnerFrame_Impl(rRenderContext, aPagePrtArea, m_aTransColor, m_aPrintAreaCol); + + if (nAnchor == RndStdIds::FLY_AT_FLY) + aRect = DrawInnerFrame_Impl(rRenderContext, aFrameAtFrame, m_aBgCol, m_aBorderCol); + + long lXPos = 0; + long lYPos = 0; + + // Horizontal alignment + if (nAnchor != RndStdIds::FLY_AS_CHAR) + { + switch (nHAlign) + { + case HoriOrientation::RIGHT: + { + lXPos = aRect.Right() - aFrmSize.Width() + 1; + break; + } + case HoriOrientation::CENTER: + { + lXPos = aRect.Left() + (aRect.GetWidth() - aFrmSize.Width()) / 2; + break; + } + case HoriOrientation::NONE: + { + lXPos = aRect.Left() + aRelPos.X(); + break; + } + + default: // HoriOrientation::LEFT + lXPos = aRect.Left(); + break; + } + } + else + { + lXPos = aRect.Right() + 2; + } + + // Vertical Alignment + if (nAnchor != RndStdIds::FLY_AS_CHAR) + { + switch (nVAlign) + { + case VertOrientation::BOTTOM: + case VertOrientation::LINE_BOTTOM: + { + // #i22341# + if ( nVRel != RelOrientation::TEXT_LINE ) + { + lYPos = aRect.Bottom() - aFrmSize.Height() + 1; + } + else + { + lYPos = aRect.Top(); + } + break; + } + case VertOrientation::CENTER: + case VertOrientation::LINE_CENTER: + { + lYPos = aRect.Top() + (aRect.GetHeight() - aFrmSize.Height()) / 2; + break; + } + case VertOrientation::NONE: + { + // #i22341# + if ( nVRel != RelOrientation::CHAR && nVRel != RelOrientation::TEXT_LINE ) + lYPos = aRect.Top() + aRelPos.Y(); + else + lYPos = aRect.Top() - aRelPos.Y(); + break; + } + default: + // #i22341# + if ( nVRel != RelOrientation::TEXT_LINE ) + { + lYPos = aRect.Top(); + } + else + { + lYPos = aRect.Bottom() - aFrmSize.Height() + 1; + } + break; + } + } + else + { + switch(nVAlign) + { + case VertOrientation::CENTER: + case VertOrientation::CHAR_CENTER: + case VertOrientation::LINE_CENTER: + lYPos = aRect.Top() + (aRect.GetHeight() - aFrmSize.Height()) / 2; + break; + + case VertOrientation::TOP: + case VertOrientation::CHAR_BOTTOM: + case VertOrientation::LINE_BOTTOM: + lYPos = aRect.Bottom() - aFrmSize.Height() + 1; + break; + + default: + lYPos = aRect.Top() - aRelPos.Y(); + break; + } + } + + tools::Rectangle aFrmRect(Point(lXPos, lYPos), aFrmSize); + + tools::Rectangle* pOuterFrame = &aPage; + + if (nAnchor == RndStdIds::FLY_AT_FLY) + pOuterFrame = &aFrameAtFrame; + + if (aFrmRect.Left() < pOuterFrame->Left()) + aFrmRect.Move(pOuterFrame->Left() - aFrmRect.Left(), 0); + if (aFrmRect.Right() > pOuterFrame->Right()) + aFrmRect.Move(pOuterFrame->Right() - aFrmRect.Right(), 0); + + if (aFrmRect.Top() < pOuterFrame->Top()) + aFrmRect.Move(0, pOuterFrame->Top() - aFrmRect.Top()); + if (aFrmRect.Bottom() > pOuterFrame->Bottom()) + aFrmRect.Move(0, pOuterFrame->Bottom() - aFrmRect.Bottom()); + + // Draw Test paragraph + const long nTxtLineHeight = aTextLine.GetHeight(); + tools::Rectangle aTxt(aTextLine); + sal_Int32 nStep; + sal_uInt16 nLines; + + if (nAnchor == RndStdIds::FLY_AT_FLY) + { + aTxt.SetLeft( aFrameAtFrame.Left() + FLYINFLY_BORDER ); + aTxt.SetRight( aFrameAtFrame.Right() - FLYINFLY_BORDER ); + aTxt.SetTop( aFrameAtFrame.Top() + FLYINFLY_BORDER ); + aTxt.SetBottom( aTxt.Top() + aTextLine.GetHeight() - 1 ); + + nStep = aTxt.GetHeight() + 2; + nLines = static_cast<sal_uInt16>(((aFrameAtFrame.GetHeight() - 2 * FLYINFLY_BORDER) * 2 / 3) + / (aTxt.GetHeight() + 2)); + } + else + { + nStep = aTxt.GetHeight() + 2; + nLines = static_cast<sal_uInt16>(aParaPrtArea.GetHeight() / (aTextLine.GetHeight() + 2)); + } + + if (nAnchor != RndStdIds::FLY_AS_CHAR) + { + // Simulate text + const long nOldR = aTxt.Right(); + const long nOldL = aTxt.Left(); + + // #i22341# + const bool bIgnoreWrap = nAnchor == RndStdIds::FLY_AT_CHAR && + ( nHRel == RelOrientation::CHAR || nVRel == RelOrientation::CHAR || + nVRel == RelOrientation::TEXT_LINE ); + + for (sal_uInt16 i = 0; i < nLines; ++i) + { + if (i == (nLines - 1)) + aTxt.SetSize(Size(aTxt.GetWidth() / 2, aTxt.GetHeight())); + + if (aTxt.IsOver(aFrmRect) && nAnchor != RndStdIds::FLY_AS_CHAR && !bIgnoreWrap) + { + switch(nWrap) + { + case WrapTextMode_NONE: + aTxt.SetTop( aFrmRect.Bottom() + nTxtLineHeight ); + aTxt.SetBottom( aTxt.Top() + nTxtLineHeight - 1 ); + break; + + case WrapTextMode_LEFT: + aTxt.SetRight( aFrmRect.Left() ); + break; + + case WrapTextMode_RIGHT: + aTxt.SetLeft( aFrmRect.Right() ); + break; + default: break; + } + } + if (pOuterFrame->IsInside(aTxt)) + DrawRect_Impl(rRenderContext, aTxt, m_aTxtCol, m_aTransColor ); + + aTxt.Move(0, nStep); + aTxt.SetRight( nOldR ); + aTxt.SetLeft( nOldL ); + } + aTxt.Move(0, -nStep); + + if (nAnchor != RndStdIds::FLY_AT_FLY && aTxt.Bottom() > aParaPrtArea.Bottom()) + { + // Text has been replaced by frame, so adjust parameters height + sal_Int32 nDiff = aTxt.Bottom() - aParaPrtArea.Bottom(); + aParaPrtArea.AdjustBottom(nDiff ); + aPara.AdjustBottom(nDiff ); + + CalcBoundRect_Impl(rRenderContext, aRect); + + aParaPrtArea.AdjustBottom( -nDiff ); + aPara.AdjustBottom( -nDiff ); + } + if (nAnchor == RndStdIds::FLY_AT_CHAR && bIgnoreWrap) + rRenderContext.DrawText(aAutoCharFrame, OUString('A')); + } + else + { + rRenderContext.DrawText(aParaPrtArea, OUString(DEMOTEXT)); + DrawRect_Impl(rRenderContext, aDrawObj, m_aBlankCol, m_aBlankFrameCol ); + } + + // Draw rectangle on which the frame is aligned: + DrawRect_Impl(rRenderContext, aRect, m_aTransColor, m_aAlignColor); + + // Frame View + bool bDontFill = (nAnchor == RndStdIds::FLY_AT_CHAR && aFrmRect.IsOver(aAutoCharFrame)) || bTrans; + DrawRect_Impl(rRenderContext, aFrmRect, bDontFill? m_aTransColor : m_aBgCol, m_aFrameColor); +} + +void SwFrameExample::SetRelPos(const Point& rP) +{ + aRelPos = rP; + + if (aRelPos.X() > 0) + aRelPos.setX( 5 ); + if (aRelPos.X() < 0) + aRelPos.setX( -5 ); + + if (aRelPos.Y() > 0) + aRelPos.setY( 5 ); + if (aRelPos.Y() < 0) + aRelPos.setY( -5 ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index f587569adca5..260e6c056c4c 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -2304,9 +2304,8 @@ public: bool bTakeOwnership) override { weld::TimeSpinButton* pRet = new weld::TimeSpinButton(weld_spin_button(id, bTakeOwnership), eFormat); - SalInstanceSpinButton* pButton = dynamic_cast<SalInstanceSpinButton*>(pRet->get_widget()); - assert(pButton); - pButton->DisableRemainderFactor(); //so with hh::mm::ss, incrementing mm will not reset ss + SalInstanceSpinButton& rButton = dynamic_cast<SalInstanceSpinButton&>(pRet->get_widget()); + rButton.DisableRemainderFactor(); //so with hh::mm::ss, incrementing mm will not reset ss return pRet; } |