diff options
Diffstat (limited to 'cui/source/tabpages')
34 files changed, 2527 insertions, 2128 deletions
diff --git a/cui/source/tabpages/TextColumnsPage.cxx b/cui/source/tabpages/TextColumnsPage.cxx index 5bfd3b47a69e..2e39995083f3 100644 --- a/cui/source/tabpages/TextColumnsPage.cxx +++ b/cui/source/tabpages/TextColumnsPage.cxx @@ -39,7 +39,7 @@ void SvxTextColumnsPage::Reset(const SfxItemSet* rAttrs) { auto pItem = GetItem(*rAttrs, SDRATTR_TEXTCOLUMNS_NUMBER); if (!pItem) - pItem = &pPool->GetDefaultItem(SDRATTR_TEXTCOLUMNS_NUMBER); + pItem = &pPool->GetUserOrPoolDefaultItem(SDRATTR_TEXTCOLUMNS_NUMBER); m_xColumnsNumber->set_value(pItem->GetValue()); m_xColumnsNumber->save_value(); } @@ -48,7 +48,7 @@ void SvxTextColumnsPage::Reset(const SfxItemSet* rAttrs) MapUnit eUnit = pPool->GetMetric(SDRATTR_TEXTCOLUMNS_SPACING); auto pItem = GetItem(*rAttrs, SDRATTR_TEXTCOLUMNS_SPACING); if (!pItem) - pItem = &pPool->GetDefaultItem(SDRATTR_TEXTCOLUMNS_SPACING); + pItem = &pPool->GetUserOrPoolDefaultItem(SDRATTR_TEXTCOLUMNS_SPACING); SetMetricValue(*m_xColumnsSpacing, pItem->GetValue(), eUnit); m_xColumnsSpacing->save_value(); } diff --git a/cui/source/tabpages/align.cxx b/cui/source/tabpages/align.cxx index 3db4e5c20ca5..d5816158d70b 100644 --- a/cui/source/tabpages/align.cxx +++ b/cui/source/tabpages/align.cxx @@ -56,24 +56,23 @@ namespace { template<typename JustContainerType, typename JustEnumType> void lcl_MaybeResetAlignToDistro( - weld::ComboBox& rLB, sal_uInt16 nListId, const SfxItemSet& rCoreAttrs, sal_uInt16 nWhichAlign, sal_uInt16 nWhichJM, JustEnumType eBlock) + weld::ComboBox& rLB, sal_uInt16 nListId, const SfxItemSet& rCoreAttrs, TypedWhichId<SfxEnumItemInterface> nWhichAlign, TypedWhichId<SfxEnumItemInterface> nWhichJM, JustEnumType eBlock) { - const SfxPoolItem* pItem; - if (rCoreAttrs.GetItemState(nWhichAlign, true, &pItem) != SfxItemState::SET) + const SfxEnumItemInterface* p = rCoreAttrs.GetItemIfSet(nWhichAlign); + if (!p) // alignment not set. return; - const SfxEnumItemInterface* p = static_cast<const SfxEnumItemInterface*>(pItem); JustContainerType eVal = static_cast<JustContainerType>(p->GetEnumValue()); if (eVal != eBlock) // alignment is not 'justify'. No need to go further. return; - if (rCoreAttrs.GetItemState(nWhichJM, true, &pItem) != SfxItemState::SET) + p = rCoreAttrs.GetItemIfSet(nWhichJM); + if (!p) // justification method is not set. return; - p = static_cast<const SfxEnumItemInterface*>(pItem); SvxCellJustifyMethod eMethod = static_cast<SvxCellJustifyMethod>(p->GetEnumValue()); if (eMethod == SvxCellJustifyMethod::Distribute) { @@ -124,7 +123,6 @@ AlignmentTabPage::AlignmentTabPage(weld::Container* pPage, weld::DialogControlle , m_xCbStacked(m_xBuilder->weld_check_button("checkVertStack")) , m_xCbAsianMode(m_xBuilder->weld_check_button("checkAsianMode")) // Properties - , m_xBoxDirection(m_xBuilder->weld_widget("boxDirection")) , m_xBtnWrap(m_xBuilder->weld_check_button("checkWrapTextAuto")) , m_xBtnHyphen(m_xBuilder->weld_check_button("checkHyphActive")) , m_xBtnShrink(m_xBuilder->weld_check_button("checkShrinkFitCellSize")) @@ -224,7 +222,7 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) assert(pIndentItem); std::unique_ptr<SfxUInt16Item> pNewIndentItem(pIndentItem->Clone()); pNewIndentItem->SetValue(m_xEdIndent->get_value(FieldUnit::TWIP)); - rSet->Put(*pNewIndentItem); + rSet->Put(std::move(pNewIndentItem)); bChanged = true; } else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false)) @@ -267,25 +265,25 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) assert(pAngleItem); std::unique_ptr<SdrAngleItem> pNewAngleItem(pAngleItem->Clone()); pNewAngleItem->SetValue(m_xCtrlDial->GetRotation()); - rSet->Put(*pNewAngleItem); + rSet->Put(std::move(pNewAngleItem)); bChanged = true; } else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false)) rSet->InvalidateItem(nWhich); - nWhich = GetWhich(SID_ATTR_ALIGN_LOCKPOS); + TypedWhichId<SvxRotateModeItem> nWhichLockPos(GetWhich(SID_ATTR_ALIGN_LOCKPOS)); if (m_aVsRefEdge.IsValueChangedFromSaved()) { switch (m_aVsRefEdge.GetSelectedItemId()) { case IID_CELLLOCK: - rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_STANDARD, nWhich)); + rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_STANDARD, nWhichLockPos)); break; case IID_TOPLOCK: - rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_TOP, nWhich)); + rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_TOP, nWhichLockPos)); break; case IID_BOTTOMLOCK: - rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_BOTTOM, nWhich)); + rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_BOTTOM, nWhichLockPos)); break; default: m_aVsRefEdge.SetNoSelection(); @@ -293,8 +291,8 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) } bChanged = true; } - else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false)) - rSet->InvalidateItem(nWhich); + else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhichLockPos, false)) + rSet->InvalidateItem(nWhichLockPos); nWhich = GetWhich(SID_ATTR_ALIGN_STACKED); if (m_xCbStacked->get_state_changed_from_saved()) @@ -304,7 +302,7 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) assert(pStackItem); std::unique_ptr<SfxBoolItem> pNewStackItem(pStackItem->Clone()); pNewStackItem->SetValue(m_xCbStacked->get_active()); - rSet->Put(*pNewStackItem); + rSet->Put(std::move(pNewStackItem)); bChanged = true; } else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false)) @@ -327,7 +325,7 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) assert(pWrapItem); std::unique_ptr<SfxBoolItem> pNewWrapItem(pWrapItem->Clone()); pNewWrapItem->SetValue(m_xBtnWrap->get_active()); - rSet->Put(*pNewWrapItem); + rSet->Put(std::move(pNewWrapItem)); bChanged = true; } else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false)) @@ -341,7 +339,7 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) assert(pHyphItem); std::unique_ptr<SfxBoolItem> pNewHyphItem(pHyphItem->Clone()); pNewHyphItem->SetValue(m_xBtnHyphen->get_active()); - rSet->Put(*pNewHyphItem); + rSet->Put(std::move(pNewHyphItem)); bChanged = true; } else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false)) @@ -355,7 +353,7 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) assert(pShrinkItem); std::unique_ptr<SfxBoolItem> pNewShrinkItem(pShrinkItem->Clone()); pNewShrinkItem->SetValue(m_xBtnShrink->get_active()); - rSet->Put(*pNewShrinkItem); + rSet->Put(std::move(pNewShrinkItem)); bChanged = true; } else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false)) @@ -376,12 +374,12 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet ) // Special treatment for distributed alignment; we need to set the justify // method to 'distribute' to distinguish from the normal justification. - sal_uInt16 nWhichHorJM = GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD); + TypedWhichId<SfxEnumItemInterface> nWhichHorJM(GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD)); lcl_SetJustifyMethodToItemSet(*rSet, rOldSet, nWhichHorJM, *m_xLbHorAlign, ALIGNDLG_HORALIGN_DISTRIBUTED); if (!bChanged) bChanged = HasAlignmentChanged(*rSet, nWhichHorJM); - sal_uInt16 nWhichVerJM = GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD); + TypedWhichId<SfxEnumItemInterface> nWhichVerJM(GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD)); lcl_SetJustifyMethodToItemSet(*rSet, rOldSet, nWhichVerJM, *m_xLbVerAlign, ALIGNDLG_VERALIGN_DISTRIBUTED); if (!bChanged) bChanged = HasAlignmentChanged(*rSet, nWhichVerJM); @@ -404,7 +402,7 @@ namespace rBtn.set_sensitive(false); rTriState.bTriStateEnabled = false; break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: rBtn.set_state(TRISTATE_INDET); rTriState.bTriStateEnabled = true; break; @@ -441,7 +439,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) case SfxItemState::DISABLED: m_xLbHorAlign->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_xLbHorAlign->set_active(-1); break; case SfxItemState::DEFAULT: @@ -484,7 +482,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) case SfxItemState::DISABLED: m_xEdIndent->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_xEdIndent->set_text(""); break; case SfxItemState::DEFAULT: @@ -507,7 +505,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) case SfxItemState::DISABLED: m_xLbVerAlign->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_xLbVerAlign->set_active(-1); break; case SfxItemState::DEFAULT: @@ -548,7 +546,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) m_xNfRotate->set_sensitive(false); m_xCtrlDialWin->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_xCtrlDial->SetNoRotation(); break; case SfxItemState::DEFAULT: @@ -570,7 +568,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) case SfxItemState::DISABLED: m_xVsRefEdge->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_aVsRefEdge.SetNoSelection(); break; case SfxItemState::DEFAULT: @@ -608,7 +606,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) case SfxItemState::DISABLED: m_xLbFrameDir->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_xLbFrameDir->set_active(-1); break; case SfxItemState::DEFAULT: @@ -622,7 +620,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) // Special treatment for distributed alignment; we need to set the justify // method to 'distribute' to distinguish from the normal justification. - sal_uInt16 nHorJustifyMethodWhich = GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD); + TypedWhichId<SfxEnumItemInterface> nHorJustifyMethodWhich(GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD)); SfxItemState eHorJustifyMethodState = pCoreAttrs->GetItemState(nHorJustifyMethodWhich); if (eHorJustifyMethodState == SfxItemState::UNKNOWN) { @@ -636,11 +634,11 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) // feature known, e.g. calc lcl_MaybeResetAlignToDistro<SvxCellHorJustify, SvxCellHorJustify>( *m_xLbHorAlign, ALIGNDLG_HORALIGN_DISTRIBUTED, *pCoreAttrs, - GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY), nHorJustifyMethodWhich, + TypedWhichId<SfxEnumItemInterface>(GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY)), nHorJustifyMethodWhich, SvxCellHorJustify::Block); } - sal_uInt16 nVerJustifyMethodWhich = GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD); + TypedWhichId<SfxEnumItemInterface> nVerJustifyMethodWhich( GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD) ); SfxItemState eVerJustifyMethodState = pCoreAttrs->GetItemState(nVerJustifyMethodWhich); if (eVerJustifyMethodState == SfxItemState::UNKNOWN) { @@ -654,7 +652,7 @@ void AlignmentTabPage::Reset(const SfxItemSet* pCoreAttrs) // feature known, e.g. calc lcl_MaybeResetAlignToDistro<SvxCellVerJustify, SvxCellVerJustify>( *m_xLbVerAlign, ALIGNDLG_VERALIGN_DISTRIBUTED, *pCoreAttrs, - GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY), nVerJustifyMethodWhich, + TypedWhichId<SfxEnumItemInterface>(GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY)), nVerJustifyMethodWhich, SvxCellVerJustify::Block); } @@ -736,21 +734,18 @@ void AlignmentTabPage::UpdateEnableControls() m_xNfRotate->set_sensitive(!bHorFill && !bStackedText); } -bool AlignmentTabPage::HasAlignmentChanged( const SfxItemSet& rNew, sal_uInt16 nWhich ) const +bool AlignmentTabPage::HasAlignmentChanged( const SfxItemSet& rNew, TypedWhichId<SfxEnumItemInterface> nWhich ) const { const SfxItemSet& rOld = GetItemSet(); - const SfxPoolItem* pItem; SvxCellJustifyMethod eMethodOld = SvxCellJustifyMethod::Auto; SvxCellJustifyMethod eMethodNew = SvxCellJustifyMethod::Auto; - if (rOld.GetItemState(nWhich, true, &pItem) == SfxItemState::SET) + if (const SfxEnumItemInterface* p = rOld.GetItemIfSet(nWhich)) { - const SfxEnumItemInterface* p = static_cast<const SfxEnumItemInterface*>(pItem); eMethodOld = static_cast<SvxCellJustifyMethod>(p->GetEnumValue()); } - if (rNew.GetItemState(nWhich, true, &pItem) == SfxItemState::SET) + if (const SfxEnumItemInterface* p = rNew.GetItemIfSet(nWhich)) { - const SfxEnumItemInterface* p = static_cast<const SfxEnumItemInterface*>(pItem); eMethodNew = static_cast<SvxCellJustifyMethod>(p->GetEnumValue()); } diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx index 28bcbcf9f951..b7abdbcce907 100644 --- a/cui/source/tabpages/autocdlg.cxx +++ b/cui/source/tabpages/autocdlg.cxx @@ -17,8 +17,11 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + #include <i18nutil/unicode.hxx> #include <o3tl/safeint.hxx> +#include <utility> #include <vcl/event.hxx> #include <vcl/keycodes.hxx> #include <vcl/settings.hxx> @@ -29,11 +32,9 @@ #include <unotools/charclass.hxx> #include <unotools/collatorwrapper.hxx> #include <comphelper/processfactory.hxx> -#include <comphelper/string.hxx> #include <vcl/svapp.hxx> #include <sfx2/module.hxx> #include <svl/eitem.hxx> -#include <svl/languageoptions.hxx> #include <svl/cjkoptions.hxx> #include <svl/ctloptions.hxx> #include <svx/SmartTagMgr.hxx> @@ -46,14 +47,13 @@ #include <autocdlg.hxx> #include <editeng/acorrcfg.hxx> #include <editeng/svxacorr.hxx> -#include <cui/cuicharmap.hxx> +#include <svx/cuicharmap.hxx> #include <strings.hrc> #include <dialmgr.hxx> #include <svx/svxids.hrc> static LanguageType eLastDialogLanguage = LANGUAGE_SYSTEM; -using namespace ::com::sun::star::util; using namespace ::com::sun::star; OfaAutoCorrDlg::OfaAutoCorrDlg(weld::Window* pParent, const SfxItemSet* _pSet ) @@ -106,7 +106,7 @@ OfaAutoCorrDlg::OfaAutoCorrDlg(weld::Window* pParent, const SfxItemSet* _pSet ) //! will be set to LANGUAGE_UNDETERMINED SvxLanguageListFlags nLangList = SvxLanguageListFlags::WESTERN; - if( SvtCTLOptions().IsCTLFontEnabled() ) + if( SvtCTLOptions::IsCTLFontEnabled() ) nLangList |= SvxLanguageListFlags::CTL; if( SvtCJKOptions::IsCJKFontEnabled() ) nLangList |= SvxLanguageListFlags::CJK; @@ -166,7 +166,7 @@ IMPL_LINK_NOARG(OfaAutoCorrDlg, SelectLanguageHdl, weld::ComboBox&, void) if(eNewLang == eLastDialogLanguage) return; - OString sPageId = GetCurPageId(); + OUString sPageId = GetCurPageId(); if (sPageId == "replace") { OfaAutocorrReplacePage* pPage = static_cast<OfaAutocorrReplacePage*>(GetTabPage(sPageId)); @@ -183,14 +183,15 @@ IMPL_LINK_NOARG(OfaAutoCorrDlg, SelectLanguageHdl, weld::ComboBox&, void) OfaAutocorrOptionsPage::OfaAutocorrOptionsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/acoroptionspage.ui", "AutocorrectOptionsPage", &rSet) - , m_sInput(CuiResId(RID_SVXSTR_USE_REPLACE)) - , m_sDoubleCaps(CuiResId(RID_SVXSTR_CPTL_STT_WORD)) - , m_sStartCap(CuiResId(RID_SVXSTR_CPTL_STT_SENT)) - , m_sBoldUnderline(CuiResId(RID_SVXSTR_BOLD_UNDER)) - , m_sURL(CuiResId(RID_SVXSTR_DETECT_URL)) - , m_sNoDblSpaces(CuiResId(RID_SVXSTR_NO_DBL_SPACES)) - , m_sDash(CuiResId(RID_SVXSTR_DASH)) - , m_sAccidentalCaps(CuiResId(RID_SVXSTR_CORRECT_ACCIDENTAL_CAPS_LOCK)) + , m_sInput(CuiResId(RID_CUISTR_USE_REPLACE)) + , m_sDoubleCaps(CuiResId(RID_CUISTR_CPTL_STT_WORD)) + , m_sStartCap(CuiResId(RID_CUISTR_CPTL_STT_SENT)) + , m_sBoldUnderline(CuiResId(RID_CUISTR_BOLD_UNDER)) + , m_sURL(CuiResId(RID_CUISTR_DETECT_URL)) + , m_sDOI(CuiResId(RID_CUISTR_DETECT_DOI)) + , m_sNoDblSpaces(CuiResId(RID_CUISTR_NO_DBL_SPACES)) + , m_sDash(CuiResId(RID_CUISTR_DASH)) + , m_sAccidentalCaps(CuiResId(RID_CUISTR_CORRECT_ACCIDENTAL_CAPS_LOCK)) , m_xCheckLB(m_xBuilder->weld_tree_view("checklist")) { m_xCheckLB->enable_toggle_buttons(weld::ColumnToggleType::Check); @@ -222,6 +223,7 @@ bool OfaAutocorrOptionsPage::FillItemSet( SfxItemSet* ) pAutoCorrect->SetAutoCorrFlag(ACFlags::CapitalStartSentence, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE); pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgWeightUnderl, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE); pAutoCorrect->SetAutoCorrFlag(ACFlags::SetINetAttr, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE); + pAutoCorrect->SetAutoCorrFlag(ACFlags::SetDOIAttr, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE); pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgToEnEmDash, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE); pAutoCorrect->SetAutoCorrFlag(ACFlags::IgnoreDoubleSpace, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE); pAutoCorrect->SetAutoCorrFlag(ACFlags::CorrectCapsLock, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE); @@ -262,6 +264,7 @@ void OfaAutocorrOptionsPage::Reset( const SfxItemSet* ) InsertEntry(m_sStartCap); InsertEntry(m_sBoldUnderline); InsertEntry(m_sURL); + InsertEntry(m_sDOI); InsertEntry(m_sDash); InsertEntry(m_sNoDblSpaces); InsertEntry(m_sAccidentalCaps); @@ -272,6 +275,7 @@ void OfaAutocorrOptionsPage::Reset( const SfxItemSet* ) m_xCheckLB->set_toggle( nPos++, bool(nFlags & ACFlags::CapitalStartSentence) ? TRISTATE_TRUE : TRISTATE_FALSE ); m_xCheckLB->set_toggle( nPos++, bool(nFlags & ACFlags::ChgWeightUnderl) ? TRISTATE_TRUE : TRISTATE_FALSE ); m_xCheckLB->set_toggle( nPos++, bool(nFlags & ACFlags::SetINetAttr) ? TRISTATE_TRUE : TRISTATE_FALSE ); + m_xCheckLB->set_toggle( nPos++, bool(nFlags & ACFlags::SetDOIAttr) ? TRISTATE_TRUE : TRISTATE_FALSE ); m_xCheckLB->set_toggle( nPos++, bool(nFlags & ACFlags::ChgToEnEmDash) ? TRISTATE_TRUE : TRISTATE_FALSE ); m_xCheckLB->set_toggle( nPos++, bool(nFlags & ACFlags::IgnoreDoubleSpace) ? TRISTATE_TRUE : TRISTATE_FALSE ); m_xCheckLB->set_toggle( nPos++, bool(nFlags & ACFlags::CorrectCapsLock) ? TRISTATE_TRUE : TRISTATE_FALSE ); @@ -332,12 +336,14 @@ enum OfaAutoFmtOptions BEGIN_UPPER, BOLD_UNDERLINE, DETECT_URL, + DETECT_DOI, REPLACE_DASHES, DEL_SPACES_AT_STT_END, DEL_SPACES_BETWEEN_LINES, IGNORE_DBLSPACE, CORRECT_CAPS_LOCK, APPLY_NUMBERING, + APPLY_NUMBERING_AFTER_SPACE, INSERT_BORDER, CREATE_TABLE, REPLACE_STYLES, @@ -352,31 +358,32 @@ enum OfaAutoFmtOptions OfaSwAutoFmtOptionsPage::OfaSwAutoFmtOptionsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ) : SfxTabPage(pPage, pController, "cui/ui/applyautofmtpage.ui", "ApplyAutoFmtPage", &rSet) - , sDeleteEmptyPara(CuiResId(RID_SVXSTR_DEL_EMPTY_PARA)) - , sUseReplaceTbl(CuiResId(RID_SVXSTR_USE_REPLACE)) - , sCapitalStartWord(CuiResId(RID_SVXSTR_CPTL_STT_WORD)) - , sCapitalStartSentence(CuiResId(RID_SVXSTR_CPTL_STT_SENT)) - , sUserStyle(CuiResId(RID_SVXSTR_USER_STYLE)) - , sBullet(CuiResId(RID_SVXSTR_BULLET)) - , sBoldUnder(CuiResId(RID_SVXSTR_BOLD_UNDER)) - , sNoDblSpaces(CuiResId(RID_SVXSTR_NO_DBL_SPACES)) - , sCorrectCapsLock(CuiResId(RID_SVXSTR_CORRECT_ACCIDENTAL_CAPS_LOCK)) - , sDetectURL(CuiResId(RID_SVXSTR_DETECT_URL)) - , sDash(CuiResId(RID_SVXSTR_DASH)) - , sRightMargin(CuiResId(RID_SVXSTR_RIGHT_MARGIN)) - , sNum(CuiResId(RID_SVXSTR_NUM)) - , sBorder(CuiResId(RID_SVXSTR_BORDER)) - , sTable(CuiResId(RID_SVXSTR_CREATE_TABLE)) - , sReplaceTemplates(CuiResId(RID_SVXSTR_REPLACE_TEMPLATES)) - , sDelSpaceAtSttEnd(CuiResId(RID_SVXSTR_DEL_SPACES_AT_STT_END)) - , sDelSpaceBetweenLines(CuiResId(RID_SVXSTR_DEL_SPACES_BETWEEN_LINES)) + , sDeleteEmptyPara(CuiResId(RID_CUISTR_DEL_EMPTY_PARA)) + , sUseReplaceTbl(CuiResId(RID_CUISTR_USE_REPLACE)) + , sCapitalStartWord(CuiResId(RID_CUISTR_CPTL_STT_WORD)) + , sCapitalStartSentence(CuiResId(RID_CUISTR_CPTL_STT_SENT)) + , sUserStyle(CuiResId(RID_CUISTR_USER_STYLE)) + , sBullet(CuiResId(RID_CUISTR_BULLET)) + , sBoldUnder(CuiResId(RID_CUISTR_BOLD_UNDER)) + , sNoDblSpaces(CuiResId(RID_CUISTR_NO_DBL_SPACES)) + , sCorrectCapsLock(CuiResId(RID_CUISTR_CORRECT_ACCIDENTAL_CAPS_LOCK)) + , sDetectURL(CuiResId(RID_CUISTR_DETECT_URL)) + , sDetectDOI(CuiResId(RID_CUISTR_DETECT_DOI)) + , sDash(CuiResId(RID_CUISTR_DASH)) + , sRightMargin(CuiResId(RID_CUISTR_RIGHT_MARGIN)) + , sNum(CuiResId(RID_CUISTR_NUM)) + , sBulletsAfterSpace(CuiResId(RID_SVXSTR_NUM_FORMAT_AFTER_SPACE)) + , sBorder(CuiResId(RID_CUISTR_BORDER)) + , sTable(CuiResId(RID_CUISTR_CREATE_TABLE)) + , sReplaceTemplates(CuiResId(RID_CUISTR_REPLACE_TEMPLATES)) + , sDelSpaceAtSttEnd(CuiResId(RID_CUISTR_DEL_SPACES_AT_STT_END)) + , sDelSpaceBetweenLines(CuiResId(RID_CUISTR_DEL_SPACES_BETWEEN_LINES)) , nPercent(50) , m_xCheckLB(m_xBuilder->weld_tree_view("list")) , m_xEditPB(m_xBuilder->weld_button("edit")) { m_xCheckLB->connect_changed(LINK(this, OfaSwAutoFmtOptionsPage, SelectHdl)); m_xCheckLB->connect_row_activated(LINK(this, OfaSwAutoFmtOptionsPage, DoubleClickEditHdl)); - m_xCheckLB->enable_toggle_buttons(weld::ColumnToggleType::Check); std::vector<int> aWidths { @@ -401,9 +408,9 @@ void OfaSwAutoFmtOptionsPage::CreateEntry(const OUString& rTxt, sal_uInt16 nCol) OfaSwAutoFmtOptionsPage::~OfaSwAutoFmtOptionsPage() { - delete reinterpret_cast<ImpUserData*>(m_xCheckLB->get_id(REPLACE_BULLETS).toInt64()); - delete reinterpret_cast<ImpUserData*>(m_xCheckLB->get_id(APPLY_NUMBERING).toInt64()); - delete reinterpret_cast<ImpUserData*>(m_xCheckLB->get_id(MERGE_SINGLE_LINE_PARA).toInt64()); + delete weld::fromId<ImpUserData*>(m_xCheckLB->get_id(REPLACE_BULLETS)); + delete weld::fromId<ImpUserData*>(m_xCheckLB->get_id(APPLY_NUMBERING)); + delete weld::fromId<ImpUserData*>(m_xCheckLB->get_id(MERGE_SINGLE_LINE_PARA)); } std::unique_ptr<SfxTabPage> OfaSwAutoFmtOptionsPage::Create(weld::Container* pPage, weld::DialogController* pController, @@ -455,6 +462,12 @@ bool OfaSwAutoFmtOptionsPage::FillItemSet( SfxItemSet* ) pAutoCorrect->SetAutoCorrFlag(ACFlags::SetINetAttr, m_xCheckLB->get_toggle(DETECT_URL, CBCOL_SECOND) == TRISTATE_TRUE); + bCheck = m_xCheckLB->get_toggle(DETECT_DOI, CBCOL_FIRST) == TRISTATE_TRUE; + bModified |= pOpt->bSetDOIAttr != bCheck; + pOpt->bSetDOIAttr = bCheck; + pAutoCorrect->SetAutoCorrFlag(ACFlags::SetDOIAttr, + m_xCheckLB->get_toggle(DETECT_DOI, CBCOL_SECOND) == TRISTATE_TRUE); + bCheck = m_xCheckLB->get_toggle(DEL_EMPTY_NODE, CBCOL_FIRST) == TRISTATE_TRUE; bModified |= pOpt->bDelEmptyNode != bCheck; pOpt->bDelEmptyNode = bCheck; @@ -486,6 +499,10 @@ bool OfaSwAutoFmtOptionsPage::FillItemSet( SfxItemSet* ) bModified |= pOpt->bSetNumRule != bCheck; pOpt->bSetNumRule = bCheck; + bCheck = m_xCheckLB->get_toggle(APPLY_NUMBERING_AFTER_SPACE, CBCOL_SECOND) == TRISTATE_TRUE; + bModified |= pOpt->bSetNumRuleAfterSpace != bCheck; + pOpt->bSetNumRuleAfterSpace = bCheck; + bCheck = m_xCheckLB->get_toggle(INSERT_BORDER, CBCOL_SECOND) == TRISTATE_TRUE; bModified |= pOpt->bSetBorder != bCheck; pOpt->bSetBorder = bCheck; @@ -558,6 +575,7 @@ void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet* ) CreateEntry(sCapitalStartSentence, CBCOL_BOTH ); CreateEntry(sBoldUnder, CBCOL_BOTH ); CreateEntry(sDetectURL, CBCOL_BOTH ); + CreateEntry(sDetectDOI, CBCOL_BOTH ); CreateEntry(sDash, CBCOL_BOTH ); CreateEntry(sDelSpaceAtSttEnd, CBCOL_BOTH ); CreateEntry(sDelSpaceBetweenLines, CBCOL_BOTH ); @@ -565,6 +583,7 @@ void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet* ) CreateEntry(sNoDblSpaces, CBCOL_SECOND); CreateEntry(sCorrectCapsLock, CBCOL_SECOND); CreateEntry(sNum.replaceFirst("%1", sBulletChar), CBCOL_SECOND); + CreateEntry(sBulletsAfterSpace, CBCOL_SECOND); CreateEntry(sBorder, CBCOL_SECOND); CreateEntry(sTable, CBCOL_SECOND); CreateEntry(sReplaceTemplates, CBCOL_SECOND); @@ -583,6 +602,8 @@ void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet* ) m_xCheckLB->set_toggle(BOLD_UNDERLINE, bool(nFlags & ACFlags::ChgWeightUnderl) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); m_xCheckLB->set_toggle(DETECT_URL, pOpt->bSetINetAttr ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST); m_xCheckLB->set_toggle(DETECT_URL, bool(nFlags & ACFlags::SetINetAttr) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); + m_xCheckLB->set_toggle(DETECT_DOI, pOpt->bSetDOIAttr ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST); + m_xCheckLB->set_toggle(DETECT_DOI, bool(nFlags & ACFlags::SetDOIAttr) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); m_xCheckLB->set_toggle(REPLACE_DASHES, pOpt->bChgToEnEmDash ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST); m_xCheckLB->set_toggle(REPLACE_DASHES, bool(nFlags & ACFlags::ChgToEnEmDash) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); m_xCheckLB->set_toggle(DEL_SPACES_AT_STT_END, pOpt->bAFormatDelSpacesAtSttEnd ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST); @@ -592,6 +613,7 @@ void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet* ) m_xCheckLB->set_toggle(IGNORE_DBLSPACE, bool(nFlags & ACFlags::IgnoreDoubleSpace) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); m_xCheckLB->set_toggle(CORRECT_CAPS_LOCK, bool(nFlags & ACFlags::CorrectCapsLock) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); m_xCheckLB->set_toggle(APPLY_NUMBERING, pOpt->bSetNumRule ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); + m_xCheckLB->set_toggle(APPLY_NUMBERING_AFTER_SPACE, pOpt->bSetNumRuleAfterSpace ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); m_xCheckLB->set_toggle(INSERT_BORDER, pOpt->bSetBorder ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); m_xCheckLB->set_toggle(CREATE_TABLE, pOpt->bCreateTable ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); m_xCheckLB->set_toggle(REPLACE_STYLES, pOpt->bReplaceStyles ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND); @@ -601,15 +623,15 @@ void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet* ) m_xCheckLB->set_toggle(MERGE_SINGLE_LINE_PARA, pOpt->bRightMargin ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST); ImpUserData* pUserData = new ImpUserData(&sBulletChar, &aBulletFont); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pUserData))); + OUString sId(weld::toId(pUserData)); m_xCheckLB->set_id(REPLACE_BULLETS, sId); pUserData = new ImpUserData(&sMargin, nullptr); - sId = OUString::number(reinterpret_cast<sal_Int64>(pUserData)); + sId = weld::toId(pUserData); m_xCheckLB->set_id(MERGE_SINGLE_LINE_PARA, sId); ImpUserData* pUserData2 = new ImpUserData(&sByInputBulletChar, &aByInputBulletFont); - sId = OUString::number(reinterpret_cast<sal_Int64>(pUserData2)); + sId = weld::toId(pUserData2); m_xCheckLB->set_id(APPLY_NUMBERING, sId); m_xCheckLB->thaw(); @@ -632,7 +654,7 @@ IMPL_LINK_NOARG(OfaSwAutoFmtOptionsPage, EditHdl, weld::Button&, void) if (nSelEntryPos == REPLACE_BULLETS || nSelEntryPos == APPLY_NUMBERING) { SvxCharacterMap aMapDlg(GetFrameWeld(), nullptr, nullptr); - ImpUserData* pUserData = reinterpret_cast<ImpUserData*>(m_xCheckLB->get_id(nSelEntryPos).toInt64()); + ImpUserData* pUserData = weld::fromId<ImpUserData*>(m_xCheckLB->get_id(nSelEntryPos)); aMapDlg.SetCharFont(*pUserData->pFont); aMapDlg.SetChar( (*pUserData->pString)[0] ); if (RET_OK == aMapDlg.run()) @@ -667,6 +689,7 @@ IMPL_LINK_NOARG(OfaSwAutoFmtOptionsPage, EditHdl, weld::Button&, void) OfaAutocorrReplacePage::OfaAutocorrReplacePage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/acorreplacepage.ui", "AcorReplacePage", &rSet) + , maCompareClass(comphelper::getProcessComponentContext()) , eLang(eLastDialogLanguage) , bHasSelectionText(false) , bFirstSelect(true) @@ -698,9 +721,8 @@ OfaAutocorrReplacePage::OfaAutocorrReplacePage(weld::Container* pPage, weld::Dia bSWriter = pMod == SfxModule::GetActiveModule(); LanguageTag aLanguageTag( eLastDialogLanguage ); - pCompareClass.reset( new CollatorWrapper( comphelper::getProcessComponentContext() ) ); - pCompareClass->loadDefaultCollator( aLanguageTag.getLocale(), 0 ); - pCharClass.reset( new CharClass( aLanguageTag ) ); + maCompareClass.loadDefaultCollator( aLanguageTag.getLocale(), 0 ); + pCharClass.reset( new CharClass( std::move(aLanguageTag) ) ); auto nColWidth = m_xReplaceTLB->get_approximate_digit_width() * 32; m_aReplaceFixedWidths.push_back(nColWidth); @@ -722,7 +744,6 @@ OfaAutocorrReplacePage::~OfaAutocorrReplacePage() aDoubleStringTable.clear(); aChangesTable.clear(); - pCompareClass.reset(); pCharClass.reset(); } @@ -770,7 +791,8 @@ bool OfaAutocorrReplacePage::FillItemSet( SfxItemSet* ) bool bKeepSourceFormatting = newEntry.pUserData == &bHasSelectionText; if (bKeepSourceFormatting) { - pAutoCorrect->PutText(newEntry.sShort, *SfxObjectShell::Current(), eCurrentLang); + if (SfxObjectShell* pSh = SfxObjectShell::Current()) + pAutoCorrect->PutText(newEntry.sShort, *pSh, eCurrentLang); continue; } @@ -810,7 +832,7 @@ void OfaAutocorrReplacePage::RefillReplaceBox(bool bFromReset, pArray->push_back(DoubleString(m_xReplaceTLB->get_text(rIter, 0), m_xReplaceTLB->get_text(rIter, 1))); DoubleString& rDouble = pArray->back(); - rDouble.pUserData = reinterpret_cast<void*>(m_xReplaceTLB->get_id(rIter).toInt64()); + rDouble.pUserData = weld::fromId<void*>(m_xReplaceTLB->get_id(rIter)); return false; }); } @@ -831,7 +853,7 @@ void OfaAutocorrReplacePage::RefillReplaceBox(bool bFromReset, if (!bTextOnly) { // that means: with format info or even with selection text - OUString sId = OUString::number(reinterpret_cast<sal_Int64>(rDouble.pUserData)); + OUString sId = weld::toId(rDouble.pUserData); m_xReplaceTLB->set_id(rIter, sId); } m_xReplaceTLB->set_text(rIter, rDouble.sShort, 0); @@ -857,7 +879,7 @@ void OfaAutocorrReplacePage::RefillReplaceBox(bool bFromReset, if (!bTextOnly) { // that means: with format info or even with selection text - OUString sId = OUString::number(reinterpret_cast<sal_Int64>(m_xTextOnlyCB.get())); + OUString sId = weld::toId(m_xTextOnlyCB.get()); m_xReplaceTLB->set_id(rIter, sId); } m_xReplaceTLB->set_text(rIter, elem.GetShort(), 0); @@ -903,9 +925,9 @@ void OfaAutocorrReplacePage::SetLanguage(LanguageType eSet) eLastDialogLanguage = eSet; LanguageTag aLanguageTag( eLastDialogLanguage ); - pCompareClass.reset( new CollatorWrapper( comphelper::getProcessComponentContext() ) ); - pCompareClass->loadDefaultCollator( aLanguageTag.getLocale(), 0 ); - pCharClass.reset( new CharClass( aLanguageTag ) ); + maCompareClass = CollatorWrapper( comphelper::getProcessComponentContext() ); + maCompareClass.loadDefaultCollator( aLanguageTag.getLocale(), 0 ); + pCharClass.reset( new CharClass( std::move(aLanguageTag) ) ); ModifyHdl(*m_xShortED); } } @@ -918,7 +940,7 @@ IMPL_LINK(OfaAutocorrReplacePage, SelectHdl, weld::TreeView&, rBox, void) OUString sTmpShort(rBox.get_text(nEntry, 0)); // if the text is set via ModifyHdl, the cursor is always at the beginning // of a word, although you're editing here - bool bSameContent = 0 == pCompareClass->compareString(sTmpShort, m_xShortED->get_text()); + bool bSameContent = 0 == maCompareClass.compareString(sTmpShort, m_xShortED->get_text()); int nStartPos, nEndPos; m_xShortED->get_selection_bounds(nStartPos, nEndPos); if (m_xShortED->get_text() != sTmpShort) @@ -1056,7 +1078,7 @@ bool OfaAutocorrReplacePage::NewDelHdl(const weld::Widget* pBtn) int nCount = m_xReplaceTLB->n_children(); for (j = 0; j < nCount; ++j) { - if (0 >= pCompareClass->compareString(sEntry, m_xReplaceTLB->get_text(j, 0))) + if (0 >= maCompareClass.compareString(sEntry, m_xReplaceTLB->get_text(j, 0))) break; } nPos = j; @@ -1065,7 +1087,7 @@ bool OfaAutocorrReplacePage::NewDelHdl(const weld::Widget* pBtn) OUString sId; if (bKeepSourceFormatting) { - sId = OUString::number(reinterpret_cast<sal_Int64>(&bHasSelectionText)); // new formatted text + sId = weld::toId(&bHasSelectionText); // new formatted text } m_xReplaceTLB->insert(nPos, sEntry, &sId, nullptr, nullptr); @@ -1109,7 +1131,7 @@ IMPL_LINK(OfaAutocorrReplacePage, ModifyHdl, weld::Entry&, rEdt, void) &bTmpSelEntry, &bFirstSelIterSet, &xFirstSel, &aWordStr](weld::TreeIter& rIter){ OUString aTestStr = m_xReplaceTLB->get_text(rIter, 0); - if( pCompareClass->compareString(rEntry, aTestStr ) == 0 ) + if( maCompareClass.compareString(rEntry, aTestStr ) == 0 ) { if (!rRepString.isEmpty()) bFirstSelect = true; @@ -1190,6 +1212,7 @@ static bool lcl_FindInArray(std::vector<OUString>& rStrings, std::u16string_view OfaAutocorrExceptPage::OfaAutocorrExceptPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/acorexceptpage.ui", "AcorExceptPage", &rSet) + , maCompareClass(comphelper::getProcessComponentContext()) , eLang(eLastDialogLanguage) , m_xAbbrevED(m_xBuilder->weld_entry("abbrev")) , m_xAbbrevLB(m_xBuilder->weld_tree_view("abbrevlist")) @@ -1209,8 +1232,7 @@ OfaAutocorrExceptPage::OfaAutocorrExceptPage(weld::Container* pPage, weld::Dialo m_xDoubleCapsLB->set_size_request(-1, m_xDoubleCapsLB->get_height_rows(6)); css::lang::Locale aLcl( LanguageTag::convertToLocale(eLastDialogLanguage )); - pCompareClass.reset( new CollatorWrapper( comphelper::getProcessComponentContext() ) ); - pCompareClass->loadDefaultCollator( aLcl, 0 ); + maCompareClass.loadDefaultCollator( aLcl, 0 ); m_xNewAbbrevPB->connect_clicked(LINK(this, OfaAutocorrExceptPage, NewDelButtonHdl)); m_xDelAbbrevPB->connect_clicked(LINK(this, OfaAutocorrExceptPage, NewDelButtonHdl)); @@ -1229,7 +1251,6 @@ OfaAutocorrExceptPage::OfaAutocorrExceptPage(weld::Container* pPage, weld::Dialo OfaAutocorrExceptPage::~OfaAutocorrExceptPage() { aStringsTable.clear(); - pCompareClass.reset(); } std::unique_ptr<SfxTabPage> OfaAutocorrExceptPage::Create(weld::Container* pPage, weld::DialogController* pController, @@ -1364,8 +1385,8 @@ void OfaAutocorrExceptPage::SetLanguage(LanguageType eSet) // save old settings and fill anew RefillReplaceBoxes(false, eLang, eSet); eLastDialogLanguage = eSet; - pCompareClass.reset( new CollatorWrapper( comphelper::getProcessComponentContext() ) ); - pCompareClass->loadDefaultCollator( LanguageTag::convertToLocale( eLastDialogLanguage ), 0 ); + maCompareClass = CollatorWrapper( comphelper::getProcessComponentContext() ); + maCompareClass.loadDefaultCollator( LanguageTag::convertToLocale( eLastDialogLanguage ), 0 ); ModifyHdl(*m_xAbbrevED); ModifyHdl(*m_xDoubleCapsED); } @@ -1510,7 +1531,7 @@ IMPL_LINK(OfaAutocorrExceptPage, ModifyHdl, weld::Entry&, rEdt, void) bool bEntryLen = !sEntry.isEmpty(); if (&rEdt == m_xAbbrevED.get()) { - bool bSame = lcl_FindEntry(*m_xAbbrevLB, sEntry, *pCompareClass); + bool bSame = lcl_FindEntry(*m_xAbbrevLB, sEntry, maCompareClass); if(bSame && sEntry != m_xAbbrevLB->get_selected_text()) rEdt.set_text(m_xAbbrevLB->get_selected_text()); m_xNewAbbrevPB->set_sensitive(!bSame && bEntryLen); @@ -1518,7 +1539,7 @@ IMPL_LINK(OfaAutocorrExceptPage, ModifyHdl, weld::Entry&, rEdt, void) } else { - bool bSame = lcl_FindEntry(*m_xDoubleCapsLB, sEntry, *pCompareClass); + bool bSame = lcl_FindEntry(*m_xDoubleCapsLB, sEntry, maCompareClass); if(bSame && sEntry != m_xDoubleCapsLB->get_selected_text()) rEdt.set_text(m_xDoubleCapsLB->get_selected_text()); m_xNewDoublePB->set_sensitive(!bSame && bEntryLen); @@ -1551,10 +1572,10 @@ void OfaQuoteTabPage::CreateEntry(weld::TreeView& rCheckLB, const OUString& rTxt OfaQuoteTabPage::OfaQuoteTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/applylocalizedpage.ui", "ApplyLocalizedPage", &rSet) - , sNonBrkSpace(CuiResId(RID_SVXSTR_NON_BREAK_SPACE)) - , sOrdinal(CuiResId(RID_SVXSTR_ORDINAL)) - , sTransliterateRTL(CuiResId(RID_SVXSTR_OLD_HUNGARIAN)) - , sAngleQuotes(CuiResId(RID_SVXSTR_ANGLE_QUOTES)) + , sNonBrkSpace(CuiResId(RID_CUISTR_NON_BREAK_SPACE)) + , sOrdinal(CuiResId(RID_CUISTR_ORDINAL)) + , sTransliterateRTL(CuiResId(RID_CUISTR_OLD_HUNGARIAN)) + , sAngleQuotes(CuiResId(RID_CUISTR_ANGLE_QUOTES)) , cSglStartQuote(0) , cSglEndQuote(0) , cStartQuote(0) @@ -1586,7 +1607,6 @@ OfaQuoteTabPage::OfaQuoteTabPage(weld::Container* pPage, weld::DialogController* if ( bShowSWOptions ) { - m_xSwCheckLB->enable_toggle_buttons(weld::ColumnToggleType::Check); std::vector<int> aWidths { o3tl::narrowing<int>(m_xSwCheckLB->get_pixel_size(m_xSwCheckLB->get_column_title(0)).Width() * 2), @@ -1795,7 +1815,7 @@ IMPL_LINK(OfaQuoteTabPage, QuoteHdl, weld::Button&, rBtn, void) SvxCharacterMap aMap(GetFrameWeld(), nullptr, nullptr); aMap.SetCharFont( OutputDevice::GetDefaultFont(DefaultFontType::LATIN_TEXT, LANGUAGE_ENGLISH_US, GetDefaultFontFlags::OnlyOne )); - aMap.set_title(nMode < SGL_END ? CuiResId(RID_SVXSTR_STARTQUOTE) : CuiResId(RID_SVXSTR_ENDQUOTE)); + aMap.set_title(nMode < SGL_END ? CuiResId(RID_CUISTR_STARTQUOTE) : CuiResId(RID_CUISTR_ENDQUOTE)); sal_UCS4 cDlg; SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect(); LanguageType eLang = Application::GetSettings().GetLanguageTag().getLanguageType(); @@ -1968,7 +1988,6 @@ bool OfaAutoCompleteTabPage::FillItemSet( SfxItemSet* ) bool bModified = false, bCheck; SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect(); SvxSwAutoFormatFlags *pOpt = &pAutoCorrect->GetSwFlags(); - sal_uInt16 nVal; bCheck = m_xCBActiv->get_active(); bModified |= pOpt->bAutoCompleteWords != bCheck; @@ -1986,13 +2005,13 @@ bool OfaAutoCompleteTabPage::FillItemSet( SfxItemSet* ) bModified |= pOpt->bAutoCmpltShowAsTip != bCheck; pOpt->bAutoCmpltShowAsTip = bCheck; - nVal = static_cast<sal_uInt16>(m_xNFMinWordlen->get_value()); + sal_uInt16 nVal = static_cast<sal_uInt16>(m_xNFMinWordlen->get_value()); bModified |= nVal != pOpt->nAutoCmpltWordLen; pOpt->nAutoCmpltWordLen = nVal; - nVal = static_cast<sal_uInt16>(m_xNFMaxEntries->get_value()); - bModified |= nVal != pOpt->nAutoCmpltListLen; - pOpt->nAutoCmpltListLen = nVal; + sal_uInt32 nList = static_cast<sal_uInt32>(m_xNFMaxEntries->get_value()); + bModified |= nList != pOpt->nAutoCmpltListLen; + pOpt->nAutoCmpltListLen = nList; const int nPos = m_xDCBExpandKey->get_active(); if (nPos != -1) @@ -2053,7 +2072,7 @@ void OfaAutoCompleteTabPage::Reset( const SfxItemSet* ) { const OUString* pStr = &(*m_pAutoCompleteList)[n]->GetAutoCompleteString(); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pStr))); + OUString sId(weld::toId(pStr)); m_xLBEntries->append(sId, *pStr); } } @@ -2079,7 +2098,7 @@ IMPL_LINK_NOARG(OfaAutoCompleteTabPage, DeleteHdl, weld::Button&, void) while (!rows.empty()) { sal_Int32 nPos = rows.back(); - OUString* pStr = reinterpret_cast<OUString*>(m_xLBEntries->get_id(nPos).toInt64()); + OUString* pStr = weld::fromId<OUString*>(m_xLBEntries->get_id(nPos)); m_xLBEntries->remove(nPos); editeng::IAutoCompleteString hack(*pStr); // UGLY m_pAutoCompleteList->erase(&hack); @@ -2115,12 +2134,7 @@ void OfaAutoCompleteTabPage::CopyToClipboard() const for (auto a : rows) { - sData.append(OUStringToOString(m_xLBEntries->get_text(a), nEncode)); -#if defined(_WIN32) - sData.append("\015\012"); -#else - sData.append("\012"); -#endif + sData.append(OUStringToOString(m_xLBEntries->get_text(a), nEncode) + SAL_NEWLINE_STRING); } pCntnr->CopyByteString( SotClipboardFormatId::STRING, sData.makeStringAndClear() ); pCntnr->CopyToClipboard(m_xLBEntries->get_clipboard()); @@ -2186,11 +2200,11 @@ struct ImplSmartTagLBUserData uno::Reference< smarttags::XSmartTagRecognizer > mxRec; sal_Int32 mnSmartTagIdx; - ImplSmartTagLBUserData( const OUString& rSmartTagType, - uno::Reference< smarttags::XSmartTagRecognizer > const & xRec, + ImplSmartTagLBUserData( OUString aSmartTagType, + uno::Reference< smarttags::XSmartTagRecognizer > xRec, sal_Int32 nSmartTagIdx ) : - maSmartTagType( rSmartTagType ), - mxRec( xRec ), + maSmartTagType(std::move( aSmartTagType )), + mxRec(std::move( xRec )), mnSmartTagIdx( nSmartTagIdx ) {} }; @@ -2203,7 +2217,7 @@ void OfaSmartTagOptionsTabPage::ClearListBox() const int nCount = m_xSmartTagTypesLB->n_children(); for (int i = 0; i < nCount; ++i) { - const ImplSmartTagLBUserData* pUserData = reinterpret_cast<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(i).toInt64()); + const ImplSmartTagLBUserData* pUserData = weld::fromId<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(i)); delete pUserData; } @@ -2243,7 +2257,7 @@ void OfaSmartTagOptionsTabPage::FillListBox( const SmartTagMgr& rSmartTagMgr ) const bool bCheck = rSmartTagMgr.IsSmartTagTypeEnabled( aSmartTagType ); m_xSmartTagTypesLB->set_toggle(nRow, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE); m_xSmartTagTypesLB->set_text(nRow, aLBEntry, 0); - m_xSmartTagTypesLB->set_id(nRow, OUString::number(reinterpret_cast<sal_Int64>(new ImplSmartTagLBUserData(aSmartTagType, xRec, j)))); + m_xSmartTagTypesLB->set_id(nRow, weld::toId(new ImplSmartTagLBUserData(aSmartTagType, xRec, j))); } } } @@ -2253,7 +2267,7 @@ void OfaSmartTagOptionsTabPage::FillListBox( const SmartTagMgr& rSmartTagMgr ) IMPL_LINK_NOARG(OfaSmartTagOptionsTabPage, ClickHdl, weld::Button&, void) { const int nPos = m_xSmartTagTypesLB->get_selected_index(); - const ImplSmartTagLBUserData* pUserData = reinterpret_cast<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(nPos).toInt64()); + const ImplSmartTagLBUserData* pUserData = weld::fromId<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(nPos)); uno::Reference< smarttags::XSmartTagRecognizer > xRec = pUserData->mxRec; const sal_Int32 nSmartTagIdx = pUserData->mnSmartTagIdx; @@ -2285,7 +2299,7 @@ IMPL_LINK_NOARG(OfaSmartTagOptionsTabPage, SelectHdl, weld::TreeView&, void) const int nPos = m_xSmartTagTypesLB->get_selected_index(); if (nPos == -1) return; - const ImplSmartTagLBUserData* pUserData = reinterpret_cast<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(nPos).toInt64()); + const ImplSmartTagLBUserData* pUserData = weld::fromId<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(nPos)); uno::Reference< smarttags::XSmartTagRecognizer > xRec = pUserData->mxRec; const sal_Int32 nSmartTagIdx = pUserData->mnSmartTagIdx; @@ -2315,7 +2329,7 @@ bool OfaSmartTagOptionsTabPage::FillItemSet( SfxItemSet* ) for (int i = 0; i < nCount; ++i) { - const ImplSmartTagLBUserData* pUserData = reinterpret_cast<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(i).toInt64()); + const ImplSmartTagLBUserData* pUserData = weld::fromId<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(i)); const bool bChecked = m_xSmartTagTypesLB->get_toggle(i) == TRISTATE_TRUE; const bool bIsCurrentlyEnabled = pSmartTagMgr->IsSmartTagTypeEnabled( pUserData->maSmartTagType ); diff --git a/cui/source/tabpages/backgrnd.cxx b/cui/source/tabpages/backgrnd.cxx index 7b06e9a86092..b10c6f79c304 100644 --- a/cui/source/tabpages/backgrnd.cxx +++ b/cui/source/tabpages/backgrnd.cxx @@ -36,7 +36,7 @@ using namespace css; #define TBL_DEST_ROW 1 #define TBL_DEST_TBL 2 -const WhichRangesContainer SvxBkgTabPage::pPageRanges(svl::Items< +const WhichRangesContainer SvxBkgTabPage::pBkgRanges(svl::Items< SID_ATTR_BRUSH, SID_ATTR_BRUSH, SID_ATTR_BRUSH_CHAR, SID_ATTR_BRUSH_CHAR >); @@ -63,32 +63,13 @@ static sal_uInt16 lcl_GetTableDestSlot(sal_Int32 nTblDest) SvxBkgTabPage::SvxBkgTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) : SvxAreaTabPage(pPage, pController, rInAttrs), - bHighlighting(false), - bCharBackColor(false), - maSet(rInAttrs) + m_aAttrSet(*rInAttrs.GetPool(), + rInAttrs.GetRanges().MergeRange(XATTR_FILL_FIRST, XATTR_FILL_LAST)) { m_xBtnGradient->hide(); m_xBtnHatch->hide(); m_xBtnBitmap->hide(); m_xBtnPattern->hide(); - - SfxObjectShell* pDocSh = SfxObjectShell::Current(); - - XColorListRef pColorTable; - if ( pDocSh ) - if (auto pItem = pDocSh->GetItem( SID_COLOR_TABLE )) - pColorTable = pItem->GetColorList(); - - if ( !pColorTable.is() ) - pColorTable = XColorList::CreateStdColorList(); - - XBitmapListRef pBitmapList; - if ( pDocSh ) - if (auto pItem = pDocSh->GetItem( SID_BITMAP_LIST ) ) - pBitmapList = pItem->GetBitmapList(); - - SetColorList(pColorTable); - SetBitmapList(pBitmapList); } SvxBkgTabPage::~SvxBkgTabPage() @@ -98,12 +79,12 @@ SvxBkgTabPage::~SvxBkgTabPage() void SvxBkgTabPage::ActivatePage( const SfxItemSet& ) { - SvxAreaTabPage::ActivatePage( maSet ); + SvxAreaTabPage::ActivatePage(m_aAttrSet); } DeactivateRC SvxBkgTabPage::DeactivatePage( SfxItemSet* _pSet ) { - if ( DeactivateRC::KeepPage == SvxAreaTabPage::DeactivatePage( &maSet ) ) + if (DeactivateRC::KeepPage == SvxAreaTabPage::DeactivatePage(&m_aAttrSet)) return DeactivateRC::KeepPage; if ( _pSet ) @@ -112,37 +93,49 @@ DeactivateRC SvxBkgTabPage::DeactivatePage( SfxItemSet* _pSet ) return DeactivateRC::LeavePage; } -void SvxBkgTabPage::Reset( const SfxItemSet* ) +void SvxBkgTabPage::Reset(const SfxItemSet* pItemSet) { - maSet.Set( *m_pResetSet ); - if ( m_xTblLBox && m_xTblLBox->get_visible() ) + if (m_xTblLBox && m_xTblLBox->get_visible()) { - m_nActPos = -1; - const SfxPoolItem* pItem; - if ( SfxItemState::SET == m_pResetSet->GetItemState( SID_BACKGRND_DESTINATION, false, &pItem ) ) + if (m_nActPos == -1) // initial reset { - sal_uInt16 nDestValue = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); - m_xTblLBox->set_active( nDestValue ); - TblDestinationHdl_Impl( *m_xTblLBox ); + m_nActPos = 0; + if (const SfxUInt16Item* pDestItem = pItemSet->GetItemIfSet(SID_BACKGRND_DESTINATION, false)) + m_nActPos = pDestItem->GetValue(); + m_xTblLBox->set_active(m_nActPos); } - m_xTblLBox->save_value(); + SetActiveTableDestinationBrushItem(); + return; + } + else if (m_bCharBackColor) + { + sal_uInt16 nWhich(pItemSet->GetPool()->GetWhichIDFromSlotID(SID_ATTR_CHAR_BACK_COLOR)); + Color aBackColor(static_cast<const SvxColorItem&>(pItemSet->Get(nWhich)).GetValue()); + SvxBrushItem aBrushItem(SvxBrushItem(aBackColor, SID_ATTR_BRUSH_CHAR)); + setSvxBrushItemAsFillAttributesToTargetSet(aBrushItem, m_aAttrSet); + } + else + { + sal_uInt16 nWhich(pItemSet->GetPool()->GetWhichIDFromSlotID(m_bHighlighting ? SID_ATTR_BRUSH_CHAR : SID_ATTR_BRUSH)); + SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(pItemSet->Get(nWhich))); + setSvxBrushItemAsFillAttributesToTargetSet(aBrushItem, m_aAttrSet); } - SvxAreaTabPage::Reset( &maSet ); + SvxAreaTabPage::Reset(&m_aAttrSet); } -bool SvxBkgTabPage::FillItemSet( SfxItemSet* rCoreSet ) +bool SvxBkgTabPage::FillItemSet(SfxItemSet* pCoreSet) { sal_uInt16 nSlot = SID_ATTR_BRUSH; if (m_xTblLBox && m_xTblLBox->get_visible()) nSlot = lcl_GetTableDestSlot(m_xTblLBox->get_active()); - else if ( bHighlighting ) + else if (m_bHighlighting) nSlot = SID_ATTR_BRUSH_CHAR; - else if( bCharBackColor ) + else if (m_bCharBackColor) nSlot = SID_ATTR_CHAR_BACK_COLOR; sal_uInt16 nWhich = GetWhich(nSlot); - drawing::FillStyle eFillType = maSet.Get( XATTR_FILLSTYLE ).GetValue(); + drawing::FillStyle eFillType = m_aAttrSet.Get(XATTR_FILLSTYLE).GetValue(); switch( eFillType ) { case drawing::FillStyle_NONE: @@ -151,76 +144,77 @@ bool SvxBkgTabPage::FillItemSet( SfxItemSet* rCoreSet ) { if ( SID_ATTR_CHAR_BACK_COLOR == nSlot ) { - maSet.Put( SvxColorItem( COL_TRANSPARENT, nWhich ) ); - rCoreSet->Put( SvxColorItem( COL_TRANSPARENT, nWhich ) ); + pCoreSet->Put(SvxColorItem(COL_TRANSPARENT, nWhich)); } else { - maSet.Put( SvxBrushItem( COL_TRANSPARENT, nWhich ) ); - rCoreSet->Put( SvxBrushItem( COL_TRANSPARENT, nWhich ) ); + pCoreSet->Put(SvxBrushItem(COL_TRANSPARENT, nWhich)); } } break; } case drawing::FillStyle_SOLID: { - XFillColorItem aColorItem( maSet.Get( XATTR_FILLCOLOR ) ); + XFillColorItem aColorItem(m_aAttrSet.Get(XATTR_FILLCOLOR)); + + // tdf#157801 - don't change direct formatting when color is unchanged + if (const SfxPoolItem* pOldItem = GetOldItem(*pCoreSet, nSlot)) + { + const SvxBrushItem* pOldBrushItem = static_cast<const SvxBrushItem*>(pOldItem); + if (pOldBrushItem->GetColor() == aColorItem.GetColorValue()) + break; + } + if ( SID_ATTR_CHAR_BACK_COLOR == nSlot ) { - maSet.Put( SvxColorItem( aColorItem.GetColorValue(), nWhich ) ); - rCoreSet->Put( SvxColorItem( aColorItem.GetColorValue(), nWhich ) ); + pCoreSet->Put(SvxColorItem(aColorItem.GetColorValue(), aColorItem.getComplexColor(), nWhich)); } else { - maSet.Put( SvxBrushItem( aColorItem.GetColorValue(), nWhich ) ); - rCoreSet->Put( SvxBrushItem( aColorItem.GetColorValue(), nWhich ) ); + pCoreSet->Put(SvxBrushItem(aColorItem.GetColorValue(), aColorItem.getComplexColor(), nWhich)); } break; } case drawing::FillStyle_BITMAP: { - std::unique_ptr<SvxBrushItem> aBrushItem( getSvxBrushItemFromSourceSet( maSet, nWhich ) ); + std::unique_ptr<SvxBrushItem> aBrushItem(getSvxBrushItemFromSourceSet(m_aAttrSet, nWhich)); if ( GraphicType::NONE != aBrushItem->GetGraphicObject()->GetType() ) - rCoreSet->Put( *aBrushItem ); + pCoreSet->Put(std::move(aBrushItem)); break; } default: break; } - if (m_xTblLBox && m_xTblLBox->get_visible()) + if (!m_xTblLBox || !m_xTblLBox->get_visible()) + return true; + + pCoreSet->Put(SfxUInt16Item(SID_BACKGRND_DESTINATION, m_xTblLBox->get_active())); + + // *Put* in the core set all table brushes that are *SET* in the m_aAttrSet + if (nSlot != SID_ATTR_BRUSH) { - if (nSlot != SID_ATTR_BRUSH) + nWhich = m_aAttrSet.GetPool()->GetWhichIDFromSlotID(SID_ATTR_BRUSH); + if (SfxItemState::SET == m_aAttrSet.GetItemState(nWhich)) { - nWhich = maSet.GetPool()->GetWhich(SID_ATTR_BRUSH); - if (SfxItemState::SET == maSet.GetItemState(nWhich)) - { - SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(maSet.Get(nWhich))); - rCoreSet->Put(aBrushItem); - } + SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(m_aAttrSet.Get(nWhich))); + pCoreSet->Put(aBrushItem); } - if (nSlot != SID_ATTR_BRUSH_ROW) - { - nWhich = maSet.GetPool()->GetWhich(SID_ATTR_BRUSH_ROW); - if (SfxItemState::SET == maSet.GetItemState(nWhich)) - { - SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(maSet.Get(nWhich))); - rCoreSet->Put(aBrushItem); - } - } - if (nSlot != SID_ATTR_BRUSH_TABLE) + } + if (nSlot != SID_ATTR_BRUSH_ROW) + { + if (SfxItemState::SET == m_aAttrSet.GetItemState(SID_ATTR_BRUSH_ROW)) { - nWhich = maSet.GetPool()->GetWhich(SID_ATTR_BRUSH_TABLE); - if (SfxItemState::SET == maSet.GetItemState(nWhich)) - { - SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(maSet.Get(nWhich))); - rCoreSet->Put(aBrushItem); - } + SvxBrushItem aBrushItem(m_aAttrSet.Get(SID_ATTR_BRUSH_ROW)); + pCoreSet->Put(aBrushItem); } - - if (m_xTblLBox->get_value_changed_from_saved()) + } + if (nSlot != SID_ATTR_BRUSH_TABLE) + { + if (SfxItemState::SET == m_aAttrSet.GetItemState(SID_ATTR_BRUSH_TABLE)) { - rCoreSet->Put(SfxUInt16Item(SID_BACKGRND_DESTINATION, m_xTblLBox->get_active())); + SvxBrushItem aBrushItem(m_aAttrSet.Get(SID_ATTR_BRUSH_TABLE)); + pCoreSet->Put(aBrushItem); } } @@ -250,89 +244,90 @@ void SvxBkgTabPage::PageCreated(const SfxAllItemSet& aSet) if ((nFlags & SvxBackgroundTabFlags::SHOW_HIGHLIGHTING) || (nFlags & SvxBackgroundTabFlags::SHOW_CHAR_BKGCOLOR)) { - bHighlighting = bool(nFlags & SvxBackgroundTabFlags::SHOW_HIGHLIGHTING); - bCharBackColor = bool(nFlags & SvxBackgroundTabFlags::SHOW_CHAR_BKGCOLOR); + m_bHighlighting = bool(nFlags & SvxBackgroundTabFlags::SHOW_HIGHLIGHTING); + m_bCharBackColor = bool(nFlags & SvxBackgroundTabFlags::SHOW_CHAR_BKGCOLOR); } if (nFlags & SvxBackgroundTabFlags::SHOW_SELECTOR) m_xBtnBitmap->show(); SetOptimalSize(GetDialogController()); } - if ( bCharBackColor ) + SfxObjectShell* pObjSh = SfxObjectShell::Current(); + + // we always have the color page + XColorListRef xColorTable; + if (pObjSh) { - sal_uInt16 nWhich(maSet.GetPool()->GetWhich(SID_ATTR_CHAR_BACK_COLOR)); - Color aBackColor(static_cast<const SvxColorItem&>(maSet.Get(nWhich)).GetValue()); - SvxBrushItem aBrushItem(SvxBrushItem(aBackColor, SID_ATTR_BRUSH_CHAR)); - setSvxBrushItemAsFillAttributesToTargetSet(aBrushItem, maSet); + const SvxColorListItem* pItem = pObjSh->GetItem(SID_COLOR_TABLE); + if (pItem) + xColorTable = pItem->GetColorList(); } - else + if (!xColorTable.is()) + xColorTable = XColorList::CreateStdColorList(); + SetColorList(xColorTable); + + // sometimes we have the bitmap page + if (m_xBtnBitmap->get_visible()) { - sal_uInt16 nWhich(maSet.GetPool()->GetWhich(bHighlighting ? SID_ATTR_BRUSH_CHAR : SID_ATTR_BRUSH)); - SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(maSet.Get(nWhich))); - setSvxBrushItemAsFillAttributesToTargetSet(aBrushItem, maSet); + XBitmapListRef xBitmapList; + if (pObjSh) + if (const SvxBitmapListItem* pItem = pObjSh->GetItem(SID_BITMAP_LIST)) + xBitmapList = pItem->GetBitmapList(); + SetBitmapList(xBitmapList); } - - m_pResetSet = maSet.Clone(); - - SvxAreaTabPage::PageCreated(aSet); } IMPL_LINK(SvxBkgTabPage, TblDestinationHdl_Impl, weld::ComboBox&, rBox, void) { - if (m_nActPos > -1) - { - // fill local item set with XATTR_FILL settings gathered from tab page - // and convert to SvxBrushItem and store in table destination slot Which - SvxAreaTabPage::FillItemSet(&maSet); - maSet.Put(*getSvxBrushItemFromSourceSet(maSet, maSet.GetPool()->GetWhich(lcl_GetTableDestSlot(m_nActPos)))); - } - sal_Int32 nSelPos = rBox.get_active(); + if (m_nActPos == nSelPos) return; + // Fill the local item set with XATTR_FILL settings gathered from the tab page, convert to + // SvxBrushItem and store in table destination slot Which. Do this so cell, row, and table + // brush items can be set together. + SvxAreaTabPage::FillItemSet(&m_aAttrSet); + m_aAttrSet.Put(getSvxBrushItemFromSourceSet(m_aAttrSet, GetWhich(lcl_GetTableDestSlot(m_nActPos)))); + m_nActPos = nSelPos; - // fill local item set with XATTR_FILL created from SvxBushItem for table destination slot Which - sal_uInt16 nWhich = maSet.GetPool()->GetWhich(lcl_GetTableDestSlot(nSelPos)); - if (SfxItemState::SET == maSet.GetItemState(nWhich)) + SetActiveTableDestinationBrushItem(); +} + +void SvxBkgTabPage::SetActiveTableDestinationBrushItem() +{ + // set the table destination (cell, row, table) brush item as a fill item in the local item set + sal_uInt16 nWhich = GetWhich(lcl_GetTableDestSlot(m_nActPos)); + if (SfxItemState::SET == GetItemSet().GetItemState(nWhich)) { - SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(maSet.Get(nWhich))); - setSvxBrushItemAsFillAttributesToTargetSet(aBrushItem, maSet); + SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(GetItemSet().Get(nWhich))); + setSvxBrushItemAsFillAttributesToTargetSet(aBrushItem, m_aAttrSet); } else { - SelectFillType(*m_xBtnNone, &maSet); + SelectFillType(*m_xBtnNone, &m_aAttrSet); return; } - // show tab page - drawing::FillStyle eXFS = drawing::FillStyle_NONE; - if (maSet.GetItemState(XATTR_FILLSTYLE) != SfxItemState::DONTCARE) - { - XFillStyleItem aFillStyleItem(static_cast<const XFillStyleItem&>(maSet.Get(GetWhich( XATTR_FILLSTYLE)))); - eXFS = aFillStyleItem.GetValue(); - } + XFillStyleItem aFillStyleItem(m_aAttrSet.Get(m_aAttrSet.GetPool()->GetWhichIDFromSlotID(XATTR_FILLSTYLE))); + drawing::FillStyle eXFS = aFillStyleItem.GetValue(); switch(eXFS) { default: case drawing::FillStyle_NONE: { - SelectFillType(*m_xBtnNone, &maSet); + SelectFillType(*m_xBtnNone, &m_aAttrSet); break; } case drawing::FillStyle_SOLID: { - SelectFillType(*m_xBtnColor, &maSet); - // color tab page Active and New preview controls are same after SelectFillType - // hack to restore color tab page Active preview - setSvxBrushItemAsFillAttributesToTargetSet(static_cast<const SvxBrushItem&>(m_pResetSet->Get(nWhich)), *m_pResetSet); - static_cast<SvxColorTabPage*>(GetFillTabPage())->SetCtlPreviewOld(*m_pResetSet); + SelectFillType(*m_xBtnColor, &m_aAttrSet); break; } case drawing::FillStyle_BITMAP: { - SelectFillType(*m_xBtnBitmap, &maSet); + SelectFillType(*m_xBtnBitmap, &m_aAttrSet); break; } } diff --git a/cui/source/tabpages/bbdlg.cxx b/cui/source/tabpages/bbdlg.cxx index 488fc5283a6b..9fc59604476e 100644 --- a/cui/source/tabpages/bbdlg.cxx +++ b/cui/source/tabpages/bbdlg.cxx @@ -33,8 +33,8 @@ SvxBorderBackgroundDlg::SvxBorderBackgroundDlg(weld::Window *pParent, ? OUString("cui/ui/borderareatransparencydialog.ui") : OUString("cui/ui/borderbackgrounddialog.ui"), bEnableDrawingLayerFillStyles - ? OString("BorderAreaTransparencyDialog") - : OString("BorderBackgroundDialog"), + ? OUString("BorderAreaTransparencyDialog") + : OUString("BorderBackgroundDialog"), &rCoreSet) , mbEnableBackgroundSelector(bEnableSelector) { @@ -51,7 +51,7 @@ SvxBorderBackgroundDlg::SvxBorderBackgroundDlg(weld::Window *pParent, } } -void SvxBorderBackgroundDlg::PageCreated(const OString& rPageId, SfxTabPage& rTabPage) +void SvxBorderBackgroundDlg::PageCreated(const OUString& rPageId, SfxTabPage& rTabPage) { if (rPageId == "background") { diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx index 64558279be60..ccb94fe46854 100644 --- a/cui/source/tabpages/border.cxx +++ b/cui/source/tabpages/border.cxx @@ -19,8 +19,6 @@ #include <sal/config.h> -#include <string_view> - #include <sfx2/objsh.hxx> #include <svx/strings.hrc> #include <svx/svxids.hrc> @@ -37,6 +35,7 @@ #include <vcl/fieldvalues.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> +#include <svx/dialmgr.hxx> #include <svx/flagsdef.hxx> #include <svl/grabbagitem.hxx> #include <svl/intitem.hxx> @@ -79,22 +78,19 @@ const WhichRangesContainer SvxBorderTabPage::pRanges( namespace { -int lcl_twipsToPt(sal_Int64 nTwips) +constexpr int twipsToPt100(sal_Int64 nTwips) { - return vcl::ConvertDoubleValue(nTwips, 0, FieldUnit::TWIP, MapUnit::MapPoint) * 100; + return o3tl::convert(nTwips * 100, o3tl::Length::twip, o3tl::Length::pt); } +constexpr int s_LineWidths[] = { twipsToPt100(SvxBorderLineWidth::Hairline), + twipsToPt100(SvxBorderLineWidth::VeryThin), + twipsToPt100(SvxBorderLineWidth::Thin), + twipsToPt100(SvxBorderLineWidth::Medium), + twipsToPt100(SvxBorderLineWidth::Thick), + twipsToPt100(SvxBorderLineWidth::ExtraThick), + -1 }; } -const std::vector<int> SvxBorderTabPage::m_aLineWidths = { - lcl_twipsToPt(SvxBorderLineWidth::Hairline), - lcl_twipsToPt(SvxBorderLineWidth::VeryThin), - lcl_twipsToPt(SvxBorderLineWidth::Thin), - lcl_twipsToPt(SvxBorderLineWidth::Medium), - lcl_twipsToPt(SvxBorderLineWidth::Thick), - lcl_twipsToPt(SvxBorderLineWidth::ExtraThick), - -1 -}; - static void lcl_SetDecimalDigitsTo1(weld::MetricSpinButton& rField) { auto nMin = rField.denormalize(rField.get_min(FieldUnit::TWIP)); @@ -140,10 +136,10 @@ static sal_Int64 lcl_GetMinLineWidth(SvxBorderLineStyle aStyle) } // number of preset images to show -const sal_uInt16 SVX_BORDER_PRESET_COUNT = 5; +const sal_uInt16 BORDER_PRESET_COUNT = 5; // number of shadow images to show -const sal_uInt16 SVX_BORDER_SHADOW_COUNT = 5; +const sal_uInt16 BORDER_SHADOW_COUNT = 5; ShadowControlsWrapper::ShadowControlsWrapper(ValueSet& rVsPos, weld::MetricSpinButton& rMfSize, ColorListBox& rLbColor) : mrVsPos(rVsPos) @@ -412,7 +408,7 @@ SvxBorderTabPage::SvxBorderTabPage(weld::Container* pPage, weld::DialogControlle for (auto const & rImageId : aShadowImageIds) m_aShadowImgVec.emplace_back(StockImage::Yes, rImageId); - assert(m_aShadowImgVec.size() == SVX_BORDER_SHADOW_COUNT); + assert(m_aShadowImgVec.size() == BORDER_SHADOW_COUNT); // this page needs ExchangeSupport SetExchangeSupport(); @@ -422,19 +418,16 @@ SvxBorderTabPage::SvxBorderTabPage(weld::Container* pPage, weld::DialogControlle is needed across various functions... */ mbUseMarginItem = rCoreAttrs.GetItemState(GetWhich(SID_ATTR_ALIGN_MARGIN)) != SfxItemState::UNKNOWN; - const SfxPoolItem* pItem = nullptr; - if (rCoreAttrs.HasItem(SID_ATTR_BORDER_STYLES, &pItem)) + if (const SfxIntegerListItem* p = rCoreAttrs.GetItemIfSet(SID_ATTR_BORDER_STYLES)) { - const SfxIntegerListItem* p = static_cast<const SfxIntegerListItem*>(pItem); std::vector<sal_Int32> aUsedStyles = p->GetList(); for (int aUsedStyle : aUsedStyles) maUsedBorderStyles.insert(static_cast<SvxBorderLineStyle>(aUsedStyle)); } - if (rCoreAttrs.HasItem(SID_ATTR_BORDER_DEFAULT_WIDTH, &pItem)) + if (const SfxInt64Item* p = rCoreAttrs.GetItemIfSet(SID_ATTR_BORDER_DEFAULT_WIDTH)) { // The caller specifies default line width. Honor it. - const SfxInt64Item* p = static_cast<const SfxInt64Item*>(pItem); SetLineWidth(p->GetValue()); } @@ -547,6 +540,7 @@ SvxBorderTabPage::SvxBorderTabPage(weld::Container* pPage, weld::DialogControlle SetLineWidth(m_xLineWidthMF->get_value(FieldUnit::NONE)); // connections + const SfxPoolItem* pItem = nullptr; if (rCoreAttrs.HasItem(GetWhich(SID_ATTR_PARA_GRABBAG), &pItem)) { const SfxGrabBagItem* pGrabBag = static_cast<const SfxGrabBagItem*>(pItem); @@ -577,8 +571,7 @@ SvxBorderTabPage::SvxBorderTabPage(weld::Container* pPage, weld::DialogControlle // checkbox "Merge adjacent line styles" only visible for Writer dialog format.table m_xMergeAdjacentBordersCB->hide(); - SfxObjectShell* pDocSh = SfxObjectShell::Current(); - if (pDocSh) + if (SfxObjectShell* pDocSh = SfxObjectShell::Current()) { Reference< XServiceInfo > xSI( pDocSh->GetModel(), UNO_QUERY ); if ( xSI.is() ) @@ -641,7 +634,7 @@ void SvxBorderTabPage::Reset( const SfxItemSet* rSet ) if (m_aFrameSel.IsBorderEnabled(svx::FrameBorderType::TLBR)) { - sal_uInt16 nBorderDiagId = pPool->GetWhich(SID_ATTR_BORDER_DIAG_TLBR); + sal_uInt16 nBorderDiagId = pPool->GetWhichIDFromSlotID(SID_ATTR_BORDER_DIAG_TLBR); if (const SvxLineItem* pLineItem = static_cast<const SvxLineItem*>(rSet->GetItem(nBorderDiagId))) m_aFrameSel.ShowBorder(svx::FrameBorderType::TLBR, pLineItem->GetLine()); else @@ -650,7 +643,7 @@ void SvxBorderTabPage::Reset( const SfxItemSet* rSet ) if (m_aFrameSel.IsBorderEnabled(svx::FrameBorderType::BLTR)) { - sal_uInt16 nBorderDiagId = pPool->GetWhich(SID_ATTR_BORDER_DIAG_BLTR); + sal_uInt16 nBorderDiagId = pPool->GetWhichIDFromSlotID(SID_ATTR_BORDER_DIAG_BLTR); if (const SvxLineItem* pLineItem = static_cast<const SvxLineItem*>(rSet->GetItem(nBorderDiagId))) m_aFrameSel.ShowBorder(svx::FrameBorderType::BLTR, pLineItem->GetLine()); else @@ -659,7 +652,7 @@ void SvxBorderTabPage::Reset( const SfxItemSet* rSet ) if (m_xShadowControls) { - sal_uInt16 nShadowId = pPool->GetWhich(mnShadowSlot); + sal_uInt16 nShadowId = pPool->GetWhichIDFromSlotID(mnShadowSlot); const SfxPoolItem* pItem = rSet->GetItem(nShadowId); if (pItem) m_xShadowControls->SetControlValue(*static_cast<const SvxShadowItem*>(pItem)); @@ -669,7 +662,7 @@ void SvxBorderTabPage::Reset( const SfxItemSet* rSet ) if (m_xMarginControls) { - sal_uInt16 nAlignMarginId = pPool->GetWhich(SID_ATTR_ALIGN_MARGIN); + sal_uInt16 nAlignMarginId = pPool->GetWhichIDFromSlotID(SID_ATTR_ALIGN_MARGIN); const SfxPoolItem* pItem = rSet->GetItem(nAlignMarginId); if (pItem) m_xMarginControls->SetControlValue(*static_cast<const SvxMarginItem*>(pItem)); @@ -677,7 +670,7 @@ void SvxBorderTabPage::Reset( const SfxItemSet* rSet ) m_xMarginControls->SetControlDontKnow(); } - sal_uInt16 nMergeAdjacentBordersId = pPool->GetWhich(SID_SW_COLLAPSING_BORDERS); + sal_uInt16 nMergeAdjacentBordersId = pPool->GetWhichIDFromSlotID(SID_SW_COLLAPSING_BORDERS); const SfxBoolItem *pMergeAdjacentBorders = static_cast<const SfxBoolItem*>(rSet->GetItem(nMergeAdjacentBordersId)); if (!pMergeAdjacentBorders) m_xMergeAdjacentBordersCB->set_state(TRISTATE_INDET); @@ -685,7 +678,7 @@ void SvxBorderTabPage::Reset( const SfxItemSet* rSet ) m_xMergeAdjacentBordersCB->set_active(pMergeAdjacentBorders->GetValue()); m_xMergeAdjacentBordersCB->save_state(); - sal_uInt16 nMergeWithNextId = pPool->GetWhich(SID_ATTR_BORDER_CONNECT); + sal_uInt16 nMergeWithNextId = pPool->GetWhichIDFromSlotID(SID_ATTR_BORDER_CONNECT); const SfxBoolItem *pMergeWithNext = static_cast<const SfxBoolItem*>(rSet->GetItem(nMergeWithNextId)); if (!pMergeWithNext) m_xMergeWithNextCB->set_state(TRISTATE_INDET); @@ -846,13 +839,15 @@ void SvxBorderTabPage::Reset( const SfxItemSet* rSet ) SelStyleHdl_Impl(*m_xLbLineStyle); } - const SfxPoolItem* pItem; - SfxObjectShell* pShell; - if(SfxItemState::SET == rSet->GetItemState(SID_HTML_MODE, false, &pItem) || - ( nullptr != (pShell = SfxObjectShell::Current()) && - nullptr != (pItem = pShell->GetItem(SID_HTML_MODE)))) + const SfxUInt16Item* pHtmlModeItem = rSet->GetItemIfSet(SID_HTML_MODE, false); + if(!pHtmlModeItem) + { + if (SfxObjectShell* pShell = SfxObjectShell::Current()) + pHtmlModeItem = pShell->GetItem(SID_HTML_MODE); + } + if(pHtmlModeItem) { - sal_uInt16 nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + sal_uInt16 nHtmlMode = pHtmlModeItem->GetValue(); if(nHtmlMode & HTMLMODE_ON) { // there are no shadows in Html-mode and only complete borders @@ -958,7 +953,7 @@ bool SvxBorderTabPage::FillItemSet( SfxItemSet* rCoreAttrs ) auto nState = m_xMergeAdjacentBordersCB->get_state(); if (nState == TRISTATE_INDET) { - sal_uInt16 nMergeAdjacentBordersId = pPool->GetWhich(SID_SW_COLLAPSING_BORDERS); + sal_uInt16 nMergeAdjacentBordersId = pPool->GetWhichIDFromSlotID(SID_SW_COLLAPSING_BORDERS); rCoreAttrs->ClearItem(nMergeAdjacentBordersId); } else @@ -978,7 +973,7 @@ bool SvxBorderTabPage::FillItemSet( SfxItemSet* rCoreAttrs ) auto nState = m_xMergeWithNextCB->get_state(); if (nState == TRISTATE_INDET) { - sal_uInt16 nMergeWithNextId = pPool->GetWhich(SID_ATTR_BORDER_CONNECT); + sal_uInt16 nMergeWithNextId = pPool->GetWhichIDFromSlotID(SID_ATTR_BORDER_CONNECT); rCoreAttrs->ClearItem(nMergeWithNextId); } else @@ -995,7 +990,7 @@ bool SvxBorderTabPage::FillItemSet( SfxItemSet* rCoreAttrs ) bool bPut = true; sal_uInt16 nBoxWhich = GetWhich( mnBoxSlot ); - sal_uInt16 nBoxInfoWhich = pPool->GetWhich( SID_ATTR_BORDER_INNER, false ); + sal_uInt16 nBoxInfoWhich = pPool->GetWhichIDFromSlotID( SID_ATTR_BORDER_INNER, false ); const SfxItemSet& rOldSet = GetItemSet(); SvxBoxItem aBoxItem ( nBoxWhich ); SvxBoxInfoItem aBoxInfoItem ( nBoxInfoWhich ); @@ -1236,15 +1231,19 @@ IMPL_LINK_NOARG(SvxBorderTabPage, SelSdwHdl_Impl, ValueSet*, void) IMPL_LINK(SvxBorderTabPage, SelColHdl_Impl, ColorListBox&, rColorBox, void) { - Color aColor = rColorBox.GetSelectEntryColor(); - m_aFrameSel.SetColorToSelection(aColor); + NamedColor aNamedColor = rColorBox.GetSelectedEntry(); + m_aFrameSel.SetColorToSelection(aNamedColor.m_aColor, aNamedColor.getComplexColor()); } IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthLBHdl_Impl, weld::ComboBox&, void) { sal_Int32 nPos = m_xLineWidthLB->get_active(); + sal_Int32 nRemovedType = 0; + if (m_xLineWidthLB->get_values_changed_from_saved()) { + nRemovedType = std::size(s_LineWidths) - m_xLineWidthLB->get_count(); + } - SetLineWidth(m_aLineWidths[nPos]); + SetLineWidth(s_LineWidths[nPos + nRemovedType], nRemovedType); // Call the spinner handler to trigger all related modifications ModifyWidthMFHdl_Impl(*m_xLineWidthMF); @@ -1253,6 +1252,13 @@ IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthLBHdl_Impl, weld::ComboBox&, void) IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthMFHdl_Impl, weld::MetricSpinButton&, void) { sal_Int64 nVal = m_xLineWidthMF->get_value(FieldUnit::NONE); + + // for DOUBLE_THIN line style we cannot allow thinner line width then 1.10pt + if (m_xLbLineStyle->GetSelectEntryStyle() == SvxBorderLineStyle::DOUBLE_THIN) + m_xLineWidthMF->set_min(110, FieldUnit::NONE); + else + m_xLineWidthMF->set_min(5, FieldUnit::NONE); + nVal = static_cast<sal_Int64>(vcl::ConvertDoubleValue( nVal, m_xLineWidthMF->get_digits(), @@ -1266,6 +1272,13 @@ IMPL_LINK_NOARG(SvxBorderTabPage, ModifyWidthMFHdl_Impl, weld::MetricSpinButton& IMPL_LINK_NOARG(SvxBorderTabPage, SelStyleHdl_Impl, SvtLineListBox&, void) { sal_Int64 nOldWidth = m_xLineWidthMF->get_value(FieldUnit::NONE); + + // for DOUBLE_THIN line style we cannot allow thinner line width then 1.10pt + if (m_xLbLineStyle->GetSelectEntryStyle() == SvxBorderLineStyle::DOUBLE_THIN) + m_xLineWidthMF->set_min(110, FieldUnit::NONE); + else + m_xLineWidthMF->set_min(5, FieldUnit::NONE); + nOldWidth = static_cast<sal_Int64>(vcl::ConvertDoubleValue( nOldWidth, m_xLineWidthMF->get_digits(), @@ -1277,7 +1290,14 @@ IMPL_LINK_NOARG(SvxBorderTabPage, SelStyleHdl_Impl, SvtLineListBox&, void) // auto change line-width if it doesn't correspond to minimal value // let's change only in case when user has not changed the line-width into some custom value - const sal_Int64 nNewWidth = (nOldMinWidth == nOldWidth)? nNewMinWidth : nOldWidth; + sal_Int64 nNewWidth = (nOldMinWidth == nOldWidth) ? nNewMinWidth : nOldWidth; + + // if we had selected a predefined border width under SvxBorderLineWidth::Medium set the Medium as default + // otherwise if we had a custom border width under 1.10pt then set the spinner to the maximum allowed value for double border styles + bool bNewDoubleHairline = m_xLbLineStyle->GetSelectEntryStyle() == SvxBorderLineStyle::DOUBLE_THIN && !m_xLineWidthMF->get_visible() && + (nOldWidth == SvxBorderLineWidth::Hairline || nOldWidth == SvxBorderLineWidth::VeryThin || nOldWidth == SvxBorderLineWidth::Thin); + if (bNewDoubleHairline && nNewWidth < SvxBorderLineWidth::Medium) + nNewWidth = SvxBorderLineWidth::Medium; // set value inside edit box if (nOldWidth != nNewWidth) @@ -1290,6 +1310,26 @@ IMPL_LINK_NOARG(SvxBorderTabPage, SelStyleHdl_Impl, SvtLineListBox&, void) SetLineWidth(nNewWidthPt); } + if (m_xLbLineStyle->GetSelectEntryStyle() == SvxBorderLineStyle::DOUBLE_THIN) + { + for (size_t i = 0; i < 3; i++) + { + m_xLineWidthLB->save_values_by_id(OUString::number(i)); + m_xLineWidthLB->remove_id(OUString::number(i)); + } + if (m_xLineWidthLB->get_active_id().isEmpty()) + m_xLineWidthLB->set_active_id("3"); + } + else + { + if (m_xLineWidthLB->get_values_changed_from_saved()) + { + for (size_t i = 0; i < 3; i++) + m_xLineWidthLB->append(i, OUString::number(i), m_xLineWidthLB->get_saved_values(i)); + m_xLineWidthLB->removeSavedValues(); + } + } + // set value inside style box m_aFrameSel.SetStyleToSelection( nNewWidth, m_xLbLineStyle->GetSelectEntryStyle() ); @@ -1300,7 +1340,7 @@ IMPL_LINK_NOARG(SvxBorderTabPage, SelStyleHdl_Impl, SvtLineListBox&, void) sal_uInt16 SvxBorderTabPage::GetPresetImageId( sal_uInt16 nValueSetIdx ) const { // table with all sets of predefined border styles - static const sal_uInt16 ppnImgIds[][ SVX_BORDER_PRESET_COUNT ] = + static const sal_uInt16 ppnImgIds[][ BORDER_PRESET_COUNT ] = { // simple cell without diagonal frame borders { IID_PRE_CELL_NONE, IID_PRE_CELL_ALL, IID_PRE_CELL_LR, IID_PRE_CELL_TB, IID_PRE_CELL_L }, @@ -1325,7 +1365,7 @@ sal_uInt16 SvxBorderTabPage::GetPresetImageId( sal_uInt16 nValueSetIdx ) const else nLine = 4; - DBG_ASSERT( (1 <= nValueSetIdx) && (nValueSetIdx <= SVX_BORDER_PRESET_COUNT), + DBG_ASSERT( (1 <= nValueSetIdx) && (nValueSetIdx <= BORDER_PRESET_COUNT), "SvxBorderTabPage::GetPresetImageId - wrong index" ); return ppnImgIds[ nLine ][ nValueSetIdx - 1 ]; } @@ -1367,14 +1407,14 @@ void SvxBorderTabPage::FillPresetVS() { // basic initialization of the ValueSet m_xWndPresets->SetStyle( m_xWndPresets->GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER ); - m_xWndPresets->SetColCount( SVX_BORDER_PRESET_COUNT ); + m_xWndPresets->SetColCount( BORDER_PRESET_COUNT ); // insert images and help texts - for( sal_uInt16 nVSIdx = 1; nVSIdx <= SVX_BORDER_PRESET_COUNT; ++nVSIdx ) + for( sal_uInt16 nVSIdx = 1; nVSIdx <= BORDER_PRESET_COUNT; ++nVSIdx ) { m_xWndPresets->InsertItem( nVSIdx ); m_xWndPresets->SetItemImage(nVSIdx, m_aBorderImgVec[GetPresetImageId(nVSIdx) - 1]); - m_xWndPresets->SetItemText( nVSIdx, CuiResId( GetPresetStringId( nVSIdx ) ) ); + m_xWndPresets->SetItemText( nVSIdx, SvxResId( GetPresetStringId( nVSIdx ) ) ); } // show the control @@ -1387,14 +1427,14 @@ void SvxBorderTabPage::FillShadowVS() { // basic initialization of the ValueSet m_xWndShadows->SetStyle( m_xWndShadows->GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER ); - m_xWndShadows->SetColCount( SVX_BORDER_SHADOW_COUNT ); + m_xWndShadows->SetColCount( BORDER_SHADOW_COUNT ); // string resource IDs for each image - static const TranslateId pnStrIds[ SVX_BORDER_SHADOW_COUNT ] = - { RID_SVXSTR_SHADOW_STYLE_NONE, RID_SVXSTR_SHADOW_STYLE_BOTTOMRIGHT, RID_SVXSTR_SHADOW_STYLE_TOPRIGHT, RID_SVXSTR_SHADOW_STYLE_BOTTOMLEFT, RID_SVXSTR_SHADOW_STYLE_TOPLEFT }; + static const TranslateId pnStrIds[ BORDER_SHADOW_COUNT ] = + { RID_CUISTR_SHADOW_STYLE_NONE, RID_CUISTR_SHADOW_STYLE_BOTTOMRIGHT, RID_CUISTR_SHADOW_STYLE_TOPRIGHT, RID_CUISTR_SHADOW_STYLE_BOTTOMLEFT, RID_CUISTR_SHADOW_STYLE_TOPLEFT }; // insert images and help texts - for( sal_uInt16 nVSIdx = 1; nVSIdx <= SVX_BORDER_SHADOW_COUNT; ++nVSIdx ) + for( sal_uInt16 nVSIdx = 1; nVSIdx <= BORDER_SHADOW_COUNT; ++nVSIdx ) { m_xWndShadows->InsertItem( nVSIdx ); m_xWndShadows->SetItemImage(nVSIdx, m_aShadowImgVec[nVSIdx-1]); @@ -1414,24 +1454,23 @@ void SvxBorderTabPage::FillValueSets() FillShadowVS(); } -void SvxBorderTabPage::SetLineWidth( sal_Int64 nWidth ) +void SvxBorderTabPage::SetLineWidth( sal_Int64 nWidth, sal_Int32 nRemovedType ) { if ( nWidth >= 0 ) m_xLineWidthMF->set_value( nWidth, FieldUnit::POINT ); - auto it = std::find_if( m_aLineWidths.begin(), m_aLineWidths.end(), - [nWidth](const int val) -> bool { return val == nWidth; } ); + auto it = std::find( std::begin(s_LineWidths), std::end(s_LineWidths), nWidth ); - if ( it != m_aLineWidths.end() && *it >= 0 ) + if ( it != std::end(s_LineWidths) && *it >= 0 ) { // Select predefined value in combobox m_xLineWidthMF->hide(); - m_xLineWidthLB->set_active(std::distance(m_aLineWidths.begin(), it)); + m_xLineWidthLB->set_active(std::distance(std::begin(s_LineWidths), it) - nRemovedType); } else { // This is not one of predefined values. Show spinner - m_xLineWidthLB->set_active(m_aLineWidths.size()-1); + m_xLineWidthLB->set_active(std::size(s_LineWidths) - nRemovedType -1); m_xLineWidthMF->show(); } } @@ -1478,7 +1517,7 @@ void SvxBorderTabPage::FillLineListBox_Impl() m_xLbLineStyle->SetSourceUnit( FieldUnit::TWIP ); - for (size_t i = 0; i < SAL_N_ELEMENTS(aLines); ++i) + for (size_t i = 0; i < std::size(aLines); ++i) { if (!IsBorderLineStyleAllowed(aLines[i].mnStyle)) continue; @@ -1603,7 +1642,7 @@ void SvxBorderTabPage::UpdateRemoveAdjCellBorderCB( sal_uInt16 nPreset ) // Check if current selection involves deletion of at least one border bool bBorderDeletionReq = false; - for ( size_t i=0; i < SAL_N_ELEMENTS( eTypes1 ); ++i ) + for ( size_t i=0; i < std::size( eTypes1 ); ++i ) { if( pOldBoxItem->GetLine( eTypes2[i] ) || !( pOldBoxInfoItem->IsValid( eTypes1[i].second ) ) ) { diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx index fef7b46fb537..cd6965375003 100644 --- a/cui/source/tabpages/chardlg.cxx +++ b/cui/source/tabpages/chardlg.cxx @@ -23,7 +23,6 @@ #include <sfx2/objsh.hxx> #include <svx/svxids.hrc> #include <svtools/unitconv.hxx> -#include <svl/languageoptions.hxx> #include <svl/cjkoptions.hxx> #include <svl/ctloptions.hxx> #include <chardlg.hxx> @@ -42,10 +41,11 @@ #include <editeng/kernitem.hxx> #include <editeng/flstitem.hxx> #include <editeng/autokernitem.hxx> +#include <editeng/nhypitem.hxx> #include <editeng/colritem.hxx> #include <dialmgr.hxx> #include <sfx2/htmlmode.hxx> -#include <cui/cuicharmap.hxx> +#include <svx/cuicharmap.hxx> #include "chardlg.h" #include <editeng/emphasismarkitem.hxx> #include <editeng/charreliefitem.hxx> @@ -63,6 +63,7 @@ #include <sal/log.hxx> #include <osl/diagnose.h> #include <o3tl/unit_conversion.hxx> +#include <o3tl/string_view.hxx> using namespace ::com::sun::star; @@ -132,7 +133,7 @@ inline SvxFont& SvxCharBasePage::GetPreviewCTLFont() return m_aPreviewWin.GetCTLFont(); } -SvxCharBasePage::SvxCharBasePage(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription, const OString& rID, const SfxItemSet& rItemset) +SvxCharBasePage::SvxCharBasePage(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription, const OUString& rID, const SfxItemSet& rItemset) : SfxTabPage(pPage, pController, rUIXMLDescription, rID, &rItemset) , m_bPreviewBackgroundToCharacter( false ) { @@ -190,84 +191,72 @@ struct SvxCharNamePage_Impl SvxCharNamePage::SvxCharNamePage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInSet) : SvxCharBasePage(pPage, pController, "cui/ui/charnamepage.ui", "CharNamePage", rInSet) , m_pImpl(new SvxCharNamePage_Impl) - , m_xEastFrame(m_xBuilder->weld_widget("asian")) - , m_xEastFontNameFT(m_xBuilder->weld_label("eastfontnameft")) - , m_xEastFontNameLB(m_xBuilder->weld_combo_box("eastfontnamelb")) - , m_xEastFontStyleFT(m_xBuilder->weld_label("eaststyleft")) - , m_xEastFontStyleLB(new FontStyleBox(m_xBuilder->weld_combo_box("eaststylelb"))) - , m_xEastFontSizeFT(m_xBuilder->weld_label("eastsizeft")) - , m_xEastFontSizeLB(new FontSizeBox(m_xBuilder->weld_combo_box("eastsizelb"))) - , m_xEastFontLanguageFT(m_xBuilder->weld_label("eastlangft")) - , m_xEastFontLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("eastlanglb"))) - , m_xEastFontTypeFT(m_xBuilder->weld_label("eastfontinfo")) - , m_xEastFontFeaturesButton(m_xBuilder->weld_button("east_features_button")) - , m_xCTLFrame(m_xBuilder->weld_widget("ctl")) - , m_xCTLFontNameFT(m_xBuilder->weld_label("ctlfontnameft")) - , m_xCTLFontNameLB(m_xBuilder->weld_combo_box("ctlfontnamelb")) - , m_xCTLFontStyleFT(m_xBuilder->weld_label("ctlstyleft")) - , m_xCTLFontStyleLB(new FontStyleBox(m_xBuilder->weld_combo_box("ctlstylelb"))) - , m_xCTLFontSizeFT(m_xBuilder->weld_label("ctlsizeft")) - , m_xCTLFontSizeLB(new FontSizeBox(m_xBuilder->weld_combo_box("ctlsizelb"))) - , m_xCTLFontLanguageFT(m_xBuilder->weld_label("ctllangft")) - , m_xCTLFontLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("ctllanglb"))) - , m_xCTLFontTypeFT(m_xBuilder->weld_label("ctlfontinfo")) - , m_xCTLFontFeaturesButton(m_xBuilder->weld_button("ctl_features_button")) - , m_xVDev(*Application::GetDefaultDevice(), DeviceFormat::DEFAULT, DeviceFormat::DEFAULT) + // Western + , m_xWestern(m_xBuilder->weld_notebook("nbWestern")) + , m_xWestFontNameFT(m_xBuilder->weld_label("lbWestFontname")) + , m_xWestFontStyleFT(m_xBuilder->weld_label("lbWestStyle")) + , m_xWestFontStyleLB(new FontStyleBox(m_xBuilder->weld_combo_box("cbWestStyle"))) + , m_xWestFontSizeFT(m_xBuilder->weld_label("lbWestSize")) + , m_xWestFontSizeLB(new FontSizeBox(m_xBuilder->weld_combo_box("cbWestSize"))) + , m_xWestFontLanguageFT(m_xBuilder->weld_label("lbWestLanguage")) + , m_xWestFontLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("cbWestLanguage"))) + , m_xWestFontFeaturesButton(m_xBuilder->weld_button("btnWestFeatures")) + , m_xWestFontTypeFT(m_xBuilder->weld_label("lbWestFontinfo")) + , m_xCJK_CTL(m_xBuilder->weld_notebook("nbCJKCTL")) + // CJK + , m_xEastFontNameFT(m_xBuilder->weld_label("lbCJKFontname")) + , m_xEastFontStyleFT(m_xBuilder->weld_label("lbCJKStyle")) + , m_xEastFontStyleLB(new FontStyleBox(m_xBuilder->weld_combo_box("cbCJKStyle"))) + , m_xEastFontSizeFT(m_xBuilder->weld_label("lbCJKSize")) + , m_xEastFontSizeLB(new FontSizeBox(m_xBuilder->weld_combo_box("cbCJKSize"))) + , m_xEastFontLanguageFT(m_xBuilder->weld_label("lbCJKLanguage")) + , m_xEastFontLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("cbCJKLanguage"))) + , m_xEastFontFeaturesButton(m_xBuilder->weld_button("btnCJKFeatures")) + , m_xEastFontTypeFT(m_xBuilder->weld_label("lbCJKFontinfo")) + // CTL + , m_xCTLFontNameFT(m_xBuilder->weld_label("lbCTLFontname")) + // tree + , m_xCTLFontStyleFT(m_xBuilder->weld_label("lbCTLStyle")) + , m_xCTLFontStyleLB(new FontStyleBox(m_xBuilder->weld_combo_box("cbCTLStyle"))) + , m_xCTLFontSizeFT(m_xBuilder->weld_label("lbCTLSize")) + , m_xCTLFontSizeLB(new FontSizeBox(m_xBuilder->weld_combo_box("cbCTLSize"))) + , m_xCTLFontLanguageFT(m_xBuilder->weld_label("lbCTLLanguage")) + , m_xCTLFontLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("cbCTLLanguage"))) + , m_xCTLFontFeaturesButton(m_xBuilder->weld_button("btnCTLFeatures")) + , m_xCTLFontTypeFT(m_xBuilder->weld_label("lbCTLFontinfo")) + + , m_xVDev(*Application::GetDefaultDevice(), DeviceFormat::WITH_ALPHA) { m_xPreviewWin.reset(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin)); #ifdef IOS m_xPreviewWin->hide(); #endif - m_pImpl->m_aNoStyleText = CuiResId( RID_SVXSTR_CHARNAME_NOSTYLE ); + m_pImpl->m_aNoStyleText = CuiResId( RID_CUISTR_CHARNAME_NOSTYLE ); - SvtCTLOptions aCTLLanguageOptions; - bool bShowCJK = SvtCJKOptions::IsCJKFontEnabled(); - bool bShowCTL = aCTLLanguageOptions.IsCTLFontEnabled(); - bool bShowNonWestern = bShowCJK || bShowCTL; - - if (bShowNonWestern) - { - m_xWestFrame = m_xBuilder->weld_widget("western"); - m_xWestFontNameFT = m_xBuilder->weld_label("westfontnameft-cjk"); - m_xWestFontNameLB = m_xBuilder->weld_combo_box("westfontnamelb-cjk"); - m_xWestFontStyleFT = m_xBuilder->weld_label("weststyleft-cjk"); - m_xWestFontSizeFT = m_xBuilder->weld_label("westsizeft-cjk"); + std::unique_ptr<weld::EntryTreeView> xWestFontName = m_xBuilder->weld_entry_tree_view("gdWestern", "edWestFontName", "trWestFontName"); + std::unique_ptr<weld::EntryTreeView> xCJKFontName = m_xBuilder->weld_entry_tree_view("gdCJK", "edCJKFontName", "trCJKFontName"); + std::unique_ptr<weld::EntryTreeView> xCTLFontName = m_xBuilder->weld_entry_tree_view("gdCTL", "edCTLFontName", "trCTLFontName"); - m_xWestFontStyleLB.reset(new FontStyleBox(m_xBuilder->weld_combo_box("weststylelb-cjk"))); - m_xWestFontSizeLB.reset(new FontSizeBox(m_xBuilder->weld_combo_box("westsizelb-cjk"))); + // 7 lines in the treeview + xWestFontName->set_height_request_by_rows(7); + xCJKFontName->set_height_request_by_rows(7); + xCTLFontName->set_height_request_by_rows(7); - m_xWestFontLanguageFT = m_xBuilder->weld_label("westlangft-cjk"); - m_xWestFontLanguageLB.reset(new SvxLanguageBox(m_xBuilder->weld_combo_box("westlanglb-cjk"))); - m_xWestFontTypeFT = m_xBuilder->weld_label("westfontinfo-cjk"); + m_xWestFontNameLB = std::move(xWestFontName); + m_xEastFontNameLB = std::move(xCJKFontName); + m_xCTLFontNameLB = std::move(xCTLFontName); - m_xWestFontFeaturesButton = m_xBuilder->weld_button("west_features_button-cjk"); - } - else + bool bShowCJK = SvtCJKOptions::IsCJKFontEnabled(); + bool bShowCTL = SvtCTLOptions::IsCTLFontEnabled(); + bool bShowNonWestern = bShowCJK || bShowCTL; + if (!bShowNonWestern) { - m_xWestFrame = m_xBuilder->weld_widget("simple"); - m_xWestFontNameFT = m_xBuilder->weld_label("westfontnameft-nocjk"); - m_xWestFontStyleFT = m_xBuilder->weld_label("weststyleft-nocjk"); - m_xWestFontSizeFT = m_xBuilder->weld_label("westsizeft-nocjk"); - - m_xWestFontLanguageFT = m_xBuilder->weld_label("westlangft-nocjk"); - m_xWestFontLanguageLB.reset(new SvxLanguageBox(m_xBuilder->weld_combo_box("westlanglb-nocjk"))); - m_xWestFontTypeFT = m_xBuilder->weld_label("westfontinfo-nocjk"); - - m_xWestFontFeaturesButton = m_xBuilder->weld_button("west_features_button-nocjk"); - - std::unique_ptr<weld::EntryTreeView> xWestFontNameLB = m_xBuilder->weld_entry_tree_view("namegrid", "westfontname-nocjk", "westfontnamelb-nocjk"); - std::unique_ptr<weld::EntryTreeView> xWestFontStyleLB = m_xBuilder->weld_entry_tree_view("stylegrid", "weststyle-nocjk", "weststylelb-nocjk"); - std::unique_ptr<weld::EntryTreeView> xWestFontSizeLB = m_xBuilder->weld_entry_tree_view("sizegrid", "westsize-nocjk", "westsizelb-nocjk"); - - // 7 lines in the treeview - xWestFontNameLB->set_height_request_by_rows(7); - xWestFontStyleLB->set_height_request_by_rows(7); - xWestFontSizeLB->set_height_request_by_rows(7); - - m_xWestFontNameLB = std::move(xWestFontNameLB); - m_xWestFontStyleLB.reset(new FontStyleBox(std::move(xWestFontStyleLB))); - m_xWestFontSizeLB.reset(new FontSizeBox(std::move(xWestFontSizeLB))); + m_xCJK_CTL->hide(); + m_xWestern->set_show_tabs(false); //hide single tab in case of Western only } + else if (!bShowCJK) m_xCJK_CTL->remove_page("nbCJK"); + else if (!bShowCTL) m_xCJK_CTL->remove_page("nbCTL"); + //In MacOSX the standard dialogs name font-name, font-style as //Family, Typeface @@ -276,33 +265,34 @@ SvxCharNamePage::SvxCharNamePage(weld::Container* pPage, weld::DialogController* //In Windows the standard dialogs name font-name, font-style as //Font, Style #ifdef _WIN32 - OUString sFontFamilyString(CuiResId(RID_SVXSTR_CHARNAME_FONT)); + OUString sFontFamilyString(CuiResId(RID_CUISTR_CHARNAME_FONT)); #else - OUString sFontFamilyString(CuiResId(RID_SVXSTR_CHARNAME_FAMILY)); + OUString sFontFamilyString(CuiResId(RID_CUISTR_CHARNAME_FAMILY)); #endif m_xWestFontNameFT->set_label(sFontFamilyString); - m_xEastFontNameFT->set_label(sFontFamilyString); m_xCTLFontNameFT->set_label(sFontFamilyString); + m_xEastFontNameFT->set_label(sFontFamilyString); #ifdef MACOSX - OUString sFontStyleString(CuiResId(RID_SVXSTR_CHARNAME_TYPEFACE)); + OUString sFontStyleString(CuiResId(RID_CUISTR_CHARNAME_TYPEFACE)); #else - OUString sFontStyleString(CuiResId(RID_SVXSTR_CHARNAME_STYLE)); + OUString sFontStyleString(CuiResId(RID_CUISTR_CHARNAME_STYLE)); #endif m_xWestFontStyleFT->set_label(sFontStyleString); m_xEastFontStyleFT->set_label(sFontStyleString); m_xCTLFontStyleFT->set_label(sFontStyleString); - m_xWestFrame->show(); - m_xEastFrame->set_visible(bShowCJK); - m_xCTLFrame->set_visible(bShowCTL); - m_xWestFontLanguageLB->SetLanguageList(SvxLanguageListFlags::WESTERN, true, false, true, true, - LANGUAGE_SYSTEM, css::i18n::ScriptType::LATIN); + LANGUAGE_SYSTEM, css::i18n::ScriptType::LATIN); m_xEastFontLanguageLB->SetLanguageList(SvxLanguageListFlags::CJK, true, false, true, true, - LANGUAGE_SYSTEM, css::i18n::ScriptType::ASIAN); + LANGUAGE_SYSTEM, css::i18n::ScriptType::ASIAN); m_xCTLFontLanguageLB->SetLanguageList(SvxLanguageListFlags::CTL, true, false, true, true, - LANGUAGE_SYSTEM, css::i18n::ScriptType::COMPLEX); + LANGUAGE_SYSTEM, css::i18n::ScriptType::COMPLEX); + int nVisibleChars = 15; + // read-only combobox / HasEntry asserts on set_width_char() + m_xWestFontLanguageLB->set_width_chars(nVisibleChars); + m_xEastFontLanguageLB->set_width_chars(nVisibleChars); + m_xCTLFontLanguageLB->set_width_chars(nVisibleChars); Initialize(); } @@ -354,10 +344,8 @@ const FontList* SvxCharNamePage::GetFontList() const { if ( !m_pImpl->m_pFontList ) { - SfxObjectShell* pDocSh = SfxObjectShell::Current(); - /* #110771# SvxFontListItem::GetFontList can return NULL */ - if ( pDocSh ) + if (SfxObjectShell* pDocSh = SfxObjectShell::Current()) { const SfxPoolItem* pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST ); if ( pItem != nullptr ) @@ -691,7 +679,7 @@ void SvxCharNamePage::Reset_Impl( const SfxItemSet& rSet, LanguageGroup eLangGrp eItalic = rItem.GetValue(); bStyle = true; } - bStyleAvailable = bStyleAvailable && (eState >= SfxItemState::DONTCARE); + bStyleAvailable = bStyleAvailable && (eState >= SfxItemState::INVALID); switch ( eLangGrp ) { @@ -708,7 +696,7 @@ void SvxCharNamePage::Reset_Impl( const SfxItemSet& rSet, LanguageGroup eLangGrp } else bStyle = false; - bStyleAvailable = bStyleAvailable && (eState >= SfxItemState::DONTCARE); + bStyleAvailable = bStyleAvailable && (eState >= SfxItemState::INVALID); // currently chosen font if ( bStyle && pFontItem ) @@ -804,7 +792,7 @@ void SvxCharNamePage::Reset_Impl( const SfxItemSet& rSet, LanguageGroup eLangGrp pLangBox->set_active_id(eLangType); break; } - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: break; } @@ -1072,31 +1060,40 @@ bool SvxCharNamePage::FillItemSet_Impl( SfxItemSet& rSet, LanguageGroup eLangGrp case Asian : nSlot = SID_ATTR_CHAR_CJK_LANGUAGE; break; case Ctl : nSlot = SID_ATTR_CHAR_CTL_LANGUAGE; break; } - nWhich = GetWhich( nSlot ); - pOld = GetOldItem( rSet, nSlot ); // For language list boxes acting as ComboBox, check for, add and select an // edited entry. - if (pLangBox == m_xWestFontLanguageLB.get()) + switch (pLangBox->GetEditedAndValid()) { - switch (pLangBox->GetEditedAndValid()) - { - case SvxLanguageBox::EditedAndValid::No: - ; // nothing to do - break; - case SvxLanguageBox::EditedAndValid::Valid: + case SvxLanguageBox::EditedAndValid::No: + ; // nothing to do + break; + case SvxLanguageBox::EditedAndValid::Valid: + { + SvxLanguageBox* ppBoxes[3] + = {m_xWestFontLanguageLB.get(), m_xEastFontLanguageLB.get(), m_xCTLFontLanguageLB.get()}; + SvxLanguageBox* pBox = pLangBox->SaveEditedAsEntry(ppBoxes); + if (pBox != pLangBox) { - const int nPos = pLangBox->SaveEditedAsEntry(); - if (nPos != -1) - pLangBox->set_active(nPos); + // Get item from corresponding slot. + if (pBox == m_xWestFontLanguageLB.get()) + nSlot = SID_ATTR_CHAR_LANGUAGE; + else if (pBox == m_xEastFontLanguageLB.get()) + nSlot = SID_ATTR_CHAR_CJK_LANGUAGE; + else if (pBox == m_xCTLFontLanguageLB.get()) + nSlot = SID_ATTR_CHAR_CTL_LANGUAGE; + pLangBox = pBox; } - break; - case SvxLanguageBox::EditedAndValid::Invalid: - pLangBox->set_active_id(pLangBox->get_saved_active_id()); - break; - } + } + break; + case SvxLanguageBox::EditedAndValid::Invalid: + pLangBox->set_active_id(pLangBox->get_saved_active_id()); + break; } + nWhich = GetWhich( nSlot ); + pOld = GetOldItem( rSet, nSlot ); + int nLangPos = pLangBox->get_active(); LanguageType eLangType = pLangBox->get_active_id(); @@ -1364,14 +1361,16 @@ void SvxCharEffectsPage::Initialize() SetExchangeSupport(); // HTML-Mode - const SfxPoolItem* pItem; - SfxObjectShell* pShell; - if ( SfxItemState::SET == GetItemSet().GetItemState( SID_HTML_MODE, false, &pItem ) || - ( nullptr != ( pShell = SfxObjectShell::Current() ) && - nullptr != ( pItem = pShell->GetItem( SID_HTML_MODE ) ) ) ) + const SfxUInt16Item* pHtmlModeItem = GetItemSet().GetItemIfSet( SID_HTML_MODE, false ); + if ( !pHtmlModeItem) + { + if (SfxObjectShell* pShell = SfxObjectShell::Current()) + pHtmlModeItem = pShell->GetItem( SID_HTML_MODE ); + } + if (pHtmlModeItem) { - m_nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); - if ( ( m_nHtmlMode & HTMLMODE_ON ) == HTMLMODE_ON ) + sal_uInt16 nHtmlMode = pHtmlModeItem->GetValue(); + if ( ( nHtmlMode & HTMLMODE_ON ) == HTMLMODE_ON ) { //!!! hide some controls please } @@ -1523,7 +1522,7 @@ void SvxCharEffectsPage::ResetColor_Impl( const SfxItemSet& rSet ) m_xFontColorLB->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: //Related: tdf#106080 if there is no font color, then allow "none" //as a color so the listbox can display that state. EnableNoneFontColor(); @@ -1573,28 +1572,31 @@ bool SvxCharEffectsPage::FillItemSetColor_Impl( SfxItemSet& rSet ) sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_COLOR ); const SfxItemSet& rOldSet = GetItemSet(); - Color aSelectedColor; + NamedColor aSelectedColor; bool bChanged = m_bNewFontColor; if (bChanged) { - aSelectedColor = m_xFontColorLB->GetSelectEntryColor(); + aSelectedColor = m_xFontColorLB->GetSelectedEntryThemedColor(); if (m_xFontTransparencyMtr->get_value_changed_from_saved()) { double fTransparency = m_xFontTransparencyMtr->get_value(FieldUnit::PERCENT) * 255.0 / 100; - aSelectedColor.SetAlpha(255 - static_cast<sal_uInt8>(basegfx::fround(fTransparency))); + aSelectedColor.m_aColor.SetAlpha(255 - static_cast<sal_uInt8>(basegfx::fround(fTransparency))); } if (m_bOrigFontColor) - bChanged = aSelectedColor != m_aOrigFontColor; - if (m_bEnableNoneFontColor && bChanged && aSelectedColor == COL_NONE_COLOR) + bChanged = aSelectedColor.m_aColor != m_aOrigFontColor; + if (m_bEnableNoneFontColor && bChanged && aSelectedColor.m_aColor == COL_NONE_COLOR) bChanged = false; } if (bChanged) - rSet.Put( SvxColorItem( aSelectedColor, nWhich ) ); + { + SvxColorItem aItem(aSelectedColor.m_aColor, aSelectedColor.getComplexColor(), nWhich); + rSet.Put(aItem); + } else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) ) rSet.InvalidateItem(nWhich); @@ -1687,9 +1689,9 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet ) m_xUnderlineLB->set_active( 0 ); SfxItemState eState = rSet->GetItemState( nWhich ); - if ( eState >= SfxItemState::DONTCARE ) + if ( eState >= SfxItemState::INVALID ) { - if ( eState == SfxItemState::DONTCARE ) + if ( eState == SfxItemState::INVALID ) m_xUnderlineLB->set_active(-1); else { @@ -1727,9 +1729,9 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet ) m_xOverlineLB->set_active( 0 ); eState = rSet->GetItemState( nWhich ); - if ( eState >= SfxItemState::DONTCARE ) + if ( eState >= SfxItemState::INVALID ) { - if ( eState == SfxItemState::DONTCARE ) + if ( eState == SfxItemState::INVALID ) m_xOverlineLB->set_active(-1); else { @@ -1767,9 +1769,9 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet ) m_xStrikeoutLB->set_active( 0 ); eState = rSet->GetItemState( nWhich ); - if ( eState >= SfxItemState::DONTCARE ) + if ( eState >= SfxItemState::INVALID ) { - if ( eState == SfxItemState::DONTCARE ) + if ( eState == SfxItemState::INVALID ) m_xStrikeoutLB->set_active(-1); else { @@ -1807,7 +1809,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet ) m_xIndividualWordsBtn->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_aIndividualWordsState.bTriStateEnabled = true; m_xIndividualWordsBtn->set_state( TRISTATE_INDET ); break; @@ -1849,7 +1851,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet ) if (nPos != -1) m_xPositionLB->set_active(nPos); } - else if ( eState == SfxItemState::DONTCARE ) + else if ( eState == SfxItemState::INVALID ) m_xEmphasisLB->set_active(-1); else if ( eState == SfxItemState::UNKNOWN ) { @@ -1884,7 +1886,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet ) m_xEffectsLB->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_xEffectsLB->set_active(-1); break; @@ -1913,7 +1915,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet ) m_xReliefLB->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_xReliefLB->set_active(-1); break; @@ -1942,7 +1944,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet ) m_xOutlineBtn->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_aOutlineState.bTriStateEnabled = true; m_xOutlineBtn->set_state(TRISTATE_INDET); break; @@ -1973,7 +1975,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet ) m_xShadowBtn->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_aShadowState.bTriStateEnabled = true; m_xShadowBtn->set_state( TRISTATE_INDET ); break; @@ -2004,7 +2006,7 @@ void SvxCharEffectsPage::Reset( const SfxItemSet* rSet ) m_xHiddenBtn->set_sensitive(false); break; - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: m_aHiddenState.bTriStateEnabled = true; m_xHiddenBtn->set_state(TRISTATE_INDET); break; @@ -2081,21 +2083,26 @@ bool SvxCharEffectsPage::FillItemSet( SfxItemSet* rSet ) //! item-state in the 'rOldSet' will be invalid. In this case //! changing the underline style will be allowed if a style is //! selected in the listbox. - bool bAllowChg = nPos != -1 && + bool bAllowChange = nPos != -1 && SfxItemState::DEFAULT > rOldSet.GetItemState( nWhich ); const SvxUnderlineItem& rItem = *static_cast<const SvxUnderlineItem*>(pOld); - if ( rItem.GetValue() == eUnder && - ( LINESTYLE_NONE == eUnder || rItem.GetColor() == m_xUnderlineColorLB->GetSelectEntryColor() ) && - ! bAllowChg ) + if (rItem.GetValue() == eUnder && + (LINESTYLE_NONE == eUnder || (rItem.GetColor() == m_xUnderlineColorLB->GetSelectEntryColor() && + rItem.getComplexColor() == m_xUnderlineColorLB->GetSelectedEntry().getComplexColor())) && + !bAllowChange) + { bChanged = false; + } } if ( bChanged ) { SvxUnderlineItem aNewItem( eUnder, nWhich ); - aNewItem.SetColor( m_xUnderlineColorLB->GetSelectEntryColor() ); - rSet->Put( aNewItem ); + auto aNamedColor = m_xUnderlineColorLB->GetSelectedEntry(); + aNewItem.SetColor(aNamedColor.m_aColor); + aNewItem.setComplexColor(aNamedColor.getComplexColor()); + rSet->Put(aNewItem); bModified = true; } else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) ) @@ -2115,21 +2122,26 @@ bool SvxCharEffectsPage::FillItemSet( SfxItemSet* rSet ) //! item-state in the 'rOldSet' will be invalid. In this case //! changing the underline style will be allowed if a style is //! selected in the listbox. - bool bAllowChg = nPos != -1 && + bool bAllowChange = nPos != -1 && SfxItemState::DEFAULT > rOldSet.GetItemState( nWhich ); const SvxOverlineItem& rItem = *static_cast<const SvxOverlineItem*>(pOld); - if ( rItem.GetValue() == eOver && - ( LINESTYLE_NONE == eOver || rItem.GetColor() == m_xOverlineColorLB->GetSelectEntryColor() ) && - ! bAllowChg ) + if (rItem.GetValue() == eOver && + (LINESTYLE_NONE == eOver || (rItem.GetColor() == m_xOverlineColorLB->GetSelectEntryColor() && + rItem.getComplexColor() == m_xOverlineColorLB->GetSelectedEntry().getComplexColor())) && + !bAllowChange) + { bChanged = false; + } } if ( bChanged ) { SvxOverlineItem aNewItem( eOver, nWhich ); - aNewItem.SetColor( m_xOverlineColorLB->GetSelectEntryColor() ); - rSet->Put( aNewItem ); + auto aNamedColor = m_xOverlineColorLB->GetSelectedEntry(); + aNewItem.SetColor(aNamedColor.m_aColor); + aNewItem.setComplexColor(aNamedColor.getComplexColor()); + rSet->Put(aNewItem); bModified = true; } else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) ) @@ -2211,7 +2223,7 @@ bool SvxCharEffectsPage::FillItemSet( SfxItemSet* rSet ) if ( pOld ) { - if( rOldSet.GetItemState( nWhich ) != SfxItemState::DONTCARE ) + if( rOldSet.GetItemState( nWhich ) != SfxItemState::INVALID ) { const SvxEmphasisMarkItem& rItem = *static_cast<const SvxEmphasisMarkItem*>(pOld); if ( rItem.GetEmphasisMark() == eMark ) @@ -2219,7 +2231,7 @@ bool SvxCharEffectsPage::FillItemSet( SfxItemSet* rSet ) } } - if (rOldSet.GetItemState( nWhich ) == SfxItemState::DONTCARE && + if (rOldSet.GetItemState( nWhich ) == SfxItemState::INVALID && m_xEmphasisLB->get_saved_value() == sMarkPos && m_xPositionLB->get_saved_value() == sPosPos) { bChanged = false; @@ -2227,7 +2239,7 @@ bool SvxCharEffectsPage::FillItemSet( SfxItemSet* rSet ) if (bChanged) { - rSet->Put( SvxEmphasisMarkItem( eMark, nWhich ) ); + rSet->Put( SvxEmphasisMarkItem( eMark, TypedWhichId<SvxEmphasisMarkItem>(nWhich) ) ); bModified = true; } else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) ) @@ -2378,10 +2390,7 @@ void SvxCharEffectsPage::PageCreated(const SfxAllItemSet& aSet) if (pDisableCtlItem) DisableControls(pDisableCtlItem->GetValue()); - if (!pFlagItem) - return; - - sal_uInt32 nFlags=pFlagItem->GetValue(); + sal_uInt32 nFlags = pFlagItem ? pFlagItem->GetValue() : 0; if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER ) // the writer uses SID_ATTR_BRUSH as font background m_bPreviewBackgroundToCharacter = true; @@ -2421,6 +2430,7 @@ SvxCharPositionPage::SvxCharPositionPage(weld::Container* pPage, weld::DialogCon , m_xScaleWidthMF(m_xBuilder->weld_metric_spin_button("scalewidthsb", FieldUnit::PERCENT)) , m_xKerningMF(m_xBuilder->weld_metric_spin_button("kerningsb", FieldUnit::POINT)) , m_xPairKerningBtn(m_xBuilder->weld_check_button("pairkerning")) + , m_xNoHyphenationBtn(m_xBuilder->weld_check_button("nohyphenation")) { m_xPreviewWin.reset(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin)); #ifdef IOS @@ -2636,10 +2646,10 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) if ( !sUser.isEmpty() ) { sal_Int32 nIdx {0}; - m_nSuperEsc = static_cast<short>(sUser.getToken( 0, ';', nIdx ).toInt32()); - m_nSubEsc = static_cast<short>(sUser.getToken( 0, ';', nIdx ).toInt32()); - m_nSuperProp = static_cast<sal_uInt8>(sUser.getToken( 0, ';', nIdx ).toInt32()); - m_nSubProp = static_cast<sal_uInt8>(sUser.getToken( 0, ';', nIdx ).toInt32()); + m_nSuperEsc = static_cast<short>(o3tl::toInt32(o3tl::getToken(sUser, 0, ';', nIdx ))); + m_nSubEsc = static_cast<short>(o3tl::toInt32(o3tl::getToken(sUser, 0, ';', nIdx ))); + m_nSuperProp = static_cast<sal_uInt8>(o3tl::toInt32(o3tl::getToken(sUser, 0, ';', nIdx ))); + m_nSubProp = static_cast<sal_uInt8>(o3tl::toInt32(o3tl::getToken(sUser, 0, ';', nIdx ))); m_xHighLowMF->set_max(MAX_ESC_POS, FieldUnit::PERCENT); @@ -2740,6 +2750,8 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) m_xHighPosBtn->set_active(false); m_xNormalPosBtn->set_active(false); m_xLowPosBtn->set_active(false); + + m_xHighLowRB->set_active(true); } // set BspFont @@ -2761,10 +2773,13 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) rCJKFont.SetFixKerning( static_cast<short>(nKern) ); rCTLFont.SetFixKerning( static_cast<short>(nKern) ); - //the attribute value must be displayed also if it's above the maximum allowed value + //the attribute value must be displayed also if it's above/below the maximum allowed value tools::Long nVal = static_cast<tools::Long>(m_xKerningMF->get_max(FieldUnit::POINT)); if(nVal < nKerning) m_xKerningMF->set_max(nKerning, FieldUnit::POINT); + nVal = static_cast<tools::Long>(m_xKerningMF->get_min(FieldUnit::POINT)); + if (nVal > nKerning) + m_xKerningMF->set_min(nKerning, FieldUnit::POINT); m_xKerningMF->set_value(nKerning, FieldUnit::POINT); } else @@ -2781,6 +2796,16 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) else m_xPairKerningBtn->set_active(false); + // No hyphenation + nWhich = GetWhich( sal_uInt16(19) ); // number borrowed from RES_CHRATR_NOHYPHEN + if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT ) + { + const SvxNoHyphenItem& rItem = static_cast<const SvxNoHyphenItem&>(rSet->Get( nWhich )); + m_xNoHyphenationBtn->set_active(rItem.GetValue()); + } + else + m_xNoHyphenationBtn->set_active(false); + // Scale Width nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH ); if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT ) @@ -2792,9 +2817,8 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) else m_xScaleWidthMF->set_value(100, FieldUnit::PERCENT); - nWhich = GetWhich( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE ); - if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT ) - m_nScaleWidthItemSetVal = static_cast<const SfxUInt16Item&>( rSet->Get( nWhich )).GetValue(); + if ( rSet->GetItemState( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE ) >= SfxItemState::DEFAULT ) + m_nScaleWidthItemSetVal = rSet->Get( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE ).GetValue(); // Rotation nWhich = GetWhich( SID_ATTR_CHAR_ROTATED ); @@ -2828,7 +2852,7 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) } else { - if( eState == SfxItemState::DONTCARE ) + if( eState == SfxItemState::INVALID ) { m_x0degRB->set_active(false); m_x90degRB->set_active(false); @@ -2842,8 +2866,8 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) m_xFitToLineCB->set_sensitive(!m_x0degRB->get_active()); // is this value set? - if( SfxItemState::UNKNOWN == rSet->GetItemState( GetWhich( - SID_ATTR_CHAR_WIDTH_FIT_TO_LINE ) )) + if( SfxItemState::UNKNOWN == rSet->GetItemState( + SID_ATTR_CHAR_WIDTH_FIT_TO_LINE )) m_xFitToLineCB->hide(); } ChangesApplied(); @@ -2862,6 +2886,7 @@ void SvxCharPositionPage::ChangesApplied() m_xScaleWidthMF->save_value(); m_xKerningMF->save_value(); m_xPairKerningBtn->save_state(); + m_xNoHyphenationBtn->save_state(); } bool SvxCharPositionPage::FillItemSet( SfxItemSet* rSet ) @@ -2951,11 +2976,23 @@ bool SvxCharPositionPage::FillItemSet( SfxItemSet* rSet ) else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) ) rSet->InvalidateItem(nWhich); + // No hyphenation + + nWhich = GetWhich( sal_uInt16(19) ); // number borrowed from RES_CHRATR_NOHYPHEN + + if (m_xNoHyphenationBtn->get_state_changed_from_saved()) + { + rSet->Put( SvxNoHyphenItem( m_xNoHyphenationBtn->get_active(), nWhich ) ); + bModified = true; + } + else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) ) + rSet->InvalidateItem(nWhich); + // Scale Width nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH ); if (m_xScaleWidthMF->get_value_changed_from_saved()) { - rSet->Put(SvxCharScaleWidthItem(static_cast<sal_uInt16>(m_xScaleWidthMF->get_value(FieldUnit::PERCENT)), nWhich)); + rSet->Put(SvxCharScaleWidthItem(static_cast<sal_uInt16>(m_xScaleWidthMF->get_value(FieldUnit::PERCENT)), TypedWhichId<SvxCharScaleWidthItem>(nWhich))); bModified = true; } else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) ) @@ -2968,7 +3005,7 @@ bool SvxCharPositionPage::FillItemSet( SfxItemSet* rSet ) m_x270degRB->get_state_changed_from_saved() || m_xFitToLineCB->get_state_changed_from_saved() ) { - SvxCharRotateItem aItem( 0_deg10, m_xFitToLineCB->get_active(), nWhich ); + SvxCharRotateItem aItem( 0_deg10, m_xFitToLineCB->get_active(), TypedWhichId<SvxCharRotateItem>(nWhich) ); if (m_x90degRB->get_active()) aItem.SetBottomToTop(); else if (m_x270degRB->get_active()) @@ -2985,7 +3022,7 @@ bool SvxCharPositionPage::FillItemSet( SfxItemSet* rSet ) void SvxCharPositionPage::FillUserData() { - static const OUStringLiteral cTok( u";" ); + static constexpr OUString cTok( u";"_ustr ); OUString sUser = OUString::number( m_nSuperEsc ) + cTok + OUString::number( m_nSubEsc ) + cTok + @@ -3017,9 +3054,9 @@ SvxCharTwoLinesPage::SvxCharTwoLinesPage(weld::Container* pPage, weld::DialogCon , m_xStartBracketLB(m_xBuilder->weld_tree_view("startbracket")) , m_xEndBracketLB(m_xBuilder->weld_tree_view("endbracket")) { - for (size_t i = 0; i < SAL_N_ELEMENTS(TWOLINE_OPEN); ++i) + for (size_t i = 0; i < std::size(TWOLINE_OPEN); ++i) m_xStartBracketLB->append(OUString::number(TWOLINE_OPEN[i].second), CuiResId(TWOLINE_OPEN[i].first)); - for (size_t i = 0; i < SAL_N_ELEMENTS(TWOLINE_CLOSE); ++i) + for (size_t i = 0; i < std::size(TWOLINE_CLOSE); ++i) m_xEndBracketLB->append(OUString::number(TWOLINE_CLOSE[i].second), CuiResId(TWOLINE_CLOSE[i].first)); m_xPreviewWin.reset(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin)); @@ -3153,7 +3190,7 @@ void SvxCharTwoLinesPage::Reset( const SfxItemSet* rSet ) sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_TWO_LINES ); SfxItemState eState = rSet->GetItemState( nWhich ); - if ( eState >= SfxItemState::DONTCARE ) + if ( eState >= SfxItemState::INVALID ) { const SvxTwoLinesItem& rItem = static_cast<const SvxTwoLinesItem&>(rSet->Get( nWhich )); m_xTwoLinesBtn->set_active(rItem.GetValue()); diff --git a/cui/source/tabpages/connect.cxx b/cui/source/tabpages/connect.cxx index 677613191130..b3d036d991f9 100644 --- a/cui/source/tabpages/connect.cxx +++ b/cui/source/tabpages/connect.cxx @@ -50,7 +50,7 @@ SvxConnectionDialog::SvxConnectionDialog(weld::Window* pParent, const SfxItemSet xPage->Construct(); SetTabPage(std::move(xPage)); - m_xDialog->set_title(CuiResId(RID_SVXSTR_CONNECTOR)); + m_xDialog->set_title(CuiResId(RID_CUISTR_CONNECTOR)); } /************************************************************************* @@ -118,6 +118,17 @@ SvxConnectionPage::~SvxConnectionPage() m_xCtlPreview.reset(); } +template<class T> +void SvxConnectionPage::SetMetricValueAndSave(const SfxItemSet* rAttrs, weld::MetricSpinButton& rField, TypedWhichId<T> nWhich) +{ + const SfxPoolItem* pItem = GetItem( *rAttrs, nWhich); + const SfxItemPool* pPool = rAttrs->GetPool(); + if( !pItem ) + pItem = &pPool->GetUserOrPoolDefaultItem( nWhich ); + SetMetricValue(rField, pItem->StaticWhichCast(nWhich).GetValue(), eUnit); + rField.save_value(); +} + /************************************************************************* |* |* reads passed Item-Set @@ -126,66 +137,35 @@ SvxConnectionPage::~SvxConnectionPage() void SvxConnectionPage::Reset( const SfxItemSet* rAttrs ) { - const SfxPoolItem* pItem = GetItem( *rAttrs, SDRATTR_EDGENODE1HORZDIST ); + const SfxPoolItem* pItem; const SfxItemPool* pPool = rAttrs->GetPool(); // SdrEdgeNode1HorzDistItem - if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_EDGENODE1HORZDIST ); - SetMetricValue(*m_xMtrFldHorz1, static_cast<const SdrEdgeNode1HorzDistItem*>(pItem)->GetValue(), - eUnit); - m_xMtrFldHorz1->save_value(); + SetMetricValueAndSave(rAttrs, *m_xMtrFldHorz1, SDRATTR_EDGENODE1HORZDIST); // SdrEdgeNode2HorzDistItem - pItem = GetItem( *rAttrs, SDRATTR_EDGENODE2HORZDIST ); - if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_EDGENODE2HORZDIST ); - SetMetricValue(*m_xMtrFldHorz2, static_cast<const SdrEdgeNode2HorzDistItem*>(pItem)->GetValue(), - eUnit); - m_xMtrFldHorz2->save_value(); + SetMetricValueAndSave(rAttrs, *m_xMtrFldHorz2, SDRATTR_EDGENODE2HORZDIST); // SdrEdgeNode1VertDistItem - pItem = GetItem( *rAttrs, SDRATTR_EDGENODE1VERTDIST ); - if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_EDGENODE1VERTDIST ); - SetMetricValue(*m_xMtrFldVert1, static_cast<const SdrEdgeNode1VertDistItem*>(pItem)->GetValue(), - eUnit); - m_xMtrFldVert1->save_value(); + SetMetricValueAndSave(rAttrs, *m_xMtrFldVert1, SDRATTR_EDGENODE1VERTDIST); // SdrEdgeNode2VertDistItem - pItem = GetItem( *rAttrs, SDRATTR_EDGENODE2VERTDIST ); - if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_EDGENODE2VERTDIST ); - SetMetricValue(*m_xMtrFldVert2, static_cast<const SdrEdgeNode2VertDistItem*>(pItem)->GetValue(), - eUnit); - m_xMtrFldVert2->save_value(); + SetMetricValueAndSave(rAttrs, *m_xMtrFldVert2, SDRATTR_EDGENODE2VERTDIST); // SdrEdgeLine1DeltaItem - pItem = GetItem( *rAttrs, SDRATTR_EDGELINE1DELTA ); - if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_EDGELINE1DELTA ); - SetMetricValue(*m_xMtrFldLine1, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit); - m_xMtrFldLine1->save_value(); + SetMetricValueAndSave(rAttrs, *m_xMtrFldLine1, SDRATTR_EDGELINE1DELTA); // SdrEdgeLine2DeltaItem - pItem = GetItem( *rAttrs, SDRATTR_EDGELINE2DELTA ); - if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_EDGELINE2DELTA ); - SetMetricValue(*m_xMtrFldLine2, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit); - m_xMtrFldLine2->save_value(); + SetMetricValueAndSave(rAttrs, *m_xMtrFldLine2, SDRATTR_EDGELINE2DELTA); // SdrEdgeLine3DeltaItem - pItem = GetItem( *rAttrs, SDRATTR_EDGELINE3DELTA ); - if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_EDGELINE3DELTA ); - SetMetricValue(*m_xMtrFldLine3, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit); - m_xMtrFldLine3->save_value(); + SetMetricValueAndSave(rAttrs, *m_xMtrFldLine3, SDRATTR_EDGELINE3DELTA); // SdrEdgeLineDeltaAnzItem pItem = GetItem( *rAttrs, SDRATTR_EDGELINEDELTACOUNT ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_EDGELINEDELTACOUNT ); - switch (static_cast<const SdrEdgeLineDeltaCountItem*>(pItem)->GetValue()) + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_EDGELINEDELTACOUNT ); + switch (pItem->StaticWhichCast(SDRATTR_EDGELINEDELTACOUNT).GetValue()) { case 0: m_xFtLine1->set_sensitive(false); @@ -207,9 +187,9 @@ void SvxConnectionPage::Reset( const SfxItemSet* rAttrs ) // SdrEdgeKindItem pItem = GetItem( *rAttrs, SDRATTR_EDGEKIND ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_EDGEKIND ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_EDGEKIND ); m_xLbType->set_active( - sal::static_int_cast<sal_uInt16>(static_cast<const SdrEdgeKindItem*>(pItem)->GetValue())); + sal::static_int_cast<sal_uInt16>(pItem->StaticWhichCast(SDRATTR_EDGEKIND).GetValue())); m_xLbType->save_value(); } @@ -394,8 +374,8 @@ void SvxConnectionPage::FillTypeLB() const SfxItemPool* pPool = rOutAttrs.GetPool(); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_EDGEKIND ); - const SdrEdgeKindItem* pEdgeKindItem = static_cast<const SdrEdgeKindItem*>(pItem); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_EDGEKIND ); + const SdrEdgeKindItem* pEdgeKindItem = &pItem->StaticWhichCast(SDRATTR_EDGEKIND); const sal_uInt16 nCount = pEdgeKindItem->GetValueCount(); for (sal_uInt16 i = 0; i < nCount; i++) { diff --git a/cui/source/tabpages/grfpage.cxx b/cui/source/tabpages/grfpage.cxx index 726b09647bc1..9e96fdbb603c 100644 --- a/cui/source/tabpages/grfpage.cxx +++ b/cui/source/tabpages/grfpage.cxx @@ -32,6 +32,7 @@ #include <svx/svxids.hrc> #include <strings.hrc> #include <vcl/fieldvalues.hxx> +#include <vcl/outdev.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> #include <svtools/unitconv.hxx> @@ -39,6 +40,7 @@ #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> #include <o3tl/unit_conversion.hxx> +#include <officecfg/Office/Common.hxx> constexpr auto CM_1_TO_TWIP = o3tl::convert(1, o3tl::Length::cm, o3tl::Length::twip); // 567 @@ -54,9 +56,10 @@ static int lcl_GetValue(const weld::MetricSpinButton& rMetric, FieldUnit eUnit) SvxGrfCropPage::SvxGrfCropPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet) : SfxTabPage(pPage, pController, "cui/ui/croppage.ui", "CropPage", &rSet) - , nOldWidth(0) - , nOldHeight(0) - , bSetOrigSize(false) + , m_nOldWidth(0) + , m_nOldHeight(0) + , m_bSetOrigSize(false) + , m_aPreferredDPI(0) , m_xCropFrame(m_xBuilder->weld_widget("cropframe")) , m_xZoomConstRB(m_xBuilder->weld_radio_button("keepscale")) , m_xSizeConstRB(m_xBuilder->weld_radio_button("keepsize")) @@ -73,6 +76,7 @@ SvxGrfCropPage::SvxGrfCropPage(weld::Container* pPage, weld::DialogController* p , m_xOrigSizeGrid(m_xBuilder->weld_widget("origsizegrid")) , m_xOrigSizeFT(m_xBuilder->weld_label("origsizeft")) , m_xOrigSizePB(m_xBuilder->weld_button("origsize")) + , m_xUncropPB(m_xBuilder->weld_button("uncrop")) , m_xExampleWN(new weld::CustomWeld(*m_xBuilder, "preview", m_aExampleWN)) { SetExchangeSupport(); @@ -102,6 +106,7 @@ SvxGrfCropPage::SvxGrfCropPage(weld::Container* pPage, weld::DialogController* p m_xBottomMF->connect_value_changed( aLk ); m_xOrigSizePB->connect_clicked(LINK(this, SvxGrfCropPage, OrigSizeHdl)); + m_xUncropPB->connect_clicked(LINK(this, SvxGrfCropPage, UncropHdl)); } SvxGrfCropPage::~SvxGrfCropPage() @@ -119,7 +124,7 @@ void SvxGrfCropPage::Reset( const SfxItemSet *rSet ) const SfxPoolItem* pItem; const SfxItemPool& rPool = *rSet->GetPool(); - if(SfxItemState::SET == rSet->GetItemState( rPool.GetWhich( + if(SfxItemState::SET == rSet->GetItemState( rPool.GetWhichIDFromSlotID( SID_ATTR_GRAF_KEEP_ZOOM ), true, &pItem )) { if( static_cast<const SfxBoolItem*>(pItem)->GetValue() ) @@ -129,7 +134,7 @@ void SvxGrfCropPage::Reset( const SfxItemSet *rSet ) m_xZoomConstRB->save_state(); } - sal_uInt16 nW = rPool.GetWhich( SID_ATTR_GRAF_CROP ); + sal_uInt16 nW = rPool.GetWhichIDFromSlotID( SID_ATTR_GRAF_CROP ); if( SfxItemState::SET == rSet->GetItemState( nW, true, &pItem)) { FieldUnit eUnit = MapToFieldUnit( rSet->GetPool()->GetMetric( nW )); @@ -159,55 +164,54 @@ void SvxGrfCropPage::Reset( const SfxItemSet *rSet ) m_xTopMF->save_value(); m_xBottomMF->save_value(); - nW = rPool.GetWhich( SID_ATTR_PAGE_SIZE ); + nW = rPool.GetWhichIDFromSlotID( SID_ATTR_PAGE_SIZE ); if ( SfxItemState::SET == rSet->GetItemState( nW, false, &pItem ) ) { // orientation and size from the PageItem FieldUnit eUnit = MapToFieldUnit( rSet->GetPool()->GetMetric( nW )); - aPageSize = static_cast<const SvxSizeItem*>(pItem)->GetSize(); + m_aPageSize = static_cast<const SvxSizeItem*>(pItem)->GetSize(); auto nMin = m_xWidthMF->normalize( 23 ); - auto nMax = m_xHeightMF->normalize(aPageSize.Height()); + auto nMax = m_xHeightMF->normalize(m_aPageSize.Height()); m_xHeightMF->set_range(nMin, nMax, eUnit); - nMax = m_xWidthMF->normalize(aPageSize.Width()); + nMax = m_xWidthMF->normalize(m_aPageSize.Width()); m_xWidthMF->set_range(nMin, nMax, eUnit); } else { - aPageSize = OutputDevice::LogicToLogic( + m_aPageSize = OutputDevice::LogicToLogic( Size( CM_1_TO_TWIP, CM_1_TO_TWIP ), MapMode( MapUnit::MapTwip ), MapMode( rSet->GetPool()->GetMetric( nW ) ) ); } bool bFound = false; - if( SfxItemState::SET == rSet->GetItemState( SID_ATTR_GRAF_GRAPHIC, false, &pItem ) ) + if( const SvxBrushItem* pGraphicItem = rSet->GetItemIfSet( SID_ATTR_GRAF_GRAPHIC, false ) ) { OUString referer; - SfxStringItem const * it = static_cast<SfxStringItem const *>( - rSet->GetItem(SID_REFERER)); + SfxStringItem const * it = rSet->GetItem(SID_REFERER); if (it != nullptr) { referer = it->GetValue(); } - const Graphic* pGrf = static_cast<const SvxBrushItem*>(pItem)->GetGraphic(referer); + const Graphic* pGrf = pGraphicItem->GetGraphic(referer); if( pGrf ) { - aOrigSize = GetGrfOrigSize( *pGrf ); - if (pGrf->GetType() == GraphicType::Bitmap && aOrigSize.Width() && aOrigSize.Height()) + m_aOrigSize = GetGrfOrigSize( *pGrf ); + if (pGrf->GetType() == GraphicType::Bitmap && m_aOrigSize.Width() && m_aOrigSize.Height()) { - aOrigPixelSize = pGrf->GetSizePixel(); + m_aOrigPixelSize = pGrf->GetSizePixel(); } - if( aOrigSize.Width() && aOrigSize.Height() ) + if( m_aOrigSize.Width() && m_aOrigSize.Height() ) { CalcMinMaxBorder(); m_aExampleWN.SetGraphic( *pGrf ); - m_aExampleWN.SetFrameSize( aOrigSize ); + m_aExampleWN.SetFrameSize( m_aOrigSize ); bFound = true; - if( !static_cast<const SvxBrushItem*>(pItem)->GetGraphicLink().isEmpty() ) - aGraphicName = static_cast<const SvxBrushItem*>(pItem)->GetGraphicLink(); + if( !pGraphicItem->GetGraphicLink().isEmpty() ) + m_aGraphicName = pGraphicItem->GetGraphicLink(); } } } @@ -223,21 +227,21 @@ bool SvxGrfCropPage::FillItemSet(SfxItemSet *rSet) if( m_xWidthMF->get_value_changed_from_saved() || m_xHeightMF->get_value_changed_from_saved() ) { - sal_uInt16 nW = rPool.GetWhich( SID_ATTR_GRAF_FRMSIZE ); + constexpr TypedWhichId<SvxSizeItem> nW = SID_ATTR_GRAF_FRMSIZE; FieldUnit eUnit = MapToFieldUnit( rSet->GetPool()->GetMetric( nW )); std::shared_ptr<SvxSizeItem> aSz(std::make_shared<SvxSizeItem>(nW)); // size could already have been set from another page const SfxItemSet* pExSet = GetDialogExampleSet(); - const SfxPoolItem* pItem = nullptr; - if( pExSet && SfxItemState::SET ==pExSet->GetItemState( nW, false, &pItem ) ) + const SvxSizeItem* pSizeItem = nullptr; + if( pExSet && (pSizeItem = pExSet->GetItemIfSet( nW, false )) ) { - aSz.reset(static_cast< SvxSizeItem*>(pItem->Clone())); + aSz.reset(pSizeItem->Clone()); } else { - aSz.reset(static_cast< SvxSizeItem*>(GetItemSet().Get(nW).Clone())); + aSz.reset(GetItemSet().Get(nW).Clone()); } Size aTmpSz( aSz->GetSize() ); @@ -251,16 +255,16 @@ bool SvxGrfCropPage::FillItemSet(SfxItemSet *rSet) bModified |= nullptr != rSet->Put( *aSz ); - if( bSetOrigSize ) + if (m_bSetOrigSize) { - bModified |= nullptr != rSet->Put( SvxSizeItem( rPool.GetWhich( + bModified |= nullptr != rSet->Put( SvxSizeItem( rPool.GetWhichIDFromSlotID( SID_ATTR_GRAF_FRMSIZE_PERCENT ), Size( 0, 0 )) ); } } if( m_xLeftMF->get_value_changed_from_saved() || m_xRightMF->get_value_changed_from_saved() || m_xTopMF->get_value_changed_from_saved() || m_xBottomMF->get_value_changed_from_saved() ) { - sal_uInt16 nW = rPool.GetWhich( SID_ATTR_GRAF_CROP ); + sal_uInt16 nW = rPool.GetWhichIDFromSlotID( SID_ATTR_GRAF_CROP ); FieldUnit eUnit = MapToFieldUnit( rSet->GetPool()->GetMetric( nW )); std::unique_ptr<SvxGrfCrop> pNew(static_cast<SvxGrfCrop*>(rSet->Get( nW ).Clone())); @@ -268,12 +272,12 @@ bool SvxGrfCropPage::FillItemSet(SfxItemSet *rSet) pNew->SetRight( lcl_GetValue( *m_xRightMF, eUnit ) ); pNew->SetTop( lcl_GetValue( *m_xTopMF, eUnit ) ); pNew->SetBottom( lcl_GetValue( *m_xBottomMF, eUnit ) ); - bModified |= nullptr != rSet->Put( *pNew ); + bModified |= nullptr != rSet->Put( std::move(pNew) ); } if( m_xZoomConstRB->get_state_changed_from_saved() ) { - bModified |= nullptr != rSet->Put( SfxBoolItem( rPool.GetWhich( + bModified |= nullptr != rSet->Put( SfxBoolItem( rPool.GetWhichIDFromSlotID( SID_ATTR_GRAF_KEEP_ZOOM), m_xZoomConstRB->get_active() ) ); } @@ -287,19 +291,23 @@ void SvxGrfCropPage::ActivatePage(const SfxItemSet& rSet) DBG_ASSERT( pPool, "Where is the pool?" ); #endif - bSetOrigSize = false; + auto& aProperties = getAdditionalProperties(); + auto aIterator = aProperties.find("PreferredDPI"); + if (aIterator != aProperties.end()) + m_aPreferredDPI = aIterator->second.get<sal_Int32>(); + + m_bSetOrigSize = false; // Size Size aSize; - const SfxPoolItem* pItem; - if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_GRAF_FRMSIZE, false, &pItem ) ) - aSize = static_cast<const SvxSizeItem*>(pItem)->GetSize(); + if( const SvxSizeItem* pFrmSizeItem = rSet.GetItemIfSet( SID_ATTR_GRAF_FRMSIZE, false ) ) + aSize = pFrmSizeItem->GetSize(); - nOldWidth = aSize.Width(); - nOldHeight = aSize.Height(); + m_nOldWidth = aSize.Width(); + m_nOldHeight = aSize.Height(); - auto nWidth = m_xWidthMF->normalize(nOldWidth); - auto nHeight = m_xHeightMF->normalize(nOldHeight); + auto nWidth = m_xWidthMF->normalize(m_nOldWidth); + auto nHeight = m_xHeightMF->normalize(m_nOldHeight); if (nWidth != m_xWidthMF->get_value(FieldUnit::TWIP)) m_xWidthMF->set_value(nWidth, FieldUnit::TWIP); @@ -309,29 +317,27 @@ void SvxGrfCropPage::ActivatePage(const SfxItemSet& rSet) m_xHeightMF->set_value(nHeight, FieldUnit::TWIP); m_xHeightMF->save_value(); - if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_GRAF_GRAPHIC, false, &pItem ) ) + if( const SvxBrushItem* pBrushItem = rSet.GetItemIfSet( SID_ATTR_GRAF_GRAPHIC, false ) ) { - const SvxBrushItem& rBrush = *static_cast<const SvxBrushItem*>(pItem); - if( !rBrush.GetGraphicLink().isEmpty() && - aGraphicName != rBrush.GetGraphicLink() ) - aGraphicName = rBrush.GetGraphicLink(); + if( !pBrushItem->GetGraphicLink().isEmpty() && + m_aGraphicName != pBrushItem->GetGraphicLink() ) + m_aGraphicName = pBrushItem->GetGraphicLink(); OUString referer; - SfxStringItem const * it = static_cast<SfxStringItem const *>( - rSet.GetItem(SID_REFERER)); + SfxStringItem const * it = rSet.GetItem(SID_REFERER); if (it != nullptr) { referer = it->GetValue(); } - const Graphic* pGrf = rBrush.GetGraphic(referer); + const Graphic* pGrf = pBrushItem->GetGraphic(referer); if( pGrf ) { m_aExampleWN.SetGraphic( *pGrf ); - aOrigSize = GetGrfOrigSize( *pGrf ); - if (pGrf->GetType() == GraphicType::Bitmap && aOrigSize.Width() > 1 && aOrigSize.Height() > 1) { - aOrigPixelSize = pGrf->GetSizePixel(); + m_aOrigSize = GetGrfOrigSize( *pGrf ); + if (pGrf->GetType() == GraphicType::Bitmap && m_aOrigSize.Width() > 1 && m_aOrigSize.Height() > 1) { + m_aOrigPixelSize = pGrf->GetSizePixel(); } - m_aExampleWN.SetFrameSize(aOrigSize); - GraphicHasChanged( aOrigSize.Width() && aOrigSize.Height() ); + m_aExampleWN.SetFrameSize(m_aOrigSize); + GraphicHasChanged( m_aOrigSize.Width() && m_aOrigSize.Height() ); CalcMinMaxBorder(); } else @@ -356,7 +362,7 @@ IMPL_LINK( SvxGrfCropPage, ZoomHdl, weld::MetricSpinButton&, rField, void ) { SfxItemPool* pPool = GetItemSet().GetPool(); DBG_ASSERT( pPool, "Where is the pool?" ); - FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich( + FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhichIDFromSlotID( SID_ATTR_GRAF_CROP ) ) ); if (&rField == m_xWidthZoomMF.get()) @@ -364,7 +370,7 @@ IMPL_LINK( SvxGrfCropPage, ZoomHdl, weld::MetricSpinButton&, rField, void ) tools::Long nLRBorders = lcl_GetValue(*m_xLeftMF, eUnit) +lcl_GetValue(*m_xRightMF, eUnit); m_xWidthMF->set_value( m_xWidthMF->normalize( - ((aOrigSize.Width() - nLRBorders) * rField.get_value(FieldUnit::NONE))/100), + ((m_aOrigSize.Width() - nLRBorders) * rField.get_value(FieldUnit::NONE))/100), eUnit); } else @@ -372,7 +378,7 @@ IMPL_LINK( SvxGrfCropPage, ZoomHdl, weld::MetricSpinButton&, rField, void ) tools::Long nULBorders = lcl_GetValue(*m_xTopMF, eUnit) +lcl_GetValue(*m_xBottomMF, eUnit); m_xHeightMF->set_value( m_xHeightMF->normalize( - ((aOrigSize.Height() - nULBorders ) * rField.get_value(FieldUnit::NONE))/100) , + ((m_aOrigSize.Height() - nULBorders ) * rField.get_value(FieldUnit::NONE))/100) , eUnit ); } } @@ -385,7 +391,7 @@ IMPL_LINK( SvxGrfCropPage, SizeHdl, weld::MetricSpinButton&, rField, void ) { SfxItemPool* pPool = GetItemSet().GetPool(); DBG_ASSERT( pPool, "Where is the pool?" ); - FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich( + FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhichIDFromSlotID( SID_ATTR_GRAF_CROP ) ) ); Size aSize( lcl_GetValue(*m_xWidthMF, eUnit), @@ -393,7 +399,7 @@ IMPL_LINK( SvxGrfCropPage, SizeHdl, weld::MetricSpinButton&, rField, void ) if(&rField == m_xWidthMF.get()) { - tools::Long nWidth = aOrigSize.Width() - + tools::Long nWidth = m_aOrigSize.Width() - ( lcl_GetValue(*m_xLeftMF, eUnit) + lcl_GetValue(*m_xRightMF, eUnit) ); if(!nWidth) @@ -403,7 +409,7 @@ IMPL_LINK( SvxGrfCropPage, SizeHdl, weld::MetricSpinButton&, rField, void ) } else { - tools::Long nHeight = aOrigSize.Height() - + tools::Long nHeight = m_aOrigSize.Height() - ( lcl_GetValue(*m_xTopMF, eUnit) + lcl_GetValue(*m_xBottomMF, eUnit)); if(!nHeight) @@ -421,7 +427,7 @@ IMPL_LINK( SvxGrfCropPage, CropModifyHdl, weld::MetricSpinButton&, rField, void { SfxItemPool* pPool = GetItemSet().GetPool(); DBG_ASSERT( pPool, "Where is the pool?" ); - FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich( + FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhichIDFromSlotID( SID_ATTR_GRAF_CROP ) ) ); bool bZoom = m_xZoomConstRB->get_active(); @@ -430,19 +436,19 @@ IMPL_LINK( SvxGrfCropPage, CropModifyHdl, weld::MetricSpinButton&, rField, void tools::Long nLeft = lcl_GetValue( *m_xLeftMF, eUnit ); tools::Long nRight = lcl_GetValue( *m_xRightMF, eUnit ); tools::Long nWidthZoom = static_cast<tools::Long>(m_xWidthZoomMF->get_value(FieldUnit::NONE)); - if (bZoom && nWidthZoom != 0 && ( ( ( aOrigSize.Width() - (nLeft + nRight )) * nWidthZoom ) - / 100 >= aPageSize.Width() ) ) + if (bZoom && nWidthZoom != 0 && ( ( ( m_aOrigSize.Width() - (nLeft + nRight )) * nWidthZoom ) + / 100 >= m_aPageSize.Width() ) ) { if (&rField == m_xLeftMF.get()) { - nLeft = aOrigSize.Width() - - ( aPageSize.Width() * 100 / nWidthZoom + nRight ); + nLeft = m_aOrigSize.Width() - + ( m_aPageSize.Width() * 100 / nWidthZoom + nRight ); m_xLeftMF->set_value( m_xLeftMF->normalize( nLeft ), eUnit ); } else { - nRight = aOrigSize.Width() - - ( aPageSize.Width() * 100 / nWidthZoom + nLeft ); + nRight = m_aOrigSize.Width() - + ( m_aPageSize.Width() * 100 / nWidthZoom + nLeft ); m_xRightMF->set_value( m_xRightMF->normalize( nRight ), eUnit ); } } @@ -467,20 +473,20 @@ IMPL_LINK( SvxGrfCropPage, CropModifyHdl, weld::MetricSpinButton&, rField, void tools::Long nTop = lcl_GetValue( *m_xTopMF, eUnit ); tools::Long nBottom = lcl_GetValue( *m_xBottomMF, eUnit ); tools::Long nHeightZoom = static_cast<tools::Long>(m_xHeightZoomMF->get_value(FieldUnit::NONE)); - if(bZoom && ( ( ( aOrigSize.Height() - (nTop + nBottom )) * nHeightZoom) - / 100 >= aPageSize.Height())) + if(bZoom && ( ( ( m_aOrigSize.Height() - (nTop + nBottom )) * nHeightZoom) + / 100 >= m_aPageSize.Height())) { assert(nHeightZoom && "div-by-zero"); if(&rField == m_xTopMF.get()) { - nTop = aOrigSize.Height() - - ( aPageSize.Height() * 100 / nHeightZoom + nBottom); + nTop = m_aOrigSize.Height() - + ( m_aPageSize.Height() * 100 / nHeightZoom + nBottom); m_xTopMF->set_value( m_xWidthMF->normalize( nTop ), eUnit ); } else { - nBottom = aOrigSize.Height() - - ( aPageSize.Height() * 100 / nHeightZoom + nTop); + nBottom = m_aOrigSize.Height() - + ( m_aPageSize.Height() * 100 / nHeightZoom + nTop); m_xBottomMF->set_value( m_xWidthMF->normalize( nBottom ), eUnit ); } } @@ -506,21 +512,47 @@ IMPL_LINK_NOARG(SvxGrfCropPage, OrigSizeHdl, weld::Button&, void) { SfxItemPool* pPool = GetItemSet().GetPool(); DBG_ASSERT( pPool, "Where is the pool?" ); - FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich( + FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhichIDFromSlotID( SID_ATTR_GRAF_CROP ) ) ); - tools::Long nWidth = aOrigSize.Width() - + tools::Long nWidth = m_aOrigSize.Width() - lcl_GetValue( *m_xLeftMF, eUnit ) - lcl_GetValue( *m_xRightMF, eUnit ); m_xWidthMF->set_value( m_xWidthMF->normalize( nWidth ), eUnit ); - tools::Long nHeight = aOrigSize.Height() - + tools::Long nHeight = m_aOrigSize.Height() - lcl_GetValue( *m_xTopMF, eUnit ) - lcl_GetValue( *m_xBottomMF, eUnit ); m_xHeightMF->set_value( m_xHeightMF->normalize( nHeight ), eUnit ); m_xWidthZoomMF->set_value(100, FieldUnit::NONE); m_xHeightZoomMF->set_value(100, FieldUnit::NONE); - bSetOrigSize = true; + m_bSetOrigSize = true; } + +/*-------------------------------------------------------------------- + description: reset crop + --------------------------------------------------------------------*/ + +IMPL_LINK_NOARG(SvxGrfCropPage, UncropHdl, weld::Button&, void) +{ + SfxItemPool* pPool = GetItemSet().GetPool(); + DBG_ASSERT( pPool, "Where is the pool?" ); + + m_xLeftMF->set_value(0, FieldUnit::NONE); + m_xRightMF->set_value(0, FieldUnit::NONE); + m_xTopMF->set_value(0, FieldUnit::NONE); + m_xBottomMF->set_value(0, FieldUnit::NONE); + + m_aExampleWN.SetLeft(0); + m_aExampleWN.SetRight(0); + m_aExampleWN.SetTop(0); + m_aExampleWN.SetBottom(0); + + m_aExampleWN.Invalidate(); + CalcMinMaxBorder(); + +} + + /*-------------------------------------------------------------------- description: compute scale --------------------------------------------------------------------*/ @@ -529,7 +561,7 @@ void SvxGrfCropPage::CalcZoom() { SfxItemPool* pPool = GetItemSet().GetPool(); DBG_ASSERT( pPool, "Where is the pool?" ); - FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich( + FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhichIDFromSlotID( SID_ATTR_GRAF_CROP ) ) ); tools::Long nWidth = lcl_GetValue( *m_xWidthMF, eUnit ); @@ -540,10 +572,10 @@ void SvxGrfCropPage::CalcZoom() lcl_GetValue( *m_xBottomMF, eUnit ); sal_uInt16 nZoom = 0; tools::Long nDen; - if( (nDen = aOrigSize.Width() - nLRBorders) > 0) + if( (nDen = m_aOrigSize.Width() - nLRBorders) > 0) nZoom = static_cast<sal_uInt16>((( nWidth * 1000 / nDen )+5)/10); m_xWidthZoomMF->set_value(nZoom, FieldUnit::NONE); - if( (nDen = aOrigSize.Height() - nULBorders) > 0) + if( (nDen = m_aOrigSize.Height() - nULBorders) > 0) nZoom = static_cast<sal_uInt16>((( nHeight * 1000 / nDen )+5)/10); else nZoom = 0; @@ -558,10 +590,10 @@ void SvxGrfCropPage::CalcMinMaxBorder() { SfxItemPool* pPool = GetItemSet().GetPool(); DBG_ASSERT( pPool, "Where is the pool?" ); - FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich( + FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhichIDFromSlotID( SID_ATTR_GRAF_CROP ) ) ); tools::Long nR = lcl_GetValue(*m_xRightMF, eUnit ); - tools::Long nMinWidth = (aOrigSize.Width() * 10) /11; + tools::Long nMinWidth = (m_aOrigSize.Width() * 10) /11; tools::Long nMin = nMinWidth - (nR >= 0 ? nR : 0); m_xLeftMF->set_max( m_xLeftMF->normalize(nMin), eUnit ); @@ -570,7 +602,7 @@ void SvxGrfCropPage::CalcMinMaxBorder() m_xRightMF->set_max( m_xRightMF->normalize(nMin), eUnit ); tools::Long nUp = lcl_GetValue( *m_xTopMF, eUnit ); - tools::Long nMinHeight = (aOrigSize.Height() * 10) /11; + tools::Long nMinHeight = (m_aOrigSize.Height() * 10) /11; nMin = nMinHeight - (nUp >= 0 ? nUp : 0); m_xBottomMF->set_max( m_xBottomMF->normalize(nMin), eUnit ); @@ -589,19 +621,19 @@ void SvxGrfCropPage::GraphicHasChanged( bool bFound ) { SfxItemPool* pPool = GetItemSet().GetPool(); DBG_ASSERT( pPool, "Where is the pool?" ); - FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich( + FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhichIDFromSlotID( SID_ATTR_GRAF_CROP ) )); - sal_Int64 nSpin = m_xLeftMF->normalize(aOrigSize.Width()) / 20; - nSpin = vcl::ConvertValue( nSpin, aOrigSize.Width(), 0, + sal_Int64 nSpin = m_xLeftMF->normalize(m_aOrigSize.Width()) / 20; + nSpin = vcl::ConvertValue( nSpin, m_aOrigSize.Width(), 0, eUnit, m_xLeftMF->get_unit()); // if the margin is too big, it is set to 1/3 on both pages tools::Long nR = lcl_GetValue( *m_xRightMF, eUnit ); tools::Long nL = lcl_GetValue( *m_xLeftMF, eUnit ); - if((nL + nR) < - aOrigSize.Width()) + if((nL + nR) < - m_aOrigSize.Width()) { - tools::Long nVal = aOrigSize.Width() / -3; + tools::Long nVal = m_aOrigSize.Width() / -3; m_xRightMF->set_value( m_xRightMF->normalize( nVal ), eUnit ); m_xLeftMF->set_value( m_xLeftMF->normalize( nVal ), eUnit ); m_aExampleWN.SetLeft(nVal); @@ -609,9 +641,9 @@ void SvxGrfCropPage::GraphicHasChanged( bool bFound ) } tools::Long nUp = lcl_GetValue(*m_xTopMF, eUnit ); tools::Long nLow = lcl_GetValue(*m_xBottomMF, eUnit ); - if((nUp + nLow) < - aOrigSize.Height()) + if((nUp + nLow) < - m_aOrigSize.Height()) { - tools::Long nVal = aOrigSize.Height() / -3; + tools::Long nVal = m_aOrigSize.Height() / -3; m_xTopMF->set_value( m_xTopMF->normalize( nVal ), eUnit ); m_xBottomMF->set_value( m_xBottomMF->normalize( nVal ), eUnit ); m_aExampleWN.SetTop(nVal); @@ -620,8 +652,8 @@ void SvxGrfCropPage::GraphicHasChanged( bool bFound ) m_xLeftMF->set_increments(nSpin, nSpin * 10, FieldUnit::NONE); m_xRightMF->set_increments(nSpin, nSpin * 10, FieldUnit::NONE); - nSpin = m_xTopMF->normalize(aOrigSize.Height()) / 20; - nSpin = vcl::ConvertValue( nSpin, aOrigSize.Width(), 0, + nSpin = m_xTopMF->normalize(m_aOrigSize.Height()) / 20; + nSpin = vcl::ConvertValue( nSpin, m_aOrigSize.Width(), 0, eUnit, m_xLeftMF->get_unit() ); m_xTopMF->set_increments(nSpin, nSpin * 10, FieldUnit::NONE); m_xBottomMF->set_increments(nSpin, nSpin * 10, FieldUnit::NONE); @@ -638,26 +670,27 @@ void SvxGrfCropPage::GraphicHasChanged( bool bFound ) xFld->set_digits(m_xWidthMF->get_digits()); xFld->set_max(INT_MAX - 1, FieldUnit::NONE); - xFld->set_value(xFld->normalize(aOrigSize.Width()), eUnit); + xFld->set_value(xFld->normalize(m_aOrigSize.Width()), eUnit); sTemp = xFld->get_text(); - xFld->set_value(xFld->normalize(aOrigSize.Height()), eUnit); + xFld->set_value(xFld->normalize(m_aOrigSize.Height()), eUnit); // multiplication sign (U+00D7) sTemp += u"\u00D7" + xFld->get_text(); } - if ( aOrigPixelSize.Width() && aOrigPixelSize.Height() ) { - sal_Int32 ax = 0.5 + aOrigPixelSize.Width() / - o3tl::convert<double>(aOrigSize.Width(), o3tl::Length::twip, + if ( m_aOrigPixelSize.Width() && m_aOrigPixelSize.Height() ) { + sal_Int32 ax = 0.5 + m_aOrigPixelSize.Width() / + o3tl::convert<double>(m_aOrigSize.Width(), o3tl::Length::twip, o3tl::Length::in); - sal_Int32 ay = 0.5 + aOrigPixelSize.Height() / - o3tl::convert<double>(aOrigSize.Height(), o3tl::Length::twip, + sal_Int32 ay = 0.5 + m_aOrigPixelSize.Height() / + o3tl::convert<double>(m_aOrigSize.Height(), o3tl::Length::twip, o3tl::Length::in); OUString sPPI = OUString::number(ax); if (abs(ax - ay) > 1) { sPPI += u"\u00D7" + OUString::number(ay); } - sTemp += " " + CuiResId(RID_SVXSTR_PPI).replaceAll("%1", sPPI); + sTemp += " " + CuiResId(RID_CUISTR_PPI).replaceAll("%1", sPPI); } + sTemp += "\n" + OUString::number(m_aOrigPixelSize.Width()) + u"\u00D7" + OUString::number(m_aOrigPixelSize.Height()) + " px"; m_xOrigSizeFT->set_label(sTemp); } @@ -670,13 +703,27 @@ void SvxGrfCropPage::GraphicHasChanged( bool bFound ) Size SvxGrfCropPage::GetGrfOrigSize(const Graphic& rGrf) { - const MapMode aMapTwip( MapUnit::MapTwip ); - Size aSize( rGrf.GetPrefSize() ); - if( MapUnit::MapPixel == rGrf.GetPrefMapMode().GetMapUnit() ) - aSize = Application::GetDefaultDevice()->PixelToLogic(aSize, aMapTwip); + Size aSize; + + if (m_aPreferredDPI > 0) + { + Size aPixelSize = rGrf.GetSizePixel(); + double fWidth = aPixelSize.Width() / double(m_aPreferredDPI); + double fHeight = aPixelSize.Height() / double(m_aPreferredDPI); + fWidth = o3tl::convert(fWidth, o3tl::Length::in, o3tl::Length::twip); + fHeight = o3tl::convert(fHeight, o3tl::Length::in, o3tl::Length::twip); + aSize = Size(fWidth, fHeight); + } else - aSize = OutputDevice::LogicToLogic( aSize, - rGrf.GetPrefMapMode(), aMapTwip ); + { + const MapMode aMapTwip( MapUnit::MapTwip ); + aSize = rGrf.GetPrefSize(); + if( MapUnit::MapPixel == rGrf.GetPrefMapMode().GetMapUnit() ) + aSize = Application::GetDefaultDevice()->PixelToLogic(aSize, aMapTwip); + else + aSize = OutputDevice::LogicToLogic( aSize, + rGrf.GetPrefMapMode(), aMapTwip ); + } return aSize; } @@ -728,7 +775,7 @@ void SvxCropExample::Paint(vcl::RenderContext& rRenderContext, const ::tools::Re // the former used XOR paint. const Color aColA(SvtOptionsDrawinglayer::GetStripeColorA().getBColor()); const Color aColB(SvtOptionsDrawinglayer::GetStripeColorB().getBColor()); - const double fStripeLength(SvtOptionsDrawinglayer::GetStripeLength()); + const double fStripeLength(officecfg::Office::Common::Drawinglayer::StripeLength::get()); const basegfx::B2DVector aDashVector(rRenderContext.GetInverseViewTransformation() * basegfx::B2DVector(fStripeLength, 0.0)); const double fLogicDashLength(aDashVector.getX()); diff --git a/cui/source/tabpages/labdlg.cxx b/cui/source/tabpages/labdlg.cxx index 867a31885af7..c5661586472c 100644 --- a/cui/source/tabpages/labdlg.cxx +++ b/cui/source/tabpages/labdlg.cxx @@ -255,9 +255,9 @@ void SvxCaptionTabPage::Reset( const SfxItemSet* ) SetMetricValue( *m_xMF_SPACING, nGap, eUnit ); nGap = m_xMF_SPACING->get_value(FieldUnit::NONE); - nCaptionType = static_cast<const SdrCaptionTypeItem&>( rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONTYPE ) ) ).GetValue(); + nCaptionType = rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONTYPE ) ).GetValue(); bFitLineLen = static_cast<const SfxBoolItem&>( rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONFITLINELEN ) ) ).GetValue(); - nEscDir = static_cast<const SdrCaptionEscDirItem&>( rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONESCDIR ) ) ).GetValue(); + nEscDir = rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONESCDIR ) ).GetValue(); bEscRel = static_cast<const SfxBoolItem&>( rOutAttrs.Get( GetWhich( SDRATTR_CAPTIONESCISREL ) ) ).GetValue(); // special treatment!!! XXX @@ -474,7 +474,7 @@ SvxCaptionTabDialog::SvxCaptionTabDialog(weld::Window* pParent, const SdrView* p SvxCaptionTabPage::GetRanges ); } -void SvxCaptionTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage) +void SvxCaptionTabDialog::PageCreated(const OUString& rId, SfxTabPage &rPage) { if (rId == "RID_SVXPAGE_POSITION_SIZE") { diff --git a/cui/source/tabpages/macroass.cxx b/cui/source/tabpages/macroass.cxx index 94143e310ebd..baff7c87b0ae 100644 --- a/cui/source/tabpages/macroass.cxx +++ b/cui/source/tabpages/macroass.cxx @@ -19,6 +19,7 @@ #include <macroass.hxx> #include <o3tl/safeint.hxx> +#include <o3tl/string_view.hxx> #include <osl/diagnose.h> #include <comphelper/string.hxx> #include <comphelper/processfactory.hxx> @@ -70,7 +71,7 @@ static OUString ConvertToUIName_Impl( SvxMacro const *pMacro ) OUString aEntry = aName.getToken( nCount-1, '.' ); if ( nCount > 2 ) { - aEntry += "(" + aName.getToken( 0, '.' ) + "." + aName.getToken( nCount-2, '.' ) + ")"; + aEntry += OUString::Concat("(") + o3tl::getToken(aName, 0, '.' ) + "." + o3tl::getToken(aName, nCount-2, '.' ) + ")"; } return aEntry; } @@ -155,9 +156,14 @@ bool SfxMacroTabPage::FillItemSet( SfxItemSet* rSet ) SvxMacroItem aItem( GetWhich( aPageRg[0] ) ); const_cast<SvxMacroTableDtor&>(aItem.GetMacroTable()) = aTbl; - const SfxPoolItem* pItem; - if( SfxItemState::SET != GetItemSet().GetItemState( aItem.Which(), true, &pItem ) - || aItem != *static_cast<const SvxMacroItem*>(pItem) ) + const SfxPoolItem* pItem = nullptr; + SfxItemState eState = GetItemSet().GetItemState(aItem.Which(), true, &pItem); + if (eState == SfxItemState::DEFAULT && aTbl.empty()) + { + // Don't touch the item set if there was no input and our table is empty. + return false; + } + if (SfxItemState::SET != eState || aItem != *static_cast<const SvxMacroItem*>(pItem)) { rSet->Put( aItem ); return true; @@ -178,11 +184,12 @@ void SfxMacroTabPage::ActivatePage( const SfxItemSet& ) void SfxMacroTabPage::PageCreated(const SfxAllItemSet& aSet) { - const SfxPoolItem* pEventsItem; - if( !mpImpl->m_bGotEvents && SfxItemState::SET == aSet.GetItemState( SID_EVENTCONFIG, true, &pEventsItem ) ) + if( mpImpl->m_bGotEvents ) + return; + if( const SfxEventNamesItem* pEventsItem = aSet.GetItemIfSet( SID_EVENTCONFIG ) ) { mpImpl->m_bGotEvents = true; - const SfxEventNamesList& rList = static_cast<const SfxEventNamesItem*>(pEventsItem)->GetEvents(); + const SfxEventNamesList& rList = pEventsItem->GetEvents(); for ( size_t nNo = 0, nCnt = rList.size(); nNo < nCnt; ++nNo ) { const SfxEventName &rOwn = rList.at(nNo); @@ -197,11 +204,11 @@ void SfxMacroTabPage::Reset( const SfxItemSet* rSet ) if( SfxItemState::SET == rSet->GetItemState( GetWhich( aPageRg[0] ), true, &pItem )) aTbl = static_cast<const SvxMacroItem*>(pItem)->GetMacroTable(); - const SfxPoolItem* pEventsItem; - if( !mpImpl->m_bGotEvents && SfxItemState::SET == rSet->GetItemState( SID_EVENTCONFIG, true, &pEventsItem ) ) + const SfxEventNamesItem* pEventsItem; + if( !mpImpl->m_bGotEvents && (pEventsItem = rSet->GetItemIfSet( SID_EVENTCONFIG ) ) ) { mpImpl->m_bGotEvents = true; - const SfxEventNamesList& rList = static_cast<const SfxEventNamesItem*>(pEventsItem)->GetEvents(); + const SfxEventNamesList& rList = pEventsItem->GetEvents(); for ( size_t nNo = 0, nCnt = rList.size(); nNo < nCnt; ++nNo ) { const SfxEventName &rOwn = rList.at(nNo); @@ -214,7 +221,10 @@ void SfxMacroTabPage::Reset( const SfxItemSet* rSet ) weld::TreeView& rListBox = mpImpl->m_xEventLB->GetListBox(); std::unique_ptr<weld::TreeIter> xIter(rListBox.make_iterator()); if (rListBox.get_iter_first(*xIter)) + { rListBox.set_cursor(*xIter); + EnableButtons(); + } } bool SfxMacroTabPage::IsReadOnly() const diff --git a/cui/source/tabpages/measure.cxx b/cui/source/tabpages/measure.cxx index 027f52a77d18..8c7b4dcd8351 100644 --- a/cui/source/tabpages/measure.cxx +++ b/cui/source/tabpages/measure.cxx @@ -54,7 +54,7 @@ SvxMeasureDialog::SvxMeasureDialog(weld::Window* pParent, const SfxItemSet& rInA xPage->Construct(); SetTabPage(std::move(xPage)); - m_xDialog->set_title(CuiResId(RID_SVXSTR_DIMENSION_LINE)); + m_xDialog->set_title(CuiResId(RID_CUISTR_DIMENSION_LINE)); } /************************************************************************* @@ -110,11 +110,16 @@ SvxMeasurePage::SvxMeasurePage(weld::Container* pPage, weld::DialogController* p m_xTsbAutoPosH->connect_toggled(LINK(this, SvxMeasurePage, ClickAutoPosHdl_Impl)); Link<weld::MetricSpinButton&,void> aLink(LINK(this, SvxMeasurePage, ChangeAttrEditHdl_Impl)); + m_xMtrFldLineDist->set_range(-10000, 10000, FieldUnit::MM); m_xMtrFldLineDist->connect_value_changed(aLink); m_xMtrFldHelplineOverhang->connect_value_changed(aLink); + m_xMtrFldHelplineOverhang->set_range(-10000, 10000, FieldUnit::MM); m_xMtrFldHelplineDist->connect_value_changed(aLink); + m_xMtrFldHelplineDist->set_range(-10000, 10000, FieldUnit::MM); m_xMtrFldHelpline1Len->connect_value_changed(aLink); + m_xMtrFldHelpline1Len->set_range(-10000, 10000, FieldUnit::MM); m_xMtrFldHelpline2Len->connect_value_changed(aLink); + m_xMtrFldHelpline2Len->set_range(-10000, 10000, FieldUnit::MM); m_xMtrFldDecimalPlaces->connect_value_changed(LINK(this, SvxMeasurePage, ChangeAttrSpinHdl_Impl)); m_xTsbBelowRefEdge->connect_toggled(LINK(this, SvxMeasurePage, ChangeAttrClickHdl_Impl)); m_xTsbParallel->connect_toggled( LINK( this, SvxMeasurePage, ChangeAttrClickHdl_Impl)); @@ -144,14 +149,14 @@ void SvxMeasurePage::Reset( const SfxItemSet* rAttrs ) // SdrMeasureLineDistItem if( pItem == nullptr ) - pItem = &pPool->GetDefaultItem( SDRATTR_MEASURELINEDIST ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_MEASURELINEDIST ); SetMetricValue(*m_xMtrFldLineDist, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit); m_xMtrFldLineDist->save_value(); // SdrMeasureHelplineOverhangItem pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINEOVERHANG ); if( pItem == nullptr ) - pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINEOVERHANG ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_MEASUREHELPLINEOVERHANG ); SetMetricValue(*m_xMtrFldHelplineOverhang, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit); m_xMtrFldHelplineOverhang->save_value(); @@ -159,7 +164,7 @@ void SvxMeasurePage::Reset( const SfxItemSet* rAttrs ) // SdrMeasureHelplineDistItem pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINEDIST ); if( pItem == nullptr ) - pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINEDIST ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_MEASUREHELPLINEDIST ); SetMetricValue(*m_xMtrFldHelplineDist, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit); m_xMtrFldHelplineDist->save_value(); @@ -167,7 +172,7 @@ void SvxMeasurePage::Reset( const SfxItemSet* rAttrs ) // SdrMeasureHelpline1LenItem pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINE1LEN ); if( pItem == nullptr ) - pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINE1LEN ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_MEASUREHELPLINE1LEN ); SetMetricValue(*m_xMtrFldHelpline1Len, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit); m_xMtrFldHelpline1Len->save_value(); @@ -175,13 +180,13 @@ void SvxMeasurePage::Reset( const SfxItemSet* rAttrs ) // SdrMeasureHelpline2LenItem pItem = GetItem( *rAttrs, SDRATTR_MEASUREHELPLINE2LEN ); if( pItem == nullptr ) - pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREHELPLINE2LEN ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_MEASUREHELPLINE2LEN ); SetMetricValue(*m_xMtrFldHelpline2Len, static_cast<const SdrMetricItem*>(pItem)->GetValue(), eUnit); m_xMtrFldHelpline2Len->save_value(); // SdrMeasureBelowRefEdgeItem - if( rAttrs->GetItemState( SDRATTR_MEASUREBELOWREFEDGE ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( SDRATTR_MEASUREBELOWREFEDGE ) != SfxItemState::INVALID ) { m_xTsbBelowRefEdge->set_state( rAttrs->Get( SDRATTR_MEASUREBELOWREFEDGE ). GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE ); @@ -195,14 +200,14 @@ void SvxMeasurePage::Reset( const SfxItemSet* rAttrs ) // SdrMeasureDecimalPlacesItem pItem = GetItem( *rAttrs, SDRATTR_MEASUREDECIMALPLACES ); if( pItem == nullptr ) - pItem = &pPool->GetDefaultItem( SDRATTR_MEASUREDECIMALPLACES ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_MEASUREDECIMALPLACES ); m_xMtrFldDecimalPlaces->set_value( static_cast<const SdrMeasureDecimalPlacesItem*>(pItem)->GetValue()); m_xMtrFldDecimalPlaces->save_value(); // SdrMeasureTextRota90Item // Attention: negate ! - if( rAttrs->GetItemState( SDRATTR_MEASURETEXTROTA90 ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( SDRATTR_MEASURETEXTROTA90 ) != SfxItemState::INVALID ) { m_xTsbParallel->set_state( rAttrs->Get( SDRATTR_MEASURETEXTROTA90 ). GetValue() ? TRISTATE_FALSE : TRISTATE_TRUE ); @@ -214,7 +219,7 @@ void SvxMeasurePage::Reset( const SfxItemSet* rAttrs ) m_xTsbParallel->save_state(); // SdrMeasureShowUnitItem - if( rAttrs->GetItemState( SDRATTR_MEASURESHOWUNIT ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( SDRATTR_MEASURESHOWUNIT ) != SfxItemState::INVALID ) { m_xTsbShowUnit->set_state( rAttrs->Get( SDRATTR_MEASURESHOWUNIT ). GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE ); @@ -226,7 +231,7 @@ void SvxMeasurePage::Reset( const SfxItemSet* rAttrs ) m_xTsbShowUnit->save_state(); // SdrMeasureUnitItem - if( rAttrs->GetItemState( SDRATTR_MEASUREUNIT ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( SDRATTR_MEASUREUNIT ) != SfxItemState::INVALID ) { tools::Long nFieldUnit = static_cast<tools::Long>(rAttrs->Get( SDRATTR_MEASUREUNIT ).GetValue()); @@ -246,12 +251,12 @@ void SvxMeasurePage::Reset( const SfxItemSet* rAttrs ) m_xLbUnit->save_value(); // Position - if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTVPOS ) != SfxItemState::DONTCARE ) + if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTVPOS ) != SfxItemState::INVALID ) { css::drawing::MeasureTextVertPos eVPos = rAttrs->Get( SDRATTR_MEASURETEXTVPOS ).GetValue(); { - if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTHPOS ) != SfxItemState::DONTCARE ) + if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTHPOS ) != SfxItemState::INVALID ) { css::drawing::MeasureTextHorzPos eHPos = rAttrs->Get( SDRATTR_MEASURETEXTHPOS ).GetValue(); @@ -460,7 +465,7 @@ bool SvxMeasurePage::FillItemSet( SfxItemSet* rAttrs) if (m_xTsbAutoPosV->get_state() == TRISTATE_TRUE) eVPos = css::drawing::MeasureTextVertPos_AUTO; - if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTVPOS ) != SfxItemState::DONTCARE ) + if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTVPOS ) != SfxItemState::INVALID ) { css::drawing::MeasureTextVertPos eOldVPos = rOutAttrs.Get(SDRATTR_MEASURETEXTVPOS).GetValue(); if( eOldVPos != eVPos ) @@ -475,7 +480,7 @@ bool SvxMeasurePage::FillItemSet( SfxItemSet* rAttrs) bModified = true; } - if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTHPOS ) != SfxItemState::DONTCARE ) + if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTHPOS ) != SfxItemState::INVALID ) { css::drawing::MeasureTextHorzPos eOldHPos = rOutAttrs.Get( SDRATTR_MEASURETEXTHPOS ).GetValue(); if( eOldHPos != eHPos ) diff --git a/cui/source/tabpages/numfmt.cxx b/cui/source/tabpages/numfmt.cxx index 219972d75edc..afaa43f0dc1c 100644 --- a/cui/source/tabpages/numfmt.cxx +++ b/cui/source/tabpages/numfmt.cxx @@ -24,8 +24,6 @@ #include <svl/intitem.hxx> #include <sfx2/objsh.hxx> #include <vcl/outdev.hxx> -#include <vcl/svapp.hxx> -#include <vcl/settings.hxx> #include <i18nlangtag/lang.h> #include <svx/svxids.hrc> #include <svtools/colorcfg.hxx> @@ -113,9 +111,19 @@ void SvxNumberPreview::NotifyChange( const OUString& rPrevStr, mnPos = -1; } } - svtools::ColorConfig aColorConfig; - Color aWindowTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor ); - aPrevCol = pColor ? *pColor : aWindowTextColor; + if (pColor) + aPrevCol = *pColor; + else + { + svtools::ColorConfig aColorConfig; + Color aFgColor = aColorConfig.GetColorValue(svtools::FONTCOLOR, false).nColor; + if (aFgColor == COL_AUTO) + { + Color aBgColor = aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor; + aFgColor = aBgColor.IsDark() ? COL_WHITE : COL_BLACK; + } + aPrevCol = aFgColor; + } Invalidate(); } @@ -135,8 +143,13 @@ void SvxNumberPreview::Paint(vcl::RenderContext& rRenderContext, const ::tools:: rRenderContext.Push(vcl::PushFlags::ALL); svtools::ColorConfig aColorConfig; - rRenderContext.SetTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor); - rRenderContext.SetBackground(aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor); + Color aBgColor = aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor; + Color aFgColor = aColorConfig.GetColorValue(svtools::FONTCOLOR, false).nColor; + if (aFgColor == COL_AUTO) + aFgColor = aBgColor.IsDark() ? COL_WHITE : COL_BLACK; + rRenderContext.SetBackground(aBgColor); + rRenderContext.SetTextColor(aFgColor); + rRenderContext.Erase(); vcl::Font aDrawFont = rRenderContext.GetFont(); Size aSzWnd(GetOutputSizePixel()); @@ -189,7 +202,7 @@ SvxNumberFormatTabPage::SvxNumberFormatTabPage(weld::Container* pPage, weld::Dia , nInitFormat(std::numeric_limits<sal_uInt32>::max()) , m_nLbFormatSelPosEdComment(SELPOS_NONE) , bLegacyAutomaticCurrency(false) - , sAutomaticLangEntry(CuiResId(RID_SVXSTR_AUTO_ENTRY)) + , sAutomaticLangEntry(CuiResId(RID_CUISTR_AUTO_ENTRY)) , m_xFtCategory(m_xBuilder->weld_label("categoryft")) , m_xLbCategory(m_xBuilder->weld_tree_view("categorylb")) , m_xFtFormat(m_xBuilder->weld_label("formatft")) @@ -217,7 +230,7 @@ SvxNumberFormatTabPage::SvxNumberFormatTabPage(weld::Container* pPage, weld::Dia , m_xLbLanguage(new SvxLanguageBox(m_xBuilder->weld_combo_box("languagelb"))) , m_xWndPreview(new weld::CustomWeld(*m_xBuilder, "preview", m_aWndPreview)) { - for (size_t i = 0; i < SAL_N_ELEMENTS(NUM_CATEGORIES); ++i) + for (size_t i = 0; i < std::size(NUM_CATEGORIES); ++i) m_xLbCategory->append_text(CuiResId(NUM_CATEGORIES[i])); auto nWidth = m_xLbCategory->get_approximate_digit_width() * 22; @@ -362,14 +375,9 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet ) double nValDouble = 0; OUString aValString; - SfxItemState eState = rSet->GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_NOLANGUAGE ),true,&pItem); - - if(eState==SfxItemState::SET) + if(const SfxBoolItem* pBoolLangItem = rSet->GetItemIfSet( SID_ATTR_NUMBERFORMAT_NOLANGUAGE )) { - const SfxBoolItem* pBoolLangItem = static_cast<const SfxBoolItem*>( - GetItem( *rSet, SID_ATTR_NUMBERFORMAT_NOLANGUAGE)); - - if(pBoolLangItem!=nullptr && pBoolLangItem->GetValue()) + if(pBoolLangItem->GetValue()) { HideLanguage(); } @@ -380,7 +388,7 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet ) } - eState = rSet->GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_INFO ),true,&pItem); + SfxItemState eState = rSet->GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_INFO ),true,&pItem); if(eState==SfxItemState::SET) { @@ -404,8 +412,7 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet ) if(eState==SfxItemState::SET) { - const SfxBoolItem* pBoolItem = static_cast<const SfxBoolItem*>( - GetItem( *rSet, SID_ATTR_NUMBERFORMAT_ONE_AREA)); + const SfxBoolItem* pBoolItem = GetItem( *rSet, SID_ATTR_NUMBERFORMAT_ONE_AREA); if(pBoolItem!=nullptr) { @@ -413,12 +420,12 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet ) } } - eState = rSet->GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_SOURCE ) ); + eState = rSet->GetItemState( SID_ATTR_NUMBERFORMAT_SOURCE ); if ( eState == SfxItemState::SET ) { - const SfxBoolItem* pBoolItem = static_cast<const SfxBoolItem*>( - GetItem( *rSet, SID_ATTR_NUMBERFORMAT_SOURCE )); + const SfxBoolItem* pBoolItem = + GetItem( *rSet, SID_ATTR_NUMBERFORMAT_SOURCE ); if ( pBoolItem ) m_xCbSourceFormat->set_active(pBoolItem->GetValue()); else @@ -439,7 +446,7 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet ) eState = rSet->GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_VALUE ) ); - if ( SfxItemState::DONTCARE != eState ) + if ( SfxItemState::INVALID != eState ) pValFmtAttr = GetItem( *rSet, SID_ATTR_NUMBERFORMAT_VALUE ); eValType = pNumItem->GetValueType(); @@ -482,8 +489,7 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet ) bool bUseStarFormat = false; - SfxObjectShell* pDocSh = SfxObjectShell::Current(); - if ( pDocSh ) + if (SfxObjectShell* pDocSh = SfxObjectShell::Current()) { // is this a calc document Reference< XServiceInfo > xSI( pDocSh->GetModel(), UNO_QUERY ); @@ -514,10 +520,9 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet ) { SetCategory(nCatLbSelPos ); } - eState = rSet->GetItemState( GetWhich( SID_ATTR_NUMBERFORMAT_ADD_AUTO ) ); + eState = rSet->GetItemState( SID_ATTR_NUMBERFORMAT_ADD_AUTO ); if(SfxItemState::SET == eState) - pAutoEntryAttr = static_cast<const SfxBoolItem*>( - GetItem( *rSet, SID_ATTR_NUMBERFORMAT_ADD_AUTO )); + pAutoEntryAttr = GetItem( *rSet, SID_ATTR_NUMBERFORMAT_ADD_AUTO ); // no_NO is an alias for nb_NO and normally isn't listed, we need it for // backwards compatibility, but only if the format passed is of // LanguageType no_NO. @@ -636,7 +641,7 @@ void SvxNumberFormatTabPage::EnableBySourceFormat_Impl() #*------------------------------------------------------------------------ #* #* Class: SvxNumberFormatTabPage -#* Function: Hides the language settings: +#* Function: Hides the Languages and Locales: #* Input: sal_Bool nFlag #* Output: --- #* @@ -667,7 +672,7 @@ bool SvxNumberFormatTabPage::FillItemSet( SfxItemSet* rCoreAttrs ) if ( bDataChanged ) { const SfxItemSet& rMyItemSet = GetItemSet(); - sal_uInt16 nWhich = GetWhich( SID_ATTR_NUMBERFORMAT_VALUE ); + TypedWhichId<SfxUInt32Item> nWhich = GetWhich( SID_ATTR_NUMBERFORMAT_VALUE ); SfxItemState eItemState = rMyItemSet.GetItemState( nWhich, false ); // OK chosen - Is format code input entered already taken over? @@ -722,11 +727,8 @@ bool SvxNumberFormatTabPage::FillItemSet( SfxItemSet* rCoreAttrs ) else { SfxObjectShell* pDocSh = SfxObjectShell::Current(); - DBG_ASSERT( pDocSh, "DocShell not found!" ); - - - if ( pDocSh ) + if (pDocSh) pDocSh->PutItem( *pNumItem ); } } @@ -736,12 +738,11 @@ bool SvxNumberFormatTabPage::FillItemSet( SfxItemSet* rCoreAttrs ) if ( m_xCbSourceFormat->get_sensitive() ) { - sal_uInt16 _nWhich = GetWhich( SID_ATTR_NUMBERFORMAT_SOURCE ); - SfxItemState _eItemState = rMyItemSet.GetItemState( _nWhich, false ); - const SfxBoolItem* pBoolItem = static_cast<const SfxBoolItem*>( - GetItem( rMyItemSet, SID_ATTR_NUMBERFORMAT_SOURCE )); + SfxItemState _eItemState = rMyItemSet.GetItemState( SID_ATTR_NUMBERFORMAT_SOURCE, false ); + const SfxBoolItem* pBoolItem = + GetItem( rMyItemSet, SID_ATTR_NUMBERFORMAT_SOURCE ); bool bOld = pBoolItem && pBoolItem->GetValue(); - rCoreAttrs->Put( SfxBoolItem( _nWhich, m_xCbSourceFormat->get_active() ) ); + rCoreAttrs->Put( SfxBoolItem( SID_ATTR_NUMBERFORMAT_SOURCE, m_xCbSourceFormat->get_active() ) ); if ( !bDataChanged ) bDataChanged = (bOld != m_xCbSourceFormat->get_active() || _eItemState != SfxItemState::SET); @@ -940,7 +941,8 @@ void SvxNumberFormatTabPage::UpdateOptions_Impl( bool bCheckCatChange /*= sal_Fa m_xBtnNegRed->set_active( bNegRed ); if ( nCategory != CAT_SCIENTIFIC ) { - m_xBtnThousand->set_sensitive( nCategory != CAT_TIME ); + m_xBtnThousand->set_sensitive( nCategory != CAT_TIME + && !pNumFmtShell->IsNatNum12( theFormat ) ); m_xBtnThousand->set_active( bThousand && nCategory != CAT_TIME ); } break; @@ -1290,10 +1292,10 @@ IMPL_LINK( SvxNumberFormatTabPage, ClickHdl_Impl, weld::Button&, rIB, void) bool SvxNumberFormatTabPage::Click_Impl(const weld::Button& rIB) { - sal_uLong nReturn = 0; - constexpr sal_uLong nReturnChanged = 0x1; // THE boolean return value - constexpr sal_uLong nReturnAdded = 0x2; // temp: format added - constexpr sal_uLong nReturnOneArea = 0x4; // temp: one area but category changed => ignored + sal_uInt8 nReturn = 0; + constexpr sal_uInt8 nReturnChanged = 0x1; // THE boolean return value + constexpr sal_uInt8 nReturnAdded = 0x2; // temp: format added + constexpr sal_uInt8 nReturnOneArea = 0x4; // temp: one area but category changed => ignored if (&rIB == m_xIbAdd.get()) { // Also called from FillItemSet() if a temporary currency format has @@ -1674,6 +1676,16 @@ OUString SvxNumberFormatTabPage::GetExpColorString( } double fVal = fSvxNumValConst[i]; + // use lower number for long NatNum12 transliteration + if ( ( CAT_CURRENCY == nTmpCatPos || CAT_NUMBER == nTmpCatPos ) && + rFormatStr.indexOf("NatNum12") >= 0 ) + { + if ( CAT_CURRENCY == nTmpCatPos ) + fVal = 1.2; + else + fVal = 100; // show also title case for English: One Hundred + } + OUString aPreviewString; pNumFmtShell->MakePrevStringFromVal( rFormatStr, aPreviewString, rpPreviewColor, fVal ); return aPreviewString; diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx index ade080a1436a..2d084a1cd9af 100644 --- a/cui/source/tabpages/numpages.cxx +++ b/cui/source/tabpages/numpages.cxx @@ -17,7 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <com/sun/star/text/HoriOrientation.hpp> #include <com/sun/star/text/VertOrientation.hpp> #include <numpages.hxx> @@ -29,6 +28,7 @@ #include <svl/eitem.hxx> #include <vcl/svapp.hxx> #include <svx/colorbox.hxx> +#include <svx/dlgutil.hxx> #include <svx/strarray.hxx> #include <svx/gallery.hxx> #include <editeng/brushitem.hxx> @@ -36,13 +36,14 @@ #include <sfx2/objsh.hxx> #include <vcl/graph.hxx> #include <vcl/settings.hxx> -#include <cui/cuicharmap.hxx> +#include <svx/cuicharmap.hxx> #include <editeng/flstitem.hxx> #include <svx/numvset.hxx> #include <sfx2/htmlmode.hxx> #include <unotools/pathoptions.hxx> #include <svtools/ctrltool.hxx> #include <svtools/unitconv.hxx> +#include <svtools/colorcfg.hxx> #include <com/sun/star/style/NumberingType.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/container/XIndexAccess.hpp> @@ -51,7 +52,10 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <comphelper/processfactory.hxx> #include <comphelper/propertyvalue.hxx> +#include <comphelper/lok.hxx> #include <svx/svxids.hrc> +#include <o3tl/string_view.hxx> +#include <officecfg/Office/Common.hxx> #include <algorithm> #include <memory> @@ -72,13 +76,14 @@ #include <o3tl/temporary.hxx> #include <osl/diagnose.h> +#include <bitmaps.hlst> + using namespace css; using namespace css::uno; using namespace css::beans; using namespace css::lang; using namespace css::text; using namespace css::container; -using namespace css::style; #define SHOW_NUMBERING 0 #define SHOW_BULLET 1 @@ -117,19 +122,6 @@ static SvxNumSettings_Impl* lcl_CreateNumSettingsPtr(const Sequence<PropertyValu return pNew; } -// the selection of bullets from the OpenSymbol -const sal_Unicode aBulletTypes[] = -{ - 0x2022, - 0x25cf, - 0xe00c, - 0xe00a, - 0x2794, - 0x27a2, - 0x2717, - 0x2714 -}; - // Is one of the masked formats set? static bool lcl_IsNumFmtSet(SvxNumRule const * pNum, sal_uInt16 nLevelMask) { @@ -144,7 +136,7 @@ static bool lcl_IsNumFmtSet(SvxNumRule const * pNum, sal_uInt16 nLevelMask) return bRet; } -static const vcl::Font& lcl_GetDefaultBulletFont() +static vcl::Font& lcl_GetDefaultBulletFont() { static vcl::Font aDefBulletFont = []() { @@ -227,20 +219,19 @@ bool SvxSingleNumPickTabPage::FillItemSet( SfxItemSet* rSet ) void SvxSingleNumPickTabPage::ActivatePage(const SfxItemSet& rSet) { - const SfxPoolItem* pItem; bPreset = false; bool bIsPreset = false; const SfxItemSet* pExampleSet = GetDialogExampleSet(); if(pExampleSet) { - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem)) - bIsPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue(); - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem)) - nActNumLvl = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + if(const SfxBoolItem* pPresetItem = pExampleSet->GetItemIfSet(SID_PARAM_NUM_PRESET, false)) + bIsPreset = pPresetItem->GetValue(); + if(const SfxUInt16Item* pLevelItem = pExampleSet->GetItemIfSet(SID_PARAM_CUR_NUM_LEVEL, false)) + nActNumLvl = pLevelItem->GetValue(); } - if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem)) + if(const SvxNumBulletItem* pNumItem = rSet.GetItemIfSet(nNumItemId, false)) { - pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(pNumItem->GetNumRule()) ); } if(pActNum && *pSaveNum != *pActNum) { @@ -274,12 +265,12 @@ void SvxSingleNumPickTabPage::Reset( const SfxItemSet* rSet ) SfxItemState eState = rSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem); if(eState != SfxItemState::SET) { - nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE); + nNumItemId = rSet->GetPool()->GetWhichIDFromSlotID(SID_ATTR_NUMBERING_RULE); eState = rSet->GetItemState(nNumItemId, false, &pItem); if( eState != SfxItemState::SET ) { - pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) ); + pItem = & rSet->Get( nNumItemId ); eState = SfxItemState::SET; } } @@ -372,20 +363,19 @@ bool SvxBulletPickTabPage::FillItemSet( SfxItemSet* rSet ) void SvxBulletPickTabPage::ActivatePage(const SfxItemSet& rSet) { - const SfxPoolItem* pItem; bPreset = false; bool bIsPreset = false; const SfxItemSet* pExampleSet = GetDialogExampleSet(); if(pExampleSet) { - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem)) - bIsPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue(); - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem)) - nActNumLvl = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + if(const SfxBoolItem* pPresetItem = pExampleSet->GetItemIfSet(SID_PARAM_NUM_PRESET, false)) + bIsPreset = pPresetItem->GetValue(); + if(const SfxUInt16Item* pLevelItem = pExampleSet->GetItemIfSet(SID_PARAM_CUR_NUM_LEVEL, false)) + nActNumLvl = pLevelItem->GetValue(); } - if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem)) + if(const SvxNumBulletItem* pBulletItem = rSet.GetItemIfSet(nNumItemId, false)) { - pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(pBulletItem->GetNumRule()) ); } if(pActNum && *pSaveNum != *pActNum) { @@ -412,23 +402,20 @@ DeactivateRC SvxBulletPickTabPage::DeactivatePage(SfxItemSet *_pSet) void SvxBulletPickTabPage::Reset( const SfxItemSet* rSet ) { - const SfxPoolItem* pItem; // in Draw the item exists as WhichId, in Writer only as SlotId - SfxItemState eState = rSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem); - if(eState != SfxItemState::SET) + const SvxNumBulletItem* pItem = rSet->GetItemIfSet(SID_ATTR_NUMBERING_RULE, false); + if(!pItem) { - nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE); - eState = rSet->GetItemState(nNumItemId, false, &pItem); + nNumItemId = rSet->GetPool()->GetWhichIDFromSlotID(SID_ATTR_NUMBERING_RULE); + pItem = rSet->GetItemIfSet(nNumItemId, false); - if( eState != SfxItemState::SET ) + if( !pItem ) { - pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) ); - eState = SfxItemState::SET; + pItem = & rSet->Get( nNumItemId ); } } - DBG_ASSERT(eState == SfxItemState::SET, "no item found!"); - pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(pItem->GetNumRule()) ); if(!pActNum) pActNum.reset( new SvxNumRule(*pSaveNum) ); @@ -443,8 +430,11 @@ IMPL_LINK_NOARG(SvxBulletPickTabPage, NumSelectHdl_Impl, ValueSet*, void) bPreset = false; bModified = true; - sal_Unicode cChar = aBulletTypes[m_xExamplesVS->GetSelectedItemId() - 1]; - const vcl::Font& rActBulletFont = lcl_GetDefaultBulletFont(); + sal_uInt16 nIndex = m_xExamplesVS->GetSelectedItemId() - 1; + sal_Unicode cChar = officecfg::Office::Common::BulletsNumbering::DefaultBullets::get()[nIndex].toChar(); + vcl::Font& rActBulletFont = lcl_GetDefaultBulletFont(); + rActBulletFont.SetFamilyName( + officecfg::Office::Common::BulletsNumbering::DefaultBulletsFonts::get()[nIndex]); sal_uInt16 nMask = 1; for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) @@ -512,11 +502,14 @@ SvxNumPickTabPage::SvxNumPickTabPage(weld::Container* pPage, weld::DialogControl SvxNumSettingsArr_Impl& rItemArr = aNumSettingsArrays[ nItem ]; Reference<XIndexAccess> xLevel = aOutlineAccess.getConstArray()[nItem]; - for(sal_Int32 nLevel = 0; nLevel < xLevel->getCount() && nLevel < 5; nLevel++) + for(sal_Int32 nLevel = 0; nLevel < SVX_MAX_NUM; nLevel++) { - Any aValueAny = xLevel->getByIndex(nLevel); + // use the last locale-defined level for all remaining levels. + sal_Int32 nLocaleLevel = std::min(nLevel, xLevel->getCount() - 1); Sequence<PropertyValue> aLevelProps; - aValueAny >>= aLevelProps; + if (nLocaleLevel >= 0) + xLevel->getByIndex(nLocaleLevel) >>= aLevelProps; + SvxNumSettings_Impl* pNew = lcl_CreateNumSettingsPtr(aLevelProps); rItemArr.push_back( std::unique_ptr<SvxNumSettings_Impl>(pNew) ); } @@ -554,20 +547,19 @@ bool SvxNumPickTabPage::FillItemSet( SfxItemSet* rSet ) void SvxNumPickTabPage::ActivatePage(const SfxItemSet& rSet) { - const SfxPoolItem* pItem; bPreset = false; bool bIsPreset = false; const SfxItemSet* pExampleSet = GetDialogExampleSet(); if(pExampleSet) { - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem)) - bIsPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue(); - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem)) - nActNumLvl = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + if(const SfxBoolItem* pPresetItem = pExampleSet->GetItemIfSet(SID_PARAM_NUM_PRESET, false)) + bIsPreset = pPresetItem->GetValue(); + if(const SfxUInt16Item* pLevelItem = pExampleSet->GetItemIfSet(SID_PARAM_CUR_NUM_LEVEL, false)) + nActNumLvl = pLevelItem->GetValue(); } - if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem)) + if(const SvxNumBulletItem* pBulletItem = rSet.GetItemIfSet(nNumItemId, false)) { - pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(pBulletItem->GetNumRule()) ); } if(pActNum && *pSaveNum != *pActNum) { @@ -594,23 +586,19 @@ DeactivateRC SvxNumPickTabPage::DeactivatePage(SfxItemSet *_pSet) void SvxNumPickTabPage::Reset( const SfxItemSet* rSet ) { - const SfxPoolItem* pItem; // in Draw the item exists as WhichId, in Writer only as SlotId - SfxItemState eState = rSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem); - if(eState != SfxItemState::SET) + const SvxNumBulletItem* pItem = rSet->GetItemIfSet(SID_ATTR_NUMBERING_RULE, false); + if(!pItem) { - nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE); - eState = rSet->GetItemState(nNumItemId, false, &pItem); + nNumItemId = rSet->GetPool()->GetWhichIDFromSlotID(SID_ATTR_NUMBERING_RULE); + pItem = rSet->GetItemIfSet(nNumItemId, false); - if( eState != SfxItemState::SET ) + if( !pItem ) { - pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) ); - eState = SfxItemState::SET; + pItem = & rSet->Get( nNumItemId ); } - } - DBG_ASSERT(eState == SfxItemState::SET, "no item found!"); - pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(pItem->GetNumRule()) ); if(!pActNum) pActNum.reset( new SvxNumRule(*pSaveNum) ); @@ -653,17 +641,18 @@ IMPL_LINK_NOARG(SvxNumPickTabPage, NumSelectHdl_Impl, ValueSet*, void) //search for the font if(!pList) { - SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); - const SvxFontListItem* pFontListItem = - static_cast<const SvxFontListItem*>( pCurDocShell - ->GetItem( SID_ATTR_CHAR_FONTLIST )); - pList = pFontListItem ? pFontListItem->GetFontList() : nullptr; + if (SfxObjectShell* pCurDocShell = SfxObjectShell::Current()) + { + const SvxFontListItem* pFontListItem = + static_cast<const SvxFontListItem*>( pCurDocShell + ->GetItem( SID_ATTR_CHAR_FONTLIST )); + pList = pFontListItem ? pFontListItem->GetFontList() : nullptr; + } } if(pList && pList->IsAvailable( pLevelSettings->sBulletFont ) ) { - FontMetric aFontMetric = pList->Get( - pLevelSettings->sBulletFont,WEIGHT_NORMAL, ITALIC_NONE); - vcl::Font aFont(aFontMetric); + vcl::Font aFont(pList->Get( + pLevelSettings->sBulletFont,WEIGHT_NORMAL, ITALIC_NONE)); aFmt.SetBulletFont(&aFont); } else @@ -694,6 +683,11 @@ IMPL_LINK_NOARG(SvxNumPickTabPage, NumSelectHdl_Impl, ValueSet*, void) aFmt.SetIncludeUpperLevels(sal::static_int_cast< sal_uInt8 >(0 != nUpperLevelOrChar ? pActNum->GetLevelCount() : 1)); aFmt.SetCharFormatName(sNumCharFmtName); aFmt.SetBulletRelSize(100); + + // Completely ignore the Left/Right value provided by the locale outline definition, + // because this function doesn't actually modify the indents at all, + // and right-adjusted numbering definitely needs a different FirstLineIndent. + // #i93908# aFmt.SetListFormat(pLevelSettings->sPrefix, pLevelSettings->sSuffix, i); } @@ -736,7 +730,10 @@ SvxBitmapPickTabPage::SvxBitmapPickTabPage(weld::Container* pPage, weld::DialogC m_xExamplesVS->SetDoubleClickHdl(LINK(this, SvxBitmapPickTabPage, DoubleClickHdl_Impl)); m_xBtBrowseFile->connect_clicked(LINK(this, SvxBitmapPickTabPage, ClickAddBrowseHdl_Impl)); - eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE)); + if(comphelper::LibreOfficeKit::isActive()) + m_xBtBrowseFile->hide(); + + eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhichIDFromSlotID(SID_ATTR_NUMBERING_RULE)); // determine graphic name GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS, aGrfNames); @@ -784,20 +781,19 @@ std::unique_ptr<SfxTabPage> SvxBitmapPickTabPage::Create(weld::Container* pPage, void SvxBitmapPickTabPage::ActivatePage(const SfxItemSet& rSet) { - const SfxPoolItem* pItem; bPreset = false; bool bIsPreset = false; const SfxItemSet* pExampleSet = GetDialogExampleSet(); if(pExampleSet) { - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem)) - bIsPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue(); - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem)) - nActNumLvl = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + if(const SfxBoolItem* pPresetItem = pExampleSet->GetItemIfSet(SID_PARAM_NUM_PRESET, false)) + bIsPreset = pPresetItem->GetValue(); + if(const SfxUInt16Item* pLevelItem = pExampleSet->GetItemIfSet(SID_PARAM_CUR_NUM_LEVEL, false)) + nActNumLvl = pLevelItem->GetValue(); } - if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem)) + if(const SvxNumBulletItem* pBulletItem = rSet.GetItemIfSet(nNumItemId, false)) { - pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(pBulletItem->GetNumRule()) ); } if(pActNum && *pSaveNum != *pActNum) { @@ -841,23 +837,21 @@ bool SvxBitmapPickTabPage::FillItemSet( SfxItemSet* rSet ) void SvxBitmapPickTabPage::Reset( const SfxItemSet* rSet ) { - const SfxPoolItem* pItem; // in Draw the item exists as WhichId, in Writer only as SlotId - SfxItemState eState = rSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem); - if(eState != SfxItemState::SET) + const SvxNumBulletItem* pItem = rSet->GetItemIfSet(SID_ATTR_NUMBERING_RULE, false); + if(!pItem) { - nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE); - eState = rSet->GetItemState(nNumItemId, false, &pItem); + nNumItemId = rSet->GetPool()->GetWhichIDFromSlotID(SID_ATTR_NUMBERING_RULE); + pItem = rSet->GetItemIfSet(nNumItemId, false); - if( eState != SfxItemState::SET ) + if( !pItem ) { - pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) ); - eState = SfxItemState::SET; + pItem = & rSet->Get( nNumItemId ); } } - DBG_ASSERT(eState == SfxItemState::SET, "no item found!"); - pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + DBG_ASSERT(pItem, "no item found!"); + pSaveNum.reset( new SvxNumRule(pItem->GetNumRule()) ); if(!pActNum) pActNum.reset( new SvxNumRule(*pSaveNum) ); @@ -912,12 +906,12 @@ IMPL_LINK_NOARG(SvxBitmapPickTabPage, ClickAddBrowseHdl_Impl, weld::Button&, voi { sfx2::FileDialogHelper aFileDialog(0, FileDialogFlags::NONE, GetFrameWeld()); aFileDialog.SetContext(sfx2::FileDialogHelper::BulletsAddImage); - aFileDialog.SetTitle(CuiResId(RID_SVXSTR_ADD_IMAGE)); + aFileDialog.SetTitle(CuiResId(RID_CUISTR_ADD_IMAGE)); if ( aFileDialog.Execute() != ERRCODE_NONE ) return; OUString aPath = SvtPathOptions().GetGalleryPath(); - OUString aPathToken = aPath.getToken( 1 , SEARCHPATH_DELIMITER ); + std::u16string_view aPathToken = o3tl::getToken(aPath, 1 , SEARCHPATH_DELIMITER ); OUString aUserImageURL = aFileDialog.GetPath(); @@ -928,7 +922,7 @@ IMPL_LINK_NOARG(SvxBitmapPickTabPage, ClickAddBrowseHdl_Impl, weld::Button&, voi else if (nPos<aUserImageURL.getLength()) aFileName = aUserImageURL.copy(nPos); - OUString aUserGalleryURL = aPathToken + "/" + aFileName; + OUString aUserGalleryURL = OUString::Concat(aPathToken) + "/" + aFileName; INetURLObject aURL( aUserImageURL ); DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" ); @@ -1021,6 +1015,8 @@ SvxNumOptionsTabPage::SvxNumOptionsTabPage(weld::Container* pPage, weld::DialogC , nBullet(0xff) , nActNumLvl(1) , nNumItemId(SID_ATTR_NUMBERING_RULE) + , m_aRatioTop(ConnectorType::Top) + , m_aRatioBottom(ConnectorType::Bottom) , m_xGrid(m_xBuilder->weld_widget("grid2")) , m_xLevelLB(m_xBuilder->weld_tree_view("levellb")) , m_xFmtLB(m_xBuilder->weld_combo_box("numfmtlb")) @@ -1038,6 +1034,7 @@ SvxNumOptionsTabPage::SvxNumOptionsTabPage(weld::Container* pPage, weld::DialogC , m_xBulRelSizeMF(m_xBuilder->weld_metric_spin_button("relsize", FieldUnit::PERCENT)) , m_xAllLevelFT(m_xBuilder->weld_label("sublevelsft")) , m_xAllLevelNF(m_xBuilder->weld_spin_button("sublevels")) + , m_xIsLegalCB(m_xBuilder->weld_check_button("islegal")) , m_xStartFT(m_xBuilder->weld_label("startatft")) , m_xStartED(m_xBuilder->weld_spin_button("startat")) , m_xBulletFT(m_xBuilder->weld_label("bulletft")) @@ -1049,6 +1046,9 @@ SvxNumOptionsTabPage::SvxNumOptionsTabPage(weld::Container* pPage, weld::DialogC , m_xHeightFT(m_xBuilder->weld_label("heightft")) , m_xHeightMF(m_xBuilder->weld_metric_spin_button("heightmf", FieldUnit::CM)) , m_xRatioCB(m_xBuilder->weld_check_button("keepratio")) + , m_xCbxScaleImg(m_xBuilder->weld_image("imRatio")) + , m_xImgRatioTop(new weld::CustomWeld(*m_xBuilder, "daRatioTop", m_aRatioTop)) + , m_xImgRatioBottom(new weld::CustomWeld(*m_xBuilder, "daRatioBottom", m_aRatioBottom)) , m_xOrientFT(m_xBuilder->weld_label("orientft")) , m_xOrientLB(m_xBuilder->weld_combo_box("orientlb")) , m_xAllLevelsFrame(m_xBuilder->weld_widget("levelsframe")) @@ -1060,6 +1060,18 @@ SvxNumOptionsTabPage::SvxNumOptionsTabPage(weld::Container* pPage, weld::DialogC m_xBulRelSizeMF->set_increments(5, 50, FieldUnit::PERCENT); SetExchangeSupport(); aActBulletFont = lcl_GetDefaultBulletFont(); + // vertical alignment = fill makes the drawingarea expand the associated spinedits so we have to size it here + const sal_Int16 aHeight + = static_cast<sal_Int16>(std::max(int(m_xRatioCB->get_preferred_size().getHeight() / 2 + - m_xWidthMF->get_preferred_size().getHeight() / 2), + 12)); + const sal_Int16 aWidth + = static_cast<sal_Int16>(m_xRatioCB->get_preferred_size().getWidth() / 2); + m_xImgRatioTop->set_size_request(aWidth, aHeight); + m_xImgRatioBottom->set_size_request(aWidth, aHeight); + //init needed for gtk3 + m_xCbxScaleImg->set_from_icon_name(m_xRatioCB->get_active() ? RID_SVXBMP_LOCKED + : RID_SVXBMP_UNLOCKED); m_xBulletPB->connect_clicked(LINK(this, SvxNumOptionsTabPage, BulletHdl_Impl)); m_xFmtLB->connect_changed(LINK(this, SvxNumOptionsTabPage, NumberTypeSelectHdl_Impl)); @@ -1075,6 +1087,7 @@ SvxNumOptionsTabPage::SvxNumOptionsTabPage(weld::Container* pPage, weld::DialogC m_xPrefixED->connect_changed(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl)); m_xSuffixED->connect_changed(LINK(this, SvxNumOptionsTabPage, EditModifyHdl_Impl)); m_xAllLevelNF->connect_value_changed(LINK(this,SvxNumOptionsTabPage, AllLevelHdl_Impl)); + m_xIsLegalCB->connect_toggled(LINK(this, SvxNumOptionsTabPage, IsLegalHdl_Impl)); m_xOrientLB->connect_changed(LINK(this, SvxNumOptionsTabPage, OrientHdl_Impl)); m_xSameLevelCB->connect_toggled(LINK(this, SvxNumOptionsTabPage, SameLevelHdl_Impl)); m_xBulRelSizeMF->connect_value_changed(LINK(this,SvxNumOptionsTabPage, BulRelSizeHdl_Impl)); @@ -1082,13 +1095,15 @@ SvxNumOptionsTabPage::SvxNumOptionsTabPage(weld::Container* pPage, weld::DialogC aInvalidateTimer.SetInvokeHandler(LINK(this, SvxNumOptionsTabPage, PreviewInvalidateHdl_Impl)); aInvalidateTimer.SetTimeout(50); - eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE)); + eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhichIDFromSlotID(SID_ATTR_NUMBERING_RULE)); // Fill ListBox with predefined / translated numbering types. sal_uInt32 nCount = SvxNumberingTypeTable::Count(); for (sal_uInt32 i = 0; i < nCount; ++i) { - m_xFmtLB->append(OUString::number(SvxNumberingTypeTable::GetValue(i)), SvxNumberingTypeTable::GetString(i)); + int nValue = SvxNumberingTypeTable::GetValue(i); + if (comphelper::LibreOfficeKit::isActive() && (nValue & SVX_NUM_BITMAP)) continue; + m_xFmtLB->append(OUString::number(nValue), SvxNumberingTypeTable::GetString(i)); } // Get advanced numbering types from the component. @@ -1136,19 +1151,18 @@ std::unique_ptr<SfxTabPage> SvxNumOptionsTabPage::Create(weld::Container* pPage, void SvxNumOptionsTabPage::ActivatePage(const SfxItemSet& rSet) { - const SfxPoolItem* pItem; const SfxItemSet* pExampleSet = GetDialogExampleSet(); sal_uInt16 nTmpNumLvl = 1; if(pExampleSet) { - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem)) - bPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue(); - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem)) - nTmpNumLvl = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + if(const SfxBoolItem* pPresetItem = pExampleSet->GetItemIfSet(SID_PARAM_NUM_PRESET, false)) + bPreset = pPresetItem->GetValue(); + if(const SfxUInt16Item* pLevelItem = pExampleSet->GetItemIfSet(SID_PARAM_CUR_NUM_LEVEL, false)) + nTmpNumLvl = pLevelItem->GetValue(); } - if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem)) + if(const SvxNumBulletItem* pBulletItem = rSet.GetItemIfSet(nNumItemId, false)) { - pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(pBulletItem->GetNumRule()) ); } bModified = (!pActNum->Get( 0 ) || bPreset); @@ -1195,23 +1209,21 @@ bool SvxNumOptionsTabPage::FillItemSet( SfxItemSet* rSet ) void SvxNumOptionsTabPage::Reset( const SfxItemSet* rSet ) { - const SfxPoolItem* pItem; // in Draw the item exists as WhichId, in Writer only as SlotId - SfxItemState eState = rSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem); - if(eState != SfxItemState::SET) + const SvxNumBulletItem* pBulletItem = + rSet->GetItemIfSet(SID_ATTR_NUMBERING_RULE, false); + if(!pBulletItem) { - nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE); - eState = rSet->GetItemState(nNumItemId, false, &pItem); + nNumItemId = rSet->GetPool()->GetWhichIDFromSlotID(SID_ATTR_NUMBERING_RULE); + pBulletItem = rSet->GetItemIfSet(nNumItemId, false); - if( eState != SfxItemState::SET ) + if( !pBulletItem ) { - pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) ); - eState = SfxItemState::SET; + pBulletItem = & rSet->Get( nNumItemId ); } - } - DBG_ASSERT(eState == SfxItemState::SET, "no item found!"); - pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + DBG_ASSERT(pBulletItem, "no item found!"); + pSaveNum.reset( new SvxNumRule(pBulletItem->GetNumRule()) ); // insert levels if (!m_xLevelLB->n_children()) @@ -1253,12 +1265,16 @@ void SvxNumOptionsTabPage::Reset( const SfxItemSet* rSet ) m_aPreviewWIN.SetNumRule(pActNum.get()); m_xSameLevelCB->set_active(pActNum->IsContinuousNumbering()); - SfxObjectShell* pShell; - if ( SfxItemState::SET == rSet->GetItemState( SID_HTML_MODE, false, &pItem ) - || ( nullptr != ( pShell = SfxObjectShell::Current()) && - nullptr != ( pItem = pShell->GetItem( SID_HTML_MODE ) ) ) ) + const SfxUInt16Item* pHtmlModeItem = + rSet->GetItemIfSet( SID_HTML_MODE, false ); + if (!pHtmlModeItem) + { + if (SfxObjectShell* pShell = SfxObjectShell::Current()) + pHtmlModeItem = pShell->GetItem( SID_HTML_MODE ); + } + if ( pHtmlModeItem ) { - sal_uInt16 nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + sal_uInt16 nHtmlMode = pHtmlModeItem->GetValue(); bHTMLMode = 0 != (nHtmlMode&HTMLMODE_ON); } @@ -1271,6 +1287,7 @@ void SvxNumOptionsTabPage::Reset( const SfxItemSet* rSet ) bool bAllLevel = bContinuous && !bHTMLMode; m_xAllLevelFT->set_visible(bAllLevel); m_xAllLevelNF->set_visible(bAllLevel); + m_xIsLegalCB->set_visible(bAllLevel); m_xAllLevelsFrame->set_visible(bContinuous); @@ -1334,6 +1351,8 @@ void SvxNumOptionsTabPage::InitControls() bool bSameBulColor = true; bool bSameBulRelSize= true; + TriState isLegal = TRISTATE_INDET; + const SvxNumberFormat* aNumFmtArr[SVX_MAX_NUM]; OUString sFirstCharFmt; sal_Int16 eFirstOrient = text::VertOrientation::NONE; @@ -1358,6 +1377,7 @@ void SvxNumOptionsTabPage::InitControls() eFirstOrient = aNumFmtArr[i]->GetVertOrient(); if(bShowBitmap) aFirstSize = aNumFmtArr[i]->GetGraphicSize(); + isLegal = aNumFmtArr[i]->GetIsLegal() ? TRISTATE_TRUE : TRISTATE_FALSE; } if( i > nLvl) { @@ -1367,6 +1387,8 @@ void SvxNumOptionsTabPage::InitControls() bSamePrefix = aNumFmtArr[i]->GetPrefix() == aNumFmtArr[nLvl]->GetPrefix(); bSameSuffix = aNumFmtArr[i]->GetSuffix() == aNumFmtArr[nLvl]->GetSuffix(); bAllLevel &= aNumFmtArr[i]->GetIncludeUpperLevels() == aNumFmtArr[nLvl]->GetIncludeUpperLevels(); + if (aNumFmtArr[i]->GetIsLegal() != aNumFmtArr[nLvl]->GetIsLegal()) + isLegal = TRISTATE_INDET; bSameCharFmt &= sFirstCharFmt == aNumFmtArr[i]->GetCharFormatName(); bSameVOrient &= eFirstOrient == aNumFmtArr[i]->GetVertOrient(); if(bShowBitmap && bSameSize) @@ -1439,6 +1461,9 @@ void SvxNumOptionsTabPage::InitControls() m_xAllLevelNF->set_text(""); } + m_xIsLegalCB->set_state(isLegal); + m_xIsLegalCB->set_sensitive(!m_xSameLevelCB->get_active()); + if(bBullRelSize) { if(bSameBulRelSize) @@ -1453,6 +1478,7 @@ void SvxNumOptionsTabPage::InitControls() else m_xBulColLB->SetNoSelection(); } + m_xStartED->set_value(1); // If this isn't set then changing the bullet type to a numbered type doesn't reset the start level switch(nBullet) { case SHOW_NUMBERING: @@ -1482,7 +1508,7 @@ void SvxNumOptionsTabPage::InitControls() { if (!sFirstCharFmt.isEmpty()) m_xCharFmtLB->set_active_text(sFirstCharFmt); - else + else if (m_xCharFmtLB->get_count()) m_xCharFmtLB->set_active(0); } else @@ -1518,6 +1544,7 @@ void SvxNumOptionsTabPage::SwitchNumberType( sal_uInt8 nType ) bool bAllLevel = bNumeric && bAllLevelFeature && !bHTMLMode; m_xAllLevelFT->set_visible(bAllLevel); m_xAllLevelNF->set_visible(bAllLevel); + m_xIsLegalCB->set_visible(bAllLevel); m_xStartFT->set_visible(!(bBullet||bBitmap)); m_xStartED->set_visible(!(bBullet||bBitmap)); @@ -1539,6 +1566,9 @@ void SvxNumOptionsTabPage::SwitchNumberType( sal_uInt8 nType ) m_xHeightFT->set_visible(bBitmap); m_xHeightMF->set_visible(bBitmap); m_xRatioCB->set_visible(bBitmap); + m_xCbxScaleImg->set_visible(bBitmap); + m_xImgRatioTop->set_visible(bBitmap); + m_xImgRatioBottom->set_visible(bBitmap); m_xOrientFT->set_visible(bBitmap && bAllLevelFeature); m_xOrientLB->set_visible(bBitmap && bAllLevelFeature); @@ -1617,7 +1647,7 @@ IMPL_LINK(SvxNumOptionsTabPage, AllLevelHdl_Impl, weld::SpinButton&, rBox, void) if(nActNumLvl & nMask) { SvxNumberFormat aNumFmt(pActNum->GetLevel(e)); - aNumFmt.SetIncludeUpperLevels(static_cast<sal_uInt8>(std::min(rBox.get_value(), int(e + 1))) ); + aNumFmt.SetIncludeUpperLevels(static_cast<sal_uInt8>(std::min(rBox.get_value(), sal_Int64(e + 1))) ); // Set the same prefix/suffix to generate list format with changed IncludedUpperLevels aNumFmt.SetListFormat(aNumFmt.GetPrefix(), aNumFmt.GetSuffix(), e); pActNum->SetLevel(e, aNumFmt); @@ -1627,6 +1657,21 @@ IMPL_LINK(SvxNumOptionsTabPage, AllLevelHdl_Impl, weld::SpinButton&, rBox, void) SetModified(); } +IMPL_LINK(SvxNumOptionsTabPage, IsLegalHdl_Impl, weld::Toggleable&, rBox, void) +{ + bool bSet = rBox.get_active(); + for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) + { + if (nActNumLvl & (sal_uInt16(1) << i)) + { + SvxNumberFormat aNumFmt(pActNum->GetLevel(i)); + aNumFmt.SetIsLegal(bSet); + pActNum->SetLevel(i, aNumFmt); + } + } + SetModified(); +} + IMPL_LINK(SvxNumOptionsTabPage, NumberTypeSelectHdl_Impl, weld::ComboBox&, rBox, void) { OUString sSelectStyle; @@ -1796,14 +1841,14 @@ IMPL_LINK(SvxNumOptionsTabPage, BulRelSizeHdl_Impl, weld::MetricSpinButton&, rFi SetModified(); } -IMPL_LINK(SvxNumOptionsTabPage, GraphicHdl_Impl, const OString&, rIdent, void) +IMPL_LINK(SvxNumOptionsTabPage, GraphicHdl_Impl, const OUString&, rIdent, void) { OUString aGrfName; Size aSize; bool bSucc(false); - SvxOpenGraphicDialog aGrfDlg(CuiResId(RID_SVXSTR_EDIT_GRAPHIC), GetFrameWeld()); + SvxOpenGraphicDialog aGrfDlg(CuiResId(RID_CUISTR_EDIT_GRAPHIC), GetFrameWeld()); - OString sNumber; + OUString sNumber; if (rIdent.startsWith("gallery", &sNumber)) { auto idx = sNumber.toUInt32(); @@ -2056,6 +2101,7 @@ IMPL_LINK( SvxNumOptionsTabPage, SizeHdl_Impl, weld::MetricSpinButton&, rField, IMPL_LINK(SvxNumOptionsTabPage, RatioHdl_Impl, weld::Toggleable&, rBox, void) { + m_xCbxScaleImg->set_from_icon_name(m_xRatioCB->get_active() ? RID_SVXBMP_LOCKED : RID_SVXBMP_UNLOCKED); if (rBox.get_active()) { if (bLastWidthModified) @@ -2121,353 +2167,6 @@ void SvxNumOptionsTabPage::EditModifyHdl_Impl(const weld::Entry* pEdit) SetModified(); } -static tools::Long lcl_DrawGraphic(VirtualDevice& rVDev, const SvxNumberFormat &rFmt, tools::Long nXStart, - tools::Long nYMiddle, tools::Long nDivision) -{ - const SvxBrushItem* pBrushItem = rFmt.GetBrush(); - tools::Long nRet = 0; - if(pBrushItem) - { - const Graphic* pGrf = pBrushItem->GetGraphic(); - if(pGrf) - { - Size aGSize( rFmt.GetGraphicSize() ); - aGSize.setWidth( aGSize.Width() / nDivision ); - nRet = aGSize.Width(); - aGSize.setHeight( aGSize.Height() / nDivision ); - pGrf->Draw(rVDev, Point(nXStart,nYMiddle - ( aGSize.Height() / 2) ), - rVDev.PixelToLogic( aGSize ) ); - } - } - return nRet; - -} - -static tools::Long lcl_DrawBullet(VirtualDevice* pVDev, - const SvxNumberFormat& rFmt, tools::Long nXStart, - tools::Long nYStart, const Size& rSize) -{ - vcl::Font aTmpFont(pVDev->GetFont()); - - // via Uno it's possible that no font has been set! - vcl::Font aFont(rFmt.GetBulletFont() ? *rFmt.GetBulletFont() : aTmpFont); - Size aTmpSize(rSize); - aTmpSize.setWidth( aTmpSize.Width() * ( rFmt.GetBulletRelSize()) ); - aTmpSize.setWidth( aTmpSize.Width() / 100 ) ; - aTmpSize.setHeight( aTmpSize.Height() * ( rFmt.GetBulletRelSize()) ); - aTmpSize.setHeight( aTmpSize.Height() / 100 ) ; - // in case of a height of zero it is drawn in original height - if(!aTmpSize.Height()) - aTmpSize.setHeight( 1 ); - aFont.SetFontSize(aTmpSize); - aFont.SetTransparent(true); - Color aBulletColor = rFmt.GetBulletColor(); - if(aBulletColor == COL_AUTO) - aBulletColor = pVDev->GetFillColor().IsDark() ? COL_WHITE : COL_BLACK; - else if(aBulletColor == pVDev->GetFillColor()) - aBulletColor.Invert(); - aFont.SetColor(aBulletColor); - pVDev->SetFont( aFont ); - sal_UCS4 cChar = rFmt.GetBulletChar(); - OUString aText(&cChar, 1); - tools::Long nY = nYStart; - nY -= ((aTmpSize.Height() - rSize.Height())/ 2); - pVDev->DrawText( Point(nXStart, nY), aText ); - tools::Long nRet = pVDev->GetTextWidth(aText); - - pVDev->SetFont(aTmpFont); - return nRet; -} - -SvxNumberingPreview::SvxNumberingPreview() - : pActNum(nullptr) - , bPosition(false) - , nActLevel(SAL_MAX_UINT16) -{ -} - -// paint preview of numeration -void SvxNumberingPreview::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) - { - tools::Long nWidthRelation = 30; // chapter dialog - - // height per level - tools::Long nXStep = aSize.Width() / (3 * pActNum->GetLevelCount()); - if (pActNum->GetLevelCount() < 10) - nXStep /= 2; - tools::Long nYStart = 4; - // the whole height mustn't be used for a single level - tools::Long nYStep = (aSize.Height() - 6)/ (pActNum->GetLevelCount() > 1 ? pActNum->GetLevelCount() : 5); - - aStdFont = OutputDevice::GetDefaultFont(DefaultFontType::UI_SANS, MsLangId::getConfiguredSystemLanguage(), GetDefaultFontFlags::OnlyOne); - aStdFont.SetColor(aTextColor); - aStdFont.SetFillColor(aBackColor); - - tools::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) - { - tools::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(); - - tools::Long nXStart( 0 ); - short nTextOffset( 0 ); - tools::Long nNumberXPos( 0 ); - if (rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION) - { - nXStart = rFmt.GetAbsLSpace() / nWidthRelation; - nTextOffset = rFmt.GetCharTextDistance() / nWidthRelation; - nNumberXPos = nXStart; - tools::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 tools::Long nTmpNumberXPos((rFmt.GetIndentAt() + rFmt.GetFirstLineIndent() ) / nWidthRelation); - if (nTmpNumberXPos < 0) - { - nNumberXPos = 0; - } - else - { - nNumberXPos = nTmpNumberXPos; - } - } - - tools::Long nBulletWidth = 0; - if (SVX_NUM_BITMAP == (rFmt.GetNumberingType() &(~LINK_TOKEN))) - { - tools::Long nYMiddle = nYStart + ( nFontHeight / 2 ); - nBulletWidth = rFmt.IsShowSymbol() ? lcl_DrawGraphic(*pVDev, 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); - } - - tools::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 - tools::Long nWidth = pVDev->GetTextWidth("Preview"); - tools::Long nTextHeight = pVDev->GetTextHeight(); - tools::Long nRectHeight = nTextHeight * 2 / 3; - tools::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(); - tools::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 tools::Long nTmpXStart((rFmt.GetIndentAt() + rFmt.GetFirstLineIndent() ) / nWidthRelation); - if (nTmpXStart < 0) - { - nXStart = 0; - } - else - { - nXStart = nTmpXStart; - } - } - nXStart /= 2; - nXStart += 2; - tools::Long nTextOffset = 2 * nXStep; - if (SVX_NUM_BITMAP == (rFmt.GetNumberingType()&(~LINK_TOKEN))) - { - if (rFmt.IsShowSymbol()) - { - tools::Long nYMiddle = nYStart + ( nFontHeight / 2 ); - nTextOffset = lcl_DrawGraphic(*pVDev, 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 aFont(aStdFont); - Size aTmpSize(aStdFont.GetFontSize()); - if(pActNum->IsFeatureSupported(SvxNumRuleFlags::BULLET_REL_SIZE)) - { - aTmpSize.setWidth( aTmpSize.Width() * ( rFmt.GetBulletRelSize()) ); - aTmpSize.setWidth( aTmpSize.Width() / 100 ) ; - aTmpSize.setHeight( aTmpSize.Height() * ( rFmt.GetBulletRelSize()) ); - aTmpSize.setHeight( aTmpSize.Height() / 100 ) ; - } - if(!aTmpSize.Height()) - aTmpSize.setHeight( 1 ); - aFont.SetFontSize(aTmpSize); - Color aTmpBulletColor = rFmt.GetBulletColor(); - if (aTmpBulletColor == COL_AUTO) - aTmpBulletColor = aBackColor.IsDark() ? COL_WHITE : COL_BLACK; - else if (aTmpBulletColor == aBackColor) - aTmpBulletColor.Invert(); - aFont.SetColor(aTmpBulletColor); - pVDev->SetFont(aFont); - aNum.SetLevel( nLevel ); - if (pActNum->IsContinuousNumbering()) - aNum.GetLevelVal()[nLevel] = nPreNum; - OUString aText(pActNum->MakeNumString(aNum)); - tools::Long nY = nYStart; - nY -= (pVDev->GetTextHeight() - nTextHeight - pVDev->GetFontMetric().GetDescent()); - pVDev->DrawText(Point(nXStart, nY), aText); - nTextOffset = pVDev->GetTextWidth(aText); - nTextOffset = nTextOffset + nXStep; - nPreNum++; - pVDev->SetFont(aStdFont); - } - //#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 @@ -2506,6 +2205,13 @@ SvxNumPositionTabPage::SvxNumPositionTabPage(weld::Container* pPage, weld::Dialo { SetExchangeSupport(); + // set metric + FieldUnit eFUnit = GetModuleFieldUnit(rSet); + + SetFieldUnit( *m_xDistBorderMF, eFUnit ); + SetFieldUnit( *m_xIndentMF, eFUnit ); + SetFieldUnit( *m_xDistNumMF, eFUnit ); + m_xAlignedAtMF->set_range(0, SAL_MAX_INT32, FieldUnit::NONE); m_xListtabMF->set_range(0, SAL_MAX_INT32, FieldUnit::NONE); m_xIndentAtMF->set_range(0, SAL_MAX_INT32, FieldUnit::NONE); @@ -2536,7 +2242,7 @@ SvxNumPositionTabPage::SvxNumPositionTabPage(weld::Container* pPage, weld::Dialo m_xRelativeCB->set_active(bLastRelative); m_aPreviewWIN.SetPositionMode(); - eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE)); + eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhichIDFromSlotID(SID_ATTR_NUMBERING_RULE)); } SvxNumPositionTabPage::~SvxNumPositionTabPage() @@ -2747,19 +2453,18 @@ void SvxNumPositionTabPage::InitControls() void SvxNumPositionTabPage::ActivatePage(const SfxItemSet& rSet) { - const SfxPoolItem* pItem; sal_uInt16 nTmpNumLvl = 1; const SfxItemSet* pExampleSet = GetDialogExampleSet(); if(pExampleSet) { - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_NUM_PRESET, false, &pItem)) - bPreset = static_cast<const SfxBoolItem*>(pItem)->GetValue(); - if(SfxItemState::SET == pExampleSet->GetItemState(SID_PARAM_CUR_NUM_LEVEL, false, &pItem)) - nTmpNumLvl = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + if(const SfxBoolItem* pPresetItem = pExampleSet->GetItemIfSet(SID_PARAM_NUM_PRESET, false)) + bPreset = pPresetItem->GetValue(); + if(const SfxUInt16Item* pLevelItem = pExampleSet->GetItemIfSet(SID_PARAM_CUR_NUM_LEVEL, false)) + nTmpNumLvl = pLevelItem->GetValue(); } - if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem)) + if(const SvxNumBulletItem* pBulletItem = rSet.GetItemIfSet(nNumItemId, false)) { - pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + pSaveNum.reset( new SvxNumRule(pBulletItem->GetNumRule()) ); } bModified = (!pActNum->Get( 0 ) || bPreset); if(*pSaveNum != *pActNum || @@ -2816,23 +2521,21 @@ bool SvxNumPositionTabPage::FillItemSet( SfxItemSet* rSet ) void SvxNumPositionTabPage::Reset( const SfxItemSet* rSet ) { - const SfxPoolItem* pItem; // in Draw the item exists as WhichId, in Writer only as SlotId - SfxItemState eState = rSet->GetItemState(SID_ATTR_NUMBERING_RULE, false, &pItem); - if(eState != SfxItemState::SET) + const SvxNumBulletItem* pItem = + rSet->GetItemIfSet(SID_ATTR_NUMBERING_RULE, false); + if(!pItem) { - nNumItemId = rSet->GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE); - eState = rSet->GetItemState(nNumItemId, false, &pItem); + nNumItemId = rSet->GetPool()->GetWhichIDFromSlotID(SID_ATTR_NUMBERING_RULE); + pItem = rSet->GetItemIfSet(nNumItemId, false); - if( eState != SfxItemState::SET ) + if( !pItem ) { - pItem = &static_cast< const SvxNumBulletItem& >( rSet->Get( nNumItemId ) ); - eState = SfxItemState::SET; + pItem = & rSet->Get( nNumItemId ); } - } - DBG_ASSERT(eState == SfxItemState::SET, "no item found!"); - pSaveNum.reset( new SvxNumRule(static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) ); + DBG_ASSERT(pItem, "no item found!"); + pSaveNum.reset( new SvxNumRule(pItem->GetNumRule()) ); // insert levels if (!m_xLevelLB->count_selected_rows()) @@ -3340,9 +3043,8 @@ void SvxNumOptionsTabPage::PageCreated(const SfxAllItemSet& aSet) if (pListItem) { const std::vector<OUString> &aList = pListItem->GetList(); - sal_uInt32 nCount = aList.size(); - for(sal_uInt32 i = 0; i < nCount; i++) - m_xCharFmtLB->append_text(aList[i]); + for (const auto& rItem : aList) + m_xCharFmtLB->append_text(rItem); } if (pMetricItem) SetMetric(static_cast<FieldUnit>(pMetricItem->GetValue())); diff --git a/cui/source/tabpages/page.cxx b/cui/source/tabpages/page.cxx index 0e29feaaeae6..0fec60690e9a 100644 --- a/cui/source/tabpages/page.cxx +++ b/cui/source/tabpages/page.cxx @@ -22,7 +22,6 @@ #include <sfx2/objsh.hxx> #include <sfx2/printer.hxx> #include <sfx2/viewsh.hxx> -#include <svl/languageoptions.hxx> #include <svl/cjkoptions.hxx> #include <svl/ctloptions.hxx> #include <svtools/unitconv.hxx> @@ -50,13 +49,13 @@ #include <editeng/eerdll.hxx> #include <editeng/editrids.hrc> #include <svx/svxids.hrc> -#include <svtools/optionsdrawinglayer.hxx> #include <svl/slstitm.hxx> #include <svx/xdef.hxx> #include <svx/unobrushitemhelper.hxx> #include <svx/SvxNumOptionsTabPageHelper.hxx> #include <sal/log.hxx> #include <svl/grabbagitem.hxx> +#include <officecfg/Office/Common.hxx> // static ---------------------------------------------------------------- @@ -81,7 +80,7 @@ const SvxPageUsage aArr[] = static sal_uInt16 PageUsageToPos_Impl( SvxPageUsage nUsage ) { - for ( size_t i = 0; i < SAL_N_ELEMENTS(aArr); ++i ) + for ( size_t i = 0; i < std::size(aArr); ++i ) if ( aArr[i] == nUsage ) return i; return 3; @@ -90,7 +89,7 @@ static sal_uInt16 PageUsageToPos_Impl( SvxPageUsage nUsage ) static SvxPageUsage PosToPageUsage_Impl( sal_uInt16 nPos ) { - if ( nPos >= SAL_N_ELEMENTS(aArr) ) + if ( nPos >= std::size(aArr) ) return SvxPageUsage::NONE; return aArr[nPos]; } @@ -150,7 +149,6 @@ SvxPageDescPage::SvxPageDescPage(weld::Container* pPage, weld::DialogController* , m_xPaperSizeBox(new SvxPaperSizeListBox(m_xBuilder->weld_combo_box("comboPageFormat"))) , m_xPaperWidthEdit(m_xBuilder->weld_metric_spin_button("spinWidth", FieldUnit::CM)) , m_xPaperHeightEdit(m_xBuilder->weld_metric_spin_button("spinHeight", FieldUnit::CM)) - , m_xOrientationFT(m_xBuilder->weld_label("labelOrientation")) , m_xPortraitBtn(m_xBuilder->weld_radio_button("radiobuttonPortrait")) , m_xLandscapeBtn(m_xBuilder->weld_radio_button("radiobuttonLandscape")) , m_xTextFlowLbl(m_xBuilder->weld_label("labelTextFlow")) @@ -193,17 +191,18 @@ SvxPageDescPage::SvxPageDescPage(weld::Container* pPage, weld::DialogController* // this page needs ExchangeSupport SetExchangeSupport(); - SvtCTLOptions aCTLLanguageOptions; bool bCJK = SvtCJKOptions::IsAsianTypographyEnabled(); - bool bCTL = aCTLLanguageOptions.IsCTLFontEnabled(); + bool bCTL = SvtCTLOptions::IsCTLFontEnabled(); bool bWeb = false; - const SfxPoolItem* pItem; - SfxObjectShell* pShell; - if(SfxItemState::SET == rAttr.GetItemState(SID_HTML_MODE, false, &pItem) || - ( nullptr != (pShell = SfxObjectShell::Current()) && - nullptr != (pItem = pShell->GetItem(SID_HTML_MODE)))) - bWeb = 0 != (static_cast<const SfxUInt16Item*>(pItem)->GetValue() & HTMLMODE_ON); + const SfxUInt16Item* pHtmlModeItem = rAttr.GetItemIfSet(SID_HTML_MODE, false); + if (!pHtmlModeItem) + { + if (SfxObjectShell* pShell = SfxObjectShell::Current()) + pHtmlModeItem = pShell->GetItem(SID_HTML_MODE); + } + if (pHtmlModeItem) + bWeb = 0 != (pHtmlModeItem->GetValue() & HTMLMODE_ON); // fill text flow listbox with valid entries @@ -277,16 +276,16 @@ SvxPageDescPage::SvxPageDescPage(weld::Container* pPage, weld::DialogController* // #i4219# take Maximum now from configuration (1/100th cm) // was: 11900 -> 119 cm ;new value 3 meters -> 300 cm -> 30000 - m_xPaperWidthEdit->set_max(m_xPaperWidthEdit->normalize(SvtOptionsDrawinglayer::GetMaximumPaperWidth()), FieldUnit::CM); - m_xPaperHeightEdit->set_max(m_xPaperHeightEdit->normalize(SvtOptionsDrawinglayer::GetMaximumPaperHeight()), FieldUnit::CM); + m_xPaperWidthEdit->set_max(m_xPaperWidthEdit->normalize(officecfg::Office::Common::Drawinglayer::MaximumPaperWidth::get()), FieldUnit::CM); + m_xPaperHeightEdit->set_max(m_xPaperHeightEdit->normalize(officecfg::Office::Common::Drawinglayer::MaximumPaperHeight::get()), FieldUnit::CM); // #i4219# also for margins (1/100th cm). Was: 9999, keeping. - m_xLeftMarginEdit->set_max(m_xLeftMarginEdit->normalize(SvtOptionsDrawinglayer::GetMaximumPaperLeftMargin()), FieldUnit::MM); - m_xRightMarginEdit->set_max(m_xRightMarginEdit->normalize(SvtOptionsDrawinglayer::GetMaximumPaperRightMargin()), FieldUnit::MM); - m_xTopMarginEdit->set_max(m_xTopMarginEdit->normalize(SvtOptionsDrawinglayer::GetMaximumPaperTopMargin()), FieldUnit::MM); - m_xBottomMarginEdit->set_max(m_xBottomMarginEdit->normalize(SvtOptionsDrawinglayer::GetMaximumPaperBottomMargin()), FieldUnit::MM); + m_xLeftMarginEdit->set_max(m_xLeftMarginEdit->normalize(officecfg::Office::Common::Drawinglayer::MaximumPaperLeftMargin::get()), FieldUnit::MM); + m_xRightMarginEdit->set_max(m_xRightMarginEdit->normalize(officecfg::Office::Common::Drawinglayer::MaximumPaperRightMargin::get()), FieldUnit::MM); + m_xTopMarginEdit->set_max(m_xTopMarginEdit->normalize(officecfg::Office::Common::Drawinglayer::MaximumPaperTopMargin::get()), FieldUnit::MM); + m_xBottomMarginEdit->set_max(m_xBottomMarginEdit->normalize(officecfg::Office::Common::Drawinglayer::MaximumPaperBottomMargin::get()), FieldUnit::MM); m_xGutterMarginEdit->set_max( - m_xGutterMarginEdit->normalize(SvtOptionsDrawinglayer::GetMaximumPaperLeftMargin()), + m_xGutterMarginEdit->normalize(officecfg::Office::Common::Drawinglayer::MaximumPaperLeftMargin::get()), FieldUnit::MM); // Get the i18n framework numberings and add them to the listbox. @@ -360,12 +359,11 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet ) static_cast<sal_uInt16>(ConvertLong_Impl( static_cast<tools::Long>(rULSpace.GetLower()), eUnit )) ); } - if (rSet->HasItem(SID_ATTR_CHAR_GRABBAG, &pItem)) + if (const SfxGrabBagItem* pGragbagItem = rSet->GetItemIfSet(SID_ATTR_CHAR_GRABBAG)) { - const auto& rGrabBagItem = static_cast<const SfxGrabBagItem&>(*pItem); bool bGutterAtTop{}; - auto it = rGrabBagItem.GetGrabBag().find("GutterAtTop"); - if (it != rGrabBagItem.GetGrabBag().end()) + auto it = pGragbagItem->GetGrabBag().find("GutterAtTop"); + if (it != pGragbagItem->GetGrabBag().end()) { it->second >>= bGutterAtTop; } @@ -379,17 +377,17 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet ) // Left. m_xGutterPositionLB->set_active(0); } - it = rGrabBagItem.GetGrabBag().find("RtlGutter"); + it = pGragbagItem->GetGrabBag().find("RtlGutter"); bool bRtlGutter{}; - if (it != rGrabBagItem.GetGrabBag().end()) + if (it != pGragbagItem->GetGrabBag().end()) { it->second >>= bRtlGutter; m_xRtlGutterCB->set_active(bRtlGutter); m_xRtlGutterCB->show(); } - it = rGrabBagItem.GetGrabBag().find("BackgroundFullSize"); + it = pGragbagItem->GetGrabBag().find("BackgroundFullSize"); bool isBackgroundFullSize{}; - if (it != rGrabBagItem.GetGrabBag().end()) + if (it != pGragbagItem->GetGrabBag().end()) { it->second >>= isBackgroundFullSize; m_xBackgroundFullSizeCB->set_active(isBackgroundFullSize); @@ -584,15 +582,14 @@ void SvxPageDescPage::Reset( const SfxItemSet* rSet ) if(SfxItemState::SET == rSet->GetItemState(SID_SWREGISTER_MODE)) { - m_xRegisterCB->set_active(static_cast<const SfxBoolItem&>(rSet->Get( - SID_SWREGISTER_MODE)).GetValue()); + m_xRegisterCB->set_active(rSet->Get(SID_SWREGISTER_MODE).GetValue()); m_xRegisterCB->save_state(); RegisterModify(*m_xRegisterCB); } if(SfxItemState::SET == rSet->GetItemState(SID_SWREGISTER_COLLECTION)) { m_xRegisterLB->set_active_text( - static_cast<const SfxStringItem&>(rSet->Get(SID_SWREGISTER_COLLECTION)).GetValue()); + rSet->Get(SID_SWREGISTER_COLLECTION).GetValue()); m_xRegisterLB->save_value(); } @@ -666,8 +663,7 @@ bool SvxPageDescPage::FillItemSet( SfxItemSet* rSet ) if (rOldSet.HasItem(SID_ATTR_CHAR_GRABBAG)) { // Set gutter position. - SfxGrabBagItem aGrabBagItem( - static_cast<const SfxGrabBagItem&>(rOldSet.Get(SID_ATTR_CHAR_GRABBAG))); + SfxGrabBagItem aGrabBagItem(rOldSet.Get(SID_ATTR_CHAR_GRABBAG)); if (m_xGutterPositionLB->get_value_changed_from_saved()) { bool bGutterAtTop = m_xGutterPositionLB->get_active() == 1; @@ -726,14 +722,14 @@ bool SvxPageDescPage::FillItemSet( SfxItemSet* rSet ) } // paper tray - nWhich = GetWhich( SID_ATTR_PAGE_PAPERBIN ); + TypedWhichId<SvxPaperBinItem> nPaperWhich = GetWhich( SID_ATTR_PAGE_PAPERBIN ); sal_Int32 nPos = m_xPaperTrayBox->get_active(); sal_uInt16 nBin = m_xPaperTrayBox->get_id(nPos).toInt32(); pOld = GetOldItem( *rSet, SID_ATTR_PAGE_PAPERBIN ); if ( !pOld || static_cast<const SvxPaperBinItem*>(pOld)->GetValue() != nBin ) { - rSet->Put( SvxPaperBinItem( nWhich, static_cast<sal_uInt8>(nBin) ) ); + rSet->Put( SvxPaperBinItem( nPaperWhich, static_cast<sal_uInt8>(nBin) ) ); bModified = true; } @@ -852,7 +848,7 @@ bool SvxPageDescPage::FillItemSet( SfxItemSet* rSet ) if (m_xRegisterCB->get_visible() && (m_xRegisterCB->get_active() || m_xRegisterCB->get_state_changed_from_saved())) { - const SfxBoolItem& rRegItem = static_cast<const SfxBoolItem&>(rOldSet.Get(SID_SWREGISTER_MODE)); + const SfxBoolItem& rRegItem = rOldSet.Get(SID_SWREGISTER_MODE); std::unique_ptr<SfxBoolItem> pRegItem(rRegItem.Clone()); bool bCheck = m_xRegisterCB->get_active(); pRegItem->SetValue(bCheck); @@ -924,8 +920,8 @@ IMPL_LINK_NOARG(SvxPageDescPage, PaperBinHdl_Impl, weld::Widget&, void) } m_xPaperTrayBox->append(OUString::number(i), aName); } - m_xPaperTrayBox->set_active_text(aOldName); m_xPaperTrayBox->thaw(); + m_xPaperTrayBox->set_active_text(aOldName); // tdf#123650 explicitly grab-focus after the modification otherwise gtk loses track // of there the focus should be @@ -1137,7 +1133,7 @@ void SvxPageDescPage::ResetBackground_Impl(const SfxItemSet& rSet) { const SvxSetItem& rSetItem = static_cast< const SvxSetItem& >(rSet.Get(nWhich, false)); const SfxItemSet& rTmpSet = rSetItem.GetItemSet(); - const SfxBoolItem& rOn = static_cast< const SfxBoolItem& >(rTmpSet.Get(GetWhich(SID_ATTR_PAGE_ON))); + const SfxBoolItem& rOn = rTmpSet.Get(GetWhich(SID_ATTR_PAGE_ON)); if(rOn.GetValue()) { @@ -1173,7 +1169,7 @@ void SvxPageDescPage::ResetBackground_Impl(const SfxItemSet& rSet) { const SvxSetItem& rSetItem = static_cast< const SvxSetItem& >(rSet.Get(nWhich,false)); const SfxItemSet& rTmpSet = rSetItem.GetItemSet(); - const SfxBoolItem& rOn = static_cast< const SfxBoolItem& >(rTmpSet.Get(GetWhich(SID_ATTR_PAGE_ON))); + const SfxBoolItem& rOn = rTmpSet.Get(GetWhich(SID_ATTR_PAGE_ON)); if(rOn.GetValue()) { @@ -1246,19 +1242,19 @@ void SvxPageDescPage::InitHeadFoot_Impl( const SfxItemSet& rSet ) { const SfxItemSet& rHeaderSet = pSetItem->GetItemSet(); const SfxBoolItem& rHeaderOn = - static_cast<const SfxBoolItem&>(rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_ON ) )); + rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_ON ) ); if ( rHeaderOn.GetValue() ) { - const SvxSizeItem& rSize = static_cast<const SvxSizeItem&>( - rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) )); - const SvxULSpaceItem& rUL = static_cast<const SvxULSpaceItem&>( - rHeaderSet.Get( GetWhich( SID_ATTR_ULSPACE ) )); + const SvxSizeItem& rSize = + rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) ); + const SvxULSpaceItem& rUL = + rHeaderSet.Get( GetWhich( SID_ATTR_ULSPACE ) ); tools::Long nDist = rUL.GetLower(); m_aBspWin.SetHdHeight( rSize.GetSize().Height() - nDist ); m_aBspWin.SetHdDist( nDist ); - const SvxLRSpaceItem& rLR = static_cast<const SvxLRSpaceItem&>( - rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) )); + const SvxLRSpaceItem& rLR = + rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) ); m_aBspWin.SetHdLeft( rLR.GetLeft() ); m_aBspWin.SetHdRight( rLR.GetRight() ); m_aBspWin.SetHeader( true ); @@ -1301,19 +1297,19 @@ void SvxPageDescPage::InitHeadFoot_Impl( const SfxItemSet& rSet ) const SfxItemSet& rFooterSet = pSetItem->GetItemSet(); const SfxBoolItem& rFooterOn = - static_cast<const SfxBoolItem&>(rFooterSet.Get( GetWhich( SID_ATTR_PAGE_ON ) )); + rFooterSet.Get( GetWhich( SID_ATTR_PAGE_ON ) ); if ( rFooterOn.GetValue() ) { - const SvxSizeItem& rSize = static_cast<const SvxSizeItem&>( - rFooterSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) )); - const SvxULSpaceItem& rUL = static_cast<const SvxULSpaceItem&>( - rFooterSet.Get( GetWhich( SID_ATTR_ULSPACE ) )); + const SvxSizeItem& rSize = + rFooterSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) ); + const SvxULSpaceItem& rUL = + rFooterSet.Get( GetWhich( SID_ATTR_ULSPACE ) ); tools::Long nDist = rUL.GetUpper(); m_aBspWin.SetFtHeight( rSize.GetSize().Height() - nDist ); m_aBspWin.SetFtDist( nDist ); - const SvxLRSpaceItem& rLR = static_cast<const SvxLRSpaceItem&>( - rFooterSet.Get( GetWhich( SID_ATTR_LRSPACE ) )); + const SvxLRSpaceItem& rLR = + rFooterSet.Get( GetWhich( SID_ATTR_LRSPACE ) ); m_aBspWin.SetFtLeft( rLR.GetLeft() ); m_aBspWin.SetFtRight( rLR.GetRight() ); m_aBspWin.SetFooter( true ); @@ -1438,8 +1434,8 @@ void SvxPageDescPage::RangeHdl_Impl() SfxItemState::DEFAULT ) { aBorder = GetMinBorderSpace_Impl( - static_cast<const SvxShadowItem&>(_pSet->Get(GetWhich(SID_ATTR_BORDER_SHADOW))), - static_cast<const SvxBoxItem&>(_pSet->Get(GetWhich(SID_ATTR_BORDER_OUTER)))); + _pSet->Get(GetWhich(SID_ATTR_BORDER_SHADOW)), + _pSet->Get(GetWhich(SID_ATTR_BORDER_OUTER))); } // limits paper diff --git a/cui/source/tabpages/paragrph.cxx b/cui/source/tabpages/paragrph.cxx index a7075bd862e7..11fefa11ed07 100644 --- a/cui/source/tabpages/paragrph.cxx +++ b/cui/source/tabpages/paragrph.cxx @@ -25,8 +25,8 @@ #include <vcl/settings.hxx> #include <svx/flagsdef.hxx> #include <svx/svxids.hrc> +#include <svx/sdtaitm.hxx> -#include <svl/languageoptions.hxx> #include <svl/cjkoptions.hxx> #include <editeng/pgrditem.hxx> #include <svx/strings.hrc> @@ -45,29 +45,47 @@ #include <editeng/lrspitem.hxx> #include <editeng/formatbreakitem.hxx> #include <editeng/keepitem.hxx> +#include <editeng/scriptspaceitem.hxx> +#include <editeng/hngpnctitem.hxx> +#include <editeng/forbiddenruleitem.hxx> +#include <i18nlangtag/languagetag.hxx> +#include <i18nlangtag/mslangid.hxx> #include <svx/dlgutil.hxx> #include <sfx2/htmlmode.hxx> #include <editeng/paravertalignitem.hxx> #include <svl/eitem.hxx> #include <svl/intitem.hxx> +#include <unotools/syslocaleoptions.hxx> +#include <com/sun/star/text/ParagraphHyphenationKeepType.hpp> const WhichRangesContainer SvxStdParagraphTabPage::pStdRanges( svl::Items< SID_ATTR_PARA_LINESPACE, SID_ATTR_PARA_LINESPACE, // 10033 + SID_ATTR_PARA_LEFTSPACE, SID_ATTR_PARA_FIRSTLINESPACE, SID_ATTR_LRSPACE, SID_ATTR_ULSPACE, // 10048 - 10049 SID_ATTR_PARA_REGISTER, SID_ATTR_PARA_REGISTER // 10413 >); const WhichRangesContainer SvxParaAlignTabPage::pAlignRanges( - svl::Items<SID_ATTR_PARA_ADJUST, SID_ATTR_PARA_ADJUST>); // 10027 + svl::Items< + SID_ATTR_PARA_ADJUST, SID_ATTR_PARA_ADJUST, // 10027 + // tdf#154543 - reset snap to grid to parent + SID_ATTR_PARA_SNAPTOGRID, SID_ATTR_PARA_SNAPTOGRID // 10945 + >); + +const WhichRangesContainer SvxParaAlignTabPage::pSdrAlignRanges( + svl::Items< + SDRATTR_TEXT_VERTADJUST, SDRATTR_TEXT_VERTADJUST, // 1076 + SID_ATTR_PARA_ADJUST, SID_ATTR_PARA_ADJUST , // 10027 + SID_ATTR_FRAMEDIRECTION, SID_ATTR_FRAMEDIRECTION // 10944 + >); const WhichRangesContainer SvxExtParagraphTabPage::pExtRanges(svl::Items< SID_ATTR_PARA_PAGEBREAK, SID_ATTR_PARA_WIDOWS, // 10037 - 10041 SID_ATTR_PARA_MODEL, SID_ATTR_PARA_KEEP // 10065 - 10066 >); -#define MAX_DURCH 5670 // 10 cm makes sense as maximum interline lead - // according to BP +#define MAX_DURCH 31680 // tdf#68335: 1584 pt for UX interoperability with Word #define FIX_DIST_DEF 283 // standard fix distance 0,5 cm namespace { @@ -139,13 +157,15 @@ void SetLineSpace_Impl( SvxLineSpacingItem& rLineSpace, static sal_uInt16 GetHtmlMode_Impl(const SfxItemSet& rSet) { sal_uInt16 nHtmlMode = 0; - const SfxPoolItem* pItem = nullptr; - SfxObjectShell* pShell; - if(SfxItemState::SET == rSet.GetItemState(SID_HTML_MODE, false, &pItem) || - ( nullptr != (pShell = SfxObjectShell::Current()) && - nullptr != (pItem = pShell->GetItem(SID_HTML_MODE)))) + const SfxUInt16Item* pItem = rSet.GetItemIfSet(SID_HTML_MODE, false); + if (!pItem) + { + if (SfxObjectShell* pShell = SfxObjectShell::Current()) + pItem = pShell->GetItem(SID_HTML_MODE); + } + if(pItem) { - nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); + nHtmlMode = pItem->GetValue(); } return nHtmlMode; @@ -158,34 +178,34 @@ void SvxStdParagraphTabPage::ELRLoseFocus() FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) ) ); - sal_Int64 nL = m_xLeftIndent->denormalize(m_xLeftIndent->get_value(eUnit)); - sal_Int64 nR = m_xRightIndent->denormalize(m_xRightIndent->get_value(eUnit)); - OUString aTmp = m_xFLineIndent->get_text(); + sal_Int64 nL = m_aLeftIndent.denormalize(m_aLeftIndent.get_value(eUnit)); + sal_Int64 nR = m_aRightIndent.denormalize(m_aRightIndent.get_value(eUnit)); + OUString aTmp = m_aFLineIndent.get_text(); - if (m_xLeftIndent->get_min(FieldUnit::NONE) < 0) - m_xFLineIndent->set_min(-99999, FieldUnit::MM); + if (m_aLeftIndent.get_min(FieldUnit::NONE) < 0) + m_aFLineIndent.set_min(-99999, FieldUnit::MM); else - m_xFLineIndent->set_min(m_xFLineIndent->normalize(-nL), eUnit); + m_aFLineIndent.set_min(m_aFLineIndent.normalize(-nL), eUnit); // Check only for concrete width (Shell) sal_Int64 nTmp = nWidth - nL - nR - MM50; - m_xFLineIndent->set_max(m_xFLineIndent->normalize(nTmp), eUnit); + m_aFLineIndent.set_max(m_aFLineIndent.normalize(nTmp), eUnit); if (aTmp.isEmpty()) - m_xFLineIndent->set_text(OUString()); + m_aFLineIndent.set_text(OUString()); // maximum left right - aTmp = m_xLeftIndent->get_text(); + aTmp = m_aLeftIndent.get_text(); nTmp = nWidth - nR - MM50; - m_xLeftIndent->set_max(m_xLeftIndent->normalize(nTmp), eUnit); + m_aLeftIndent.set_max(m_aLeftIndent.normalize(nTmp), eUnit); if ( aTmp.isEmpty() ) - m_xLeftIndent->set_text(OUString()); - aTmp = m_xRightIndent->get_text(); + m_aLeftIndent.set_text(OUString()); + aTmp = m_aRightIndent.get_text(); nTmp = nWidth - nL - MM50; - m_xRightIndent->set_max(m_xRightIndent->normalize(nTmp), eUnit); + m_aRightIndent.set_max(m_aRightIndent.normalize(nTmp), eUnit); if ( aTmp.isEmpty() ) - m_xRightIndent->set_text(OUString()); + m_aRightIndent.set_text(OUString()); UpdateExample_Impl(); } @@ -251,14 +271,14 @@ bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) if ( m_bLineDistToggled || !pOld || !( *static_cast<const SvxLineSpacingItem*>(pOld) == aSpacing ) || - SfxItemState::DONTCARE == GetItemSet().GetItemState( nWhich ) ) + SfxItemState::INVALID == GetItemSet().GetItemState( nWhich ) ) { rOutSet->Put( aSpacing ); bModified = true; } } - if ( m_xTopDist->get_value_changed_from_saved() || m_xBottomDist->get_value_changed_from_saved() + if ( m_aTopDist.get_value_changed_from_saved() || m_aBottomDist.get_value_changed_from_saved() || m_xContextualCB->get_state_changed_from_saved()) { nWhich = GetWhich( SID_ATTR_ULSPACE ); @@ -273,28 +293,28 @@ bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) const SvxULSpaceItem& rOldItem = static_cast<const SvxULSpaceItem&>(GetItemSet().GetParent()->Get( nWhich )); - if ( m_xTopDist->IsRelative() ) + if ( m_aTopDist.IsRelative() ) aMargin.SetUpper( rOldItem.GetUpper(), - static_cast<sal_uInt16>(m_xTopDist->get_value(FieldUnit::NONE)) ); + static_cast<sal_uInt16>(m_aTopDist.get_value(FieldUnit::NONE)) ); else - aMargin.SetUpper( static_cast<sal_uInt16>(m_xTopDist->GetCoreValue(eUnit)) ); + aMargin.SetUpper( static_cast<sal_uInt16>(m_aTopDist.GetCoreValue(eUnit)) ); - if ( m_xBottomDist->IsRelative() ) + if ( m_aBottomDist.IsRelative() ) aMargin.SetLower( rOldItem.GetLower(), - static_cast<sal_uInt16>(m_xBottomDist->get_value(FieldUnit::NONE)) ); + static_cast<sal_uInt16>(m_aBottomDist.get_value(FieldUnit::NONE)) ); else - aMargin.SetLower( static_cast<sal_uInt16>(m_xBottomDist->GetCoreValue(eUnit)) ); + aMargin.SetLower( static_cast<sal_uInt16>(m_aBottomDist.GetCoreValue(eUnit)) ); } else { - aMargin.SetUpper(static_cast<sal_uInt16>(m_xTopDist->GetCoreValue(eUnit))); - aMargin.SetLower(static_cast<sal_uInt16>(m_xBottomDist->GetCoreValue(eUnit))); + aMargin.SetUpper(static_cast<sal_uInt16>(m_aTopDist.GetCoreValue(eUnit))); + aMargin.SetLower(static_cast<sal_uInt16>(m_aBottomDist.GetCoreValue(eUnit))); } aMargin.SetContextValue(m_xContextualCB->get_active()); if ( !pOld || *static_cast<const SvxULSpaceItem*>(pOld) != aMargin || - SfxItemState::DONTCARE == GetItemSet().GetItemState( nWhich ) ) + SfxItemState::INVALID == GetItemSet().GetItemState( nWhich ) ) { rOutSet->Put( aMargin ); bModified = true; @@ -302,10 +322,126 @@ bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) } bool bNullTab = false; - if ( m_xLeftIndent->get_value_changed_from_saved() || - m_xFLineIndent->get_value_changed_from_saved() || - m_xRightIndent->get_value_changed_from_saved() || - m_xAutoCB->get_state_changed_from_saved() ) + if (m_bSplitLRSpace && m_aLeftIndent.get_value_changed_from_saved()) + { + nWhich = GetWhich(SID_ATTR_PARA_LEFTSPACE); + MapUnit const eUnit = pPool->GetMetric(nWhich); + SvxTextLeftMarginItem item(nWhich); + pOld = GetOldItem(*rOutSet, SID_ATTR_PARA_LEFTSPACE); + + if (bRelativeMode) + { + assert(GetItemSet().GetParent()); + + const SvxTextLeftMarginItem & rOldItem( + static_cast<const SvxTextLeftMarginItem&>(GetItemSet().GetParent()->Get(nWhich))); + + if (m_aLeftIndent.IsRelative()) + { + item.SetTextLeft(rOldItem.GetTextLeft(), + static_cast<sal_uInt16>(m_aLeftIndent.get_value(FieldUnit::NONE))); + } + else + { + item.SetTextLeft(m_aLeftIndent.GetCoreValue(eUnit)); + } + } + else + { + item.SetTextLeft(m_aLeftIndent.GetCoreValue(eUnit)); + } + if (!pOld || *static_cast<const SvxTextLeftMarginItem*>(pOld) != item + || SfxItemState::INVALID == GetItemSet().GetItemState(nWhich)) + { + rOutSet->Put(item); + bModified = true; + } + } + + if (m_bSplitLRSpace && m_aRightIndent.get_value_changed_from_saved()) + { + nWhich = GetWhich(SID_ATTR_PARA_RIGHTSPACE); + MapUnit const eUnit = pPool->GetMetric(nWhich); + SvxRightMarginItem item(nWhich); + pOld = GetOldItem(*rOutSet, SID_ATTR_PARA_RIGHTSPACE); + + if (bRelativeMode) + { + assert(GetItemSet().GetParent()); + + const SvxRightMarginItem & rOldItem( + static_cast<const SvxRightMarginItem&>(GetItemSet().GetParent()->Get(nWhich))); + + if (m_aRightIndent.IsRelative()) + { + item.SetRight(rOldItem.GetRight(), + static_cast<sal_uInt16>(m_aRightIndent.get_value(FieldUnit::NONE))); + } + else + { + item.SetRight(m_aRightIndent.GetCoreValue(eUnit)); + } + } + else + { + item.SetRight(m_aRightIndent.GetCoreValue(eUnit)); + } + if (!pOld || *static_cast<const SvxRightMarginItem*>(pOld) != item + || SfxItemState::INVALID == GetItemSet().GetItemState(nWhich)) + { + rOutSet->Put(item); + bModified = true; + } + } + + if (m_bSplitLRSpace && (m_aFLineIndent.get_value_changed_from_saved() + || m_xAutoCB->get_state_changed_from_saved())) + { + nWhich = GetWhich(SID_ATTR_PARA_FIRSTLINESPACE); + MapUnit const eUnit = pPool->GetMetric(nWhich); + SvxFirstLineIndentItem item(nWhich); + pOld = GetOldItem(*rOutSet, SID_ATTR_PARA_FIRSTLINESPACE); + + if (bRelativeMode) + { + assert(GetItemSet().GetParent()); + + const SvxFirstLineIndentItem & rOldItem( + static_cast<const SvxFirstLineIndentItem&>(GetItemSet().GetParent()->Get(nWhich))); + + if (m_aFLineIndent.IsRelative()) + { + item.SetTextFirstLineOffset(rOldItem.GetTextFirstLineOffset(), + static_cast<sal_uInt16>(m_aFLineIndent.get_value(FieldUnit::NONE))); + } + else + { + item.SetTextFirstLineOffset(static_cast<sal_uInt16>(m_aFLineIndent.GetCoreValue(eUnit))); + } + } + else + { + item.SetTextFirstLineOffset(static_cast<sal_uInt16>(m_aFLineIndent.GetCoreValue(eUnit))); + } + item.SetAutoFirst(m_xAutoCB->get_active()); + if (item.GetTextFirstLineOffset() < 0) + { + bNullTab = true; + } + + if (!pOld || *static_cast<const SvxFirstLineIndentItem*>(pOld) != item + || SfxItemState::INVALID == GetItemSet().GetItemState(nWhich)) + { + rOutSet->Put(item); + bModified = true; + } + } + + if (!m_bSplitLRSpace && + (m_aLeftIndent.get_value_changed_from_saved() || + m_aFLineIndent.get_value_changed_from_saved() || + m_aRightIndent.get_value_changed_from_saved() || + m_xAutoCB->get_state_changed_from_saved())) { nWhich = GetWhich( SID_ATTR_LRSPACE ); MapUnit eUnit = pPool->GetMetric( nWhich ); @@ -319,36 +455,36 @@ bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) const SvxLRSpaceItem& rOldItem = static_cast<const SvxLRSpaceItem&>(GetItemSet().GetParent()->Get( nWhich )); - if (m_xLeftIndent->IsRelative()) + if (m_aLeftIndent.IsRelative()) aMargin.SetTextLeft( rOldItem.GetTextLeft(), - static_cast<sal_uInt16>(m_xLeftIndent->get_value(FieldUnit::NONE)) ); + static_cast<sal_uInt16>(m_aLeftIndent.get_value(FieldUnit::NONE)) ); else - aMargin.SetTextLeft(m_xLeftIndent->GetCoreValue(eUnit)); + aMargin.SetTextLeft(m_aLeftIndent.GetCoreValue(eUnit)); - if ( m_xRightIndent->IsRelative() ) + if ( m_aRightIndent.IsRelative() ) aMargin.SetRight( rOldItem.GetRight(), - static_cast<sal_uInt16>(m_xRightIndent->get_value(FieldUnit::NONE)) ); + static_cast<sal_uInt16>(m_aRightIndent.get_value(FieldUnit::NONE)) ); else - aMargin.SetRight(m_xRightIndent->GetCoreValue(eUnit)); + aMargin.SetRight(m_aRightIndent.GetCoreValue(eUnit)); - if ( m_xFLineIndent->IsRelative() ) + if ( m_aFLineIndent.IsRelative() ) aMargin.SetTextFirstLineOffset( rOldItem.GetTextFirstLineOffset(), - static_cast<sal_uInt16>(m_xFLineIndent->get_value(FieldUnit::NONE)) ); + static_cast<sal_uInt16>(m_aFLineIndent.get_value(FieldUnit::NONE)) ); else - aMargin.SetTextFirstLineOffset(static_cast<sal_uInt16>(m_xFLineIndent->GetCoreValue(eUnit))); + aMargin.SetTextFirstLineOffset(static_cast<sal_uInt16>(m_aFLineIndent.GetCoreValue(eUnit))); } else { - aMargin.SetTextLeft(m_xLeftIndent->GetCoreValue(eUnit)); - aMargin.SetRight(m_xRightIndent->GetCoreValue(eUnit)); - aMargin.SetTextFirstLineOffset(static_cast<sal_uInt16>(m_xFLineIndent->GetCoreValue(eUnit))); + aMargin.SetTextLeft(m_aLeftIndent.GetCoreValue(eUnit)); + aMargin.SetRight(m_aRightIndent.GetCoreValue(eUnit)); + aMargin.SetTextFirstLineOffset(static_cast<sal_uInt16>(m_aFLineIndent.GetCoreValue(eUnit))); } aMargin.SetAutoFirst(m_xAutoCB->get_active()); if ( aMargin.GetTextFirstLineOffset() < 0 ) bNullTab = true; if ( !pOld || *static_cast<const SvxLRSpaceItem*>(pOld) != aMargin || - SfxItemState::DONTCARE == GetItemSet().GetItemState( nWhich ) ) + SfxItemState::INVALID == GetItemSet().GetItemState( nWhich ) ) { rOutSet->Put( aMargin ); bModified = true; @@ -382,14 +518,14 @@ bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) *rOutSet, SID_ATTR_PARA_REGISTER)); if (!pBoolItem) return bModified; - std::unique_ptr<SfxBoolItem> pRegItem(pBoolItem->Clone()); sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_REGISTER ); - bool bSet = pRegItem->GetValue(); + bool bSet = pBoolItem->GetValue(); if (m_xRegisterCB->get_active() != bSet) { + std::unique_ptr<SfxBoolItem> pRegItem(pBoolItem->Clone()); pRegItem->SetValue(!bSet); - rOutSet->Put(*pRegItem); + rOutSet->Put(std::move(pRegItem)); bModified = true; } else if ( SfxItemState::DEFAULT == GetItemSet().GetItemState( _nWhich, false ) ) @@ -399,6 +535,19 @@ bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) return bModified; } +static bool UseCharUnitInUI(const SfxItemSet& rSet) +{ + const bool bApplyCharUnit = GetApplyCharUnit(rSet); + if (!bApplyCharUnit) + return false; + if (!SvtCJKOptions::IsAsianTypographyEnabled()) + return false; + // tdf#101895 Given that we choose to show cm vs inch based on this Locale + // setting, also choose to use ch[ar] and line based on that locale when + // bApplyCharUnit is enabled. + return MsLangId::isCJK(SvtSysLocaleOptions().GetRealLanguageTag().getLanguageType()); +} + void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet ) { SfxItemPool* pPool = rSet->GetPool(); @@ -406,32 +555,134 @@ void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet ) // adjust metric FieldUnit eFUnit = GetModuleFieldUnit( *rSet ); - - bool bApplyCharUnit = GetApplyCharUnit( *rSet ); - - if(SvtCJKOptions::IsAsianTypographyEnabled() && bApplyCharUnit ) + if (UseCharUnitInUI(*rSet)) eFUnit = FieldUnit::CHAR; - m_xLeftIndent->SetFieldUnit(eFUnit); - m_xRightIndent->SetFieldUnit(eFUnit); - m_xFLineIndent->SetFieldUnit(eFUnit); + m_aLeftIndent.SetFieldUnit(eFUnit); + m_aRightIndent.SetFieldUnit(eFUnit); + m_aFLineIndent.SetFieldUnit(eFUnit); if ( eFUnit == FieldUnit::CHAR ) { - m_xTopDist->SetFieldUnit(FieldUnit::LINE); - m_xBottomDist->SetFieldUnit(FieldUnit::LINE); + m_aTopDist.SetFieldUnit(FieldUnit::LINE); + m_aBottomDist.SetFieldUnit(FieldUnit::LINE); SetFieldUnit(*m_xLineDistAtMetricBox, FieldUnit::POINT); } else { - m_xTopDist->SetFieldUnit(eFUnit); - m_xBottomDist->SetFieldUnit(eFUnit); + m_aTopDist.SetFieldUnit(eFUnit); + m_aBottomDist.SetFieldUnit(eFUnit); SetFieldUnit(*m_xLineDistAtMetricBox, eFUnit); } + sal_uInt16 const nWhichFL(GetWhich(SID_ATTR_PARA_FIRSTLINESPACE)); + m_bSplitLRSpace = (nWhichFL != SID_ATTR_PARA_FIRSTLINESPACE); + SfxItemState const eItemStateFL(rSet->GetItemState(nWhichFL)); + sal_uInt16 const nWhichLM(GetWhich(SID_ATTR_PARA_LEFTSPACE)); + SfxItemState const eItemStateLM(rSet->GetItemState(nWhichLM)); + sal_uInt16 const nWhichRM(GetWhich(SID_ATTR_PARA_RIGHTSPACE)); + SfxItemState const eItemStateRM(rSet->GetItemState(nWhichRM)); + + if (m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemStateLM) + { + const SvxTextLeftMarginItem & rOldLeftMargin( + static_cast<const SvxTextLeftMarginItem &>(rSet->Get(nWhichLM))); + + MapUnit const eUnit = pPool->GetMetric(nWhichLM); + + if (bRelativeMode) + { + if (rOldLeftMargin.GetPropLeft() != 100) + { + m_aLeftIndent.SetRelative( true ); + m_aLeftIndent.set_value(rOldLeftMargin.GetPropLeft(), FieldUnit::NONE); + } + else + { + m_aLeftIndent.SetRelative(false); + m_aLeftIndent.SetFieldUnit(eFUnit); + m_aLeftIndent.SetMetricValue(rOldLeftMargin.GetTextLeft(), eUnit); + } + } + else + { + m_aLeftIndent.SetMetricValue(rOldLeftMargin.GetTextLeft(), eUnit); + } + } + else if (m_bSplitLRSpace) + { + m_aLeftIndent.set_text(OUString()); + } + + if (m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemStateRM) + { + const SvxRightMarginItem & rOldRightMargin( + static_cast<const SvxRightMarginItem &>(rSet->Get(nWhichRM))); + + MapUnit const eUnit = pPool->GetMetric(nWhichRM); + + if (bRelativeMode) + { + if (rOldRightMargin.GetPropRight() != 100) + { + m_aRightIndent.SetRelative( true ); + m_aRightIndent.set_value(rOldRightMargin.GetPropRight(), FieldUnit::NONE); + } + else + { + m_aRightIndent.SetRelative(false); + m_aRightIndent.SetFieldUnit(eFUnit); + m_aRightIndent.SetMetricValue(rOldRightMargin.GetRight(), eUnit); + } + } + else + { + m_aRightIndent.SetMetricValue(rOldRightMargin.GetRight(), eUnit); + } + } + else if (m_bSplitLRSpace) + { + m_aRightIndent.set_text(OUString()); + } + + if (m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemStateFL) + { + const SvxFirstLineIndentItem & rOldFirstLine( + static_cast<const SvxFirstLineIndentItem &>(rSet->Get(nWhichFL))); + + MapUnit const eUnit = pPool->GetMetric(nWhichFL); + + if (bRelativeMode) + { + if (rOldFirstLine.GetPropTextFirstLineOffset() != 100) + { + m_aFLineIndent.SetRelative(true); + m_aFLineIndent.set_value(rOldFirstLine.GetPropTextFirstLineOffset(), FieldUnit::NONE); + } + else + { + m_aFLineIndent.SetRelative(false); + m_aFLineIndent.set_min(-9999, FieldUnit::NONE); + m_aFLineIndent.SetFieldUnit(eFUnit); + m_aFLineIndent.SetMetricValue(rOldFirstLine.GetTextFirstLineOffset(), eUnit); + } + m_xAutoCB->set_active(rOldFirstLine.IsAutoFirst()); + } + else + { + m_aFLineIndent.SetMetricValue(rOldFirstLine.GetTextFirstLineOffset(), eUnit); + m_xAutoCB->set_active(rOldFirstLine.IsAutoFirst()); + } + AutoHdl_Impl(*m_xAutoCB); + } + else if (m_bSplitLRSpace) + { + m_aFLineIndent.set_text(OUString()); + } + sal_uInt16 _nWhich = GetWhich( SID_ATTR_LRSPACE ); SfxItemState eItemState = rSet->GetItemState( _nWhich ); - if ( eItemState >= SfxItemState::DEFAULT ) + if (!m_bSplitLRSpace && SfxItemState::DEFAULT <= eItemState) { MapUnit eUnit = pPool->GetMetric( _nWhich ); @@ -442,39 +693,39 @@ void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet ) if ( rOldItem.GetPropLeft() != 100 ) { - m_xLeftIndent->SetRelative( true ); - m_xLeftIndent->set_value(rOldItem.GetPropLeft(), FieldUnit::NONE); + m_aLeftIndent.SetRelative( true ); + m_aLeftIndent.set_value(rOldItem.GetPropLeft(), FieldUnit::NONE); } else { - m_xLeftIndent->SetRelative(false); - m_xLeftIndent->SetFieldUnit(eFUnit); - m_xLeftIndent->SetMetricValue(rOldItem.GetTextLeft(), eUnit); + m_aLeftIndent.SetRelative(false); + m_aLeftIndent.SetFieldUnit(eFUnit); + m_aLeftIndent.SetMetricValue(rOldItem.GetTextLeft(), eUnit); } if ( rOldItem.GetPropRight() != 100 ) { - m_xRightIndent->SetRelative( true ); - m_xRightIndent->set_value(rOldItem.GetPropRight(), FieldUnit::NONE); + m_aRightIndent.SetRelative( true ); + m_aRightIndent.set_value(rOldItem.GetPropRight(), FieldUnit::NONE); } else { - m_xRightIndent->SetRelative(false); - m_xRightIndent->SetFieldUnit(eFUnit); - m_xRightIndent->SetMetricValue(rOldItem.GetRight(), eUnit); + m_aRightIndent.SetRelative(false); + m_aRightIndent.SetFieldUnit(eFUnit); + m_aRightIndent.SetMetricValue(rOldItem.GetRight(), eUnit); } if ( rOldItem.GetPropTextFirstLineOffset() != 100 ) { - m_xFLineIndent->SetRelative(true); - m_xFLineIndent->set_value(rOldItem.GetPropTextFirstLineOffset(), FieldUnit::NONE); + m_aFLineIndent.SetRelative(true); + m_aFLineIndent.set_value(rOldItem.GetPropTextFirstLineOffset(), FieldUnit::NONE); } else { - m_xFLineIndent->SetRelative(false); - m_xFLineIndent->set_min(-9999, FieldUnit::NONE); - m_xFLineIndent->SetFieldUnit(eFUnit); - m_xFLineIndent->SetMetricValue(rOldItem.GetTextFirstLineOffset(), eUnit); + m_aFLineIndent.SetRelative(false); + m_aFLineIndent.set_min(-9999, FieldUnit::NONE); + m_aFLineIndent.SetFieldUnit(eFUnit); + m_aFLineIndent.SetMetricValue(rOldItem.GetTextFirstLineOffset(), eUnit); } m_xAutoCB->set_active(rOldItem.IsAutoFirst()); } @@ -483,18 +734,18 @@ void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet ) const SvxLRSpaceItem& rSpace = static_cast<const SvxLRSpaceItem&>(rSet->Get( _nWhich )); - m_xLeftIndent->SetMetricValue(rSpace.GetTextLeft(), eUnit); - m_xRightIndent->SetMetricValue(rSpace.GetRight(), eUnit); - m_xFLineIndent->SetMetricValue(rSpace.GetTextFirstLineOffset(), eUnit); + m_aLeftIndent.SetMetricValue(rSpace.GetTextLeft(), eUnit); + m_aRightIndent.SetMetricValue(rSpace.GetRight(), eUnit); + m_aFLineIndent.SetMetricValue(rSpace.GetTextFirstLineOffset(), eUnit); m_xAutoCB->set_active(rSpace.IsAutoFirst()); } AutoHdl_Impl(*m_xAutoCB); } - else + else if (!m_bSplitLRSpace) { - m_xLeftIndent->set_text(OUString()); - m_xRightIndent->set_text(OUString()); - m_xFLineIndent->set_text(OUString()); + m_aLeftIndent.set_text(OUString()); + m_aRightIndent.set_text(OUString()); + m_aFLineIndent.set_text(OUString()); } _nWhich = GetWhich( SID_ATTR_ULSPACE ); @@ -511,45 +762,45 @@ void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet ) if ( rOldItem.GetPropUpper() != 100 ) { - m_xTopDist->SetRelative( true ); - m_xTopDist->set_value(rOldItem.GetPropUpper(), FieldUnit::NONE); + m_aTopDist.SetRelative( true ); + m_aTopDist.set_value(rOldItem.GetPropUpper(), FieldUnit::NONE); } else { - m_xTopDist->SetRelative(false); + m_aTopDist.SetRelative(false); if (eFUnit == FieldUnit::CHAR) - m_xTopDist->SetFieldUnit(FieldUnit::LINE); + m_aTopDist.SetFieldUnit(FieldUnit::LINE); else - m_xTopDist->SetFieldUnit(eFUnit); - m_xTopDist->SetMetricValue(rOldItem.GetUpper(), eUnit); + m_aTopDist.SetFieldUnit(eFUnit); + m_aTopDist.SetMetricValue(rOldItem.GetUpper(), eUnit); } if ( rOldItem.GetPropLower() != 100 ) { - m_xBottomDist->SetRelative( true ); - m_xBottomDist->set_value(rOldItem.GetPropLower(), FieldUnit::NONE); + m_aBottomDist.SetRelative( true ); + m_aBottomDist.set_value(rOldItem.GetPropLower(), FieldUnit::NONE); } else { - m_xBottomDist->SetRelative(false); + m_aBottomDist.SetRelative(false); if (eFUnit == FieldUnit::CHAR) - m_xBottomDist->SetFieldUnit(FieldUnit::LINE); + m_aBottomDist.SetFieldUnit(FieldUnit::LINE); else - m_xBottomDist->SetFieldUnit(eFUnit); - m_xBottomDist->SetMetricValue(rOldItem.GetLower(), eUnit); + m_aBottomDist.SetFieldUnit(eFUnit); + m_aBottomDist.SetMetricValue(rOldItem.GetLower(), eUnit); } } else { - m_xTopDist->SetMetricValue(rOldItem.GetUpper(), eUnit); - m_xBottomDist->SetMetricValue(rOldItem.GetLower(), eUnit); + m_aTopDist.SetMetricValue(rOldItem.GetUpper(), eUnit); + m_aBottomDist.SetMetricValue(rOldItem.GetLower(), eUnit); } m_xContextualCB->set_active(rOldItem.GetContext()); } else { - m_xTopDist->set_text(OUString()); - m_xBottomDist->set_text(OUString()); + m_aTopDist.set_text(OUString()); + m_aBottomDist.set_text(OUString()); } _nWhich = GetWhich( SID_ATTR_PARA_LINESPACE ); @@ -582,15 +833,15 @@ void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet ) void SvxStdParagraphTabPage::ChangesApplied() { - m_xLeftIndent->save_value(); - m_xRightIndent->save_value(); - m_xFLineIndent->save_value(); + m_aLeftIndent.save_value(); + m_aRightIndent.save_value(); + m_aFLineIndent.save_value(); m_xLineDist->save_value(); m_xLineDistAtPercentBox->save_value(); m_xLineDistAtMetricBox->save_value(); m_xRegisterCB->save_state(); - m_xTopDist->save_value(); - m_xBottomDist->save_value(); + m_aTopDist.save_value(); + m_aBottomDist.save_value(); m_xContextualCB->save_state(); m_xAutoCB->save_state(); } @@ -599,11 +850,11 @@ void SvxStdParagraphTabPage::EnableRelativeMode() { DBG_ASSERT( GetItemSet().GetParent(), "RelativeMode, but no parent-set!" ); - m_xLeftIndent->EnableRelativeMode( 0, 999 ); - m_xFLineIndent->EnableRelativeMode( 0, 999 ); - m_xRightIndent->EnableRelativeMode( 0, 999 ); - m_xTopDist->EnableRelativeMode( 0, 999 ); - m_xBottomDist->EnableRelativeMode( 0, 999 ); + m_aLeftIndent.EnableRelativeMode( 0, 999 ); + m_aFLineIndent.EnableRelativeMode( 0, 999 ); + m_aRightIndent.EnableRelativeMode( 0, 999 ); + m_aTopDist.EnableRelativeMode( 0, 999 ); + m_aBottomDist.EnableRelativeMode( 0, 999 ); bRelativeMode = true; } @@ -658,32 +909,32 @@ SvxStdParagraphTabPage::SvxStdParagraphTabPage(weld::Container* pPage, weld::Dia , nWidth(11905 /*567 * 50*/) , nMinFixDist(0) , bRelativeMode(false) - , m_xLeftIndent(new SvxRelativeField(m_xBuilder->weld_metric_spin_button("spinED_LEFTINDENT", FieldUnit::CM))) - , m_xRightLabel(m_xBuilder->weld_label("labelFT_RIGHTINDENT")) - , m_xRightIndent(new SvxRelativeField(m_xBuilder->weld_metric_spin_button("spinED_RIGHTINDENT", FieldUnit::CM))) + , m_aLeftIndent(m_xBuilder->weld_metric_spin_button("spinED_LEFTINDENT", FieldUnit::CM)) + , m_aRightIndent(m_xBuilder->weld_metric_spin_button("spinED_RIGHTINDENT", FieldUnit::CM)) , m_xFLineLabel(m_xBuilder->weld_label("labelFT_FLINEINDENT")) - , m_xFLineIndent(new SvxRelativeField(m_xBuilder->weld_metric_spin_button("spinED_FLINEINDENT", FieldUnit::CM))) + , m_aFLineIndent(m_xBuilder->weld_metric_spin_button("spinED_FLINEINDENT", FieldUnit::CM)) , m_xAutoCB(m_xBuilder->weld_check_button("checkCB_AUTO")) - , m_xTopDist(new SvxRelativeField(m_xBuilder->weld_metric_spin_button("spinED_TOPDIST", FieldUnit::CM))) - , m_xBottomDist(new SvxRelativeField(m_xBuilder->weld_metric_spin_button("spinED_BOTTOMDIST", FieldUnit::CM))) + , m_aTopDist(m_xBuilder->weld_metric_spin_button("spinED_TOPDIST", FieldUnit::CM)) + , m_aBottomDist(m_xBuilder->weld_metric_spin_button("spinED_BOTTOMDIST", FieldUnit::CM)) , m_xContextualCB(m_xBuilder->weld_check_button("checkCB_CONTEXTUALSPACING")) , m_xLineDist(m_xBuilder->weld_combo_box("comboLB_LINEDIST")) , m_xLineDistAtPercentBox(m_xBuilder->weld_metric_spin_button("spinED_LINEDISTPERCENT", FieldUnit::PERCENT)) , m_xLineDistAtMetricBox(m_xBuilder->weld_metric_spin_button("spinED_LINEDISTMETRIC", FieldUnit::CM)) + , m_xLineDistAtPlaceHolderBox(m_xBuilder->weld_metric_spin_button("spinED_BLANK", FieldUnit::CM)) , m_xLineDistAtLabel(m_xBuilder->weld_label("labelFT_LINEDIST")) , m_xAbsDist(m_xBuilder->weld_label("labelST_LINEDIST_ABS")) , m_xRegisterCB(m_xBuilder->weld_check_button("checkCB_REGISTER")) , m_xExampleWin(new weld::CustomWeld(*m_xBuilder, "drawingareaWN_EXAMPLE", m_aExampleWin)) { - sAbsDist = m_xAbsDist->get_label(); - // this page needs ExchangeSupport SetExchangeSupport(); m_xLineDistAtMetricBox->hide(); + m_xLineDistAtPlaceHolderBox->hide(); + m_xLineDistAtPlaceHolderBox->set_text(OUString()); Init_Impl(); - m_xFLineIndent->set_min(-9999, FieldUnit::NONE); // is set to 0 on default + m_aFLineIndent.set_min(-9999, FieldUnit::NONE); // is set to 0 on default } SvxStdParagraphTabPage::~SvxStdParagraphTabPage() @@ -692,10 +943,10 @@ SvxStdParagraphTabPage::~SvxStdParagraphTabPage() void SvxStdParagraphTabPage::EnableNegativeMode() { - m_xLeftIndent->set_min(-9999, FieldUnit::NONE); - m_xRightIndent->set_min(-9999, FieldUnit::NONE); - m_xRightIndent->EnableNegativeMode(); - m_xLeftIndent->EnableNegativeMode(); + m_aLeftIndent.set_min(-9999, FieldUnit::NONE); + m_aRightIndent.set_min(-9999, FieldUnit::NONE); + m_aRightIndent.EnableNegativeMode(); + m_aLeftIndent.EnableNegativeMode(); } void SvxStdParagraphTabPage::SetLineSpacing_Impl @@ -784,10 +1035,9 @@ IMPL_LINK(SvxStdParagraphTabPage, LineDistHdl_Impl, weld::ComboBox&, rBox, void) case LLINESPACE_15: case LLINESPACE_2: m_xLineDistAtLabel->set_sensitive(false); - m_xLineDistAtPercentBox->set_sensitive(false); - m_xLineDistAtPercentBox->set_text(OUString()); - m_xLineDistAtMetricBox->set_sensitive(false); - m_xLineDistAtMetricBox->set_text(OUString()); + m_xLineDistAtPercentBox->hide(); + m_xLineDistAtMetricBox->hide(); + m_xLineDistAtPlaceHolderBox->show(); break; case LLINESPACE_DURCH: @@ -795,32 +1045,32 @@ IMPL_LINK(SvxStdParagraphTabPage, LineDistHdl_Impl, weld::ComboBox&, rBox, void) // limit MS min(10, aPageSize) m_xLineDistAtMetricBox->set_min(0, FieldUnit::NONE); - if (m_xLineDistAtMetricBox->get_text().isEmpty()) + if (m_xLineDistAtPlaceHolderBox->get_visible()) m_xLineDistAtMetricBox->set_value(m_xLineDistAtMetricBox->normalize(1), FieldUnit::NONE); + m_xLineDistAtPlaceHolderBox->hide(); m_xLineDistAtPercentBox->hide(); m_xLineDistAtMetricBox->show(); - m_xLineDistAtMetricBox->set_sensitive(true); m_xLineDistAtLabel->set_sensitive(true); break; case LLINESPACE_MIN: m_xLineDistAtMetricBox->set_min(0, FieldUnit::NONE); - if (m_xLineDistAtMetricBox->get_text().isEmpty()) + if (m_xLineDistAtPlaceHolderBox->get_visible()) m_xLineDistAtMetricBox->set_value(m_xLineDistAtMetricBox->normalize(10), FieldUnit::TWIP); + m_xLineDistAtPlaceHolderBox->hide(); m_xLineDistAtPercentBox->hide(); m_xLineDistAtMetricBox->show(); - m_xLineDistAtMetricBox->set_sensitive(true); m_xLineDistAtLabel->set_sensitive(true); break; case LLINESPACE_PROP: - if (m_xLineDistAtPercentBox->get_text().isEmpty()) + if (m_xLineDistAtPlaceHolderBox->get_visible()) m_xLineDistAtPercentBox->set_value(m_xLineDistAtPercentBox->normalize(100), FieldUnit::TWIP); + m_xLineDistAtPlaceHolderBox->hide(); m_xLineDistAtMetricBox->hide(); m_xLineDistAtPercentBox->show(); - m_xLineDistAtPercentBox->set_sensitive(true); m_xLineDistAtLabel->set_sensitive(true); break; case LLINESPACE_FIX: @@ -832,9 +1082,9 @@ IMPL_LINK(SvxStdParagraphTabPage, LineDistHdl_Impl, weld::ComboBox&, rBox, void) // it is time for the default if (m_xLineDistAtMetricBox->get_value(FieldUnit::NONE) != nTemp) SetMetricValue( *m_xLineDistAtMetricBox, FIX_DIST_DEF, MapUnit::MapTwip ); // fix is only in Writer + m_xLineDistAtPlaceHolderBox->hide(); m_xLineDistAtPercentBox->hide(); m_xLineDistAtMetricBox->show(); - m_xLineDistAtMetricBox->set_sensitive(true); m_xLineDistAtLabel->set_sensitive(true); } break; @@ -853,31 +1103,31 @@ void SvxStdParagraphTabPage::Init_Impl() m_xLineDist->connect_changed(LINK(this, SvxStdParagraphTabPage, LineDistHdl_Impl)); Link<weld::MetricSpinButton&,void> aLink2 = LINK(this, SvxStdParagraphTabPage, ELRLoseFocusHdl); - m_xFLineIndent->connect_value_changed(aLink2); - m_xLeftIndent->connect_value_changed(aLink2); - m_xRightIndent->connect_value_changed(aLink2); + m_aFLineIndent.connect_value_changed(aLink2); + m_aLeftIndent.connect_value_changed(aLink2); + m_aRightIndent.connect_value_changed(aLink2); Link<weld::MetricSpinButton&,void> aLink = LINK(this, SvxStdParagraphTabPage, ModifyHdl_Impl); - m_xTopDist->connect_value_changed(aLink); - m_xBottomDist->connect_value_changed(aLink); + m_aTopDist.connect_value_changed(aLink); + m_aBottomDist.connect_value_changed(aLink); m_xAutoCB->connect_toggled(LINK(this, SvxStdParagraphTabPage, AutoHdl_Impl)); SfxItemPool* pPool = GetItemSet().GetPool(); DBG_ASSERT( pPool, "Where is the pool?" ); FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( GetWhich( SID_ATTR_LRSPACE ) ) ); - m_xTopDist->set_max( m_xTopDist->normalize( MAX_DURCH ), eUnit ); - m_xBottomDist->set_max( m_xBottomDist->normalize( MAX_DURCH ), eUnit ); + m_aTopDist.set_max( m_aTopDist.normalize( MAX_DURCH ), eUnit ); + m_aBottomDist.set_max( m_aBottomDist.normalize( MAX_DURCH ), eUnit ); m_xLineDistAtMetricBox->set_max( m_xLineDistAtMetricBox->normalize( MAX_DURCH ), eUnit ); } void SvxStdParagraphTabPage::UpdateExample_Impl() { - m_aExampleWin.SetFirstLineOffset( static_cast<short>(m_xFLineIndent->denormalize( m_xFLineIndent->get_value( FieldUnit::TWIP ) )) ); - m_aExampleWin.SetLeftMargin( static_cast<tools::Long>(m_xLeftIndent->denormalize( m_xLeftIndent->get_value( FieldUnit::TWIP ) ) ) ); - m_aExampleWin.SetRightMargin( static_cast<tools::Long>(m_xRightIndent->denormalize( m_xRightIndent->get_value( FieldUnit::TWIP ) ) ) ); - m_aExampleWin.SetUpper( static_cast<sal_uInt16>(m_xTopDist->denormalize( m_xTopDist->get_value( FieldUnit::TWIP ) )) ); - m_aExampleWin.SetLower( static_cast<sal_uInt16>(m_xBottomDist->denormalize( m_xBottomDist->get_value( FieldUnit::TWIP ) )) ); + m_aExampleWin.SetFirstLineOffset( static_cast<short>(m_aFLineIndent.denormalize( m_aFLineIndent.get_value( FieldUnit::TWIP ) )) ); + m_aExampleWin.SetLeftMargin( static_cast<tools::Long>(m_aLeftIndent.denormalize( m_aLeftIndent.get_value( FieldUnit::TWIP ) ) ) ); + m_aExampleWin.SetRightMargin( static_cast<tools::Long>(m_aRightIndent.denormalize( m_aRightIndent.get_value( FieldUnit::TWIP ) ) ) ); + m_aExampleWin.SetUpper( static_cast<sal_uInt16>(m_aTopDist.denormalize( m_aTopDist.get_value( FieldUnit::TWIP ) )) ); + m_aExampleWin.SetLower( static_cast<sal_uInt16>(m_aBottomDist.denormalize( m_aBottomDist.get_value( FieldUnit::TWIP ) )) ); int nPos = m_xLineDist->get_active(); @@ -911,7 +1161,7 @@ IMPL_LINK(SvxStdParagraphTabPage, AutoHdl_Impl, weld::Toggleable&, rBox, void) { bool bEnable = !rBox.get_active(); m_xFLineLabel->set_sensitive(bEnable); - m_xFLineIndent->set_sensitive(bEnable); + m_aFLineIndent.set_sensitive(bEnable); } void SvxStdParagraphTabPage::EnableAutoFirstLine() @@ -919,12 +1169,6 @@ void SvxStdParagraphTabPage::EnableAutoFirstLine() m_xAutoCB->show(); } -void SvxStdParagraphTabPage::EnableAbsLineDist(tools::Long nMinTwip) -{ - m_xLineDist->append_text(sAbsDist); - nMinFixDist = nMinTwip; -} - void SvxStdParagraphTabPage::PageCreated(const SfxAllItemSet& aSet) { @@ -937,7 +1181,6 @@ void SvxStdParagraphTabPage::PageCreated(const SfxAllItemSet& aSet) */ const SfxUInt16Item* pPageWidthItem = aSet.GetItem<SfxUInt16Item>(SID_SVXSTDPARAGRAPHTABPAGE_PAGEWIDTH, false); const SfxUInt32Item* pFlagSetItem = aSet.GetItem<SfxUInt32Item>(SID_SVXSTDPARAGRAPHTABPAGE_FLAGSET, false); - const SfxUInt32Item* pLineDistItem = aSet.GetItem<SfxUInt32Item>(SID_SVXSTDPARAGRAPHTABPAGE_ABSLINEDIST, false); if (pPageWidthItem) nWidth = pPageWidthItem->GetValue(); @@ -954,9 +1197,6 @@ void SvxStdParagraphTabPage::PageCreated(const SfxAllItemSet& aSet) EnableAutoFirstLine(); } - if(pLineDistItem) - EnableAbsLineDist(pLineDistItem->GetValue()); - if (pFlagSetItem) { if (( 0x0008 & pFlagSetItem->GetValue()) == 0x0008 ) @@ -975,6 +1215,7 @@ void SvxStdParagraphTabPage::PageCreated(const SfxAllItemSet& aSet) SvxParaAlignTabPage::SvxParaAlignTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/paragalignpage.ui", "ParaAlignPage", &rSet) + , m_bSdrVertAlign(false) , m_xLeft(m_xBuilder->weld_radio_button("radioBTN_LEFTALIGN")) , m_xRight(m_xBuilder->weld_radio_button("radioBTN_RIGHTALIGN")) , m_xCenter(m_xBuilder->weld_radio_button("radioBTN_CENTERALIGN")) @@ -988,7 +1229,8 @@ SvxParaAlignTabPage::SvxParaAlignTabPage(weld::Container* pPage, weld::DialogCon , m_xExampleWin(new weld::CustomWeld(*m_xBuilder, "drawingareaWN_EXAMPLE", m_aExampleWin)) , m_xVertAlignFL(m_xBuilder->weld_widget("frameFL_VERTALIGN")) , m_xVertAlignLB(m_xBuilder->weld_combo_box("comboLB_VERTALIGN")) - , m_xPropertiesFL(m_xBuilder->weld_widget("framePROPERTIES")) + , m_xVertAlign(m_xBuilder->weld_label("labelFL_VERTALIGN")) + , m_xVertAlignSdr(m_xBuilder->weld_label("labelST_VERTALIGN_SDR")) , m_xTextDirectionLB(new svx::FrameDirectionListBox(m_xBuilder->weld_combo_box("comboLB_TEXTDIRECTION"))) { SetExchangeSupport(); @@ -1104,7 +1346,10 @@ bool SvxParaAlignTabPage::FillItemSet( SfxItemSet* rOutSet ) if (m_xVertAlignLB->get_value_changed_from_saved()) { - rOutSet->Put(SvxParaVertAlignItem(static_cast<SvxParaVertAlignItem::Align>(m_xVertAlignLB->get_active()), GetWhich( SID_PARA_VERTALIGN ))); + if (m_bSdrVertAlign) + rOutSet->Put(SdrTextVertAdjustItem(static_cast<SdrTextVertAdjust>(m_xVertAlignLB->get_active()))); + else + rOutSet->Put(SvxParaVertAlignItem(static_cast<SvxParaVertAlignItem::Align>(m_xVertAlignLB->get_active()), GetWhich( SID_PARA_VERTALIGN ))); bModified = true; } @@ -1190,16 +1435,23 @@ void SvxParaAlignTabPage::Reset( const SfxItemSet* rSet ) m_xSnapToGridCB->set_active(rSnap.GetValue()); } - _nWhich = GetWhich( SID_PARA_VERTALIGN ); + _nWhich = m_bSdrVertAlign ? SDRATTR_TEXT_VERTADJUST : GetWhich( SID_PARA_VERTALIGN ); eItemState = rSet->GetItemState( _nWhich ); if ( eItemState >= SfxItemState::DEFAULT ) { m_xVertAlignFL->show(); - const SvxParaVertAlignItem& rAlign = static_cast<const SvxParaVertAlignItem&>(rSet->Get( _nWhich )); - - m_xVertAlignLB->set_active(static_cast<sal_Int32>(rAlign.GetValue())); + if (m_bSdrVertAlign) + { + const SdrTextVertAdjustItem& rAlign = static_cast<const SdrTextVertAdjustItem&>(rSet->Get( _nWhich )); + m_xVertAlignLB->set_active(rAlign.GetValue()); + } + else + { + const SvxParaVertAlignItem& rAlign = static_cast<const SvxParaVertAlignItem&>(rSet->Get( _nWhich )); + m_xVertAlignLB->set_active(static_cast<sal_Int32>(rAlign.GetValue())); + } } _nWhich = GetWhich( SID_ATTR_FRAMEDIRECTION ); @@ -1329,6 +1581,15 @@ void SvxParaAlignTabPage::EnableJustifyExt() } +void SvxParaAlignTabPage::EnableSdrVertAlign() +{ + m_bSdrVertAlign = true; + + m_xVertAlignLB->remove_id("0"); + m_xVertAlignLB->remove_id("1"); + m_xVertAlign->set_label(m_xVertAlignSdr->get_label()); +} + void SvxParaAlignTabPage::PageCreated (const SfxAllItemSet& aSet) { const SfxBoolItem* pBoolItem = aSet.GetItem<SfxBoolItem>(SID_SVXPARAALIGNTABPAGE_ENABLEJUSTIFYEXT, false); @@ -1350,22 +1611,68 @@ bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) if ( m_xHyphenBox->get_state_changed_from_saved() || m_xHyphenNoCapsBox->get_state_changed_from_saved() || + m_xHyphenNoLastWordBox->get_state_changed_from_saved() || m_xExtHyphenBeforeBox->get_value_changed_from_saved() || m_xExtHyphenAfterBox->get_value_changed_from_saved() || - m_xMaxHyphenEdit->get_value_changed_from_saved() ) + m_xExtCompoundHyphenBeforeBox->get_value_changed_from_saved() || + m_xMaxHyphenEdit->get_value_changed_from_saved() || + m_xMinWordLength->get_value_changed_from_saved() || + m_aHyphenZone.get_value_changed_from_saved() || + m_xAcrossColumnBox->get_state_changed_from_saved() || + m_xAcrossPageBox->get_state_changed_from_saved() || + m_xAcrossSpreadBox->get_state_changed_from_saved() ) { SvxHyphenZoneItem aHyphen( static_cast<const SvxHyphenZoneItem&>(GetItemSet().Get( _nWhich )) ); aHyphen.SetHyphen( eHyphenState == TRISTATE_TRUE ); - aHyphen.SetNoCapsHyphenation(m_xHyphenNoCapsBox->get_state() == TRISTATE_TRUE); + aHyphen.SetNoCapsHyphenation(m_xHyphenNoCapsBox->get_state() != TRISTATE_TRUE); + aHyphen.SetNoLastWordHyphenation(m_xHyphenNoLastWordBox->get_state() != TRISTATE_TRUE); if ( eHyphenState == TRISTATE_TRUE ) { aHyphen.GetMinLead() = static_cast<sal_uInt8>(m_xExtHyphenBeforeBox->get_value()); aHyphen.GetMinTrail() = static_cast<sal_uInt8>(m_xExtHyphenAfterBox->get_value()); + aHyphen.GetCompoundMinLead() = static_cast<sal_uInt8>(m_xExtCompoundHyphenBeforeBox->get_value()); + aHyphen.GetMinWordLength() = static_cast<sal_uInt8>(m_xMinWordLength->get_value()); } aHyphen.GetMaxHyphens() = static_cast<sal_uInt8>(m_xMaxHyphenEdit->get_value()); + SfxItemPool* pPool = GetItemSet().GetPool(); + DBG_ASSERT( pPool, "Where is the pool?" ); + MapUnit eUnit = pPool->GetMetric( _nWhich ); + aHyphen.GetTextHyphenZone() = static_cast<sal_uInt16>(m_aHyphenZone.GetCoreValue(eUnit)); + aHyphen.SetHyphen( eHyphenState == TRISTATE_TRUE ); + aHyphen.SetNoLastWordHyphenation(m_xHyphenNoLastWordBox->get_state() != TRISTATE_TRUE); + const TriState eAcrossColumnState = m_xAcrossColumnBox->get_state(); + const TriState eAcrossPageState = m_xAcrossPageBox->get_state(); + const TriState eAcrossSpreadState = m_xAcrossSpreadBox->get_state(); + aHyphen.SetKeep( eAcrossSpreadState != TRISTATE_TRUE ); + if ( eAcrossSpreadState == TRISTATE_TRUE ) + { + // hyphenate across column, page and spread -> ParaHyphenationKeep = false and + // set default value 3 (COLUMN) + aHyphen.GetKeepType() = + static_cast<sal_uInt8>(css::text::ParagraphHyphenationKeepType::COLUMN); + } + else if ( eAcrossPageState == TRISTATE_TRUE ) + { + // hyphenate across column and page, but not spread -> 1 (SPREAD) + aHyphen.GetKeepType() = + static_cast<sal_uInt8>(css::text::ParagraphHyphenationKeepType::SPREAD); + } + else if ( eAcrossColumnState == TRISTATE_TRUE ) + { + // hyphenate across column, but not page and spread -> 2 (PAGE) + aHyphen.GetKeepType() = + static_cast<sal_uInt8>(css::text::ParagraphHyphenationKeepType::PAGE); + } + else + { + // don't hyphenate across column, page and spread -> 3 (COLUMN) + aHyphen.GetKeepType() = + static_cast<sal_uInt8>(css::text::ParagraphHyphenationKeepType::COLUMN); + } + if ( !pOld || *static_cast<const SvxHyphenZoneItem*>(pOld) != aHyphen || m_xHyphenBox->get_state_changed_from_saved()) @@ -1403,7 +1710,6 @@ bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) TriState eState = m_xApplyCollBtn->get_state(); bool bIsPageModel = false; - _nWhich = GetWhich( SID_ATTR_PARA_MODEL ); OUString sPage; if ( m_xApplyCollBtn->get_state_changed_from_saved() || ( TRISTATE_TRUE == eState && @@ -1418,7 +1724,7 @@ bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) if ( !pOld || static_cast<const SvxPageModelItem*>(pOld)->GetValue() != sPage ) { - rOutSet->Put( SvxPageModelItem( sPage, false, _nWhich ) ); + rOutSet->Put( SvxPageModelItem( sPage, false, SID_ATTR_PARA_MODEL ) ); bModified = true; } else @@ -1427,7 +1733,7 @@ bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) else if(TRISTATE_TRUE == eState && m_xApplyCollBtn->get_sensitive()) bIsPageModel = true; else - rOutSet->Put( SvxPageModelItem( sPage, false, _nWhich ) ); + rOutSet->Put( SvxPageModelItem( sPage, false, SID_ATTR_PARA_MODEL ) ); _nWhich = GetWhich( SID_ATTR_PARA_PAGEBREAK ); @@ -1489,9 +1795,9 @@ bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) // paragraph split _nWhich = GetWhich( SID_ATTR_PARA_SPLIT ); - eState = m_xKeepTogetherBox->get_state(); + eState = m_xAllowSplitBox->get_state(); - if (m_xKeepTogetherBox->get_state_changed_from_saved()) + if (m_xAllowSplitBox->get_state_changed_from_saved()) { pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_SPLIT ); @@ -1515,14 +1821,14 @@ bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) } // widows and orphans - _nWhich = GetWhich( SID_ATTR_PARA_WIDOWS ); + TypedWhichId<SvxWidowsItem> nWidowsWhich = GetWhich( SID_ATTR_PARA_WIDOWS ); eState = m_xWidowBox->get_state(); if ( m_xWidowBox->get_state_changed_from_saved() || m_xWidowRowNo->get_value_changed_from_saved() ) { SvxWidowsItem rItem( eState == TRISTATE_TRUE ? - static_cast<sal_uInt8>(m_xWidowRowNo->get_value()) : 0, _nWhich ); + static_cast<sal_uInt8>(m_xWidowRowNo->get_value()) : 0, nWidowsWhich ); pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_WIDOWS ); if ( m_xWidowBox->get_state_changed_from_saved() || !pOld || !( *static_cast<const SvxWidowsItem*>(pOld) == rItem ) ) @@ -1532,14 +1838,14 @@ bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) } } - _nWhich = GetWhich( SID_ATTR_PARA_ORPHANS ); + TypedWhichId<SvxOrphansItem> nOrphansWhich = GetWhich( SID_ATTR_PARA_ORPHANS ); eState = m_xOrphanBox->get_state(); if ( m_xOrphanBox->get_state_changed_from_saved() || m_xOrphanRowNo->get_value_changed_from_saved() ) { SvxOrphansItem rItem( eState == TRISTATE_TRUE ? - static_cast<sal_uInt8>(m_xOrphanRowNo->get_value()) : 0, _nWhich ); + static_cast<sal_uInt8>(m_xOrphanRowNo->get_value()) : 0, nOrphansWhich ); pOld = GetOldItem( *rOutSet, SID_ATTR_PARA_ORPHANS ); if ( m_xOrphanBox->get_state_changed_from_saved() || @@ -1555,6 +1861,14 @@ bool SvxExtParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) } void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet ) { + SfxItemPool* pPool = rSet->GetPool(); + DBG_ASSERT( pPool, "Where is the pool?" ); + + // adjust metric + FieldUnit eFUnit = GetModuleFieldUnit( *rSet ); + if (UseCharUnitInUI(*rSet)) + eFUnit = FieldUnit::CHAR; + sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_HYPHENZONE ); SfxItemState eItemState = rSet->GetItemState( _nWhich ); @@ -1568,40 +1882,61 @@ void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet ) bIsHyphen = rHyphen.IsHyphen(); m_xHyphenBox->set_state(bIsHyphen ? TRISTATE_TRUE : TRISTATE_FALSE); - m_xHyphenNoCapsBox->set_state(rHyphen.IsNoCapsHyphenation() ? TRISTATE_TRUE : TRISTATE_FALSE); + m_xHyphenNoCapsBox->set_state(rHyphen.IsNoCapsHyphenation() ? TRISTATE_FALSE : TRISTATE_TRUE); + m_xHyphenNoLastWordBox->set_state(rHyphen.IsNoLastWordHyphenation() ? TRISTATE_FALSE : TRISTATE_TRUE); m_xExtHyphenBeforeBox->set_value(rHyphen.GetMinLead()); m_xExtHyphenAfterBox->set_value(rHyphen.GetMinTrail()); + m_xExtCompoundHyphenBeforeBox->set_value(rHyphen.GetCompoundMinLead()); m_xMaxHyphenEdit->set_value(rHyphen.GetMaxHyphens()); + m_xMinWordLength->set_value(rHyphen.GetMinWordLength()); + m_aHyphenZone.SetFieldUnit(eFUnit); + m_aHyphenZone.SetMetricValue(rHyphen.GetTextHyphenZone(), MapUnit::MapTwip); + m_xAcrossColumnBox->set_state(!rHyphen.IsKeep() || rHyphen.GetKeepType() < 3 ? TRISTATE_TRUE : TRISTATE_FALSE); + m_xAcrossPageBox->set_state(!rHyphen.IsKeep() || rHyphen.GetKeepType() < 2 ? TRISTATE_TRUE : TRISTATE_FALSE); + m_xAcrossSpreadBox->set_state(!rHyphen.IsKeep() || rHyphen.GetKeepType() == 0 ? TRISTATE_TRUE : TRISTATE_FALSE); + aAcrossColumnState.bTriStateEnabled = false; + aAcrossPageState.bTriStateEnabled = false; + aAcrossSpreadState.bTriStateEnabled = false; } else { m_xHyphenBox->set_state(TRISTATE_INDET); m_xHyphenNoCapsBox->set_state(TRISTATE_INDET); + m_xHyphenNoLastWordBox->set_state(TRISTATE_INDET); } bool bEnable = bItemAvailable && bIsHyphen; m_xHyphenNoCapsBox->set_sensitive(bEnable); + m_xHyphenNoLastWordBox->set_sensitive(bEnable); m_xExtHyphenBeforeBox->set_sensitive(bEnable); m_xExtHyphenAfterBox->set_sensitive(bEnable); + m_xExtCompoundHyphenBeforeBox->set_sensitive(bEnable); m_xBeforeText->set_sensitive(bEnable); m_xAfterText->set_sensitive(bEnable); + m_xCompoundBeforeText->set_sensitive(bEnable); m_xMaxHyphenLabel->set_sensitive(bEnable); m_xMaxHyphenEdit->set_sensitive(bEnable); + m_xMinWordLabel->set_sensitive(bEnable); + m_xMinWordLength->set_sensitive(bEnable); + m_xHyphenZoneLabel->set_sensitive(bEnable); + m_aHyphenZone.set_sensitive(bEnable); + m_xAcrossText->set_sensitive(bEnable); + m_xAcrossColumnBox->set_sensitive(bEnable); + m_xAcrossPageBox->set_sensitive(bEnable); + m_xAcrossSpreadBox->set_sensitive(bEnable); - _nWhich = GetWhich( SID_ATTR_PARA_PAGENUM ); - - switch (rSet->GetItemState(_nWhich)) + switch (rSet->GetItemState(SID_ATTR_PARA_PAGENUM)) { case SfxItemState::SET: { aPageNumState.bTriStateEnabled = false; m_xPageNumBox->set_state(TRISTATE_TRUE); - SfxUInt16Item const*const pItem(rSet->GetItem<SfxUInt16Item>(_nWhich)); + SfxUInt16Item const*const pItem(rSet->GetItem<SfxUInt16Item>(SID_ATTR_PARA_PAGENUM)); const sal_uInt16 nPageNum(pItem->GetValue()); m_xPagenumEdit->set_value(nPageNum); break; } - case SfxItemState::DONTCARE: + case SfxItemState::INVALID: { aPageNumState.bTriStateEnabled = true; m_xPageNumBox->set_state(TRISTATE_INDET); @@ -1623,16 +1958,14 @@ void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet ) if ( bPageBreak ) { // first handle PageModel - _nWhich = GetWhich( SID_ATTR_PARA_MODEL ); bool bIsPageModel = false; - eItemState = rSet->GetItemState( _nWhich ); + eItemState = rSet->GetItemState( SID_ATTR_PARA_MODEL ); if ( eItemState >= SfxItemState::SET ) { aApplyCollState.bTriStateEnabled = false; - const SvxPageModelItem& rModel = - static_cast<const SvxPageModelItem&>(rSet->Get( _nWhich )); + const SvxPageModelItem& rModel = rSet->Get( SID_ATTR_PARA_MODEL ); const OUString& aStr( rModel.GetValue() ); if (!aStr.isEmpty() && m_xApplyCollBox->find_text(aStr) != -1) @@ -1661,7 +1994,7 @@ void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet ) m_xApplyCollBtn->set_state(TRISTATE_FALSE); } } - else if ( SfxItemState::DONTCARE == eItemState ) + else if ( SfxItemState::INVALID == eItemState ) { aApplyCollState.bTriStateEnabled = true; m_xApplyCollBtn->set_state(TRISTATE_INDET); @@ -1733,7 +2066,7 @@ void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet ) m_xBreakTypeLB->set_active(nType); m_xBreakPositionLB->set_active(nPosition); } - else if ( SfxItemState::DONTCARE == eItemState ) + else if ( SfxItemState::INVALID == eItemState ) m_xPageBreakBox->set_state(TRISTATE_INDET); else { @@ -1763,7 +2096,7 @@ void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet ) else m_xKeepParaBox->set_state(TRISTATE_FALSE); } - else if ( SfxItemState::DONTCARE == eItemState ) + else if ( SfxItemState::INVALID == eItemState ) m_xKeepParaBox->set_state(TRISTATE_INDET); else m_xKeepParaBox->set_sensitive(false); @@ -1775,70 +2108,69 @@ void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet ) { const SvxFormatSplitItem& rSplit = static_cast<const SvxFormatSplitItem&>(rSet->Get( _nWhich )); - aKeepTogetherState.bTriStateEnabled = false; + aAllowSplitState.bTriStateEnabled = false; if ( !rSplit.GetValue() ) - m_xKeepTogetherBox->set_state(TRISTATE_TRUE); + m_xAllowSplitBox->set_state(TRISTATE_FALSE); else { - m_xKeepTogetherBox->set_state(TRISTATE_FALSE); - - // widows and orphans + m_xAllowSplitBox->set_state(TRISTATE_TRUE); + // default widows and orphans to enabled m_xWidowBox->set_sensitive(true); - _nWhich = GetWhich( SID_ATTR_PARA_WIDOWS ); - SfxItemState eTmpState = rSet->GetItemState( _nWhich ); - - if ( eTmpState >= SfxItemState::DEFAULT ) - { - const SvxWidowsItem& rWidow = - static_cast<const SvxWidowsItem&>(rSet->Get( _nWhich )); - aWidowState.bTriStateEnabled = false; - const sal_uInt16 nLines = rWidow.GetValue(); + m_xOrphanBox->set_sensitive(true); + } - bool _bEnable = nLines > 0; - m_xWidowRowNo->set_value(m_xWidowRowNo->normalize(nLines)); - m_xWidowBox->set_state(_bEnable ? TRISTATE_TRUE : TRISTATE_FALSE); - m_xWidowRowNo->set_sensitive(_bEnable); - //m_xWidowRowLabel->set_sensitive(_bEnable); + // widows and orphans + _nWhich = GetWhich( SID_ATTR_PARA_WIDOWS ); + SfxItemState eTmpState = rSet->GetItemState( _nWhich ); - } - else if ( SfxItemState::DONTCARE == eTmpState ) - m_xWidowBox->set_state( TRISTATE_INDET ); - else - m_xWidowBox->set_sensitive(false); + if ( eTmpState >= SfxItemState::DEFAULT ) + { + const SvxWidowsItem& rWidow = + static_cast<const SvxWidowsItem&>(rSet->Get( _nWhich )); + aWidowState.bTriStateEnabled = false; + const sal_uInt16 nLines = rWidow.GetValue(); + + bool _bEnable = nLines > 0; + m_xWidowRowNo->set_value(m_xWidowRowNo->normalize(nLines)); + m_xWidowBox->set_state(_bEnable ? TRISTATE_TRUE : TRISTATE_FALSE); + m_xWidowRowNo->set_sensitive(_bEnable); + } + else if ( SfxItemState::INVALID == eTmpState ) + m_xWidowBox->set_state( TRISTATE_INDET ); + else + m_xWidowBox->set_sensitive(false); - m_xOrphanBox->set_sensitive(true); - _nWhich = GetWhich( SID_ATTR_PARA_ORPHANS ); - eTmpState = rSet->GetItemState( _nWhich ); + _nWhich = GetWhich( SID_ATTR_PARA_ORPHANS ); + eTmpState = rSet->GetItemState( _nWhich ); - if ( eTmpState >= SfxItemState::DEFAULT ) - { - const SvxOrphansItem& rOrphan = - static_cast<const SvxOrphansItem&>(rSet->Get( _nWhich )); - const sal_uInt16 nLines = rOrphan.GetValue(); - aOrphanState.bTriStateEnabled = false; + if ( eTmpState >= SfxItemState::DEFAULT ) + { + const SvxOrphansItem& rOrphan = + static_cast<const SvxOrphansItem&>(rSet->Get( _nWhich )); + const sal_uInt16 nLines = rOrphan.GetValue(); + aOrphanState.bTriStateEnabled = false; - bool _bEnable = nLines > 0; - m_xOrphanBox->set_state(_bEnable ? TRISTATE_TRUE : TRISTATE_FALSE); - m_xOrphanRowNo->set_value(m_xOrphanRowNo->normalize(nLines)); - m_xOrphanRowNo->set_sensitive(_bEnable); - m_xOrphanRowLabel->set_sensitive(_bEnable); + bool _bEnable = nLines > 0; + m_xOrphanBox->set_state(_bEnable ? TRISTATE_TRUE : TRISTATE_FALSE); + m_xOrphanRowNo->set_value(m_xOrphanRowNo->normalize(nLines)); + m_xOrphanRowNo->set_sensitive(_bEnable); + m_xOrphanRowLabel->set_sensitive(_bEnable); - } - else if ( SfxItemState::DONTCARE == eTmpState ) - m_xOrphanBox->set_state(TRISTATE_INDET); - else - m_xOrphanBox->set_sensitive(false); - aOrphanState.eState = m_xOrphanBox->get_state(); } + else if ( SfxItemState::INVALID == eTmpState ) + m_xOrphanBox->set_state(TRISTATE_INDET); + else + m_xOrphanBox->set_sensitive(false); + aOrphanState.eState = m_xOrphanBox->get_state(); } - else if ( SfxItemState::DONTCARE == eItemState ) - m_xKeepTogetherBox->set_state(TRISTATE_INDET); + else if ( SfxItemState::INVALID == eItemState ) + m_xAllowSplitBox->set_state(TRISTATE_INDET); else - m_xKeepTogetherBox->set_sensitive(false); + m_xAllowSplitBox->set_sensitive(false); // so that everything is enabled correctly - KeepTogetherHdl(); + AllowSplitHdl(); WidowHdl(); OrphanHdl(); ChangesApplied(); @@ -1847,9 +2179,16 @@ void SvxExtParagraphTabPage::ChangesApplied() { m_xHyphenBox->save_state(); m_xHyphenNoCapsBox->save_state(); - m_xExtHyphenBeforeBox->set_value(m_xExtHyphenBeforeBox->get_value()); - m_xExtHyphenAfterBox->set_value(m_xExtHyphenAfterBox->get_value()); - m_xMaxHyphenEdit->set_value(m_xMaxHyphenEdit->get_value()); + m_xHyphenNoLastWordBox->save_state(); + m_xExtHyphenBeforeBox->save_value(); + m_xExtHyphenAfterBox->save_value(); + m_xExtCompoundHyphenBeforeBox->save_value(); + m_xMaxHyphenEdit->save_value(); + m_xMinWordLength->save_value(); + m_aHyphenZone.save_value(); + m_xAcrossColumnBox->save_state(); + m_xAcrossPageBox->save_state(); + m_xAcrossSpreadBox->save_state(); m_xPageBreakBox->save_state(); m_xBreakPositionLB->save_value(); m_xBreakTypeLB->save_value(); @@ -1857,7 +2196,7 @@ void SvxExtParagraphTabPage::ChangesApplied() m_xApplyCollBox->save_value(); m_xPageNumBox->save_state(); m_xPagenumEdit->save_value(); - m_xKeepTogetherBox->save_state(); + m_xAllowSplitBox->save_state(); m_xKeepParaBox->save_state(); m_xWidowBox->save_state(); m_xOrphanBox->save_state(); @@ -1893,12 +2232,19 @@ SvxExtParagraphTabPage::SvxExtParagraphTabPage(weld::Container* pPage, weld::Dia // Hyphenation , m_xHyphenBox(m_xBuilder->weld_check_button("checkAuto")) , m_xHyphenNoCapsBox(m_xBuilder->weld_check_button("checkNoCaps")) + , m_xHyphenNoLastWordBox(m_xBuilder->weld_check_button("checkNoLastWord")) , m_xBeforeText(m_xBuilder->weld_label("labelLineBegin")) , m_xExtHyphenBeforeBox(m_xBuilder->weld_spin_button("spinLineEnd")) , m_xAfterText(m_xBuilder->weld_label("labelLineEnd")) , m_xExtHyphenAfterBox(m_xBuilder->weld_spin_button("spinLineBegin")) + , m_xCompoundBeforeText(m_xBuilder->weld_label("labelCompoundLineEnd")) + , m_xExtCompoundHyphenBeforeBox(m_xBuilder->weld_spin_button("spinCompoundLineEnd")) , m_xMaxHyphenLabel(m_xBuilder->weld_label("labelMaxNum")) , m_xMaxHyphenEdit(m_xBuilder->weld_spin_button("spinMaxNum")) + , m_xMinWordLabel(m_xBuilder->weld_label("labelMinLen")) + , m_xMinWordLength(m_xBuilder->weld_spin_button("spinMinLen")) + , m_xHyphenZoneLabel(m_xBuilder->weld_label("labelHyphenZone")) + , m_aHyphenZone(m_xBuilder->weld_metric_spin_button("spinHyphenZone", FieldUnit::CM)) //Page break , m_xPageBreakBox(m_xBuilder->weld_check_button("checkInsert")) , m_xBreakTypeFT(m_xBuilder->weld_label("labelType")) @@ -1910,7 +2256,7 @@ SvxExtParagraphTabPage::SvxExtParagraphTabPage(weld::Container* pPage, weld::Dia , m_xPageNumBox(m_xBuilder->weld_check_button("labelPageNum")) , m_xPagenumEdit(m_xBuilder->weld_spin_button("spinPageNumber")) // Options - , m_xKeepTogetherBox(m_xBuilder->weld_check_button("checkSplitPara")) + , m_xAllowSplitBox(m_xBuilder->weld_check_button("checkSplitPara")) , m_xKeepParaBox(m_xBuilder->weld_check_button("checkKeepPara")) , m_xOrphanBox(m_xBuilder->weld_check_button("checkOrphan")) , m_xOrphanRowNo(m_xBuilder->weld_spin_button("spinOrphan")) @@ -1918,13 +2264,18 @@ SvxExtParagraphTabPage::SvxExtParagraphTabPage(weld::Container* pPage, weld::Dia , m_xWidowBox(m_xBuilder->weld_check_button("checkWidow")) , m_xWidowRowNo(m_xBuilder->weld_spin_button("spinWidow")) , m_xWidowRowLabel(m_xBuilder->weld_label("labelWidow")) + // Avoid hyphenation across + , m_xAcrossText(m_xBuilder->weld_label("labelHyphenAcross")) + , m_xAcrossColumnBox(m_xBuilder->weld_check_button("checkAcrossColumn")) + , m_xAcrossPageBox(m_xBuilder->weld_check_button("checkAcrossPage")) + , m_xAcrossSpreadBox(m_xBuilder->weld_check_button("checkAcrossSpread")) { // this page needs ExchangeSupport SetExchangeSupport(); m_xHyphenBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, HyphenClickHdl_Impl)); m_xPageBreakBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, PageBreakHdl_Impl)); - m_xKeepTogetherBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, KeepTogetherHdl_Impl)); + m_xAllowSplitBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, AllowSplitHdl_Impl)); m_xWidowBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, WidowHdl_Impl)); m_xOrphanBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, OrphanHdl_Impl)); m_xApplyCollBtn->connect_toggled(LINK(this, SvxExtParagraphTabPage, ApplyCollClickHdl_Impl)); @@ -1932,9 +2283,11 @@ SvxExtParagraphTabPage::SvxExtParagraphTabPage(weld::Container* pPage, weld::Dia m_xBreakPositionLB->connect_changed(LINK(this, SvxExtParagraphTabPage, PageBreakPosHdl_Impl)); m_xPageNumBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, PageNumBoxClickHdl_Impl)); m_xKeepParaBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, KeepParaBoxClickHdl_Impl)); + m_xAcrossColumnBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, AcrossColumnHdl_Impl)); + m_xAcrossPageBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, AcrossPageHdl_Impl)); + m_xAcrossSpreadBox->connect_toggled(LINK(this, SvxExtParagraphTabPage, AcrossSpreadHdl_Impl)); - SfxObjectShell* pSh = SfxObjectShell::Current(); - if ( pSh ) + if (SfxObjectShell* pSh = SfxObjectShell::Current()) { SfxStyleSheetBasePool* pPool = pSh->GetStyleSheetPool(); SfxStyleSheetBase* pStyle = pPool->First(SfxStyleFamily::Page); @@ -1960,14 +2313,25 @@ SvxExtParagraphTabPage::SvxExtParagraphTabPage(weld::Container* pPage, weld::Dia bHtmlMode = true; m_xHyphenBox->set_sensitive(false); m_xHyphenNoCapsBox->set_sensitive(false); + m_xHyphenNoLastWordBox->set_sensitive(false); m_xBeforeText->set_sensitive(false); m_xExtHyphenBeforeBox->set_sensitive(false); m_xAfterText->set_sensitive(false); m_xExtHyphenAfterBox->set_sensitive(false); + m_xCompoundBeforeText->set_sensitive(false); + m_xExtCompoundHyphenBeforeBox->set_sensitive(false); m_xMaxHyphenLabel->set_sensitive(false); m_xMaxHyphenEdit->set_sensitive(false); + m_xMinWordLabel->set_sensitive(false); + m_xMinWordLength->set_sensitive(false); + m_xHyphenZoneLabel->set_sensitive(false); + m_aHyphenZone.set_sensitive(false); m_xPageNumBox->set_sensitive(false); m_xPagenumEdit->set_sensitive(false); + m_xAcrossText->set_sensitive(false); + m_xAcrossColumnBox->set_sensitive(false); + m_xAcrossPageBox->set_sensitive(false); + m_xAcrossSpreadBox->set_sensitive(false); // no column break in HTML m_xBreakTypeLB->remove(1); } @@ -2022,17 +2386,17 @@ IMPL_LINK(SvxExtParagraphTabPage, PageBreakHdl_Impl, weld::Toggleable&, rToggle, PageBreakHdl(); } -void SvxExtParagraphTabPage::KeepTogetherHdl() +void SvxExtParagraphTabPage::AllowSplitHdl() { - bool bEnable = m_xKeepTogetherBox->get_state() == TRISTATE_FALSE; + bool bEnable = m_xAllowSplitBox->get_state() == TRISTATE_TRUE; m_xWidowBox->set_sensitive(bEnable); m_xOrphanBox->set_sensitive(bEnable); } -IMPL_LINK(SvxExtParagraphTabPage, KeepTogetherHdl_Impl, weld::Toggleable&, rToggle, void) +IMPL_LINK(SvxExtParagraphTabPage, AllowSplitHdl_Impl, weld::Toggleable&, rToggle, void) { - aKeepTogetherState.ButtonToggled(rToggle); - KeepTogetherHdl(); + aAllowSplitState.ButtonToggled(rToggle); + AllowSplitHdl(); } void SvxExtParagraphTabPage::WidowHdl() @@ -2042,11 +2406,11 @@ void SvxExtParagraphTabPage::WidowHdl() case TRISTATE_TRUE: m_xWidowRowNo->set_sensitive(true); m_xWidowRowLabel->set_sensitive(true); - m_xKeepTogetherBox->set_sensitive(false); + m_xAllowSplitBox->set_sensitive(true); break; case TRISTATE_FALSE: if (m_xOrphanBox->get_state() == TRISTATE_FALSE) - m_xKeepTogetherBox->set_sensitive(true); + m_xAllowSplitBox->set_sensitive(false); [[fallthrough]]; case TRISTATE_INDET: m_xWidowRowNo->set_sensitive(false); @@ -2074,12 +2438,12 @@ void SvxExtParagraphTabPage::OrphanHdl() case TRISTATE_TRUE: m_xOrphanRowNo->set_sensitive(true); m_xOrphanRowLabel->set_sensitive(true); - m_xKeepTogetherBox->set_sensitive(false); + m_xAllowSplitBox->set_sensitive(true); break; case TRISTATE_FALSE: if (m_xWidowBox->get_state() == TRISTATE_FALSE) - m_xKeepTogetherBox->set_sensitive(true); + m_xAllowSplitBox->set_sensitive(true); [[fallthrough]]; case TRISTATE_INDET: m_xOrphanRowNo->set_sensitive(false); @@ -2092,12 +2456,23 @@ void SvxExtParagraphTabPage::HyphenClickHdl() { bool bEnable = m_xHyphenBox->get_state() == TRISTATE_TRUE; m_xHyphenNoCapsBox->set_sensitive(bEnable); + m_xHyphenNoLastWordBox->set_sensitive(bEnable); m_xBeforeText->set_sensitive(bEnable); m_xExtHyphenBeforeBox->set_sensitive(bEnable); m_xAfterText->set_sensitive(bEnable); m_xExtHyphenAfterBox->set_sensitive(bEnable); + m_xCompoundBeforeText->set_sensitive(bEnable); + m_xExtCompoundHyphenBeforeBox->set_sensitive(bEnable); m_xMaxHyphenLabel->set_sensitive(bEnable); m_xMaxHyphenEdit->set_sensitive(bEnable); + m_xMinWordLabel->set_sensitive(bEnable); + m_xMinWordLength->set_sensitive(bEnable); + m_xHyphenZoneLabel->set_sensitive(bEnable); + m_aHyphenZone.set_sensitive(bEnable); + m_xAcrossText->set_sensitive(bEnable); + m_xAcrossColumnBox->set_sensitive(bEnable); + m_xAcrossPageBox->set_sensitive(bEnable); + m_xAcrossSpreadBox->set_sensitive(bEnable); m_xHyphenBox->set_state(bEnable ? TRISTATE_TRUE : TRISTATE_FALSE); } @@ -2199,6 +2574,35 @@ void SvxExtParagraphTabPage::PageCreated(const SfxAllItemSet& aSet) DisablePageBreak(); } +IMPL_LINK(SvxExtParagraphTabPage, AcrossColumnHdl_Impl, weld::Toggleable&, rToggle, void) +{ + aAcrossColumnState.ButtonToggled(rToggle); + if (m_xAcrossColumnBox->get_state() != TRISTATE_TRUE ) + { + m_xAcrossPageBox->set_state( TRISTATE_FALSE ); + m_xAcrossSpreadBox->set_state( TRISTATE_FALSE ); + } +} + +IMPL_LINK(SvxExtParagraphTabPage, AcrossPageHdl_Impl, weld::Toggleable&, rToggle, void) +{ + aAcrossPageState.ButtonToggled(rToggle); + if (m_xAcrossPageBox->get_state() == TRISTATE_TRUE ) + m_xAcrossColumnBox->set_state( TRISTATE_TRUE ); + else + m_xAcrossSpreadBox->set_state( TRISTATE_FALSE ); +} + +IMPL_LINK(SvxExtParagraphTabPage, AcrossSpreadHdl_Impl, weld::Toggleable&, rToggle, void) +{ + aAcrossSpreadState.ButtonToggled(rToggle); + if (m_xAcrossSpreadBox->get_state() == TRISTATE_TRUE ) + { + m_xAcrossColumnBox->set_state( TRISTATE_TRUE ); + m_xAcrossPageBox->set_state( TRISTATE_TRUE ); + } +} + SvxAsianTabPage::SvxAsianTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/asiantypography.ui", "AsianTypography", &rSet) , m_xForbiddenRulesCB(m_xBuilder->weld_check_button("checkForbidList")) @@ -2228,7 +2632,7 @@ bool SvxAsianTabPage::FillItemSet( SfxItemSet* rSet ) if (m_xScriptSpaceCB->get_sensitive() && m_xScriptSpaceCB->get_state_changed_from_saved()) { std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get( - pPool->GetWhich(SID_ATTR_PARA_SCRIPTSPACE)).Clone())); + pPool->GetWhichIDFromSlotID(SID_ATTR_PARA_SCRIPTSPACE)).Clone())); pNewItem->SetValue(m_xScriptSpaceCB->get_active()); rSet->Put(std::move(pNewItem)); bRet = true; @@ -2236,7 +2640,7 @@ bool SvxAsianTabPage::FillItemSet( SfxItemSet* rSet ) if (m_xHangingPunctCB->get_sensitive() && m_xHangingPunctCB->get_state_changed_from_saved()) { std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get( - pPool->GetWhich(SID_ATTR_PARA_HANGPUNCTUATION)).Clone())); + pPool->GetWhichIDFromSlotID(SID_ATTR_PARA_HANGPUNCTUATION)).Clone())); pNewItem->SetValue(m_xHangingPunctCB->get_active()); rSet->Put(std::move(pNewItem)); bRet = true; @@ -2244,7 +2648,7 @@ bool SvxAsianTabPage::FillItemSet( SfxItemSet* rSet ) if (m_xForbiddenRulesCB->get_sensitive() && m_xForbiddenRulesCB->get_state_changed_from_saved()) { std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(rSet->Get( - pPool->GetWhich(SID_ATTR_PARA_FORBIDDEN_RULES)).Clone())); + pPool->GetWhichIDFromSlotID(SID_ATTR_PARA_FORBIDDEN_RULES)).Clone())); pNewItem->SetValue(m_xForbiddenRulesCB->get_active()); rSet->Put(std::move(pNewItem)); bRet = true; @@ -2254,7 +2658,7 @@ bool SvxAsianTabPage::FillItemSet( SfxItemSet* rSet ) static void lcl_SetBox(const SfxItemSet& rSet, sal_uInt16 nSlotId, weld::CheckButton& rBox) { - sal_uInt16 _nWhich = rSet.GetPool()->GetWhich(nSlotId); + sal_uInt16 _nWhich = rSet.GetPool()->GetWhichIDFromSlotID(nSlotId); SfxItemState eState = rSet.GetItemState(_nWhich); if( eState == SfxItemState::UNKNOWN || eState == SfxItemState::DISABLED ) rBox.set_sensitive(false); diff --git a/cui/source/tabpages/swpossizetabpage.cxx b/cui/source/tabpages/swpossizetabpage.cxx index 5e5352aff400..1a0d14759eac 100644 --- a/cui/source/tabpages/swpossizetabpage.cxx +++ b/cui/source/tabpages/swpossizetabpage.cxx @@ -19,6 +19,7 @@ #include <memory> #include <cstddef> +#include <type_traits> #include <swpossizetabpage.hxx> #include <svx/dlgutil.hxx> #include <svx/anchorid.hxx> @@ -37,6 +38,8 @@ #include <svtools/unitconv.hxx> #include <osl/diagnose.h> +#include <bitmaps.hlst> + using namespace ::com::sun::star::text; namespace { @@ -205,7 +208,7 @@ FrmMap const aHFlyHtmlMap[] = // #i18732# - own vertical alignment map for to frame anchored objects // #i22305# -#define VERT_FRAME_REL (LB::VertFrame|LB::FlyVertPrintArea) +#define VERT_FRAME_REL (LB::FlyVertFrame|LB::FlyVertPrintArea) FrmMap const aVFrameMap[] = { @@ -379,55 +382,54 @@ FrmMap const aVAsCharHtmlMap[] = static std::size_t lcl_GetFrmMapCount(const FrmMap* pMap) { - if( pMap ) - { - if( pMap == aVParaHtmlMap ) - return SAL_N_ELEMENTS(aVParaHtmlMap); - if( pMap == aVAsCharHtmlMap ) - return SAL_N_ELEMENTS( aVAsCharHtmlMap ); - if( pMap == aHParaHtmlMap ) - return SAL_N_ELEMENTS( aHParaHtmlMap ); - if( pMap == aHParaHtmlAbsMap ) - return SAL_N_ELEMENTS( aHParaHtmlAbsMap ); - if( pMap == aVPageMap ) - return SAL_N_ELEMENTS( aVPageMap ); - if( pMap == aVPageHtmlMap ) - return SAL_N_ELEMENTS( aVPageHtmlMap ); - if( pMap == aVAsCharMap ) - return SAL_N_ELEMENTS( aVAsCharMap ); - if( pMap == aVParaMap ) - return SAL_N_ELEMENTS( aVParaMap ); - if( pMap == aHParaMap ) - return SAL_N_ELEMENTS( aHParaMap ); - if( pMap == aHFrameMap ) - return SAL_N_ELEMENTS( aHFrameMap ); - if( pMap == aVFrameMap ) - return SAL_N_ELEMENTS( aVFrameMap ); - if( pMap == aHCharMap ) - return SAL_N_ELEMENTS( aHCharMap ); - if( pMap == aHCharHtmlMap ) - return SAL_N_ELEMENTS( aHCharHtmlMap ); - if( pMap == aHCharHtmlAbsMap ) - return SAL_N_ELEMENTS( aHCharHtmlAbsMap ); - if( pMap == aVCharMap ) - return SAL_N_ELEMENTS( aVCharMap ); - if( pMap == aVCharHtmlMap ) - return SAL_N_ELEMENTS( aVCharHtmlMap ); - if( pMap == aVCharHtmlAbsMap ) - return SAL_N_ELEMENTS( aVCharHtmlAbsMap ); - if( pMap == aHPageHtmlMap ) - return SAL_N_ELEMENTS( aHPageHtmlMap ); - if( pMap == aHFlyHtmlMap ) - return SAL_N_ELEMENTS( aHFlyHtmlMap ); - if( pMap == aVFlyHtmlMap ) - return SAL_N_ELEMENTS( aVFlyHtmlMap ); - if( pMap == aVMultiSelectionMap ) - return SAL_N_ELEMENTS( aVMultiSelectionMap ); - if( pMap == aHMultiSelectionMap ) - return SAL_N_ELEMENTS( aHMultiSelectionMap ); - return SAL_N_ELEMENTS(aHPageMap); - } - return 0; + if( !pMap ) + return 0; + + if( pMap == aVParaHtmlMap ) + return std::size(aVParaHtmlMap); + if( pMap == aVAsCharHtmlMap ) + return std::size( aVAsCharHtmlMap ); + if( pMap == aHParaHtmlMap ) + return std::size( aHParaHtmlMap ); + if( pMap == aHParaHtmlAbsMap ) + return std::size( aHParaHtmlAbsMap ); + if( pMap == aVPageMap ) + return std::size( aVPageMap ); + if( pMap == aVPageHtmlMap ) + return std::size( aVPageHtmlMap ); + if( pMap == aVAsCharMap ) + return std::size( aVAsCharMap ); + if( pMap == aVParaMap ) + return std::size( aVParaMap ); + if( pMap == aHParaMap ) + return std::size( aHParaMap ); + if( pMap == aHFrameMap ) + return std::size( aHFrameMap ); + if( pMap == aVFrameMap ) + return std::size( aVFrameMap ); + if( pMap == aHCharMap ) + return std::size( aHCharMap ); + if( pMap == aHCharHtmlMap ) + return std::size( aHCharHtmlMap ); + if( pMap == aHCharHtmlAbsMap ) + return std::size( aHCharHtmlAbsMap ); + if( pMap == aVCharMap ) + return std::size( aVCharMap ); + if( pMap == aVCharHtmlMap ) + return std::size( aVCharHtmlMap ); + if( pMap == aVCharHtmlAbsMap ) + return std::size( aVCharHtmlAbsMap ); + if( pMap == aHPageHtmlMap ) + return std::size( aHPageHtmlMap ); + if( pMap == aHFlyHtmlMap ) + return std::size( aHFlyHtmlMap ); + if( pMap == aVFlyHtmlMap ) + return std::size( aVFlyHtmlMap ); + if( pMap == aVMultiSelectionMap ) + return std::size( aVMultiSelectionMap ); + if( pMap == aHMultiSelectionMap ) + return std::size( aHMultiSelectionMap ); + return std::size(aHPageMap); } static SvxSwFramePosString::StringId lcl_ChangeResIdToVerticalOrRTL( @@ -466,19 +468,19 @@ static SvxSwFramePosString::StringId lcl_ChangeResIdToVerticalOrRTL( {SvxSwFramePosString::REL_FRM_TOP, SvxSwFramePosString::REL_FRM_LEFT }, {SvxSwFramePosString::REL_FRM_BOTTOM, SvxSwFramePosString::REL_FRM_RIGHT } }; - for(size_t nIndex = 0; nIndex < SAL_N_ELEMENTS(aHoriIds); ++nIndex) + for(const auto &a : aHoriIds) { - if(aHoriIds[nIndex].eHori == eStringId) + if(a.eHori == eStringId) { - eStringId = aHoriIds[nIndex].eVert; + eStringId = a.eVert; return eStringId; } } - for(size_t nIndex = 0; nIndex < SAL_N_ELEMENTS(aVertIds); ++nIndex) + for(const auto &a : aVertIds) { - if(aVertIds[nIndex].eHori == eStringId) + if(a.eHori == eStringId) { - eStringId = aVertIds[nIndex].eVert; + eStringId = a.eVert; break; } } @@ -539,9 +541,14 @@ SvxSwPosSizeTabPage::SvxSwPosSizeTabPage(weld::Container* pPage, weld::DialogCon , m_bIsMultiSelection(false) , m_bIsInRightToLeft(false) , m_nProtectSizeState(TRISTATE_FALSE) + , m_aRatioTop(ConnectorType::Top) + , m_aRatioBottom(ConnectorType::Bottom) , m_xWidthMF(m_xBuilder->weld_metric_spin_button("width", FieldUnit::CM)) , m_xHeightMF(m_xBuilder->weld_metric_spin_button("height", FieldUnit::CM)) , m_xKeepRatioCB(m_xBuilder->weld_check_button("ratio")) + , m_xCbxScaleImg(m_xBuilder->weld_image("imRatio")) + , m_xImgRatioTop(new weld::CustomWeld(*m_xBuilder, "daRatioTop", m_aRatioTop)) + , m_xImgRatioBottom(new weld::CustomWeld(*m_xBuilder, "daRatioBottom", m_aRatioBottom)) , m_xToPageRB(m_xBuilder->weld_radio_button("topage")) , m_xToParaRB(m_xBuilder->weld_radio_button("topara")) , m_xToCharRB(m_xBuilder->weld_radio_button("tochar")) @@ -575,6 +582,20 @@ SvxSwPosSizeTabPage::SvxSwPosSizeTabPage(weld::Container* pPage, weld::DialogCon SetFieldUnit(*m_xWidthMF , eDlgUnit, true); SetFieldUnit(*m_xHeightMF, eDlgUnit, true); + // vertical alignment = fill makes the drawingarea expand the associated spinedits so we have to size it here + const sal_Int16 aHeight + = static_cast<sal_Int16>(std::max(int(m_xKeepRatioCB->get_preferred_size().getHeight() / 2 + - m_xWidthMF->get_preferred_size().getHeight() / 2), + 12)); + const sal_Int16 aWidth + = static_cast<sal_Int16>(m_xKeepRatioCB->get_preferred_size().getWidth() / 2); + m_xImgRatioTop->set_size_request(aWidth, aHeight); + m_xImgRatioBottom->set_size_request(aWidth, aHeight); + //init needed for gtk3 + m_xCbxScaleImg->set_from_icon_name(m_xKeepRatioCB->get_active() ? RID_SVXBMP_LOCKED + : RID_SVXBMP_UNLOCKED); + m_xKeepRatioCB->connect_toggled(LINK(this, SvxSwPosSizeTabPage, RatioHdl_Impl)); + SetExchangeSupport(); Link<weld::Widget&,void> aLk3 = LINK(this, SvxSwPosSizeTabPage, RangeModifyHdl); @@ -627,27 +648,27 @@ namespace void SvxSwPosSizeTabPage::setOptimalFrmWidth() { static const FrmMaps aMaps[] = { - { aHPageMap, SAL_N_ELEMENTS(aHPageMap) }, - { aHPageHtmlMap, SAL_N_ELEMENTS(aHPageHtmlMap) }, - { aVPageMap, SAL_N_ELEMENTS(aVPageMap) }, - { aVPageHtmlMap, SAL_N_ELEMENTS(aVPageHtmlMap) }, - { aHFrameMap, SAL_N_ELEMENTS(aHFrameMap) }, - { aHFlyHtmlMap, SAL_N_ELEMENTS(aHFlyHtmlMap) }, - { aVFrameMap, SAL_N_ELEMENTS(aVFrameMap) }, - { aVFlyHtmlMap, SAL_N_ELEMENTS(aVFlyHtmlMap) }, - { aHParaMap, SAL_N_ELEMENTS(aHParaMap) }, - { aHParaHtmlMap, SAL_N_ELEMENTS(aHParaHtmlMap) }, - { aHParaHtmlAbsMap, SAL_N_ELEMENTS(aHParaHtmlAbsMap) }, - { aVParaMap, SAL_N_ELEMENTS(aVParaMap) }, - { aVParaHtmlMap, SAL_N_ELEMENTS(aVParaHtmlMap) }, - { aHCharMap, SAL_N_ELEMENTS(aHCharMap) }, - { aHCharHtmlMap, SAL_N_ELEMENTS(aHCharHtmlMap) }, - { aHCharHtmlAbsMap, SAL_N_ELEMENTS(aHCharHtmlAbsMap) }, - { aVCharMap, SAL_N_ELEMENTS(aVCharMap) }, - { aVCharHtmlMap, SAL_N_ELEMENTS(aVCharHtmlMap) }, - { aVCharHtmlAbsMap, SAL_N_ELEMENTS(aVCharHtmlAbsMap) }, - { aVAsCharMap, SAL_N_ELEMENTS(aVAsCharMap) }, - { aVAsCharHtmlMap, SAL_N_ELEMENTS(aVAsCharHtmlMap) } + { aHPageMap, std::size(aHPageMap) }, + { aHPageHtmlMap, std::size(aHPageHtmlMap) }, + { aVPageMap, std::size(aVPageMap) }, + { aVPageHtmlMap, std::size(aVPageHtmlMap) }, + { aHFrameMap, std::size(aHFrameMap) }, + { aHFlyHtmlMap, std::size(aHFlyHtmlMap) }, + { aVFrameMap, std::size(aVFrameMap) }, + { aVFlyHtmlMap, std::size(aVFlyHtmlMap) }, + { aHParaMap, std::size(aHParaMap) }, + { aHParaHtmlMap, std::size(aHParaHtmlMap) }, + { aHParaHtmlAbsMap, std::size(aHParaHtmlAbsMap) }, + { aVParaMap, std::size(aVParaMap) }, + { aVParaHtmlMap, std::size(aVParaHtmlMap) }, + { aHCharMap, std::size(aHCharMap) }, + { aHCharHtmlMap, std::size(aHCharHtmlMap) }, + { aHCharHtmlAbsMap, std::size(aHCharHtmlAbsMap) }, + { aVCharMap, std::size(aVCharMap) }, + { aVCharHtmlMap, std::size(aVCharHtmlMap) }, + { aVCharHtmlAbsMap, std::size(aVCharHtmlAbsMap) }, + { aVAsCharMap, std::size(aVAsCharMap) }, + { aVAsCharHtmlMap, std::size(aVAsCharHtmlMap) } }; std::vector<SvxSwFramePosString::StringId> aFrames; @@ -686,8 +707,8 @@ namespace void SvxSwPosSizeTabPage::setOptimalRelWidth() { static const RelationMaps aMaps[] = { - { aRelationMap, SAL_N_ELEMENTS(aRelationMap) }, - { aAsCharRelationMap, SAL_N_ELEMENTS(aAsCharRelationMap) } + { aRelationMap, std::size(aRelationMap) }, + { aAsCharRelationMap, std::size(aAsCharRelationMap) } }; std::vector<SvxSwFramePosString::StringId> aRels; @@ -749,7 +770,7 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) rSet->InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_POS ); else rSet->Put( - SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS ), + SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_POS, m_xPositionCB->get_state() == TRISTATE_TRUE ) ); bModified = true; } @@ -760,7 +781,7 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) rSet->InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_SIZE ); else rSet->Put( - SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE ), + SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE, m_xSizeCB->get_state() == TRISTATE_TRUE ) ); bModified = true; } @@ -784,8 +805,8 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) nHoriByPos += m_aAnchorPos.X(); nVertByPos += m_aAnchorPos.Y(); - rSet->Put( SfxInt32Item( GetWhich( SID_ATTR_TRANSFORM_POS_X ), nHoriByPos ) ); - rSet->Put( SfxInt32Item( GetWhich( SID_ATTR_TRANSFORM_POS_Y ), nVertByPos ) ); + rSet->Put( SfxInt32Item( SID_ATTR_TRANSFORM_POS_X, nHoriByPos ) ); + rSet->Put( SfxInt32Item( SID_ATTR_TRANSFORM_POS_Y, nVertByPos ) ); bModified = true; } @@ -795,11 +816,11 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) if ( m_pHMap ) { const SfxInt16Item& rHoriOrient = - static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_HORI_ORIENT)); + rOldSet.Get( SID_ATTR_TRANSFORM_HORI_ORIENT ); const SfxInt16Item& rHoriRelation = - static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_HORI_RELATION)); + rOldSet.Get( SID_ATTR_TRANSFORM_HORI_RELATION); const SfxInt32Item& rHoriPosition = - static_cast<const SfxInt32Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_HORI_POSITION)) ; + rOldSet.Get( SID_ATTR_TRANSFORM_HORI_POSITION); sal_uInt16 nMapPos = GetMapPos(m_pHMap, *m_xHoriLB); short nAlign = GetAlignment(m_pHMap, nMapPos, *m_xHoriToLB); @@ -824,11 +845,11 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) if ( m_pVMap ) { const SfxInt16Item& rVertOrient = - static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_VERT_ORIENT)); + rOldSet.Get( SID_ATTR_TRANSFORM_VERT_ORIENT); const SfxInt16Item& rVertRelation = - static_cast<const SfxInt16Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_VERT_RELATION)); + rOldSet.Get( SID_ATTR_TRANSFORM_VERT_RELATION); const SfxInt32Item& rVertPosition = - static_cast<const SfxInt32Item&>(rOldSet.Get( SID_ATTR_TRANSFORM_VERT_POSITION)); + rOldSet.Get( SID_ATTR_TRANSFORM_VERT_POSITION); sal_uInt16 nMapPos = GetMapPos(m_pVMap, *m_xVertLB); short nAlign = GetAlignment(m_pVMap, nMapPos, *m_xVertToLB); @@ -862,7 +883,7 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) { std::unique_ptr<SfxBoolItem> pFollow(static_cast<SfxBoolItem*>(pItem->Clone())); pFollow->SetValue(m_xFollowCB->get_active()); - bModified |= nullptr != rSet->Put(*pFollow); + bModified |= nullptr != rSet->Put(std::move(pFollow)); } } } @@ -871,10 +892,10 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) { sal_uInt32 nWidth = static_cast<sal_uInt32>(m_xWidthMF->denormalize(m_xWidthMF->get_value(FieldUnit::TWIP))); sal_uInt32 nHeight = static_cast<sal_uInt32>(m_xHeightMF->denormalize(m_xHeightMF->get_value(FieldUnit::TWIP))); - rSet->Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_WIDTH ), nWidth ) ); - rSet->Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_HEIGHT ), nHeight ) ); + rSet->Put( SfxUInt32Item( SID_ATTR_TRANSFORM_WIDTH, nWidth ) ); + rSet->Put( SfxUInt32Item( SID_ATTR_TRANSFORM_HEIGHT, nHeight ) ); //this item is required by SdrEditView::SetGeoAttrToMarked() - rSet->Put( SfxUInt16Item( GetWhich( SID_ATTR_TRANSFORM_SIZE_POINT ), sal_uInt16(RectPoint::LT) ) ); + rSet->Put( SfxUInt16Item( SID_ATTR_TRANSFORM_SIZE_POINT, sal_uInt16(RectPoint::LT) ) ); bModified = true; } @@ -1050,9 +1071,9 @@ DeactivateRC SvxSwPosSizeTabPage::DeactivatePage( SfxItemSet* _pSet ) { if( _pSet ) { - _pSet->Put(SfxBoolItem(GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS ), + _pSet->Put(SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_POS, m_xPositionCB->get_active())); - _pSet->Put(SfxBoolItem(GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE ), + _pSet->Put(SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE, m_xSizeCB->get_active())); FillItemSet( _pSet ); } @@ -1109,6 +1130,11 @@ RndStdIds SvxSwPosSizeTabPage::GetAnchorType(bool* pbHasChanged) return nRet; } +IMPL_LINK_NOARG(SvxSwPosSizeTabPage, RatioHdl_Impl, weld::Toggleable&, void) +{ + m_xCbxScaleImg->set_from_icon_name(m_xKeepRatioCB->get_active() ? RID_SVXBMP_LOCKED : RID_SVXBMP_UNLOCKED); +} + IMPL_LINK_NOARG(SvxSwPosSizeTabPage, RangeModifyClickHdl, weld::Toggleable&, void) { RangeModifyHdl(m_xWidthMF->get_widget()); @@ -1269,7 +1295,7 @@ IMPL_LINK(SvxSwPosSizeTabPage, PosHdl, weld::ComboBox&, rLB, void) if (rLB.get_active() != -1) { if (pRelLB->get_active() != -1) - nRel = reinterpret_cast<RelationMap*>(pRelLB->get_active_id().toUInt64())->nRelation; + nRel = weld::fromId<RelationMap*>(pRelLB->get_active_id())->nRelation; FillRelLB(pMap, nMapPos, nAlign, nRel, *pRelLB, *pRelFT); } @@ -1372,7 +1398,7 @@ short SvxSwPosSizeTabPage::GetRelation(const weld::ComboBox& rRelationLB) int nPos = rRelationLB.get_active(); if (nPos != -1) { - RelationMap *pEntry = reinterpret_cast<RelationMap*>(rRelationLB.get_id(nPos).toUInt64()); + RelationMap *pEntry = weld::fromId<RelationMap*>(rRelationLB.get_id(nPos)); nRel = pEntry->nRelation; } @@ -1390,7 +1416,7 @@ short SvxSwPosSizeTabPage::GetAlignment(FrmMap const *pMap, sal_uInt16 nMapPos, { if (rRelationLB.get_active() != -1) { - LB nRel = reinterpret_cast<RelationMap*>(rRelationLB.get_active_id().toUInt64())->nLBRelation; + LB nRel = weld::fromId<RelationMap*>(rRelationLB.get_active_id())->nLBRelation; std::size_t nMapCount = ::lcl_GetFrmMapCount(pMap); SvxSwFramePosString::StringId eStrId = pMap[nMapPos].eStrId; @@ -1460,7 +1486,7 @@ void SvxSwPosSizeTabPage::InitPos(RndStdIds nAnchor, m_nOldV = m_pVMap[nPos].nAlign; nPos = m_xVertToLB->get_active(); if (nPos != -1) - m_nOldVRel = reinterpret_cast<RelationMap*>(m_xVertToLB->get_id(nPos).toUInt64())->nRelation; + m_nOldVRel = weld::fromId<RelationMap*>(m_xVertToLB->get_id(nPos))->nRelation; } nPos = m_xHoriLB->get_active(); @@ -1470,7 +1496,7 @@ void SvxSwPosSizeTabPage::InitPos(RndStdIds nAnchor, nPos = m_xHoriToLB->get_active(); if (nPos != -1) - m_nOldHRel = reinterpret_cast<RelationMap*>(m_xHoriToLB->get_id(nPos).toUInt64())->nRelation; + m_nOldHRel = weld::fromId<RelationMap*>(m_xHoriToLB->get_id(nPos))->nRelation; } bool bEnable = true; @@ -1645,7 +1671,7 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ if (pMap[_nMapPos].eStrId == eStrId) { nLBRelations = pMap[_nMapPos].nLBRelations; - for (size_t nRelPos = 0; nRelPos < SAL_N_ELEMENTS(aAsCharRelationMap); nRelPos++) + for (size_t nRelPos = 0; nRelPos < std::size(aAsCharRelationMap); nRelPos++) { if (nLBRelations & aAsCharRelationMap[nRelPos].nLBRelation) { @@ -1653,7 +1679,7 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, m_bIsVerticalFrame, m_bIsInRightToLeft); OUString sEntry = SvxSwFramePosString::GetString(sStrId1); - rLB.append(OUString::number(reinterpret_cast<sal_uInt64>(&aAsCharRelationMap[nRelPos])), sEntry); + rLB.append(weld::toId(&aAsCharRelationMap[nRelPos]), sEntry); if (pMap[_nMapPos].nAlign == nAlign) sSelEntry = sEntry; break; @@ -1670,7 +1696,7 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ { for (int i = 0; i < rLB.get_count(); i++) { - RelationMap *pEntry = reinterpret_cast<RelationMap*>(rLB.get_id(i).toUInt64()); + RelationMap *pEntry = weld::fromId<RelationMap*>(rLB.get_id(i)); if (pEntry->nLBRelation == LB::RelChar) // Default { rLB.set_active(i); @@ -1697,18 +1723,18 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ nLBRelations = pMap[nMapPos].nLBRelations; } - for (sal_uLong nBit = 1; nBit < sal_uLong(LB::LAST); nBit <<= 1) + for (std::underlying_type_t<LB> nBit = 1; nBit < o3tl::to_underlying(LB::LAST) ; nBit <<= 1) { if (nLBRelations & static_cast<LB>(nBit)) { - for (size_t nRelPos = 0; nRelPos < SAL_N_ELEMENTS(aRelationMap); nRelPos++) + for (size_t nRelPos = 0; nRelPos < std::size(aRelationMap); nRelPos++) { if (aRelationMap[nRelPos].nLBRelation == static_cast<LB>(nBit)) { SvxSwFramePosString::StringId sStrId1 = m_xHoriMirrorCB->get_active() ? aRelationMap[nRelPos].eMirrorStrId : aRelationMap[nRelPos].eStrId; sStrId1 = lcl_ChangeResIdToVerticalOrRTL(sStrId1, m_bIsVerticalFrame, m_bIsInRightToLeft); OUString sEntry = SvxSwFramePosString::GetString(sStrId1); - rLB.append(OUString::number(reinterpret_cast<sal_uInt64>(&aRelationMap[nRelPos])), sEntry); + rLB.append(weld::toId(&aRelationMap[nRelPos]), sEntry); if (sSelEntry.isEmpty() && aRelationMap[nRelPos].nRelation == nRel) sSelEntry = sEntry; } @@ -1734,7 +1760,7 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ default: if (rLB.get_count()) { - RelationMap *pEntry = reinterpret_cast<RelationMap*>(rLB.get_id(rLB.get_count() - 1).toUInt64()); + RelationMap *pEntry = weld::fromId<RelationMap*>(rLB.get_id(rLB.get_count() - 1)); nRel = pEntry->nRelation; } break; @@ -1742,7 +1768,7 @@ void SvxSwPosSizeTabPage::FillRelLB(FrmMap const *pMap, sal_uInt16 nMapPos, sal_ for (int i = 0; i < rLB.get_count(); ++i) { - RelationMap *pEntry = reinterpret_cast<RelationMap*>(rLB.get_id(i).toUInt64()); + RelationMap *pEntry = weld::fromId<RelationMap*>(rLB.get_id(i)); if (pEntry->nRelation == nRel) { rLB.set_active(i); @@ -1867,7 +1893,7 @@ void SvxSwPosSizeTabPage::SetView( const SdrView* pSdrView ) const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier(); if( ( pObj->GetObjInventor() == SdrInventor::Default ) && - ( eKind==OBJ_TEXT || eKind==OBJ_TITLETEXT || eKind==OBJ_OUTLINETEXT) && + ( eKind==SdrObjKind::Text || eKind==SdrObjKind::TitleText || eKind==SdrObjKind::OutlineText) && pObj->HasText() ) { OSL_FAIL("AutoWidth/AutoHeight should be enabled"); diff --git a/cui/source/tabpages/tabarea.cxx b/cui/source/tabpages/tabarea.cxx index a400c0207839..a568eb08223b 100644 --- a/cui/source/tabpages/tabarea.cxx +++ b/cui/source/tabpages/tabarea.cxx @@ -31,7 +31,8 @@ SvxAreaTabDialog::SvxAreaTabDialog weld::Window* pParent, const SfxItemSet* pAttr, SdrModel* pModel, - bool bShadow + bool bShadow, + bool bSlideBackground ) : SfxTabDialogController(pParent, "cui/ui/areadialog.ui", "AreaDialog", pAttr) , mpDrawModel ( pModel ), @@ -52,7 +53,10 @@ SvxAreaTabDialog::SvxAreaTabDialog mnGradientListState ( ChangeType::NONE ), mnHatchingListState ( ChangeType::NONE ) { - AddTabPage("RID_SVXPAGE_AREA", SvxAreaTabPage::Create, nullptr); + if (bSlideBackground) + AddTabPage("RID_SVXPAGE_AREA", SvxAreaTabPage::CreateWithSlideBackground, nullptr); + else + AddTabPage("RID_SVXPAGE_AREA", SvxAreaTabPage::Create, nullptr); if (bShadow) { @@ -71,55 +75,46 @@ SvxAreaTabDialog::SvxAreaTabDialog void SvxAreaTabDialog::SavePalettes() { - SfxObjectShell* pShell = SfxObjectShell::Current(); + SfxObjectShell* pShell(SfxObjectShell::Current()); + if (!pShell) + { + SAL_WARN("cui.dialogs", "SvxAreaTabDialog: No SfxObjectShell!"); + return; + } + if( mpNewColorList != mpDrawModel->GetColorList() ) { mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewColorList.get()) ); SvxColorListItem aColorListItem( mpNewColorList, SID_COLOR_TABLE ); - if ( pShell ) - pShell->PutItem( aColorListItem ); - else - mpDrawModel->GetItemPool().Put(aColorListItem,SID_COLOR_TABLE); + pShell->PutItem( aColorListItem ); mpColorList = mpDrawModel->GetColorList(); } if( mpNewGradientList != mpDrawModel->GetGradientList() ) { mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewGradientList.get()) ); SvxGradientListItem aItem( mpNewGradientList, SID_GRADIENT_LIST ); - if ( pShell ) - pShell->PutItem( aItem ); - else - mpDrawModel->GetItemPool().Put(aItem,SID_GRADIENT_LIST); + pShell->PutItem( aItem ); mpGradientList = mpDrawModel->GetGradientList(); } if( mpNewHatchingList != mpDrawModel->GetHatchList() ) { mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewHatchingList.get()) ); SvxHatchListItem aItem( mpNewHatchingList, SID_HATCH_LIST ); - if ( pShell ) - pShell->PutItem( aItem ); - else - mpDrawModel->GetItemPool().Put(aItem,SID_HATCH_LIST); + pShell->PutItem( aItem ); mpHatchingList = mpDrawModel->GetHatchList(); } if( mpNewBitmapList != mpDrawModel->GetBitmapList() ) { mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewBitmapList.get()) ); SvxBitmapListItem aItem( mpNewBitmapList, SID_BITMAP_LIST ); - if ( pShell ) - pShell->PutItem( aItem ); - else - mpDrawModel->GetItemPool().Put(aItem,SID_BITMAP_LIST); + pShell->PutItem( aItem ); mpBitmapList = mpDrawModel->GetBitmapList(); } if( mpNewPatternList != mpDrawModel->GetPatternList() ) { mpDrawModel->SetPropertyList( static_cast<XPropertyList *>(mpNewPatternList.get()) ); SvxPatternListItem aItem( mpNewPatternList, SID_PATTERN_LIST ); - if( pShell ) - pShell->PutItem( aItem ); - else - mpDrawModel->GetItemPool().Put(aItem,SID_PATTERN_LIST); + pShell->PutItem( aItem ); mpPatternList = mpDrawModel->GetPatternList(); } @@ -141,10 +136,7 @@ void SvxAreaTabDialog::SavePalettes() SvxHatchListItem aItem( mpHatchingList, SID_HATCH_LIST ); // ToolBoxControls are informed: - if ( pShell ) - pShell->PutItem( aItem ); - else - mpDrawModel->GetItemPool().Put(aItem); + pShell->PutItem( aItem ); } if( mnBitmapListState & ChangeType::MODIFIED ) @@ -154,12 +146,7 @@ void SvxAreaTabDialog::SavePalettes() SvxBitmapListItem aItem( mpBitmapList, SID_BITMAP_LIST ); // ToolBoxControls are informed: - if ( pShell ) - pShell->PutItem( aItem ); - else - { - mpDrawModel->GetItemPool().Put(aItem); - } + pShell->PutItem( aItem ); } if( mnPatternListState & ChangeType::MODIFIED ) @@ -169,10 +156,7 @@ void SvxAreaTabDialog::SavePalettes() SvxPatternListItem aItem( mpPatternList, SID_PATTERN_LIST ); // ToolBoxControls are informed: - if( pShell ) - pShell->PutItem( aItem ); - else - mpDrawModel->GetItemPool().Put(aItem); + pShell->PutItem( aItem ); } if( mnGradientListState & ChangeType::MODIFIED ) @@ -182,24 +166,14 @@ void SvxAreaTabDialog::SavePalettes() SvxGradientListItem aItem( mpGradientList, SID_GRADIENT_LIST ); // ToolBoxControls are informed: - if ( pShell ) - pShell->PutItem( aItem ); - else - { - mpDrawModel->GetItemPool().Put(aItem); - } + pShell->PutItem( aItem ); } if (mnColorListState & ChangeType::MODIFIED && mpColorList.is()) { SvxColorListItem aItem( mpColorList, SID_COLOR_TABLE ); // ToolBoxControls are informed: - if ( pShell ) - pShell->PutItem( aItem ); - else - { - mpDrawModel->GetItemPool().Put(aItem); - } + pShell->PutItem( aItem ); } } @@ -218,7 +192,7 @@ IMPL_LINK_NOARG(SvxAreaTabDialog, CancelHdlImpl, weld::Button&, void) m_xDialog->response(RET_CANCEL); } -void SvxAreaTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage) +void SvxAreaTabDialog::PageCreated(const OUString& rId, SfxTabPage &rPage) { if (rId == "RID_SVXPAGE_AREA") { diff --git a/cui/source/tabpages/tabline.cxx b/cui/source/tabpages/tabline.cxx index f4e0a1268013..ac6cadd51109 100644 --- a/cui/source/tabpages/tabline.cxx +++ b/cui/source/tabpages/tabline.cxx @@ -50,12 +50,12 @@ SvxLineTabDialog::SvxLineTabDialog(weld::Window* pParent, const SfxItemSet* pAtt { switch( pObj->GetObjIdentifier() ) { - case OBJ_LINE: - case OBJ_PLIN: - case OBJ_PATHLINE: - case OBJ_FREELINE: - case OBJ_MEASURE: - case OBJ_EDGE: + case SdrObjKind::Line: + case SdrObjKind::PolyLine: + case SdrObjKind::PathLine: + case SdrObjKind::FreehandLine: + case SdrObjKind::Measure: + case SdrObjKind::Edge: bLineOnly = true; break; @@ -160,7 +160,7 @@ IMPL_LINK_NOARG(SvxLineTabDialog, CancelHdlImpl, weld::Button&, void) m_xDialog->response(RET_CANCEL); } -void SvxLineTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage) +void SvxLineTabDialog::PageCreated(const OUString& rId, SfxTabPage &rPage) { if (rId == "RID_SVXPAGE_LINE") { diff --git a/cui/source/tabpages/tabstpge.cxx b/cui/source/tabpages/tabstpge.cxx index 7a4beeb8437e..b3a1745c26f9 100644 --- a/cui/source/tabpages/tabstpge.cxx +++ b/cui/source/tabpages/tabstpge.cxx @@ -52,7 +52,11 @@ void TabWin_Impl::Paint(vcl::RenderContext& rRenderContext, const ::tools::Recta Size aSize(GetOutputSizePixel()); aPoint.setX( aSize.Width() / 2 ); aPoint.setY( aSize.Height() / 2 ); - Ruler::DrawTab(rRenderContext, rRenderContext.GetSettings().GetStyleSettings().GetFontColor(), aPoint, nTabStyle); + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + rRenderContext.SetLineColor(rStyleSettings.GetShadowColor()); + rRenderContext.SetFillColor(rStyleSettings.GetDialogColor()); + rRenderContext.DrawRect(tools::Rectangle(Point(0,0), rRenderContext.GetOutputSize())); + Ruler::DrawTab(rRenderContext, rStyleSettings.GetDialogTextColor(), aPoint, nTabStyle); } SvxTabulatorTabPage::SvxTabulatorTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rAttr) @@ -190,7 +194,7 @@ bool SvxTabulatorTabPage::FillItemSet(SfxItemSet* rSet) if (!pOld || *static_cast<const SvxTabStopItem*>(pOld) != *aTmp) { - rSet->Put(*aTmp); + rSet->Put(std::move(aTmp)); bModified = true; } } @@ -312,10 +316,9 @@ void SvxTabulatorTabPage::InitTabPos_Impl( sal_uInt16 nTabPos ) m_xTabBox->clear(); tools::Long nOffset = 0; - const SfxPoolItem* pItem = nullptr; - if (GetItemSet().GetItemState(SID_ATTR_TABSTOP_OFFSET, true, &pItem) == SfxItemState::SET) + if (const SfxInt32Item* pOffSetItem = GetItemSet().GetItemIfSet(SID_ATTR_TABSTOP_OFFSET)) { - nOffset = static_cast<const SfxInt32Item*>(pItem)->GetValue(); + nOffset = pOffSetItem->GetValue(); MapUnit eUnit = GetItemSet().GetPool()->GetMetric(GetWhich(SID_ATTR_TABSTOP)); nOffset = OutputDevice::LogicToLogic(nOffset, eUnit, MapUnit::Map100thMM); } @@ -426,12 +429,10 @@ void SvxTabulatorTabPage::NewHdl_Impl(const weld::Button* pBtn) return; tools::Long nOffset = 0; - const SfxPoolItem* pItem = nullptr; - if ( GetItemSet().GetItemState( SID_ATTR_TABSTOP_OFFSET, true, &pItem ) == - SfxItemState::SET ) + if ( const SfxInt32Item* pOffsetItem = GetItemSet().GetItemIfSet( SID_ATTR_TABSTOP_OFFSET ) ) { - nOffset = static_cast<const SfxInt32Item*>(pItem)->GetValue(); + nOffset = pOffsetItem->GetValue(); MapUnit eUnit = GetItemSet().GetPool()->GetMetric( GetWhich( SID_ATTR_TABSTOP ) ); nOffset = OutputDevice::LogicToLogic( nOffset, eUnit, MapUnit::Map100thMM ); } diff --git a/cui/source/tabpages/textanim.cxx b/cui/source/tabpages/textanim.cxx index 95d3463a1607..f0964e4957d6 100644 --- a/cui/source/tabpages/textanim.cxx +++ b/cui/source/tabpages/textanim.cxx @@ -53,12 +53,12 @@ SvxTextTabDialog::SvxTextTabDialog(weld::Window* pParent, const SfxItemSet* pAtt |* \************************************************************************/ -void SvxTextTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage) +void SvxTextTabDialog::PageCreated(const OUString& rId, SfxTabPage &rPage) { if (rId != "RID_SVXPAGE_TEXTATTR") return; - SdrObjKind eKind = OBJ_NONE; + SdrObjKind eKind = SdrObjKind::NONE; if (pView) { const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); @@ -140,7 +140,7 @@ void SvxTextAnimationPage::Reset( const SfxItemSet* rAttrs ) const SfxPoolItem* pItem = GetItem( *rAttrs, SDRATTR_TEXT_ANIKIND ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_ANIKIND ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_TEXT_ANIKIND ); eAniKind = static_cast<const SdrTextAniKindItem*>(pItem)->GetValue(); m_xLbEffect->set_active(sal::static_int_cast<sal_Int32>(eAniKind)); @@ -149,7 +149,7 @@ void SvxTextAnimationPage::Reset( const SfxItemSet* rAttrs ) // animation direction pItem = GetItem( *rAttrs, SDRATTR_TEXT_ANIDIRECTION ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_ANIDIRECTION ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_TEXT_ANIDIRECTION ); SelectDirection(static_cast<const SdrTextAniDirectionItem*>(pItem)->GetValue()); m_aUpState = m_xBtnUp->get_state(); @@ -160,7 +160,7 @@ void SvxTextAnimationPage::Reset( const SfxItemSet* rAttrs ) // Start inside pItem = GetItem( *rAttrs, SDRATTR_TEXT_ANISTARTINSIDE ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_ANISTARTINSIDE ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_TEXT_ANISTARTINSIDE ); if (static_cast<const SdrTextAniStartInsideItem*>(pItem)->GetValue()) m_xTsbStartInside->set_state(TRISTATE_TRUE); @@ -171,7 +171,7 @@ void SvxTextAnimationPage::Reset( const SfxItemSet* rAttrs ) // Stop inside pItem = GetItem( *rAttrs, SDRATTR_TEXT_ANISTOPINSIDE ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_ANISTOPINSIDE ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_TEXT_ANISTOPINSIDE ); if (static_cast<const SdrTextAniStopInsideItem*>(pItem)->GetValue()) m_xTsbStopInside->set_state(TRISTATE_TRUE); @@ -182,7 +182,7 @@ void SvxTextAnimationPage::Reset( const SfxItemSet* rAttrs ) // quantity pItem = GetItem( *rAttrs, SDRATTR_TEXT_ANICOUNT ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_ANICOUNT ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_TEXT_ANICOUNT ); tools::Long nValue = static_cast<tools::Long>(static_cast<const SdrTextAniCountItem*>(pItem)->GetValue()); m_xNumFldCount->set_value(nValue); @@ -207,7 +207,7 @@ void SvxTextAnimationPage::Reset( const SfxItemSet* rAttrs ) // delay pItem = GetItem( *rAttrs, SDRATTR_TEXT_ANIDELAY ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_ANIDELAY ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_TEXT_ANIDELAY ); nValue = static_cast<tools::Long>(static_cast<const SdrTextAniDelayItem*>(pItem)->GetValue()); m_xMtrFldDelay->set_value(nValue, FieldUnit::NONE); @@ -224,7 +224,7 @@ void SvxTextAnimationPage::Reset( const SfxItemSet* rAttrs ) // step size pItem = GetItem( *rAttrs, SDRATTR_TEXT_ANIAMOUNT ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_ANIAMOUNT ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_TEXT_ANIAMOUNT ); nValue = static_cast<tools::Long>(static_cast<const SdrTextAniAmountItem*>(pItem)->GetValue()); if (nValue <= 0) diff --git a/cui/source/tabpages/textattr.cxx b/cui/source/tabpages/textattr.cxx index d542f9b0810e..a803efffe5cb 100644 --- a/cui/source/tabpages/textattr.cxx +++ b/cui/source/tabpages/textattr.cxx @@ -24,7 +24,6 @@ #include <svx/sdtaitm.hxx> #include <svx/sdtfsitm.hxx> #include <svx/sdtcfitm.hxx> -#include <svx/svdobj.hxx> #include <svx/svxids.hrc> #include <textattr.hxx> @@ -49,7 +48,7 @@ const WhichRangesContainer SvxTextAttrPage::pRanges( SvxTextAttrPage::SvxTextAttrPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) : SvxTabPage(pPage, pController, "cui/ui/textattrtabpage.ui", "TextAttributesPage", rInAttrs) , rOutAttrs(rInAttrs) - , m_eObjKind(OBJ_NONE) + , m_eObjKind(SdrObjKind::NONE) , bAutoGrowSizeEnabled(false) , bContourEnabled(false) , bAutoGrowWidthEnabled(false) @@ -110,34 +109,34 @@ void SvxTextAttrPage::Reset( const SfxItemSet* rAttrs ) const SdrMetricItem* pItem = GetItem(*rAttrs, SDRATTR_TEXT_LEFTDIST); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LEFTDIST ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_TEXT_LEFTDIST ); SetMetricValue(*m_xMtrFldLeft, pItem->GetValue(), eUnit); m_xMtrFldLeft->save_value(); pItem = GetItem( *rAttrs, SDRATTR_TEXT_RIGHTDIST ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_RIGHTDIST ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_TEXT_RIGHTDIST ); SetMetricValue(*m_xMtrFldRight, pItem->GetValue(), eUnit); m_xMtrFldRight->save_value(); pItem = GetItem( *rAttrs, SDRATTR_TEXT_UPPERDIST ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_UPPERDIST ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_TEXT_UPPERDIST ); SetMetricValue(*m_xMtrFldTop, pItem->GetValue(), eUnit); m_xMtrFldTop->save_value(); pItem = GetItem( *rAttrs, SDRATTR_TEXT_LOWERDIST ); if( !pItem ) - pItem = &pPool->GetDefaultItem( SDRATTR_TEXT_LOWERDIST ); + pItem = &pPool->GetUserOrPoolDefaultItem( SDRATTR_TEXT_LOWERDIST ); SetMetricValue(*m_xMtrFldBottom, pItem->GetValue(), eUnit); m_xMtrFldBottom->save_value(); // adjust to height and autogrowsize - if ( rAttrs->GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) != SfxItemState::DONTCARE ) + if ( rAttrs->GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) != SfxItemState::INVALID ) { m_xTsbAutoGrowHeight->set_state( rAttrs->Get( SDRATTR_TEXT_AUTOGROWHEIGHT ). GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE ); @@ -154,7 +153,7 @@ void SvxTextAttrPage::Reset( const SfxItemSet* rAttrs ) m_xTsbAutoGrowSize->save_state(); // adjust to width - if ( rAttrs->GetItemState( SDRATTR_TEXT_AUTOGROWWIDTH ) != SfxItemState::DONTCARE ) + if ( rAttrs->GetItemState( SDRATTR_TEXT_AUTOGROWWIDTH ) != SfxItemState::INVALID ) { m_xTsbAutoGrowWidth->set_state( rAttrs->Get( SDRATTR_TEXT_AUTOGROWWIDTH ). GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE ); @@ -164,7 +163,7 @@ void SvxTextAttrPage::Reset( const SfxItemSet* rAttrs ) m_xTsbAutoGrowWidth->save_state(); // wordwrap text - if ( rAttrs->GetItemState( SDRATTR_TEXT_WORDWRAP ) != SfxItemState::DONTCARE ) + if ( rAttrs->GetItemState( SDRATTR_TEXT_WORDWRAP ) != SfxItemState::INVALID ) { m_xTsbWordWrapText->set_state( rAttrs->Get( SDRATTR_TEXT_WORDWRAP ). GetValue() ? TRISTATE_TRUE : TRISTATE_FALSE ); @@ -179,7 +178,7 @@ void SvxTextAttrPage::Reset( const SfxItemSet* rAttrs ) SfxItemState eVState = rAttrs->GetItemState( SDRATTR_TEXT_VERTADJUST ); SfxItemState eHState = rAttrs->GetItemState( SDRATTR_TEXT_HORZADJUST ); - if(SfxItemState::DONTCARE != eVState && SfxItemState::DONTCARE != eHState) + if(SfxItemState::INVALID != eVState && SfxItemState::INVALID != eHState) { // VertAdjust and HorAdjust are unequivocal, thus SdrTextVertAdjust eTVA = rAttrs->Get(SDRATTR_TEXT_VERTADJUST).GetValue(); @@ -255,7 +254,7 @@ void SvxTextAttrPage::Reset( const SfxItemSet* rAttrs ) } // adjust to border - if (rAttrs->GetItemState(SDRATTR_TEXT_FITTOSIZE) != SfxItemState::DONTCARE) + if (rAttrs->GetItemState(SDRATTR_TEXT_FITTOSIZE) != SfxItemState::INVALID) { drawing::TextFitToSizeType const eFTS = rAttrs->Get( SDRATTR_TEXT_FITTOSIZE ).GetValue(); @@ -268,7 +267,7 @@ void SvxTextAttrPage::Reset( const SfxItemSet* rAttrs ) m_xTsbFitToSize->set_state( TRISTATE_INDET ); m_xTsbFitToSize->save_state(); - if( rAttrs->GetItemState( SDRATTR_TEXT_CONTOURFRAME ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( SDRATTR_TEXT_CONTOURFRAME ) != SfxItemState::INVALID ) { bool bContour = rAttrs->Get( SDRATTR_TEXT_CONTOURFRAME ).GetValue(); m_xTsbContour->set_state( bContour ? TRISTATE_TRUE : TRISTATE_FALSE ); @@ -395,34 +394,34 @@ bool SvxTextAttrPage::FillItemSet( SfxItemSet* rAttrs) // #103516# Do not change values if adjust controls were disabled. bool bIsDisabled(m_aCtlPosition.IsCompletelyDisabled()); - if(!bIsDisabled) - { - if( m_xTsbFullWidth->get_state() == TRISTATE_TRUE ) - { - if (IsTextDirectionLeftToRight()) - eTHA = SDRTEXTHORZADJUST_BLOCK; - else - eTVA = SDRTEXTVERTADJUST_BLOCK; - } + if(bIsDisabled) + return true; - if ( rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ) != SfxItemState::DONTCARE ) - { - SdrTextVertAdjust eOldTVA = rOutAttrs.Get( SDRATTR_TEXT_VERTADJUST ).GetValue(); - if( eOldTVA != eTVA ) - rAttrs->Put( SdrTextVertAdjustItem( eTVA ) ); - } + if( m_xTsbFullWidth->get_state() == TRISTATE_TRUE ) + { + if (IsTextDirectionLeftToRight()) + eTHA = SDRTEXTHORZADJUST_BLOCK; else + eTVA = SDRTEXTVERTADJUST_BLOCK; + } + + if ( rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ) != SfxItemState::INVALID ) + { + SdrTextVertAdjust eOldTVA = rOutAttrs.Get( SDRATTR_TEXT_VERTADJUST ).GetValue(); + if( eOldTVA != eTVA ) rAttrs->Put( SdrTextVertAdjustItem( eTVA ) ); + } + else + rAttrs->Put( SdrTextVertAdjustItem( eTVA ) ); - if ( rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ) != SfxItemState::DONTCARE ) - { - SdrTextHorzAdjust eOldTHA = rOutAttrs.Get( SDRATTR_TEXT_HORZADJUST ).GetValue(); - if( eOldTHA != eTHA ) - rAttrs->Put( SdrTextHorzAdjustItem( eTHA ) ); - } - else + if ( rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ) != SfxItemState::INVALID ) + { + SdrTextHorzAdjust eOldTHA = rOutAttrs.Get( SDRATTR_TEXT_HORZADJUST ).GetValue(); + if( eOldTHA != eTHA ) rAttrs->Put( SdrTextHorzAdjustItem( eTHA ) ); } + else + rAttrs->Put( SdrTextHorzAdjustItem( eTHA ) ); return true; } @@ -431,17 +430,17 @@ void SvxTextAttrPage::Construct() { switch (m_eObjKind) { - case OBJ_NONE: + case SdrObjKind::NONE: // indeterminate, show them all bFitToSizeEnabled = bContourEnabled = bWordWrapTextEnabled = bAutoGrowSizeEnabled = bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = true; m_xCustomShapeText->show(); m_xDrawingText->show(); break; - case OBJ_TEXT: - case OBJ_TITLETEXT: - case OBJ_OUTLINETEXT: - case OBJ_CAPTION: + case SdrObjKind::Text: + case SdrObjKind::TitleText: + case SdrObjKind::OutlineText: + case SdrObjKind::Caption: // contour NOT possible for pure text objects bContourEnabled = bWordWrapTextEnabled = bAutoGrowSizeEnabled = false; @@ -450,7 +449,7 @@ void SvxTextAttrPage::Construct() m_xCustomShapeText->hide(); m_xDrawingText->show(); break; - case OBJ_CUSTOMSHAPE: + case SdrObjKind::CustomShape: bFitToSizeEnabled = bContourEnabled = bAutoGrowWidthEnabled = bAutoGrowHeightEnabled = false; bWordWrapTextEnabled = bAutoGrowSizeEnabled = true; m_xDrawingText->hide(); @@ -631,7 +630,7 @@ IMPL_LINK(SvxTextAttrPage, ClickHdl_Impl, weld::Toggleable&, rButton, void) // #103516# Do the setup based on states of hor/ver adjust SfxItemState eVState = rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ); SfxItemState eHState = rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ); - bool bHorAndVer(SfxItemState::DONTCARE == eVState || SfxItemState::DONTCARE == eHState); + bool bHorAndVer(SfxItemState::INVALID == eVState || SfxItemState::INVALID == eHState); // #83698# enable/disable text anchoring dependent of contour m_xFlPosition->set_sensitive(!bContour && !bHorAndVer); @@ -644,7 +643,7 @@ bool SvxTextAttrPage::IsTextDirectionLeftToRight() const bool bLeftToRightDirection = true; SfxItemState eState = rOutAttrs.GetItemState(SDRATTR_TEXTDIRECTION); - if(SfxItemState::DONTCARE != eState) + if(SfxItemState::INVALID != eState) { const SvxWritingModeItem& rItem = rOutAttrs.Get(SDRATTR_TEXTDIRECTION); if (rItem.GetValue() == css::text::WritingMode_TB_RL) diff --git a/cui/source/tabpages/tparea.cxx b/cui/source/tabpages/tparea.cxx index 2bacae4da9f5..b67990e29625 100644 --- a/cui/source/tabpages/tparea.cxx +++ b/cui/source/tabpages/tparea.cxx @@ -19,12 +19,14 @@ #include <svx/svxids.hrc> #include <svx/xfillit0.hxx> +#include <svx/xfilluseslidebackgrounditem.hxx> #include <svx/xflbckit.hxx> #include <svx/drawitem.hxx> #include <svx/xflclit.hxx> #include <svx/xflgrit.hxx> #include <svx/xflhtit.hxx> #include <svx/xbtmpit.hxx> +#include <svx/xgrscit.hxx> #include <cuitabarea.hxx> #include <sfx2/tabdlg.hxx> @@ -41,7 +43,8 @@ enum FillType GRADIENT, HATCH, BITMAP, - PATTERN + PATTERN, + USE_BACKGROUND_FILL }; } @@ -70,7 +73,8 @@ void lclExtendSize(Size& rSize, const Size& rInputSize) |* \************************************************************************/ -SvxAreaTabPage::SvxAreaTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) +SvxAreaTabPage::SvxAreaTabPage(weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet& rInAttrs, bool bSlideBackground) : SfxTabPage(pPage, pController, "cui/ui/areatabpage.ui", "AreaTabPage", &rInAttrs) // local fixed not o be changed values for local pointers , maFixed_ChangeType(ChangeType::NONE) @@ -89,6 +93,7 @@ SvxAreaTabPage::SvxAreaTabPage(weld::Container* pPage, weld::DialogController* p , m_xBtnHatch(m_xBuilder->weld_toggle_button("btnhatch")) , m_xBtnBitmap(m_xBuilder->weld_toggle_button("btnbitmap")) , m_xBtnPattern(m_xBuilder->weld_toggle_button("btnpattern")) + , m_xBtnUseBackground(m_xBuilder->weld_toggle_button("btnusebackground")) { maBox.AddButton(m_xBtnNone.get()); maBox.AddButton(m_xBtnColor.get()); @@ -96,6 +101,7 @@ SvxAreaTabPage::SvxAreaTabPage(weld::Container* pPage, weld::DialogController* p maBox.AddButton(m_xBtnHatch.get()); maBox.AddButton(m_xBtnBitmap.get()); maBox.AddButton(m_xBtnPattern.get()); + Link<weld::Toggleable&, void> aLink = LINK(this, SvxAreaTabPage, SelectFillTypeHdl_Impl); m_xBtnNone->connect_toggled(aLink); m_xBtnColor->connect_toggled(aLink); @@ -103,6 +109,13 @@ SvxAreaTabPage::SvxAreaTabPage(weld::Container* pPage, weld::DialogController* p m_xBtnHatch->connect_toggled(aLink); m_xBtnBitmap->connect_toggled(aLink); m_xBtnPattern->connect_toggled(aLink); + if (bSlideBackground) + { + maBox.AddButton(m_xBtnUseBackground.get()); + m_xBtnUseBackground->connect_toggled(aLink); + } + else + m_xBtnUseBackground->hide(); SetExchangeSupport(); } @@ -154,9 +167,9 @@ SvxAreaTabPage::~SvxAreaTabPage() void SvxAreaTabPage::ActivatePage( const SfxItemSet& rSet ) { drawing::FillStyle eXFS = drawing::FillStyle_NONE; - if( rSet.GetItemState( XATTR_FILLSTYLE ) != SfxItemState::DONTCARE ) + if( rSet.GetItemState( XATTR_FILLSTYLE ) != SfxItemState::INVALID ) { - XFillStyleItem aFillStyleItem( static_cast<const XFillStyleItem&>( rSet.Get( GetWhich( XATTR_FILLSTYLE ) ) ) ); + XFillStyleItem aFillStyleItem( rSet.Get( GetWhich( XATTR_FILLSTYLE ) ) ); eXFS = aFillStyleItem.GetValue(); m_rXFSet.Put( aFillStyleItem ); } @@ -166,33 +179,37 @@ void SvxAreaTabPage::ActivatePage( const SfxItemSet& rSet ) default: case drawing::FillStyle_NONE: { - SelectFillType(*m_xBtnNone); + XFillUseSlideBackgroundItem aBckItem( rSet.Get(XATTR_FILLUSESLIDEBACKGROUND)); + if (aBckItem.GetValue()) + SelectFillType(*m_xBtnUseBackground); + else + SelectFillType(*m_xBtnNone); break; } case drawing::FillStyle_SOLID: { - m_rXFSet.Put( static_cast<const XFillColorItem&>( rSet.Get( GetWhich( XATTR_FILLCOLOR ) ) ) ); + m_rXFSet.Put( rSet.Get( GetWhich( XATTR_FILLCOLOR ) ) ); SelectFillType(*m_xBtnColor); break; } case drawing::FillStyle_GRADIENT: { - m_rXFSet.Put( static_cast<const XFillGradientItem&>( rSet.Get( GetWhich( XATTR_FILLGRADIENT ) ) ) ); + m_rXFSet.Put( rSet.Get( GetWhich( XATTR_FILLGRADIENT ) ) ); + m_rXFSet.Put(rSet.Get(GetWhich(XATTR_GRADIENTSTEPCOUNT))); SelectFillType(*m_xBtnGradient); break; } case drawing::FillStyle_HATCH: { m_rXFSet.Put( rSet.Get(XATTR_FILLHATCH) ); - m_rXFSet.Put( rSet.Get(XATTR_FILLBACKGROUND) ); + m_rXFSet.Put( rSet.Get(XATTR_FILLUSESLIDEBACKGROUND) ); m_rXFSet.Put( rSet.Get(XATTR_FILLCOLOR) ); SelectFillType(*m_xBtnHatch); break; } case drawing::FillStyle_BITMAP: { - const bool bPattern - = rSet.Get(TypedWhichId<XFillBitmapItem>(GetWhich(XATTR_FILLBITMAP))).isPattern(); + const bool bPattern = rSet.Get(GetWhich(XATTR_FILLBITMAP)).isPattern(); // pass full item set here, bitmap fill has many attributes (tiling, size, offset etc.) m_rXFSet.Put( rSet ); if (!bPattern) @@ -223,6 +240,8 @@ DeactivateRC SvxAreaTabPage::DeactivatePage( SfxItemSet* _pSet ) { XFillStyleItem aStyleItem( drawing::FillStyle_NONE ); _pSet->Put( aStyleItem ); + XFillUseSlideBackgroundItem aFillBgItem( false ); + _pSet->Put( aFillBgItem ); } break; } @@ -236,6 +255,17 @@ DeactivateRC SvxAreaTabPage::DeactivatePage( SfxItemSet* _pSet ) return DeactivatePage_Impl<SvxBitmapTabPage&>(_pSet); case PATTERN: return DeactivatePage_Impl<SvxPatternTabPage>(_pSet); + case USE_BACKGROUND_FILL: + { + if ( m_bBtnClicked ) + { + XFillStyleItem aStyleItem( drawing::FillStyle_NONE ); + _pSet->Put( aStyleItem ); + XFillUseSlideBackgroundItem aFillBgItem( true ); + _pSet->Put( aFillBgItem ); + } + break; + } default: break; } @@ -248,6 +278,21 @@ bool SvxAreaTabPage::FillItemSet_Impl( SfxItemSet* rAttrs) return static_cast<TTabPage&>( *m_xFillTabPage ).FillItemSet( rAttrs ); } +OUString SvxAreaTabPage::GetAllStrings() +{ + OUString sAllStrings; + OUString toggleButton[] = { "btnnone", "btncolor", "btngradient", "btnbitmap", + "btnpattern", "btnhatch", "btnusebackground" }; + + for (const auto& toggle : toggleButton) + { + if (const auto& pString = m_xBuilder->weld_toggle_button(toggle)) + sAllStrings += pString->get_label() + " "; + } + + return sAllStrings.replaceAll("_", ""); +} + bool SvxAreaTabPage::FillItemSet( SfxItemSet* rAttrs ) { FillType eFillType = static_cast<FillType>(maBox.GetCurrentButtonPos()); @@ -256,6 +301,7 @@ bool SvxAreaTabPage::FillItemSet( SfxItemSet* rAttrs ) case TRANSPARENT: { rAttrs->Put( XFillStyleItem( drawing::FillStyle_NONE ) ); + rAttrs->Put( XFillUseSlideBackgroundItem( false ) ); return true; } case SOLID: @@ -278,6 +324,12 @@ bool SvxAreaTabPage::FillItemSet( SfxItemSet* rAttrs ) { return FillItemSet_Impl<SvxPatternTabPage>( rAttrs ); } + case USE_BACKGROUND_FILL: + { + rAttrs->Put( XFillStyleItem( drawing::FillStyle_NONE ) ); + rAttrs->Put( XFillUseSlideBackgroundItem( true ) ); + return true; + } default: return false; } @@ -332,6 +384,14 @@ std::unique_ptr<SfxTabPage> SvxAreaTabPage::Create(weld::Container* pPage, weld: return xRet; } +std::unique_ptr<SfxTabPage> SvxAreaTabPage::CreateWithSlideBackground( + weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrs) +{ + auto xRet = std::make_unique<SvxAreaTabPage>(pPage, pController, *rAttrs, true); + xRet->SetOptimalSize(pController); + return xRet; +} + namespace { std::unique_ptr<SfxTabPage> lcl_CreateFillStyleTabPage(sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) @@ -345,6 +405,7 @@ std::unique_ptr<SfxTabPage> lcl_CreateFillStyleTabPage(sal_uInt16 nId, weld::Con case HATCH: fnCreate = &SvxHatchTabPage::Create; break; case BITMAP: fnCreate = &SvxBitmapTabPage::Create; break; case PATTERN: fnCreate = &SvxPatternTabPage::Create; break; + case USE_BACKGROUND_FILL: fnCreate = nullptr; break; } return fnCreate ? (*fnCreate)( pPage, pController, &rSet ) : nullptr; } @@ -373,8 +434,10 @@ void SvxAreaTabPage::SelectFillType(weld::Toggleable& rButton, const SfxItemSet* FillType eFillType = static_cast<FillType>(maBox.GetCurrentButtonPos()); m_xFillTabPage = lcl_CreateFillStyleTabPage(eFillType, m_xFillTab.get(), GetDialogController(), m_rXFSet); if (m_xFillTabPage) + { m_xFillTabPage->SetDialogController(GetDialogController()); - CreatePage(eFillType, m_xFillTabPage.get()); + CreatePage(eFillType, *m_xFillTabPage); + } } } @@ -398,63 +461,63 @@ void SvxAreaTabPage::PageCreated(const SfxAllItemSet& aSet) SetPatternList(pPatternListItem->GetPatternList()); } -void SvxAreaTabPage::CreatePage( sal_Int32 nId, SfxTabPage* pTab ) +void SvxAreaTabPage::CreatePage(sal_Int32 nId, SfxTabPage& rTab) { if(nId == SOLID ) { - auto* pColorTab = static_cast<SvxColorTabPage*>(pTab); - pColorTab->SetColorList(m_pColorList); - pColorTab->SetColorChgd(m_pnColorListState); - pColorTab->Construct(); - pColorTab->ActivatePage(m_rXFSet); - pColorTab->Reset(&m_rXFSet); - pColorTab->set_visible(true); + auto& rColorTab = static_cast<SvxColorTabPage&>(rTab); + rColorTab.SetColorList(m_pColorList); + rColorTab.SetColorChgd(m_pnColorListState); + rColorTab.Construct(); + rColorTab.ActivatePage(m_rXFSet); + rColorTab.Reset(&m_rXFSet); + rColorTab.set_visible(true); } else if(nId == GRADIENT) { - auto* pGradientTab = static_cast<SvxGradientTabPage*>(pTab); - pGradientTab->SetColorList(m_pColorList); - pGradientTab->SetGradientList(m_pGradientList); - pGradientTab->SetGrdChgd(m_pnGradientListState); - pGradientTab->SetColorChgd(m_pnColorListState); - pGradientTab->Construct(); - pGradientTab->ActivatePage(m_rXFSet); - pGradientTab->Reset(&m_rXFSet); - pGradientTab->set_visible(true); + auto& rGradientTab = static_cast<SvxGradientTabPage&>(rTab); + rGradientTab.SetColorList(m_pColorList); + rGradientTab.SetGradientList(m_pGradientList); + rGradientTab.SetGrdChgd(m_pnGradientListState); + rGradientTab.SetColorChgd(m_pnColorListState); + rGradientTab.Construct(); + rGradientTab.ActivatePage(m_rXFSet); + rGradientTab.Reset(&m_rXFSet); + rGradientTab.set_visible(true); } else if(nId == HATCH) { - auto* pHatchTab = static_cast<SvxHatchTabPage*>(pTab); - pHatchTab->SetColorList(m_pColorList); - pHatchTab->SetHatchingList(m_pHatchingList); - pHatchTab->SetHtchChgd(m_pnHatchingListState); - pHatchTab->SetColorChgd(m_pnColorListState); - pHatchTab->Construct(); - pHatchTab->ActivatePage(m_rXFSet); - pHatchTab->Reset(&m_rXFSet); - pHatchTab->set_visible(true); + auto& rHatchTab = static_cast<SvxHatchTabPage&>(rTab); + rHatchTab.SetColorList(m_pColorList); + rHatchTab.SetHatchingList(m_pHatchingList); + rHatchTab.SetHtchChgd(m_pnHatchingListState); + rHatchTab.SetColorChgd(m_pnColorListState); + rHatchTab.Construct(); + rHatchTab.ActivatePage(m_rXFSet); + rHatchTab.Reset(&m_rXFSet); + rHatchTab.set_visible(true); } else if(nId == BITMAP) { - auto* pBitmapTab = static_cast<SvxBitmapTabPage*>(pTab); - pBitmapTab->SetBitmapList(m_pBitmapList); - pBitmapTab->SetBmpChgd(m_pnBitmapListState); - pBitmapTab->Construct(); - pBitmapTab->ActivatePage(m_rXFSet); - pBitmapTab->Reset(&m_rXFSet); - pBitmapTab->set_visible(true); + auto& rBitmapTab = static_cast<SvxBitmapTabPage&>(rTab); + rBitmapTab.SetBitmapList(m_pBitmapList); + rBitmapTab.SetBmpChgd(m_pnBitmapListState); + rBitmapTab.Construct(); + rBitmapTab.ActivatePage(m_rXFSet); + rBitmapTab.Reset(&m_rXFSet); + rBitmapTab.set_visible(true); } else if(nId == PATTERN) { - auto* pPatternTab = static_cast<SvxPatternTabPage*>(pTab); - pPatternTab->SetColorList(m_pColorList); - pPatternTab->SetPatternList(m_pPatternList); - pPatternTab->SetPtrnChgd(m_pnPatternListState); - pPatternTab->SetColorChgd(m_pnColorListState); - pPatternTab->Construct(); - pPatternTab->ActivatePage(m_rXFSet); - pPatternTab->Reset(&m_rXFSet); - pPatternTab->set_visible(true); + auto& rPatternTab = static_cast<SvxPatternTabPage&>(rTab); + rPatternTab.SetColorList(m_pColorList); + rPatternTab.SetPatternList(m_pPatternList); + rPatternTab.SetPtrnChgd(m_pnPatternListState); + rPatternTab.SetColorChgd(m_pnColorListState); + rPatternTab.Construct(); + rPatternTab.ActivatePage(m_rXFSet); + rPatternTab.Reset(&m_rXFSet); + rPatternTab.set_visible(true); } } diff --git a/cui/source/tabpages/tpbitmap.cxx b/cui/source/tabpages/tpbitmap.cxx index 65cb4136cd5e..2990f4473e91 100644 --- a/cui/source/tabpages/tpbitmap.cxx +++ b/cui/source/tabpages/tpbitmap.cxx @@ -260,7 +260,7 @@ void SvxBitmapTabPage::Reset( const SfxItemSet* rAttrs ) double fUIScale = 1.0; if (mpView) { - fUIScale = ( mpView->GetModel() ? double(mpView->GetModel()->GetUIScale()) : 1.0); + fUIScale = double(mpView->GetModel().GetUIScale()); if (mpView->AreObjectsMarked()) @@ -298,9 +298,9 @@ void SvxBitmapTabPage::Reset( const SfxItemSet* rAttrs ) CalculateBitmapPresetSize(); bool bTiled = false; bool bStretched = false; - if(rAttrs->GetItemState( XATTR_FILLBMP_TILE ) != SfxItemState::DONTCARE) + if(rAttrs->GetItemState( XATTR_FILLBMP_TILE ) != SfxItemState::INVALID) bTiled = rAttrs->Get( XATTR_FILLBMP_TILE ).GetValue(); - if(rAttrs->GetItemState( XATTR_FILLBMP_STRETCH ) != SfxItemState::DONTCARE) + if(rAttrs->GetItemState( XATTR_FILLBMP_STRETCH ) != SfxItemState::INVALID) bStretched = rAttrs->Get( XATTR_FILLBMP_STRETCH ).GetValue(); if (bTiled) @@ -313,42 +313,38 @@ void SvxBitmapTabPage::Reset( const SfxItemSet* rAttrs ) tools::Long nWidth = 0; tools::Long nHeight = 0; - if(rAttrs->GetItemState(XATTR_FILLBMP_SIZELOG) != SfxItemState::DONTCARE) + if(rAttrs->GetItemState(XATTR_FILLBMP_SIZELOG) != SfxItemState::INVALID) { if (rAttrs->Get( XATTR_FILLBMP_SIZELOG ).GetValue()) - { m_xTsbScale->set_state(TRISTATE_FALSE); - m_bLogicalSize = true; - } else - { m_xTsbScale->set_state(TRISTATE_TRUE); - m_bLogicalSize = false; - } } else m_xTsbScale->set_state(TRISTATE_INDET); TriState eRelative = TRISTATE_FALSE; - if(rAttrs->GetItemState(XATTR_FILLBMP_SIZEX) != SfxItemState::DONTCARE) + if(rAttrs->GetItemState(XATTR_FILLBMP_SIZEX) != SfxItemState::INVALID) { nWidth = static_cast<const XFillBmpSizeXItem&>( rAttrs->Get( XATTR_FILLBMP_SIZEX ) ).GetValue(); if(nWidth == 0) nWidth = rBitmapSize.Width(); else if(nWidth < 0) { + m_bLogicalSize = true; eRelative = TRISTATE_TRUE; nWidth = std::abs(nWidth); } } - if(rAttrs->GetItemState( XATTR_FILLBMP_SIZEY ) != SfxItemState::DONTCARE) + if(rAttrs->GetItemState( XATTR_FILLBMP_SIZEY ) != SfxItemState::INVALID) { nHeight = rAttrs->Get( XATTR_FILLBMP_SIZEY ).GetValue(); if(nHeight == 0) nHeight = rBitmapSize.Height(); else if(nHeight < 0) { + m_bLogicalSize = true; eRelative = TRISTATE_TRUE; nHeight = std::abs(nHeight); } @@ -371,13 +367,13 @@ void SvxBitmapTabPage::Reset( const SfxItemSet* rAttrs ) } } - if( rAttrs->GetItemState( XATTR_FILLBMP_POS ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( XATTR_FILLBMP_POS ) != SfxItemState::INVALID ) { RectPoint eValue = rAttrs->Get( XATTR_FILLBMP_POS ).GetValue(); m_xPositionLB->set_active( static_cast< sal_Int32 >(eValue) ); } - if( rAttrs->GetItemState( XATTR_FILLBMP_POSOFFSETX ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( XATTR_FILLBMP_POSOFFSETX ) != SfxItemState::INVALID ) { sal_Int32 nValue = rAttrs->Get( XATTR_FILLBMP_POSOFFSETX ).GetValue(); m_xPositionOffX->set_value(nValue, FieldUnit::PERCENT); @@ -385,7 +381,7 @@ void SvxBitmapTabPage::Reset( const SfxItemSet* rAttrs ) else m_xPositionOffX->set_text(""); - if( rAttrs->GetItemState( XATTR_FILLBMP_POSOFFSETY ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( XATTR_FILLBMP_POSOFFSETY ) != SfxItemState::INVALID ) { sal_Int32 nValue = rAttrs->Get( XATTR_FILLBMP_POSOFFSETY ).GetValue(); m_xPositionOffY->set_value(nValue, FieldUnit::PERCENT); @@ -393,7 +389,7 @@ void SvxBitmapTabPage::Reset( const SfxItemSet* rAttrs ) else m_xPositionOffY->set_text(""); - if( rAttrs->GetItemState( XATTR_FILLBMP_TILEOFFSETX ) != SfxItemState::DONTCARE) + if( rAttrs->GetItemState( XATTR_FILLBMP_TILEOFFSETX ) != SfxItemState::INVALID) { sal_Int32 nValue = rAttrs->Get( XATTR_FILLBMP_TILEOFFSETX ).GetValue(); if(nValue > 0) @@ -403,7 +399,7 @@ void SvxBitmapTabPage::Reset( const SfxItemSet* rAttrs ) } } - if( rAttrs->GetItemState( XATTR_FILLBMP_TILEOFFSETY ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( XATTR_FILLBMP_TILEOFFSETY ) != SfxItemState::INVALID ) { sal_Int32 nValue = rAttrs->Get( XATTR_FILLBMP_TILEOFFSETY ).GetValue(); if(nValue > 0) @@ -464,15 +460,14 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ModifyBitmapHdl, ValueSet*, void) } else { - const SfxPoolItem* pPoolItem = nullptr; - - if(SfxItemState::SET == m_rOutAttrs.GetItemState(GetWhich(XATTR_FILLSTYLE), true, &pPoolItem)) + if(const XFillStyleItem* pFillStyleItem = m_rOutAttrs.GetItemIfSet(GetWhich(XATTR_FILLSTYLE))) { - const drawing::FillStyle eXFS(static_cast<const XFillStyleItem*>(pPoolItem)->GetValue()); + const drawing::FillStyle eXFS(pFillStyleItem->GetValue()); - if((drawing::FillStyle_BITMAP == eXFS) && (SfxItemState::SET == m_rOutAttrs.GetItemState(GetWhich(XATTR_FILLBITMAP), true, &pPoolItem))) + const XFillBitmapItem* pBitmapItem; + if((drawing::FillStyle_BITMAP == eXFS) && (pBitmapItem = m_rOutAttrs.GetItemIfSet(GetWhich(XATTR_FILLBITMAP)))) { - pGraphicObject.reset(new GraphicObject(static_cast<const XFillBitmapItem*>(pPoolItem)->GetGraphicObject())); + pGraphicObject.reset(new GraphicObject(pBitmapItem->GetGraphicObject())); } } @@ -492,7 +487,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ModifyBitmapHdl, ValueSet*, void) { BitmapEx aBmpEx(pGraphicObject->GetGraphic().GetBitmapEx()); Size aTempBitmapSize = aBmpEx.GetSizePixel(); - const double fUIScale = ( (mpView && mpView->GetModel()) ? double(mpView->GetModel()->GetUIScale()) : 1.0); + const double fUIScale = mpView ? double(mpView->GetModel().GetUIScale()) : 1.0; Size aBitmapSize100mm = o3tl::convert(aTempBitmapSize, o3tl::Length::pt, o3tl::Length::mm100); rBitmapSize.setWidth(aBitmapSize100mm.Width() / fUIScale); @@ -523,7 +518,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickRenameHdl, SvxPresetListBox*, void) if( nPos == VALUESET_ITEM_NOTFOUND ) return; - OUString aDesc( CuiResId( RID_SVXSTR_DESC_NEW_BITMAP ) ); + OUString aDesc( CuiResId( RID_CUISTR_DESC_NEW_BITMAP ) ); OUString aName( m_pBitmapList->GetBitmap( nPos )->GetName() ); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); @@ -532,7 +527,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickRenameHdl, SvxPresetListBox*, void) bool bLoop = true; while( bLoop && pDlg->Execute() == RET_OK ) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); sal_Int32 nBitmapPos = SearchBitmapList( aName ); bool bValidBitmapName = (nBitmapPos == static_cast<sal_Int32>(nPos) ) || (nBitmapPos == -1); @@ -718,7 +713,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickImportHdl, weld::Button&, void) { weld::Window* pDialogFrameWeld = GetFrameWeld(); - SvxOpenGraphicDialog aDlg(CuiResId(RID_SVXSTR_ADD_IMAGE), pDialogFrameWeld); + SvxOpenGraphicDialog aDlg(CuiResId(RID_CUISTR_ADD_IMAGE), pDialogFrameWeld); aDlg.EnableLink(false); tools::Long nCount = m_pBitmapList->Count(); @@ -733,7 +728,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickImportHdl, weld::Button&, void) if( !nError ) { - OUString aDesc(CuiResId(RID_SVXSTR_DESC_EXT_BITMAP)); + OUString aDesc(CuiResId(RID_CUISTR_DESC_EXT_BITMAP)); // convert file URL to UI name OUString aName; @@ -745,7 +740,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickImportHdl, weld::Button&, void) while( pDlg->Execute() == RET_OK ) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); bool bDifferent = true; diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx index 5669f73adc76..ccfe75232bef 100644 --- a/cui/source/tabpages/tpcolor.cxx +++ b/cui/source/tabpages/tpcolor.cxx @@ -36,6 +36,7 @@ #include <officecfg/Office/Common.hxx> #include <osl/diagnose.h> #include <comphelper/dispatchcommand.hxx> +#include <comphelper/lok.hxx> #include <comphelper/propertyvalue.hxx> using namespace com::sun::star; @@ -48,7 +49,6 @@ SvxColorTabPage::SvxColorTabPage(weld::Container* pPage, weld::DialogController* , aXFillAttr( rInAttrs.GetPool() ) , rXFSet( aXFillAttr.GetItemSet() ) , eCM( ColorModel::RGB ) - , m_context(comphelper::getProcessComponentContext()) , m_xValSetColorList(new SvxColorValueSet(m_xBuilder->weld_scrolled_window("colorsetwin", true))) , m_xValSetRecentList(new SvxColorValueSet(nullptr)) , m_xSelectPalette(m_xBuilder->weld_combo_box("paletteselector")) @@ -129,9 +129,8 @@ SvxColorTabPage::SvxColorTabPage(weld::Container* pPage, weld::DialogController* // disable modify buttons // Color palettes can't be modified m_xBtnDelete->set_sensitive(false); - m_xBtnDelete->set_tooltip_text( SvxResId(RID_SVXSTR_DELETEUSERCOLOR1) ); + m_xBtnDelete->set_tooltip_text( CuiResId(RID_CUISTR_DELETEUSERCOLOR1) ); - m_xMoreColors->set_from_icon_name("cmd/sc_additionsdialog.png"); m_xMoreColors->connect_clicked(LINK(this, SvxColorTabPage, OnMoreColorsClick)); // disable preset color values @@ -150,6 +149,12 @@ SvxColorTabPage::SvxColorTabPage(weld::Container* pPage, weld::DialogController* maPaletteManager.ReloadRecentColorSet(*m_xValSetRecentList); aSize = m_xValSetRecentList->layoutAllVisible(maPaletteManager.GetRecentColorCount()); m_xValSetRecentList->set_size_request(aSize.Width(), aSize.Height()); + + // it is not possible to install color palette extensions in Online or mobile apps + if(comphelper::LibreOfficeKit::isActive()) + { + m_xMoreColors->hide(); + } } SvxColorTabPage::~SvxColorTabPage() @@ -198,14 +203,15 @@ void SvxColorTabPage::ActivatePage( const SfxItemSet& ) if( !pColorList.is() ) return; - const SfxPoolItem* pPoolItem = nullptr; - if( SfxItemState::SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLCOLOR ), true, &pPoolItem ) ) + if( const XFillColorItem* pFillColorItem = rOutAttrs.GetItemIfSet( GetWhich( XATTR_FILLCOLOR ) ) ) { SetColorModel( ColorModel::RGB ); ChangeColorModel(); - const Color aColor = static_cast<const XFillColorItem*>(pPoolItem)->GetColorValue(); - ChangeColor( aColor ); + const Color aColor = pFillColorItem->GetColorValue(); + NamedColor aNamedColor; + aNamedColor.m_aColor = aColor; + ChangeColor(aNamedColor); sal_Int32 nPos = FindInPalette( aColor ); if ( nPos != -1 ) @@ -232,13 +238,16 @@ bool SvxColorTabPage::FillItemSet( SfxItemSet* rSet ) { Color aColor = m_xValSetColorList->GetItemColor( m_xValSetColorList->GetSelectedItemId() ); OUString sColorName; - if ( aCurrentColor == aColor ) + if (m_aCurrentColor.m_aColor == aColor) sColorName = m_xValSetColorList->GetItemText( m_xValSetColorList->GetSelectedItemId() ); else - sColorName = "#" + aCurrentColor.AsRGBHexString().toAsciiUpperCase(); - maPaletteManager.AddRecentColor( aCurrentColor, sColorName ); - rSet->Put( XFillColorItem( sColorName, aCurrentColor ) ); - rSet->Put( XFillStyleItem( drawing::FillStyle_SOLID ) ); + sColorName = "#" + m_aCurrentColor.m_aColor.AsRGBHexString().toAsciiUpperCase(); + + maPaletteManager.AddRecentColor(m_aCurrentColor.m_aColor, sColorName); + XFillColorItem aColorItem(sColorName, m_aCurrentColor.m_aColor); + aColorItem.setComplexColor(m_aCurrentColor.getComplexColor()); + rSet->Put(aColorItem); + rSet->Put(XFillStyleItem(drawing::FillStyle_SOLID)); return true; } @@ -257,7 +266,7 @@ void SvxColorTabPage::Reset( const SfxItemSet* rSet ) if ( nState >= SfxItemState::DEFAULT ) { XFillColorItem aColorItem( rSet->Get( XATTR_FILLCOLOR ) ); - aPreviousColor = aColorItem.GetColorValue(); + m_aPreviousColor = aColorItem.GetColorValue(); aNewColor = aColorItem.GetColorValue(); } @@ -267,7 +276,9 @@ void SvxColorTabPage::Reset( const SfxItemSet* rSet ) SetColorModel( eCM ); ChangeColorModel(); - ChangeColor(aNewColor); + NamedColor aColor; + aColor.m_aColor = aNewColor; + ChangeColor(aColor); UpdateModified(); } @@ -281,12 +292,12 @@ std::unique_ptr<SfxTabPage> SvxColorTabPage::Create(weld::Container* pPage, weld IMPL_LINK_NOARG(SvxColorTabPage, SpinValueHdl_Impl, weld::SpinButton&, void) { // read current MtrFields, if cmyk, then k-value as transparency - aCurrentColor = Color(static_cast<sal_uInt8>(PercentToColor_Impl(m_xRcustom->get_value())), + m_aCurrentColor.m_aColor = Color(static_cast<sal_uInt8>(PercentToColor_Impl(m_xRcustom->get_value())), static_cast<sal_uInt8>(PercentToColor_Impl(m_xGcustom->get_value())), static_cast<sal_uInt8>(PercentToColor_Impl(m_xBcustom->get_value()))); UpdateColorValues(); - rXFSet.Put( XFillColorItem( OUString(), aCurrentColor ) ); + rXFSet.Put( XFillColorItem( OUString(), m_aCurrentColor.m_aColor ) ); m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() ); m_aCtlPreviewNew.Invalidate(); @@ -295,13 +306,13 @@ IMPL_LINK_NOARG(SvxColorTabPage, SpinValueHdl_Impl, weld::SpinButton&, void) IMPL_LINK_NOARG(SvxColorTabPage, MetricSpinValueHdl_Impl, weld::MetricSpinButton&, void) { // read current MtrFields, if cmyk, then k-value as transparency - aCurrentColor = Color(ColorTransparency, static_cast<sal_uInt8>(PercentToColor_Impl(m_xKcustom->get_value(FieldUnit::NONE))), + m_aCurrentColor.m_aColor = Color(ColorTransparency, static_cast<sal_uInt8>(PercentToColor_Impl(m_xKcustom->get_value(FieldUnit::NONE))), static_cast<sal_uInt8>(PercentToColor_Impl(m_xCcustom->get_value(FieldUnit::NONE))), static_cast<sal_uInt8>(PercentToColor_Impl(m_xYcustom->get_value(FieldUnit::NONE))), static_cast<sal_uInt8>(PercentToColor_Impl(m_xMcustom->get_value(FieldUnit::NONE)))); - ConvertColorValues (aCurrentColor, ColorModel::RGB); + ConvertColorValues (m_aCurrentColor.m_aColor, ColorModel::RGB); - rXFSet.Put( XFillColorItem( OUString(), aCurrentColor ) ); + rXFSet.Put( XFillColorItem( OUString(), m_aCurrentColor.m_aColor ) ); m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() ); m_aCtlPreviewNew.Invalidate(); @@ -309,10 +320,10 @@ IMPL_LINK_NOARG(SvxColorTabPage, MetricSpinValueHdl_Impl, weld::MetricSpinButton IMPL_LINK_NOARG(SvxColorTabPage, ModifiedHdl_Impl, weld::Entry&, void) { - aCurrentColor = m_xHexcustom->GetColor(); + m_aCurrentColor.m_aColor = m_xHexcustom->GetColor(); UpdateColorValues(); - rXFSet.Put( XFillColorItem( OUString(), aCurrentColor ) ); + rXFSet.Put( XFillColorItem( OUString(), m_aCurrentColor.m_aColor ) ); m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() ); m_aCtlPreviewNew.Invalidate(); @@ -321,7 +332,7 @@ IMPL_LINK_NOARG(SvxColorTabPage, ModifiedHdl_Impl, weld::Entry&, void) IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl, weld::Button&, void) { OUString aNewName( SvxResId( RID_SVXSTR_COLOR ) ); - OUString aDesc( CuiResId( RID_SVXSTR_DESC_COLOR ) ); + OUString aDesc( CuiResId( RID_CUISTR_DESC_COLOR ) ); OUString aName; tools::Long j = 1; @@ -339,7 +350,7 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl, weld::Button&, void) while (pDlg->Execute() == RET_OK) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); bValidColorName = (FindInCustomColors(aName) == -1); if (bValidColorName) @@ -360,22 +371,22 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl, weld::Button&, void) { m_xSelectPalette->set_active(0); SelectPaletteLBHdl(*m_xSelectPalette); - std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(m_context)); + std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); css::uno::Sequence< sal_Int32 > aCustomColorList(officecfg::Office::Common::UserColors::CustomColor::get()); css::uno::Sequence< OUString > aCustomColorNameList(officecfg::Office::Common::UserColors::CustomColorName::get()); sal_Int32 nSize = aCustomColorList.getLength(); aCustomColorList.realloc( nSize + 1 ); aCustomColorNameList.realloc( nSize + 1 ); - aCustomColorList.getArray()[nSize] = sal_Int32(aCurrentColor); + aCustomColorList.getArray()[nSize] = sal_Int32(m_aCurrentColor.m_aColor); aCustomColorNameList.getArray()[nSize] = aName; officecfg::Office::Common::UserColors::CustomColor::set(aCustomColorList, batch); officecfg::Office::Common::UserColors::CustomColorName::set(aCustomColorNameList, batch); batch->commit(); sal_uInt16 nId = m_xValSetColorList->GetItemId(nSize - 1); - m_xValSetColorList->InsertItem( nId + 1 , aCurrentColor, aName ); + m_xValSetColorList->InsertItem( nId + 1 , m_aCurrentColor.m_aColor, aName ); m_xValSetColorList->SelectItem( nId + 1 ); m_xBtnDelete->set_sensitive(false); - m_xBtnDelete->set_tooltip_text( SvxResId(RID_SVXSTR_DELETEUSERCOLOR2) ); + m_xBtnDelete->set_tooltip_text( CuiResId(RID_CUISTR_DELETEUSERCOLOR2) ); ImpColorCountChanged(); } @@ -386,13 +397,13 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickWorkOnHdl_Impl, weld::Button&, void) { SvColorDialog aColorDlg; - aColorDlg.SetColor (aCurrentColor); + aColorDlg.SetColor (m_aCurrentColor.m_aColor); aColorDlg.SetMode( svtools::ColorPickerMode::Modify ); if (aColorDlg.Execute(GetFrameWeld()) == RET_OK) { Color aPreviewColor = aColorDlg.GetColor(); - aCurrentColor = aPreviewColor; + m_aCurrentColor.m_aColor = aPreviewColor; UpdateColorValues( false ); // fill ItemSet and pass it on to XOut rXFSet.Put( XFillColorItem( OUString(), aPreviewColor ) ); @@ -410,7 +421,7 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickDeleteHdl_Impl, weld::Button&, void) if (m_xSelectPalette->get_active() != 0 || nPos == VALUESET_ITEM_NOTFOUND) return; - std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(m_context)); + std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); css::uno::Sequence< sal_Int32 > aCustomColorList(officecfg::Office::Common::UserColors::CustomColor::get()); auto aCustomColorListRange = asNonConstRange(aCustomColorList); css::uno::Sequence< OUString > aCustomColorNameList(officecfg::Office::Common::UserColors::CustomColorName::get()); @@ -436,7 +447,7 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickDeleteHdl_Impl, weld::Button&, void) else { m_xBtnDelete->set_sensitive(false); - m_xBtnDelete->set_tooltip_text( SvxResId(RID_SVXSTR_DELETEUSERCOLOR2) ); + m_xBtnDelete->set_tooltip_text( CuiResId(RID_CUISTR_DELETEUSERCOLOR2) ); } } @@ -472,7 +483,7 @@ IMPL_LINK_NOARG(SvxColorTabPage, SelectPaletteLBHdl, weld::ComboBox&, void) if (nPos != 0) { m_xBtnDelete->set_sensitive(false); - m_xBtnDelete->set_tooltip_text( SvxResId(RID_SVXSTR_DELETEUSERCOLOR1) ); + m_xBtnDelete->set_tooltip_text( CuiResId(RID_CUISTR_DELETEUSERCOLOR1) ); } m_xValSetColorList->Resize(); @@ -489,7 +500,22 @@ IMPL_LINK(SvxColorTabPage, SelectValSetHdl_Impl, ValueSet*, pValSet, void) rXFSet.Put( XFillColorItem( OUString(), aColor ) ); m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() ); m_aCtlPreviewNew.Invalidate(); - ChangeColor(aColor, false); + + NamedColor aNamedColor; + aNamedColor.m_aColor = aColor; + + if (pValSet == m_xValSetColorList.get() && maPaletteManager.IsThemePaletteSelected()) + { + sal_uInt16 nThemeIndex; + sal_uInt16 nEffectIndex; + if (PaletteManager::GetThemeAndEffectIndex(nPos, nThemeIndex, nEffectIndex)) + { + aNamedColor.m_nThemeIndex = nThemeIndex; + maPaletteManager.GetLumModOff(nThemeIndex, nEffectIndex, aNamedColor.m_nLumMod, aNamedColor.m_nLumOff); + } + } + + ChangeColor(aNamedColor, false); if (pValSet == m_xValSetColorList.get()) { @@ -502,14 +528,14 @@ IMPL_LINK(SvxColorTabPage, SelectValSetHdl_Impl, ValueSet*, pValSet, void) else { m_xBtnDelete->set_sensitive(false); - m_xBtnDelete->set_tooltip_text( SvxResId(RID_SVXSTR_DELETEUSERCOLOR1) ); + m_xBtnDelete->set_tooltip_text( CuiResId(RID_CUISTR_DELETEUSERCOLOR1) ); } } if (pValSet == m_xValSetRecentList.get()) { m_xValSetColorList->SetNoSelection(); m_xBtnDelete->set_sensitive(false); - m_xBtnDelete->set_tooltip_text( SvxResId(RID_SVXSTR_DELETEUSERCOLOR2) ); + m_xBtnDelete->set_tooltip_text( CuiResId(RID_CUISTR_DELETEUSERCOLOR2) ); } } @@ -552,13 +578,16 @@ IMPL_STATIC_LINK_NOARG(SvxColorTabPage, OnMoreColorsClick, weld::Button&, void) comphelper::dispatchCommand(".uno:AdditionsDialog", aArgs); } -void SvxColorTabPage::ChangeColor(const Color &rNewColor, bool bUpdatePreset ) +void SvxColorTabPage::ChangeColor(const NamedColor &rNewColor, bool bUpdatePreset ) { - aPreviousColor = rNewColor; - aCurrentColor = rNewColor; + m_aPreviousColor = rNewColor.m_aColor; + m_aCurrentColor = rNewColor; UpdateColorValues( bUpdatePreset ); // fill ItemSet and pass it on to XOut - rXFSet.Put( XFillColorItem( OUString(), aCurrentColor ) ); + XFillColorItem aItem(OUString(), m_aCurrentColor.m_aColor); + aItem.setComplexColor(m_aCurrentColor.getComplexColor()); + rXFSet.Put(aItem); + m_aCtlPreviewNew.SetAttributes(aXFillAttr.GetItemSet()); m_aCtlPreviewNew.Invalidate(); } @@ -599,42 +628,42 @@ void SvxColorTabPage::UpdateColorValues( bool bUpdatePreset ) { if (eCM != ColorModel::RGB) { - ConvertColorValues (aPreviousColor, eCM ); - ConvertColorValues (aCurrentColor, eCM); + ConvertColorValues (m_aPreviousColor, eCM ); + ConvertColorValues (m_aCurrentColor.m_aColor, eCM); - m_xCcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetRed() ), FieldUnit::PERCENT ); - m_xMcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetBlue() ), FieldUnit::PERCENT ); - m_xYcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetGreen() ), FieldUnit::PERCENT ); - m_xKcustom->set_value( ColorToPercent_Impl( 255 - aCurrentColor.GetAlpha() ), FieldUnit::PERCENT ); + m_xCcustom->set_value( ColorToPercent_Impl( m_aCurrentColor.m_aColor.GetRed() ), FieldUnit::PERCENT ); + m_xMcustom->set_value( ColorToPercent_Impl( m_aCurrentColor.m_aColor.GetBlue() ), FieldUnit::PERCENT ); + m_xYcustom->set_value( ColorToPercent_Impl( m_aCurrentColor.m_aColor.GetGreen() ), FieldUnit::PERCENT ); + m_xKcustom->set_value( ColorToPercent_Impl( 255 - m_aCurrentColor.m_aColor.GetAlpha() ), FieldUnit::PERCENT ); if( bUpdatePreset ) { - m_xCpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(aPreviousColor.GetRed()), + m_xCpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(m_aPreviousColor.GetRed()), Application::GetSettings().GetUILanguageTag())); - m_xMpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(aPreviousColor.GetBlue()), + m_xMpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(m_aPreviousColor.GetBlue()), Application::GetSettings().GetUILanguageTag())); - m_xYpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(aPreviousColor.GetGreen()), + m_xYpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(m_aPreviousColor.GetGreen()), Application::GetSettings().GetUILanguageTag())); - m_xKpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(255 - aPreviousColor.GetAlpha()), + m_xKpreset->set_text(unicode::formatPercent(ColorToPercent_Impl(255 - m_aPreviousColor.GetAlpha()), Application::GetSettings().GetUILanguageTag())); } - ConvertColorValues (aPreviousColor, ColorModel::RGB); - ConvertColorValues (aCurrentColor, ColorModel::RGB); + ConvertColorValues (m_aPreviousColor, ColorModel::RGB); + ConvertColorValues (m_aCurrentColor.m_aColor, ColorModel::RGB); } else { - m_xRcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetRed() ) ); - m_xGcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetGreen() ) ); - m_xBcustom->set_value( ColorToPercent_Impl( aCurrentColor.GetBlue() ) ); - m_xHexcustom->SetColor( aCurrentColor ); + m_xRcustom->set_value( ColorToPercent_Impl( m_aCurrentColor.m_aColor.GetRed() ) ); + m_xGcustom->set_value( ColorToPercent_Impl( m_aCurrentColor.m_aColor.GetGreen() ) ); + m_xBcustom->set_value( ColorToPercent_Impl( m_aCurrentColor.m_aColor.GetBlue() ) ); + m_xHexcustom->SetColor( m_aCurrentColor.m_aColor ); if( bUpdatePreset ) { - m_xRpreset->set_text(OUString::number(ColorToPercent_Impl(aPreviousColor.GetRed()))); - m_xGpreset->set_text(OUString::number(ColorToPercent_Impl(aPreviousColor.GetGreen()))); - m_xBpreset->set_text(OUString::number(ColorToPercent_Impl(aPreviousColor.GetBlue()))); - m_xHexpreset->SetColor( aPreviousColor ); + m_xRpreset->set_text(OUString::number(ColorToPercent_Impl(m_aPreviousColor.GetRed()))); + m_xGpreset->set_text(OUString::number(ColorToPercent_Impl(m_aPreviousColor.GetGreen()))); + m_xBpreset->set_text(OUString::number(ColorToPercent_Impl(m_aPreviousColor.GetBlue()))); + m_xHexpreset->SetColor( m_aPreviousColor ); } } } diff --git a/cui/source/tabpages/tpgradnt.cxx b/cui/source/tabpages/tpgradnt.cxx index 00b01bd0ce33..2fb57742e0b3 100644 --- a/cui/source/tabpages/tpgradnt.cxx +++ b/cui/source/tabpages/tpgradnt.cxx @@ -34,10 +34,9 @@ #include <dialmgr.hxx> #include <svx/dialmgr.hxx> #include <svx/strings.hrc> +#include <basegfx/utils/gradienttools.hxx> #include <sal/log.hxx> -#define DEFAULT_GRADIENTSTEP 64 - using namespace com::sun::star; SvxGradientTabPage::SvxGradientTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) @@ -83,7 +82,7 @@ SvxGradientTabPage::SvxGradientTabPage(weld::Container* pPage, weld::DialogContr // setting the output device m_rXFSet.Put( XFillStyleItem(drawing::FillStyle_GRADIENT) ); - m_rXFSet.Put( XFillGradientItem(OUString(), XGradient( COL_BLACK, COL_WHITE )) ); + m_rXFSet.Put( XFillGradientItem(OUString(), basegfx::BGradient())); m_aCtlPreview.SetAttributes(m_aXFillAttr.GetItemSet()); // set handler @@ -149,7 +148,7 @@ void SvxGradientTabPage::ActivatePage( const SfxItemSet& rSet ) // determining (and possibly cutting) the name and // displaying it in the GroupBox - OUString aString = CuiResId( RID_SVXSTR_TABLE ) + ": "; + OUString aString = CuiResId( RID_CUISTR_TABLE ) + ": "; INetURLObject aURL( m_pGradientList->GetPath() ); aURL.Append( m_pGradientList->GetName() ); @@ -183,19 +182,26 @@ DeactivateRC SvxGradientTabPage::DeactivatePage( SfxItemSet* _pSet ) bool SvxGradientTabPage::FillItemSet( SfxItemSet* rSet ) { - std::unique_ptr<XGradient> pXGradient; + std::unique_ptr<basegfx::BGradient> pBGradient; size_t nPos = m_xGradientLB->IsNoSelection() ? VALUESET_ITEM_NOTFOUND : m_xGradientLB->GetSelectItemPos(); + + sal_uInt16 nValue = 0; // automatic step count + if (!m_xCbIncrement->get_active()) + nValue = m_xMtrIncrement->get_value(); + if( nPos != VALUESET_ITEM_NOTFOUND ) { - pXGradient.reset(new XGradient( m_pGradientList->GetGradient( static_cast<sal_uInt16>(nPos) )->GetGradient() )); + pBGradient.reset(new basegfx::BGradient( m_pGradientList->GetGradient( static_cast<sal_uInt16>(nPos) )->GetGradient() )); OUString aString = m_xGradientLB->GetItemText( m_xGradientLB->GetSelectedItemId() ); - rSet->Put( XFillGradientItem( aString, *pXGradient ) ); + // update StepCount to current value to be in sync with FillGradientStepCount + pBGradient->SetSteps(nValue); + rSet->Put( XFillGradientItem( aString, *pBGradient ) ); } else // gradient was passed (unidentified) { - pXGradient.reset(new XGradient( m_xLbColorFrom->GetSelectEntryColor(), - m_xLbColorTo->GetSelectEntryColor(), + pBGradient.reset(new basegfx::BGradient( + createColorStops(), static_cast<css::awt::GradientStyle>(m_xLbGradientType->get_active()), Degree10(static_cast<sal_Int16>(m_xMtrAngle->get_value(FieldUnit::NONE) * 10)), // should be changed in resource static_cast<sal_uInt16>(m_xMtrCenterX->get_value(FieldUnit::NONE)), @@ -203,15 +209,11 @@ bool SvxGradientTabPage::FillItemSet( SfxItemSet* rSet ) static_cast<sal_uInt16>(m_xMtrBorder->get_value(FieldUnit::NONE)), static_cast<sal_uInt16>(m_xMtrColorFrom->get_value(FieldUnit::NONE)), static_cast<sal_uInt16>(m_xMtrColorTo->get_value(FieldUnit::NONE)), - static_cast<sal_uInt16>(m_xMtrIncrement->get_value()) )); - rSet->Put( XFillGradientItem( OUString(), *pXGradient ) ); + nValue)); + rSet->Put( XFillGradientItem( OUString(), *pBGradient ) ); } - sal_uInt16 nValue = 0; - if (!m_xCbIncrement->get_active()) - nValue = m_xMtrIncrement->get_value(); - - assert( pXGradient && "XGradient could not be created" ); + assert( pBGradient && "basegfx::BGradient could not be created" ); rSet->Put( XFillStyleItem( drawing::FillStyle_GRADIENT ) ); rSet->Put( XGradientStepCountItem( nValue ) ); return true; @@ -219,8 +221,7 @@ bool SvxGradientTabPage::FillItemSet( SfxItemSet* rSet ) void SvxGradientTabPage::Reset( const SfxItemSet* ) { - m_xMtrIncrement->set_value(DEFAULT_GRADIENTSTEP); - ChangeGradientHdl_Impl(); + ChangeGradientHdl_Impl(); // includes setting m_xCbIncrement and m_xMtrIncrement // determine state of the buttons if( m_pGradientList->Count() ) @@ -292,8 +293,12 @@ void SvxGradientTabPage::ModifiedHdl_Impl( void const * pControl ) css::awt::GradientStyle eXGS = static_cast<css::awt::GradientStyle>(m_xLbGradientType->get_active()); - XGradient aXGradient( m_xLbColorFrom->GetSelectEntryColor(), - m_xLbColorTo->GetSelectEntryColor(), + sal_uInt16 nValue = 0; // automatic + if (!m_xCbIncrement->get_active()) + nValue = static_cast<sal_uInt16>(m_xMtrIncrement->get_value()); + + basegfx::BGradient aBGradient( + createColorStops(), eXGS, Degree10(static_cast<sal_Int16>(m_xMtrAngle->get_value(FieldUnit::NONE) * 10)), // should be changed in resource static_cast<sal_uInt16>(m_xMtrCenterX->get_value(FieldUnit::NONE)), @@ -301,19 +306,16 @@ void SvxGradientTabPage::ModifiedHdl_Impl( void const * pControl ) static_cast<sal_uInt16>(m_xMtrBorder->get_value(FieldUnit::NONE)), static_cast<sal_uInt16>(m_xMtrColorFrom->get_value(FieldUnit::NONE)), static_cast<sal_uInt16>(m_xMtrColorTo->get_value(FieldUnit::NONE)), - static_cast<sal_uInt16>(m_xMtrIncrement->get_value()) ); + nValue); // enable/disable controls if (pControl == m_xLbGradientType.get() || pControl == this) SetControlState_Impl( eXGS ); - sal_uInt16 nValue = 0; - if (!m_xCbIncrement->get_active()) - nValue = static_cast<sal_uInt16>(m_xMtrIncrement->get_value()); m_rXFSet.Put( XGradientStepCountItem( nValue ) ); // displaying in XOutDev - m_rXFSet.Put( XFillGradientItem( OUString(), aXGradient ) ); + m_rXFSet.Put( XFillGradientItem( OUString(), aBGradient ) ); m_aCtlPreview.SetAttributes(m_aXFillAttr.GetItemSet()); m_aCtlPreview.Invalidate(); } @@ -321,7 +323,7 @@ void SvxGradientTabPage::ModifiedHdl_Impl( void const * pControl ) IMPL_LINK_NOARG(SvxGradientTabPage, ClickAddHdl_Impl, weld::Button&, void) { OUString aNewName( SvxResId( RID_SVXSTR_GRADIENT ) ); - OUString aDesc( CuiResId( RID_SVXSTR_DESC_GRADIENT ) ); + OUString aDesc( CuiResId( RID_CUISTR_DESC_GRADIENT ) ); OUString aName; tools::Long nCount = m_pGradientList->Count(); @@ -340,7 +342,7 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickAddHdl_Impl, weld::Button&, void) while (pDlg->Execute() == RET_OK) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); bValidGradientName = (SearchGradientList(aName) == -1); @@ -359,8 +361,11 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickAddHdl_Impl, weld::Button&, void) if( !nError ) { - XGradient aXGradient( m_xLbColorFrom->GetSelectEntryColor(), - m_xLbColorTo->GetSelectEntryColor(), + sal_uInt16 nValue = 0; // automatic step count + if (!m_xCbIncrement->get_active()) + nValue = m_xMtrIncrement->get_value(); + basegfx::BGradient aBGradient( + createColorStops(), static_cast<css::awt::GradientStyle>(m_xLbGradientType->get_active()), Degree10(static_cast<sal_Int16>(m_xMtrAngle->get_value(FieldUnit::NONE) * 10)), // should be changed in resource static_cast<sal_uInt16>(m_xMtrCenterX->get_value(FieldUnit::NONE)), @@ -368,9 +373,9 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickAddHdl_Impl, weld::Button&, void) static_cast<sal_uInt16>(m_xMtrBorder->get_value(FieldUnit::NONE)), static_cast<sal_uInt16>(m_xMtrColorFrom->get_value(FieldUnit::NONE)), static_cast<sal_uInt16>(m_xMtrColorTo->get_value(FieldUnit::NONE)), - static_cast<sal_uInt16>(m_xMtrIncrement->get_value()) ); + nValue); - m_pGradientList->Insert(std::make_unique<XGradientEntry>(aXGradient, aName), nCount); + m_pGradientList->Insert(std::make_unique<XGradientEntry>(aBGradient, aName), nCount); sal_Int32 nId = m_xGradientLB->GetItemId(nCount - 1); //calculate the last ID BitmapEx aBitmap = m_pGradientList->GetBitmapForPreview( nCount, m_xGradientLB->GetIconSize() ); @@ -399,8 +404,12 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickModifyHdl_Impl, weld::Button&, void) OUString aName( m_pGradientList->GetGradient( static_cast<sal_uInt16>(nPos) )->GetName() ); - XGradient aXGradient( m_xLbColorFrom->GetSelectEntryColor(), - m_xLbColorTo->GetSelectEntryColor(), + sal_uInt16 nValue = 0; // automatic step count + if (!m_xCbIncrement->get_active()) + nValue = m_xMtrIncrement->get_value(); + + basegfx::BGradient aBGradient( + createColorStops(), static_cast<css::awt::GradientStyle>(m_xLbGradientType->get_active()), Degree10(static_cast<sal_Int16>(m_xMtrAngle->get_value(FieldUnit::NONE) * 10)), // should be changed in resource static_cast<sal_uInt16>(m_xMtrCenterX->get_value(FieldUnit::NONE)), @@ -408,9 +417,9 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickModifyHdl_Impl, weld::Button&, void) static_cast<sal_uInt16>(m_xMtrBorder->get_value(FieldUnit::NONE)), static_cast<sal_uInt16>(m_xMtrColorFrom->get_value(FieldUnit::NONE)), static_cast<sal_uInt16>(m_xMtrColorTo->get_value(FieldUnit::NONE)), - static_cast<sal_uInt16>(m_xMtrIncrement->get_value()) ); + nValue); - m_pGradientList->Replace(std::make_unique<XGradientEntry>(aXGradient, aName), nPos); + m_pGradientList->Replace(std::make_unique<XGradientEntry>(aBGradient, aName), nPos); BitmapEx aBitmap = m_pGradientList->GetBitmapForPreview( static_cast<sal_uInt16>(nPos), m_xGradientLB->GetIconSize() ); m_xGradientLB->RemoveItem( nId ); @@ -457,7 +466,7 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickRenameHdl_Impl, SvxPresetListBox*, void if ( nPos == VALUESET_ITEM_NOTFOUND ) return; - OUString aDesc( CuiResId( RID_SVXSTR_DESC_GRADIENT ) ); + OUString aDesc( CuiResId( RID_CUISTR_DESC_GRADIENT ) ); OUString aName( m_pGradientList->GetGradient( nPos )->GetName() ); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); @@ -466,7 +475,7 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickRenameHdl_Impl, SvxPresetListBox*, void bool bLoop = true; while( bLoop && pDlg->Execute() == RET_OK ) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); sal_Int32 nGradientPos = SearchGradientList(aName); bool bValidGradientName = (nGradientPos == static_cast<sal_Int32>(nPos) ) || (nGradientPos == -1); @@ -496,20 +505,20 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ChangeGradientHdl, ValueSet*, void) void SvxGradientTabPage::ChangeGradientHdl_Impl() { - std::unique_ptr<XGradient> pGradient; + std::unique_ptr<basegfx::BGradient> pGradient; size_t nPos = m_xGradientLB->GetSelectItemPos(); if( nPos != VALUESET_ITEM_NOTFOUND ) - pGradient.reset(new XGradient( m_pGradientList->GetGradient( static_cast<sal_uInt16>( nPos ) )->GetGradient() )); + pGradient.reset(new basegfx::BGradient( m_pGradientList->GetGradient( static_cast<sal_uInt16>( nPos ) )->GetGradient() )); else { - const SfxPoolItem* pPoolItem = nullptr; - if( SfxItemState::SET == m_rOutAttrs.GetItemState( GetWhich( XATTR_FILLSTYLE ), true, &pPoolItem ) ) + if( const XFillStyleItem* pFillStyleItem = m_rOutAttrs.GetItemIfSet( GetWhich( XATTR_FILLSTYLE ) ) ) { - if( ( drawing::FillStyle_GRADIENT == static_cast<const XFillStyleItem*>( pPoolItem )->GetValue() ) && - ( SfxItemState::SET == m_rOutAttrs.GetItemState( GetWhich( XATTR_FILLGRADIENT ), true, &pPoolItem ) ) ) + const XFillGradientItem* pGradientItem; + if( ( drawing::FillStyle_GRADIENT == pFillStyleItem->GetValue() ) && + ( pGradientItem = m_rOutAttrs.GetItemIfSet( GetWhich( XATTR_FILLGRADIENT ) ) ) ) { - pGradient.reset(new XGradient( static_cast<const XFillGradientItem*>( pPoolItem )->GetGradientValue() )); + pGradient.reset(new basegfx::BGradient( pGradientItem->GetGradientValue() )); } } if( !pGradient ) @@ -517,7 +526,7 @@ void SvxGradientTabPage::ChangeGradientHdl_Impl() sal_uInt16 nPosition = m_xGradientLB->GetItemId(0); m_xGradientLB->SelectItem( nPosition ); if( nPosition != 0 ) - pGradient.reset(new XGradient( m_pGradientList->GetGradient( 0 )->GetGradient() )); + pGradient.reset(new basegfx::BGradient( m_pGradientList->GetGradient( 0 )->GetGradient() )); } } @@ -526,6 +535,10 @@ void SvxGradientTabPage::ChangeGradientHdl_Impl() css::awt::GradientStyle eXGS = pGradient->GetGradientStyle(); sal_uInt16 nValue = pGradient->GetSteps(); + if (const XGradientStepCountItem* pGradientStepCountItem = m_rOutAttrs.GetItemIfSet(GetWhich(XATTR_GRADIENTSTEPCOUNT))) + { + nValue = pGradientStepCountItem->GetValue(); + } if( nValue == 0 ) { m_xCbIncrement->set_state(TRISTATE_TRUE); @@ -542,10 +555,17 @@ void SvxGradientTabPage::ChangeGradientHdl_Impl() // if the entry is not in the listbox, // colors are added temporarily m_xLbColorFrom->SetNoSelection(); - m_xLbColorFrom->SelectEntry( pGradient->GetStartColor() ); + m_xLbColorFrom->SelectEntry(Color(pGradient->GetColorStops().front().getStopColor())); m_xLbColorTo->SetNoSelection(); - m_xLbColorTo->SelectEntry( pGradient->GetEndColor() ); + m_xLbColorTo->SelectEntry(Color(pGradient->GetColorStops().back().getStopColor())); + + // MCGR: preserve ColorStops if given. + // tdf#155901 We need offset of first and last stop, so include them. + if (pGradient->GetColorStops().size() >= 2) + m_aColorStops = pGradient->GetColorStops(); + else + m_aColorStops.clear(); m_xMtrAngle->set_value(pGradient->GetAngle().get() / 10, FieldUnit::NONE); // should be changed in resource m_xSliderAngle->set_value(pGradient->GetAngle().get() / 10); @@ -630,4 +650,25 @@ sal_Int32 SvxGradientTabPage::SearchGradientList(std::u16string_view rGradientNa return nPos; } +basegfx::BColorStops SvxGradientTabPage::createColorStops() +{ + basegfx::BColorStops aColorStops; + + if(m_aColorStops.size() >= 2) + { + aColorStops = m_aColorStops; + aColorStops.front() = basegfx::BColorStop(m_aColorStops.front().getStopOffset(), + m_xLbColorFrom->GetSelectEntryColor().getBColor()); + aColorStops.back() = basegfx::BColorStop(m_aColorStops.back().getStopOffset(), + m_xLbColorTo->GetSelectEntryColor().getBColor()); + } + else + { + aColorStops.emplace_back(0.0, m_xLbColorFrom->GetSelectEntryColor().getBColor()); + aColorStops.emplace_back(1.0, m_xLbColorTo->GetSelectEntryColor().getBColor()); + } + + return aColorStops; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/tabpages/tphatch.cxx b/cui/source/tabpages/tphatch.cxx index 2b9bb9401482..ccfc12a7b445 100644 --- a/cui/source/tabpages/tphatch.cxx +++ b/cui/source/tabpages/tphatch.cxx @@ -149,7 +149,7 @@ void SvxHatchTabPage::ActivatePage( const SfxItemSet& rSet ) // determining (possibly cutting) the name // and displaying it in the GroupBox - OUString aString = CuiResId( RID_SVXSTR_TABLE ) + ": "; + OUString aString = CuiResId( RID_CUISTR_TABLE ) + ": "; INetURLObject aURL( m_pHatchingList->GetPath() ); aURL.Append( m_pHatchingList->GetName() ); @@ -245,7 +245,7 @@ bool SvxHatchTabPage::FillItemSet( SfxItemSet* rSet ) if (m_xCbBackgroundColor->get_active()) { NamedColor aColor = m_xLbBackgroundColor->GetSelectedEntry(); - rSet->Put(XFillColorItem(aColor.second, aColor.first)); + rSet->Put(XFillColorItem(aColor.m_aName, aColor.m_aColor)); } return true; } @@ -358,13 +358,13 @@ void SvxHatchTabPage::ChangeHatchHdl_Impl() pHatch.reset(new XHatch( m_pHatchingList->GetHatch( static_cast<sal_uInt16>(nPos) )->GetHatch() )); else { - const SfxPoolItem* pPoolItem = nullptr; - if( SfxItemState::SET == m_rOutAttrs.GetItemState( GetWhich( XATTR_FILLSTYLE ), true, &pPoolItem ) ) + if( const XFillStyleItem* pFillStyleItem = m_rOutAttrs.GetItemIfSet( GetWhich( XATTR_FILLSTYLE ) ) ) { - if( ( drawing::FillStyle_HATCH == static_cast<const XFillStyleItem*>( pPoolItem )->GetValue() ) && - ( SfxItemState::SET == m_rOutAttrs.GetItemState( GetWhich( XATTR_FILLHATCH ), true, &pPoolItem ) ) ) + const XFillHatchItem* pFillHatchItem; + if( ( drawing::FillStyle_HATCH == pFillStyleItem->GetValue() ) && + ( pFillHatchItem = m_rOutAttrs.GetItemIfSet( GetWhich( XATTR_FILLHATCH ) ) ) ) { - pHatch.reset(new XHatch( static_cast<const XFillHatchItem*>( pPoolItem )->GetHatchValue() )); + pHatch.reset(new XHatch( pFillHatchItem->GetHatchValue() )); } } if( !pHatch ) @@ -403,7 +403,7 @@ void SvxHatchTabPage::ChangeHatchHdl_Impl() IMPL_LINK_NOARG(SvxHatchTabPage, ClickAddHdl_Impl, weld::Button&, void) { OUString aNewName( SvxResId( RID_SVXSTR_HATCH ) ); - OUString aDesc( CuiResId( RID_SVXSTR_DESC_HATCH ) ); + OUString aDesc( CuiResId( RID_CUISTR_DESC_HATCH ) ); OUString aName; tools::Long nCount = m_pHatchingList->Count(); @@ -422,7 +422,7 @@ IMPL_LINK_NOARG(SvxHatchTabPage, ClickAddHdl_Impl, weld::Button&, void) while( pDlg->Execute() == RET_OK ) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); bValidHatchName = (SearchHatchList(aName) == -1); if( bValidHatchName ) @@ -526,7 +526,7 @@ IMPL_LINK_NOARG(SvxHatchTabPage, ClickRenameHdl_Impl, SvxPresetListBox*, void ) if( nPos == VALUESET_ITEM_NOTFOUND ) return; - OUString aDesc( CuiResId( RID_SVXSTR_DESC_HATCH ) ); + OUString aDesc( CuiResId( RID_CUISTR_DESC_HATCH ) ); OUString aName( m_pHatchingList->GetHatch( nPos )->GetName() ); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); @@ -535,7 +535,7 @@ IMPL_LINK_NOARG(SvxHatchTabPage, ClickRenameHdl_Impl, SvxPresetListBox*, void ) bool bLoop = true; while( bLoop && pDlg->Execute() == RET_OK ) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); sal_Int32 nHatchPos = SearchHatchList( aName ); bool bValidHatchName = (nHatchPos == static_cast<sal_Int32>(nPos) ) || (nHatchPos == -1); diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx index e93b7bfa6310..1c1635293823 100644 --- a/cui/source/tabpages/tpline.cxx +++ b/cui/source/tabpages/tpline.cxx @@ -242,7 +242,7 @@ void SvxLineTabPage::FillListboxes() void SvxLineTabPage::ActivatePage( const SfxItemSet& rSet ) { - const CntUInt16Item* pPageTypeItem = rSet.GetItem<CntUInt16Item>(SID_PAGE_TYPE, false); + const SfxUInt16Item* pPageTypeItem = rSet.GetItem<SfxUInt16Item>(SID_PAGE_TYPE, false); if (pPageTypeItem) SetPageType(static_cast<PageType>(pPageTypeItem->GetValue())); if( m_nDlgType == 0 && m_pDashList.is() ) @@ -413,7 +413,7 @@ bool SvxLineTabPage::FillItemSet( SfxItemSet* rAttrs ) pOld = GetOldItem( *rAttrs, XATTR_LINESTYLE ); if ( !pOld || !( *static_cast<const XLineStyleItem*>(pOld) == *pStyleItem ) ) { - rAttrs->Put( *pStyleItem ); + rAttrs->Put( std::move(pStyleItem) ); bModified = true; } } @@ -456,8 +456,10 @@ bool SvxLineTabPage::FillItemSet( SfxItemSet* rAttrs ) // Line color if (m_xLbColor->IsValueChangedFromSaved()) { - NamedColor aColor = m_xLbColor->GetSelectedEntry(); - XLineColorItem aItem(aColor.second, aColor.first); + NamedColor aNamedColor = m_xLbColor->GetSelectedEntry(); + XLineColorItem aItem(aNamedColor.m_aName, aNamedColor.m_aColor); + aItem.setComplexColor(aNamedColor.getComplexColor()); + pOld = GetOldItem( *rAttrs, XATTR_LINECOLOR ); if ( !pOld || !( *static_cast<const XLineColorItem*>(pOld) == aItem ) ) { @@ -480,7 +482,7 @@ bool SvxLineTabPage::FillItemSet( SfxItemSet* rAttrs ) pOld = GetOldItem( *rAttrs, XATTR_LINESTART ); if( pItem && ( !pOld || *pOld != *pItem ) ) { - rAttrs->Put( *pItem ); + rAttrs->Put( std::move(pItem) ); bModified = true; } } @@ -497,7 +499,7 @@ bool SvxLineTabPage::FillItemSet( SfxItemSet* rAttrs ) if( pItem && ( !pOld || !( *static_cast<const XLineEndItem*>(pOld) == *pItem ) ) ) { - rAttrs->Put( *pItem ); + rAttrs->Put( std::move(pItem) ); bModified = true; } } @@ -575,7 +577,7 @@ bool SvxLineTabPage::FillItemSet( SfxItemSet* rAttrs ) if(!pOld || !(*static_cast<const XLineJointItem*>(pOld) == *pNew)) { - rAttrs->Put( *pNew ); + rAttrs->Put( std::move(pNew) ); bModified = true; } } @@ -612,7 +614,7 @@ bool SvxLineTabPage::FillItemSet( SfxItemSet* rAttrs ) if(!pOld || !(*static_cast<const XLineCapItem*>(pOld) == *pNew)) { - rAttrs->Put( *pNew ); + rAttrs->Put( std::move(pNew) ); bModified = true; } } @@ -621,8 +623,8 @@ bool SvxLineTabPage::FillItemSet( SfxItemSet* rAttrs ) if(m_nSymbolType!=SVX_SYMBOLTYPE_UNKNOWN || m_bNewSize) { // Was set by selection or the size is different - SvxSizeItem aSItem(rAttrs->GetPool()->GetWhich(SID_ATTR_SYMBOLSIZE),m_aSymbolSize); - const SfxPoolItem* pSOld = GetOldItem( *rAttrs, rAttrs->GetPool()->GetWhich(SID_ATTR_SYMBOLSIZE) ); + SvxSizeItem aSItem(rAttrs->GetPool()->GetWhichIDFromSlotID(SID_ATTR_SYMBOLSIZE),m_aSymbolSize); + const SfxPoolItem* pSOld = GetOldItem( *rAttrs, rAttrs->GetPool()->GetWhichIDFromSlotID(SID_ATTR_SYMBOLSIZE) ); m_bNewSize = pSOld ? *static_cast<const SvxSizeItem *>(pSOld) != aSItem : m_bNewSize ; if(m_bNewSize) { @@ -630,8 +632,8 @@ bool SvxLineTabPage::FillItemSet( SfxItemSet* rAttrs ) bModified=true; } - SfxInt32Item aTItem(rAttrs->GetPool()->GetWhich(SID_ATTR_SYMBOLTYPE),m_nSymbolType); - const SfxPoolItem* pTOld = GetOldItem( *rAttrs, rAttrs->GetPool()->GetWhich(SID_ATTR_SYMBOLTYPE) ); + SfxInt32Item aTItem(rAttrs->GetPool()->GetWhichIDFromSlotID(SID_ATTR_SYMBOLTYPE),m_nSymbolType); + const SfxPoolItem* pTOld = GetOldItem( *rAttrs, rAttrs->GetPool()->GetWhichIDFromSlotID(SID_ATTR_SYMBOLTYPE) ); bool bNewType = pTOld == nullptr || *static_cast<const SfxInt32Item*>(pTOld) != aTItem; if(bNewType && m_nSymbolType==SVX_SYMBOLTYPE_UNKNOWN) bNewType=false; // a small fix, type wasn't set -> don't create a type item after all! @@ -643,8 +645,8 @@ bool SvxLineTabPage::FillItemSet( SfxItemSet* rAttrs ) if(m_nSymbolType!=SVX_SYMBOLTYPE_NONE) { - SvxBrushItem aBItem(m_aSymbolGraphic,GPOS_MM,rAttrs->GetPool()->GetWhich(SID_ATTR_BRUSH)); - const SfxPoolItem* pBOld = GetOldItem( *rAttrs, rAttrs->GetPool()->GetWhich(SID_ATTR_BRUSH) ); + SvxBrushItem aBItem(m_aSymbolGraphic,GPOS_MM,rAttrs->GetPool()->GetWhichIDFromSlotID(SID_ATTR_BRUSH)); + const SfxPoolItem* pBOld = GetOldItem( *rAttrs, rAttrs->GetPool()->GetWhichIDFromSlotID(SID_ATTR_BRUSH) ); bool bNewBrush = pBOld == nullptr || *static_cast<const SvxBrushItem*>(pBOld) != aBItem; if(bNewBrush) @@ -758,8 +760,10 @@ void SvxLineTabPage::FillXLSet_Impl() m_rXLSet.Put( XLineEndWidthItem( GetCoreValue( *m_xMtrEndWidth, m_ePoolUnit ) ) ); m_rXLSet.Put( XLineWidthItem( GetCoreValue( *m_xMtrLineWidth, m_ePoolUnit ) ) ); - NamedColor aColor = m_xLbColor->GetSelectedEntry(); - m_rXLSet.Put(XLineColorItem(aColor.second, aColor.first)); + NamedColor aNamedColor = m_xLbColor->GetSelectedEntry(); + XLineColorItem aLineColor(aNamedColor.m_aName, aNamedColor.m_aColor); + aLineColor.setComplexColor(aNamedColor.getComplexColor()); + m_rXLSet.Put(aLineColor); // Centered line end if( m_xTsbCenterStart->get_state() == TRISTATE_TRUE ) @@ -785,15 +789,14 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) drawing::LineStyle eXLS; // drawing::LineStyle_NONE, drawing::LineStyle_SOLID, drawing::LineStyle_DASH // Line style - const SfxPoolItem *pPoolItem; tools::Long nSymType=SVX_SYMBOLTYPE_UNKNOWN; bool bPrevSym=false; bool bEnable=true; bool bIgnoreGraphic=false; bool bIgnoreSize=false; - if(rAttrs->GetItemState(rAttrs->GetPool()->GetWhich(SID_ATTR_SYMBOLTYPE),true,&pPoolItem) == SfxItemState::SET) + if(const SfxInt32Item* pSymbolTypeItem = rAttrs->GetItemIfSet(rAttrs->GetPool()->GetWhichIDFromSlotID(SID_ATTR_SYMBOLTYPE))) { - nSymType=static_cast<const SfxInt32Item *>(pPoolItem)->GetValue(); + nSymType = pSymbolTypeItem->GetValue(); } if(nSymType == SVX_SYMBOLTYPE_AUTO) @@ -815,7 +818,6 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) std::unique_ptr<SdrModel> pModel( new SdrModel(nullptr, nullptr, true)); - pModel->GetItemPool().FreezeIdRanges(); rtl::Reference<SdrPage> pPage = new SdrPage( *pModel, false ); pPage->SetSize(Size(1000,1000)); pModel->InsertPage( pPage.get(), 0 ); @@ -829,7 +831,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) if(m_pSymbolList->GetObjCount()) { nSymTmp %= m_pSymbolList->GetObjCount(); // Treat list as cyclic! - SdrObject *pObj=m_pSymbolList->GetObj(nSymTmp); + rtl::Reference<SdrObject> pObj=m_pSymbolList->GetObj(nSymTmp); if(pObj) { // directly clone to target SdrModel @@ -844,16 +846,16 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) pObj->SetMergedItemSet(m_rOutAttrs); } - pPage->NbcInsertObject(pObj); + pPage->NbcInsertObject(pObj.get()); // Generate invisible square to give all symbol types a // bitmap size, which is independent from specific glyph - SdrObject* pInvisibleSquare(m_pSymbolList->GetObj(0)); + rtl::Reference<SdrObject> pInvisibleSquare(m_pSymbolList->GetObj(0)); // directly clone to target SdrModel pInvisibleSquare = pInvisibleSquare->CloneSdrObject(*pModel); - pPage->NbcInsertObject(pInvisibleSquare); + pPage->NbcInsertObject(pInvisibleSquare.get()); pInvisibleSquare->SetMergedItem(XFillTransparenceItem(100)); pInvisibleSquare->SetMergedItem(XLineTransparenceItem(100)); @@ -869,18 +871,18 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) bIgnoreGraphic=true; aView.UnmarkAll(); - pInvisibleSquare=pPage->RemoveObject(1); - SdrObject::Free( pInvisibleSquare); - pObj=pPage->RemoveObject(0); - SdrObject::Free( pObj ); + pPage->RemoveObject(1); + pInvisibleSquare.clear(); + pPage->RemoveObject(0); + pObj.clear(); } } } } } - if(rAttrs->GetItemState(rAttrs->GetPool()->GetWhich(SID_ATTR_BRUSH),true,&pPoolItem) == SfxItemState::SET) + if(const SvxBrushItem* pBrushItem = rAttrs->GetItemIfSet(rAttrs->GetPool()->GetWhichIDFromSlotID(SID_ATTR_BRUSH))) { - const Graphic* pGraphic = static_cast<const SvxBrushItem *>(pPoolItem)->GetGraphic(); + const Graphic* pGraphic = pBrushItem->GetGraphic(); if( pGraphic ) { if(!bIgnoreGraphic) @@ -897,9 +899,9 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) } } - if(rAttrs->GetItemState(rAttrs->GetPool()->GetWhich(SID_ATTR_SYMBOLSIZE),true,&pPoolItem) == SfxItemState::SET) + if(const SvxSizeItem* pSymbolSizeItem = rAttrs->GetItemIfSet(rAttrs->GetPool()->GetWhichIDFromSlotID(SID_ATTR_SYMBOLSIZE))) { - m_aSymbolSize = static_cast<const SvxSizeItem *>(pPoolItem)->GetSize(); + m_aSymbolSize = pSymbolSizeItem->GetSize(); } m_xGridIconSize->set_sensitive(bEnable); @@ -912,7 +914,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) m_aSymbolLastSize=m_aSymbolSize; } - if( rAttrs->GetItemState( XATTR_LINESTYLE ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( XATTR_LINESTYLE ) != SfxItemState::INVALID ) { eXLS = rAttrs->Get( XATTR_LINESTYLE ).GetValue(); @@ -940,7 +942,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) } // Line strength - if( rAttrs->GetItemState( XATTR_LINEWIDTH ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( XATTR_LINEWIDTH ) != SfxItemState::INVALID ) { SetMetricValue( *m_xMtrLineWidth, rAttrs->Get( XATTR_LINEWIDTH ).GetValue(), m_ePoolUnit ); } @@ -950,7 +952,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) // Line color m_xLbColor->SetNoSelection(); - if ( rAttrs->GetItemState( XATTR_LINECOLOR ) != SfxItemState::DONTCARE ) + if ( rAttrs->GetItemState( XATTR_LINECOLOR ) != SfxItemState::INVALID ) { Color aCol = rAttrs->Get( XATTR_LINECOLOR ).GetColorValue(); m_xLbColor->SelectEntry( aCol ); @@ -961,7 +963,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) { m_xLbStartStyle->set_sensitive(false); } - else if( rAttrs->GetItemState( XATTR_LINESTART ) != SfxItemState::DONTCARE ) + else if( rAttrs->GetItemState( XATTR_LINESTART ) != SfxItemState::INVALID ) { // #86265# select entry using list and polygon, not string bool bSelected(false); @@ -993,7 +995,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) { m_xLbEndStyle->set_sensitive(false); } - else if( rAttrs->GetItemState( XATTR_LINEEND ) != SfxItemState::DONTCARE ) + else if( rAttrs->GetItemState( XATTR_LINEEND ) != SfxItemState::INVALID ) { // #86265# select entry using list and polygon, not string bool bSelected(false); @@ -1025,7 +1027,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) { m_xMtrStartWidth->set_sensitive(false); } - else if( rAttrs->GetItemState( XATTR_LINESTARTWIDTH ) != SfxItemState::DONTCARE ) + else if( rAttrs->GetItemState( XATTR_LINESTARTWIDTH ) != SfxItemState::INVALID ) { SetMetricValue( *m_xMtrStartWidth, rAttrs->Get( XATTR_LINESTARTWIDTH ).GetValue(), @@ -1039,7 +1041,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) { m_xMtrEndWidth->set_sensitive(false); } - else if( rAttrs->GetItemState( XATTR_LINEENDWIDTH ) != SfxItemState::DONTCARE ) + else if( rAttrs->GetItemState( XATTR_LINEENDWIDTH ) != SfxItemState::INVALID ) { SetMetricValue( *m_xMtrEndWidth, rAttrs->Get( XATTR_LINEENDWIDTH ).GetValue(), @@ -1053,7 +1055,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) { m_xTsbCenterStart->set_sensitive(false); } - else if( rAttrs->GetItemState( XATTR_LINESTARTCENTER ) != SfxItemState::DONTCARE ) + else if( rAttrs->GetItemState( XATTR_LINESTARTCENTER ) != SfxItemState::INVALID ) { if( rAttrs->Get( XATTR_LINESTARTCENTER ).GetValue() ) m_xTsbCenterStart->set_state(TRISTATE_TRUE); @@ -1070,7 +1072,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) { m_xTsbCenterEnd->set_sensitive(false); } - else if( rAttrs->GetItemState( XATTR_LINEENDCENTER ) != SfxItemState::DONTCARE ) + else if( rAttrs->GetItemState( XATTR_LINEENDCENTER ) != SfxItemState::INVALID ) { if( rAttrs->Get( XATTR_LINEENDCENTER ).GetValue() ) m_xTsbCenterEnd->set_state(TRISTATE_TRUE); @@ -1083,7 +1085,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) } // Transparency - if( rAttrs->GetItemState( XATTR_LINETRANSPARENCE ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( XATTR_LINETRANSPARENCE ) != SfxItemState::INVALID ) { sal_uInt16 nTransp = rAttrs->Get( XATTR_LINETRANSPARENCE ).GetValue(); m_xMtrTransparent->set_value(nTransp, FieldUnit::PERCENT); @@ -1113,7 +1115,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) // maFTEdgeStyle.set_sensitive(false); m_xLBEdgeStyle->set_sensitive(false); } - else if(SfxItemState::DONTCARE != rAttrs->GetItemState(XATTR_LINEJOINT)) + else if(SfxItemState::INVALID != rAttrs->GetItemState(XATTR_LINEJOINT)) { const css::drawing::LineJoint eLineJoint = rAttrs->Get(XATTR_LINEJOINT).GetValue(); @@ -1137,7 +1139,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs ) { m_xLBCapStyle->set_sensitive(false); } - else if(SfxItemState::DONTCARE != rAttrs->GetItemState(XATTR_LINECAP)) + else if(SfxItemState::INVALID != rAttrs->GetItemState(XATTR_LINECAP)) { const css::drawing::LineCap eLineCap(rAttrs->Get(XATTR_LINECAP).GetValue()); @@ -1443,7 +1445,6 @@ IMPL_LINK_NOARG(SvxLineTabPage, MenuCreateHdl_Impl, weld::Toggleable&, void) pVDev->SetMapMode(MapMode(MapUnit::Map100thMM)); std::unique_ptr<SdrModel> pModel( new SdrModel(nullptr, nullptr, true)); - pModel->GetItemPool().FreezeIdRanges(); // Page rtl::Reference<SdrPage> pPage = new SdrPage( *pModel, false ); pPage->SetSize(Size(1000,1000)); @@ -1456,25 +1457,25 @@ IMPL_LINK_NOARG(SvxLineTabPage, MenuCreateHdl_Impl, weld::Toggleable&, void) // Generate invisible square to give all symbols a // bitmap size, which is independent from specific glyph - SdrObject *pInvisibleSquare=m_pSymbolList->GetObj(0); + rtl::Reference<SdrObject> pInvisibleSquare=m_pSymbolList->GetObj(0); // directly clone to target SdrModel pInvisibleSquare = pInvisibleSquare->CloneSdrObject(*pModel); - pPage->NbcInsertObject(pInvisibleSquare); + pPage->NbcInsertObject(pInvisibleSquare.get()); pInvisibleSquare->SetMergedItem(XFillTransparenceItem(100)); pInvisibleSquare->SetMergedItem(XLineTransparenceItem(100)); for(size_t i=0; i < m_pSymbolList->GetObjCount(); ++i) { - SdrObject *pObj=m_pSymbolList->GetObj(i); + rtl::Reference<SdrObject> pObj=m_pSymbolList->GetObj(i); assert(pObj); // directly clone to target SdrModel pObj = pObj->CloneSdrObject(*pModel); m_aGrfNames.emplace_back(""); - pPage->NbcInsertObject(pObj); + pPage->NbcInsertObject(pObj.get()); if(m_xSymbolAttr) { pObj->SetMergedItemSet(*m_xSymbolAttr); @@ -1487,8 +1488,8 @@ IMPL_LINK_NOARG(SvxLineTabPage, MenuCreateHdl_Impl, weld::Toggleable&, void) BitmapEx aBitmapEx(aView.GetMarkedObjBitmapEx()); GDIMetaFile aMeta(aView.GetMarkedObjMetaFile()); aView.UnmarkAll(); - pObj=pPage->RemoveObject(1); - SdrObject::Free(pObj); + pPage->RemoveObject(1); + pObj.clear(); SvxBmpItemInfo* pInfo = new SvxBmpItemInfo; pInfo->pBrushItem.reset(new SvxBrushItem(Graphic(aMeta), GPOS_AREA, SID_ATTR_BRUSH)); @@ -1508,8 +1509,8 @@ IMPL_LINK_NOARG(SvxLineTabPage, MenuCreateHdl_Impl, weld::Toggleable&, void) pVD->DrawBitmapEx(Point(), aBitmapEx); m_xSymbolsMenu->append(pInfo->sItemId, "", *pVD); } - pInvisibleSquare=pPage->RemoveObject(0); - SdrObject::Free(pInvisibleSquare); + pPage->RemoveObject(0); + pInvisibleSquare.clear(); if (m_aGrfNames.empty()) m_xSymbolMB->set_item_sensitive("symbols", false); @@ -1518,7 +1519,7 @@ IMPL_LINK_NOARG(SvxLineTabPage, MenuCreateHdl_Impl, weld::Toggleable&, void) // #58425# Symbols on a list (e.g. StarChart) // Handler for menu button -IMPL_LINK(SvxLineTabPage, GraphicHdl_Impl, const OString&, rIdent, void) +IMPL_LINK(SvxLineTabPage, GraphicHdl_Impl, const OUString&, rIdent, void) { const Graphic* pGraphic = nullptr; Graphic aGraphic; @@ -1526,7 +1527,7 @@ IMPL_LINK(SvxLineTabPage, GraphicHdl_Impl, const OString&, rIdent, void) bool bEnable = true; tools::Long nPreviousSymbolType = m_nSymbolType; - OString sNumber; + OUString sNumber; if (rIdent.startsWith("gallery", &sNumber)) { SvxBmpItemInfo* pInfo = m_aGalleryBrushItems[sNumber.toUInt32()].get(); @@ -1553,7 +1554,7 @@ IMPL_LINK(SvxLineTabPage, GraphicHdl_Impl, const OString&, rIdent, void) } else if (rIdent == "file") { - SvxOpenGraphicDialog aGrfDlg(CuiResId(RID_SVXSTR_EDIT_GRAPHIC), GetFrameWeld()); + SvxOpenGraphicDialog aGrfDlg(CuiResId(RID_CUISTR_EDIT_GRAPHIC), GetFrameWeld()); aGrfDlg.EnableLink(false); aGrfDlg.AsLink(false); if( !aGrfDlg.Execute() ) diff --git a/cui/source/tabpages/tplnedef.cxx b/cui/source/tabpages/tplnedef.cxx index c895a6969c9b..c8c180b047e3 100644 --- a/cui/source/tabpages/tplnedef.cxx +++ b/cui/source/tabpages/tplnedef.cxx @@ -166,7 +166,7 @@ void SvxLineDefTabPage::ActivatePage( const SfxItemSet& ) // determining (and possibly cutting) the name // and displaying it in the GroupBox -// OUString aString( CuiResId( RID_SVXSTR_TABLE ) ); +// OUString aString( CuiResId( RID_CUISTR_TABLE ) ); // aString += ": "; INetURLObject aURL( pDashList->GetPath() ); @@ -203,10 +203,10 @@ void SvxLineDefTabPage::CheckChanges_Impl() { std::unique_ptr<weld::MessageDialog> xMessDlg(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Cancel, - CuiResId(RID_SVXSTR_ASK_CHANGE_LINESTYLE))); + CuiResId(RID_CUISTR_ASK_CHANGE_LINESTYLE))); xMessDlg->set_title(SvxResId(RID_SVXSTR_LINESTYLE)); - xMessDlg->add_button(CuiResId(RID_SVXSTR_CHANGE), RET_BTN_1); - xMessDlg->add_button(CuiResId(RID_SVXSTR_ADD), RET_BTN_2); + xMessDlg->add_button(CuiResId(RID_CUISTR_CHANGE), RET_BTN_1); + xMessDlg->add_button(CuiResId(RID_CUISTR_ADD), RET_BTN_2); short nRet = xMessDlg->run(); @@ -256,9 +256,9 @@ bool SvxLineDefTabPage::FillItemSet( SfxItemSet* rAttrs ) void SvxLineDefTabPage::Reset( const SfxItemSet* rAttrs ) { - if( rAttrs->GetItemState( GetWhich( XATTR_LINESTYLE ) ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( GetWhich( XATTR_LINESTYLE ) ) != SfxItemState::INVALID ) { - drawing::LineStyle eXLS = static_cast<const XLineStyleItem&>( rAttrs->Get( GetWhich( XATTR_LINESTYLE ) ) ).GetValue(); + drawing::LineStyle eXLS = rAttrs->Get( GetWhich( XATTR_LINESTYLE ) ).GetValue(); switch( eXLS ) { @@ -489,7 +489,7 @@ void SvxLineDefTabPage::SelectTypeHdl_Impl(const weld::ComboBox* p) IMPL_LINK_NOARG(SvxLineDefTabPage, ClickAddHdl_Impl, weld::Button&, void) { OUString aNewName(SvxResId(RID_SVXSTR_LINESTYLE)); - OUString aDesc(CuiResId(RID_SVXSTR_DESC_LINESTYLE)); + OUString aDesc(CuiResId(RID_CUISTR_DESC_LINESTYLE)); OUString aName; tools::Long nCount = pDashList->Count(); @@ -512,7 +512,7 @@ IMPL_LINK_NOARG(SvxLineDefTabPage, ClickAddHdl_Impl, weld::Button&, void) while ( bLoop && pDlg->Execute() == RET_OK ) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); bDifferent = true; for( tools::Long i = 0; i < nCount && bDifferent; i++ ) @@ -569,7 +569,7 @@ IMPL_LINK_NOARG(SvxLineDefTabPage, ClickModifyHdl_Impl, weld::Button&, void) if (nPos == -1) return; - OUString aDesc(CuiResId(RID_SVXSTR_DESC_LINESTYLE)); + OUString aDesc(CuiResId(RID_CUISTR_DESC_LINESTYLE)); OUString aName( pDashList->GetDash( nPos )->GetName() ); OUString aOldName = aName; @@ -581,7 +581,7 @@ IMPL_LINK_NOARG(SvxLineDefTabPage, ClickModifyHdl_Impl, weld::Button&, void) while ( bLoop && pDlg->Execute() == RET_OK ) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); bool bDifferent = true; for( tools::Long i = 0; i < nCount && bDifferent; i++ ) diff --git a/cui/source/tabpages/tplneend.cxx b/cui/source/tabpages/tplneend.cxx index d34b016fa7b0..2d181a3f5cb9 100644 --- a/cui/source/tabpages/tplneend.cxx +++ b/cui/source/tabpages/tplneend.cxx @@ -109,7 +109,7 @@ void SvxLineEndDefTabPage::Construct() { SdrObjTransformInfoRec aInfoRec; pPolyObj->TakeObjInfo( aInfoRec ); - SdrObjectUniquePtr pNewObj; + rtl::Reference<SdrObject> pNewObj; if( aInfoRec.bCanConvToPath ) pNewObj = pPolyObj->ConvertToPolyObj( true, false ); @@ -270,7 +270,7 @@ IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickModifyHdl_Impl, weld::Button&, void) if (nPos == -1) return; - OUString aDesc(CuiResId(RID_SVXSTR_DESC_LINEEND)); + OUString aDesc(CuiResId(RID_CUISTR_DESC_LINEEND)); OUString aName(m_xEdtName->get_text()); tools::Long nCount = pLineEndList->Count(); bool bDifferent = true; @@ -293,7 +293,7 @@ IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickModifyHdl_Impl, weld::Button&, void) while( !bDifferent && bLoop && pDlg->Execute() == RET_OK ) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); bDifferent = true; for( tools::Long i = 0; i < nCount && bDifferent; i++ ) @@ -341,7 +341,7 @@ IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickAddHdl_Impl, weld::Button&, void) if( pPolyObj ) { const SdrObject* pNewObj; - SdrObjectUniquePtr pConvPolyObj; + rtl::Reference<SdrObject> pConvPolyObj; if( nullptr != dynamic_cast<const SdrPathObj*>( pPolyObj) ) { @@ -370,10 +370,10 @@ IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickAddHdl_Impl, weld::Button&, void) // normalize aNewPolyPolygon.transform(basegfx::utils::createTranslateB2DHomMatrix( -aNewRange.getMinX(), -aNewRange.getMinY())); - pConvPolyObj.reset(); + pConvPolyObj.clear(); OUString aNewName(SvxResId(RID_SVXSTR_LINEEND)); - OUString aDesc(CuiResId(RID_SVXSTR_DESC_LINEEND)); + OUString aDesc(CuiResId(RID_CUISTR_DESC_LINEEND)); OUString aName; tools::Long nCount = pLineEndList->Count(); @@ -396,7 +396,7 @@ IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickAddHdl_Impl, weld::Button&, void) while ( bLoop && pDlg->Execute() == RET_OK ) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); bDifferent = true; for( tools::Long i = 0; i < nCount && bDifferent; i++ ) diff --git a/cui/source/tabpages/tppattern.cxx b/cui/source/tabpages/tppattern.cxx index 5fe830715b7f..9a37685951dd 100644 --- a/cui/source/tabpages/tppattern.cxx +++ b/cui/source/tabpages/tppattern.cxx @@ -147,7 +147,7 @@ void SvxPatternTabPage::ActivatePage( const SfxItemSet& rSet ) // determining (possibly cutting) the name and // displaying it in the GroupBox - OUString aString = CuiResId( RID_SVXSTR_TABLE ) + ": "; + OUString aString = CuiResId( RID_CUISTR_TABLE ) + ": "; INetURLObject aURL( m_pPatternList->GetPath() ); aURL.Append( m_pPatternList->GetName() ); @@ -253,15 +253,14 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ChangePatternHdl_Impl, ValueSet*, void) } else { - const SfxPoolItem* pPoolItem = nullptr; - - if(SfxItemState::SET == m_rOutAttrs.GetItemState(GetWhich(XATTR_FILLSTYLE), true, &pPoolItem)) + if(const XFillStyleItem* pFillStyleItem = m_rOutAttrs.GetItemIfSet(GetWhich(XATTR_FILLSTYLE))) { - const drawing::FillStyle eXFS(static_cast<const XFillStyleItem*>(pPoolItem)->GetValue()); + const drawing::FillStyle eXFS(pFillStyleItem->GetValue()); - if((drawing::FillStyle_BITMAP == eXFS) && (SfxItemState::SET == m_rOutAttrs.GetItemState(GetWhich(XATTR_FILLBITMAP), true, &pPoolItem))) + const XFillBitmapItem* pBitmapItem; + if((drawing::FillStyle_BITMAP == eXFS) && (pBitmapItem = m_rOutAttrs.GetItemIfSet(GetWhich(XATTR_FILLBITMAP)))) { - pGraphicObject.reset(new GraphicObject(static_cast<const XFillBitmapItem*>(pPoolItem)->GetGraphicObject())); + pGraphicObject.reset(new GraphicObject(pBitmapItem->GetGraphicObject())); } } @@ -323,7 +322,7 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickAddHdl_Impl, weld::Button&, void) { OUString aNewName( SvxResId( RID_SVXSTR_PATTERN_UNTITLED ) ); - OUString aDesc( CuiResId( RID_SVXSTR_DESC_NEW_PATTERN ) ); + OUString aDesc( CuiResId( RID_CUISTR_DESC_NEW_PATTERN ) ); OUString aName; tools::Long nCount = m_pPatternList->Count(); @@ -342,7 +341,7 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickAddHdl_Impl, weld::Button&, void) while( pDlg->Execute() == RET_OK ) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); bValidPatternName = (SearchPatternList(aName) == -1); @@ -370,12 +369,8 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickAddHdl_Impl, weld::Button&, void) } else // it must be a not existing imported bitmap { - const SfxPoolItem* pPoolItem = nullptr; - - if(SfxItemState::SET == m_rOutAttrs.GetItemState(XATTR_FILLBITMAP, true, &pPoolItem)) + if(const XFillBitmapItem* pFillBmpItem = m_rOutAttrs.GetItemIfSet(XATTR_FILLBITMAP)) { - auto pFillBmpItem = dynamic_cast<const XFillBitmapItem*>(pPoolItem); - assert(pFillBmpItem); pEntry.reset(new XBitmapEntry(pFillBmpItem->GetGraphicObject(), aName)); } else @@ -436,7 +431,7 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickRenameHdl_Impl, SvxPresetListBox*, void) if ( nPos == VALUESET_ITEM_NOTFOUND ) return; - OUString aDesc(CuiResId(RID_SVXSTR_DESC_NEW_PATTERN)); + OUString aDesc(CuiResId(RID_CUISTR_DESC_NEW_PATTERN)); OUString aName(m_pPatternList->GetBitmap(nPos)->GetName()); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); @@ -446,7 +441,7 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickRenameHdl_Impl, SvxPresetListBox*, void) while( bLoop && pDlg->Execute() == RET_OK ) { - pDlg->GetName( aName ); + aName = pDlg->GetName(); sal_Int32 nPatternPos = SearchPatternList(aName); bool bValidPatternName = (nPatternPos == static_cast<sal_Int32>(nPos) ) || (nPatternPos == -1); diff --git a/cui/source/tabpages/tpshadow.cxx b/cui/source/tabpages/tpshadow.cxx index 4a538968536b..ca2bc3b8a574 100644 --- a/cui/source/tabpages/tpshadow.cxx +++ b/cui/source/tabpages/tpshadow.cxx @@ -91,28 +91,27 @@ SvxShadowTabPage::SvxShadowTabPage(weld::Container* pPage, weld::DialogControlle // setting the output device drawing::FillStyle eXFS = drawing::FillStyle_SOLID; - if( m_rOutAttrs.GetItemState( XATTR_FILLSTYLE ) != SfxItemState::DONTCARE ) + if( m_rOutAttrs.GetItemState( XATTR_FILLSTYLE ) != SfxItemState::INVALID ) { - eXFS = static_cast<const XFillStyleItem&>( m_rOutAttrs. - Get( GetWhich( XATTR_FILLSTYLE ) ) ).GetValue(); + eXFS = m_rOutAttrs.Get( GetWhich( XATTR_FILLSTYLE ) ).GetValue(); switch( eXFS ) { case drawing::FillStyle_SOLID: - if( SfxItemState::DONTCARE != m_rOutAttrs.GetItemState( XATTR_FILLCOLOR ) ) + if( SfxItemState::INVALID != m_rOutAttrs.GetItemState( XATTR_FILLCOLOR ) ) { m_rXFSet.Put( m_rOutAttrs.Get( XATTR_FILLCOLOR ) ); } break; case drawing::FillStyle_GRADIENT: - if( SfxItemState::DONTCARE != m_rOutAttrs.GetItemState( XATTR_FILLGRADIENT ) ) + if( SfxItemState::INVALID != m_rOutAttrs.GetItemState( XATTR_FILLGRADIENT ) ) { m_rXFSet.Put( m_rOutAttrs.Get( XATTR_FILLGRADIENT ) ); } break; case drawing::FillStyle_HATCH: - if( SfxItemState::DONTCARE != m_rOutAttrs.GetItemState( XATTR_FILLHATCH ) ) + if( SfxItemState::INVALID != m_rOutAttrs.GetItemState( XATTR_FILLHATCH ) ) { m_rXFSet.Put( m_rOutAttrs.Get( XATTR_FILLHATCH ) ); } @@ -120,7 +119,7 @@ SvxShadowTabPage::SvxShadowTabPage(weld::Container* pPage, weld::DialogControlle case drawing::FillStyle_BITMAP: { - if( SfxItemState::DONTCARE != m_rOutAttrs.GetItemState( XATTR_FILLBITMAP ) ) + if( SfxItemState::INVALID != m_rOutAttrs.GetItemState( XATTR_FILLBITMAP ) ) { m_rXFSet.Put( m_rOutAttrs.Get( XATTR_FILLBITMAP ) ); } @@ -258,18 +257,18 @@ bool SvxShadowTabPage::FillItemSet( SfxItemSet* rAttrs ) case RectPoint::MM: break; } - // If the values of the shadow distances==SfxItemState::DONTCARE and the displayed + // If the values of the shadow distances==SfxItemState::INVALID and the displayed // string in the respective MetricField=="", then the comparison of the old // and the new distance values would return a wrong result because in such a // case the new distance values would match the default values of the MetricField !!!! if ( !m_xMtrDistance->get_text().isEmpty() || - m_rOutAttrs.GetItemState( SDRATTR_SHADOWXDIST ) != SfxItemState::DONTCARE || - m_rOutAttrs.GetItemState( SDRATTR_SHADOWYDIST ) != SfxItemState::DONTCARE ) + m_rOutAttrs.GetItemState( SDRATTR_SHADOWXDIST ) != SfxItemState::INVALID || + m_rOutAttrs.GetItemState( SDRATTR_SHADOWYDIST ) != SfxItemState::INVALID ) { sal_Int32 nOldX = 9876543; // impossible value, so DontCare sal_Int32 nOldY = 9876543; - if( m_rOutAttrs.GetItemState( SDRATTR_SHADOWXDIST ) != SfxItemState::DONTCARE && - m_rOutAttrs.GetItemState( SDRATTR_SHADOWYDIST ) != SfxItemState::DONTCARE ) + if( m_rOutAttrs.GetItemState( SDRATTR_SHADOWXDIST ) != SfxItemState::INVALID && + m_rOutAttrs.GetItemState( SDRATTR_SHADOWYDIST ) != SfxItemState::INVALID ) { nOldX = m_rOutAttrs.Get( SDRATTR_SHADOWXDIST ).GetValue(); nOldY = m_rOutAttrs.Get( SDRATTR_SHADOWYDIST ).GetValue(); @@ -339,7 +338,7 @@ void SvxShadowTabPage::Reset( const SfxItemSet* rAttrs ) // at the moment there are only 8 possible positions where a shadow can be set // has a shadow been set? - if( rAttrs->GetItemState( SDRATTR_SHADOW ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( SDRATTR_SHADOW ) != SfxItemState::INVALID ) { if( rAttrs->Get( SDRATTR_SHADOW ).GetValue() ) m_xTsbShowShadow->set_state(TRISTATE_TRUE); @@ -354,8 +353,8 @@ void SvxShadowTabPage::Reset( const SfxItemSet* rAttrs ) // distance (only 8 possible positions), // so there is only one item evaluated - if( rAttrs->GetItemState( SDRATTR_SHADOWXDIST ) != SfxItemState::DONTCARE && - rAttrs->GetItemState( SDRATTR_SHADOWYDIST ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( SDRATTR_SHADOWXDIST ) != SfxItemState::INVALID && + rAttrs->GetItemState( SDRATTR_SHADOWYDIST ) != SfxItemState::INVALID ) { sal_Int32 nX = rAttrs->Get( SDRATTR_SHADOWXDIST ).GetValue(); sal_Int32 nY = rAttrs->Get( SDRATTR_SHADOWYDIST ).GetValue(); @@ -382,9 +381,9 @@ void SvxShadowTabPage::Reset( const SfxItemSet* rAttrs ) // determine default-distance SfxItemPool* pPool = m_rOutAttrs.GetPool(); { - sal_Int32 n = pPool->GetDefaultItem(SDRATTR_SHADOWXDIST).GetValue(); + sal_Int32 n = pPool->GetUserOrPoolDefaultItem(SDRATTR_SHADOWXDIST).GetValue(); if (n == 0) - n = pPool->GetDefaultItem(SDRATTR_SHADOWYDIST).GetValue(); + n = pPool->GetUserOrPoolDefaultItem(SDRATTR_SHADOWYDIST).GetValue(); SetMetricValue(*m_xMtrDistance, std::abs(n), m_ePoolUnit); } @@ -395,14 +394,14 @@ void SvxShadowTabPage::Reset( const SfxItemSet* rAttrs ) m_aCtlPosition.SetActualRP( RectPoint::MM ); } - if( rAttrs->GetItemState( SDRATTR_SHADOWCOLOR ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( SDRATTR_SHADOWCOLOR ) != SfxItemState::INVALID ) { m_xLbShadowColor->SelectEntry( rAttrs->Get( SDRATTR_SHADOWCOLOR ).GetColorValue() ); } else m_xLbShadowColor->SetNoSelection(); - if( rAttrs->GetItemState( SDRATTR_SHADOWTRANSPARENCE ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( SDRATTR_SHADOWTRANSPARENCE ) != SfxItemState::INVALID ) { sal_uInt16 nTransp = rAttrs->Get( SDRATTR_SHADOWTRANSPARENCE ).GetValue(); m_xMtrTransparent->set_value(nTransp, FieldUnit::PERCENT); @@ -410,7 +409,7 @@ void SvxShadowTabPage::Reset( const SfxItemSet* rAttrs ) else m_xMtrTransparent->set_text(""); - if( rAttrs->GetItemState( SDRATTR_SHADOWBLUR ) != SfxItemState::DONTCARE ) + if( rAttrs->GetItemState( SDRATTR_SHADOWBLUR ) != SfxItemState::INVALID ) { sal_uInt16 nBlur = rAttrs->Get( SDRATTR_SHADOWBLUR ).GetValue(); m_xLbShadowBlurMetric->set_value(nBlur, FieldUnit::MM_100TH); diff --git a/cui/source/tabpages/tptrans.cxx b/cui/source/tabpages/tptrans.cxx index e78fcfffe16d..b2d6a10dea0a 100644 --- a/cui/source/tabpages/tptrans.cxx +++ b/cui/source/tabpages/tptrans.cxx @@ -119,11 +119,8 @@ void SvxTransparenceTabPage::ModifiedTrgrHdl_Impl(const weld::ComboBox* pControl } // preview - sal_uInt8 nStartCol = static_cast<sal_uInt8>((static_cast<sal_uInt16>(m_xMtrTrgrStartValue->get_value(FieldUnit::PERCENT)) * 255) / 100); - sal_uInt8 nEndCol = static_cast<sal_uInt8>((static_cast<sal_uInt16>(m_xMtrTrgrEndValue->get_value(FieldUnit::PERCENT)) * 255) / 100); - XGradient aTmpGradient( - Color(nStartCol, nStartCol, nStartCol), - Color(nEndCol, nEndCol, nEndCol), + basegfx::BGradient aTmpGradient( + createColorStops(), static_cast<css::awt::GradientStyle>(m_xLbTrgrGradientType->get_active()), Degree10(static_cast<sal_Int16>(m_xMtrTrgrAngle->get_value(FieldUnit::DEGREE)) * 10), static_cast<sal_uInt16>(m_xMtrTrgrCenterX->get_value(FieldUnit::PERCENT)), @@ -253,8 +250,8 @@ bool SvxTransparenceTabPage::FillItemSet(SfxItemSet* rAttrs) bool bGradActive = (eStateGradient == SfxItemState::SET && static_cast<const XFillFloatTransparenceItem*>(pGradientItem)->IsEnabled()); bool bLinearActive = (eStateLinear == SfxItemState::SET && static_cast<const XFillTransparenceItem*>(pLinearItem)->GetValue() != 0); - bool bGradUsed = (eStateGradient == SfxItemState::DONTCARE); - bool bLinearUsed = (eStateLinear == SfxItemState::DONTCARE); + bool bGradUsed = (eStateGradient == SfxItemState::INVALID); + bool bLinearUsed = (eStateLinear == SfxItemState::INVALID); bool bModified(false); bool bSwitchOffLinear(false); @@ -290,11 +287,8 @@ bool SvxTransparenceTabPage::FillItemSet(SfxItemSet* rAttrs) || m_xMtrTrgrStartValue->get_value_changed_from_saved() || m_xMtrTrgrEndValue->get_value_changed_from_saved()) { - sal_uInt8 nStartCol = static_cast<sal_uInt8>((static_cast<sal_uInt16>(m_xMtrTrgrStartValue->get_value(FieldUnit::PERCENT)) * 255) / 100); - sal_uInt8 nEndCol = static_cast<sal_uInt8>((static_cast<sal_uInt16>(m_xMtrTrgrEndValue->get_value(FieldUnit::PERCENT)) * 255) / 100); - XGradient aTmpGradient( - Color(nStartCol, nStartCol, nStartCol), - Color(nEndCol, nEndCol, nEndCol), + basegfx::BGradient aTmpGradient( + createColorStops(), static_cast<css::awt::GradientStyle>(m_xLbTrgrGradientType->get_active()), Degree10(static_cast<sal_Int16>(m_xMtrTrgrAngle->get_value(FieldUnit::DEGREE)) * 10), static_cast<sal_uInt16>(m_xMtrTrgrCenterX->get_value(FieldUnit::PERCENT)), @@ -323,9 +317,10 @@ bool SvxTransparenceTabPage::FillItemSet(SfxItemSet* rAttrs) // disable unused XFillFloatTransparenceItem if(bSwitchOffGradient && (bGradActive || bGradUsed)) { - XGradient aGrad(COL_BLACK, COL_WHITE); - aGrad.SetStartIntens(100); - aGrad.SetEndIntens(100); + // basegfx::BGradient() default already creates [COL_BLACK, COL_WHITE] with same defaults + // basegfx::BGradient() default also sets the Start/EndIntensity to 100 already + basegfx::BGradient aGrad; + XFillFloatTransparenceItem aItem(aGrad); aItem.SetEnabled(false); rAttrs->Put(aItem); @@ -347,31 +342,40 @@ bool SvxTransparenceTabPage::FillItemSet(SfxItemSet* rAttrs) void SvxTransparenceTabPage::Reset(const SfxItemSet* rAttrs) { - const SfxPoolItem* pGradientItem = nullptr; - SfxItemState eStateGradient(rAttrs->GetItemState(XATTR_FILLFLOATTRANSPARENCE, true, &pGradientItem)); + const XFillFloatTransparenceItem* pGradientItem = + rAttrs->GetItemIfSet(XATTR_FILLFLOATTRANSPARENCE); + bool bGradActive = (pGradientItem && pGradientItem->IsEnabled()); if(!pGradientItem) pGradientItem = &rAttrs->Get(XATTR_FILLFLOATTRANSPARENCE); - bool bGradActive = (eStateGradient == SfxItemState::SET && static_cast<const XFillFloatTransparenceItem*>(pGradientItem)->IsEnabled()); - const SfxPoolItem* pLinearItem = nullptr; - SfxItemState eStateLinear(rAttrs->GetItemState(XATTR_FILLTRANSPARENCE, true, &pLinearItem)); + const XFillTransparenceItem* pLinearItem = + rAttrs->GetItemIfSet(XATTR_FILLTRANSPARENCE); + bool bLinearActive = (pLinearItem && pLinearItem->GetValue() != 0); if(!pLinearItem) pLinearItem = &rAttrs->Get(XATTR_FILLTRANSPARENCE); - bool bLinearActive = (eStateLinear == SfxItemState::SET && static_cast<const XFillTransparenceItem*>(pLinearItem)->GetValue() != 0); // transparence gradient - const XGradient& rGradient = static_cast<const XFillFloatTransparenceItem*>(pGradientItem)->GetGradientValue(); + const basegfx::BGradient& rGradient = pGradientItem->GetGradientValue(); css::awt::GradientStyle eXGS(rGradient.GetGradientStyle()); m_xLbTrgrGradientType->set_active(sal::static_int_cast< sal_Int32 >(eXGS)); m_xMtrTrgrAngle->set_value(rGradient.GetAngle().get() / 10, FieldUnit::DEGREE); m_xMtrTrgrBorder->set_value(rGradient.GetBorder(), FieldUnit::PERCENT); m_xMtrTrgrCenterX->set_value(rGradient.GetXOffset(), FieldUnit::PERCENT); m_xMtrTrgrCenterY->set_value(rGradient.GetYOffset(), FieldUnit::PERCENT); - m_xMtrTrgrStartValue->set_value(static_cast<sal_uInt16>(((static_cast<sal_uInt16>(rGradient.GetStartColor().GetRed()) + 1) * 100) / 255), FieldUnit::PERCENT); - m_xMtrTrgrEndValue->set_value(static_cast<sal_uInt16>(((static_cast<sal_uInt16>(rGradient.GetEndColor().GetRed()) + 1) * 100) / 255), FieldUnit::PERCENT); + const Color aStart(rGradient.GetColorStops().front().getStopColor()); + const Color aEnd(rGradient.GetColorStops().back().getStopColor()); + m_xMtrTrgrStartValue->set_value(static_cast<sal_uInt16>(((static_cast<sal_uInt16>(aStart.GetRed()) + 1) * 100) / 255), FieldUnit::PERCENT); + m_xMtrTrgrEndValue->set_value(static_cast<sal_uInt16>(((static_cast<sal_uInt16>(aEnd.GetRed()) + 1) * 100) / 255), FieldUnit::PERCENT); + + // MCGR: preserve ColorStops if given + // tdf#155901 We need offset of first and last stop, so include them. + if (rGradient.GetColorStops().size() >= 2) + maColorStops = rGradient.GetColorStops(); + else + maColorStops.clear(); // linear transparence - sal_uInt16 nTransp = static_cast<const XFillTransparenceItem*>(pLinearItem)->GetValue(); + sal_uInt16 nTransp = pLinearItem->GetValue(); m_xMtrTransparent->set_value(bLinearActive ? nTransp : 50, FieldUnit::PERCENT); ModifyTransparentHdl_Impl(*m_xMtrTransparent); @@ -416,7 +420,7 @@ void SvxTransparenceTabPage::ChangesApplied() void SvxTransparenceTabPage::ActivatePage(const SfxItemSet& rSet) { - const CntUInt16Item* pPageTypeItem = rSet.GetItem<CntUInt16Item>(SID_PAGE_TYPE, false); + const CntUInt16Item* pPageTypeItem = rSet.GetItem<SfxUInt16Item>(SID_PAGE_TYPE, false); if (pPageTypeItem) SetPageType(static_cast<PageType>(pPageTypeItem->GetValue())); @@ -505,6 +509,29 @@ void SvxTransparenceTabPage::InvalidatePreview (bool bEnable) } } +basegfx::BColorStops SvxTransparenceTabPage::createColorStops() +{ + basegfx::BColorStops aColorStops; + basegfx::BColor aStartBColor(m_xMtrTrgrStartValue->get_value(FieldUnit::PERCENT) / 100.0); + aStartBColor.clamp(); + basegfx::BColor aEndBColor(m_xMtrTrgrEndValue->get_value(FieldUnit::PERCENT) / 100.0); + aEndBColor.clamp(); + + if(maColorStops.size() >= 2) + { + aColorStops = maColorStops; + aColorStops.front() = basegfx::BColorStop(maColorStops.front().getStopOffset(), aStartBColor); + aColorStops.back() = basegfx::BColorStop(maColorStops.back().getStopOffset(), aEndBColor); + } + else + { + aColorStops.emplace_back(0.0, aStartBColor); + aColorStops.emplace_back(1.0, aEndBColor); + } + + return aColorStops; +} + void SvxTransparenceTabPage::PageCreated(const SfxAllItemSet& aSet) { const SfxUInt16Item* pPageTypeItem = aSet.GetItem<SfxUInt16Item>(SID_PAGE_TYPE, false); diff --git a/cui/source/tabpages/transfrm.cxx b/cui/source/tabpages/transfrm.cxx index f9396cfd6ab4..78294eb5d584 100644 --- a/cui/source/tabpages/transfrm.cxx +++ b/cui/source/tabpages/transfrm.cxx @@ -34,13 +34,14 @@ #include <svtools/unitconv.hxx> #include <transfrm.hxx> -#include <svx/dlgutil.hxx> #include <svx/anchorid.hxx> #include <svl/rectitem.hxx> #include <swpossizetabpage.hxx> #include <vcl/canvastools.hxx> #include <vcl/fieldvalues.hxx> +#include <bitmaps.hlst> + // static ---------------------------------------------------------------- const WhichRangesContainer SvxPositionSizeTabPage::pPosSizeRanges(svl::Items< @@ -93,7 +94,7 @@ SvxTransformTabDialog::SvxTransformTabDialog(weld::Window* pParent, const SfxIte } -void SvxTransformTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage) +void SvxTransformTabDialog::PageCreated(const OUString& rId, SfxTabPage &rPage) { if (rId == "RID_SVXPAGE_POSITION_SIZE") { @@ -207,7 +208,7 @@ void SvxAngleTabPage::Construct() } // take scale into account - const Fraction aUIScale(pView->GetModel()->GetUIScale()); + const Fraction aUIScale(pView->GetModel().GetUIScale()); TransfrmHelper::ScaleRect(maRange, aUIScale); // take UI units into account @@ -227,13 +228,13 @@ bool SvxAngleTabPage::FillItemSet(SfxItemSet* rSet) if (m_xCtlAngle->IsValueModified() || m_xMtrPosX->get_value_changed_from_saved() || m_xMtrPosY->get_value_changed_from_saved()) { - const double fUIScale(double(pView->GetModel()->GetUIScale())); + const double fUIScale(double(pView->GetModel().GetUIScale())); const double fTmpX((GetCoreValue(*m_xMtrPosX, ePoolUnit) + maAnchor.getX()) * fUIScale); const double fTmpY((GetCoreValue(*m_xMtrPosY, ePoolUnit) + maAnchor.getY()) * fUIScale); - rSet->Put(SdrAngleItem(GetWhich(SID_ATTR_TRANSFORM_ANGLE), m_xCtlAngle->GetRotation())); - rSet->Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ROT_X), basegfx::fround(fTmpX))); - rSet->Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_ROT_Y), basegfx::fround(fTmpY))); + rSet->Put(SdrAngleItem(SID_ATTR_TRANSFORM_ANGLE, m_xCtlAngle->GetRotation())); + rSet->Put(SfxInt32Item(SID_ATTR_TRANSFORM_ROT_X, basegfx::fround(fTmpX))); + rSet->Put(SfxInt32Item(SID_ATTR_TRANSFORM_ROT_Y, basegfx::fround(fTmpY))); bModified = true; } @@ -244,7 +245,7 @@ bool SvxAngleTabPage::FillItemSet(SfxItemSet* rSet) void SvxAngleTabPage::Reset(const SfxItemSet* rAttrs) { - const double fUIScale(double(pView->GetModel()->GetUIScale())); + const double fUIScale(double(pView->GetModel().GetUIScale())); const SfxPoolItem* pItem = GetItem( *rAttrs, SID_ATTR_TRANSFORM_ROT_X ); if(pItem) @@ -289,8 +290,7 @@ std::unique_ptr<SfxTabPage> SvxAngleTabPage::Create(weld::Container* pPage, weld void SvxAngleTabPage::ActivatePage(const SfxItemSet& rSet) { - SfxBoolItem const * bPosProtect = nullptr; - if(SfxItemState::SET == rSet.GetItemState( GetWhich(SID_ATTR_TRANSFORM_PROTECT_POS ) , false, reinterpret_cast<SfxPoolItem const **>(&bPosProtect) )) + if(SfxBoolItem const * bPosProtect = rSet.GetItemIfSet( SID_ATTR_TRANSFORM_PROTECT_POS, false )) { m_xFlPosition->set_sensitive(!bPosProtect->GetValue()); m_xFlAngle->set_sensitive(!bPosProtect->GetValue()); @@ -387,11 +387,11 @@ SvxSlantTabPage::SvxSlantTabPage(weld::Container* pPage, weld::DialogController* { for (int i = 0; i < 2; ++i) { - m_aControlGroups[i] = m_xBuilder->weld_widget("controlgroups" + OString::number(i+1)); - m_aControlGroupX[i] = m_xBuilder->weld_widget("controlgroupx" + OString::number(i+1)); - m_aControlX[i] = m_xBuilder->weld_metric_spin_button("controlx" + OString::number(i+1), FieldUnit::CM); - m_aControlGroupY[i] = m_xBuilder->weld_widget("controlgroupy" + OString::number(i+1)); - m_aControlY[i] = m_xBuilder->weld_metric_spin_button("controly" + OString::number(i+1), FieldUnit::CM); + m_aControlGroups[i] = m_xBuilder->weld_widget("controlgroups" + OUString::number(i+1)); + m_aControlGroupX[i] = m_xBuilder->weld_widget("controlgroupx" + OUString::number(i+1)); + m_aControlX[i] = m_xBuilder->weld_metric_spin_button("controlx" + OUString::number(i+1), FieldUnit::CM); + m_aControlGroupY[i] = m_xBuilder->weld_widget("controlgroupy" + OUString::number(i+1)); + m_aControlY[i] = m_xBuilder->weld_metric_spin_button("controly" + OUString::number(i+1), FieldUnit::CM); } // this page needs ExchangeSupport @@ -431,7 +431,7 @@ bool SvxSlantTabPage::FillItemSet(SfxItemSet* rAttrs) if (m_xMtrRadius->get_value_changed_from_saved()) { - Fraction aUIScale = pView->GetModel()->GetUIScale(); + Fraction aUIScale = pView->GetModel().GetUIScale(); tools::Long nTmp = tools::Long(GetCoreValue(*m_xMtrRadius, ePoolUnit) * aUIScale); rAttrs->Put( makeSdrEckenradiusItem( nTmp ) ); @@ -562,7 +562,7 @@ void SvxSlantTabPage::Reset(const SfxItemSet* rAttrs) if( pItem ) { - const double fUIScale(double(pView->GetModel()->GetUIScale())); + const double fUIScale(double(pView->GetModel().GetUIScale())); const double fTmp(static_cast<double>(static_cast<const SdrMetricItem*>(pItem)->GetValue()) / fUIScale); SetMetricValue(*m_xMtrRadius, basegfx::fround(fTmp), ePoolUnit); } @@ -628,7 +628,7 @@ void SvxSlantTabPage::Reset(const SfxItemSet* rAttrs) *pView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj())); //save geometry - const bool bOrigModelChangeState = pView->GetModel()->IsChanged(); + const bool bOrigModelChangeState = pView->GetModel().IsChanged(); SdrCustomShapeGeometryItem aInitialGeometry(rSdrObjCustomShape.GetMergedItem(SDRATTR_CUSTOMSHAPE_GEOMETRY)); EnhancedCustomShape2d aShape(rSdrObjCustomShape); @@ -672,7 +672,7 @@ void SvxSlantTabPage::Reset(const SfxItemSet* rAttrs) //restore geometry rSdrObjCustomShape.SetMergedItem(aInitialGeometry); - pView->GetModel()->SetChanged(bOrigModelChangeState); + pView->GetModel().SetChanged(bOrigModelChangeState); } for (int i = 0; i < 2; ++i) @@ -689,13 +689,11 @@ std::unique_ptr<SfxTabPage> SvxSlantTabPage::Create(weld::Container* pPage, weld void SvxSlantTabPage::ActivatePage( const SfxItemSet& rSet ) { - SfxBoolItem const * bPosProtect = nullptr; - if(SfxItemState::SET == rSet.GetItemState( GetWhich(SID_ATTR_TRANSFORM_PROTECT_POS ) , false, reinterpret_cast<SfxPoolItem const **>(&bPosProtect) )) + if(SfxBoolItem const * bPosProtect = rSet.GetItemIfSet( SID_ATTR_TRANSFORM_PROTECT_POS, false )) { m_xFlAngle->set_sensitive(!bPosProtect->GetValue()); } - SfxBoolItem const * bSizeProtect = nullptr; - if(SfxItemState::SET == rSet.GetItemState( GetWhich(SID_ATTR_TRANSFORM_PROTECT_SIZE ) , false, reinterpret_cast<SfxPoolItem const **>(&bSizeProtect) )) + if(SfxBoolItem const * bSizeProtect = rSet.GetItemIfSet( SID_ATTR_TRANSFORM_PROTECT_SIZE, false )) { m_xFlAngle->set_sensitive(!bSizeProtect->GetValue()); } @@ -734,6 +732,8 @@ SvxPositionSizeTabPage::SvxPositionSizeTabPage(weld::Container* pPage, weld::Dia , mfOldHeight(0.0) , m_aCtlPos(this) , m_aCtlSize(this) + , m_aRatioTop(ConnectorType::Top) + , m_aRatioBottom(ConnectorType::Bottom) , m_xFlPosition(m_xBuilder->weld_widget("FL_POSITION")) , m_xMtrPosX(m_xBuilder->weld_metric_spin_button("MTR_FLD_POS_X", FieldUnit::CM)) , m_xMtrPosY(m_xBuilder->weld_metric_spin_button("MTR_FLD_POS_Y", FieldUnit::CM)) @@ -744,6 +744,9 @@ SvxPositionSizeTabPage::SvxPositionSizeTabPage(weld::Container* pPage, weld::Dia , m_xFtHeight(m_xBuilder->weld_label("FT_HEIGHT")) , m_xMtrHeight(m_xBuilder->weld_metric_spin_button("MTR_FLD_HEIGHT", FieldUnit::CM)) , m_xCbxScale(m_xBuilder->weld_check_button("CBX_SCALE")) + , m_xCbxScaleImg(m_xBuilder->weld_image("imRatio")) + , m_xImgRatioTop(new weld::CustomWeld(*m_xBuilder, "daRatioTop", m_aRatioTop)) + , m_xImgRatioBottom(new weld::CustomWeld(*m_xBuilder, "daRatioBottom", m_aRatioBottom)) , m_xCtlSize(new weld::CustomWeld(*m_xBuilder, "CTL_SIZERECT", m_aCtlSize)) , m_xFlProtect(m_xBuilder->weld_widget("FL_PROTECT")) , m_xTsbPosProtect(m_xBuilder->weld_check_button("TSB_POSPROTECT")) @@ -764,9 +767,19 @@ SvxPositionSizeTabPage::SvxPositionSizeTabPage(weld::Container* pPage, weld::Dia m_aCtlSize.SetActualRP(RectPoint::LT); meRP = RectPoint::LT; // see above - m_xMtrWidth->connect_value_changed( LINK( this, SvxPositionSizeTabPage, ChangeWidthHdl ) ); - m_xMtrHeight->connect_value_changed( LINK( this, SvxPositionSizeTabPage, ChangeHeightHdl ) ); - m_xCbxScale->connect_toggled( LINK( this, SvxPositionSizeTabPage, ClickAutoHdl ) ); + m_xMtrWidth->connect_value_changed(LINK(this, SvxPositionSizeTabPage, ChangeWidthHdl)); + m_xMtrHeight->connect_value_changed(LINK(this, SvxPositionSizeTabPage, ChangeHeightHdl)); + + m_xCbxScale->connect_toggled(LINK(this, SvxPositionSizeTabPage, ClickAutoHdl)); + // vertical alignment = fill makes the drawingarea expand the associated spinedits so we have to size it here + const sal_Int16 aHeight + = static_cast<sal_Int16>(std::max(int(m_xCbxScale->get_preferred_size().getHeight() / 2 + - m_xFtWidth->get_preferred_size().getHeight() / 2), + 12)); + const sal_Int16 aWidth + = static_cast<sal_Int16>(m_xCbxScale->get_preferred_size().getWidth() / 2); + m_xImgRatioTop->set_size_request(aWidth, aHeight); + m_xImgRatioBottom->set_size_request(aWidth, aHeight); m_xFlAdjust->set_sensitive(false); @@ -846,7 +859,7 @@ void SvxPositionSizeTabPage::Construct() const SdrObjKind eKind(pObj->GetObjIdentifier()); if((pObj->GetObjInventor() == SdrInventor::Default) && - (OBJ_TEXT == eKind || OBJ_TITLETEXT == eKind || OBJ_OUTLINETEXT == eKind) && + (SdrObjKind::Text == eKind || SdrObjKind::TitleText == eKind || SdrObjKind::OutlineText == eKind) && pObj->HasText()) { mbAdjustDisabled = false; @@ -856,14 +869,14 @@ void SvxPositionSizeTabPage::Construct() m_xTsbAutoGrowWidth->connect_toggled( LINK( this, SvxPositionSizeTabPage, ClickSizeProtectHdl ) ); m_xTsbAutoGrowHeight->connect_toggled( LINK( this, SvxPositionSizeTabPage, ClickSizeProtectHdl ) ); - // is used as flag to evaluate if its selectable + // is used as flag to evaluate if it's selectable mbIgnoreAutoGrowWidth = false; mbIgnoreAutoGrowHeight = false; } } // take scale into account - const Fraction aUIScale(mpView->GetModel()->GetUIScale()); + const Fraction aUIScale(mpView->GetModel().GetUIScale()); TransfrmHelper::ScaleRect( maWorkRange, aUIScale ); TransfrmHelper::ScaleRect( maRange, aUIScale ); @@ -894,7 +907,7 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs ) { if (m_xMtrPosX->get_value_changed_from_saved() || m_xMtrPosY->get_value_changed_from_saved()) { - const double fUIScale(double(mpView->GetModel()->GetUIScale())); + const double fUIScale(double(mpView->GetModel().GetUIScale())); double fX((GetCoreValue( *m_xMtrPosX, mePoolUnit ) + maAnchor.getX()) * fUIScale); double fY((GetCoreValue( *m_xMtrPosY, mePoolUnit ) + maAnchor.getY()) * fUIScale); @@ -907,8 +920,8 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs ) // #101581# GetTopLeftPosition(...) needs coordinates after UI scaling, in real PagePositions GetTopLeftPosition(fX, fY, maRange); - rOutAttrs->Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_POS_X), basegfx::fround(fX))); - rOutAttrs->Put(SfxInt32Item(GetWhich(SID_ATTR_TRANSFORM_POS_Y), basegfx::fround(fY))); + rOutAttrs->Put(SfxInt32Item(SID_ATTR_TRANSFORM_POS_X, basegfx::fround(fX))); + rOutAttrs->Put(SfxInt32Item(SID_ATTR_TRANSFORM_POS_Y, basegfx::fround(fY))); bModified = true; } @@ -922,7 +935,7 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs ) else { rOutAttrs->Put( - SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS ), + SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_POS, m_xTsbPosProtect->get_active() ) ); } @@ -932,7 +945,7 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs ) if (m_xMtrWidth->get_value_changed_from_saved() || m_xMtrHeight->get_value_changed_from_saved()) { - Fraction aUIScale = mpView->GetModel()->GetUIScale(); + Fraction aUIScale = mpView->GetModel().GetUIScale(); // get Width double nWidth = static_cast<double>(m_xMtrWidth->get_value(FieldUnit::MM_100TH)); @@ -947,9 +960,9 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs ) lHeight = static_cast<tools::Long>(m_xMtrHeight->denormalize( lHeight )); // put Width & Height to itemset - rOutAttrs->Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_WIDTH ), static_cast<sal_uInt32>(lWidth) ) ); - rOutAttrs->Put( SfxUInt32Item( GetWhich( SID_ATTR_TRANSFORM_HEIGHT ), static_cast<sal_uInt32>(lHeight) ) ); - rOutAttrs->Put( SfxUInt16Item( GetWhich( SID_ATTR_TRANSFORM_SIZE_POINT ), sal::static_int_cast< sal_uInt16 >( meRP ) ) ); + rOutAttrs->Put( SfxUInt32Item( SID_ATTR_TRANSFORM_WIDTH, static_cast<sal_uInt32>(lWidth) ) ); + rOutAttrs->Put( SfxUInt32Item( SID_ATTR_TRANSFORM_HEIGHT, static_cast<sal_uInt32>(lHeight) ) ); + rOutAttrs->Put( SfxUInt16Item( SID_ATTR_TRANSFORM_SIZE_POINT, sal::static_int_cast< sal_uInt16 >( meRP ) ) ); bModified = true; } @@ -959,7 +972,7 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs ) rOutAttrs->InvalidateItem( SID_ATTR_TRANSFORM_PROTECT_SIZE ); else rOutAttrs->Put( - SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE ), + SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE, m_xTsbSizeProtect->get_active() ) ); bModified = true; } @@ -972,7 +985,7 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs ) rOutAttrs->InvalidateItem( SID_ATTR_TRANSFORM_AUTOWIDTH ); else rOutAttrs->Put( - SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_AUTOWIDTH ), + SfxBoolItem( SID_ATTR_TRANSFORM_AUTOWIDTH, m_xTsbAutoGrowWidth->get_active() ) ); } bModified = true; @@ -989,7 +1002,7 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs ) else { rOutAttrs->Put( - SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_AUTOHEIGHT ), + SfxBoolItem( SID_ATTR_TRANSFORM_AUTOHEIGHT, m_xTsbAutoGrowHeight->get_active() ) ); } } @@ -1002,7 +1015,7 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs ) void SvxPositionSizeTabPage::Reset( const SfxItemSet* ) { const SfxPoolItem* pItem; - const double fUIScale(double(mpView->GetModel()->GetUIScale())); + const double fUIScale(double(mpView->GetModel().GetUIScale())); if ( !mbPageDisabled ) { @@ -1044,7 +1057,7 @@ void SvxPositionSizeTabPage::Reset( const SfxItemSet* ) double fTmpWidth((OutputDevice::LogicToLogic(static_cast<sal_Int32>(mfOldWidth), mePoolUnit, MapUnit::Map100thMM)) / fUIScale); if (m_xMtrWidth->get_digits()) fTmpWidth *= pow(10.0, m_xMtrWidth->get_digits()); - m_xMtrWidth->set_value(static_cast<int>(fTmpWidth), FieldUnit::MM_100TH); + m_xMtrWidth->set_value(fTmpWidth, FieldUnit::MM_100TH); } { // #i75273# set height @@ -1053,7 +1066,7 @@ void SvxPositionSizeTabPage::Reset( const SfxItemSet* ) double fTmpHeight((OutputDevice::LogicToLogic(static_cast<sal_Int32>(mfOldHeight), mePoolUnit, MapUnit::Map100thMM)) / fUIScale); if (m_xMtrHeight->get_digits()) fTmpHeight *= pow(10.0, m_xMtrHeight->get_digits()); - m_xMtrHeight->set_value(static_cast<int>(fTmpHeight), FieldUnit::MM_100TH); + m_xMtrHeight->set_value(fTmpHeight, FieldUnit::MM_100TH); } pItem = GetItem( mrOutAttrs, SID_ATTR_TRANSFORM_PROTECT_SIZE ); @@ -1083,6 +1096,7 @@ void SvxPositionSizeTabPage::Reset( const SfxItemSet* ) // Is matching set? OUString aStr = GetUserData(); m_xCbxScale->set_active(aStr.toInt32() != 0); + m_xCbxScaleImg->set_from_icon_name(m_xCbxScale->get_active() ? RID_SVXBMP_LOCKED : RID_SVXBMP_UNLOCKED); m_xMtrPosX->save_value(); m_xMtrPosY->save_value(); @@ -1105,9 +1119,7 @@ std::unique_ptr<SfxTabPage> SvxPositionSizeTabPage::Create(weld::Container* pPag void SvxPositionSizeTabPage::ActivatePage( const SfxItemSet& rSet ) { - SfxRectangleItem const * pRectItem = nullptr; - - if( SfxItemState::SET == rSet.GetItemState( GetWhich( SID_ATTR_TRANSFORM_INTERN ) , false, reinterpret_cast<SfxPoolItem const **>(&pRectItem) ) ) + if( SfxRectangleItem const * pRectItem = rSet.GetItemIfSet( SID_ATTR_TRANSFORM_INTERN, false ) ) { { // #i75273# const ::tools::Rectangle aTempRect(pRectItem->GetValue()); @@ -1128,12 +1140,12 @@ DeactivateRC SvxPositionSizeTabPage::DeactivatePage( SfxItemSet* _pSet ) GetTopLeftPosition(fX, fY, maRange); const ::tools::Rectangle aOutRectangle( - basegfx::fround(fX), basegfx::fround(fY), - basegfx::fround(fX + maRange.getWidth()), basegfx::fround(fY + maRange.getHeight())); + basegfx::fround<tools::Long>(fX), basegfx::fround<tools::Long>(fY), + basegfx::fround<tools::Long>(fX + maRange.getWidth()), basegfx::fround<tools::Long>(fY + maRange.getHeight())); _pSet->Put(SfxRectangleItem(SID_ATTR_TRANSFORM_INTERN, aOutRectangle)); - _pSet->Put(SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_POS ), + _pSet->Put(SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_POS, m_xTsbPosProtect->get_state() == TRISTATE_TRUE )); - _pSet->Put(SfxBoolItem( GetWhich( SID_ATTR_TRANSFORM_PROTECT_SIZE ), + _pSet->Put(SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE, m_xTsbSizeProtect->get_state() == TRISTATE_TRUE )); FillItemSet(_pSet); } @@ -1271,7 +1283,7 @@ void SvxPositionSizeTabPage::SetMinMaxPosition() } } - const double fMaxLong(static_cast<double>(vcl::ConvertValue( LONG_MAX, 0, MapUnit::Map100thMM, meDlgUnit ) - 1)); + const double fMaxLong(vcl::ConvertValue(std::numeric_limits<sal_Int64>::max(), 0, MapUnit::Map100thMM, meDlgUnit) - 1); fLeft = std::clamp(fLeft, -fMaxLong, fMaxLong); fRight = std::clamp(fRight, -fMaxLong, fMaxLong); fTop = std::clamp(fTop, - fMaxLong, fMaxLong); @@ -1503,7 +1515,7 @@ IMPL_LINK_NOARG(SvxPositionSizeTabPage, ChangeWidthHdl, weld::MetricSpinButton&, return; sal_Int64 nHeight(basegfx::fround64((mfOldHeight * static_cast<double>(m_xMtrWidth->get_value(FieldUnit::NONE))) / mfOldWidth)); - int nMin, nMax; + sal_Int64 nMin, nMax; m_xMtrHeight->get_range(nMin, nMax, FieldUnit::NONE); if (nHeight <= nMax) @@ -1526,7 +1538,7 @@ IMPL_LINK_NOARG(SvxPositionSizeTabPage, ChangeHeightHdl, weld::MetricSpinButton& return; sal_Int64 nWidth(basegfx::fround64((mfOldWidth * static_cast<double>(m_xMtrHeight->get_value(FieldUnit::NONE))) / mfOldHeight)); - int nMin, nMax; + sal_Int64 nMin, nMax; m_xMtrWidth->get_range(nMin, nMax, FieldUnit::NONE); if (nWidth <= nMax) @@ -1550,6 +1562,7 @@ IMPL_LINK_NOARG(SvxPositionSizeTabPage, ClickSizeProtectHdl, weld::Toggleable&, IMPL_LINK_NOARG(SvxPositionSizeTabPage, ClickAutoHdl, weld::Toggleable&, void) { + m_xCbxScaleImg->set_from_icon_name(m_xCbxScale->get_active() ? RID_SVXBMP_LOCKED : RID_SVXBMP_UNLOCKED); if (m_xCbxScale->get_active()) { mfOldWidth = std::max( static_cast<double>(GetCoreValue( *m_xMtrWidth, mePoolUnit )), 1.0 ); |