summaryrefslogtreecommitdiff
path: root/svx/source
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2024-05-06 09:20:58 +0200
committerSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2024-05-16 09:17:09 +0200
commitc8a5dc46d11f2ef1e3a66d633730d9a700ced24a (patch)
treedf9b1b9ad3572d536e9b981c4d3df4cfa61d6009 /svx/source
parent28c64afa68f52fb847e9915cde108b856fa39987 (diff)
tdf#161056 Show bullets used in document in bullets dropdown
Change-Id: I40cfc39501006146f7c6c04a1f3c7cf877c6f1c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167186 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
Diffstat (limited to 'svx/source')
-rw-r--r--svx/source/dialog/svxbmpnumvalueset.cxx26
-rw-r--r--svx/source/sidebar/nbdtmg.cxx24
-rw-r--r--svx/source/tbxctrls/bulletsnumbering.cxx100
3 files changed, 142 insertions, 8 deletions
diff --git a/svx/source/dialog/svxbmpnumvalueset.cxx b/svx/source/dialog/svxbmpnumvalueset.cxx
index 442256081e5b..a934a972cf74 100644
--- a/svx/source/dialog/svxbmpnumvalueset.cxx
+++ b/svx/source/dialog/svxbmpnumvalueset.cxx
@@ -149,13 +149,18 @@ void SvxNumValueSet::UserDraw( const UserDrawEvent& rUDEvt )
aRuleFont.SetFillColor(aBackColor);
css::uno::Sequence< OUString > aBulletSymbols;
- if(ePageType == NumberingPageType::BULLET)
+ if(ePageType == NumberingPageType::BULLET || ePageType == NumberingPageType::DOCBULLET)
{
aBulletSymbols = officecfg::Office::Common::BulletsNumbering::DefaultBullets::get();
css::uno::Sequence< OUString > aBulletFonts(officecfg::Office::Common::BulletsNumbering::DefaultBulletsFonts::get());
aRuleFont.SetFamilyName(aBulletFonts[nIndex]);
aFont = aRuleFont;
}
+ else if (ePageType == NumberingPageType::DOCBULLET)
+ {
+ aRuleFont.SetFamilyName(maCustomBullets[nIndex].second);
+ aFont = aRuleFont;
+ }
else if(ePageType == NumberingPageType::OUTLINE)
{
aSize.setHeight( nRectHeight/8 );
@@ -198,7 +203,8 @@ void SvxNumValueSet::UserDraw( const UserDrawEvent& rUDEvt )
// Now comes the text
static constexpr OUStringLiteral sValue(u"Value");
if( NumberingPageType::SINGLENUM == ePageType ||
- NumberingPageType::BULLET == ePageType )
+ NumberingPageType::BULLET == ePageType ||
+ NumberingPageType::DOCBULLET == ePageType)
{
Point aStart(aBLPos.X() + nRectWidth / 9,0);
for( sal_uInt16 i = 0; i < 3; i++ )
@@ -212,6 +218,12 @@ void SvxNumValueSet::UserDraw( const UserDrawEvent& rUDEvt )
aStart.AdjustY( -(pDev->GetTextHeight()/2) );
aStart.setX( aBLPos.X() + 5 );
}
+ else if (ePageType == NumberingPageType::DOCBULLET)
+ {
+ sText = maCustomBullets[nIndex].first;
+ aStart.AdjustY( -(pDev->GetTextHeight()/2) );
+ aStart.setX( aBLPos.X() + 5 );
+ }
else
{
if(xFormatter.is() && aNumSettings.getLength() > nIndex)
@@ -446,6 +458,16 @@ void SvxNumValueSet::SetOutlineNumberingSettings(
}
}
+void SvxNumValueSet::SetCustomBullets(std::vector<std::pair<OUString, OUString>> aCustomBullets)
+{
+ Clear();
+ maCustomBullets = aCustomBullets;
+ for (size_t i = 0; i < aCustomBullets.size(); i++)
+ {
+ InsertItem(i + 1, i);
+ }
+}
+
SvxBmpNumValueSet::SvxBmpNumValueSet(std::unique_ptr<weld::ScrolledWindow> pScrolledWindow)
: SvxNumValueSet(std::move(pScrolledWindow))
, aFormatIdle("SvxBmpNumValueSet FormatIdle")
diff --git a/svx/source/sidebar/nbdtmg.cxx b/svx/source/sidebar/nbdtmg.cxx
index ed88addb88b2..14a27feaedbb 100644
--- a/svx/source/sidebar/nbdtmg.cxx
+++ b/svx/source/sidebar/nbdtmg.cxx
@@ -341,6 +341,30 @@ void BulletsTypeMgr::ApplyNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt1
}
}
+void BulletsTypeMgr::ApplyCustomRule(SvxNumRule& aNum, std::u16string_view sBullet,
+ std::u16string_view sFont, sal_uInt16 mLevel, bool isResetSize)
+{
+ sal_uInt16 nMask = 1;
+ OUString sBulletCharFormatName = GetBulletCharFmtName();
+ const vcl::Font aFont(OUString(sFont), Size(1, 1));
+ for (sal_uInt16 i = 0; i < aNum.GetLevelCount(); i++)
+ {
+ if (mLevel & nMask)
+ {
+ SvxNumberFormat aFmt(aNum.GetLevel(i));
+ aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
+ aFmt.SetBulletFont(&aFont);
+ aFmt.SetBulletChar(sBullet[0]);
+ aFmt.SetCharFormatName(sBulletCharFormatName);
+ aFmt.SetListFormat("");
+ if (isResetSize)
+ aFmt.SetBulletRelSize(45);
+ aNum.SetLevel(i, aFmt);
+ }
+ nMask <<= 1;
+ }
+}
+
OUString BulletsTypeMgr::GetDescription(sal_uInt16 /*nIndex*/, bool /*isDefault*/)
{
return OUString();
diff --git a/svx/source/tbxctrls/bulletsnumbering.cxx b/svx/source/tbxctrls/bulletsnumbering.cxx
index f6ca64be5bdb..0ce9057012e0 100644
--- a/svx/source/tbxctrls/bulletsnumbering.cxx
+++ b/svx/source/tbxctrls/bulletsnumbering.cxx
@@ -9,9 +9,11 @@
#include <com/sun/star/text/DefaultNumberingProvider.hpp>
#include <com/sun/star/text/XNumberingFormatter.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
#include <comphelper/propertysequence.hxx>
#include <i18nlangtag/languagetag.hxx>
+#include <officecfg/Office/Common.hxx>
#include <svtools/popupwindowcontroller.hxx>
#include <svtools/toolbarmenu.hxx>
#include <svx/strings.hrc>
@@ -32,8 +34,13 @@ class NumberingPopup : public WeldToolbarPopup
NumberingToolBoxControl& mrController;
std::unique_ptr<SvxNumValueSet> mxValueSet;
std::unique_ptr<weld::CustomWeld> mxValueSetWin;
+ std::unique_ptr<SvxNumValueSet> mxValueSetDoc;
+ std::unique_ptr<weld::CustomWeld> mxValueSetWinDoc;
std::unique_ptr<weld::Button> mxMoreButton;
+ std::unique_ptr<weld::Label> mxBulletsLabel;
+ std::unique_ptr<weld::Label> mxDocBulletsLabel;
DECL_LINK(VSSelectValueSetHdl, ValueSet*, void);
+ DECL_LINK(VSSelectValueSetDocHdl, ValueSet*, void);
DECL_LINK(VSButtonClickSetHdl, weld::Button&, void);
virtual void GrabFocus() override;
@@ -70,13 +77,22 @@ NumberingPopup::NumberingPopup(NumberingToolBoxControl& rController,
, mrController(rController)
, mxValueSet(new SvxNumValueSet(m_xBuilder->weld_scrolled_window(u"valuesetwin"_ustr, true)))
, mxValueSetWin(new weld::CustomWeld(*m_xBuilder, u"valueset"_ustr, *mxValueSet))
+ , mxValueSetDoc(new SvxNumValueSet(m_xBuilder->weld_scrolled_window(u"valuesetwin_doc"_ustr, true)))
+ , mxValueSetWinDoc(new weld::CustomWeld(*m_xBuilder, u"valueset_doc"_ustr, *mxValueSetDoc))
, mxMoreButton(m_xBuilder->weld_button(u"more"_ustr))
+ , mxBulletsLabel(m_xBuilder->weld_label(u"label_default"_ustr))
+ , mxDocBulletsLabel(m_xBuilder->weld_label(u"label_doc"_ustr))
{
mxValueSet->SetStyle(WB_MENUSTYLEVALUESET | WB_FLATVALUESET | WB_NO_DIRECTSELECT);
+ mxValueSetDoc->SetStyle(WB_MENUSTYLEVALUESET | WB_FLATVALUESET | WB_NO_DIRECTSELECT);
mxValueSet->init(mePageType);
+ mxValueSetDoc->init(NumberingPageType::DOCBULLET);
+ mxValueSetWinDoc->hide();
+ mxDocBulletsLabel->hide();
if ( mePageType != NumberingPageType::BULLET )
{
+ mxBulletsLabel->hide();
css::uno::Reference< css::text::XDefaultNumberingProvider > xDefNum = css::text::DefaultNumberingProvider::create( mrController.getContext() );
if ( xDefNum.is() )
{
@@ -99,16 +115,24 @@ NumberingPopup::NumberingPopup(NumberingToolBoxControl& rController,
}
weld::DrawingArea* pDrawingArea = mxValueSet->GetDrawingArea();
+ weld::DrawingArea* pDrawingAreaDoc = mxValueSetDoc->GetDrawingArea();
OutputDevice& rRefDevice = pDrawingArea->get_ref_device();
Size aItemSize(rRefDevice.LogicToPixel(Size(30, 42), MapMode(MapUnit::MapAppFont)));
mxValueSet->SetExtraSpacing( 2 );
+ mxValueSetDoc->SetExtraSpacing( 2 );
Size aSize(mxValueSet->CalcWindowSizePixel(aItemSize));
pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
+ pDrawingAreaDoc->set_size_request(aSize.Width(), aSize.Height());
mxValueSet->SetOutputSizePixel(aSize);
+ mxValueSetDoc->SetOutputSizePixel(aSize);
mxValueSet->SetColor(Application::GetSettings().GetStyleSettings().GetFieldColor());
+ mxValueSetDoc->SetColor(Application::GetSettings().GetStyleSettings().GetFieldColor());
if ( mePageType == NumberingPageType::BULLET )
+ {
AddStatusListener( u".uno:CurrentBulletListType"_ustr );
+ AddStatusListener( u".uno:DocumentBulletList"_ustr );
+ }
else if ( mePageType == NumberingPageType::SINGLENUM )
AddStatusListener( u".uno:CurrentNumListType"_ustr );
else
@@ -119,15 +143,67 @@ NumberingPopup::NumberingPopup(NumberingToolBoxControl& rController,
mxMoreButton->connect_clicked(LINK(this, NumberingPopup, VSButtonClickSetHdl));
mxValueSet->SetSelectHdl(LINK(this, NumberingPopup, VSSelectValueSetHdl));
+ mxValueSetDoc->SetSelectHdl(LINK(this, NumberingPopup, VSSelectValueSetDocHdl));
}
-void NumberingPopup::statusChanged( const css::frame::FeatureStateEvent& rEvent )
+namespace
+{
+bool lcl_BulletIsDefault(std::u16string_view aSymbol, std::u16string_view aFont)
{
- mxValueSet->SetNoSelection();
+ css::uno::Sequence<OUString> aBulletSymbols
+ = officecfg::Office::Common::BulletsNumbering::DefaultBullets::get();
+ css::uno::Sequence<OUString> aBulletFonts
+ = officecfg::Office::Common::BulletsNumbering::DefaultBulletsFonts::get();
+ for (sal_Int32 i = 0; i < aBulletSymbols.getLength(); i++)
+ {
+ if (aBulletSymbols[i] == aSymbol && aBulletFonts[i] == aFont)
+ return true;
+ }
+ return false;
+}
+}
- sal_Int32 nSelItem;
- if ( rEvent.State >>= nSelItem )
- mxValueSet->SelectItem( nSelItem );
+void NumberingPopup::statusChanged( const css::frame::FeatureStateEvent& rEvent )
+{
+ if (rEvent.FeatureURL.Complete == ".uno:DocumentBulletList")
+ {
+ css::uno::Sequence<OUString> aSeq;
+ if (rEvent.State >>= aSeq)
+ {
+ std::vector<std::pair<OUString, OUString>> aList;
+ mxValueSetDoc->Clear();
+ int i = 1;
+ // The string contains the bullet as first character, and then the font name
+ for (const OUString& sBulletFont : aSeq)
+ {
+ OUString sBullet(sBulletFont.copy(0, 1));
+ OUString sFont(sBulletFont.copy(1, sBulletFont.getLength() - 1));
+ if (lcl_BulletIsDefault(sBullet, sFont))
+ continue;
+ mxValueSetDoc->InsertItem(i, sBullet, i);
+ aList.emplace_back(sBullet, sFont);
+ i++;
+ }
+ if (!aList.empty())
+ {
+ mxValueSetWinDoc->show();
+ mxDocBulletsLabel->show();
+ mxValueSetDoc->SetCustomBullets(aList);
+ }
+ else
+ {
+ mxValueSetWinDoc->hide();
+ mxDocBulletsLabel->hide();
+ }
+ }
+ }
+ else
+ {
+ mxValueSet->SetNoSelection();
+ sal_Int32 nSelItem;
+ if ( rEvent.State >>= nSelItem )
+ mxValueSet->SelectItem( nSelItem );
+ }
}
IMPL_LINK_NOARG(NumberingPopup, VSSelectValueSetHdl, ValueSet*, void)
@@ -135,7 +211,7 @@ IMPL_LINK_NOARG(NumberingPopup, VSSelectValueSetHdl, ValueSet*, void)
sal_uInt16 nSelItem = mxValueSet->GetSelectedItemId();
if ( mePageType == NumberingPageType::BULLET )
{
- auto aArgs( comphelper::InitPropertySequence( { { "SetBullet", css::uno::Any( nSelItem ) } } ) );
+ auto aArgs( comphelper::InitPropertySequence( { { "BulletIndex", css::uno::Any( nSelItem ) } } ) );
mrController.dispatchCommand( u".uno:SetBullet"_ustr, aArgs );
}
else if ( mePageType == NumberingPageType::SINGLENUM )
@@ -151,6 +227,18 @@ IMPL_LINK_NOARG(NumberingPopup, VSSelectValueSetHdl, ValueSet*, void)
mrController.EndPopupMode();
}
+IMPL_LINK_NOARG(NumberingPopup, VSSelectValueSetDocHdl, ValueSet*, void)
+{
+ sal_uInt16 nSelItem = mxValueSetDoc->GetSelectedItemId() - 1;
+ auto aCustomBullets = mxValueSetDoc->GetCustomBullets();
+ OUString nChar(aCustomBullets[nSelItem].first);
+ OUString sFont(aCustomBullets[nSelItem].second);
+ auto aArgs(comphelper::InitPropertySequence(
+ { { "BulletChar", css::uno::Any(nChar) }, { "BulletFont", css::uno::Any(sFont) } }));
+ mrController.dispatchCommand(".uno:SetBullet", aArgs);
+ mrController.EndPopupMode();
+}
+
void NumberingPopup::GrabFocus()
{
mxValueSet->GrabFocus();