diff options
Diffstat (limited to 'cui/source/tabpages/numpages.cxx')
-rw-r--r-- | cui/source/tabpages/numpages.cxx | 779 |
1 files changed, 241 insertions, 538 deletions
diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx index fbeb40aa4b3d..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> @@ -50,7 +51,11 @@ #include <com/sun/star/text/XNumberingFormatter.hpp> #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> @@ -71,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 @@ -116,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) { @@ -143,9 +136,9 @@ 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 = [&]() + static vcl::Font aDefBulletFont = []() { vcl::Font tmp("OpenSymbol", "", Size(0, 14)); tmp.SetCharSet( RTL_TEXTENCODING_SYMBOL ); @@ -226,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) { @@ -273,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; } } @@ -314,14 +306,8 @@ IMPL_LINK_NOARG(SvxSingleNumPickTabPage, NumSelectHdl_Impl, ValueSet*, void) { SvxNumberFormat aFmt(pActNum->GetLevel(i)); aFmt.SetNumberingType(eNewType); - if(cLocalPrefix == ' ') - aFmt.SetPrefix( "" ); - else - aFmt.SetPrefix(_pSet->sPrefix); - if(cLocalSuffix == ' ') - aFmt.SetSuffix( "" ); - else - aFmt.SetSuffix(_pSet->sSuffix); + aFmt.SetListFormat(cLocalPrefix == ' ' ? "" : _pSet->sPrefix, + cLocalSuffix == ' ' ? "" : _pSet->sSuffix, i); aFmt.SetCharFormatName(""); aFmt.SetBulletRelSize(100); pActNum->SetLevel(i, aFmt); @@ -377,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) { @@ -417,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) ); @@ -448,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++) @@ -459,8 +444,7 @@ IMPL_LINK_NOARG(SvxBulletPickTabPage, NumSelectHdl_Impl, ValueSet*, void) SvxNumberFormat aFmt(pActNum->GetLevel(i)); aFmt.SetNumberingType( SVX_NUM_CHAR_SPECIAL ); // #i93908# clear suffix for bullet lists - aFmt.SetPrefix( OUString() ); - aFmt.SetSuffix( OUString() ); + aFmt.SetListFormat("", "", i); aFmt.SetBulletFont(&rActBulletFont); aFmt.SetBulletChar(cChar ); aFmt.SetCharFormatName(sBulletCharFormatName); @@ -518,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) ); } @@ -560,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) { @@ -600,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) ); @@ -652,25 +634,25 @@ IMPL_LINK_NOARG(SvxNumPickTabPage, NumSelectHdl_Impl, ValueSet*, void) if(aFmt.GetNumberingType() == SVX_NUM_CHAR_SPECIAL) { // #i93908# clear suffix for bullet lists - aFmt.SetPrefix(OUString()); - aFmt.SetSuffix(OUString()); + aFmt.SetListFormat("", "", i); if( !pLevelSettings->sBulletFont.isEmpty() && pLevelSettings->sBulletFont != rActBulletFont.GetFamilyName()) { //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 @@ -698,12 +680,16 @@ IMPL_LINK_NOARG(SvxNumPickTabPage, NumSelectHdl_Impl, ValueSet*, void) } else { - aFmt.SetIncludeUpperLevels(sal::static_int_cast< sal_uInt8 >(0 != nUpperLevelOrChar ? pActNum->GetLevelCount() : 0)); + 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.SetPrefix(pLevelSettings->sPrefix); - aFmt.SetSuffix(pLevelSettings->sSuffix); + aFmt.SetListFormat(pLevelSettings->sPrefix, pLevelSettings->sSuffix, i); } pActNum->SetLevel(i, aFmt); } @@ -744,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); @@ -755,8 +744,12 @@ SvxBitmapPickTabPage::SvxBitmapPickTabPage(weld::Container* pPage, weld::DialogC m_xExamplesVS->InsertItem( i + 1, i); INetURLObject aObj(grfName); - if(aObj.GetProtocol() == INetProtocol::File) - grfName = aObj.PathToFileName(); + if (aObj.GetProtocol() == INetProtocol::File) + { + // tdf#114070 - only show the last name of the filename without its extension + aObj.removeExtension(); + grfName = aObj.GetLastName(INetURLObject::DecodeMechanism::Unambiguous); + } m_xExamplesVS->SetItemText( i + 1, grfName ); ++i; @@ -788,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) { @@ -845,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) ); @@ -885,8 +875,7 @@ IMPL_LINK_NOARG(SvxBitmapPickTabPage, NumSelectHdl_Impl, ValueSet*, void) { SvxNumberFormat aFmt(pActNum->GetLevel(i)); aFmt.SetNumberingType(SVX_NUM_BITMAP); - aFmt.SetPrefix( "" ); - aFmt.SetSuffix( "" ); + aFmt.SetListFormat("", "", i); aFmt.SetCharFormatName( "" ); Graphic aGraphic; @@ -916,12 +905,13 @@ IMPL_LINK_NOARG(SvxBitmapPickTabPage, DoubleClickHdl_Impl, ValueSet*, void) IMPL_LINK_NOARG(SvxBitmapPickTabPage, ClickAddBrowseHdl_Impl, weld::Button&, void) { sfx2::FileDialogHelper aFileDialog(0, FileDialogFlags::NONE, GetFrameWeld()); - aFileDialog.SetTitle(CuiResId(RID_SVXSTR_ADD_IMAGE)); + aFileDialog.SetContext(sfx2::FileDialogHelper::BulletsAddImage); + 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(); @@ -932,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" ); @@ -975,11 +965,10 @@ IMPL_LINK_NOARG(SvxBitmapPickTabPage, ClickAddBrowseHdl_Impl, weld::Button&, voi Graphic aScaledGraphic( aBitmap ); GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); - Sequence< PropertyValue > aFilterData( 2 ); - aFilterData[ 0 ].Name = "Compression"; - aFilterData[ 0 ].Value <<= sal_Int32(-1) ; - aFilterData[ 1 ].Name = "Quality"; - aFilterData[ 1 ].Value <<= sal_Int32(1); + Sequence< PropertyValue > aFilterData{ + comphelper::makePropertyValue("Compression", sal_Int32(-1)), + comphelper::makePropertyValue("Quality", sal_Int32(1)) + }; sal_uInt16 nFilterFormat = rFilter.GetExportFormatNumberForShortName( gURL.GetFileExtension() ); rFilter.ExportGraphic( aScaledGraphic, gURL , nFilterFormat, &aFilterData ); @@ -991,8 +980,12 @@ IMPL_LINK_NOARG(SvxBitmapPickTabPage, ClickAddBrowseHdl_Impl, weld::Button&, voi { m_xExamplesVS->InsertItem( i + 1, i); INetURLObject aObj(grfName); - if(aObj.GetProtocol() == INetProtocol::File) - grfName = aObj.PathToFileName(); + if (aObj.GetProtocol() == INetProtocol::File) + { + // tdf#114070 - only show the last name of the filename without its extension + aObj.removeExtension(); + grfName = aObj.GetLastName(INetURLObject::DecodeMechanism::Unambiguous); + } m_xExamplesVS->SetItemText( i + 1, grfName ); ++i; } @@ -1012,6 +1005,7 @@ IMPL_LINK_NOARG(SvxBitmapPickTabPage, ClickAddBrowseHdl_Impl, weld::Button&, voi SvxNumOptionsTabPage::SvxNumOptionsTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/numberingoptionspage.ui", "NumberingOptionsPage", &rSet) + , aInvalidateTimer("cui SvxNumOptionsTabPage aInvalidateTimer") , m_pLevelHdlEvent(nullptr) , bLastWidthModified(false) , bModified(false) @@ -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,9 @@ 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); } nMask <<= 1; @@ -1625,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; @@ -1643,9 +1690,8 @@ IMPL_LINK(SvxNumOptionsTabPage, NumberTypeSelectHdl_Impl, weld::ComboBox&, rBox, if(SVX_NUM_BITMAP == (nNumberingType&(~LINK_TOKEN))) { bBmp |= nullptr != aNumFmt.GetBrush(); - aNumFmt.SetIncludeUpperLevels( 0 ); - aNumFmt.SetSuffix( "" ); - aNumFmt.SetPrefix( "" ); + aNumFmt.SetIncludeUpperLevels( 1 ); + aNumFmt.SetListFormat("", "", i); if(!bBmp) aNumFmt.SetGraphic(""); pActNum->SetLevel(i, aNumFmt); @@ -1654,9 +1700,8 @@ IMPL_LINK(SvxNumOptionsTabPage, NumberTypeSelectHdl_Impl, weld::ComboBox&, rBox, } else if( SVX_NUM_CHAR_SPECIAL == nNumberingType ) { - aNumFmt.SetIncludeUpperLevels( 0 ); - aNumFmt.SetSuffix( "" ); - aNumFmt.SetPrefix( "" ); + aNumFmt.SetIncludeUpperLevels( 1 ); + aNumFmt.SetListFormat("", "", i); if( !aNumFmt.GetBulletFont() ) aNumFmt.SetBulletFont(&aActBulletFont); if( !aNumFmt.GetBulletChar() ) @@ -1671,8 +1716,8 @@ IMPL_LINK(SvxNumOptionsTabPage, NumberTypeSelectHdl_Impl, weld::ComboBox&, rBox, } else { - aNumFmt.SetPrefix( m_xPrefixED->get_text() ); - aNumFmt.SetSuffix( m_xSuffixED->get_text() ); + aNumFmt.SetListFormat(m_xPrefixED->get_text(), m_xSuffixED->get_text(), i); + SwitchNumberType(SHOW_NUMBERING); pActNum->SetLevel(i, aNumFmt); CheckForStartValue_Impl(nNumberingType); @@ -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(); @@ -1896,8 +1941,12 @@ IMPL_LINK_NOARG(SvxNumOptionsTabPage, PopupActivateHdl_Impl, weld::Toggleable&, sGrfName = grfName; OUString sItemId = "gallery" + OUString::number(i); INetURLObject aObj(sGrfName); - if(aObj.GetProtocol() == INetProtocol::File) - sGrfName = aObj.PathToFileName(); + if (aObj.GetProtocol() == INetProtocol::File) + { + // tdf#141334 - only show the last name of the filename without its extension + aObj.removeExtension(); + sGrfName = aObj.GetLastName(INetURLObject::DecodeMechanism::Unambiguous); + } if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, i, &aGraphic)) { BitmapEx aBitmap(aGraphic.GetBitmapEx()); @@ -1929,7 +1978,7 @@ IMPL_LINK_NOARG(SvxNumOptionsTabPage, BulletHdl_Impl, weld::Button&, void) SvxCharacterMap aMap(GetFrameWeld(), nullptr, nullptr); sal_uInt16 nMask = 1; - const vcl::Font* pFmtFont = nullptr; + std::optional<vcl::Font> pFmtFont; bool bSameBullet = true; sal_UCS4 cBullet = 0; bool bFirst = true; @@ -2052,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) @@ -2098,8 +2148,7 @@ IMPL_LINK(SvxNumOptionsTabPage, SpinModifyHdl_Impl, weld::SpinButton&, rSpinButt void SvxNumOptionsTabPage::EditModifyHdl_Impl(const weld::Entry* pEdit) { - bool bPrefix = pEdit == m_xPrefixED.get(); - bool bSuffix = pEdit == m_xSuffixED.get(); + bool bPrefixSuffix = (pEdit == m_xPrefixED.get())|| (pEdit == m_xSuffixED.get()); bool bStart = pEdit == m_xStartED.get(); sal_uInt16 nMask = 1; for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) @@ -2107,10 +2156,8 @@ void SvxNumOptionsTabPage::EditModifyHdl_Impl(const weld::Entry* pEdit) if(nActNumLvl & nMask) { SvxNumberFormat aNumFmt(pActNum->GetLevel(i)); - if(bPrefix) - aNumFmt.SetPrefix(m_xPrefixED->get_text()); - else if(bSuffix) - aNumFmt.SetSuffix(m_xSuffixED->get_text()); + if (bPrefixSuffix) + aNumFmt.SetListFormat(m_xPrefixED->get_text(), m_xSuffixED->get_text(), i); else if(bStart) aNumFmt.SetStart(m_xStartED->get_value()); pActNum->SetLevel(i, aNumFmt); @@ -2120,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::getSystemLanguage(), 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 @@ -2505,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); @@ -2535,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() @@ -2746,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 || @@ -2815,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()) @@ -3339,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())); |