diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-09-10 16:30:33 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-09-11 09:57:26 +0200 |
commit | d072795d78342c4be68d9410ee438fa3607c34ac (patch) | |
tree | 04cc92f682947199227864f3be1800fa6479dcd9 /cui | |
parent | 1520d56ea3cd5075c71b8ec492e3d4c23b9593f5 (diff) |
weld SvxNumPositionTabPage
Change-Id: I95844c549393f5e151377cdfd79e770d1563b662
Reviewed-on: https://gerrit.libreoffice.org/60271
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/inc/numpages.hxx | 108 | ||||
-rw-r--r-- | cui/source/tabpages/numpages.cxx | 734 | ||||
-rw-r--r-- | cui/uiconfig/ui/numberingpositionpage.ui | 189 |
3 files changed, 625 insertions, 406 deletions
diff --git a/cui/source/inc/numpages.hxx b/cui/source/inc/numpages.hxx index e0d9a1909f30..7d5ebc526e84 100644 --- a/cui/source/inc/numpages.hxx +++ b/cui/source/inc/numpages.hxx @@ -65,6 +65,27 @@ class SvxNumberingPreview : public vcl::Window }; +class NumberingPreview : public weld::CustomWidgetController +{ + const SvxNumRule* pActNum; + vcl::Font aStdFont; + bool bPosition; + sal_uInt16 nActLevel; + +protected: + virtual void Paint( vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect ) override; + +public: + NumberingPreview(); + + void SetNumRule(const SvxNumRule* pNum) + {pActNum = pNum; Invalidate();}; + void SetPositionMode() + { bPosition = true;} + void SetLevel(sal_uInt16 nSet) {nActLevel = nSet;} + +}; + struct SvxNumSettings_Impl { SvxNumType nNumberType; @@ -358,37 +379,6 @@ class SvxNumPositionTabPage : public SfxTabPage using TabPage::ActivatePage; using TabPage::DeactivatePage; - VclPtr<ListBox> m_pLevelLB; - - // former set of controls shown for numbering rules containing list level - // attributes in SvxNumberFormat::SvxNumPositionAndSpaceMode == LABEL_WIDTH_AND_POSITION - VclPtr<FixedText> m_pDistBorderFT; - VclPtr<MetricField> m_pDistBorderMF; - VclPtr<CheckBox> m_pRelativeCB; - VclPtr<FixedText> m_pIndentFT; - VclPtr<MetricField> m_pIndentMF; - VclPtr<FixedText> m_pDistNumFT; - VclPtr<MetricField> m_pDistNumMF; - VclPtr<FixedText> m_pAlignFT; - VclPtr<ListBox> m_pAlignLB; - - // new set of controls shown for numbering rules containing list level - // attributes in SvxNumberFormat::SvxNumPositionAndSpaceMode == LABEL_ALIGNMENT - VclPtr<FixedText> m_pLabelFollowedByFT; - VclPtr<ListBox> m_pLabelFollowedByLB; - VclPtr<FixedText> m_pListtabFT; - VclPtr<MetricField> m_pListtabMF; - VclPtr<FixedText> m_pAlign2FT; - VclPtr<ListBox> m_pAlign2LB; - VclPtr<FixedText> m_pAlignedAtFT; - VclPtr<MetricField> m_pAlignedAtMF; - VclPtr<FixedText> m_pIndentAtFT; - VclPtr<MetricField> m_pIndentAtMF; - - VclPtr<PushButton> m_pStandardPB; - - VclPtr<SvxNumberingPreview> m_pPreviewWIN; - std::unique_ptr<SvxNumRule> pActNum; std::unique_ptr<SvxNumRule> pSaveNum; @@ -401,30 +391,54 @@ class SvxNumPositionTabPage : public SfxTabPage bool bInInintControl : 1; // workaround for Modify-error, is said to be corrected from 391 on bool bLabelAlignmentPosAndSpaceModeActive; + NumberingPreview m_aPreviewWIN; + std::unique_ptr<weld::TreeView> m_xLevelLB; + // former set of controls shown for numbering rules containing list level + // attributes in SvxNumberFormat::SvxNumPositionAndSpaceMode == LABEL_WIDTH_AND_POSITION + std::unique_ptr<weld::Label> m_xDistBorderFT; + std::unique_ptr<weld::MetricSpinButton> m_xDistBorderMF; + std::unique_ptr<weld::CheckButton> m_xRelativeCB; + std::unique_ptr<weld::Label> m_xIndentFT; + std::unique_ptr<weld::MetricSpinButton> m_xIndentMF; + std::unique_ptr<weld::Label> m_xDistNumFT; + std::unique_ptr<weld::MetricSpinButton> m_xDistNumMF; + std::unique_ptr<weld::Label> m_xAlignFT; + std::unique_ptr<weld::ComboBoxText> m_xAlignLB; + // new set of controls shown for numbering rules containing list level + // attributes in SvxNumberFormat::SvxNumPositionAndSpaceMode == LABEL_ALIGNMENT + std::unique_ptr<weld::Label> m_xLabelFollowedByFT; + std::unique_ptr<weld::ComboBoxText> m_xLabelFollowedByLB; + std::unique_ptr<weld::Label> m_xListtabFT; + std::unique_ptr<weld::MetricSpinButton> m_xListtabMF; + std::unique_ptr<weld::Label>m_xAlign2FT; + std::unique_ptr<weld::ComboBoxText> m_xAlign2LB; + std::unique_ptr<weld::Label> m_xAlignedAtFT; + std::unique_ptr<weld::MetricSpinButton> m_xAlignedAtMF; + std::unique_ptr<weld::Label> m_xIndentAtFT; + std::unique_ptr<weld::MetricSpinButton> m_xIndentAtMF; + std::unique_ptr<weld::Button> m_xStandardPB; + std::unique_ptr<weld::CustomWeld> m_xPreviewWIN; + void InitControls(); - DECL_LINK( LevelHdl_Impl, ListBox&, void ); - DECL_LINK( EditModifyHdl_Impl, ListBox&, void); - DECL_LINK( DistanceHdl_Impl, SpinField&, void ); - DECL_LINK( DistanceFocusHdl_Impl, Control&, void ); - DECL_LINK( RelativeHdl_Impl, Button*, void ); - DECL_LINK( StandardHdl_Impl, Button*, void); + DECL_LINK(LevelHdl_Impl, weld::TreeView&, void); + DECL_LINK(EditModifyHdl_Impl, weld::ComboBoxText&, void); + DECL_LINK(DistanceHdl_Impl, weld::MetricSpinButton&, void); + DECL_LINK(DistanceFocusHdl_Impl, Control&, void); + DECL_LINK(RelativeHdl_Impl, weld::ToggleButton&, void); + DECL_LINK(StandardHdl_Impl, weld::Button&, void); void InitPosAndSpaceMode(); void ShowControlsDependingOnPosAndSpaceMode(); - DECL_LINK(LabelFollowedByHdl_Impl, ListBox&, void); - DECL_LINK( ListtabPosHdl_Impl, SpinField&, void ); - DECL_LINK( ListtabPosFocusHdl_Impl, Control&, void ); - DECL_LINK( AlignAtHdl_Impl, SpinField&, void ); - DECL_LINK( AlignAtFocusHdl_Impl, Control&, void ); - DECL_LINK( IndentAtHdl_Impl, SpinField&, void ); - DECL_LINK( IndentAtFocusHdl_Impl, Control&, void ); + DECL_LINK(LabelFollowedByHdl_Impl, weld::ComboBoxText&, void); + DECL_LINK(ListtabPosHdl_Impl, weld::MetricSpinButton&, void); + DECL_LINK(AlignAtHdl_Impl, weld::MetricSpinButton&, void); + DECL_LINK(IndentAtHdl_Impl, weld::MetricSpinButton&, void); public: - SvxNumPositionTabPage(vcl::Window* pParent, - const SfxItemSet& rSet); - virtual ~SvxNumPositionTabPage() override; + SvxNumPositionTabPage(TabPageParent pParent, const SfxItemSet& rSet); + virtual ~SvxNumPositionTabPage() override; virtual void dispose() override; virtual void ActivatePage(const SfxItemSet& rSet) override; diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx index a505c954c306..7ab6d400b8ab 100644 --- a/cui/source/tabpages/numpages.cxx +++ b/cui/source/tabpages/numpages.cxx @@ -2528,102 +2528,345 @@ void SvxNumberingPreview::Paint(vcl::RenderContext& rRenderContext, const ::tool rRenderContext.DrawOutDev(Point(), aSize, Point(), aSize, *pVDev); } +NumberingPreview::NumberingPreview() + : pActNum(nullptr) + , bPosition(false) + , nActLevel(SAL_MAX_UINT16) +{ +} + +// paint preview of numeration +void NumberingPreview::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& /*rRect*/) +{ + Size aSize(rRenderContext.PixelToLogic(GetOutputSizePixel())); + + const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); + const Color aBackColor = rStyleSettings.GetFieldColor(); + const Color aTextColor = rStyleSettings.GetFieldTextColor(); + + ScopedVclPtrInstance<VirtualDevice> pVDev(rRenderContext); + pVDev->EnableRTL(rRenderContext.IsRTLEnabled()); + pVDev->SetMapMode(rRenderContext.GetMapMode()); + pVDev->SetOutputSize(aSize); + + Color aLineColor(COL_LIGHTGRAY); + if (aLineColor == aBackColor) + aLineColor.Invert(); + pVDev->SetLineColor(aLineColor); + pVDev->SetFillColor(aBackColor); + + if (pActNum) + { + long nWidthRelation = 30; // chapter dialog + + // height per level + long nXStep = aSize.Width() / (3 * pActNum->GetLevelCount()); + if (pActNum->GetLevelCount() < 10) + nXStep /= 2; + long nYStart = 4; + // the whole height mustn't be used for a single level + long nYStep = (aSize.Height() - 6)/ (pActNum->GetLevelCount() > 1 ? pActNum->GetLevelCount() : 5); + + aStdFont = OutputDevice::GetDefaultFont(DefaultFontType::UI_SANS, MsLangId::getSystemLanguage(), GetDefaultFontFlags::OnlyOne); + aStdFont.SetColor(aTextColor); + aStdFont.SetFillColor(aBackColor); + + long nFontHeight = nYStep * 6 / 10; + if (bPosition) + nFontHeight = nYStep * 15 / 10; + aStdFont.SetFontSize(Size( 0, nFontHeight )); + + SvxNodeNum aNum; + sal_uInt16 nPreNum = pActNum->GetLevel(0).GetStart(); + + if (bPosition) + { + long nLineHeight = nFontHeight * 8 / 7; + sal_uInt8 nStart = 0; + while (!(nActLevel & (1<<nStart))) + { + nStart++; + } + if (nStart) + nStart--; + sal_uInt8 nEnd = std::min(sal_uInt8(nStart + 3), sal_uInt8(pActNum->GetLevelCount())); + for (sal_uInt8 nLevel = nStart; nLevel < nEnd; ++nLevel) + { + const SvxNumberFormat &rFmt = pActNum->GetLevel(nLevel); + aNum.GetLevelVal()[nLevel] = rFmt.GetStart(); + + long nXStart( 0 ); + short nTextOffset( 0 ); + long nNumberXPos( 0 ); + if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION) + { + nXStart = rFmt.GetAbsLSpace() / nWidthRelation; + nTextOffset = rFmt.GetCharTextDistance() / nWidthRelation; + nNumberXPos = nXStart; + long nFirstLineOffset = (-rFmt.GetFirstLineOffset()) / nWidthRelation; + + if (nFirstLineOffset <= nNumberXPos) + nNumberXPos = nNumberXPos - nFirstLineOffset; + else + nNumberXPos = 0; + // in draw this is valid + if (nTextOffset < 0) + nNumberXPos = nNumberXPos + nTextOffset; + } + else if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT) + { + const long nTmpNumberXPos((rFmt.GetIndentAt() + rFmt.GetFirstLineIndent() ) / nWidthRelation); + if (nTmpNumberXPos < 0) + { + nNumberXPos = 0; + } + else + { + nNumberXPos = nTmpNumberXPos; + } + } + + long nBulletWidth = 0; + if (SVX_NUM_BITMAP == (rFmt.GetNumberingType() &(~LINK_TOKEN))) + { + long nYMiddle = nYStart + ( nFontHeight / 2 ); + nBulletWidth = rFmt.IsShowSymbol() ? lcl_DrawGraphic(pVDev.get(), rFmt, nNumberXPos, nYMiddle, nWidthRelation) : 0; + } + else if (SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType()) + { + nBulletWidth = rFmt.IsShowSymbol() ? lcl_DrawBullet(pVDev.get(), rFmt, nNumberXPos, nYStart, aStdFont.GetFontSize()) : 0; + } + else + { + pVDev->SetFont(aStdFont); + aNum.SetLevel(nLevel); + if (pActNum->IsContinuousNumbering()) + aNum.GetLevelVal()[nLevel] = nPreNum; + OUString aText(pActNum->MakeNumString( aNum )); + vcl::Font aSaveFont = pVDev->GetFont(); + vcl::Font aColorFont(aSaveFont); + Color aTmpBulletColor = rFmt.GetBulletColor(); + if (aTmpBulletColor == COL_AUTO) + aTmpBulletColor = aBackColor.IsDark() ? COL_WHITE : COL_BLACK; + else if (aTmpBulletColor == aBackColor) + aTmpBulletColor.Invert(); + aColorFont.SetColor(aTmpBulletColor); + pVDev->SetFont(aColorFont); + pVDev->DrawText(Point(nNumberXPos, nYStart), aText); + pVDev->SetFont(aSaveFont); + nBulletWidth = pVDev->GetTextWidth(aText); + nPreNum++; + } + if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT && + rFmt.GetLabelFollowedBy() == SvxNumberFormat::SPACE ) + { + pVDev->SetFont(aStdFont); + OUString aText(' '); + pVDev->DrawText( Point(nNumberXPos, nYStart), aText ); + nBulletWidth = nBulletWidth + pVDev->GetTextWidth(aText); + } + + long nTextXPos( 0 ); + if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION) + { + nTextXPos = nXStart; + if (nTextOffset < 0) + nTextXPos = nTextXPos + nTextOffset; + if (nNumberXPos + nBulletWidth + nTextOffset > nTextXPos) + nTextXPos = nNumberXPos + nBulletWidth + nTextOffset; + } + else if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT) + { + switch (rFmt.GetLabelFollowedBy()) + { + case SvxNumberFormat::LISTTAB: + { + nTextXPos = rFmt.GetListtabPos() / nWidthRelation; + if (nTextXPos < nNumberXPos + nBulletWidth) + { + nTextXPos = nNumberXPos + nBulletWidth; + } + } + break; + case SvxNumberFormat::SPACE: + case SvxNumberFormat::NOTHING: + case SvxNumberFormat::NEWLINE: + { + nTextXPos = nNumberXPos + nBulletWidth; + } + break; + } + + nXStart = rFmt.GetIndentAt() / nWidthRelation; + } + + ::tools::Rectangle aRect1(Point(nTextXPos, nYStart + nFontHeight / 2), Size(aSize.Width() / 2, 2)); + pVDev->SetFillColor(aBackColor); + pVDev->DrawRect(aRect1); + + ::tools::Rectangle aRect2(Point(nXStart, nYStart + nLineHeight + nFontHeight / 2 ), Size(aSize.Width() / 2, 2)); + pVDev->DrawRect(aRect2); + nYStart += 2 * nLineHeight; + } + } + else + { + //#i5153# painting gray or black rectangles as 'normal' numbering text + long nWidth = pVDev->GetTextWidth("Preview"); + long nTextHeight = pVDev->GetTextHeight(); + long nRectHeight = nTextHeight * 2 / 3; + long nTopOffset = nTextHeight - nRectHeight; + Color aBlackColor(COL_BLACK); + if (aBlackColor == aBackColor) + aBlackColor.Invert(); + + for (sal_uInt16 nLevel = 0; nLevel < pActNum->GetLevelCount(); ++nLevel, nYStart = nYStart + nYStep) + { + const SvxNumberFormat &rFmt = pActNum->GetLevel(nLevel); + aNum.GetLevelVal()[ nLevel ] = rFmt.GetStart(); + long nXStart( 0 ); + pVDev->SetFillColor( aBackColor ); + + if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION) + { + nXStart = rFmt.GetAbsLSpace() / nWidthRelation; + } + else if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT) + { + const long nTmpXStart((rFmt.GetIndentAt() + rFmt.GetFirstLineIndent() ) / nWidthRelation); + if (nTmpXStart < 0) + { + nXStart = 0; + } + else + { + nXStart = nTmpXStart; + } + } + nXStart /= 2; + nXStart += 2; + long nTextOffset = 2 * nXStep; + if (SVX_NUM_BITMAP == (rFmt.GetNumberingType()&(~LINK_TOKEN))) + { + if (rFmt.IsShowSymbol()) + { + long nYMiddle = nYStart + ( nFontHeight / 2 ); + nTextOffset = lcl_DrawGraphic(pVDev.get(), rFmt, nXStart, nYMiddle, nWidthRelation); + nTextOffset = nTextOffset + nXStep; + } + } + else if (SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType()) + { + if (rFmt.IsShowSymbol()) + { + nTextOffset = lcl_DrawBullet(pVDev.get(), rFmt, nXStart, nYStart, aStdFont.GetFontSize()); + nTextOffset = nTextOffset + nXStep; + } + } + else + { + vcl::Font aColorFont(aStdFont); + Color aTmpBulletColor = rFmt.GetBulletColor(); + if (aTmpBulletColor == COL_AUTO) + aTmpBulletColor = aBackColor.IsDark() ? COL_WHITE : COL_BLACK; + else if (aTmpBulletColor == aBackColor) + aTmpBulletColor.Invert(); + aColorFont.SetColor(aTmpBulletColor); + pVDev->SetFont(aColorFont); + aNum.SetLevel( nLevel ); + if (pActNum->IsContinuousNumbering()) + aNum.GetLevelVal()[nLevel] = nPreNum; + OUString aText(pActNum->MakeNumString(aNum)); + pVDev->DrawText(Point(nXStart, nYStart), aText); + pVDev->SetFont(aStdFont); + nTextOffset = pVDev->GetTextWidth(aText); + nTextOffset = nTextOffset + nXStep; + nPreNum++; + } + //#i5153# the selected rectangle(s) should be black + if (0 != (nActLevel & (1<<nLevel))) + { + pVDev->SetFillColor( aBlackColor ); + pVDev->SetLineColor( aBlackColor ); + } + else + { + //#i5153# unselected levels are gray + pVDev->SetFillColor( aLineColor ); + pVDev->SetLineColor( aLineColor ); + } + ::tools::Rectangle aRect1(Point(nXStart + nTextOffset, nYStart + nTopOffset), Size(nWidth, nRectHeight)); + pVDev->DrawRect(aRect1); + } + } + } + rRenderContext.DrawOutDev(Point(), aSize, Point(), aSize, *pVDev); +} + + //See uiconfig/swriter/ui/outlinepositionpage.ui for effectively a duplicate //dialog to this one, except with a different preview window impl. //TODO, determine if SwNumPositionTabPage and SvxNumPositionTabPage can be //merged -SvxNumPositionTabPage::SvxNumPositionTabPage(vcl::Window* pParent, - const SfxItemSet& rSet) - : SfxTabPage(pParent, "NumberingPositionPage", "cui/ui/numberingpositionpage.ui", &rSet) +SvxNumPositionTabPage::SvxNumPositionTabPage(TabPageParent pParent, const SfxItemSet& rSet) + : SfxTabPage(pParent, "cui/ui/numberingpositionpage.ui", "NumberingPositionPage", &rSet) , nActNumLvl(1) , nNumItemId(SID_ATTR_NUMBERING_RULE) , bModified(false) , bPreset(false) , bInInintControl(false) , bLabelAlignmentPosAndSpaceModeActive(false) + , m_xLevelLB(m_xBuilder->weld_tree_view("levellb")) + , m_xDistBorderFT(m_xBuilder->weld_label("indent")) + , m_xDistBorderMF(m_xBuilder->weld_metric_spin_button("indentmf", FUNIT_CM)) + , m_xRelativeCB(m_xBuilder->weld_check_button("relative")) + , m_xIndentFT(m_xBuilder->weld_label("numberingwidth")) + , m_xIndentMF(m_xBuilder->weld_metric_spin_button("numberingwidthmf", FUNIT_CM)) + , m_xDistNumFT(m_xBuilder->weld_label("numdist")) + , m_xDistNumMF(m_xBuilder->weld_metric_spin_button("numdistmf", FUNIT_CM)) + , m_xAlignFT(m_xBuilder->weld_label("numalign")) + , m_xAlignLB(m_xBuilder->weld_combo_box_text("numalignlb")) + , m_xLabelFollowedByFT(m_xBuilder->weld_label("numfollowedby")) + , m_xLabelFollowedByLB(m_xBuilder->weld_combo_box_text("numfollowedbylb")) + , m_xListtabFT(m_xBuilder->weld_label("at")) + , m_xListtabMF(m_xBuilder->weld_metric_spin_button("atmf", FUNIT_CM)) + , m_xAlign2FT(m_xBuilder->weld_label("num2align")) + , m_xAlign2LB(m_xBuilder->weld_combo_box_text("num2alignlb")) + , m_xAlignedAtFT(m_xBuilder->weld_label("alignedat")) + , m_xAlignedAtMF(m_xBuilder->weld_metric_spin_button("alignedatmf", FUNIT_CM)) + , m_xIndentAtFT(m_xBuilder->weld_label("indentat")) + , m_xIndentAtMF(m_xBuilder->weld_metric_spin_button("indentatmf", FUNIT_CM)) + , m_xStandardPB(m_xBuilder->weld_button("standard")) + , m_xPreviewWIN(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWIN)) { SetExchangeSupport(); - get(m_pLevelLB, "levellb"); - get(m_pDistBorderFT, "indent"); - get(m_pDistBorderMF, "indentmf"); - get(m_pRelativeCB, "relative"); - get(m_pIndentFT, "numberingwidth"); - get(m_pIndentMF, "numberingwidthmf"); - get(m_pDistNumFT, "numdist"); - get(m_pDistNumMF, "numdistmf"); - get(m_pAlignFT, "numalign"); - get(m_pAlignLB, "numalignlb"); - - get(m_pLabelFollowedByFT, "numfollowedby"); - get(m_pLabelFollowedByLB, "numfollowedbylb"); - get(m_pListtabFT, "at"); - get(m_pListtabMF, "atmf"); - get(m_pAlign2FT, "num2align"); - get(m_pAlign2LB, "num2alignlb"); - get(m_pAlignedAtFT, "alignedat"); - get(m_pAlignedAtMF, "alignedatmf"); - get(m_pIndentAtFT, "indentat"); - get(m_pIndentAtMF, "indentatmf"); - - get(m_pStandardPB, "standard"); - get(m_pPreviewWIN, "preview"); - - m_pPreviewWIN->SetBackground(Wallpaper(COL_TRANSPARENT)); - - m_pRelativeCB->Check(); - m_pAlignLB->SetSelectHdl(LINK(this, SvxNumPositionTabPage, EditModifyHdl_Impl)); - m_pAlign2LB->SetSelectHdl(LINK(this, SvxNumPositionTabPage, EditModifyHdl_Impl)); - for ( sal_Int32 i = 0; i < m_pAlignLB->GetEntryCount(); ++i ) + m_xRelativeCB->set_active(true); + m_xAlignLB->connect_changed(LINK(this, SvxNumPositionTabPage, EditModifyHdl_Impl)); + m_xAlign2LB->connect_changed(LINK(this, SvxNumPositionTabPage, EditModifyHdl_Impl)); + for ( sal_Int32 i = 0; i < m_xAlignLB->get_count(); ++i ) { - m_pAlign2LB->InsertEntry( m_pAlignLB->GetEntry( i ) ); + m_xAlign2LB->append_text(m_xAlignLB->get_text(i)); } - m_pAlign2LB->SetDropDownLineCount( m_pAlign2LB->GetEntryCount() ); - Link<SpinField&,void> aLk3 = LINK(this, SvxNumPositionTabPage, DistanceHdl_Impl); - Link<Control&,void> aLk2 = LINK(this, SvxNumPositionTabPage, DistanceFocusHdl_Impl); + Link<weld::MetricSpinButton&,void> aLk3 = LINK(this, SvxNumPositionTabPage, DistanceHdl_Impl); + m_xDistBorderMF->connect_value_changed(aLk3); + m_xDistNumMF->connect_value_changed(aLk3); + m_xIndentMF->connect_value_changed(aLk3); - m_pDistBorderMF->SetUpHdl(aLk3); - m_pDistBorderMF->SetDownHdl(aLk3); - m_pDistBorderMF->SetLoseFocusHdl(aLk2); + m_xLabelFollowedByLB->connect_changed(LINK(this, SvxNumPositionTabPage, LabelFollowedByHdl_Impl)); - m_pDistNumMF->SetUpHdl(aLk3); - m_pDistNumMF->SetDownHdl(aLk3); - m_pDistNumMF->SetLoseFocusHdl(aLk2); + m_xListtabMF->connect_value_changed(LINK(this, SvxNumPositionTabPage, ListtabPosHdl_Impl)); + m_xAlignedAtMF->connect_value_changed(LINK(this, SvxNumPositionTabPage, AlignAtHdl_Impl)); + m_xIndentAtMF->connect_value_changed(LINK(this, SvxNumPositionTabPage, IndentAtHdl_Impl)); - m_pIndentMF->SetUpHdl(aLk3); - m_pIndentMF->SetDownHdl(aLk3); - m_pIndentMF->SetLoseFocusHdl(aLk2); + m_xLevelLB->set_selection_mode(true); + m_xLevelLB->connect_changed(LINK(this, SvxNumPositionTabPage, LevelHdl_Impl)); + m_xRelativeCB->connect_toggled(LINK(this, SvxNumPositionTabPage, RelativeHdl_Impl)); + m_xStandardPB->connect_clicked(LINK(this, SvxNumPositionTabPage, StandardHdl_Impl)); - m_pLabelFollowedByLB->SetDropDownLineCount( m_pLabelFollowedByLB->GetEntryCount() ); - m_pLabelFollowedByLB->SetSelectHdl( LINK(this, SvxNumPositionTabPage, LabelFollowedByHdl_Impl) ); - - aLk3 = LINK(this, SvxNumPositionTabPage, ListtabPosHdl_Impl); - aLk2 = LINK(this, SvxNumPositionTabPage, ListtabPosFocusHdl_Impl); - m_pListtabMF->SetUpHdl(aLk3); - m_pListtabMF->SetDownHdl(aLk3); - m_pListtabMF->SetLoseFocusHdl(aLk2); - - aLk3 = LINK(this, SvxNumPositionTabPage, AlignAtHdl_Impl); - aLk2 = LINK(this, SvxNumPositionTabPage, AlignAtFocusHdl_Impl); - m_pAlignedAtMF->SetUpHdl(aLk3); - m_pAlignedAtMF->SetDownHdl(aLk3); - m_pAlignedAtMF->SetLoseFocusHdl(aLk2); - - aLk3 = LINK(this, SvxNumPositionTabPage, IndentAtHdl_Impl); - aLk2 = LINK(this, SvxNumPositionTabPage, IndentAtFocusHdl_Impl); - m_pIndentAtMF->SetUpHdl(aLk3); - m_pIndentAtMF->SetDownHdl(aLk3); - m_pIndentAtMF->SetLoseFocusHdl(aLk2); - - m_pLevelLB->EnableMultiSelection(true); - m_pLevelLB->SetSelectHdl(LINK(this, SvxNumPositionTabPage, LevelHdl_Impl)); - m_pRelativeCB->SetClickHdl(LINK(this, SvxNumPositionTabPage, RelativeHdl_Impl)); - m_pStandardPB->SetClickHdl(LINK(this, SvxNumPositionTabPage, StandardHdl_Impl)); - - - m_pRelativeCB->Check(bLastRelative); - m_pPreviewWIN->SetPositionMode(); + m_xRelativeCB->set_active(bLastRelative); + m_aPreviewWIN.SetPositionMode(); eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE)); } @@ -2634,68 +2877,23 @@ SvxNumPositionTabPage::~SvxNumPositionTabPage() void SvxNumPositionTabPage::dispose() { - pActNum.reset(); - pSaveNum.reset(); - m_pLevelLB.clear(); - m_pDistBorderFT.clear(); - m_pDistBorderMF.clear(); - m_pRelativeCB.clear(); - m_pIndentFT.clear(); - m_pIndentMF.clear(); - m_pDistNumFT.clear(); - m_pDistNumMF.clear(); - m_pAlignFT.clear(); - m_pAlignLB.clear(); - m_pLabelFollowedByFT.clear(); - m_pLabelFollowedByLB.clear(); - m_pListtabFT.clear(); - m_pListtabMF.clear(); - m_pAlign2FT.clear(); - m_pAlign2LB.clear(); - m_pAlignedAtFT.clear(); - m_pAlignedAtMF.clear(); - m_pIndentAtFT.clear(); - m_pIndentAtMF.clear(); - m_pStandardPB.clear(); - m_pPreviewWIN.clear(); + m_xPreviewWIN.reset(); SfxTabPage::dispose(); } /*-------------------------------------------------------*/ -#if OSL_DEBUG_LEVEL > 1 -void lcl_PrintDebugOutput(FixedText& rFixed, const SvxNumberFormat& rNumFmt) -{ - OUString const sHash( " # " ); - if ( rNumFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) - { - OUString sDebugText = OUString::number( convertTwipToMm100(rNumFmt.GetAbsLSpace() ) ) + sHash - + OUString::number( convertTwipToMm100(rNumFmt.GetCharTextDistance() )) + sHash - + OUString::number( convertTwipToMm100(rNumFmt.GetFirstLineOffset() ) ); - rFixed.SetText(sDebugText); - } - else if ( rNumFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) - { - OUString sDebugText = OUString::number( convertTwipToMm100(rNumFmt.GetListtabPos() ) ) + sHash - + OUString::number( convertTwipToMm100(rNumFmt.GetFirstLineIndent() ) ) + sHash - + OUString::number( convertTwipToMm100(rNumFmt.GetIndentAt() ) ); - rFixed.SetText(sDebugText); - } - -} -#endif - void SvxNumPositionTabPage::InitControls() { bInInintControl = true; const bool bRelative = !bLabelAlignmentPosAndSpaceModeActive && - m_pRelativeCB->IsEnabled() && m_pRelativeCB->IsChecked(); - const bool bSingleSelection = m_pLevelLB->GetSelectedEntryCount() == 1 && + m_xRelativeCB->get_sensitive() && m_xRelativeCB->get_active(); + const bool bSingleSelection = m_xLevelLB->count_selected_rows() == 1 && SAL_MAX_UINT16 != nActNumLvl; - m_pDistBorderMF->Enable( !bLabelAlignmentPosAndSpaceModeActive && + m_xDistBorderMF->set_sensitive( !bLabelAlignmentPosAndSpaceModeActive && ( bSingleSelection || bRelative ) ); - m_pDistBorderFT->Enable( !bLabelAlignmentPosAndSpaceModeActive && + m_xDistBorderFT->set_sensitive( !bLabelAlignmentPosAndSpaceModeActive && ( bSingleSelection || bRelative ) ); bool bSetDistEmpty = false; @@ -2781,19 +2979,19 @@ void SvxNumPositionTabPage::InitControls() { nDistBorderNum = static_cast<long>(aNumFmtArr[nLvl]->GetAbsLSpace())+ aNumFmtArr[nLvl]->GetFirstLineOffset(); } - SetMetricValue(*m_pDistBorderMF, nDistBorderNum, eCoreUnit); + SetMetricValue(*m_xDistBorderMF, nDistBorderNum, eCoreUnit); } else bSetDistEmpty = true; if(bSameDist) - SetMetricValue(*m_pDistNumMF, aNumFmtArr[nLvl]->GetCharTextDistance(), eCoreUnit); + SetMetricValue(*m_xDistNumMF, aNumFmtArr[nLvl]->GetCharTextDistance(), eCoreUnit); else - m_pDistNumMF->SetText(""); + m_xDistNumMF->set_text(""); if(bSameIndent) - SetMetricValue(*m_pIndentMF, - aNumFmtArr[nLvl]->GetFirstLineOffset(), eCoreUnit); + SetMetricValue(*m_xIndentMF, - aNumFmtArr[nLvl]->GetFirstLineOffset(), eCoreUnit); else - m_pIndentMF->SetText(""); + m_xIndentMF->set_text(""); if(bSameAdjust) { @@ -2802,13 +3000,13 @@ void SvxNumPositionTabPage::InitControls() nPos = 0; else if(aNumFmtArr[nLvl]->GetNumAdjust() == SvxAdjust::Right) nPos = 2; - m_pAlignLB->SelectEntryPos(nPos); - m_pAlign2LB->SelectEntryPos( nPos ); + m_xAlignLB->set_active(nPos); + m_xAlign2LB->set_active(nPos); } else { - m_pAlignLB->SetNoSelection(); - m_pAlign2LB->SetNoSelection(); + m_xAlignLB->set_active(-1); + m_xAlign2LB->set_active(-1); } if ( bSameLabelFollowedBy ) @@ -2826,55 +3024,55 @@ void SvxNumPositionTabPage::InitControls() { nPos = 3; } - m_pLabelFollowedByLB->SelectEntryPos( nPos ); + m_xLabelFollowedByLB->set_active(nPos); } else { - m_pLabelFollowedByLB->SetNoSelection(); + m_xLabelFollowedByLB->set_active(-1); } if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == SvxNumberFormat::LISTTAB ) { - m_pListtabFT->Enable(); - m_pListtabMF->Enable(); + m_xListtabFT->set_sensitive(true); + m_xListtabMF->set_sensitive(true); if ( bSameListtab ) { - SetMetricValue(*m_pListtabMF, aNumFmtArr[nLvl]->GetListtabPos(), eCoreUnit); + SetMetricValue(*m_xListtabMF, aNumFmtArr[nLvl]->GetListtabPos(), eCoreUnit); } else { - m_pListtabMF->SetText(""); + m_xListtabMF->set_text(""); } } else { - m_pListtabFT->Enable( false ); - m_pListtabMF->Enable( false ); - m_pListtabMF->SetText(""); + m_xListtabFT->set_sensitive(false); + m_xListtabMF->set_sensitive(false); + m_xListtabMF->set_text(""); } if ( bSameAlignAt ) { - SetMetricValue(*m_pAlignedAtMF, + SetMetricValue(*m_xAlignedAtMF, aNumFmtArr[nLvl]->GetIndentAt() + aNumFmtArr[nLvl]->GetFirstLineIndent(), eCoreUnit); } else { - m_pAlignedAtMF->SetText(""); + m_xAlignedAtMF->set_text(""); } if ( bSameIndentAt ) { - SetMetricValue(*m_pIndentAtMF, aNumFmtArr[nLvl]->GetIndentAt(), eCoreUnit); + SetMetricValue(*m_xIndentAtMF, aNumFmtArr[nLvl]->GetIndentAt(), eCoreUnit); } else { - m_pIndentAtMF->SetText(""); + m_xIndentAtMF->set_text(""); } if ( bSetDistEmpty ) - m_pDistBorderMF->SetText(""); + m_xDistBorderMF->set_text(""); bInInintControl = false; } @@ -2902,35 +3100,34 @@ void SvxNumPositionTabPage::ActivatePage(const SfxItemSet& rSet) *pActNum = *pSaveNum; nActNumLvl = nTmpNumLvl; sal_uInt16 nMask = 1; - m_pLevelLB->SetUpdateMode(false); - m_pLevelLB->SetNoSelection(); - m_pLevelLB->SelectEntryPos( pActNum->GetLevelCount(), nActNumLvl == SAL_MAX_UINT16); - if(nActNumLvl != SAL_MAX_UINT16) - for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) + m_xLevelLB->unselect_all(); + if (nActNumLvl == SAL_MAX_UINT16) + m_xLevelLB->select(pActNum->GetLevelCount()); + if (nActNumLvl != SAL_MAX_UINT16) + for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) { - if(nActNumLvl & nMask) - m_pLevelLB->SelectEntryPos( i ); + if (nActNumLvl & nMask) + m_xLevelLB->select(i); nMask <<= 1 ; } - m_pRelativeCB->Enable(nActNumLvl != 1); - m_pLevelLB->SetUpdateMode(true); + m_xRelativeCB->set_sensitive(nActNumLvl != 1); InitPosAndSpaceMode(); ShowControlsDependingOnPosAndSpaceMode(); InitControls(); } - m_pPreviewWIN->SetLevel(nActNumLvl); - m_pPreviewWIN->Invalidate(); + m_aPreviewWIN.SetLevel(nActNumLvl); + m_aPreviewWIN.Invalidate(); } DeactivateRC SvxNumPositionTabPage::DeactivatePage(SfxItemSet *_pSet) { if(_pSet) { - if(m_pDistBorderMF->IsEnabled()) - DistanceHdl_Impl(*m_pDistBorderMF); - DistanceHdl_Impl(*m_pIndentMF); + if (m_xDistBorderMF->get_sensitive()) + DistanceHdl_Impl(*m_xDistBorderMF); + DistanceHdl_Impl(*m_xIndentMF); FillItemSet(_pSet); } return DeactivateRC::LeavePage; @@ -2970,44 +3167,42 @@ void SvxNumPositionTabPage::Reset( const SfxItemSet* rSet ) pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); // insert levels - if(!m_pLevelLB->GetEntryCount()) + if (!m_xLevelLB->count_selected_rows()) { for(sal_uInt16 i = 1; i <= pSaveNum->GetLevelCount(); i++) - m_pLevelLB->InsertEntry( OUString::number(i) ); + m_xLevelLB->append_text(OUString::number(i)); if(pSaveNum->GetLevelCount() > 1) { OUString sEntry = "1 - " + OUString::number( pSaveNum->GetLevelCount() ); - m_pLevelLB->InsertEntry(sEntry); - m_pLevelLB->SelectEntry(sEntry); + m_xLevelLB->append_text(sEntry); + m_xLevelLB->select_text(sEntry); } else - m_pLevelLB->SelectEntryPos(0); + m_xLevelLB->select(0); } else - m_pLevelLB->SelectEntryPos(m_pLevelLB->GetEntryCount() - 1); + m_xLevelLB->select(m_xLevelLB->count_selected_rows() - 1); sal_uInt16 nMask = 1; - m_pLevelLB->SetUpdateMode(false); - m_pLevelLB->SetNoSelection(); + m_xLevelLB->unselect_all(); if (nActNumLvl == SAL_MAX_UINT16) { - m_pLevelLB->SelectEntryPos( pSaveNum->GetLevelCount() ); + m_xLevelLB->select(pSaveNum->GetLevelCount()); } else { for(sal_uInt16 i = 0; i < pSaveNum->GetLevelCount(); i++) { if(nActNumLvl & nMask) - m_pLevelLB->SelectEntryPos( i ); + m_xLevelLB->select(i); nMask <<= 1; } } - m_pLevelLB->SetUpdateMode(true); if(!pActNum) pActNum.reset( new SvxNumRule(*pSaveNum) ); else if(*pSaveNum != *pActNum) *pActNum = *pSaveNum; - m_pPreviewWIN->SetNumRule(pActNum.get()); + m_aPreviewWIN.SetNumRule(pActNum.get()); InitPosAndSpaceMode(); ShowControlsDependingOnPosAndSpaceMode(); @@ -3048,56 +3243,56 @@ void SvxNumPositionTabPage::InitPosAndSpaceMode() void SvxNumPositionTabPage::ShowControlsDependingOnPosAndSpaceMode() { - m_pDistBorderFT->Show( !bLabelAlignmentPosAndSpaceModeActive ); - m_pDistBorderMF->Show( !bLabelAlignmentPosAndSpaceModeActive ); - m_pRelativeCB->Show( !bLabelAlignmentPosAndSpaceModeActive ); - m_pIndentFT->Show( !bLabelAlignmentPosAndSpaceModeActive ); - m_pIndentMF->Show( !bLabelAlignmentPosAndSpaceModeActive ); - m_pDistNumFT->Show( !bLabelAlignmentPosAndSpaceModeActive && - pActNum->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS) ); - m_pDistNumMF->Show( !bLabelAlignmentPosAndSpaceModeActive && - pActNum->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS)); - m_pAlignFT->Show( !bLabelAlignmentPosAndSpaceModeActive ); - m_pAlignLB->Show( !bLabelAlignmentPosAndSpaceModeActive ); - - m_pLabelFollowedByFT->Show( bLabelAlignmentPosAndSpaceModeActive ); - m_pLabelFollowedByLB->Show( bLabelAlignmentPosAndSpaceModeActive ); - m_pListtabFT->Show( bLabelAlignmentPosAndSpaceModeActive ); - m_pListtabMF->Show( bLabelAlignmentPosAndSpaceModeActive ); - m_pAlign2FT->Show( bLabelAlignmentPosAndSpaceModeActive ); - m_pAlign2LB->Show( bLabelAlignmentPosAndSpaceModeActive ); - m_pAlignedAtFT->Show( bLabelAlignmentPosAndSpaceModeActive ); - m_pAlignedAtMF->Show( bLabelAlignmentPosAndSpaceModeActive ); - m_pIndentAtFT->Show( bLabelAlignmentPosAndSpaceModeActive ); - m_pIndentAtMF->Show( bLabelAlignmentPosAndSpaceModeActive ); -} - -VclPtr<SfxTabPage> SvxNumPositionTabPage::Create( TabPageParent pParent, - const SfxItemSet* rAttrSet) + m_xDistBorderFT->show( !bLabelAlignmentPosAndSpaceModeActive ); + m_xDistBorderMF->show( !bLabelAlignmentPosAndSpaceModeActive ); + m_xRelativeCB->show( !bLabelAlignmentPosAndSpaceModeActive ); + m_xIndentFT->show( !bLabelAlignmentPosAndSpaceModeActive ); + m_xIndentMF->show( !bLabelAlignmentPosAndSpaceModeActive ); + m_xDistNumFT->show( !bLabelAlignmentPosAndSpaceModeActive && + pActNum->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS) ); + m_xDistNumMF->show( !bLabelAlignmentPosAndSpaceModeActive && + pActNum->IsFeatureSupported(SvxNumRuleFlags::CONTINUOUS)); + m_xAlignFT->show( !bLabelAlignmentPosAndSpaceModeActive ); + m_xAlignLB->show( !bLabelAlignmentPosAndSpaceModeActive ); + + m_xLabelFollowedByFT->show( bLabelAlignmentPosAndSpaceModeActive ); + m_xLabelFollowedByLB->show( bLabelAlignmentPosAndSpaceModeActive ); + m_xListtabFT->show( bLabelAlignmentPosAndSpaceModeActive ); + m_xListtabMF->show( bLabelAlignmentPosAndSpaceModeActive ); + m_xAlign2FT->show( bLabelAlignmentPosAndSpaceModeActive ); + m_xAlign2LB->show( bLabelAlignmentPosAndSpaceModeActive ); + m_xAlignedAtFT->show( bLabelAlignmentPosAndSpaceModeActive ); + m_xAlignedAtMF->show( bLabelAlignmentPosAndSpaceModeActive ); + m_xIndentAtFT->show( bLabelAlignmentPosAndSpaceModeActive ); + m_xIndentAtMF->show( bLabelAlignmentPosAndSpaceModeActive ); +} + +VclPtr<SfxTabPage> SvxNumPositionTabPage::Create(TabPageParent pParent, + const SfxItemSet* rAttrSet) { - return VclPtr<SvxNumPositionTabPage>::Create(pParent.pParent, *rAttrSet); + return VclPtr<SvxNumPositionTabPage>::Create(pParent, *rAttrSet); } -void SvxNumPositionTabPage::SetMetric(FieldUnit eMetric) +void SvxNumPositionTabPage::SetMetric(FieldUnit eMetric) { - if(eMetric == FUNIT_MM) + if (eMetric == FUNIT_MM) { - m_pDistBorderMF->SetDecimalDigits(1); - m_pDistNumMF->SetDecimalDigits(1); - m_pIndentMF->SetDecimalDigits(1); - m_pListtabMF->SetDecimalDigits(1); - m_pAlignedAtMF->SetDecimalDigits(1); - m_pIndentAtMF->SetDecimalDigits(1); + m_xDistBorderMF->set_digits(1); + m_xDistNumMF->set_digits(1); + m_xIndentMF->set_digits(1); + m_xListtabMF->set_digits(1); + m_xAlignedAtMF->set_digits(1); + m_xIndentAtMF->set_digits(1); } - m_pDistBorderMF->SetUnit( eMetric ); - m_pDistNumMF->SetUnit( eMetric ); - m_pIndentMF->SetUnit( eMetric ); - m_pListtabMF->SetUnit( eMetric ); - m_pAlignedAtMF->SetUnit( eMetric ); - m_pIndentAtMF->SetUnit( eMetric ); + m_xDistBorderMF->set_unit(eMetric); + m_xDistNumMF->set_unit(eMetric); + m_xIndentMF->set_unit(eMetric); + m_xListtabMF->set_unit(eMetric); + m_xAlignedAtMF->set_unit(eMetric); + m_xIndentAtMF->set_unit(eMetric); } -IMPL_LINK_NOARG(SvxNumPositionTabPage, EditModifyHdl_Impl, ListBox&, void) +IMPL_LINK_NOARG(SvxNumPositionTabPage, EditModifyHdl_Impl, weld::ComboBoxText&, void) { sal_uInt16 nMask = 1; for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) @@ -3106,9 +3301,9 @@ IMPL_LINK_NOARG(SvxNumPositionTabPage, EditModifyHdl_Impl, ListBox&, void) { SvxNumberFormat aNumFmt(pActNum->GetLevel(i)); - const sal_Int32 nPos = m_pAlignLB->IsVisible() - ? m_pAlignLB->GetSelectedEntryPos() - : m_pAlign2LB->GetSelectedEntryPos(); + const sal_Int32 nPos = m_xAlignLB->get_visible() + ? m_xAlignLB->get_active() + : m_xAlign2LB->get_active(); SvxAdjust eAdjust = SvxAdjust::Center; if(nPos == 0) eAdjust = SvxAdjust::Left; @@ -3122,29 +3317,28 @@ IMPL_LINK_NOARG(SvxNumPositionTabPage, EditModifyHdl_Impl, ListBox&, void) SetModified(); } -IMPL_LINK( SvxNumPositionTabPage, LevelHdl_Impl, ListBox&, rBox, void ) +IMPL_LINK(SvxNumPositionTabPage, LevelHdl_Impl, weld::TreeView&, rBox, void) { sal_uInt16 nSaveNumLvl = nActNumLvl; nActNumLvl = 0; - if(rBox.IsEntryPosSelected( pActNum->GetLevelCount() ) && - (rBox.GetSelectedEntryCount() == 1 || nSaveNumLvl != 0xffff)) + std::vector<int> aSelectedRows = rBox.get_selected_rows(); + if (std::find(aSelectedRows.begin(), aSelectedRows.end(), pActNum->GetLevelCount()) != aSelectedRows.end() && + (aSelectedRows.size() == 1 || nSaveNumLvl != 0xffff)) { nActNumLvl = 0xFFFF; - rBox.SetUpdateMode(false); for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ ) - rBox.SelectEntryPos( i, false ); - rBox.SetUpdateMode(true); + rBox.unselect(i); } - else if(rBox.GetSelectedEntryCount()) + else if (!aSelectedRows.empty()) { sal_uInt16 nMask = 1; for( sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++ ) { - if(rBox.IsEntryPosSelected( i )) + if (std::find(aSelectedRows.begin(), aSelectedRows.end(), i) != aSelectedRows.end()) nActNumLvl |= nMask; nMask <<= 1; } - rBox.SelectEntryPos( pActNum->GetLevelCount(), false ); + rBox.unselect(pActNum->GetLevelCount()); } else { @@ -3154,38 +3348,34 @@ IMPL_LINK( SvxNumPositionTabPage, LevelHdl_Impl, ListBox&, rBox, void ) { if(nActNumLvl & nMask) { - rBox.SelectEntryPos(i); + rBox.select(i); break; } nMask <<=1; } } - m_pRelativeCB->Enable(nActNumLvl != 1); + m_xRelativeCB->set_sensitive(nActNumLvl != 1); SetModified(); InitPosAndSpaceMode(); ShowControlsDependingOnPosAndSpaceMode(); InitControls(); } -IMPL_LINK( SvxNumPositionTabPage, DistanceFocusHdl_Impl, Control&, rControl, void ) -{ - DistanceHdl_Impl(static_cast<SpinField&>(rControl)); -} -IMPL_LINK( SvxNumPositionTabPage, DistanceHdl_Impl, SpinField&, rFld, void ) +IMPL_LINK(SvxNumPositionTabPage, DistanceHdl_Impl, weld::MetricSpinButton&, rFld, void) { if(bInInintControl) return; - long nValue = GetCoreValue(static_cast<MetricField&>(rFld), eCoreUnit); + long nValue = GetCoreValue(rFld, eCoreUnit); sal_uInt16 nMask = 1; for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) { if(nActNumLvl & nMask) { SvxNumberFormat aNumFmt( pActNum->GetLevel( i ) ); - if (&rFld == m_pDistBorderMF) + if (&rFld == m_xDistBorderMF.get()) { - if(m_pRelativeCB->IsChecked()) + if (m_xRelativeCB->get_active()) { if(0 == i) { @@ -3206,11 +3396,11 @@ IMPL_LINK( SvxNumPositionTabPage, DistanceHdl_Impl, SpinField&, rFld, void ) aNumFmt.SetAbsLSpace( nValue - aNumFmt.GetFirstLineOffset()); } } - else if (&rFld == m_pDistNumMF) + else if (&rFld == m_xDistNumMF.get()) { aNumFmt.SetCharTextDistance( static_cast<short>(nValue) ); } - else if (&rFld == m_pIndentMF) + else if (&rFld == m_xIndentMF.get()) { // together with the FirstLineOffset the AbsLSpace must be changed, too long nDiff = nValue + aNumFmt.GetFirstLineOffset(); @@ -3225,16 +3415,16 @@ IMPL_LINK( SvxNumPositionTabPage, DistanceHdl_Impl, SpinField&, rFld, void ) } SetModified(); - if(!m_pDistBorderMF->IsEnabled()) + if (!m_xDistBorderMF->get_sensitive()) { - m_pDistBorderMF->SetText(""); + m_xDistBorderMF->set_text(""); } } -IMPL_LINK( SvxNumPositionTabPage, RelativeHdl_Impl, Button*, pBox, void ) +IMPL_LINK(SvxNumPositionTabPage, RelativeHdl_Impl, weld::ToggleButton&, rBox, void) { - bool bOn = static_cast<CheckBox*>(pBox)->IsChecked(); - bool bSingleSelection = m_pLevelLB->GetSelectedEntryCount() == 1 && SAL_MAX_UINT16 != nActNumLvl; + bool bOn = rBox.get_active(); + bool bSingleSelection = m_xLevelLB->count_selected_rows() == 1 && SAL_MAX_UINT16 != nActNumLvl; bool bSetValue = false; long nValue = 0; if(bOn || bSingleSelection) @@ -3264,20 +3454,20 @@ IMPL_LINK( SvxNumPositionTabPage, RelativeHdl_Impl, Button*, pBox, void ) } if(bSetValue) - SetMetricValue(*m_pDistBorderMF, nValue, eCoreUnit); + SetMetricValue(*m_xDistBorderMF, nValue, eCoreUnit); else - m_pDistBorderMF->SetText(""); - m_pDistBorderMF->Enable(bOn || bSingleSelection); - m_pDistBorderFT->Enable(bOn || bSingleSelection); + m_xDistBorderMF->set_text(""); + m_xDistBorderMF->set_sensitive(bOn || bSingleSelection); + m_xDistBorderFT->set_sensitive(bOn || bSingleSelection); bLastRelative = bOn; } -IMPL_LINK_NOARG(SvxNumPositionTabPage, LabelFollowedByHdl_Impl, ListBox&, void) +IMPL_LINK_NOARG(SvxNumPositionTabPage, LabelFollowedByHdl_Impl, weld::ComboBoxText&, void) { // determine value to be set at the chosen list levels SvxNumberFormat::LabelFollowedBy eLabelFollowedBy = SvxNumberFormat::LISTTAB; { - const sal_Int32 nPos = m_pLabelFollowedByLB->GetSelectedEntryPos(); + const auto nPos = m_xLabelFollowedByLB->get_active(); if ( nPos == 1 ) { eLabelFollowedBy = SvxNumberFormat::SPACE; @@ -3319,28 +3509,24 @@ IMPL_LINK_NOARG(SvxNumPositionTabPage, LabelFollowedByHdl_Impl, ListBox&, void) // enable/disable metric field for list tab stop position depending on // selected item following the list label. - m_pListtabFT->Enable( eLabelFollowedBy == SvxNumberFormat::LISTTAB ); - m_pListtabMF->Enable( eLabelFollowedBy == SvxNumberFormat::LISTTAB ); + m_xListtabFT->set_sensitive( eLabelFollowedBy == SvxNumberFormat::LISTTAB ); + m_xListtabMF->set_sensitive( eLabelFollowedBy == SvxNumberFormat::LISTTAB ); if ( bSameListtabPos && eLabelFollowedBy == SvxNumberFormat::LISTTAB ) { - SetMetricValue(*m_pListtabMF, pActNum->GetLevel( nFirstLvl ).GetListtabPos(), eCoreUnit); + SetMetricValue(*m_xListtabMF, pActNum->GetLevel( nFirstLvl ).GetListtabPos(), eCoreUnit); } else { - m_pListtabMF->SetText( OUString() ); + m_xListtabMF->set_text(OUString()); } SetModified(); } -IMPL_LINK( SvxNumPositionTabPage, ListtabPosFocusHdl_Impl, Control&, rControl, void ) -{ - ListtabPosHdl_Impl(static_cast<SpinField&>(rControl)); -} -IMPL_LINK( SvxNumPositionTabPage, ListtabPosHdl_Impl, SpinField&, rFld, void ) +IMPL_LINK(SvxNumPositionTabPage, ListtabPosHdl_Impl, weld::MetricSpinButton&, rFld, void) { // determine value to be set at the chosen list levels - const long nValue = GetCoreValue( static_cast<MetricField&>(rFld), eCoreUnit ); + const long nValue = GetCoreValue(rFld, eCoreUnit); // set value at the chosen list levels sal_uInt16 nMask = 1; @@ -3358,14 +3544,10 @@ IMPL_LINK( SvxNumPositionTabPage, ListtabPosHdl_Impl, SpinField&, rFld, void ) SetModified(); } -IMPL_LINK( SvxNumPositionTabPage, AlignAtFocusHdl_Impl, Control&, rControl, void ) -{ - AlignAtHdl_Impl(static_cast<SpinField&>(rControl)); -} -IMPL_LINK( SvxNumPositionTabPage, AlignAtHdl_Impl, SpinField&, rFld, void ) +IMPL_LINK(SvxNumPositionTabPage, AlignAtHdl_Impl, weld::MetricSpinButton&, rFld, void) { // determine value to be set at the chosen list levels - const long nValue = GetCoreValue( static_cast<MetricField&>(rFld), eCoreUnit ); + const long nValue = GetCoreValue(rFld, eCoreUnit); // set value at the chosen list levels sal_uInt16 nMask = 1; @@ -3384,14 +3566,10 @@ IMPL_LINK( SvxNumPositionTabPage, AlignAtHdl_Impl, SpinField&, rFld, void ) SetModified(); } -IMPL_LINK( SvxNumPositionTabPage, IndentAtFocusHdl_Impl, Control&, rControl, void ) -{ - IndentAtHdl_Impl(static_cast<SpinField&>(rControl)); -} -IMPL_LINK( SvxNumPositionTabPage, IndentAtHdl_Impl, SpinField&, rFld, void ) +IMPL_LINK(SvxNumPositionTabPage, IndentAtHdl_Impl, weld::MetricSpinButton&, rFld, void) { // determine value to be set at the chosen list levels - const long nValue = GetCoreValue( static_cast<MetricField&>(rFld), eCoreUnit ); + const long nValue = GetCoreValue(rFld, eCoreUnit); // set value at the chosen list levels sal_uInt16 nMask = 1; @@ -3413,7 +3591,7 @@ IMPL_LINK( SvxNumPositionTabPage, IndentAtHdl_Impl, SpinField&, rFld, void ) SetModified(); } -IMPL_LINK_NOARG(SvxNumPositionTabPage, StandardHdl_Impl, Button*, void) +IMPL_LINK_NOARG(SvxNumPositionTabPage, StandardHdl_Impl, weld::Button&, void) { sal_uInt16 nMask = 1; SvxNumRule aTmpNumRule( pActNum->GetFeatureFlags(), @@ -3455,14 +3633,14 @@ IMPL_LINK_NOARG(SvxNumPositionTabPage, StandardHdl_Impl, Button*, void) void SvxNumPositionTabPage::SetModified() { bModified = true; - m_pPreviewWIN->SetLevel(nActNumLvl); - m_pPreviewWIN->Invalidate(); + m_aPreviewWIN.SetLevel(nActNumLvl); + m_aPreviewWIN.Invalidate(); } void SvxNumOptionsTabPage::SetModified(bool bRepaint) { bModified = true; - if(bRepaint) + if (bRepaint) { m_pPreviewWIN->SetLevel(nActNumLvl); m_pPreviewWIN->Invalidate(); diff --git a/cui/uiconfig/ui/numberingpositionpage.ui b/cui/uiconfig/ui/numberingpositionpage.ui index f1dbe1d82cf6..5b15b93ff796 100644 --- a/cui/uiconfig/ui/numberingpositionpage.ui +++ b/cui/uiconfig/ui/numberingpositionpage.ui @@ -1,5 +1,5 @@ <?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"/> <object class="GtkAdjustment" id="adjustment1"> @@ -13,39 +13,10 @@ <property name="step_increment">0.050000000000000003</property> <property name="page_increment">10</property> </object> - <object class="GtkListStore" id="liststore1"> - <columns> - <!-- column-name gchararray1 --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0" translatable="yes" context="numberingpositionpage|liststore1">Left</col> - </row> - <row> - <col id="0" translatable="yes" context="numberingpositionpage|liststore1">Centered</col> - </row> - <row> - <col id="0" translatable="yes" context="numberingpositionpage|liststore1">Right</col> - </row> - </data> - </object> - <object class="GtkListStore" id="liststore2"> - <columns> - <!-- column-name gchararray1 --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0" translatable="yes" context="numberingpositionpage|liststore2">Tab stop</col> - </row> - <row> - <col id="0" translatable="yes" context="numberingpositionpage|liststore2">Space</col> - </row> - <row> - <col id="0" translatable="yes" context="numberingpositionpage|liststore2">Nothing</col> - </row> - </data> + <object class="GtkAdjustment" id="adjustment3"> + <property name="upper">19.989999999999998</property> + <property name="step_increment">0.050000000000000003</property> + <property name="page_increment">10</property> </object> <object class="GtkBox" id="NumberingPositionPage"> <property name="visible">True</property> @@ -67,14 +38,31 @@ <property name="top_padding">6</property> <property name="left_padding">12</property> <child> - <object class="GtkTreeView" id="levellb:border"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="headers_visible">False</property> - <property name="search_column">0</property> - <child internal-child="selection"> - <object class="GtkTreeSelection" id="treeview-selection6"> - <property name="mode">multiple</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="levellb"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="headers_visible">False</property> + <property name="headers_clickable">False</property> + <property name="search_column">0</property> + <property name="show_expanders">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="treeview-selection1"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn1"> + <child> + <object class="GtkCellRendererText" id="cellrenderertext1"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> </object> </child> </object> @@ -135,10 +123,10 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="numberingpositionpage|numfollowedby">Numbering followed by:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">numfollowedbylb</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -149,10 +137,10 @@ <object class="GtkLabel" id="num2align"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="numberingpositionpage|num2align">N_umbering alignment:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">num2alignlb</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -163,10 +151,10 @@ <object class="GtkLabel" id="alignedat"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="numberingpositionpage|alignedat">Aligned at:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">alignedatmf:0.00cm</property> + <property name="mnemonic_widget">alignedatmf</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -177,10 +165,10 @@ <object class="GtkLabel" id="indentat"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="numberingpositionpage|indentat">Indent at:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">indentatmf:0.00cm</property> + <property name="mnemonic_widget">indentatmf</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -188,19 +176,10 @@ </packing> </child> <child> - <object class="GtkComboBox" id="num2alignlb"> - <property name="visible">True</property> - <property name="can_focus">False</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkSpinButton" id="indentatmf:0.00cm"> + <object class="GtkSpinButton" id="indentatmf"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="activates_default">True</property> <property name="digits">2</property> </object> <packing> @@ -212,10 +191,10 @@ <object class="GtkLabel" id="at"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="numberingpositionpage|at">Tab stop at:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">atmf:0.00cm</property> + <property name="mnemonic_widget">atmf</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -223,9 +202,10 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="atmf:0.00cm"> + <object class="GtkSpinButton" id="atmf"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="activates_default">True</property> <property name="digits">2</property> </object> <packing> @@ -234,9 +214,10 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="alignedatmf:0.00cm"> + <object class="GtkSpinButton" id="alignedatmf"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="activates_default">True</property> <property name="digits">2</property> </object> <packing> @@ -245,10 +226,14 @@ </packing> </child> <child> - <object class="GtkComboBox" id="numfollowedbylb"> + <object class="GtkComboBoxText" id="numfollowedbylb"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="model">liststore2</property> + <items> + <item translatable="yes" context="numberingpositionpage|liststore2">Tab stop</item> + <item translatable="yes" context="numberingpositionpage|liststore2">Space</item> + <item translatable="yes" context="numberingpositionpage|liststore2">Nothing</item> + </items> </object> <packing> <property name="left_attach">1</property> @@ -259,10 +244,10 @@ <object class="GtkLabel" id="indent"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="numberingpositionpage|indent">Indent:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">indentmf:0.00cm</property> + <property name="mnemonic_widget">indentmf</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -270,9 +255,10 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="indentmf:0.00cm"> + <object class="GtkSpinButton" id="indentmf"> <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> @@ -302,10 +288,10 @@ <object class="GtkLabel" id="numberingwidth"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="numberingpositionpage|numberingwidth">Width of numbering:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">numberingwidthmf:0.00cm</property> + <property name="mnemonic_widget">numberingwidthmf</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -313,9 +299,10 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="numberingwidthmf:0.00cm"> + <object class="GtkSpinButton" id="numberingwidthmf"> <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> @@ -325,10 +312,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="numdistmf:0.00cm"> + <object class="GtkSpinButton" id="numdistmf"> <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">adjustment3</property> <property name="digits">2</property> </object> <packing> @@ -340,12 +328,12 @@ <object class="GtkLabel" id="numdist"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="numberingpositionpage|numdist">Minimum space between numbering and text:</property> <property name="use_underline">True</property> <property name="justify">right</property> - <property name="mnemonic_widget">numdistmf:0.00cm</property> + <property name="mnemonic_widget">numdistmf</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -356,10 +344,10 @@ numbering and text:</property> <object class="GtkLabel" id="numalign"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">1</property> <property name="label" translatable="yes" context="numberingpositionpage|numalign">N_umbering alignment:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">numalignlb</property> + <property name="xalign">1</property> </object> <packing> <property name="left_attach">0</property> @@ -367,16 +355,30 @@ numbering and text:</property> </packing> </child> <child> - <object class="GtkComboBox" id="numalignlb"> + <object class="GtkComboBoxText" id="numalignlb"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="model">liststore1</property> + <items> + <item translatable="yes" context="numberingpositionpage|liststore1">Left</item> + <item translatable="yes" context="numberingpositionpage|liststore1">Centered</item> + <item translatable="yes" context="numberingpositionpage|liststore1">Right</item> + </items> </object> <packing> <property name="left_attach">1</property> <property name="top_attach">9</property> </packing> </child> + <child> + <object class="GtkComboBoxText" id="num2alignlb"> + <property name="visible">True</property> + <property name="can_focus">False</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + </packing> + </child> </object> </child> </object> @@ -419,14 +421,31 @@ numbering and text:</property> </packing> </child> <child> - <object class="cuilo-SvxNumberingPreview" id="preview"> - <property name="width_request">300</property> - <property name="height_request">150</property> + <object class="GtkScrolledWindow" id="previewwin"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="hscrollbar_policy">never</property> + <property name="vscrollbar_policy">never</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkViewport"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> + <child> + <object class="GtkDrawingArea" id="preview"> + <property name="width_request">300</property> + <property name="height_request">150</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + </object> + </child> </object> + </child> + </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> @@ -447,4 +466,12 @@ numbering and text:</property> </packing> </child> </object> + <object class="GtkListStore" id="liststore1"> + <columns> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> + </object> </interface> |