diff options
author | Vasily Melenchuk <Vasily.Melenchuk@cib.de> | 2018-06-26 11:24:43 +0300 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2018-06-28 14:02:46 +0200 |
commit | d77f8eef165a7c6fd97cc06dcbc4ead55e7b633c (patch) | |
tree | ac7db08c222abe22975cce394830003232d24025 /framework | |
parent | tdf#117866 cui personalization: fix a possible race (diff) | |
download | core-d77f8eef165a7c6fd97cc06dcbc4ead55e7b633c.tar.gz core-d77f8eef165a7c6fd97cc06dcbc4ead55e7b633c.zip |
tdf#86612: statusbar: hide some elements if width is not sufficient
new statusbar element property mandatory=true/false to determine
if this element can be hidden if total statusbar width is not
enough to fit all elements.
marked some calc and draw statusbar elements as not mandatory.
Change-Id: I20e26d3c4bd865e94ea48632a1e97d55f3fa712f
Reviewed-on: https://gerrit.libreoffice.org/56443
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/dtd/statusbar.dtd | 1 | ||||
-rw-r--r-- | framework/inc/xml/statusbardocumenthandler.hxx | 1 | ||||
-rw-r--r-- | framework/source/fwe/classes/addonsoptions.cxx | 14 | ||||
-rw-r--r-- | framework/source/fwe/xml/statusbardocumenthandler.cxx | 29 | ||||
-rw-r--r-- | framework/source/uielement/statusbarmanager.cxx | 3 | ||||
-rw-r--r-- | framework/source/uielement/statusbarmerger.cxx | 5 |
6 files changed, 47 insertions, 6 deletions
diff --git a/framework/dtd/statusbar.dtd b/framework/dtd/statusbar.dtd index 22513df9250e..9f4e9e2a35c3 100644 --- a/framework/dtd/statusbar.dtd +++ b/framework/dtd/statusbar.dtd @@ -33,6 +33,7 @@ statusbar:align %alignment; "center" statusbar:style %style; "in" statusbar:autosize %boolean; "false" + statusbar:mandatory %boolean; "true" statusbar:ownerdraw %boolean; "false" statusbar:width %numeric; "0" statusbar:offset %numeric; "5" diff --git a/framework/inc/xml/statusbardocumenthandler.hxx b/framework/inc/xml/statusbardocumenthandler.hxx index bc12c5a724a1..759699aa61ce 100644 --- a/framework/inc/xml/statusbardocumenthandler.hxx +++ b/framework/inc/xml/statusbardocumenthandler.hxx @@ -53,6 +53,7 @@ class FWE_DLLPUBLIC OReadStatusBarDocumentHandler : public OReadStatusBarDocumen SB_ATTRIBUTE_WIDTH, SB_ATTRIBUTE_OFFSET, SB_ATTRIBUTE_HELPURL, + SB_ATTRIBUTE_MANDATORY, SB_XML_ENTRY_COUNT }; diff --git a/framework/source/fwe/classes/addonsoptions.cxx b/framework/source/fwe/classes/addonsoptions.cxx index 0ed4c5b45833..8c45c86157ea 100644 --- a/framework/source/fwe/classes/addonsoptions.cxx +++ b/framework/source/fwe/classes/addonsoptions.cxx @@ -71,7 +71,8 @@ using namespace ::com::sun::star; #define INDEX_ALIGN 8 #define INDEX_AUTOSIZE 9 #define INDEX_OWNERDRAW 10 -#define PROPERTYCOUNT_INDEX 11 +#define INDEX_MANDATORY 11 +#define PROPERTYCOUNT_INDEX 12 // The following order is mandatory. Please add properties at the end! #define PROPERTYCOUNT_MENUITEM 6 @@ -100,14 +101,15 @@ using namespace ::com::sun::star; #define OFFSET_TOOLBARITEM_WIDTH 6 // The following order is mandatory. Please add properties at the end! -#define PROPERTYCOUNT_STATUSBARITEM 7 +#define PROPERTYCOUNT_STATUSBARITEM 8 #define OFFSET_STATUSBARITEM_URL 0 #define OFFSET_STATUSBARITEM_TITLE 1 #define OFFSET_STATUSBARITEM_CONTEXT 2 #define OFFSET_STATUSBARITEM_ALIGN 3 #define OFFSET_STATUSBARITEM_AUTOSIZE 4 #define OFFSET_STATUSBARITEM_OWNERDRAW 5 -#define OFFSET_STATUSBARITEM_WIDTH 6 +#define OFFSET_STATUSBARITEM_MANDATORY 6 +#define OFFSET_STATUSBARITEM_WIDTH 7 // The following order is mandatory. Please add properties at the end! #define PROPERTYCOUNT_IMAGES 8 @@ -331,6 +333,7 @@ AddonsOptions_Impl::AddonsOptions_Impl() m_aPropNames[ INDEX_ALIGN ] = "Alignment"; m_aPropNames[ INDEX_AUTOSIZE ] = "AutoSize"; m_aPropNames[ INDEX_OWNERDRAW ] = "OwnerDraw"; + m_aPropNames[ INDEX_MANDATORY ] = "Mandatory"; // initialize array with fixed images property names m_aPropImagesNames[ OFFSET_IMAGES_SMALL ] = "ImageSmall"; @@ -1001,6 +1004,7 @@ bool AddonsOptions_Impl::ReadMergeStatusbarData( aStatusbarItem[ OFFSET_STATUSBARITEM_ALIGN ].Name = m_aPropNames[ INDEX_ALIGN ]; aStatusbarItem[ OFFSET_STATUSBARITEM_AUTOSIZE ].Name = m_aPropNames[ INDEX_AUTOSIZE ]; aStatusbarItem[ OFFSET_STATUSBARITEM_OWNERDRAW ].Name = m_aPropNames[ INDEX_OWNERDRAW ]; + aStatusbarItem[ OFFSET_STATUSBARITEM_MANDATORY ].Name = m_aPropNames[ INDEX_MANDATORY ]; aStatusbarItem[ OFFSET_STATUSBARITEM_WIDTH ].Name = m_aPropNames[ INDEX_WIDTH ]; sal_uInt32 nCount = aAddonStatusbarItemSetNodeSeq.getLength(); @@ -1039,6 +1043,7 @@ bool AddonsOptions_Impl::ReadStatusBarItem( aStatusbarItem[ OFFSET_STATUSBARITEM_ALIGN ].Value = aStatusbarItemNodePropValues[ OFFSET_STATUSBARITEM_ALIGN ]; aStatusbarItem[ OFFSET_STATUSBARITEM_AUTOSIZE ].Value = aStatusbarItemNodePropValues[ OFFSET_STATUSBARITEM_AUTOSIZE ]; aStatusbarItem[ OFFSET_STATUSBARITEM_OWNERDRAW ].Value = aStatusbarItemNodePropValues[ OFFSET_STATUSBARITEM_OWNERDRAW ]; + aStatusbarItem[ OFFSET_STATUSBARITEM_MANDATORY ].Value = aStatusbarItemNodePropValues[ OFFSET_STATUSBARITEM_MANDATORY ]; // Configuration uses hyper for long. Therefore transform into sal_Int32 sal_Int64 nValue( 0 ); @@ -1448,7 +1453,8 @@ Sequence< ::rtl::OUString > AddonsOptions_Impl::GetPropertyNamesStatusbarItem( lResult[3] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_ALIGN ] ); lResult[4] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_AUTOSIZE ] ); lResult[5] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_OWNERDRAW ] ); - lResult[6] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_WIDTH ] ); + lResult[6] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_MANDATORY ] ); + lResult[7] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_WIDTH ] ); return lResult; } diff --git a/framework/source/fwe/xml/statusbardocumenthandler.cxx b/framework/source/fwe/xml/statusbardocumenthandler.cxx index 0599b5bbb265..497170750b6f 100644 --- a/framework/source/fwe/xml/statusbardocumenthandler.cxx +++ b/framework/source/fwe/xml/statusbardocumenthandler.cxx @@ -56,6 +56,7 @@ using namespace ::com::sun::star::container; #define ATTRIBUTE_AUTOSIZE "autosize" #define ATTRIBUTE_OWNERDRAW "ownerdraw" #define ATTRIBUTE_HELPURL "helpid" +#define ATTRIBUTE_MANDATORY "mandatory" #define ELEMENT_NS_STATUSBAR "statusbar:statusbar" #define ELEMENT_NS_STATUSBARITEM "statusbar:statusbaritem" @@ -140,7 +141,8 @@ StatusBarEntryProperty const StatusBarEntries[OReadStatusBarDocumentHandler::SB_ { OReadStatusBarDocumentHandler::SB_NS_STATUSBAR, ATTRIBUTE_OWNERDRAW }, { OReadStatusBarDocumentHandler::SB_NS_STATUSBAR, ATTRIBUTE_WIDTH }, { OReadStatusBarDocumentHandler::SB_NS_STATUSBAR, ATTRIBUTE_OFFSET }, - { OReadStatusBarDocumentHandler::SB_NS_STATUSBAR, ATTRIBUTE_HELPURL } + { OReadStatusBarDocumentHandler::SB_NS_STATUSBAR, ATTRIBUTE_HELPURL }, + { OReadStatusBarDocumentHandler::SB_NS_STATUSBAR, ATTRIBUTE_MANDATORY } }; OReadStatusBarDocumentHandler::OReadStatusBarDocumentHandler( @@ -232,7 +234,7 @@ void SAL_CALL OReadStatusBarDocumentHandler::startElement( OUString aCommandURL; OUString aHelpURL; - sal_Int16 nItemBits( ItemStyle::ALIGN_CENTER|ItemStyle::DRAW_IN3D ); + sal_Int16 nItemBits( ItemStyle::ALIGN_CENTER|ItemStyle::DRAW_IN3D|ItemStyle::MANDATORY ); sal_Int16 nWidth( 0 ); sal_Int16 nOffset( STATUSBAR_OFFSET ); bool bCommandURL( false ); @@ -350,6 +352,21 @@ void SAL_CALL OReadStatusBarDocumentHandler::startElement( } break; + case SB_ATTRIBUTE_MANDATORY: + { + if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_BOOLEAN_TRUE ) + nItemBits |= ItemStyle::MANDATORY; + else if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_BOOLEAN_FALSE ) + nItemBits &= ~ItemStyle::MANDATORY; + else + { + OUString aErrorMessage = getErrorLineString(); + aErrorMessage += "Attribute statusbar:mandatory must have value 'true' or 'false'!"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } + } + break; + default: break; } @@ -631,6 +648,14 @@ void OWriteStatusBarDocumentHandler::WriteStatusBarItem( OUString::number( nOffset ) ); } + // mandatory (default sal_True) + if ( !( nStyle & ItemStyle::MANDATORY ) ) + { + pList->AddAttribute( m_aXMLStatusBarNS + ATTRIBUTE_MANDATORY, + m_aAttributeType, + ATTRIBUTE_BOOLEAN_FALSE ); + } + m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); m_xWriteDocumentHandler->startElement( ELEMENT_NS_STATUSBARITEM, xList ); m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); diff --git a/framework/source/uielement/statusbarmanager.cxx b/framework/source/uielement/statusbarmanager.cxx index 2cc90fd8293e..df5421a58e69 100644 --- a/framework/source/uielement/statusbarmanager.cxx +++ b/framework/source/uielement/statusbarmanager.cxx @@ -113,6 +113,9 @@ StatusBarItemBits impl_convertItemStyleToItemBits( sal_Int16 nStyle ) if ( nStyle & css::ui::ItemStyle::OWNER_DRAW ) nItemBits |= StatusBarItemBits::UserDraw; + if ( nStyle & css::ui::ItemStyle::MANDATORY ) + nItemBits |= StatusBarItemBits::Mandatory; + return nItemBits; } diff --git a/framework/source/uielement/statusbarmerger.cxx b/framework/source/uielement/statusbarmerger.cxx index 41719b2e24a8..7239fb5b20cc 100644 --- a/framework/source/uielement/statusbarmerger.cxx +++ b/framework/source/uielement/statusbarmerger.cxx @@ -38,6 +38,7 @@ void lcl_ConvertSequenceToValues( OUString sAlignment; bool bAutoSize = false; bool bOwnerDraw = false; + bool bMandatory = true; PropertyValue aPropVal; for ( sal_Int32 i = 0; i < rSequence.getLength(); i++ ) @@ -55,6 +56,8 @@ void lcl_ConvertSequenceToValues( aPropVal.Value >>= bAutoSize; else if ( aPropVal.Name == "OwnerDraw" ) aPropVal.Value >>= bOwnerDraw; + else if ( aPropVal.Name == "Mandatory" ) + aPropVal.Value >>= bMandatory; else if ( aPropVal.Name == "Width" ) { sal_Int32 aWidth = 0; @@ -68,6 +71,8 @@ void lcl_ConvertSequenceToValues( nItemBits |= StatusBarItemBits::AutoSize; if ( bOwnerDraw ) nItemBits |= StatusBarItemBits::UserDraw; + if ( bMandatory ) + nItemBits |= StatusBarItemBits::Mandatory; if ( sAlignment == "center" ) nItemBits |= StatusBarItemBits::Center; else if ( sAlignment == "right" ) |