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 | |
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>
-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 | ||||
-rw-r--r-- | include/vcl/status.hxx | 3 | ||||
-rw-r--r-- | offapi/com/sun/star/ui/ItemStyle.idl | 7 | ||||
-rw-r--r-- | offapi/com/sun/star/ui/XStatusbarItem.idl | 1 | ||||
-rw-r--r-- | officecfg/registry/schema/org/openoffice/Office/Addons.xcs | 6 | ||||
-rw-r--r-- | sc/uiconfig/scalc/statusbar/statusbar.xml | 6 | ||||
-rw-r--r-- | sd/uiconfig/sdraw/statusbar/statusbar.xml | 6 | ||||
-rw-r--r-- | vcl/source/window/status.cxx | 60 |
13 files changed, 117 insertions, 25 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" ) diff --git a/include/vcl/status.hxx b/include/vcl/status.hxx index 0ead49f7ddad..1fe0935fc622 100644 --- a/include/vcl/status.hxx +++ b/include/vcl/status.hxx @@ -45,10 +45,11 @@ enum class StatusBarItemBits { Flat = 0x0020, AutoSize = 0x0040, UserDraw = 0x0080, + Mandatory = 0x0100, }; namespace o3tl { - template<> struct typed_flags<StatusBarItemBits> : is_typed_flags<StatusBarItemBits, 0x00ff> {}; + template<> struct typed_flags<StatusBarItemBits> : is_typed_flags<StatusBarItemBits, 0x01ff> {}; } #define STATUSBAR_APPEND (sal_uInt16(0xFFFF)) diff --git a/offapi/com/sun/star/ui/ItemStyle.idl b/offapi/com/sun/star/ui/ItemStyle.idl index 8479bbc15a75..966a4f4e19dc 100644 --- a/offapi/com/sun/star/ui/ItemStyle.idl +++ b/offapi/com/sun/star/ui/ItemStyle.idl @@ -149,6 +149,13 @@ constants ItemStyle icon+text)</p> */ const short TEXT = 2048; + + /** marks always visible element which can not be removed when statusbar + width is not sufficient. + + @since LibreOffice 6.2 + */ + const short MANDATORY = 4096; }; }; }; }; }; diff --git a/offapi/com/sun/star/ui/XStatusbarItem.idl b/offapi/com/sun/star/ui/XStatusbarItem.idl index adec214ec5b6..faed72d9021f 100644 --- a/offapi/com/sun/star/ui/XStatusbarItem.idl +++ b/offapi/com/sun/star/ui/XStatusbarItem.idl @@ -64,6 +64,7 @@ interface XStatusbarItem </li> <li>com::sun::star::ui::ItemStyle::AUTO_SIZE</li> <li>com::sun::star::ui::ItemStyle::OWNER_DRAW</li> + <li>com::sun::star::ui::ItemStyle::MANDATORY (@since LibreOffice 6.2)</li> </ul> @see com::sun::star::ui::ItemStyle diff --git a/officecfg/registry/schema/org/openoffice/Office/Addons.xcs b/officecfg/registry/schema/org/openoffice/Office/Addons.xcs index bfcc5f34c61a..2f83bcfd8c23 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Addons.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Addons.xcs @@ -282,6 +282,12 @@ </info> <value>false</value> </prop> + <prop oor:name="Mandatory" oor:type="xs:boolean"> + <info> + <desc>Specifies whether the element can be hidden (false) or not (true) if status bar width is not sufficient to fit all elements.</desc> + </info> + <value>true</value> + </prop> <prop oor:name="Width" oor:type="xs:long"> <info> <desc>A property to define the size of a status bar item.</desc> diff --git a/sc/uiconfig/scalc/statusbar/statusbar.xml b/sc/uiconfig/scalc/statusbar/statusbar.xml index 49f69c751cb3..6fe161d9379b 100644 --- a/sc/uiconfig/scalc/statusbar/statusbar.xml +++ b/sc/uiconfig/scalc/statusbar/statusbar.xml @@ -19,14 +19,14 @@ --> <statusbar:statusbar xmlns:statusbar="http://openoffice.org/2001/statusbar" xmlns:xlink="http://www.w3.org/1999/xlink"> <statusbar:statusbaritem xlink:href=".uno:StatusDocPos" statusbar:align="left" statusbar:autosize="true" statusbar:width="58"/> - <statusbar:statusbaritem xlink:href=".uno:RowColSelCount" statusbar:align="left" statusbar:autosize="true" statusbar:width="58"/> + <statusbar:statusbaritem xlink:href=".uno:RowColSelCount" statusbar:align="left" statusbar:autosize="true" statusbar:mandatory="false" statusbar:width="58"/> <statusbar:statusbaritem xlink:href=".uno:StatusPageStyle" statusbar:align="left" statusbar:autosize="true" statusbar:width="83"/> <statusbar:statusbaritem xlink:href=".uno:LanguageStatus" statusbar:align="center" statusbar:autosize="true" statusbar:width="100"/> - <statusbar:statusbaritem xlink:href=".uno:InsertMode" statusbar:align="center" statusbar:width="55"/> + <statusbar:statusbaritem xlink:href=".uno:InsertMode" statusbar:align="center" statusbar:mandatory="false" statusbar:width="55"/> <statusbar:statusbaritem xlink:href=".uno:StatusSelectionMode" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="16"/> <statusbar:statusbaritem xlink:href=".uno:ModifiedStatus" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="16"/> <statusbar:statusbaritem xlink:href=".uno:Signature" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="16"/> - <statusbar:statusbaritem xlink:href=".uno:Size" statusbar:align="center" statusbar:autosize="true" statusbar:ownerdraw="true" statusbar:width="200"/> + <statusbar:statusbaritem xlink:href=".uno:Size" statusbar:align="center" statusbar:autosize="true" statusbar:mandatory="false" statusbar:ownerdraw="true" statusbar:width="200"/> <statusbar:statusbaritem xlink:href=".uno:ZoomSlider" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="130"/> <statusbar:statusbaritem xlink:href=".uno:Zoom" statusbar:align="center" statusbar:width="35"/> </statusbar:statusbar> diff --git a/sd/uiconfig/sdraw/statusbar/statusbar.xml b/sd/uiconfig/sdraw/statusbar/statusbar.xml index f7493de6fa74..6a975cb477de 100644 --- a/sd/uiconfig/sdraw/statusbar/statusbar.xml +++ b/sd/uiconfig/sdraw/statusbar/statusbar.xml @@ -19,9 +19,9 @@ --> <statusbar:statusbar xmlns:statusbar="http://openoffice.org/2001/statusbar" xmlns:xlink="http://www.w3.org/1999/xlink"> <statusbar:statusbaritem xlink:href=".uno:PageStatus" statusbar:align="left" statusbar:width="124"/> - <statusbar:statusbaritem xlink:href=".uno:Context" statusbar:align="left" statusbar:autosize="true" statusbar:width="184"/> - <statusbar:statusbaritem xlink:href=".uno:LayoutStatus" statusbar:align="left" statusbar:autosize="true" statusbar:width="54"/> - <statusbar:statusbaritem xlink:href=".uno:Size" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="400"/> + <statusbar:statusbaritem xlink:href=".uno:Context" statusbar:align="left" statusbar:autosize="true" statusbar:mandatory="false" statusbar:width="184"/> + <statusbar:statusbaritem xlink:href=".uno:LayoutStatus" statusbar:align="left" statusbar:autosize="true" statusbar:mandatory="false" statusbar:width="54"/> + <statusbar:statusbaritem xlink:href=".uno:Size" statusbar:align="center" statusbar:ownerdraw="true" statusbar:autosize="true" statusbar:width="200"/> <statusbar:statusbaritem xlink:href=".uno:ModifiedStatus" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="9"/> <statusbar:statusbaritem xlink:href=".uno:Signature" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="16"/> <statusbar:statusbaritem xlink:href=".uno:ZoomPage" statusbar:align="center" statusbar:ownerdraw="true" statusbar:width="9"/> diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx index 57f881cfbd48..61b467b8360d 100644 --- a/vcl/source/window/status.cxx +++ b/vcl/source/window/status.cxx @@ -217,22 +217,58 @@ void StatusBar::ImplFormat() long nExtraWidth; long nExtraWidth2; long nX; - sal_uInt16 nAutoSizeItems = 0; + sal_uInt16 nAutoSizeItems; + bool bChanged; + + do { + // sum up widths + nAutoSizeItems = 0; + mnItemsWidth = STATUSBAR_OFFSET_X; + bChanged = false; + long nOffset = 0; + for ( const auto & pItem : mvItemList ) { + if ( pItem->mbVisible ) + { + if ( pItem->mnBits & StatusBarItemBits::AutoSize ) { + nAutoSizeItems++; + } - // sum up widths - mnItemsWidth = STATUSBAR_OFFSET_X; - long nOffset = 0; - for (auto & pItem : mvItemList) { - if ( pItem->mbVisible ) - { - if ( pItem->mnBits & StatusBarItemBits::AutoSize ) { - nAutoSizeItems++; + mnItemsWidth += pItem->mnWidth + nOffset; + nOffset = pItem->mnOffset; } + } - mnItemsWidth += pItem->mnWidth + nOffset; - nOffset = pItem->mnOffset; + if ( mnDX > 0 && mnDX < mnItemsWidth ) + { + // Total width of items is more than available width + // Try to hide secondary elements, if any + for ( auto & pItem : mvItemList ) + { + if ( pItem->mbVisible && !(pItem->mnBits & StatusBarItemBits::Mandatory) ) + { + pItem->mbVisible = false; + bChanged = true; + break; + } + } } - } + else if ( mnDX > mnItemsWidth ) + { + // Width of statusbar is sufficient. + // Try to restore hidden items, if any + for ( auto & pItem : mvItemList ) + { + if ( !pItem->mbVisible && + !(pItem->mnBits & StatusBarItemBits::Mandatory) && + pItem->mnWidth + nOffset + mnItemsWidth < mnDX ) + { + pItem->mbVisible = true; + bChanged = true; + break; + } + } + } + } while ( bChanged ); if ( GetStyle() & WB_RIGHT ) { |