diff options
Diffstat (limited to 'sc/source/ui')
-rw-r--r-- | sc/source/ui/dbgui/fieldwnd.cxx | 60 | ||||
-rw-r--r-- | sc/source/ui/inc/fieldwnd.hxx | 9 | ||||
-rw-r--r-- | sc/source/ui/view/output2.cxx | 6 |
3 files changed, 54 insertions, 21 deletions
diff --git a/sc/source/ui/dbgui/fieldwnd.cxx b/sc/source/ui/dbgui/fieldwnd.cxx index e20542bfedf6..4d3c478d9068 100644 --- a/sc/source/ui/dbgui/fieldwnd.cxx +++ b/sc/source/ui/dbgui/fieldwnd.cxx @@ -31,12 +31,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" - - #include <vcl/virdev.hxx> #include <vcl/decoview.hxx> #include <vcl/svapp.hxx> - +#include <vcl/mnemonic.hxx> +#include <vcl/help.hxx> #include <tools/debug.hxx> #include "fieldwnd.hxx" @@ -44,10 +43,7 @@ #include "pvglob.hxx" #include "AccessibleDataPilotControl.hxx" #include "scresid.hxx" -#ifndef SC_SC_HRC #include "sc.hrc" -#endif -#include <vcl/mnemonic.hxx> const size_t INVALID_INDEX = static_cast< size_t >( -1 ); @@ -238,27 +234,44 @@ void ScDPFieldWindow::DrawBackground( OutputDevice& rDev ) } void ScDPFieldWindow::DrawField( - OutputDevice& rDev, const Rectangle& rRect, const String& rText, bool bFocus ) + OutputDevice& rDev, const Rectangle& rRect, FieldString& rText, bool bFocus ) { VirtualDevice aVirDev( rDev ); // #i97623# VirtualDevice is always LTR while other windows derive direction from parent aVirDev.EnableRTL( IsRTLEnabled() ); + String aText = rText.first; Size aDevSize( rRect.GetSize() ); long nWidth = aDevSize.Width(); long nHeight = aDevSize.Height(); - long nLabelWidth = rDev.GetTextWidth( rText ); + long nLabelWidth = rDev.GetTextWidth( aText ); long nLabelHeight = rDev.GetTextHeight(); - Point aLabelPos( - ((nWidth > nLabelWidth + 6) ? (nWidth - nLabelWidth) / 2 : 3), - ((nHeight > nLabelHeight + 6) ? (nHeight - nLabelHeight) / 2 : 3) ); + + // #i31600# if text is too long, cut and add ellipsis + rText.second = nLabelWidth + 6 <= nWidth; + if( !rText.second ) + { + xub_StrLen nMinLen = 0; + xub_StrLen nMaxLen = aText.Len(); + bool bFits = false; + do + { + xub_StrLen nCurrLen = (nMinLen + nMaxLen) / 2; + aText = String( rText.first, 0, nCurrLen ).AppendAscii( "..." ); + nLabelWidth = rDev.GetTextWidth( aText ); + bFits = nLabelWidth + 6 <= nWidth; + (bFits ? nMinLen : nMaxLen) = nCurrLen; + } + while( !bFits || (nMinLen + 1 < nMaxLen) ); + } + Point aLabelPos( (nWidth - nLabelWidth) / 2, ::std::max< long >( (nHeight - nLabelHeight) / 2, 3 ) ); aVirDev.SetOutputSizePixel( aDevSize ); aVirDev.SetFont( rDev.GetFont() ); DecorationView aDecoView( &aVirDev ); aDecoView.DrawButton( Rectangle( Point( 0, 0 ), aDevSize ), bFocus ? BUTTON_DRAW_DEFAULT : 0 ); aVirDev.SetTextColor( aTextColor ); - aVirDev.DrawText( aLabelPos, rText ); + aVirDev.DrawText( aLabelPos, aText ); rDev.DrawBitmap( rRect.TopLeft(), aVirDev.GetBitmap( Point( 0, 0 ), aDevSize ) ); } @@ -292,7 +305,7 @@ void ScDPFieldWindow::Redraw() if( HasFocus() && (nFieldSelected < aFieldArr.size()) ) { long nFieldWidth = aFieldRect.GetWidth(); - long nSelectionWidth = Min( GetTextWidth( aFieldArr[ nFieldSelected ] ) + 4, nFieldWidth - 6 ); + long nSelectionWidth = Min( GetTextWidth( aFieldArr[ nFieldSelected ].first ) + 4, nFieldWidth - 6 ); Rectangle aSelection( GetFieldPosition( nFieldSelected ) + Point( (nFieldWidth - nSelectionWidth) / 2, 3 ), Size( nSelectionWidth, aFieldRect.GetHeight() - 6 ) ); @@ -320,6 +333,11 @@ bool ScDPFieldWindow::IsExistingIndex( size_t nIndex ) const return nIndex < aFieldArr.size(); } +bool ScDPFieldWindow::IsShortenedText( size_t nIndex ) const +{ + return (nIndex < aFieldArr.size()) && !aFieldArr[ nIndex ].second; +} + size_t ScDPFieldWindow::CalcNewFieldIndex( SCsCOL nDX, SCsROW nDY ) const { size_t nNewField = nFieldSelected; @@ -513,6 +531,14 @@ void __EXPORT ScDPFieldWindow::MouseMove( const MouseEvent& rMEvt ) PointerStyle ePtr = pDlg->NotifyMouseMove( OutputToScreenPixel( rMEvt.GetPosPixel() ) ); SetPointer( Pointer( ePtr ) ); } + size_t nIndex = 0; + if( GetFieldIndex( rMEvt.GetPosPixel(), nIndex ) && IsShortenedText( nIndex ) ) + { + Point aPos = OutputToScreenPixel( rMEvt.GetPosPixel() ); + Rectangle aRect( aPos, GetSizePixel() ); + String aHelpText = GetFieldText(nIndex); + Help::ShowQuickHelp( this, aRect, aHelpText ); + } } void __EXPORT ScDPFieldWindow::KeyInput( const KeyEvent& rKEvt ) @@ -598,7 +624,7 @@ void ScDPFieldWindow::AddField( const String& rText, size_t nNewIndex ) DBG_ASSERT( nNewIndex == aFieldArr.size(), "ScDPFieldWindow::AddField - invalid index" ); if( IsValidIndex( nNewIndex ) ) { - aFieldArr.push_back( rText ); + aFieldArr.push_back( FieldString( rText, true ) ); if (pAccessible) { com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible; @@ -646,7 +672,7 @@ void ScDPFieldWindow::SetFieldText( const String& rText, size_t nIndex ) { if( IsExistingIndex( nIndex ) ) { - aFieldArr[ nIndex ] = rText; + aFieldArr[ nIndex ] = FieldString( rText, true ); Redraw(); if (pAccessible) @@ -663,7 +689,7 @@ void ScDPFieldWindow::SetFieldText( const String& rText, size_t nIndex ) const String& ScDPFieldWindow::GetFieldText( size_t nIndex ) const { if( IsExistingIndex( nIndex ) ) - return aFieldArr[ nIndex ]; + return aFieldArr[ nIndex ].first; return EMPTY_STRING; } @@ -680,7 +706,7 @@ bool ScDPFieldWindow::AddField( const String& rText, const Point& rPos, size_t& if( nNewIndex > aFieldArr.size() ) nNewIndex = aFieldArr.size(); - aFieldArr.insert( aFieldArr.begin() + nNewIndex, rText ); + aFieldArr.insert( aFieldArr.begin() + nNewIndex, FieldString( rText, true ) ); nFieldSelected = nNewIndex; Redraw(); rnIndex = nNewIndex; diff --git a/sc/source/ui/inc/fieldwnd.hxx b/sc/source/ui/inc/fieldwnd.hxx index 5b24b5fea3df..ae2dbf1ffb52 100644 --- a/sc/source/ui/inc/fieldwnd.hxx +++ b/sc/source/ui/inc/fieldwnd.hxx @@ -68,12 +68,14 @@ enum ScDPFieldType class ScDPFieldWindow : public Control { private: + typedef ::std::pair< String, bool > FieldString; // true = text fits into button + String aName; /// name of the control, used in Accessibility ScDPLayoutDlg* pDlg; /// Parent dialog. Rectangle aWndRect; /// Area rectangle in pixels. FixedText* pFtCaption; /// FixedText containing the name of the control. Point aTextPos; /// Position of the caption text. - std::vector< String > aFieldArr; /// Pointer to string array of the field names. + std::vector< FieldString > aFieldArr; /// String array of the field names and flags, if text fits into button. ScDPFieldType eType; /// Type of this area. Color aFaceColor; /// Color for dialog background. Color aWinColor; /// Color for window background. @@ -97,13 +99,16 @@ private: void DrawField( OutputDevice& rDev, const Rectangle& rRect, - const String& rText, + FieldString& rText, bool bFocus ); /** @return TRUE, if the field index is inside of the control area. */ bool IsValidIndex( size_t nIndex ) const; /** @return TRUE, if the field with the given index exists. */ bool IsExistingIndex( size_t nIndex ) const; + /** @return TRUE, if the field with the given index exists and the text is + too long for the button control. */ + bool IsShortenedText( size_t nIndex ) const; /** @return The new selection index after moving to the given direction. */ size_t CalcNewFieldIndex( SCsCOL nDX, SCsROW nDY ) const; diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index e41bd4941d9c..dd76058756a1 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -1358,11 +1358,13 @@ void ScOutputData::DrawStrings( BOOL bPixelToLogic ) } if (bDoCell && !bNeedEdit) { - if ( pCell->GetCellType() == CELLTYPE_FORMULA ) + BOOL bFormulaCell = (pCell->GetCellType() == CELLTYPE_FORMULA ); + if ( bFormulaCell ) lcl_CreateInterpretProgress( bProgress, pDoc, (ScFormulaCell*)pCell ); if ( aVars.SetText(pCell) ) pOldPattern = NULL; - bNeedEdit = aVars.HasEditCharacters(); + bNeedEdit = aVars.HasEditCharacters() || + (bFormulaCell && ((ScFormulaCell*)pCell)->IsMultilineResult()); } if (bDoCell && !bNeedEdit) { |