diff options
Diffstat (limited to 'svtools/source/control')
-rw-r--r-- | svtools/source/control/accessibleruler.cxx | 48 | ||||
-rw-r--r-- | svtools/source/control/autocmpledit.cxx | 20 | ||||
-rw-r--r-- | svtools/source/control/calendar.cxx | 158 | ||||
-rw-r--r-- | svtools/source/control/ctrlbox.cxx | 198 | ||||
-rw-r--r-- | svtools/source/control/headbar.cxx | 320 | ||||
-rw-r--r-- | svtools/source/control/inettbc.cxx | 82 | ||||
-rw-r--r-- | svtools/source/control/roadmap.cxx | 52 | ||||
-rw-r--r-- | svtools/source/control/ruler.cxx | 508 | ||||
-rw-r--r-- | svtools/source/control/tabbar.cxx | 516 | ||||
-rw-r--r-- | svtools/source/control/toolbarmenu.cxx | 102 | ||||
-rw-r--r-- | svtools/source/control/toolbarmenuacc.cxx | 60 | ||||
-rw-r--r-- | svtools/source/control/valueacc.cxx | 112 | ||||
-rw-r--r-- | svtools/source/control/valueset.cxx | 526 |
13 files changed, 1351 insertions, 1351 deletions
diff --git a/svtools/source/control/accessibleruler.cxx b/svtools/source/control/accessibleruler.cxx index d6ac5437246f..925840e335a8 100644 --- a/svtools/source/control/accessibleruler.cxx +++ b/svtools/source/control/accessibleruler.cxx @@ -256,20 +256,20 @@ void SAL_CALL SvtRulerAccessible::addAccessibleEventListener( const uno::Referen void SAL_CALL SvtRulerAccessible::removeAccessibleEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) { - if (xListener.is() && mnClientId) - { - ::osl::MutexGuard aGuard( m_aMutex ); + if (!(xListener.is() && mnClientId)) + return; - sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener ); - if ( !nListenerCount ) - { - // no listeners anymore - // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), - // and at least to us not firing any events anymore, in case somebody calls - // NotifyAccessibleEvent, again - comphelper::AccessibleEventNotifier::revokeClient( mnClientId ); - mnClientId = 0; - } + ::osl::MutexGuard aGuard( m_aMutex ); + + sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener ); + if ( !nListenerCount ) + { + // no listeners anymore + // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), + // and at least to us not firing any events anymore, in case somebody calls + // NotifyAccessibleEvent, again + comphelper::AccessibleEventNotifier::revokeClient( mnClientId ); + mnClientId = 0; } } @@ -324,19 +324,19 @@ Sequence< sal_Int8 > SAL_CALL SvtRulerAccessible::getImplementationId() void SAL_CALL SvtRulerAccessible::disposing() { - if( !rBHelper.bDisposed ) - { - ::osl::MutexGuard aGuard( m_aMutex ); - mpRepr = nullptr; // object dies with representation + if( rBHelper.bDisposed ) + return; - // Send a disposing to all listeners. - if ( mnClientId ) - { - comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this ); - mnClientId = 0; - } - mxParent.clear(); + ::osl::MutexGuard aGuard( m_aMutex ); + mpRepr = nullptr; // object dies with representation + + // Send a disposing to all listeners. + if ( mnClientId ) + { + comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this ); + mnClientId = 0; } + mxParent.clear(); } tools::Rectangle SvtRulerAccessible::GetBoundingBoxOnScreen() diff --git a/svtools/source/control/autocmpledit.cxx b/svtools/source/control/autocmpledit.cxx index 99f11b27194a..262c7341d81c 100644 --- a/svtools/source/control/autocmpledit.cxx +++ b/svtools/source/control/autocmpledit.cxx @@ -41,19 +41,19 @@ IMPL_LINK_NOARG(AutocompleteEdit, AutoCompleteHdl_Impl, Edit&, void) sal_uInt16 nLen = ( sal_uInt16 )aSelection.Min(); aCurText = aCurText.copy( 0, nLen ); - if( !aCurText.isEmpty() ) + if( aCurText.isEmpty() ) + return; + + if( m_aEntries.size() ) { - if( m_aEntries.size() ) + if( Match( aCurText ) ) { - if( Match( aCurText ) ) - { - m_nCurrent = 0; - SetText( m_aMatching[0] ); - sal_uInt16 nNewLen = m_aMatching[0].getLength(); + m_nCurrent = 0; + SetText( m_aMatching[0] ); + sal_uInt16 nNewLen = m_aMatching[0].getLength(); - Selection aSel( nLen, nNewLen ); - SetSelection( aSel ); - } + Selection aSel( nLen, nNewLen ); + SetSelection( aSel ); } } } diff --git a/svtools/source/control/calendar.cxx b/svtools/source/control/calendar.cxx index 1195fb09be50..e4bfa6e58cf4 100644 --- a/svtools/source/control/calendar.cxx +++ b/svtools/source/control/calendar.cxx @@ -957,22 +957,22 @@ void Calendar::ImplShowMenu( const Point& rPos, const Date& rDate ) nCurItemId = aPopupMenu->Execute( this, rPos ); mbMenuDown = false; - if ( nCurItemId ) - { - sal_uInt16 nTempMonthOff = nMonthOff % 12; - sal_uInt16 nTempYearOff = nMonthOff / 12; - sal_uInt16 nNewMonth = nCurItemId % 1000; - sal_uInt16 nNewYear = nYear+((nCurItemId-1000)/1000); - if ( nTempMonthOff < nNewMonth ) - nNewMonth = nNewMonth - nTempMonthOff; - else - { - nNewYear--; - nNewMonth = 12-(nTempMonthOff-nNewMonth); - } - nNewYear = nNewYear - nTempYearOff; - SetFirstDate( Date( 1, nNewMonth, nNewYear ) ); + if ( !nCurItemId ) + return; + + sal_uInt16 nTempMonthOff = nMonthOff % 12; + sal_uInt16 nTempYearOff = nMonthOff / 12; + sal_uInt16 nNewMonth = nCurItemId % 1000; + sal_uInt16 nNewYear = nYear+((nCurItemId-1000)/1000); + if ( nTempMonthOff < nNewMonth ) + nNewMonth = nNewMonth - nTempMonthOff; + else + { + nNewYear--; + nNewMonth = 12-(nTempMonthOff-nNewMonth); } + nNewYear = nNewYear - nTempYearOff; + SetFirstDate( Date( 1, nNewMonth, nNewYear ) ); } void Calendar::ImplTracking( const Point& rPos, bool bRepeat ) @@ -1026,32 +1026,32 @@ void Calendar::ImplEndTracking( bool bCancel ) } } - if ( !bSpinDown ) + if ( bSpinDown ) + return; + + if ( !bCancel ) { - if ( !bCancel ) + // determine if we should scroll the visible area + if ( !mpSelectTable->empty() ) { - // determine if we should scroll the visible area - if ( !mpSelectTable->empty() ) - { - Date aFirstSelDate( *mpSelectTable->begin() ); - Date aLastSelDate( *mpSelectTable->rbegin() ); - if ( aLastSelDate < GetFirstMonth() ) - ImplScroll( true ); - else if ( GetLastMonth() < aFirstSelDate ) - ImplScroll( false ); - } + Date aFirstSelDate( *mpSelectTable->begin() ); + Date aLastSelDate( *mpSelectTable->rbegin() ); + if ( aLastSelDate < GetFirstMonth() ) + ImplScroll( true ); + else if ( GetLastMonth() < aFirstSelDate ) + ImplScroll( false ); } + } - if ( mbAllSel || - (!bCancel && ((maCurDate != maOldCurDate) || (*mpOldSelectTable != *mpSelectTable))) ) - Select(); + if ( mbAllSel || + (!bCancel && ((maCurDate != maOldCurDate) || (*mpOldSelectTable != *mpSelectTable))) ) + Select(); - if ( !bSelection && (mnWinStyle & WB_TABSTOP) && !bCancel ) - GrabFocus(); + if ( !bSelection && (mnWinStyle & WB_TABSTOP) && !bCancel ) + GrabFocus(); - delete mpOldSelectTable; - mpOldSelectTable = nullptr; - } + delete mpOldSelectTable; + mpOldSelectTable = nullptr; } IMPL_LINK_NOARG( Calendar, ScrollHdl, Timer*, void ) @@ -1353,48 +1353,48 @@ void Calendar::SetCurDate( const Date& rNewDate ) if ( !rNewDate.IsValidAndGregorian() ) return; - if ( maCurDate != rNewDate ) - { - bool bUpdate = IsVisible() && IsUpdateMode(); - Date aOldDate = maCurDate; - maCurDate = rNewDate; - maAnchorDate = maCurDate; + if ( maCurDate == rNewDate ) + return; - ImplCalendarSelectDate( mpSelectTable, aOldDate, false ); - ImplCalendarSelectDate( mpSelectTable, maCurDate, true ); + bool bUpdate = IsVisible() && IsUpdateMode(); + Date aOldDate = maCurDate; + maCurDate = rNewDate; + maAnchorDate = maCurDate; - // shift actual date in the visible area - if ( mbFormat || (maCurDate < GetFirstMonth()) ) - SetFirstDate( maCurDate ); - else if ( maCurDate > GetLastMonth() ) + ImplCalendarSelectDate( mpSelectTable, aOldDate, false ); + ImplCalendarSelectDate( mpSelectTable, maCurDate, true ); + + // shift actual date in the visible area + if ( mbFormat || (maCurDate < GetFirstMonth()) ) + SetFirstDate( maCurDate ); + else if ( maCurDate > GetLastMonth() ) + { + Date aTempDate = GetLastMonth(); + long nDateOff = maCurDate-aTempDate; + if ( nDateOff < 365 ) { - Date aTempDate = GetLastMonth(); - long nDateOff = maCurDate-aTempDate; - if ( nDateOff < 365 ) + Date aFirstDate = GetFirstMonth(); + aFirstDate.AddDays( aFirstDate.GetDaysInMonth() ); + ++aTempDate; + while ( nDateOff > aTempDate.GetDaysInMonth() ) { - Date aFirstDate = GetFirstMonth(); aFirstDate.AddDays( aFirstDate.GetDaysInMonth() ); - ++aTempDate; - while ( nDateOff > aTempDate.GetDaysInMonth() ) - { - aFirstDate.AddDays( aFirstDate.GetDaysInMonth() ); - sal_Int32 nDaysInMonth = aTempDate.GetDaysInMonth(); - aTempDate.AddDays( nDaysInMonth ); - nDateOff -= nDaysInMonth; - } - SetFirstDate( aFirstDate ); + sal_Int32 nDaysInMonth = aTempDate.GetDaysInMonth(); + aTempDate.AddDays( nDaysInMonth ); + nDateOff -= nDaysInMonth; } - else - SetFirstDate( maCurDate ); + SetFirstDate( aFirstDate ); } else + SetFirstDate( maCurDate ); + } + else + { + if ( bUpdate ) { - if ( bUpdate ) - { - HideFocus(); - ImplUpdateDate( aOldDate ); - ImplUpdateDate( maCurDate ); - } + HideFocus(); + ImplUpdateDate( aOldDate ); + ImplUpdateDate( maCurDate ); } } } @@ -1802,18 +1802,18 @@ void CalendarField::dispose() IMPL_LINK( CalendarField, ImplSelectHdl, Calendar*, pCalendar, void ) { - if ( !pCalendar->IsTravelSelect() ) + if ( pCalendar->IsTravelSelect() ) + return; + + mpFloatWin->EndPopupMode(); + EndDropDown(); + GrabFocus(); + Date aNewDate = mpCalendar->GetFirstSelectedDate(); + if ( IsEmptyDate() || ( aNewDate != GetDate() ) ) { - mpFloatWin->EndPopupMode(); - EndDropDown(); - GrabFocus(); - Date aNewDate = mpCalendar->GetFirstSelectedDate(); - if ( IsEmptyDate() || ( aNewDate != GetDate() ) ) - { - SetDate( aNewDate ); - SetModifyFlag(); - Modify(); - } + SetDate( aNewDate ); + SetModifyFlag(); + Modify(); } } diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx index 18f924ec1d2b..cbad6e420028 100644 --- a/svtools/source/control/ctrlbox.cxx +++ b/svtools/source/control/ctrlbox.cxx @@ -447,27 +447,27 @@ void LineListBox::ImpGetLine( long nLine1, long nLine2, long nDistance, if ( nVirHeight > aSize.Height() ) aSize.Height() = nVirHeight; // negative width should not be drawn - if ( aSize.Width() > 0 ) - { - Size aVirSize = aVirDev->LogicToPixel( aSize ); - if ( aVirDev->GetOutputSizePixel() != aVirSize ) - aVirDev->SetOutputSizePixel( aVirSize ); - aVirDev->SetFillColor( aColorDist ); - aVirDev->DrawRect( tools::Rectangle( Point(), aSize ) ); + if ( aSize.Width() <= 0 ) + return; - aVirDev->SetFillColor( aColor1 ); + Size aVirSize = aVirDev->LogicToPixel( aSize ); + if ( aVirDev->GetOutputSizePixel() != aVirSize ) + aVirDev->SetOutputSizePixel( aVirSize ); + aVirDev->SetFillColor( aColorDist ); + aVirDev->DrawRect( tools::Rectangle( Point(), aSize ) ); - double y1 = double( n1 ) / 2; - svtools::DrawLine( *aVirDev.get(), basegfx::B2DPoint( 0, y1 ), basegfx::B2DPoint( aSize.Width( ), y1 ), n1, nStyle ); + aVirDev->SetFillColor( aColor1 ); - if ( n2 ) - { - double y2 = n1 + nDist + double( n2 ) / 2; - aVirDev->SetFillColor( aColor2 ); - svtools::DrawLine( *aVirDev.get(), basegfx::B2DPoint( 0, y2 ), basegfx::B2DPoint( aSize.Width(), y2 ), n2, SvxBorderLineStyle::SOLID ); - } - rBmp = aVirDev->GetBitmap( Point(), Size( aSize.Width(), n1+nDist+n2 ) ); + double y1 = double( n1 ) / 2; + svtools::DrawLine( *aVirDev.get(), basegfx::B2DPoint( 0, y1 ), basegfx::B2DPoint( aSize.Width( ), y1 ), n1, nStyle ); + + if ( n2 ) + { + double y2 = n1 + nDist + double( n2 ) / 2; + aVirDev->SetFillColor( aColor2 ); + svtools::DrawLine( *aVirDev.get(), basegfx::B2DPoint( 0, y2 ), basegfx::B2DPoint( aSize.Width(), y2 ), n2, SvxBorderLineStyle::SOLID ); } + rBmp = aVirDev->GetBitmap( Point(), Size( aSize.Width(), n1+nDist+n2 ) ); } void LineListBox::ImplInit() @@ -1329,52 +1329,52 @@ void FontSizeBox::Modify() { MetricBox::Modify(); - if ( bRelativeMode ) - { - OUString aStr = comphelper::string::stripStart(GetText(), ' '); + if ( !bRelativeMode ) + return; + + OUString aStr = comphelper::string::stripStart(GetText(), ' '); - bool bNewMode = bRelative; - bool bOldPtRelMode = bPtRelative; + bool bNewMode = bRelative; + bool bOldPtRelMode = bPtRelative; - if ( bRelative ) + if ( bRelative ) + { + bPtRelative = false; + const sal_Unicode* pStr = aStr.getStr(); + while ( *pStr ) { - bPtRelative = false; - const sal_Unicode* pStr = aStr.getStr(); - while ( *pStr ) + if ( ((*pStr < '0') || (*pStr > '9')) && (*pStr != '%') && !unicode::isSpace(*pStr) ) { - if ( ((*pStr < '0') || (*pStr > '9')) && (*pStr != '%') && !unicode::isSpace(*pStr) ) + if ( ('-' == *pStr || '+' == *pStr) && !bPtRelative ) + bPtRelative = true; + else if ( bPtRelative && 'p' == *pStr && 't' == *++pStr ) + ; + else { - if ( ('-' == *pStr || '+' == *pStr) && !bPtRelative ) - bPtRelative = true; - else if ( bPtRelative && 'p' == *pStr && 't' == *++pStr ) - ; - else - { - bNewMode = false; - break; - } + bNewMode = false; + break; } - pStr++; } + pStr++; } - else if (!aStr.isEmpty()) + } + else if (!aStr.isEmpty()) + { + if ( -1 != aStr.indexOf('%') ) { - if ( -1 != aStr.indexOf('%') ) - { - bNewMode = true; - bPtRelative = false; - } - - if ( '-' == aStr[0] || '+' == aStr[0] ) - { - bNewMode = true; - bPtRelative = true; - } + bNewMode = true; + bPtRelative = false; } - if ( bNewMode != bRelative || bPtRelative != bOldPtRelMode ) - SetRelative( bNewMode ); + if ( '-' == aStr[0] || '+' == aStr[0] ) + { + bNewMode = true; + bPtRelative = true; + } } + + if ( bNewMode != bRelative || bPtRelative != bOldPtRelMode ) + SetRelative( bNewMode ); } void FontSizeBox::Fill( const FontMetric* pFontMetric, const FontList* pList ) @@ -1485,66 +1485,66 @@ void FontSizeBox::EnablePtRelativeMode( short nMin, short nMax, short nStep ) void FontSizeBox::SetRelative( bool bNewRelative ) { - if ( bRelativeMode ) + if ( !bRelativeMode ) + return; + + Selection aSelection = GetSelection(); + OUString aStr = comphelper::string::stripStart(GetText(), ' '); + + if ( bNewRelative ) { - Selection aSelection = GetSelection(); - OUString aStr = comphelper::string::stripStart(GetText(), ' '); + bRelative = true; + bStdSize = false; - if ( bNewRelative ) + if ( bPtRelative ) { - bRelative = true; - bStdSize = false; + Clear(); //clear early because SetDecimalDigits is a slow recalc - if ( bPtRelative ) - { - Clear(); //clear early because SetDecimalDigits is a slow recalc - - SetDecimalDigits( 1 ); - SetMin( nPtRelMin ); - SetMax( nPtRelMax ); - SetUnit( FUNIT_POINT ); + SetDecimalDigits( 1 ); + SetMin( nPtRelMin ); + SetMax( nPtRelMax ); + SetUnit( FUNIT_POINT ); - short i = nPtRelMin, n = 0; - // JP 30.06.98: more than 100 values are not useful - while ( i <= nPtRelMax && n++ < 100 ) - { - InsertValue( i ); - i = i + nPtRelStep; - } - } - else + short i = nPtRelMin, n = 0; + // JP 30.06.98: more than 100 values are not useful + while ( i <= nPtRelMax && n++ < 100 ) { - Clear(); //clear early because SetDecimalDigits is a slow recalc - - SetDecimalDigits( 0 ); - SetMin( nRelMin ); - SetMax( nRelMax ); - SetUnit( FUNIT_PERCENT ); - - sal_uInt16 i = nRelMin; - while ( i <= nRelMax ) - { - InsertValue( i ); - i = i + nRelStep; - } + InsertValue( i ); + i = i + nPtRelStep; } } else { - if (pFontList) - Clear(); //clear early because SetDecimalDigits is a slow recalc - bRelative = bPtRelative = false; - SetDecimalDigits( 1 ); - SetMin( 20 ); - SetMax( 9999 ); - SetUnit( FUNIT_POINT ); - if ( pFontList ) - Fill( &aFontMetric, pFontList ); - } + Clear(); //clear early because SetDecimalDigits is a slow recalc - SetText( aStr ); - SetSelection( aSelection ); + SetDecimalDigits( 0 ); + SetMin( nRelMin ); + SetMax( nRelMax ); + SetUnit( FUNIT_PERCENT ); + + sal_uInt16 i = nRelMin; + while ( i <= nRelMax ) + { + InsertValue( i ); + i = i + nRelStep; + } + } + } + else + { + if (pFontList) + Clear(); //clear early because SetDecimalDigits is a slow recalc + bRelative = bPtRelative = false; + SetDecimalDigits( 1 ); + SetMin( 20 ); + SetMax( 9999 ); + SetUnit( FUNIT_POINT ); + if ( pFontList ) + Fill( &aFontMetric, pFontList ); } + + SetText( aStr ); + SetSelection( aSelection ); } OUString FontSizeBox::CreateFieldText( sal_Int64 nValue ) const diff --git a/svtools/source/control/headbar.cxx b/svtools/source/control/headbar.cxx index a5d0263270ed..bd66dbc52c02 100644 --- a/svtools/source/control/headbar.cxx +++ b/svtools/source/control/headbar.cxx @@ -525,81 +525,81 @@ void HeaderBar::ImplDrawItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos } } - if (nBits & (HeaderBarItemBits::UPARROW | HeaderBarItemBits::DOWNARROW)) + if (!(nBits & (HeaderBarItemBits::UPARROW | HeaderBarItemBits::DOWNARROW))) + return; + + long nArrowX = nTxtPos; + if (nBits & HeaderBarItemBits::RIGHT) + nArrowX -= nArrowWidth; + else + nArrowX += nTxtWidth + HEADERBAR_ARROWOFF; + if (!(nBits & (HeaderBarItemBits::LEFTIMAGE | HeaderBarItemBits::RIGHTIMAGE)) && pItem->maText.isEmpty()) { - long nArrowX = nTxtPos; if (nBits & HeaderBarItemBits::RIGHT) - nArrowX -= nArrowWidth; + nArrowX -= aImageSize.Width(); else - nArrowX += nTxtWidth + HEADERBAR_ARROWOFF; - if (!(nBits & (HeaderBarItemBits::LEFTIMAGE | HeaderBarItemBits::RIGHTIMAGE)) && pItem->maText.isEmpty()) - { - if (nBits & HeaderBarItemBits::RIGHT) - nArrowX -= aImageSize.Width(); - else - nArrowX += aImageSize.Width(); - } + nArrowX += aImageSize.Width(); + } - // is there enough space to draw the item? - bool bDraw = true; - if (nArrowX < aRect.Left() + HEADERBAR_TEXTOFF) - bDraw = false; - else if (nArrowX + HEAD_ARROWSIZE2 > aRect.Right()) - bDraw = false; + // is there enough space to draw the item? + bool bDraw = true; + if (nArrowX < aRect.Left() + HEADERBAR_TEXTOFF) + bDraw = false; + else if (nArrowX + HEAD_ARROWSIZE2 > aRect.Right()) + bDraw = false; + + if (!bDraw) + return; - if (bDraw) + if (rRenderContext.IsNativeControlSupported(ControlType::ListHeader, ControlPart::Arrow)) + { + aCtrlRegion = tools::Rectangle(Point(nArrowX, aRect.Top()), Size(nArrowWidth, aRect.GetHeight())); + // control value passes 1 if arrow points down, 0 otherwise + aControlValue.setNumericVal((nBits & HeaderBarItemBits::DOWNARROW) ? 1 : 0); + nState |= ControlState::ENABLED; + if (bHigh) + nState |= ControlState::PRESSED; + rRenderContext.DrawNativeControl(ControlType::ListHeader, ControlPart::Arrow, aCtrlRegion, + nState, aControlValue, OUString()); + } + else + { + long nArrowY; + if (aTxtSize.Height()) + nArrowY = nTxtPosY + (aTxtSize.Height() / 2); + else if (aImageSize.Width() && aImageSize.Height()) + nArrowY = nImagePosY + (aImageSize.Height() / 2); + else { - if (rRenderContext.IsNativeControlSupported(ControlType::ListHeader, ControlPart::Arrow)) - { - aCtrlRegion = tools::Rectangle(Point(nArrowX, aRect.Top()), Size(nArrowWidth, aRect.GetHeight())); - // control value passes 1 if arrow points down, 0 otherwise - aControlValue.setNumericVal((nBits & HeaderBarItemBits::DOWNARROW) ? 1 : 0); - nState |= ControlState::ENABLED; - if (bHigh) - nState |= ControlState::PRESSED; - rRenderContext.DrawNativeControl(ControlType::ListHeader, ControlPart::Arrow, aCtrlRegion, - nState, aControlValue, OUString()); - } + if (nBits & HeaderBarItemBits::TOP) + nArrowY = aRect.Top() + 1; + else if (nBits & HeaderBarItemBits::BOTTOM) + nArrowY = aRect.Bottom() - HEAD_ARROWSIZE2 - 1; else - { - long nArrowY; - if (aTxtSize.Height()) - nArrowY = nTxtPosY + (aTxtSize.Height() / 2); - else if (aImageSize.Width() && aImageSize.Height()) - nArrowY = nImagePosY + (aImageSize.Height() / 2); - else - { - if (nBits & HeaderBarItemBits::TOP) - nArrowY = aRect.Top() + 1; - else if (nBits & HeaderBarItemBits::BOTTOM) - nArrowY = aRect.Bottom() - HEAD_ARROWSIZE2 - 1; - else - nArrowY = aRect.Top() + ((aRect.GetHeight() - HEAD_ARROWSIZE2) / 2); - } - nArrowY -= HEAD_ARROWSIZE1 - 1; - if (nBits & HeaderBarItemBits::DOWNARROW) - { - rRenderContext.SetLineColor(rStyleSettings.GetLightColor()); - rRenderContext.DrawLine(Point(nArrowX, nArrowY), - Point(nArrowX + HEAD_ARROWSIZE2, nArrowY)); - rRenderContext.DrawLine(Point(nArrowX, nArrowY), - Point(nArrowX + HEAD_ARROWSIZE1, nArrowY + HEAD_ARROWSIZE2)); - rRenderContext.SetLineColor(rStyleSettings.GetShadowColor()); - rRenderContext.DrawLine(Point(nArrowX + HEAD_ARROWSIZE1, nArrowY + HEAD_ARROWSIZE2), - Point(nArrowX + HEAD_ARROWSIZE2, nArrowY)); - } - else - { - rRenderContext.SetLineColor(rStyleSettings.GetLightColor()); - rRenderContext.DrawLine(Point(nArrowX, nArrowY + HEAD_ARROWSIZE2), - Point(nArrowX + HEAD_ARROWSIZE1, nArrowY)); - rRenderContext.SetLineColor(rStyleSettings.GetShadowColor()); - rRenderContext.DrawLine(Point(nArrowX, nArrowY + HEAD_ARROWSIZE2), - Point(nArrowX + HEAD_ARROWSIZE2, nArrowY + HEAD_ARROWSIZE2)); - rRenderContext.DrawLine(Point(nArrowX + HEAD_ARROWSIZE2, nArrowY + HEAD_ARROWSIZE2), - Point(nArrowX + HEAD_ARROWSIZE1, nArrowY)); - } - } + nArrowY = aRect.Top() + ((aRect.GetHeight() - HEAD_ARROWSIZE2) / 2); + } + nArrowY -= HEAD_ARROWSIZE1 - 1; + if (nBits & HeaderBarItemBits::DOWNARROW) + { + rRenderContext.SetLineColor(rStyleSettings.GetLightColor()); + rRenderContext.DrawLine(Point(nArrowX, nArrowY), + Point(nArrowX + HEAD_ARROWSIZE2, nArrowY)); + rRenderContext.DrawLine(Point(nArrowX, nArrowY), + Point(nArrowX + HEAD_ARROWSIZE1, nArrowY + HEAD_ARROWSIZE2)); + rRenderContext.SetLineColor(rStyleSettings.GetShadowColor()); + rRenderContext.DrawLine(Point(nArrowX + HEAD_ARROWSIZE1, nArrowY + HEAD_ARROWSIZE2), + Point(nArrowX + HEAD_ARROWSIZE2, nArrowY)); + } + else + { + rRenderContext.SetLineColor(rStyleSettings.GetLightColor()); + rRenderContext.DrawLine(Point(nArrowX, nArrowY + HEAD_ARROWSIZE2), + Point(nArrowX + HEAD_ARROWSIZE1, nArrowY)); + rRenderContext.SetLineColor(rStyleSettings.GetShadowColor()); + rRenderContext.DrawLine(Point(nArrowX, nArrowY + HEAD_ARROWSIZE2), + Point(nArrowX + HEAD_ARROWSIZE2, nArrowY + HEAD_ARROWSIZE2)); + rRenderContext.DrawLine(Point(nArrowX + HEAD_ARROWSIZE2, nArrowY + HEAD_ARROWSIZE2), + Point(nArrowX + HEAD_ARROWSIZE1, nArrowY)); } } } @@ -613,85 +613,85 @@ void HeaderBar::ImplDrawItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos void HeaderBar::ImplUpdate(sal_uInt16 nPos, bool bEnd) { - if (IsVisible() && IsUpdateMode()) + if (!(IsVisible() && IsUpdateMode())) + return; + + tools::Rectangle aRect; + size_t nItemCount = mpItemList->size(); + if (nPos < nItemCount) + aRect = ImplGetItemRect(nPos); + else { - tools::Rectangle aRect; - size_t nItemCount = mpItemList->size(); - if (nPos < nItemCount) - aRect = ImplGetItemRect(nPos); - else - { - aRect.Bottom() = mnDY - 1; - if (nItemCount) - aRect.Left() = ImplGetItemRect(nItemCount - 1).Right(); - } - if (bEnd) - aRect.Right() = mnDX - 1; - aRect.Top() += mnBorderOff1; - aRect.Bottom() -= mnBorderOff2; - Invalidate(aRect); + aRect.Bottom() = mnDY - 1; + if (nItemCount) + aRect.Left() = ImplGetItemRect(nItemCount - 1).Right(); } + if (bEnd) + aRect.Right() = mnDX - 1; + aRect.Top() += mnBorderOff1; + aRect.Bottom() -= mnBorderOff2; + Invalidate(aRect); } void HeaderBar::ImplStartDrag( const Point& rMousePos, bool bCommand ) { sal_uInt16 nPos; sal_uInt16 nHitTest = ImplHitTest( rMousePos, mnMouseOff, nPos ); - if ( nHitTest ) + if ( !nHitTest ) + return; + + mbDrag = false; + ImplHeadItem* pItem = (*mpItemList)[ nPos ]; + if ( nHitTest & HEAD_HITTEST_DIVIDER ) + mbDrag = true; + else { - mbDrag = false; - ImplHeadItem* pItem = (*mpItemList)[ nPos ]; - if ( nHitTest & HEAD_HITTEST_DIVIDER ) - mbDrag = true; - else + if ( ((pItem->mnBits & HeaderBarItemBits::CLICKABLE) && !(pItem->mnBits & HeaderBarItemBits::FLAT)) || + (mbDragable && !(pItem->mnBits & HeaderBarItemBits::FIXEDPOS)) ) { - if ( ((pItem->mnBits & HeaderBarItemBits::CLICKABLE) && !(pItem->mnBits & HeaderBarItemBits::FLAT)) || - (mbDragable && !(pItem->mnBits & HeaderBarItemBits::FIXEDPOS)) ) - { - mbItemMode = true; - mbDrag = true; - if ( bCommand ) - { - if ( mbDragable ) - mbItemDrag = true; - else - { - mbItemMode = false; - mbDrag = false; - } - } - } - else + mbItemMode = true; + mbDrag = true; + if ( bCommand ) { - if ( !bCommand ) + if ( mbDragable ) + mbItemDrag = true; + else { - mnCurItemId = pItem->mnId; - Select(); - mnCurItemId = 0; + mbItemMode = false; + mbDrag = false; } } } - - if ( mbDrag ) + else { - mbOutDrag = false; - mnCurItemId = pItem->mnId; - mnItemDragPos = nPos; - StartTracking(); - mnStartPos = rMousePos.X()-mnMouseOff; - mnDragPos = mnStartPos; - maStartDragHdl.Call( this ); - if (mbItemMode) - Invalidate(); - else + if ( !bCommand ) { - tools::Rectangle aSizeRect( mnDragPos, 0, mnDragPos, mnDragSize+mnDY ); - ShowTracking( aSizeRect, ShowTrackFlags::Split ); + mnCurItemId = pItem->mnId; + Select(); + mnCurItemId = 0; } } + } + + if ( mbDrag ) + { + mbOutDrag = false; + mnCurItemId = pItem->mnId; + mnItemDragPos = nPos; + StartTracking(); + mnStartPos = rMousePos.X()-mnMouseOff; + mnDragPos = mnStartPos; + maStartDragHdl.Call( this ); + if (mbItemMode) + Invalidate(); else - mnMouseOff = 0; + { + tools::Rectangle aSizeRect( mnDragPos, 0, mnDragPos, mnDragSize+mnDY ); + ShowTracking( aSizeRect, ShowTrackFlags::Split ); + } } + else + mnMouseOff = 0; } void HeaderBar::ImplDrag( const Point& rMousePos ) @@ -854,29 +854,29 @@ void HeaderBar::ImplEndDrag( bool bCancel ) void HeaderBar::MouseButtonDown( const MouseEvent& rMEvt ) { - if ( rMEvt.IsLeft() ) + if ( !rMEvt.IsLeft() ) + return; + + if ( rMEvt.GetClicks() == 2 ) { - if ( rMEvt.GetClicks() == 2 ) + long nTemp; + sal_uInt16 nPos; + sal_uInt16 nHitTest = ImplHitTest( rMEvt.GetPosPixel(), nTemp, nPos ); + if ( nHitTest ) { - long nTemp; - sal_uInt16 nPos; - sal_uInt16 nHitTest = ImplHitTest( rMEvt.GetPosPixel(), nTemp, nPos ); - if ( nHitTest ) - { - ImplHeadItem* pItem = (*mpItemList)[ nPos ]; - if ( nHitTest & HEAD_HITTEST_DIVIDER ) - mbItemMode = false; - else - mbItemMode = true; - mnCurItemId = pItem->mnId; - DoubleClick(); + ImplHeadItem* pItem = (*mpItemList)[ nPos ]; + if ( nHitTest & HEAD_HITTEST_DIVIDER ) mbItemMode = false; - mnCurItemId = 0; - } + else + mbItemMode = true; + mnCurItemId = pItem->mnId; + DoubleClick(); + mbItemMode = false; + mnCurItemId = 0; } - else - ImplStartDrag( rMEvt.GetPosPixel(), false ); } + else + ImplStartDrag( rMEvt.GetPosPixel(), false ); } void HeaderBar::MouseMove( const MouseEvent& rMEvt ) @@ -1150,22 +1150,22 @@ void HeaderBar::RemoveItem( sal_uInt16 nItemId ) void HeaderBar::MoveItem( sal_uInt16 nItemId, sal_uInt16 nNewPos ) { sal_uInt16 nPos = GetItemPos( nItemId ); - if ( nPos != HEADERBAR_ITEM_NOTFOUND ) - { - if ( nPos != nNewPos ) - { - ImplHeadItemList::iterator it = mpItemList->begin(); - ::std::advance( it, nPos ); - ImplHeadItem* pItem = *it; - mpItemList->erase( it ); - if ( nNewPos < nPos ) - nPos = nNewPos; - it = mpItemList->begin(); - ::std::advance( it, nNewPos ); - mpItemList->insert( it, pItem ); - ImplUpdate( nPos, true); - } - } + if ( nPos == HEADERBAR_ITEM_NOTFOUND ) + return; + + if ( nPos == nNewPos ) + return; + + ImplHeadItemList::iterator it = mpItemList->begin(); + ::std::advance( it, nPos ); + ImplHeadItem* pItem = *it; + mpItemList->erase( it ); + if ( nNewPos < nPos ) + nPos = nNewPos; + it = mpItemList->begin(); + ::std::advance( it, nNewPos ); + mpItemList->insert( it, pItem ); + ImplUpdate( nPos, true); } void HeaderBar::Clear() diff --git a/svtools/source/control/inettbc.cxx b/svtools/source/control/inettbc.cxx index 725ff7136a82..a432d2269678 100644 --- a/svtools/source/control/inettbc.cxx +++ b/svtools/source/control/inettbc.cxx @@ -910,59 +910,59 @@ void SvtURLBox::SetSmartProtocol( INetProtocol eProt ) void SvtURLBox::UpdatePicklistForSmartProtocol_Impl() { Clear(); - if ( !bHistoryDisabled ) - { - // read history pick list - Sequence< Sequence< PropertyValue > > seqPicklist = SvtHistoryOptions().GetList( ePICKLIST ); - sal_uInt32 nCount = seqPicklist.getLength(); - INetURLObject aCurObj; + if ( bHistoryDisabled ) + return; - for( sal_uInt32 nItem=0; nItem < nCount; nItem++ ) - { - Sequence< PropertyValue > seqPropertySet = seqPicklist[ nItem ]; + // read history pick list + Sequence< Sequence< PropertyValue > > seqPicklist = SvtHistoryOptions().GetList( ePICKLIST ); + sal_uInt32 nCount = seqPicklist.getLength(); + INetURLObject aCurObj; - OUString sURL; + for( sal_uInt32 nItem=0; nItem < nCount; nItem++ ) + { + Sequence< PropertyValue > seqPropertySet = seqPicklist[ nItem ]; + + OUString sURL; - sal_uInt32 nPropertyCount = seqPropertySet.getLength(); + sal_uInt32 nPropertyCount = seqPropertySet.getLength(); - for( sal_uInt32 nProperty=0; nProperty < nPropertyCount; nProperty++ ) + for( sal_uInt32 nProperty=0; nProperty < nPropertyCount; nProperty++ ) + { + if( seqPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_URL ) { - if( seqPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_URL ) - { - seqPropertySet[nProperty].Value >>= sURL; - aCurObj.SetURL( sURL ); + seqPropertySet[nProperty].Value >>= sURL; + aCurObj.SetURL( sURL ); - if ( !sURL.isEmpty() && ( eSmartProtocol != INetProtocol::NotValid ) ) - { - if( aCurObj.GetProtocol() != eSmartProtocol ) - break; - } + if ( !sURL.isEmpty() && ( eSmartProtocol != INetProtocol::NotValid ) ) + { + if( aCurObj.GetProtocol() != eSmartProtocol ) + break; + } - OUString aURL( aCurObj.GetMainURL( INetURLObject::DecodeMechanism::WithCharset ) ); + OUString aURL( aCurObj.GetMainURL( INetURLObject::DecodeMechanism::WithCharset ) ); - if ( !aURL.isEmpty() ) + if ( !aURL.isEmpty() ) + { + bool bFound = aURL.endsWith("/"); + if ( !bFound ) { - bool bFound = aURL.endsWith("/"); - if ( !bFound ) - { - OUString aUpperURL( aURL ); - aUpperURL = aUpperURL.toAsciiUpperCase(); + OUString aUpperURL( aURL ); + aUpperURL = aUpperURL.toAsciiUpperCase(); - bFound = ::std::any_of(pImpl->m_aFilters.begin(), - pImpl->m_aFilters.end(), - FilterMatch( aUpperURL ) ); - } - if ( bFound ) - { - OUString aFile; - if (osl::FileBase::getSystemPathFromFileURL(aURL, aFile) == osl::FileBase::E_None) - InsertEntry(aFile); - else - InsertEntry(aURL); - } + bFound = ::std::any_of(pImpl->m_aFilters.begin(), + pImpl->m_aFilters.end(), + FilterMatch( aUpperURL ) ); + } + if ( bFound ) + { + OUString aFile; + if (osl::FileBase::getSystemPathFromFileURL(aURL, aFile) == osl::FileBase::E_None) + InsertEntry(aFile); + else + InsertEntry(aURL); } - break; } + break; } } } diff --git a/svtools/source/control/roadmap.cxx b/svtools/source/control/roadmap.cxx index 4cce5aec37ec..8f8c40be3050 100644 --- a/svtools/source/control/roadmap.cxx +++ b/svtools/source/control/roadmap.cxx @@ -404,18 +404,18 @@ void ORoadmap::EnableRoadmapItem( ItemId _nItemId, bool _bEnable ) void ORoadmap::ChangeRoadmapItemLabel( ItemId _nID, const OUString& _sLabel ) { RoadmapItem* pItem = GetByID( _nID ); - if ( pItem != nullptr ) - { - pItem->Update( pItem->GetIndex(), _sLabel ); + if ( pItem == nullptr ) + return; - const HL_Vector& rItems = m_pImpl->getHyperLabels(); - for ( HL_Vector::const_iterator i = rItems.begin(); - i != rItems.end(); - ++i - ) - { - (*i)->SetPosition( GetPreviousHyperLabel( i - rItems.begin() ) ); - } + pItem->Update( pItem->GetIndex(), _sLabel ); + + const HL_Vector& rItems = m_pImpl->getHyperLabels(); + for ( HL_Vector::const_iterator i = rItems.begin(); + i != rItems.end(); + ++i + ) + { + (*i)->SetPosition( GetPreviousHyperLabel( i - rItems.begin() ) ); } } @@ -640,24 +640,24 @@ IMPL_LINK(ORoadmap, ImplClickHdl, HyperLabel*, CurHyperLabel, void) void ORoadmap::DataChanged(const DataChangedEvent& rDCEvt) { - if ((( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) || + if (!((( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) || ( rDCEvt.GetType() == DataChangedEventType::DISPLAY )) && - ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE )) + ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE ))) + return; + + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + SetBackground( Wallpaper( rStyleSettings.GetFieldColor() ) ); + Color aTextColor = rStyleSettings.GetFieldTextColor(); + vcl::Font aFont = GetFont(); + aFont.SetColor( aTextColor ); + SetFont( aFont ); + RoadmapTypes::ItemId curItemID = GetCurrentRoadmapItemID(); + RoadmapItem* pLabelItem = GetByID( curItemID ); + if (pLabelItem != nullptr) { - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - SetBackground( Wallpaper( rStyleSettings.GetFieldColor() ) ); - Color aTextColor = rStyleSettings.GetFieldTextColor(); - vcl::Font aFont = GetFont(); - aFont.SetColor( aTextColor ); - SetFont( aFont ); - RoadmapTypes::ItemId curItemID = GetCurrentRoadmapItemID(); - RoadmapItem* pLabelItem = GetByID( curItemID ); - if (pLabelItem != nullptr) - { - pLabelItem->ToggleBackgroundColor(rStyleSettings.GetHighlightColor()); - } - Invalidate(); + pLabelItem->ToggleBackgroundColor(rStyleSettings.GetHighlightColor()); } + Invalidate(); } void ORoadmap::ApplySettings(vcl::RenderContext& rRenderContext) diff --git a/svtools/source/control/ruler.cxx b/svtools/source/control/ruler.cxx index 52198ae55f92..2c1aa5be85ff 100644 --- a/svtools/source/control/ruler.cxx +++ b/svtools/source/control/ruler.cxx @@ -329,61 +329,61 @@ void Ruler::ImplVDrawText(vcl::RenderContext& rRenderContext, long nX, long nY, void Ruler::ImplInvertLines(vcl::RenderContext& rRenderContext) { // Position lines - if (!mpData->pLines.empty() && mbActive && !mbDrag && !mbFormat && !(mnUpdateFlags & RULER_UPDATE_LINES) ) - { - long nNullWinOff = mpData->nNullVirOff + mnVirOff; - long nRulX1 = mpData->nRulVirOff + mnVirOff; - long nRulX2 = nRulX1 + mpData->nRulWidth; - long nY = (RULER_OFF * 2) + mnVirHeight - 1; + if (!(!mpData->pLines.empty() && mbActive && !mbDrag && !mbFormat && !(mnUpdateFlags & RULER_UPDATE_LINES)) ) + return; - // Calculate rectangle - tools::Rectangle aRect; - if (mnWinStyle & WB_HORZ) - aRect.Bottom() = nY; - else - aRect.Right() = nY; + long nNullWinOff = mpData->nNullVirOff + mnVirOff; + long nRulX1 = mpData->nRulVirOff + mnVirOff; + long nRulX2 = nRulX1 + mpData->nRulWidth; + long nY = (RULER_OFF * 2) + mnVirHeight - 1; + + // Calculate rectangle + tools::Rectangle aRect; + if (mnWinStyle & WB_HORZ) + aRect.Bottom() = nY; + else + aRect.Right() = nY; - // Draw lines - for (RulerLine & rLine : mpData->pLines) + // Draw lines + for (RulerLine & rLine : mpData->pLines) + { + const long n = rLine.nPos + nNullWinOff; + if ((n >= nRulX1) && (n < nRulX2)) { - const long n = rLine.nPos + nNullWinOff; - if ((n >= nRulX1) && (n < nRulX2)) + if (mnWinStyle & WB_HORZ ) { - if (mnWinStyle & WB_HORZ ) - { - aRect.Left() = n; - aRect.Right() = n; - } - else - { - aRect.Top() = n; - aRect.Bottom() = n; - } - tools::Rectangle aTempRect = aRect; + aRect.Left() = n; + aRect.Right() = n; + } + else + { + aRect.Top() = n; + aRect.Bottom() = n; + } + tools::Rectangle aTempRect = aRect; - if (mnWinStyle & WB_HORZ) - aTempRect.Bottom() = RULER_OFF - 1; - else - aTempRect.Right() = RULER_OFF - 1; + if (mnWinStyle & WB_HORZ) + aTempRect.Bottom() = RULER_OFF - 1; + else + aTempRect.Right() = RULER_OFF - 1; - rRenderContext.Erase(aTempRect); + rRenderContext.Erase(aTempRect); - if (mnWinStyle & WB_HORZ) - { - aTempRect.Bottom() = aRect.Bottom(); - aTempRect.Top() = aTempRect.Bottom() - RULER_OFF + 1; - } - else - { - aTempRect.Right() = aRect.Right(); - aTempRect.Left() = aTempRect.Right() - RULER_OFF + 1; - } - rRenderContext.Erase(aTempRect); - Invert(aRect); + if (mnWinStyle & WB_HORZ) + { + aTempRect.Bottom() = aRect.Bottom(); + aTempRect.Top() = aTempRect.Bottom() - RULER_OFF + 1; + } + else + { + aTempRect.Right() = aRect.Right(); + aTempRect.Left() = aTempRect.Right() - RULER_OFF + 1; } + rRenderContext.Erase(aTempRect); + Invert(aRect); } - mnUpdateFlags = 0; } + mnUpdateFlags = 0; } void Ruler::ImplDrawTicks(vcl::RenderContext& rRenderContext, long nMin, long nMax, long nStart, long nTop, long nBottom) @@ -497,118 +497,118 @@ void Ruler::ImplDrawTicks(vcl::RenderContext& rRenderContext, long nMin, long nM rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetShadowColor()); } - if (!bNoTicks) - { - long n = 0; - double nTick = 0.0; - double nTick3 = 0; + if (bNoTicks) + return; - if ((mnUnitIndex != RULER_UNIT_CHAR) && (mnUnitIndex != RULER_UNIT_LINE)) - { - nTick2 = aImplRulerUnitTab[mnUnitIndex].nTick2; - nTick3 = aImplRulerUnitTab[mnUnitIndex].nTick3; - } + long n = 0; + double nTick = 0.0; + double nTick3 = 0; + + if ((mnUnitIndex != RULER_UNIT_CHAR) && (mnUnitIndex != RULER_UNIT_LINE)) + { + nTick2 = aImplRulerUnitTab[mnUnitIndex].nTick2; + nTick3 = aImplRulerUnitTab[mnUnitIndex].nTick3; + } - Size nTickGapSize; + Size nTickGapSize; - nTickGapSize = rRenderContext.LogicToPixel(Size(nTickCount, nTickCount), maMapMode); - long nTickGap1 = mnWinStyle & WB_HORZ ? nTickGapSize.Width() : nTickGapSize.Height(); - nTickGapSize = rRenderContext.LogicToPixel(Size(nTick2, nTick2), maMapMode); - long nTickGap2 = mnWinStyle & WB_HORZ ? nTickGapSize.Width() : nTickGapSize.Height(); - nTickGapSize = rRenderContext.LogicToPixel(Size(nTick3, nTick3), maMapMode); - long nTickGap3 = mnWinStyle & WB_HORZ ? nTickGapSize.Width() : nTickGapSize.Height(); + nTickGapSize = rRenderContext.LogicToPixel(Size(nTickCount, nTickCount), maMapMode); + long nTickGap1 = mnWinStyle & WB_HORZ ? nTickGapSize.Width() : nTickGapSize.Height(); + nTickGapSize = rRenderContext.LogicToPixel(Size(nTick2, nTick2), maMapMode); + long nTickGap2 = mnWinStyle & WB_HORZ ? nTickGapSize.Width() : nTickGapSize.Height(); + nTickGapSize = rRenderContext.LogicToPixel(Size(nTick3, nTick3), maMapMode); + long nTickGap3 = mnWinStyle & WB_HORZ ? nTickGapSize.Width() : nTickGapSize.Height(); - while (((nStart - n) >= nMin) || ((nStart + n) <= nMax)) + while (((nStart - n) >= nMin) || ((nStart + n) <= nMax)) + { + // Null point + if (nTick == 0.0) { - // Null point - if (nTick == 0.0) + if (nStart > nMin) { - if (nStart > nMin) + // 0 is only painted when Margin1 is not equal to zero + if ((mpData->nMargin1Style & RulerMarginStyle::Invisible) || (mpData->nMargin1 != 0)) { - // 0 is only painted when Margin1 is not equal to zero - if ((mpData->nMargin1Style & RulerMarginStyle::Invisible) || (mpData->nMargin1 != 0)) - { - aNumString = "0"; - ImplVDrawText(rRenderContext, nStart, nCenter, aNumString); - } + aNumString = "0"; + ImplVDrawText(rRenderContext, nStart, nCenter, aNumString); } } + } + else + { + aPixSize = rRenderContext.LogicToPixel(Size(nTick, nTick), maMapMode); + + if (mnWinStyle & WB_HORZ) + n = aPixSize.Width(); else - { - aPixSize = rRenderContext.LogicToPixel(Size(nTick, nTick), maMapMode); + n = aPixSize.Height(); + + // Tick4 - Output (Text) + double aStep = (nTick / nTick4); + double aRest = std::abs(aStep - std::floor(aStep)); + double nAcceptanceDelta = 0.0001; - if (mnWinStyle & WB_HORZ) - n = aPixSize.Width(); + if (aRest < nAcceptanceDelta) + { + if ((mnUnitIndex == RULER_UNIT_CHAR) || (mnUnitIndex == RULER_UNIT_LINE)) + aNumString = OUString::number(nTick / nTickUnit); else - n = aPixSize.Height(); + aNumString = OUString::number(nTick / aImplRulerUnitTab[mnUnitIndex].nTickUnit); - // Tick4 - Output (Text) - double aStep = (nTick / nTick4); - double aRest = std::abs(aStep - std::floor(aStep)); - double nAcceptanceDelta = 0.0001; + long nHorizontalLocation = nStart + n; + ImplVDrawText(rRenderContext, nHorizontalLocation, nCenter, aNumString, nMin, nMax); - if (aRest < nAcceptanceDelta) + if (nMin < nHorizontalLocation && nHorizontalLocation < nMax) { - if ((mnUnitIndex == RULER_UNIT_CHAR) || (mnUnitIndex == RULER_UNIT_LINE)) - aNumString = OUString::number(nTick / nTickUnit); - else - aNumString = OUString::number(nTick / aImplRulerUnitTab[mnUnitIndex].nTickUnit); - - long nHorizontalLocation = nStart + n; - ImplVDrawText(rRenderContext, nHorizontalLocation, nCenter, aNumString, nMin, nMax); - - if (nMin < nHorizontalLocation && nHorizontalLocation < nMax) - { - ImplVDrawRect(rRenderContext, nHorizontalLocation, nBottom, nHorizontalLocation + DPIOffset, nBottom - 1 * nScale); - ImplVDrawRect(rRenderContext, nHorizontalLocation, nTop, nHorizontalLocation + DPIOffset, nTop + 1 * nScale); - } + ImplVDrawRect(rRenderContext, nHorizontalLocation, nBottom, nHorizontalLocation + DPIOffset, nBottom - 1 * nScale); + ImplVDrawRect(rRenderContext, nHorizontalLocation, nTop, nHorizontalLocation + DPIOffset, nTop + 1 * nScale); + } - nHorizontalLocation = nStart - n; - ImplVDrawText(rRenderContext, nHorizontalLocation, nCenter, aNumString, nMin, nMax); + nHorizontalLocation = nStart - n; + ImplVDrawText(rRenderContext, nHorizontalLocation, nCenter, aNumString, nMin, nMax); - if (nMin < nHorizontalLocation && nHorizontalLocation < nMax) - { - ImplVDrawRect(rRenderContext, nHorizontalLocation, nBottom, - nHorizontalLocation + DPIOffset, nBottom - 1 * nScale); - ImplVDrawRect(rRenderContext, nHorizontalLocation, nTop, - nHorizontalLocation + DPIOffset, nTop + 1 * nScale); - } - } - // Tick/Tick2 - Output (Strokes) - else + if (nMin < nHorizontalLocation && nHorizontalLocation < nMax) { - long nTickLength = nTickLength1; + ImplVDrawRect(rRenderContext, nHorizontalLocation, nBottom, + nHorizontalLocation + DPIOffset, nBottom - 1 * nScale); + ImplVDrawRect(rRenderContext, nHorizontalLocation, nTop, + nHorizontalLocation + DPIOffset, nTop + 1 * nScale); + } + } + // Tick/Tick2 - Output (Strokes) + else + { + long nTickLength = nTickLength1; - aStep = (nTick / nTick2); - aRest = std::abs(aStep - std::floor(aStep)); - if (aRest < nAcceptanceDelta) - nTickLength = nTickLength2; + aStep = (nTick / nTick2); + aRest = std::abs(aStep - std::floor(aStep)); + if (aRest < nAcceptanceDelta) + nTickLength = nTickLength2; - aStep = (nTick / nTick3); - aRest = std::abs(aStep - std::floor(aStep)); - if (aRest < nAcceptanceDelta ) - nTickLength = nTickLength3; + aStep = (nTick / nTick3); + aRest = std::abs(aStep - std::floor(aStep)); + if (aRest < nAcceptanceDelta ) + nTickLength = nTickLength3; - if ((nTickLength == nTickLength1 && nTickGap1 > 6) || - (nTickLength == nTickLength2 && nTickGap2 > 6) || - (nTickLength == nTickLength3 && nTickGap3 > 6)) - { - long nT1 = nCenter - (nTickLength / 2.0); - long nT2 = nT1 + nTickLength - 1; - long nT; + if ((nTickLength == nTickLength1 && nTickGap1 > 6) || + (nTickLength == nTickLength2 && nTickGap2 > 6) || + (nTickLength == nTickLength3 && nTickGap3 > 6)) + { + long nT1 = nCenter - (nTickLength / 2.0); + long nT2 = nT1 + nTickLength - 1; + long nT; - nT = nStart + n; + nT = nStart + n; - if (nT < nMax) - ImplVDrawRect(rRenderContext, nT, nT1, nT + DPIOffset, nT2); - nT = nStart - n; - if (nT > nMin) - ImplVDrawRect(rRenderContext, nT, nT1, nT + DPIOffset, nT2); - } + if (nT < nMax) + ImplVDrawRect(rRenderContext, nT, nT1, nT + DPIOffset, nT2); + nT = nStart - n; + if (nT > nMin) + ImplVDrawRect(rRenderContext, nT, nT1, nT + DPIOffset, nT2); } } - nTick += nTickCount; } + nTick += nTickCount; } } @@ -802,20 +802,20 @@ static void ImplCenterTabPos(Point& rPos, sal_uInt16 nTabStyle) static void lcl_RotateRect_Impl(tools::Rectangle& rRect, const long nReference, bool bRightAligned) { - if (!rRect.IsEmpty()) - { - tools::Rectangle aTmp(rRect); - rRect.Top() = aTmp.Left(); - rRect.Bottom() = aTmp.Right(); - rRect.Left() = aTmp.Top(); - rRect.Right() = aTmp.Bottom(); + if (rRect.IsEmpty()) + return; - if (bRightAligned) - { - long nRef = 2 * nReference; - rRect.Left() = nRef - rRect.Left(); - rRect.Right() = nRef - rRect.Right(); - } + tools::Rectangle aTmp(rRect); + rRect.Top() = aTmp.Left(); + rRect.Bottom() = aTmp.Right(); + rRect.Left() = aTmp.Top(); + rRect.Right() = aTmp.Bottom(); + + if (bRightAligned) + { + long nRef = 2 * nReference; + rRect.Left() = nRef - rRect.Left(); + rRect.Right() = nRef - rRect.Right(); } } @@ -1280,30 +1280,30 @@ void Ruler::ImplDraw(vcl::RenderContext& rRenderContext) ImplFormat(rRenderContext); } - if (IsReallyVisible()) - { - // output the ruler to the virtual device - Point aOffPos; - Size aVirDevSize = maVirDev->GetOutputSizePixel(); + if (!IsReallyVisible()) + return; - if (mnWinStyle & WB_HORZ) - { - aOffPos.X() = mnVirOff; - if (mpData->bTextRTL) - aVirDevSize.Width() -= maExtraRect.GetWidth(); + // output the ruler to the virtual device + Point aOffPos; + Size aVirDevSize = maVirDev->GetOutputSizePixel(); - aOffPos.Y() = RULER_OFF; - } - else - { - aOffPos.X() = RULER_OFF; - aOffPos.Y() = mnVirOff; - } - rRenderContext.DrawOutDev(aOffPos, aVirDevSize, Point(), aVirDevSize, *maVirDev.get()); + if (mnWinStyle & WB_HORZ) + { + aOffPos.X() = mnVirOff; + if (mpData->bTextRTL) + aVirDevSize.Width() -= maExtraRect.GetWidth(); - // redraw positionlines - ImplInvertLines(rRenderContext); + aOffPos.Y() = RULER_OFF; } + else + { + aOffPos.X() = RULER_OFF; + aOffPos.Y() = mnVirOff; + } + rRenderContext.DrawOutDev(aOffPos, aVirDevSize, Point(), aVirDevSize, *maVirDev.get()); + + // redraw positionlines + ImplInvertLines(rRenderContext); } void Ruler::ImplDrawExtra(vcl::RenderContext& rRenderContext) @@ -1889,63 +1889,63 @@ void Ruler::ImplEndDrag() void Ruler::MouseButtonDown( const MouseEvent& rMEvt ) { - if ( rMEvt.IsLeft() && !IsTracking() ) + if ( !(rMEvt.IsLeft() && !IsTracking()) ) + return; + + Point aMousePos = rMEvt.GetPosPixel(); + sal_uInt16 nMouseClicks = rMEvt.GetClicks(); + sal_uInt16 nMouseModifier = rMEvt.GetModifier(); + + // update ruler + if ( mbFormat ) { - Point aMousePos = rMEvt.GetPosPixel(); - sal_uInt16 nMouseClicks = rMEvt.GetClicks(); - sal_uInt16 nMouseModifier = rMEvt.GetModifier(); + Invalidate(InvalidateFlags::NoErase); + } - // update ruler - if ( mbFormat ) - { - Invalidate(InvalidateFlags::NoErase); - } + if ( maExtraRect.IsInside( aMousePos ) ) + { + ExtraDown(); + } + else + { + std::unique_ptr<RulerSelection> pHitTest(new RulerSelection); + bool bHitTestResult = ImplHitTest(aMousePos, pHitTest.get()); - if ( maExtraRect.IsInside( aMousePos ) ) - { - ExtraDown(); - } - else + if ( nMouseClicks == 1 ) { - std::unique_ptr<RulerSelection> pHitTest(new RulerSelection); - bool bHitTestResult = ImplHitTest(aMousePos, pHitTest.get()); - - if ( nMouseClicks == 1 ) + if ( bHitTestResult ) { - if ( bHitTestResult ) - { - ImplStartDrag( pHitTest.get(), nMouseModifier ); - } - else - { - // calculate position inside of ruler area - if ( pHitTest->eType == RulerType::DontKnow ) - { - mnDragPos = pHitTest->nPos; - Click(); - mnDragPos = 0; - - // call HitTest again as a click, for example, could set a new tab - if ( ImplHitTest(aMousePos, pHitTest.get()) ) - ImplStartDrag(pHitTest.get(), nMouseModifier); - } - } + ImplStartDrag( pHitTest.get(), nMouseModifier ); } else { - if (bHitTestResult) + // calculate position inside of ruler area + if ( pHitTest->eType == RulerType::DontKnow ) { - mnDragPos = pHitTest->nPos; - mnDragAryPos = pHitTest->nAryPos; + mnDragPos = pHitTest->nPos; + Click(); + mnDragPos = 0; + + // call HitTest again as a click, for example, could set a new tab + if ( ImplHitTest(aMousePos, pHitTest.get()) ) + ImplStartDrag(pHitTest.get(), nMouseModifier); } - meDragType = pHitTest->eType; + } + } + else + { + if (bHitTestResult) + { + mnDragPos = pHitTest->nPos; + mnDragAryPos = pHitTest->nAryPos; + } + meDragType = pHitTest->eType; - DoubleClick(); + DoubleClick(); - meDragType = RulerType::DontKnow; - mnDragPos = 0; - mnDragAryPos = 0; - } + meDragType = RulerType::DontKnow; + mnDragPos = 0; + mnDragAryPos = 0; } } } @@ -2347,52 +2347,52 @@ void Ruler::SetBorderPos( long nOff ) void Ruler::SetUnit( FieldUnit eNewUnit ) { - if ( meUnit != eNewUnit ) - { - meUnit = eNewUnit; - switch ( meUnit ) - { - case FUNIT_MM: - mnUnitIndex = RULER_UNIT_MM; - break; - case FUNIT_CM: - mnUnitIndex = RULER_UNIT_CM; - break; - case FUNIT_M: - mnUnitIndex = RULER_UNIT_M; - break; - case FUNIT_KM: - mnUnitIndex = RULER_UNIT_KM; - break; - case FUNIT_INCH: - mnUnitIndex = RULER_UNIT_INCH; - break; - case FUNIT_FOOT: - mnUnitIndex = RULER_UNIT_FOOT; - break; - case FUNIT_MILE: - mnUnitIndex = RULER_UNIT_MILE; - break; - case FUNIT_POINT: - mnUnitIndex = RULER_UNIT_POINT; - break; - case FUNIT_PICA: - mnUnitIndex = RULER_UNIT_PICA; - break; - case FUNIT_CHAR: - mnUnitIndex = RULER_UNIT_CHAR; - break; - case FUNIT_LINE: - mnUnitIndex = RULER_UNIT_LINE; - break; - default: - SAL_WARN( "svtools.control", "Ruler::SetUnit() - Wrong Unit" ); - break; - } + if ( meUnit == eNewUnit ) + return; - maMapMode.SetMapUnit( aImplRulerUnitTab[mnUnitIndex].eMapUnit ); - ImplUpdate(); - } + meUnit = eNewUnit; + switch ( meUnit ) + { + case FUNIT_MM: + mnUnitIndex = RULER_UNIT_MM; + break; + case FUNIT_CM: + mnUnitIndex = RULER_UNIT_CM; + break; + case FUNIT_M: + mnUnitIndex = RULER_UNIT_M; + break; + case FUNIT_KM: + mnUnitIndex = RULER_UNIT_KM; + break; + case FUNIT_INCH: + mnUnitIndex = RULER_UNIT_INCH; + break; + case FUNIT_FOOT: + mnUnitIndex = RULER_UNIT_FOOT; + break; + case FUNIT_MILE: + mnUnitIndex = RULER_UNIT_MILE; + break; + case FUNIT_POINT: + mnUnitIndex = RULER_UNIT_POINT; + break; + case FUNIT_PICA: + mnUnitIndex = RULER_UNIT_PICA; + break; + case FUNIT_CHAR: + mnUnitIndex = RULER_UNIT_CHAR; + break; + case FUNIT_LINE: + mnUnitIndex = RULER_UNIT_LINE; + break; + default: + SAL_WARN( "svtools.control", "Ruler::SetUnit() - Wrong Unit" ); + break; + } + + maMapMode.SetMapUnit( aImplRulerUnitTab[mnUnitIndex].eMapUnit ); + ImplUpdate(); } void Ruler::SetZoom( const Fraction& rNewZoom ) diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx index cb9ee3fe007c..8fab52d1fcbd 100644 --- a/svtools/source/control/tabbar.cxx +++ b/svtools/source/control/tabbar.cxx @@ -1548,23 +1548,23 @@ void TabBar::ImplPrePaint() ImplFormat(); // assure the actual tabpage becomes visible at first format - if (mbFirstFormat) - { - mbFirstFormat = false; + if (!mbFirstFormat) + return; - if (mnCurPageId && (mnFirstPos == 0) && !mbDropPos) - { - ImplTabBarItem* pItem = mpImpl->mpItemList[GetPagePos(mnCurPageId)]; - if (pItem->maRect.IsEmpty()) - { - // set mbDropPos (or misuse) to prevent Invalidate() - mbDropPos = true; - SetFirstPageId(mnCurPageId); - mbDropPos = false; - if (mnFirstPos != 0) - ImplFormat(); - } - } + mbFirstFormat = false; + + if (!(mnCurPageId && (mnFirstPos == 0) && !mbDropPos)) + return; + + ImplTabBarItem* pItem = mpImpl->mpItemList[GetPagePos(mnCurPageId)]; + if (pItem->maRect.IsEmpty()) + { + // set mbDropPos (or misuse) to prevent Invalidate() + mbDropPos = true; + SetFirstPageId(mnCurPageId); + mbDropPos = false; + if (mnFirstPos != 0) + ImplFormat(); } } @@ -1669,22 +1669,22 @@ Color TabBar::GetTabBgColor(sal_uInt16 nPageId) const void TabBar::SetTabBgColor(sal_uInt16 nPageId, const Color& aTabBgColor) { sal_uInt16 nPos = GetPagePos(nPageId); - if (nPos != PAGE_NOT_FOUND) + if (nPos == PAGE_NOT_FOUND) + return; + + ImplTabBarItem* pItem = mpImpl->mpItemList[nPos]; + if (aTabBgColor != Color(COL_AUTO)) { - ImplTabBarItem* pItem = mpImpl->mpItemList[nPos]; - if (aTabBgColor != Color(COL_AUTO)) - { - pItem->maTabBgColor = aTabBgColor; - if (aTabBgColor.GetLuminance() <= 128) //Do not use aTabBgColor.IsDark(), because that threshold is way too low... - pItem->maTabTextColor = Color(COL_WHITE); - else - pItem->maTabTextColor = Color(COL_BLACK); - } + pItem->maTabBgColor = aTabBgColor; + if (aTabBgColor.GetLuminance() <= 128) //Do not use aTabBgColor.IsDark(), because that threshold is way too low... + pItem->maTabTextColor = Color(COL_WHITE); else - { - pItem->maTabBgColor = Color(COL_AUTO); - pItem->maTabTextColor = Color(COL_AUTO); - } + pItem->maTabTextColor = Color(COL_BLACK); + } + else + { + pItem->maTabBgColor = Color(COL_AUTO); + pItem->maTabTextColor = Color(COL_AUTO); } } @@ -1693,27 +1693,27 @@ void TabBar::RemovePage(sal_uInt16 nPageId) sal_uInt16 nPos = GetPagePos(nPageId); // does item exist - if (nPos != PAGE_NOT_FOUND) - { - if (mnCurPageId == nPageId) - mnCurPageId = 0; + if (nPos == PAGE_NOT_FOUND) + return; - // check if first visible page should be moved - if (mnFirstPos > nPos) - mnFirstPos--; + if (mnCurPageId == nPageId) + mnCurPageId = 0; - // delete item data - ImplTabBarList::iterator it = mpImpl->mpItemList.begin(); - std::advance(it, nPos); - delete *it; - mpImpl->mpItemList.erase(it); + // check if first visible page should be moved + if (mnFirstPos > nPos) + mnFirstPos--; - // redraw bar - if (IsReallyVisible() && IsUpdateMode()) - Invalidate(); + // delete item data + ImplTabBarList::iterator it = mpImpl->mpItemList.begin(); + std::advance(it, nPos); + delete *it; + mpImpl->mpItemList.erase(it); - CallEventListeners(VclEventId::TabbarPageRemoved, reinterpret_cast<void*>(sal::static_int_cast<sal_IntPtr>(nPageId))); - } + // redraw bar + if (IsReallyVisible() && IsUpdateMode()) + Invalidate(); + + CallEventListeners(VclEventId::TabbarPageRemoved, reinterpret_cast<void*>(sal::static_int_cast<sal_IntPtr>(nPageId))); } void TabBar::MovePage(sal_uInt16 nPageId, sal_uInt16 nNewPos) @@ -1728,30 +1728,30 @@ void TabBar::MovePage(sal_uInt16 nPageId, sal_uInt16 nNewPos) return; // does item exit - if (nPos != PAGE_NOT_FOUND) + if (nPos == PAGE_NOT_FOUND) + return; + + // move tabbar item in the list + ImplTabBarList::iterator it = mpImpl->mpItemList.begin(); + std::advance(it, nPos); + ImplTabBarItem* pItem = *it; + mpImpl->mpItemList.erase(it); + if (nNewPos < mpImpl->mpItemList.size()) { - // move tabbar item in the list - ImplTabBarList::iterator it = mpImpl->mpItemList.begin(); - std::advance(it, nPos); - ImplTabBarItem* pItem = *it; - mpImpl->mpItemList.erase(it); - if (nNewPos < mpImpl->mpItemList.size()) - { - it = mpImpl->mpItemList.begin(); - std::advance(it, nNewPos); - mpImpl->mpItemList.insert(it, pItem); - } - else - { - mpImpl->mpItemList.push_back(pItem); - } + it = mpImpl->mpItemList.begin(); + std::advance(it, nNewPos); + mpImpl->mpItemList.insert(it, pItem); + } + else + { + mpImpl->mpItemList.push_back(pItem); + } - // redraw bar - if (IsReallyVisible() && IsUpdateMode()) - Invalidate(); + // redraw bar + if (IsReallyVisible() && IsUpdateMode()) + Invalidate(); - CallEventListeners( VclEventId::TabbarPageMoved, static_cast<void*>(&aPair) ); - } + CallEventListeners( VclEventId::TabbarPageMoved, static_cast<void*>(&aPair) ); } void TabBar::Clear() @@ -1787,18 +1787,18 @@ void TabBar::SetPageBits(sal_uInt16 nPageId, TabBarPageBits nBits) { sal_uInt16 nPos = GetPagePos(nPageId); - if (nPos != PAGE_NOT_FOUND) - { - ImplTabBarItem* pItem = mpImpl->mpItemList[nPos]; + if (nPos == PAGE_NOT_FOUND) + return; - if (pItem->mnBits != nBits) - { - pItem->mnBits = nBits; + ImplTabBarItem* pItem = mpImpl->mpItemList[nPos]; - // redraw bar - if (IsReallyVisible() && IsUpdateMode()) - Invalidate(pItem->maRect); - } + if (pItem->mnBits != nBits) + { + pItem->mnBits = nBits; + + // redraw bar + if (IsReallyVisible() && IsUpdateMode()) + Invalidate(pItem->maRect); } } @@ -1860,112 +1860,58 @@ void TabBar::SetCurPageId(sal_uInt16 nPageId) sal_uInt16 nPos = GetPagePos(nPageId); // do nothing if item does not exit - if (nPos != PAGE_NOT_FOUND) - { - // do nothing if the actual page did not change - if (nPageId == mnCurPageId) - return; - - // make invalid - bool bUpdate = false; - if (IsReallyVisible() && IsUpdateMode()) - bUpdate = true; - - ImplTabBarItem* pItem = mpImpl->mpItemList[nPos]; - ImplTabBarItem* pOldItem; - - if (mnCurPageId) - pOldItem = mpImpl->mpItemList[GetPagePos(mnCurPageId)]; - else - pOldItem = nullptr; - - // deselect previous page if page was not selected, if this is the - // only selected page - if (!pItem->mbSelect && pOldItem) - { - sal_uInt16 nSelPageCount = GetSelectPageCount(); - if (nSelPageCount == 1) - pOldItem->mbSelect = false; - pItem->mbSelect = true; - } + if (nPos == PAGE_NOT_FOUND) + return; - mnCurPageId = nPageId; - mbFormat = true; + // do nothing if the actual page did not change + if (nPageId == mnCurPageId) + return; - // assure the actual page becomes visible - if (IsReallyVisible()) - { - if (nPos < mnFirstPos) - SetFirstPageId(nPageId); - else - { - // calculate visible width - long nWidth = mnLastOffX; - if (nWidth > ADDNEWPAGE_AREAWIDTH) - nWidth -= ADDNEWPAGE_AREAWIDTH; + // make invalid + bool bUpdate = false; + if (IsReallyVisible() && IsUpdateMode()) + bUpdate = true; - if (pItem->maRect.IsEmpty()) - ImplFormat(); + ImplTabBarItem* pItem = mpImpl->mpItemList[nPos]; + ImplTabBarItem* pOldItem; - while ((mbMirrored ? (pItem->maRect.Left() < mnOffX) : (pItem->maRect.Right() > nWidth)) || - pItem->maRect.IsEmpty()) - { - sal_uInt16 nNewPos = mnFirstPos + 1; - // assure at least the actual tabpages are visible as first tabpage - if (nNewPos >= nPos) - { - SetFirstPageId(nPageId); - break; - } - else - SetFirstPageId(GetPageId(nNewPos)); - ImplFormat(); - // abort if first page is not forwarded - if (nNewPos != mnFirstPos) - break; - } - } - } + if (mnCurPageId) + pOldItem = mpImpl->mpItemList[GetPagePos(mnCurPageId)]; + else + pOldItem = nullptr; - // redraw bar - if (bUpdate) - { - Invalidate(pItem->maRect); - if (pOldItem) - Invalidate(pOldItem->maRect); - } + // deselect previous page if page was not selected, if this is the + // only selected page + if (!pItem->mbSelect && pOldItem) + { + sal_uInt16 nSelPageCount = GetSelectPageCount(); + if (nSelPageCount == 1) + pOldItem->mbSelect = false; + pItem->mbSelect = true; } -} - -void TabBar::MakeVisible(sal_uInt16 nPageId) -{ - if (!IsReallyVisible()) - return; - sal_uInt16 nPos = GetPagePos(nPageId); + mnCurPageId = nPageId; + mbFormat = true; - // do nothing if item does not exist - if (nPos != PAGE_NOT_FOUND) + // assure the actual page becomes visible + if (IsReallyVisible()) { if (nPos < mnFirstPos) SetFirstPageId(nPageId); else { - ImplTabBarItem* pItem = mpImpl->mpItemList[nPos]; - - // calculate visible area + // calculate visible width long nWidth = mnLastOffX; + if (nWidth > ADDNEWPAGE_AREAWIDTH) + nWidth -= ADDNEWPAGE_AREAWIDTH; - if (mbFormat || pItem->maRect.IsEmpty()) - { - mbFormat = true; + if (pItem->maRect.IsEmpty()) ImplFormat(); - } - while ((pItem->maRect.Right() > nWidth) || + while ((mbMirrored ? (pItem->maRect.Left() < mnOffX) : (pItem->maRect.Right() > nWidth)) || pItem->maRect.IsEmpty()) { - sal_uInt16 nNewPos = mnFirstPos+1; + sal_uInt16 nNewPos = mnFirstPos + 1; // assure at least the actual tabpages are visible as first tabpage if (nNewPos >= nPos) { @@ -1981,56 +1927,110 @@ void TabBar::MakeVisible(sal_uInt16 nPageId) } } } + + // redraw bar + if (bUpdate) + { + Invalidate(pItem->maRect); + if (pOldItem) + Invalidate(pOldItem->maRect); + } } -void TabBar::SetFirstPageId(sal_uInt16 nPageId) +void TabBar::MakeVisible(sal_uInt16 nPageId) { + if (!IsReallyVisible()) + return; + sal_uInt16 nPos = GetPagePos(nPageId); - // return false if item does not exist - if (nPos != PAGE_NOT_FOUND) + // do nothing if item does not exist + if (nPos == PAGE_NOT_FOUND) + return; + + if (nPos < mnFirstPos) + SetFirstPageId(nPageId); + else { - if (nPos != mnFirstPos) + ImplTabBarItem* pItem = mpImpl->mpItemList[nPos]; + + // calculate visible area + long nWidth = mnLastOffX; + + if (mbFormat || pItem->maRect.IsEmpty()) { - // assure as much pages are visible as possible + mbFormat = true; ImplFormat(); - sal_uInt16 nLastFirstPos = ImplGetLastFirstPos(); - sal_uInt16 nNewPos; - if (nPos > nLastFirstPos) - nNewPos = nLastFirstPos; - else - nNewPos = nPos; + } - if (nNewPos != mnFirstPos) + while ((pItem->maRect.Right() > nWidth) || + pItem->maRect.IsEmpty()) + { + sal_uInt16 nNewPos = mnFirstPos+1; + // assure at least the actual tabpages are visible as first tabpage + if (nNewPos >= nPos) { - mnFirstPos = nNewPos; - mbFormat = true; - - // redraw bar (attention: check mbDropPos, - // as if this flag was set, we do not re-paint immediately - if (IsReallyVisible() && IsUpdateMode() && !mbDropPos) - Invalidate(); + SetFirstPageId(nPageId); + break; } + else + SetFirstPageId(GetPageId(nNewPos)); + ImplFormat(); + // abort if first page is not forwarded + if (nNewPos != mnFirstPos) + break; } } } -void TabBar::SelectPage(sal_uInt16 nPageId, bool bSelect) +void TabBar::SetFirstPageId(sal_uInt16 nPageId) { sal_uInt16 nPos = GetPagePos(nPageId); - if (nPos != PAGE_NOT_FOUND) + // return false if item does not exist + if (nPos == PAGE_NOT_FOUND) + return; + + if (nPos == mnFirstPos) + return; + + // assure as much pages are visible as possible + ImplFormat(); + sal_uInt16 nLastFirstPos = ImplGetLastFirstPos(); + sal_uInt16 nNewPos; + if (nPos > nLastFirstPos) + nNewPos = nLastFirstPos; + else + nNewPos = nPos; + + if (nNewPos != mnFirstPos) { - ImplTabBarItem* pItem = mpImpl->mpItemList[nPos]; + mnFirstPos = nNewPos; + mbFormat = true; - if (pItem->mbSelect != bSelect) - { - pItem->mbSelect = bSelect; + // redraw bar (attention: check mbDropPos, + // as if this flag was set, we do not re-paint immediately + if (IsReallyVisible() && IsUpdateMode() && !mbDropPos) + Invalidate(); + } +} - // redraw bar - if (IsReallyVisible() && IsUpdateMode()) - Invalidate(pItem->maRect); - } +void TabBar::SelectPage(sal_uInt16 nPageId, bool bSelect) +{ + sal_uInt16 nPos = GetPagePos(nPageId); + + if (nPos == PAGE_NOT_FOUND) + return; + + ImplTabBarItem* pItem = mpImpl->mpItemList[nPos]; + + if (pItem->mbSelect != bSelect) + { + pItem->mbSelect = bSelect; + + // redraw bar + if (IsReallyVisible() && IsUpdateMode()) + Invalidate(pItem->maRect); } } @@ -2151,43 +2151,43 @@ bool TabBar::IsInEditMode() const void TabBar::EndEditMode(bool bCancel) { - if (mpImpl->mpEdit) - { - // call hdl - bool bEnd = true; - mbEditCanceled = bCancel; - maEditText = mpImpl->mpEdit->GetText(); - mpImpl->mpEdit->SetPostEvent(); - if (!bCancel) - { - TabBarAllowRenamingReturnCode nAllowRenaming = AllowRenaming(); - if (nAllowRenaming == TABBAR_RENAMING_YES) - SetPageText(mnEditId, maEditText); - else if (nAllowRenaming == TABBAR_RENAMING_NO) - bEnd = false; - else // nAllowRenaming == TABBAR_RENAMING_CANCEL - mbEditCanceled = true; - } + if (!mpImpl->mpEdit) + return; - // renaming not allowed, than reset edit data - if (!bEnd) - { - mpImpl->mpEdit->ResetPostEvent(); - mpImpl->mpEdit->GrabFocus(); - } - else - { - // close edit and call end hdl - mpImpl->mpEdit.disposeAndClear(); + // call hdl + bool bEnd = true; + mbEditCanceled = bCancel; + maEditText = mpImpl->mpEdit->GetText(); + mpImpl->mpEdit->SetPostEvent(); + if (!bCancel) + { + TabBarAllowRenamingReturnCode nAllowRenaming = AllowRenaming(); + if (nAllowRenaming == TABBAR_RENAMING_YES) + SetPageText(mnEditId, maEditText); + else if (nAllowRenaming == TABBAR_RENAMING_NO) + bEnd = false; + else // nAllowRenaming == TABBAR_RENAMING_CANCEL + mbEditCanceled = true; + } - EndRenaming(); - mnEditId = 0; - } + // renaming not allowed, than reset edit data + if (!bEnd) + { + mpImpl->mpEdit->ResetPostEvent(); + mpImpl->mpEdit->GrabFocus(); + } + else + { + // close edit and call end hdl + mpImpl->mpEdit.disposeAndClear(); - // reset - maEditText.clear(); - mbEditCanceled = false; + EndRenaming(); + mnEditId = 0; } + + // reset + maEditText.clear(); + mbEditCanceled = false; } void TabBar::SetMirrored(bool bMirrored) @@ -2442,40 +2442,40 @@ sal_uInt16 TabBar::ShowDropPos(const Point& rPos) void TabBar::HideDropPos() { - if (mbDropPos) - { - ImplTabBarItem* pItem; - long nX; - long nY1 = (maWinSize.Height() / 2) - 3; - long nY2 = nY1 + 5; - sal_uInt16 nItemCount = mpImpl->getItemSize(); + if (!mbDropPos) + return; - if (mnDropPos < nItemCount) - { - pItem = mpImpl->mpItemList[mnDropPos]; - nX = pItem->maRect.Left(); - // immediately call Paint, as it is not possible during drag and drop - tools::Rectangle aRect( nX-1, nY1, nX+3, nY2 ); - vcl::Region aRegion( aRect ); - SetClipRegion( aRegion ); - Invalidate(aRect); - SetClipRegion(); - } - if (mnDropPos > 0 && mnDropPos < nItemCount + 1) - { - pItem = mpImpl->mpItemList[mnDropPos - 1]; - nX = pItem->maRect.Right(); - // immediately call Paint, as it is not possible during drag and drop - tools::Rectangle aRect(nX - 2, nY1, nX + 1, nY2); - vcl::Region aRegion(aRect); - SetClipRegion(aRegion); - Invalidate(aRect); - SetClipRegion(); - } + ImplTabBarItem* pItem; + long nX; + long nY1 = (maWinSize.Height() / 2) - 3; + long nY2 = nY1 + 5; + sal_uInt16 nItemCount = mpImpl->getItemSize(); - mbDropPos = false; - mnDropPos = 0; + if (mnDropPos < nItemCount) + { + pItem = mpImpl->mpItemList[mnDropPos]; + nX = pItem->maRect.Left(); + // immediately call Paint, as it is not possible during drag and drop + tools::Rectangle aRect( nX-1, nY1, nX+3, nY2 ); + vcl::Region aRegion( aRect ); + SetClipRegion( aRegion ); + Invalidate(aRect); + SetClipRegion(); } + if (mnDropPos > 0 && mnDropPos < nItemCount + 1) + { + pItem = mpImpl->mpItemList[mnDropPos - 1]; + nX = pItem->maRect.Right(); + // immediately call Paint, as it is not possible during drag and drop + tools::Rectangle aRect(nX - 2, nY1, nX + 1, nY2); + vcl::Region aRegion(aRect); + SetClipRegion(aRegion); + Invalidate(aRect); + SetClipRegion(); + } + + mbDropPos = false; + mnDropPos = 0; } void TabBar::SwitchPage(const Point& rPos) diff --git a/svtools/source/control/toolbarmenu.cxx b/svtools/source/control/toolbarmenu.cxx index 3a77a9f80225..12a651f49fa0 100644 --- a/svtools/source/control/toolbarmenu.cxx +++ b/svtools/source/control/toolbarmenu.cxx @@ -351,37 +351,37 @@ void ToolbarMenu_Impl::clearAccessibleSelection() void ToolbarMenu_Impl::notifyHighlightedEntry() { - if( mxAccessible.is() && mxAccessible->HasAccessibleListeners() ) - { - ToolbarMenuEntry* pEntry = implGetEntry( mnHighlightedEntry ); - if( pEntry && pEntry->mbEnabled && (pEntry->mnEntryId != TITLE_ID) ) - { - Any aNew; - Any aOld( mxOldSelection ); - if( pEntry->mpControl ) - { - sal_Int32 nChildIndex = 0; - // todo: if other controls than ValueSet are allowed, adapt this code - ValueSet* pValueSet = dynamic_cast< ValueSet* >( pEntry->mpControl.get() ); - if( pValueSet ) - nChildIndex = static_cast< sal_Int32 >( pValueSet->GetItemPos( pValueSet->GetSelectItemId() ) ); + if( !(mxAccessible.is() && mxAccessible->HasAccessibleListeners()) ) + return; - if( (nChildIndex >= pEntry->getAccessibleChildCount()) || (nChildIndex < 0) ) - return; + ToolbarMenuEntry* pEntry = implGetEntry( mnHighlightedEntry ); + if( !(pEntry && pEntry->mbEnabled && (pEntry->mnEntryId != TITLE_ID)) ) + return; - aNew <<= getAccessibleChild( pEntry->mpControl, nChildIndex ); - } - else - { - aNew <<= pEntry->GetAccessible(); - } + Any aNew; + Any aOld( mxOldSelection ); + if( pEntry->mpControl ) + { + sal_Int32 nChildIndex = 0; + // todo: if other controls than ValueSet are allowed, adapt this code + ValueSet* pValueSet = dynamic_cast< ValueSet* >( pEntry->mpControl.get() ); + if( pValueSet ) + nChildIndex = static_cast< sal_Int32 >( pValueSet->GetItemPos( pValueSet->GetSelectItemId() ) ); - fireAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOld, aNew ); - fireAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, aOld, aNew ); - fireAccessibleEvent( AccessibleEventId::STATE_CHANGED, Any(), Any( AccessibleStateType::FOCUSED ) ); - aNew >>= mxOldSelection; - } + if( (nChildIndex >= pEntry->getAccessibleChildCount()) || (nChildIndex < 0) ) + return; + + aNew <<= getAccessibleChild( pEntry->mpControl, nChildIndex ); + } + else + { + aNew <<= pEntry->GetAccessible(); } + + fireAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOld, aNew ); + fireAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, aOld, aNew ); + fireAccessibleEvent( AccessibleEventId::STATE_CHANGED, Any(), Any( AccessibleStateType::FOCUSED ) ); + aNew >>= mxOldSelection; } @@ -1029,32 +1029,32 @@ ToolbarMenuEntry* ToolbarMenu::implCursorUpDown( bool bUp, bool bHomeEnd ) void ToolbarMenu_Impl::implHighlightControl( sal_uInt16 nCode, Control* pControl ) { ValueSet* pValueSet = dynamic_cast< ValueSet* >( pControl ); - if( pValueSet ) + if( !pValueSet ) + return; + + const size_t nItemCount = pValueSet->GetItemCount(); + size_t nItemPos = VALUESET_ITEM_NOTFOUND; + switch( nCode ) { - const size_t nItemCount = pValueSet->GetItemCount(); - size_t nItemPos = VALUESET_ITEM_NOTFOUND; - switch( nCode ) - { - case KEY_UP: - { - const sal_uInt16 nColCount = pValueSet->GetColCount(); - const sal_uInt16 nLastLine = nItemCount / nColCount; - nItemPos = std::min( static_cast<size_t>(((nLastLine-1) * nColCount) + mnLastColumn), nItemCount-1 ); - break; - } - case KEY_DOWN: - nItemPos = std::min( static_cast<size_t>(mnLastColumn), nItemCount-1 ); - break; - case KEY_END: - nItemPos = nItemCount -1; - break; - case KEY_HOME: - nItemPos = 0; - break; - } - pValueSet->SelectItem( pValueSet->GetItemId( nItemPos ) ); - notifyHighlightedEntry(); + case KEY_UP: + { + const sal_uInt16 nColCount = pValueSet->GetColCount(); + const sal_uInt16 nLastLine = nItemCount / nColCount; + nItemPos = std::min( static_cast<size_t>(((nLastLine-1) * nColCount) + mnLastColumn), nItemCount-1 ); + break; + } + case KEY_DOWN: + nItemPos = std::min( static_cast<size_t>(mnLastColumn), nItemCount-1 ); + break; + case KEY_END: + nItemPos = nItemCount -1; + break; + case KEY_HOME: + nItemPos = 0; + break; } + pValueSet->SelectItem( pValueSet->GetItemId( nItemPos ) ); + notifyHighlightedEntry(); } diff --git a/svtools/source/control/toolbarmenuacc.cxx b/svtools/source/control/toolbarmenuacc.cxx index 233ffddff37f..e33813372e84 100644 --- a/svtools/source/control/toolbarmenuacc.cxx +++ b/svtools/source/control/toolbarmenuacc.cxx @@ -105,26 +105,26 @@ IMPL_LINK( ToolbarMenuAcc, WindowEventListener, VclWindowEvent&, rEvent, void ) void ToolbarMenuAcc::FireAccessibleEvent( short nEventId, const Any& rOldValue, const Any& rNewValue ) { - if( nEventId ) - { - EventListenerVector aTmpListeners( mxEventListeners ); - AccessibleEventObject aEvtObject; + if( !nEventId ) + return; + + EventListenerVector aTmpListeners( mxEventListeners ); + AccessibleEventObject aEvtObject; - aEvtObject.EventId = nEventId; - aEvtObject.Source = static_cast<XWeak*>(this); - aEvtObject.NewValue = rNewValue; - aEvtObject.OldValue = rOldValue; + aEvtObject.EventId = nEventId; + aEvtObject.Source = static_cast<XWeak*>(this); + aEvtObject.NewValue = rNewValue; + aEvtObject.OldValue = rOldValue; - for (EventListenerVector::const_iterator aIter( aTmpListeners.begin() ), aEnd( aTmpListeners.end() ); - aIter != aEnd ; ++aIter) + for (EventListenerVector::const_iterator aIter( aTmpListeners.begin() ), aEnd( aTmpListeners.end() ); + aIter != aEnd ; ++aIter) + { + try + { + (*aIter)->notifyEvent( aEvtObject ); + } + catch( Exception& ) { - try - { - (*aIter)->notifyEvent( aEvtObject ); - } - catch( Exception& ) - { - } } } } @@ -273,22 +273,22 @@ void SAL_CALL ToolbarMenuAcc::addAccessibleEventListener( const Reference< XAcce ThrowIfDisposed(); ::osl::MutexGuard aGuard(m_aMutex); - if( rxListener.is() ) - { - EventListenerVector::const_iterator aIter = mxEventListeners.begin(); - bool bFound = false; + if( !rxListener.is() ) + return; - while( !bFound && ( aIter != mxEventListeners.end() ) ) - { - if( *aIter == rxListener ) - bFound = true; - else - ++aIter; - } + EventListenerVector::const_iterator aIter = mxEventListeners.begin(); + bool bFound = false; - if (!bFound) - mxEventListeners.push_back( rxListener ); + while( !bFound && ( aIter != mxEventListeners.end() ) ) + { + if( *aIter == rxListener ) + bFound = true; + else + ++aIter; } + + if (!bFound) + mxEventListeners.push_back( rxListener ); } diff --git a/svtools/source/control/valueacc.cxx b/svtools/source/control/valueacc.cxx index f1e145cc8e7a..cb12cd85bbb3 100644 --- a/svtools/source/control/valueacc.cxx +++ b/svtools/source/control/valueacc.cxx @@ -77,26 +77,26 @@ ValueSetAcc::~ValueSetAcc() void ValueSetAcc::FireAccessibleEvent( short nEventId, const uno::Any& rOldValue, const uno::Any& rNewValue ) { - if( nEventId ) - { - ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > > aTmpListeners( mxEventListeners ); - accessibility::AccessibleEventObject aEvtObject; + if( !nEventId ) + return; + + ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > > aTmpListeners( mxEventListeners ); + accessibility::AccessibleEventObject aEvtObject; - aEvtObject.EventId = nEventId; - aEvtObject.Source = static_cast<uno::XWeak*>(this); - aEvtObject.NewValue = rNewValue; - aEvtObject.OldValue = rOldValue; + aEvtObject.EventId = nEventId; + aEvtObject.Source = static_cast<uno::XWeak*>(this); + aEvtObject.NewValue = rNewValue; + aEvtObject.OldValue = rOldValue; - for (::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::const_iterator aIter( aTmpListeners.begin() ); - aIter != aTmpListeners.end() ; ++aIter) + for (::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::const_iterator aIter( aTmpListeners.begin() ); + aIter != aTmpListeners.end() ; ++aIter) + { + try + { + (*aIter)->notifyEvent( aEvtObject ); + } + catch(const uno::Exception&) { - try - { - (*aIter)->notifyEvent( aEvtObject ); - } - catch(const uno::Exception&) - { - } } } } @@ -336,22 +336,22 @@ void SAL_CALL ValueSetAcc::addAccessibleEventListener( const uno::Reference< acc ThrowIfDisposed(); ::osl::MutexGuard aGuard (m_aMutex); - if( rxListener.is() ) - { - ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::const_iterator aIter = mxEventListeners.begin(); - bool bFound = false; + if( !rxListener.is() ) + return; - while( !bFound && ( aIter != mxEventListeners.end() ) ) - { - if( *aIter == rxListener ) - bFound = true; - else - ++aIter; - } + ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::const_iterator aIter = mxEventListeners.begin(); + bool bFound = false; - if (!bFound) - mxEventListeners.push_back( rxListener ); + while( !bFound && ( aIter != mxEventListeners.end() ) ) + { + if( *aIter == rxListener ) + bFound = true; + else + ++aIter; } + + if (!bFound) + mxEventListeners.push_back( rxListener ); } @@ -684,21 +684,21 @@ ValueItemAcc::~ValueItemAcc() void ValueItemAcc::FireAccessibleEvent( short nEventId, const uno::Any& rOldValue, const uno::Any& rNewValue ) { - if( nEventId ) - { - ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > > aTmpListeners( mxEventListeners ); - accessibility::AccessibleEventObject aEvtObject; + if( !nEventId ) + return; - aEvtObject.EventId = nEventId; - aEvtObject.Source = static_cast<uno::XWeak*>(this); - aEvtObject.NewValue = rNewValue; - aEvtObject.OldValue = rOldValue; + ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > > aTmpListeners( mxEventListeners ); + accessibility::AccessibleEventObject aEvtObject; - for (::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::const_iterator aIter( aTmpListeners.begin() ); - aIter != aTmpListeners.end() ; ++aIter) - { - (*aIter)->notifyEvent( aEvtObject ); - } + aEvtObject.EventId = nEventId; + aEvtObject.Source = static_cast<uno::XWeak*>(this); + aEvtObject.NewValue = rNewValue; + aEvtObject.OldValue = rOldValue; + + for (::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::const_iterator aIter( aTmpListeners.begin() ); + aIter != aTmpListeners.end() ; ++aIter) + { + (*aIter)->notifyEvent( aEvtObject ); } } @@ -905,22 +905,22 @@ void SAL_CALL ValueItemAcc::addAccessibleEventListener( const uno::Reference< ac { const ::osl::MutexGuard aGuard( maMutex ); - if( rxListener.is() ) - { - ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::const_iterator aIter = mxEventListeners.begin(); - bool bFound = false; + if( !rxListener.is() ) + return; - while( !bFound && ( aIter != mxEventListeners.end() ) ) - { - if( *aIter == rxListener ) - bFound = true; - else - ++aIter; - } + ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::const_iterator aIter = mxEventListeners.begin(); + bool bFound = false; - if (!bFound) - mxEventListeners.push_back( rxListener ); + while( !bFound && ( aIter != mxEventListeners.end() ) ) + { + if( *aIter == rxListener ) + bFound = true; + else + ++aIter; } + + if (!bFound) + mxEventListeners.push_back( rxListener ); } diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index 04d94b4c06d4..0502bbe4017c 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -185,19 +185,19 @@ void ValueSet::ImplInitSettings(bool bFont, bool bForeground, bool bBackground) void ValueSet::ImplInitScrollBar() { - if (GetStyle() & WB_VSCROLL) + if (!(GetStyle() & WB_VSCROLL)) + return; + + if (!mxScrollBar.get()) { - if (!mxScrollBar.get()) - { - mxScrollBar.reset(VclPtr<ScrollBar>::Create(this, WB_VSCROLL | WB_DRAG)); - mxScrollBar->SetScrollHdl(LINK(this, ValueSet, ImplScrollHdl)); - } - else - { - // adapt the width because of the changed settings - long nScrBarWidth = Application::GetSettings().GetStyleSettings().GetScrollBarSize(); - mxScrollBar->setPosSizePixel(0, 0, nScrBarWidth, 0, PosSizeFlags::Width); - } + mxScrollBar.reset(VclPtr<ScrollBar>::Create(this, WB_VSCROLL | WB_DRAG)); + mxScrollBar->SetScrollHdl(LINK(this, ValueSet, ImplScrollHdl)); + } + else + { + // adapt the width because of the changed settings + long nScrBarWidth = Application::GetSettings().GetStyleSettings().GetScrollBarSize(); + mxScrollBar->setPosSizePixel(0, 0, nScrBarWidth, 0, PosSizeFlags::Width); } } @@ -230,109 +230,109 @@ void ValueSet::ImplFormatItem(vcl::RenderContext const & rRenderContext, ValueSe if (pItem == mpNoneItem.get()) pItem->maText = GetText(); - if ((aRect.GetHeight() > 0) && (aRect.GetWidth() > 0)) - { - const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); + if (!((aRect.GetHeight() > 0) && (aRect.GetWidth() > 0))) + return; + + const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); - if (pItem == mpNoneItem.get()) + if (pItem == mpNoneItem.get()) + { + maVirDev->SetFont(rRenderContext.GetFont()); + maVirDev->SetTextColor((nStyle & WB_MENUSTYLEVALUESET) ? rStyleSettings.GetMenuTextColor() : rStyleSettings.GetWindowTextColor()); + maVirDev->SetTextFillColor(); + maVirDev->SetFillColor((nStyle & WB_MENUSTYLEVALUESET) ? rStyleSettings.GetMenuColor() : rStyleSettings.GetWindowColor()); + maVirDev->DrawRect(aRect); + Point aTxtPos(aRect.Left() + 2, aRect.Top()); + long nTxtWidth = rRenderContext.GetTextWidth(pItem->maText); + if ((aTxtPos.X() + nTxtWidth) > aRect.Right()) { - maVirDev->SetFont(rRenderContext.GetFont()); - maVirDev->SetTextColor((nStyle & WB_MENUSTYLEVALUESET) ? rStyleSettings.GetMenuTextColor() : rStyleSettings.GetWindowTextColor()); - maVirDev->SetTextFillColor(); - maVirDev->SetFillColor((nStyle & WB_MENUSTYLEVALUESET) ? rStyleSettings.GetMenuColor() : rStyleSettings.GetWindowColor()); - maVirDev->DrawRect(aRect); - Point aTxtPos(aRect.Left() + 2, aRect.Top()); - long nTxtWidth = rRenderContext.GetTextWidth(pItem->maText); - if ((aTxtPos.X() + nTxtWidth) > aRect.Right()) - { - maVirDev->SetClipRegion(vcl::Region(aRect)); - maVirDev->DrawText(aTxtPos, pItem->maText); - maVirDev->SetClipRegion(); - } - else - maVirDev->DrawText(aTxtPos, pItem->maText); + maVirDev->SetClipRegion(vcl::Region(aRect)); + maVirDev->DrawText(aTxtPos, pItem->maText); + maVirDev->SetClipRegion(); } - else if (pItem->meType == VALUESETITEM_COLOR) + else + maVirDev->DrawText(aTxtPos, pItem->maText); + } + else if (pItem->meType == VALUESETITEM_COLOR) + { + maVirDev->SetFillColor(pItem->maColor); + maVirDev->DrawRect(aRect); + } + else + { + if (IsColor()) + maVirDev->SetFillColor(maColor); + else if (nStyle & WB_MENUSTYLEVALUESET) + maVirDev->SetFillColor(rStyleSettings.GetMenuColor()); + else if (IsEnabled()) + maVirDev->SetFillColor(rStyleSettings.GetWindowColor()); + else + maVirDev->SetFillColor(rStyleSettings.GetFaceColor()); + maVirDev->DrawRect(aRect); + + if (pItem->meType == VALUESETITEM_USERDRAW) { - maVirDev->SetFillColor(pItem->maColor); - maVirDev->DrawRect(aRect); + UserDrawEvent aUDEvt(this, maVirDev.get(), aRect, pItem->mnId); + UserDraw(aUDEvt); } else { - if (IsColor()) - maVirDev->SetFillColor(maColor); - else if (nStyle & WB_MENUSTYLEVALUESET) - maVirDev->SetFillColor(rStyleSettings.GetMenuColor()); - else if (IsEnabled()) - maVirDev->SetFillColor(rStyleSettings.GetWindowColor()); - else - maVirDev->SetFillColor(rStyleSettings.GetFaceColor()); - maVirDev->DrawRect(aRect); + Size aImageSize = pItem->maImage.GetSizePixel(); + Size aRectSize = aRect.GetSize(); + Point aPos(aRect.Left(), aRect.Top()); + aPos.X() += (aRectSize.Width() - aImageSize.Width()) / 2; + + if (pItem->meType != VALUESETITEM_IMAGE_AND_TEXT) + aPos.Y() += (aRectSize.Height() - aImageSize.Height()) / 2; + + DrawImageFlags nImageStyle = DrawImageFlags::NONE; + if (!IsEnabled()) + nImageStyle |= DrawImageFlags::Disable; - if (pItem->meType == VALUESETITEM_USERDRAW) + if (aImageSize.Width() > aRectSize.Width() || + aImageSize.Height() > aRectSize.Height()) { - UserDrawEvent aUDEvt(this, maVirDev.get(), aRect, pItem->mnId); - UserDraw(aUDEvt); + maVirDev->SetClipRegion(vcl::Region(aRect)); + maVirDev->DrawImage(aPos, pItem->maImage, nImageStyle); + maVirDev->SetClipRegion(); } else - { - Size aImageSize = pItem->maImage.GetSizePixel(); - Size aRectSize = aRect.GetSize(); - Point aPos(aRect.Left(), aRect.Top()); - aPos.X() += (aRectSize.Width() - aImageSize.Width()) / 2; + maVirDev->DrawImage(aPos, pItem->maImage, nImageStyle); - if (pItem->meType != VALUESETITEM_IMAGE_AND_TEXT) - aPos.Y() += (aRectSize.Height() - aImageSize.Height()) / 2; + if (pItem->meType == VALUESETITEM_IMAGE_AND_TEXT) + { + maVirDev->SetFont(rRenderContext.GetFont()); + maVirDev->SetTextColor((nStyle & WB_MENUSTYLEVALUESET) ? rStyleSettings.GetMenuTextColor() : rStyleSettings.GetWindowTextColor()); + maVirDev->SetTextFillColor(); - DrawImageFlags nImageStyle = DrawImageFlags::NONE; - if (!IsEnabled()) - nImageStyle |= DrawImageFlags::Disable; + long nTxtWidth = maVirDev->GetTextWidth(pItem->maText); - if (aImageSize.Width() > aRectSize.Width() || - aImageSize.Height() > aRectSize.Height()) - { + if (nTxtWidth > aRect.GetWidth()) maVirDev->SetClipRegion(vcl::Region(aRect)); - maVirDev->DrawImage(aPos, pItem->maImage, nImageStyle); - maVirDev->SetClipRegion(); - } - else - maVirDev->DrawImage(aPos, pItem->maImage, nImageStyle); - - if (pItem->meType == VALUESETITEM_IMAGE_AND_TEXT) - { - maVirDev->SetFont(rRenderContext.GetFont()); - maVirDev->SetTextColor((nStyle & WB_MENUSTYLEVALUESET) ? rStyleSettings.GetMenuTextColor() : rStyleSettings.GetWindowTextColor()); - maVirDev->SetTextFillColor(); - long nTxtWidth = maVirDev->GetTextWidth(pItem->maText); + maVirDev->DrawText(Point(aRect.Left() + + (aRect.GetWidth() - nTxtWidth) / 2, + aRect.Bottom() - maVirDev->GetTextHeight()), + pItem->maText); - if (nTxtWidth > aRect.GetWidth()) - maVirDev->SetClipRegion(vcl::Region(aRect)); - - maVirDev->DrawText(Point(aRect.Left() + - (aRect.GetWidth() - nTxtWidth) / 2, - aRect.Bottom() - maVirDev->GetTextHeight()), - pItem->maText); - - if (nTxtWidth > aRect.GetWidth()) - maVirDev->SetClipRegion(); - } + if (nTxtWidth > aRect.GetWidth()) + maVirDev->SetClipRegion(); } } + } - const sal_uInt16 nEdgeBlendingPercent(GetEdgeBlending() ? rStyleSettings.GetEdgeBlending() : 0); + const sal_uInt16 nEdgeBlendingPercent(GetEdgeBlending() ? rStyleSettings.GetEdgeBlending() : 0); - if (nEdgeBlendingPercent) - { - const Color& rTopLeft(rStyleSettings.GetEdgeBlendingTopLeftColor()); - const Color& rBottomRight(rStyleSettings.GetEdgeBlendingBottomRightColor()); - const sal_uInt8 nAlpha((nEdgeBlendingPercent * 255) / 100); - const BitmapEx aBlendFrame(createBlendFrame(aRect.GetSize(), nAlpha, rTopLeft, rBottomRight)); + if (nEdgeBlendingPercent) + { + const Color& rTopLeft(rStyleSettings.GetEdgeBlendingTopLeftColor()); + const Color& rBottomRight(rStyleSettings.GetEdgeBlendingBottomRightColor()); + const sal_uInt8 nAlpha((nEdgeBlendingPercent * 255) / 100); + const BitmapEx aBlendFrame(createBlendFrame(aRect.GetSize(), nAlpha, rTopLeft, rBottomRight)); - if (!aBlendFrame.IsEmpty()) - { - maVirDev->DrawBitmapEx(aRect.TopLeft(), aBlendFrame); - } + if (!aBlendFrame.IsEmpty()) + { + maVirDev->DrawBitmapEx(aRect.TopLeft(), aBlendFrame); } } } @@ -752,102 +752,102 @@ void ValueSet::ImplDrawSelect(vcl::RenderContext& rRenderContext, sal_uInt16 nIt return; } - if (pItem->mbVisible) - { - // draw selection - const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); - rRenderContext.SetFillColor(); + if (!pItem->mbVisible) + return; - Color aDoubleColor(rStyleSettings.GetHighlightColor()); - Color aSingleColor(rStyleSettings.GetHighlightTextColor()); - if (!mbDoubleSel) + // draw selection + const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); + rRenderContext.SetFillColor(); + + Color aDoubleColor(rStyleSettings.GetHighlightColor()); + Color aSingleColor(rStyleSettings.GetHighlightTextColor()); + if (!mbDoubleSel) + { + /* + * #99777# contrast enhancement for thin mode + */ + const Wallpaper& rWall = GetDisplayBackground(); + if (!rWall.IsBitmap() && ! rWall.IsGradient()) { - /* - * #99777# contrast enhancement for thin mode - */ - const Wallpaper& rWall = GetDisplayBackground(); - if (!rWall.IsBitmap() && ! rWall.IsGradient()) + const Color& rBack = rWall.GetColor(); + if (rBack.IsDark() && ! aDoubleColor.IsBright()) { - const Color& rBack = rWall.GetColor(); - if (rBack.IsDark() && ! aDoubleColor.IsBright()) - { - aDoubleColor = Color(COL_WHITE); - aSingleColor = Color(COL_BLACK); - } - else if (rBack.IsBright() && ! aDoubleColor.IsDark()) - { - aDoubleColor = Color(COL_BLACK); - aSingleColor = Color(COL_WHITE); - } + aDoubleColor = Color(COL_WHITE); + aSingleColor = Color(COL_BLACK); + } + else if (rBack.IsBright() && ! aDoubleColor.IsDark()) + { + aDoubleColor = Color(COL_BLACK); + aSingleColor = Color(COL_WHITE); } } + } - // specify selection output - WinBits nStyle = GetStyle(); - if (nStyle & WB_MENUSTYLEVALUESET) - { - if (bFocus) - ShowFocus(aRect); + // specify selection output + WinBits nStyle = GetStyle(); + if (nStyle & WB_MENUSTYLEVALUESET) + { + if (bFocus) + ShowFocus(aRect); - if (bDrawSel) - { - rRenderContext.SetLineColor(mbBlackSel ? Color(COL_BLACK) : aDoubleColor); - rRenderContext.DrawRect(aRect); - } + if (bDrawSel) + { + rRenderContext.SetLineColor(mbBlackSel ? Color(COL_BLACK) : aDoubleColor); + rRenderContext.DrawRect(aRect); } - else + } + else + { + if (bDrawSel) + { + rRenderContext.SetLineColor(mbBlackSel ? Color(COL_BLACK) : aDoubleColor); + rRenderContext.DrawRect(aRect); + } + if (mbDoubleSel) { - if (bDrawSel) - { - rRenderContext.SetLineColor(mbBlackSel ? Color(COL_BLACK) : aDoubleColor); - rRenderContext.DrawRect(aRect); - } - if (mbDoubleSel) - { - aRect.Left()++; - aRect.Top()++; - aRect.Right()--; - aRect.Bottom()--; - if (bDrawSel) - rRenderContext.DrawRect(aRect); - } aRect.Left()++; aRect.Top()++; aRect.Right()--; aRect.Bottom()--; - tools::Rectangle aRect2 = aRect; + if (bDrawSel) + rRenderContext.DrawRect(aRect); + } + aRect.Left()++; + aRect.Top()++; + aRect.Right()--; + aRect.Bottom()--; + tools::Rectangle aRect2 = aRect; + aRect.Left()++; + aRect.Top()++; + aRect.Right()--; + aRect.Bottom()--; + if (bDrawSel) + rRenderContext.DrawRect(aRect); + if (mbDoubleSel) + { aRect.Left()++; aRect.Top()++; aRect.Right()--; aRect.Bottom()--; if (bDrawSel) rRenderContext.DrawRect(aRect); - if (mbDoubleSel) - { - aRect.Left()++; - aRect.Top()++; - aRect.Right()--; - aRect.Bottom()--; - if (bDrawSel) - rRenderContext.DrawRect(aRect); - } - - if (bDrawSel) - { - rRenderContext.SetLineColor(mbBlackSel ? Color(COL_WHITE) : aSingleColor); - } - else - { - rRenderContext.SetLineColor(Color(COL_LIGHTGRAY)); - } - rRenderContext.DrawRect(aRect2); + } - if (bFocus) - ShowFocus(aRect2); + if (bDrawSel) + { + rRenderContext.SetLineColor(mbBlackSel ? Color(COL_WHITE) : aSingleColor); } + else + { + rRenderContext.SetLineColor(Color(COL_LIGHTGRAY)); + } + rRenderContext.DrawRect(aRect2); - ImplDrawItemText(rRenderContext, pItem->maText); + if (bFocus) + ShowFocus(aRect2); } + + ImplDrawItemText(rRenderContext, pItem->maText); } void ValueSet::ImplHideSelect( sal_uInt16 nItemId ) @@ -880,21 +880,21 @@ void ValueSet::ImplHideSelect( sal_uInt16 nItemId ) void ValueSet::ImplHighlightItem( sal_uInt16 nItemId, bool bIsSelection ) { - if ( mnHighItemId != nItemId ) - { - // remember the old item to delete the previous selection - sal_uInt16 nOldItem = mnHighItemId; - mnHighItemId = nItemId; + if ( mnHighItemId == nItemId ) + return; - // don't draw the selection if nothing is selected - if ( !bIsSelection && mbNoSelection ) - mbDrawSelection = false; + // remember the old item to delete the previous selection + sal_uInt16 nOldItem = mnHighItemId; + mnHighItemId = nItemId; - // remove the old selection and draw the new one - ImplHideSelect( nOldItem ); - Invalidate(); - mbDrawSelection = true; - } + // don't draw the selection if nothing is selected + if ( !bIsSelection && mbNoSelection ) + mbDrawSelection = false; + + // remove the old selection and draw the new one + ImplHideSelect( nOldItem ); + Invalidate(); + mbDrawSelection = true; } void ValueSet::ImplDraw(vcl::RenderContext& rRenderContext) @@ -1340,23 +1340,23 @@ void ValueSet::KeyInput( const KeyEvent& rKeyEvent ) // in which case selection mode should be switched off EndSelection(); - if ( nItemPos != VALUESET_ITEM_NOTFOUND ) + if ( nItemPos == VALUESET_ITEM_NOTFOUND ) + return; + + if ( nItemPos!=VALUESET_ITEM_NONEITEM && nItemPos<nLastItem ) { - if ( nItemPos!=VALUESET_ITEM_NONEITEM && nItemPos<nLastItem ) - { - // update current column only in case of a new position - // which is also not a "specially" handled one. - mnCurCol = mnCols ? nItemPos % mnCols : 0; - } - const sal_uInt16 nItemId = (nItemPos != VALUESET_ITEM_NONEITEM) ? GetItemId( nItemPos ) : 0; - if ( nItemId != mnSelItemId ) + // update current column only in case of a new position + // which is also not a "specially" handled one. + mnCurCol = mnCols ? nItemPos % mnCols : 0; + } + const sal_uInt16 nItemId = (nItemPos != VALUESET_ITEM_NONEITEM) ? GetItemId( nItemPos ) : 0; + if ( nItemId != mnSelItemId ) + { + SelectItem( nItemId ); + if (!(GetStyle() & WB_NO_DIRECTSELECT)) { - SelectItem( nItemId ); - if (!(GetStyle() & WB_NO_DIRECTSELECT)) - { - // select only if WB_NO_DIRECTSELECT is not set - Select(); - } + // select only if WB_NO_DIRECTSELECT is not set + Select(); } } } @@ -1781,97 +1781,97 @@ void ValueSet::SelectItem( sal_uInt16 nItemId ) return; } - if ( (mnSelItemId != nItemId) || mbNoSelection ) - { - sal_uInt16 nOldItem = mnSelItemId ? mnSelItemId : 1; - mnSelItemId = nItemId; - mbNoSelection = false; + if ( !((mnSelItemId != nItemId) || mbNoSelection) ) + return; + + sal_uInt16 nOldItem = mnSelItemId ? mnSelItemId : 1; + mnSelItemId = nItemId; + mbNoSelection = false; - bool bNewOut = !mbFormat && IsReallyVisible() && IsUpdateMode(); - bool bNewLine = false; + bool bNewOut = !mbFormat && IsReallyVisible() && IsUpdateMode(); + bool bNewLine = false; - // if necessary scroll to the visible area - if (mbScroll && nItemId && mnCols) + // if necessary scroll to the visible area + if (mbScroll && nItemId && mnCols) + { + sal_uInt16 nNewLine = (sal_uInt16)(nItemPos / mnCols); + if ( nNewLine < mnFirstLine ) { - sal_uInt16 nNewLine = (sal_uInt16)(nItemPos / mnCols); - if ( nNewLine < mnFirstLine ) - { - mnFirstLine = nNewLine; - bNewLine = true; - } - else if ( nNewLine > (sal_uInt16)(mnFirstLine+mnVisLines-1) ) - { - mnFirstLine = (sal_uInt16)(nNewLine-mnVisLines+1); - bNewLine = true; - } + mnFirstLine = nNewLine; + bNewLine = true; } + else if ( nNewLine > (sal_uInt16)(mnFirstLine+mnVisLines-1) ) + { + mnFirstLine = (sal_uInt16)(nNewLine-mnVisLines+1); + bNewLine = true; + } + } - if ( bNewOut ) + if ( bNewOut ) + { + if ( bNewLine ) { - if ( bNewLine ) - { - // redraw everything if the visible area has changed - mbFormat = true; - Invalidate(); - } - else - { - // remove old selection and draw the new one - ImplHideSelect( nOldItem ); - Invalidate(); - } + // redraw everything if the visible area has changed + mbFormat = true; + Invalidate(); + } + else + { + // remove old selection and draw the new one + ImplHideSelect( nOldItem ); + Invalidate(); } + } - if( ImplHasAccessibleListeners() ) + if( ImplHasAccessibleListeners() ) + { + // focus event (deselect) + if( nOldItem ) { - // focus event (deselect) - if( nOldItem ) + const size_t nPos = GetItemPos( nItemId ); + + if( nPos != VALUESET_ITEM_NOTFOUND ) { - const size_t nPos = GetItemPos( nItemId ); + ValueItemAcc* pItemAcc = ValueItemAcc::getImplementation( + mItemList[nPos]->GetAccessible( false/*bIsTransientChildrenDisabled*/ ) ); - if( nPos != VALUESET_ITEM_NOTFOUND ) + if( pItemAcc ) { - ValueItemAcc* pItemAcc = ValueItemAcc::getImplementation( - mItemList[nPos]->GetAccessible( false/*bIsTransientChildrenDisabled*/ ) ); - - if( pItemAcc ) - { - Any aOldAny; - Any aNewAny; - aOldAny <<= Reference<XInterface>(static_cast<cppu::OWeakObject*>(pItemAcc)); - ImplFireAccessibleEvent(AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldAny, aNewAny ); - } + Any aOldAny; + Any aNewAny; + aOldAny <<= Reference<XInterface>(static_cast<cppu::OWeakObject*>(pItemAcc)); + ImplFireAccessibleEvent(AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldAny, aNewAny ); } } + } - // focus event (select) - const size_t nPos = GetItemPos( mnSelItemId ); - - ValueSetItem* pItem; - if( nPos != VALUESET_ITEM_NOTFOUND ) - pItem = mItemList[nPos]; - else - pItem = mpNoneItem.get(); + // focus event (select) + const size_t nPos = GetItemPos( mnSelItemId ); - ValueItemAcc* pItemAcc = nullptr; - if (pItem != nullptr) - pItemAcc = ValueItemAcc::getImplementation( pItem->GetAccessible( false/*bIsTransientChildrenDisabled*/ ) ); + ValueSetItem* pItem; + if( nPos != VALUESET_ITEM_NOTFOUND ) + pItem = mItemList[nPos]; + else + pItem = mpNoneItem.get(); - if( pItemAcc ) - { - Any aOldAny; - Any aNewAny; - aNewAny <<= Reference<XInterface>(static_cast<cppu::OWeakObject*>(pItemAcc)); - ImplFireAccessibleEvent(AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldAny, aNewAny); - } + ValueItemAcc* pItemAcc = nullptr; + if (pItem != nullptr) + pItemAcc = ValueItemAcc::getImplementation( pItem->GetAccessible( false/*bIsTransientChildrenDisabled*/ ) ); - // selection event + if( pItemAcc ) + { Any aOldAny; Any aNewAny; - ImplFireAccessibleEvent(AccessibleEventId::SELECTION_CHANGED, aOldAny, aNewAny); + aNewAny <<= Reference<XInterface>(static_cast<cppu::OWeakObject*>(pItemAcc)); + ImplFireAccessibleEvent(AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldAny, aNewAny); } - maHighlightHdl.Call(this); + + // selection event + Any aOldAny; + Any aNewAny; + ImplFireAccessibleEvent(AccessibleEventId::SELECTION_CHANGED, aOldAny, aNewAny); } + maHighlightHdl.Call(this); } void ValueSet::SetNoSelection() |