diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2015-11-14 23:34:37 +0200 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2015-11-14 23:02:47 +0000 |
commit | 7272e8df62a12d6172b297d7a82a0265cd1bc44a (patch) | |
tree | c7d457a98fdaf19f90bd97558badc38ad9e61032 /svx | |
parent | 2faf5622664c322f0516dd2484fc154ae504049a (diff) |
tdf#95403 Add Outline button
Change-Id: I0d5187ed34539a05ab9f2ffdfb89118df0aa3511
Reviewed-on: https://gerrit.libreoffice.org/19964
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/sdi/svx.sdi | 47 | ||||
-rw-r--r-- | svx/source/dialog/svxbmpnumvalueset.cxx | 2 | ||||
-rw-r--r-- | svx/source/tbxctrls/bulletsnumbering.cxx | 97 |
3 files changed, 106 insertions, 40 deletions
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi index b5e87ad34615..51b6e8091ffe 100644 --- a/svx/sdi/svx.sdi +++ b/svx/sdi/svx.sdi @@ -16444,3 +16444,50 @@ SfxVoidItem ParaspaceIncrease SID_PARASPACE_INCREASE ToolBoxConfig = TRUE, GroupId = GID_FORMAT; ] + +SfxVoidItem SetOutline FN_SVX_SET_OUTLINE +(SfxUInt16Item SetOutline FN_SVX_SET_OUTLINE) +[ + /* flags: */ + AutoUpdate = TRUE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + /* config: */ + AccelConfig = FALSE, + MenuConfig = FALSE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_ENUMERATION; +] + +SfxUInt16Item CurrentOutlineType FN_OUTLINE_RULE_INDEX +[ + /* flags: */ + AutoUpdate = TRUE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + /* config: */ + AccelConfig = FALSE, + MenuConfig = FALSE, + StatusBarConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = GID_ENUMERATION; +] diff --git a/svx/source/dialog/svxbmpnumvalueset.cxx b/svx/source/dialog/svxbmpnumvalueset.cxx index 18884050b214..953f062a2095 100644 --- a/svx/source/dialog/svxbmpnumvalueset.cxx +++ b/svx/source/dialog/svxbmpnumvalueset.cxx @@ -246,6 +246,7 @@ void SvxNumValueSet::UserDraw( const UserDrawEvent& rUDEvt ) // Outline numbering has to be painted into the virtual device // to get correct lines // has to be made again + pVDev->SetLineColor(aBackColor); pVDev->DrawRect(aOrgRect); long nStartX = aOrgRect.TopLeft().X(); long nStartY = aOrgRect.TopLeft().Y(); @@ -352,6 +353,7 @@ void SvxNumValueSet::UserDraw( const UserDrawEvent& rUDEvt ) long nLineTop = nStartY + nRectHeight * aLinesArr[2 * i + 1]/100 ; Point aLineLeft(aLeft.X(), nLineTop ); Point aLineRight(nStartX + nRectWidth * 90 /100, nLineTop ); + pVDev->SetLineColor(COL_LIGHTGRAY); pVDev->DrawLine(aLineLeft, aLineRight); } diff --git a/svx/source/tbxctrls/bulletsnumbering.cxx b/svx/source/tbxctrls/bulletsnumbering.cxx index f753f238697a..305f3a3af5ed 100644 --- a/svx/source/tbxctrls/bulletsnumbering.cxx +++ b/svx/source/tbxctrls/bulletsnumbering.cxx @@ -10,7 +10,7 @@ #include <com/sun/star/text/DefaultNumberingProvider.hpp> #include <com/sun/star/text/XNumberingFormatter.hpp> -#include <comphelper/processfactory.hxx> +#include <comphelper/propertysequence.hxx> #include <i18nlangtag/mslangid.hxx> #include <sfx2/imagemgr.hxx> #include <svtools/popupwindowcontroller.hxx> @@ -25,7 +25,7 @@ class NumberingToolBoxControl; class NumberingPopup : public svtools::ToolbarMenu { - bool mbBulletItem; + NumberingPageType mePageType; NumberingToolBoxControl& mrController; VclPtr<SvxNumValueSet> mpValueSet; DECL_LINK_TYPED( VSSelectToolbarMenuHdl, ToolbarMenu*, void ); @@ -34,7 +34,7 @@ class NumberingPopup : public svtools::ToolbarMenu public: NumberingPopup( NumberingToolBoxControl& rController, const css::uno::Reference< css::frame::XFrame >& rFrame, - vcl::Window* pParent, bool bBulletItem ); + vcl::Window* pParent, NumberingPageType ePageType ); virtual ~NumberingPopup(); virtual void dispose() override; @@ -44,7 +44,7 @@ public: class NumberingToolBoxControl : public svt::PopupWindowController { - bool mbBulletItem; + NumberingPageType mePageType; public: explicit NumberingToolBoxControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); @@ -71,31 +71,35 @@ public: //class NumberingPopup NumberingPopup::NumberingPopup( NumberingToolBoxControl& rController, const css::uno::Reference< css::frame::XFrame >& rFrame, - vcl::Window* pParent, bool bBulletItem ) : + vcl::Window* pParent, NumberingPageType ePageType ) : ToolbarMenu( rFrame, pParent, WB_STDPOPUP ), - mbBulletItem( bBulletItem ), + mePageType( ePageType ), mrController( rController ) { WinBits nBits = WB_TABSTOP | WB_MENUSTYLEVALUESET | WB_FLATVALUESET | WB_NO_DIRECTSELECT; mpValueSet = VclPtr<SvxNumValueSet>::Create( this, nBits ); - mpValueSet->init( mbBulletItem ? NumberingPageType::BULLET : NumberingPageType::SINGLENUM ); + mpValueSet->init( mePageType ); - if ( !mbBulletItem ) + if ( mePageType != NumberingPageType::BULLET ) { - css::uno::Reference< css::text::XDefaultNumberingProvider > xDefNum = css::text::DefaultNumberingProvider::create( comphelper::getProcessComponentContext() ); + css::uno::Reference< css::text::XDefaultNumberingProvider > xDefNum = css::text::DefaultNumberingProvider::create( mrController.getContext() ); if ( xDefNum.is() ) { - css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > aNumberings; css::lang::Locale aLocale = GetSettings().GetLanguageTag().getLocale(); - try + css::uno::Reference< css::text::XNumberingFormatter > xFormat( xDefNum, css::uno::UNO_QUERY ); + + if ( mePageType == NumberingPageType::SINGLENUM ) { - aNumberings = xDefNum->getDefaultContinuousNumberingLevels( aLocale ); + css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > aNumberings( + xDefNum->getDefaultContinuousNumberingLevels( aLocale ) ); + mpValueSet->SetNumberingSettings( aNumberings, xFormat, aLocale ); + } + else if ( mePageType == NumberingPageType::OUTLINE ) + { + css::uno::Sequence< css::uno::Reference< css::container::XIndexAccess > > aOutline( + xDefNum->getDefaultOutlineNumberings( aLocale ) ); + mpValueSet->SetOutlineNumberingSettings( aOutline, xFormat, aLocale ); } - catch( css::uno::Exception& ) - {} - - css::uno::Reference< css::text::XNumberingFormatter > xFormat( xDefNum, css::uno::UNO_QUERY ); - mpValueSet->SetNumberingSettings( aNumberings, xFormat, aLocale ); } } @@ -107,19 +111,28 @@ NumberingPopup::NumberingPopup( NumberingToolBoxControl& rController, appendEntry( 0, mpValueSet ); appendSeparator(); - if ( mbBulletItem ) - appendEntry( 1, SVX_RESSTR( RID_SVXSTR_MOREBULLETS ), ::GetImage( rFrame, ".uno:OutlineBullet", false ) ); + OUString aMoreItemText; + if ( mePageType == NumberingPageType::BULLET ) + { + aMoreItemText = SVX_RESSTR( RID_SVXSTR_MOREBULLETS ); + AddStatusListener( ".uno:CurrentBulletListType" ); + } + else if ( mePageType == NumberingPageType::SINGLENUM ) + { + aMoreItemText = SVX_RESSTR( RID_SVXSTR_MORENUMBERING ); + AddStatusListener( ".uno:CurrentNumListType" ); + } else - appendEntry( 1, SVX_RESSTR( RID_SVXSTR_MORENUMBERING ), ::GetImage( rFrame, ".uno:OutlineBullet", false ) ); + { + aMoreItemText = SVX_RESSTR( RID_SVXSTR_MORE ); + AddStatusListener( ".uno:CurrentOutlineType" ); + } + + appendEntry( 1, aMoreItemText, ::GetImage( rFrame, ".uno:OutlineBullet", false ) ); SetOutputSizePixel( getMenuSize() ); mpValueSet->SetSelectHdl( LINK( this, NumberingPopup, VSSelectValueSetHdl ) ); SetSelectHdl( LINK( this, NumberingPopup, VSSelectToolbarMenuHdl ) ); - - if ( mbBulletItem ) - AddStatusListener( ".uno:CurrentBulletListType" ); - else - AddStatusListener( ".uno:CurrentNumListType" ); } NumberingPopup::~NumberingPopup() @@ -160,19 +173,21 @@ void NumberingPopup::VSSelectHdl(void* pControl) if ( pControl == mpValueSet ) { sal_uInt16 nSelItem = mpValueSet->GetSelectItemId(); - css::uno::Sequence< css::beans::PropertyValue > aArgs( 1 ); - if ( mbBulletItem ) + if ( mePageType == NumberingPageType::BULLET ) { - aArgs[0].Name = "SetBullet"; - aArgs[0].Value <<= sal_uInt16( nSelItem ); + auto aArgs( comphelper::InitPropertySequence( { { "SetBullet", css::uno::makeAny( nSelItem ) } } ) ); mrController.dispatchCommand( ".uno:SetBullet", aArgs ); } - else + else if ( mePageType == NumberingPageType::SINGLENUM ) { - aArgs[0].Name = "SetNumber"; - aArgs[0].Value <<= sal_uInt16( nSelItem ); + auto aArgs( comphelper::InitPropertySequence( { { "SetNumber", css::uno::makeAny( nSelItem ) } } ) ); mrController.dispatchCommand( ".uno:SetNumber", aArgs ); } + else + { + auto aArgs( comphelper::InitPropertySequence( { { "SetOutline", css::uno::makeAny( nSelItem ) } } ) ); + mrController.dispatchCommand( ".uno:SetOutline", aArgs ); + } } else if ( getSelectedEntryId() == 1 ) { @@ -183,9 +198,7 @@ void NumberingPopup::VSSelectHdl(void* pControl) // Writer variants aPageName = "options"; - css::uno::Sequence< css::beans::PropertyValue > aArgs( 1 ); - aArgs[0].Name = "Page"; - aArgs[0].Value <<= aPageName; + auto aArgs( comphelper::InitPropertySequence( { { "Page", css::uno::makeAny( aPageName ) } } ) ); mrController.dispatchCommand( ".uno:OutlineBullet", aArgs ); } } @@ -194,13 +207,13 @@ void NumberingPopup::VSSelectHdl(void* pControl) //class NumberingToolBoxControl NumberingToolBoxControl::NumberingToolBoxControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext ): svt::PopupWindowController( rxContext, css::uno::Reference< css::frame::XFrame >(), OUString() ), - mbBulletItem( false ) + mePageType( NumberingPageType::SINGLENUM ) { } VclPtr<vcl::Window> NumberingToolBoxControl::createPopupWindow( vcl::Window* pParent ) { - return VclPtr<NumberingPopup>::Create( *this, m_xFrame, pParent, mbBulletItem ); + return VclPtr<NumberingPopup>::Create( *this, m_xFrame, pParent, mePageType ); } bool NumberingToolBoxControl::IsInImpressDraw() @@ -228,12 +241,16 @@ void SAL_CALL NumberingToolBoxControl::initialize( const css::uno::Sequence< css { svt::PopupWindowController::initialize( aArguments ); + if ( m_aCommandURL == ".uno:DefaultBullet" ) + mePageType = NumberingPageType::BULLET; + else if ( m_aCommandURL == ".uno:SetOutline" ) + mePageType = NumberingPageType::OUTLINE; + + ToolBoxItemBits nBits = ( mePageType == NumberingPageType::OUTLINE ) ? ToolBoxItemBits::DROPDOWNONLY : ToolBoxItemBits::DROPDOWN; ToolBox* pToolBox = nullptr; sal_uInt16 nId = 0; if ( getToolboxId( nId, &pToolBox ) ) - pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWN ); - - mbBulletItem = m_aCommandURL == ".uno:DefaultBullet"; + pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | nBits ); } OUString SAL_CALL NumberingToolBoxControl::getImplementationName() |