diff options
Diffstat (limited to 'svtools/source')
68 files changed, 4182 insertions, 4180 deletions
diff --git a/svtools/source/brwbox/brwbox1.cxx b/svtools/source/brwbox/brwbox1.cxx index fe7d5a8d58e2..275e8c9e5fa7 100644 --- a/svtools/source/brwbox/brwbox1.cxx +++ b/svtools/source/brwbox/brwbox1.cxx @@ -372,107 +372,107 @@ void BrowseBox::SetColumnPos( sal_uInt16 nColumnId, sal_uInt16 nPos ) return; // does the state change? - if (nOldPos != nPos) - { - // remark the column selection - sal_uInt16 nSelectedColId = ToggleSelectedColumn(); - - // determine old column area - Size aDataWinSize( pDataWin->GetSizePixel() ); - if ( pDataWin->pHeaderBar ) - aDataWinSize.Height() += pDataWin->pHeaderBar->GetSizePixel().Height(); + if (nOldPos == nPos) + return; - tools::Rectangle aFromRect( GetFieldRect( nColumnId) ); - aFromRect.Right() += 2*MIN_COLUMNWIDTH; + // remark the column selection + sal_uInt16 nSelectedColId = ToggleSelectedColumn(); - sal_uInt16 nNextPos = nOldPos + 1; - if ( nOldPos > nPos ) - nNextPos = nOldPos - 1; + // determine old column area + Size aDataWinSize( pDataWin->GetSizePixel() ); + if ( pDataWin->pHeaderBar ) + aDataWinSize.Height() += pDataWin->pHeaderBar->GetSizePixel().Height(); - BrowserColumn *pNextCol = pCols[ nNextPos ]; - tools::Rectangle aNextRect(GetFieldRect( pNextCol->GetId() )); + tools::Rectangle aFromRect( GetFieldRect( nColumnId) ); + aFromRect.Right() += 2*MIN_COLUMNWIDTH; - // move column internally - { - BrowserColumns::iterator it = pCols.begin(); - ::std::advance( it, nOldPos ); - BrowserColumn* pTemp = *it; - pCols.erase( it ); - it = pCols.begin(); - ::std::advance( it, nPos ); - pCols.insert( it, pTemp ); - } + sal_uInt16 nNextPos = nOldPos + 1; + if ( nOldPos > nPos ) + nNextPos = nOldPos - 1; - // determine new column area - tools::Rectangle aToRect( GetFieldRect( nColumnId ) ); - aToRect.Right() += 2*MIN_COLUMNWIDTH; + BrowserColumn *pNextCol = pCols[ nNextPos ]; + tools::Rectangle aNextRect(GetFieldRect( pNextCol->GetId() )); - // do scroll, let redraw - if( pDataWin->GetBackground().IsScrollable() ) - { - long nScroll = -aFromRect.GetWidth(); - tools::Rectangle aScrollArea; - if ( nOldPos > nPos ) - { - long nFrozenWidth = GetFrozenWidth(); - if ( aToRect.Left() < nFrozenWidth ) - aToRect.Left() = nFrozenWidth; - aScrollArea = tools::Rectangle(Point(aToRect.Left(),0), - Point(aNextRect.Right(),aDataWinSize.Height())); - nScroll *= -1; // reverse direction - } - else - aScrollArea = tools::Rectangle(Point(aNextRect.Left(),0), - Point(aToRect.Right(),aDataWinSize.Height())); + // move column internally + { + BrowserColumns::iterator it = pCols.begin(); + ::std::advance( it, nOldPos ); + BrowserColumn* pTemp = *it; + pCols.erase( it ); + it = pCols.begin(); + ::std::advance( it, nPos ); + pCols.insert( it, pTemp ); + } - pDataWin->Scroll( nScroll, 0, aScrollArea ); - aToRect.Top() = 0; - aToRect.Bottom() = aScrollArea.Bottom(); - Invalidate( aToRect ); - } - else - pDataWin->Window::Invalidate( InvalidateFlags::NoChildren ); + // determine new column area + tools::Rectangle aToRect( GetFieldRect( nColumnId ) ); + aToRect.Right() += 2*MIN_COLUMNWIDTH; - // adjust header bar positions - if ( pDataWin->pHeaderBar ) + // do scroll, let redraw + if( pDataWin->GetBackground().IsScrollable() ) + { + long nScroll = -aFromRect.GetWidth(); + tools::Rectangle aScrollArea; + if ( nOldPos > nPos ) { - sal_uInt16 nNewPos = nPos; - if ( GetColumnId(0) == HandleColumnId ) - --nNewPos; - pDataWin->pHeaderBar->MoveItem(nColumnId,nNewPos); + long nFrozenWidth = GetFrozenWidth(); + if ( aToRect.Left() < nFrozenWidth ) + aToRect.Left() = nFrozenWidth; + aScrollArea = tools::Rectangle(Point(aToRect.Left(),0), + Point(aNextRect.Right(),aDataWinSize.Height())); + nScroll *= -1; // reverse direction } - // remember the column selection - SetToggledSelectedColumn(nSelectedColId); + else + aScrollArea = tools::Rectangle(Point(aNextRect.Left(),0), + Point(aToRect.Right(),aDataWinSize.Height())); - if ( isAccessibleAlive() ) - { - commitTableEvent( - TABLE_MODEL_CHANGED, - makeAny( AccessibleTableModelChange( - DELETE, - 0, - GetRowCount(), - nOldPos, - nOldPos - ) - ), - Any() - ); + pDataWin->Scroll( nScroll, 0, aScrollArea ); + aToRect.Top() = 0; + aToRect.Bottom() = aScrollArea.Bottom(); + Invalidate( aToRect ); + } + else + pDataWin->Window::Invalidate( InvalidateFlags::NoChildren ); - commitTableEvent( - TABLE_MODEL_CHANGED, - makeAny( AccessibleTableModelChange( - INSERT, - 0, - GetRowCount(), - nPos, - nPos - ) - ), - Any() - ); - } + // adjust header bar positions + if ( pDataWin->pHeaderBar ) + { + sal_uInt16 nNewPos = nPos; + if ( GetColumnId(0) == HandleColumnId ) + --nNewPos; + pDataWin->pHeaderBar->MoveItem(nColumnId,nNewPos); } + // remember the column selection + SetToggledSelectedColumn(nSelectedColId); + + if ( !isAccessibleAlive() ) + return; + + commitTableEvent( + TABLE_MODEL_CHANGED, + makeAny( AccessibleTableModelChange( + DELETE, + 0, + GetRowCount(), + nOldPos, + nOldPos + ) + ), + Any() + ); + + commitTableEvent( + TABLE_MODEL_CHANGED, + makeAny( AccessibleTableModelChange( + INSERT, + 0, + GetRowCount(), + nPos, + nPos + ) + ), + Any() + ); } @@ -492,30 +492,30 @@ void BrowseBox::SetColumnTitle( sal_uInt16 nItemId, const OUString& rTitle ) // does the state change? BrowserColumn *pCol = pCols[ nItemPos ]; - if ( pCol->Title() != rTitle ) - { - OUString sOld(pCol->Title()); + if ( pCol->Title() == rTitle ) + return; - pCol->Title() = rTitle; + OUString sOld(pCol->Title()); - // adjust headerbar column - if ( pDataWin->pHeaderBar ) - pDataWin->pHeaderBar->SetItemText( nItemId, rTitle ); - else - { - // redraw visible columns - if ( GetUpdateMode() && ( pCol->IsFrozen() || nItemPos > nFirstCol ) ) - Invalidate( tools::Rectangle( Point(0,0), - Size( GetOutputSizePixel().Width(), GetTitleHeight() ) ) ); - } + pCol->Title() = rTitle; - if ( isAccessibleAlive() ) - { - commitTableEvent( TABLE_COLUMN_DESCRIPTION_CHANGED, - makeAny( rTitle ), - makeAny( sOld ) - ); - } + // adjust headerbar column + if ( pDataWin->pHeaderBar ) + pDataWin->pHeaderBar->SetItemText( nItemId, rTitle ); + else + { + // redraw visible columns + if ( GetUpdateMode() && ( pCol->IsFrozen() || nItemPos > nFirstCol ) ) + Invalidate( tools::Rectangle( Point(0,0), + Size( GetOutputSizePixel().Width(), GetTitleHeight() ) ) ); + } + + if ( isAccessibleAlive() ) + { + commitTableEvent( TABLE_COLUMN_DESCRIPTION_CHANGED, + makeAny( rTitle ), + makeAny( sOld ) + ); } } @@ -529,99 +529,98 @@ void BrowseBox::SetColumnWidth( sal_uInt16 nItemId, sal_uLong nWidth ) return; // does the state change? - if ( nWidth >= LONG_MAX || pCols[ nItemPos ]->Width() != nWidth ) - { - long nOldWidth = pCols[ nItemPos ]->Width(); + if ( !(nWidth >= LONG_MAX || pCols[ nItemPos ]->Width() != nWidth) ) + return; - // adjust last column, if necessary - if ( IsVisible() && nItemPos == pCols.size() - 1 ) + long nOldWidth = pCols[ nItemPos ]->Width(); + + // adjust last column, if necessary + if ( IsVisible() && nItemPos == pCols.size() - 1 ) + { + long nMaxWidth = pDataWin->GetSizePixel().Width(); + nMaxWidth -= pDataWin->bAutoSizeLastCol + ? GetFieldRect(nItemId).Left() + : GetFrozenWidth(); + if ( pDataWin->bAutoSizeLastCol || nWidth > (sal_uLong)nMaxWidth ) { - long nMaxWidth = pDataWin->GetSizePixel().Width(); - nMaxWidth -= pDataWin->bAutoSizeLastCol - ? GetFieldRect(nItemId).Left() - : GetFrozenWidth(); - if ( pDataWin->bAutoSizeLastCol || nWidth > (sal_uLong)nMaxWidth ) - { - nWidth = nMaxWidth > 16 ? nMaxWidth : nOldWidth; - } + nWidth = nMaxWidth > 16 ? nMaxWidth : nOldWidth; } + } - // OV - // In AutoSizeLastColumn(), we call SetColumnWidth with nWidth==0xffff. - // Thus, check here, if the width has actually changed. - if( (sal_uLong)nOldWidth == nWidth ) - return; + // OV + // In AutoSizeLastColumn(), we call SetColumnWidth with nWidth==0xffff. + // Thus, check here, if the width has actually changed. + if( (sal_uLong)nOldWidth == nWidth ) + return; - // do we want to display the change immediately? - bool bUpdate = GetUpdateMode() && - ( pCols[ nItemPos ]->IsFrozen() || nItemPos >= nFirstCol ); + // do we want to display the change immediately? + bool bUpdate = GetUpdateMode() && + ( pCols[ nItemPos ]->IsFrozen() || nItemPos >= nFirstCol ); - if ( bUpdate ) - { - // Selection hidden - DoHideCursor( "SetColumnWidth" ); - ToggleSelection(); - //!pDataWin->Update(); - //!Control::Update(); - } + if ( bUpdate ) + { + // Selection hidden + DoHideCursor( "SetColumnWidth" ); + ToggleSelection(); + //!pDataWin->Update(); + //!Control::Update(); + } - // set width - pCols[ nItemPos ]->SetWidth(nWidth, GetZoom()); + // set width + pCols[ nItemPos ]->SetWidth(nWidth, GetZoom()); - // scroll and invalidate - if ( bUpdate ) + // scroll and invalidate + if ( bUpdate ) + { + // get X-Pos of the column changed + long nX = 0; + for ( size_t nCol = 0; nCol < nItemPos; ++nCol ) { - // get X-Pos of the column changed - long nX = 0; - for ( size_t nCol = 0; nCol < nItemPos; ++nCol ) - { - BrowserColumn *pCol = pCols[ nCol ]; - if ( pCol->IsFrozen() || nCol >= nFirstCol ) - nX += pCol->Width(); - } - - // actually scroll+invalidate - pDataWin->SetClipRegion(); - bool bSelVis = bSelectionIsVisible; - bSelectionIsVisible = false; - if( GetBackground().IsScrollable() ) - { - - tools::Rectangle aScrRect( nX + std::min( (sal_uLong)nOldWidth, nWidth ), 0, - GetSizePixel().Width() , // the header is longer than the datawin - pDataWin->GetPosPixel().Y() - 1 ); - Control::Scroll( nWidth-nOldWidth, 0, aScrRect, SCROLL_FLAGS ); - aScrRect.Bottom() = pDataWin->GetSizePixel().Height(); - pDataWin->Scroll( nWidth-nOldWidth, 0, aScrRect, SCROLL_FLAGS ); - tools::Rectangle aInvRect( nX, 0, nX + std::max( nWidth, (sal_uLong)nOldWidth ), USHRT_MAX ); - Control::Invalidate( aInvRect, InvalidateFlags::NoChildren ); - pDataWin->Invalidate( aInvRect ); - } - else - { - Control::Invalidate( InvalidateFlags::NoChildren ); - pDataWin->Window::Invalidate( InvalidateFlags::NoChildren ); - } + BrowserColumn *pCol = pCols[ nCol ]; + if ( pCol->IsFrozen() || nCol >= nFirstCol ) + nX += pCol->Width(); + } + // actually scroll+invalidate + pDataWin->SetClipRegion(); + bool bSelVis = bSelectionIsVisible; + bSelectionIsVisible = false; + if( GetBackground().IsScrollable() ) + { - //!pDataWin->Update(); - //!Control::Update(); - bSelectionIsVisible = bSelVis; - ToggleSelection(); - DoShowCursor( "SetColumnWidth" ); + tools::Rectangle aScrRect( nX + std::min( (sal_uLong)nOldWidth, nWidth ), 0, + GetSizePixel().Width() , // the header is longer than the datawin + pDataWin->GetPosPixel().Y() - 1 ); + Control::Scroll( nWidth-nOldWidth, 0, aScrRect, SCROLL_FLAGS ); + aScrRect.Bottom() = pDataWin->GetSizePixel().Height(); + pDataWin->Scroll( nWidth-nOldWidth, 0, aScrRect, SCROLL_FLAGS ); + tools::Rectangle aInvRect( nX, 0, nX + std::max( nWidth, (sal_uLong)nOldWidth ), USHRT_MAX ); + Control::Invalidate( aInvRect, InvalidateFlags::NoChildren ); + pDataWin->Invalidate( aInvRect ); + } + else + { + Control::Invalidate( InvalidateFlags::NoChildren ); + pDataWin->Window::Invalidate( InvalidateFlags::NoChildren ); } - UpdateScrollbars(); - - // adjust headerbar column - if ( pDataWin->pHeaderBar ) - pDataWin->pHeaderBar->SetItemSize( - nItemId ? nItemId : USHRT_MAX - 1, nWidth ); - // adjust last column - if ( nItemPos != pCols.size() - 1 ) - AutoSizeLastColumn(); + //!pDataWin->Update(); + //!Control::Update(); + bSelectionIsVisible = bSelVis; + ToggleSelection(); + DoShowCursor( "SetColumnWidth" ); } + UpdateScrollbars(); + + // adjust headerbar column + if ( pDataWin->pHeaderBar ) + pDataWin->pHeaderBar->SetItemSize( + nItemId ? nItemId : USHRT_MAX - 1, nWidth ); + + // adjust last column + if ( nItemPos != pCols.size() - 1 ) + AutoSizeLastColumn(); } @@ -695,27 +694,27 @@ void BrowseBox::RemoveColumn( sal_uInt16 nItemId ) SetColumnWidth( GetColumnId( nPos - 1 ), LONG_MAX ); } - if ( isAccessibleAlive() ) - { - commitTableEvent( - TABLE_MODEL_CHANGED, - makeAny( AccessibleTableModelChange( DELETE, - 0, - GetRowCount(), - nPos, - nPos - ) - ), - Any() - ); + if ( !isAccessibleAlive() ) + return; - commitHeaderBarEvent( - CHILD, - Any(), - makeAny( CreateAccessibleColumnHeader( nPos ) ), - true - ); - } + commitTableEvent( + TABLE_MODEL_CHANGED, + makeAny( AccessibleTableModelChange( DELETE, + 0, + GetRowCount(), + nPos, + nPos + ) + ), + Any() + ); + + commitHeaderBarEvent( + CHILD, + Any(), + makeAny( CreateAccessibleColumnHeader( nPos ) ), + true + ); } @@ -752,39 +751,39 @@ void BrowseBox::RemoveColumns() Control::Invalidate(); } - if ( isAccessibleAlive() ) - { - if ( pCols.size() != nOldCount ) - { - // all columns should be removed, so we remove the column header bar and append it again - // to avoid to notify every column remove - commitBrowseBoxEvent( - CHILD, - Any(), - makeAny(m_pImpl->getAccessibleHeaderBar(BBTYPE_COLUMNHEADERBAR)) - ); + if ( !isAccessibleAlive() ) + return; - // and now append it again - commitBrowseBoxEvent( - CHILD, - makeAny(m_pImpl->getAccessibleHeaderBar(BBTYPE_COLUMNHEADERBAR)), - Any() - ); + if ( pCols.size() == nOldCount ) + return; - // notify a table model change - commitTableEvent( - TABLE_MODEL_CHANGED, - makeAny ( AccessibleTableModelChange( DELETE, - 0, - GetRowCount(), - 0, - nOldCount - ) - ), - Any() - ); - } - } + // all columns should be removed, so we remove the column header bar and append it again + // to avoid to notify every column remove + commitBrowseBoxEvent( + CHILD, + Any(), + makeAny(m_pImpl->getAccessibleHeaderBar(BBTYPE_COLUMNHEADERBAR)) + ); + + // and now append it again + commitBrowseBoxEvent( + CHILD, + makeAny(m_pImpl->getAccessibleHeaderBar(BBTYPE_COLUMNHEADERBAR)), + Any() + ); + + // notify a table model change + commitTableEvent( + TABLE_MODEL_CHANGED, + makeAny ( AccessibleTableModelChange( DELETE, + 0, + GetRowCount(), + 0, + nOldCount + ) + ), + Any() + ); } @@ -1086,38 +1085,38 @@ void BrowseBox::Clear() DoShowCursor( "Clear" ); CursorMoved(); - if ( isAccessibleAlive() ) - { - // all rows should be removed, so we remove the row header bar and append it again - // to avoid to notify every row remove - if ( nOldRowCount != nRowCount ) - { - commitBrowseBoxEvent( - CHILD, - Any(), - makeAny( m_pImpl->getAccessibleHeaderBar( BBTYPE_ROWHEADERBAR ) ) - ); + if ( !isAccessibleAlive() ) + return; - // and now append it again - commitBrowseBoxEvent( - CHILD, - makeAny( m_pImpl->getAccessibleHeaderBar( BBTYPE_ROWHEADERBAR ) ), - Any() - ); + // all rows should be removed, so we remove the row header bar and append it again + // to avoid to notify every row remove + if ( nOldRowCount == nRowCount ) + return; - // notify a table model change - commitTableEvent( - TABLE_MODEL_CHANGED, - makeAny( AccessibleTableModelChange( DELETE, - 0, - nOldRowCount, - 0, - GetColumnCount()) - ), - Any() - ); - } - } + commitBrowseBoxEvent( + CHILD, + Any(), + makeAny( m_pImpl->getAccessibleHeaderBar( BBTYPE_ROWHEADERBAR ) ) + ); + + // and now append it again + commitBrowseBoxEvent( + CHILD, + makeAny( m_pImpl->getAccessibleHeaderBar( BBTYPE_ROWHEADERBAR ) ), + Any() + ); + + // notify a table model change + commitTableEvent( + TABLE_MODEL_CHANGED, + makeAny( AccessibleTableModelChange( DELETE, + 0, + nOldRowCount, + 0, + GetColumnCount()) + ), + Any() + ); } void BrowseBox::RowInserted( long nRow, long nNumRows, bool bDoPaint, bool bKeepSelection ) @@ -1662,27 +1661,27 @@ void BrowseBox::SelectAll() // restore screen SAL_INFO("svtools", "BrowseBox::ShowCursor " << this ); - if ( isAccessibleAlive() ) - { - commitTableEvent( - SELECTION_CHANGED, - Any(), - Any() - ); - commitHeaderBarEvent( - SELECTION_CHANGED, - Any(), - Any(), - true - ); // column header event + if ( !isAccessibleAlive() ) + return; - commitHeaderBarEvent( - SELECTION_CHANGED, - Any(), - Any(), - false - ); // row header event - } + commitTableEvent( + SELECTION_CHANGED, + Any(), + Any() + ); + commitHeaderBarEvent( + SELECTION_CHANGED, + Any(), + Any(), + true + ); // column header event + + commitHeaderBarEvent( + SELECTION_CHANGED, + Any(), + Any(), + false + ); // row header event } @@ -1741,20 +1740,20 @@ void BrowseBox::SelectRow( long nRow, bool _bSelect, bool bExpand ) // restore screen SAL_INFO("svtools", "BrowseBox::ShowCursor " << this ); - if ( isAccessibleAlive() ) - { - commitTableEvent( - SELECTION_CHANGED, - Any(), - Any() - ); - commitHeaderBarEvent( - SELECTION_CHANGED, - Any(), - Any(), - false - ); // row header event - } + if ( !isAccessibleAlive() ) + return; + + commitTableEvent( + SELECTION_CHANGED, + Any(), + Any() + ); + commitHeaderBarEvent( + SELECTION_CHANGED, + Any(), + Any(), + false + ); // row header event } diff --git a/svtools/source/brwbox/brwbox2.cxx b/svtools/source/brwbox/brwbox2.cxx index 4e341b72dbf4..f1030cd9ec31 100644 --- a/svtools/source/brwbox/brwbox2.cxx +++ b/svtools/source/brwbox/brwbox2.cxx @@ -576,57 +576,57 @@ void BrowseBox::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle // Title Bar // If there is a handle column and if the header bar is available, only // take the HandleColumn into account - if (nTitleLines && (!bHeaderBar || bHandleCol)) + if (!(nTitleLines && (!bHeaderBar || bHandleCol))) + return; + + // iterate through columns to redraw + long nX = 0; + size_t nCol; + for (nCol = 0; nCol < pCols.size() && nX < rRect.Right(); ++nCol) { - // iterate through columns to redraw - long nX = 0; - size_t nCol; - for (nCol = 0; nCol < pCols.size() && nX < rRect.Right(); ++nCol) - { - // skip invisible columns between frozen and scrollable area - if (nCol < nFirstCol && !pCols[nCol]->IsFrozen()) - nCol = nFirstCol; + // skip invisible columns between frozen and scrollable area + if (nCol < nFirstCol && !pCols[nCol]->IsFrozen()) + nCol = nFirstCol; - // only the handle column? - if (bHeaderBar && bHandleCol && nCol > 0) - break; + // only the handle column? + if (bHeaderBar && bHandleCol && nCol > 0) + break; - BrowserColumn* pCol = pCols[nCol]; + BrowserColumn* pCol = pCols[nCol]; - // draw the column and increment position - if ( pCol->Width() > 4 ) - { - ButtonFrame aButtonFrame( Point( nX, 0 ), - Size( pCol->Width()-1, GetTitleHeight()-1 ), - pCol->Title(), !IsEnabled()); - aButtonFrame.Draw(rRenderContext); - rRenderContext.DrawLine(Point(nX + pCol->Width() - 1, 0), - Point(nX + pCol->Width() - 1, GetTitleHeight() - 1)); - } - else - { - rRenderContext.Push(PushFlags::FILLCOLOR); - rRenderContext.SetFillColor(Color(COL_BLACK)); - rRenderContext.DrawRect(tools::Rectangle(Point(nX, 0), Size(pCol->Width(), GetTitleHeight() - 1))); - rRenderContext.Pop(); - } - - // skip column - nX += pCol->Width(); + // draw the column and increment position + if ( pCol->Width() > 4 ) + { + ButtonFrame aButtonFrame( Point( nX, 0 ), + Size( pCol->Width()-1, GetTitleHeight()-1 ), + pCol->Title(), !IsEnabled()); + aButtonFrame.Draw(rRenderContext); + rRenderContext.DrawLine(Point(nX + pCol->Width() - 1, 0), + Point(nX + pCol->Width() - 1, GetTitleHeight() - 1)); } - - // retouching - if ( !bHeaderBar && nCol == pCols.size() ) + else { - const StyleSettings &rSettings = rRenderContext.GetSettings().GetStyleSettings(); - Color aColFace(rSettings.GetFaceColor()); - rRenderContext.Push(PushFlags::FILLCOLOR | PushFlags::LINECOLOR); - rRenderContext.SetFillColor(aColFace); - rRenderContext.SetLineColor(aColFace); - rRenderContext.DrawRect(tools::Rectangle(Point(nX, 0), - Point(rRect.Right(), GetTitleHeight() - 2 ))); + rRenderContext.Push(PushFlags::FILLCOLOR); + rRenderContext.SetFillColor(Color(COL_BLACK)); + rRenderContext.DrawRect(tools::Rectangle(Point(nX, 0), Size(pCol->Width(), GetTitleHeight() - 1))); rRenderContext.Pop(); } + + // skip column + nX += pCol->Width(); + } + + // retouching + if ( !bHeaderBar && nCol == pCols.size() ) + { + const StyleSettings &rSettings = rRenderContext.GetSettings().GetStyleSettings(); + Color aColFace(rSettings.GetFaceColor()); + rRenderContext.Push(PushFlags::FILLCOLOR | PushFlags::LINECOLOR); + rRenderContext.SetFillColor(aColFace); + rRenderContext.SetLineColor(aColFace); + rRenderContext.DrawRect(tools::Rectangle(Point(nX, 0), + Point(rRect.Right(), GetTitleHeight() - 2 ))); + rRenderContext.Pop(); } } diff --git a/svtools/source/brwbox/brwbox3.cxx b/svtools/source/brwbox/brwbox3.cxx index 8eff53f03fe0..073277734c89 100644 --- a/svtools/source/brwbox/brwbox3.cxx +++ b/svtools/source/brwbox/brwbox3.cxx @@ -497,23 +497,23 @@ void BrowseBox::GetAllSelectedColumns( css::uno::Sequence< sal_Int32 >& _rColumn { const MultiSelection* pColumnSel = GetColumnSelection(); sal_Int32 nCount = GetSelectedColumnCount(); - if( pColumnSel && nCount ) - { - _rColumns.realloc( nCount ); + if( !(pColumnSel && nCount) ) + return; + + _rColumns.realloc( nCount ); - sal_Int32 nIndex = 0; - const size_t nRangeCount = pColumnSel->GetRangeCount(); - for( size_t nRange = 0; nRange < nRangeCount; ++nRange ) + sal_Int32 nIndex = 0; + const size_t nRangeCount = pColumnSel->GetRangeCount(); + for( size_t nRange = 0; nRange < nRangeCount; ++nRange ) + { + const Range& rRange = pColumnSel->GetRange( nRange ); + // loop has to include aRange.Max() + for( sal_Int32 nCol = rRange.Min(); nCol <= (sal_Int32)rRange.Max(); ++nCol ) { - const Range& rRange = pColumnSel->GetRange( nRange ); - // loop has to include aRange.Max() - for( sal_Int32 nCol = rRange.Min(); nCol <= (sal_Int32)rRange.Max(); ++nCol ) - { - DBG_ASSERT( nIndex < nCount, - "GetAllSelectedColumns - range overflow" ); - _rColumns[ nIndex ] = nCol; - ++nIndex; - } + DBG_ASSERT( nIndex < nCount, + "GetAllSelectedColumns - range overflow" ); + _rColumns[ nIndex ] = nCol; + ++nIndex; } } } diff --git a/svtools/source/brwbox/brwhead.cxx b/svtools/source/brwbox/brwhead.cxx index 9db299802b1d..f8ffa0e834e3 100644 --- a/svtools/source/brwbox/brwhead.cxx +++ b/svtools/source/brwbox/brwhead.cxx @@ -69,35 +69,35 @@ void BrowserHeader::EndDrag() // not aborted? sal_uInt16 nId = GetCurItemId(); - if ( nId ) + if ( !nId ) + return; + + // handle column? + if ( nId == USHRT_MAX-1 ) + nId = 0; + + if ( !IsItemMode() ) + { + // column resize + _pBrowseBox->SetColumnWidth( nId, GetItemSize( nId ) ); + _pBrowseBox->ColumnResized( nId ); + SetItemSize( nId, _pBrowseBox->GetColumnWidth( nId ) ); + } + else { - // handle column? - if ( nId == USHRT_MAX-1 ) - nId = 0; + // column drag + // did the position actually change? + // take the handle column into account + sal_uInt16 nOldPos = _pBrowseBox->GetColumnPos(nId), + nNewPos = GetItemPos( nId ); - if ( !IsItemMode() ) - { - // column resize - _pBrowseBox->SetColumnWidth( nId, GetItemSize( nId ) ); - _pBrowseBox->ColumnResized( nId ); - SetItemSize( nId, _pBrowseBox->GetColumnWidth( nId ) ); - } - else + if (_pBrowseBox->GetColumnId(0) == BrowseBox::HandleColumnId) + nNewPos++; + + if (nOldPos != nNewPos) { - // column drag - // did the position actually change? - // take the handle column into account - sal_uInt16 nOldPos = _pBrowseBox->GetColumnPos(nId), - nNewPos = GetItemPos( nId ); - - if (_pBrowseBox->GetColumnId(0) == BrowseBox::HandleColumnId) - nNewPos++; - - if (nOldPos != nNewPos) - { - _pBrowseBox->SetColumnPos( nId, nNewPos ); - _pBrowseBox->ColumnMoved( nId ); - } + _pBrowseBox->SetColumnPos( nId, nNewPos ); + _pBrowseBox->ColumnMoved( nId ); } } } diff --git a/svtools/source/brwbox/editbrowsebox.cxx b/svtools/source/brwbox/editbrowsebox.cxx index 2df958fd2ef5..eb092d16c51f 100644 --- a/svtools/source/brwbox/editbrowsebox.cxx +++ b/svtools/source/brwbox/editbrowsebox.cxx @@ -489,44 +489,45 @@ namespace svt else if (IsEditing() && !aController->GetWindow().HasChildPathFocus()) AsynchGetFocus(); - if (IsEditing() && aController->GetWindow().IsEnabled() && aController->WantMouseEvent()) - { // forwards the event to the control + if (!(IsEditing() && aController->GetWindow().IsEnabled() && aController->WantMouseEvent())) +return; - // If the field has been moved previously, we have to adjust the position +// forwards the event to the control - aController->GetWindow().GrabFocus(); + // If the field has been moved previously, we have to adjust the position - // the position of the event relative to the controller's window - Point aPos = _rEvt.GetPosPixel() - _rEvt.GetRect().TopLeft(); - // the (child) window which should really get the event - vcl::Window* pRealHandler = aController->GetWindow().FindWindow(aPos); - if (pRealHandler) - // the coords relative to this real handler - aPos -= pRealHandler->GetPosPixel(); - else - pRealHandler = &aController->GetWindow(); + aController->GetWindow().GrabFocus(); + + // the position of the event relative to the controller's window + Point aPos = _rEvt.GetPosPixel() - _rEvt.GetRect().TopLeft(); + // the (child) window which should really get the event + vcl::Window* pRealHandler = aController->GetWindow().FindWindow(aPos); + if (pRealHandler) + // the coords relative to this real handler + aPos -= pRealHandler->GetPosPixel(); + else + pRealHandler = &aController->GetWindow(); - // the faked event - MouseEvent aEvent(aPos, _rEvt.GetClicks(), _rEvt.GetMode(), - _rEvt.GetButtons(), - _rEvt.GetModifier()); + // the faked event + MouseEvent aEvent(aPos, _rEvt.GetClicks(), _rEvt.GetMode(), + _rEvt.GetButtons(), + _rEvt.GetModifier()); - pRealHandler->MouseButtonDown(aEvent); - if (_bUp) - pRealHandler->MouseButtonUp(aEvent); + pRealHandler->MouseButtonDown(aEvent); + if (_bUp) + pRealHandler->MouseButtonUp(aEvent); - vcl::Window *pWin = &aController->GetWindow(); - if (!pWin->IsTracking()) + vcl::Window *pWin = &aController->GetWindow(); + if (!pWin->IsTracking()) + { + for (pWin = pWin->GetWindow(GetWindowType::FirstChild); + pWin && !pWin->IsTracking(); + pWin = pWin->GetWindow(GetWindowType::Next)) { - for (pWin = pWin->GetWindow(GetWindowType::FirstChild); - pWin && !pWin->IsTracking(); - pWin = pWin->GetWindow(GetWindowType::Next)) - { - } } - if (pWin && pWin->IsTracking()) - pWin->EndTracking(); } + if (pWin && pWin->IsTracking()) + pWin->EndTracking(); } @@ -770,20 +771,20 @@ namespace svt GetDataWindow().ApplyControlForeground(GetDataWindow(), rStyleSettings.GetFieldTextColor()); } - if (bBackground) // FIXME: Outside of Paint Hierarchy + if (!bBackground) // FIXME: Outside of Paint Hierarchy + return; + + if (GetDataWindow().IsControlBackground()) { - if (GetDataWindow().IsControlBackground()) - { - GetDataWindow().SetControlBackground(GetControlBackground()); - GetDataWindow().SetBackground(GetDataWindow().GetControlBackground()); - GetDataWindow().SetFillColor(GetDataWindow().GetControlBackground()); - } - else - { - GetDataWindow().SetControlBackground(); - GetDataWindow().SetBackground(rStyleSettings.GetFieldColor()); - GetDataWindow().SetFillColor(rStyleSettings.GetFieldColor()); - } + GetDataWindow().SetControlBackground(GetControlBackground()); + GetDataWindow().SetBackground(GetDataWindow().GetControlBackground()); + GetDataWindow().SetFillColor(GetDataWindow().GetControlBackground()); + } + else + { + GetDataWindow().SetControlBackground(); + GetDataWindow().SetBackground(rStyleSettings.GetFieldColor()); + GetDataWindow().SetFillColor(rStyleSettings.GetFieldColor()); } } @@ -940,38 +941,38 @@ namespace svt return; } - if (nEditRow >= 0 && nEditCol > HandleColumnId) + if (!(nEditRow >= 0 && nEditCol > HandleColumnId)) + return; + + aController = GetController(nRow, nCol); + if (aController.is()) { - aController = GetController(nRow, nCol); - if (aController.is()) - { - tools::Rectangle aRect( GetCellRect(nEditRow, nEditCol, false)); - ResizeController(aController, aRect); + tools::Rectangle aRect( GetCellRect(nEditRow, nEditCol, false)); + ResizeController(aController, aRect); - InitController(aController, nEditRow, nEditCol); + InitController(aController, nEditRow, nEditCol); - aController->ClearModified(); - aController->SetModifyHdl(LINK(this,EditBrowseBox,ModifyHdl)); - EnableAndShow(); + aController->ClearModified(); + aController->SetModifyHdl(LINK(this,EditBrowseBox,ModifyHdl)); + EnableAndShow(); - if ( isAccessibleAlive() ) - implCreateActiveAccessible(); + if ( isAccessibleAlive() ) + implCreateActiveAccessible(); - // activate the cell only of the browser has the focus - if ( bHasFocus && bCellFocus ) - AsynchGetFocus(); - } - else + // activate the cell only of the browser has the focus + if ( bHasFocus && bCellFocus ) + AsynchGetFocus(); + } + else + { + // no controller -> we have a new "active descendant" + if ( isAccessibleAlive() && HasFocus() ) { - // no controller -> we have a new "active descendant" - if ( isAccessibleAlive() && HasFocus() ) - { - commitTableEvent( - ACTIVE_DESCENDANT_CHANGED, - makeAny( CreateAccessibleCell( nRow, GetColumnPos( nCol -1) ) ), - Any() - ); - } + commitTableEvent( + ACTIVE_DESCENDANT_CHANGED, + makeAny( CreateAccessibleCell( nRow, GetColumnPos( nCol -1) ) ), + Any() + ); } } } @@ -979,37 +980,37 @@ namespace svt void EditBrowseBox::DeactivateCell(bool bUpdate) { - if (IsEditing()) + if (!IsEditing()) + return; + + if ( isAccessibleAlive() ) { - if ( isAccessibleAlive() ) - { - commitBrowseBoxEvent( CHILD, Any(), makeAny( m_aImpl->m_xActiveCell ) ); - m_aImpl->clearActiveCell(); - } + commitBrowseBoxEvent( CHILD, Any(), makeAny( m_aImpl->m_xActiveCell ) ); + m_aImpl->clearActiveCell(); + } - aOldController = aController; - aController.clear(); + aOldController = aController; + aController.clear(); - // reset the modify handler - aOldController->SetModifyHdl(Link<LinkParamNone*,void>()); + // reset the modify handler + aOldController->SetModifyHdl(Link<LinkParamNone*,void>()); - if (bHasFocus) - GrabFocus(); // ensure that we have (and keep) the focus + if (bHasFocus) + GrabFocus(); // ensure that we have (and keep) the focus - aOldController->suspend(); + aOldController->suspend(); - // update if requested - if (bUpdate) - Update(); + // update if requested + if (bUpdate) + Update(); - nOldEditCol = nEditCol; - nOldEditRow = nEditRow; + nOldEditCol = nEditCol; + nOldEditRow = nEditRow; - // release the controller (asynchronously) - if (nEndEvent) - Application::RemoveUserEvent(nEndEvent); - nEndEvent = Application::PostUserEvent(LINK(this,EditBrowseBox,EndEditHdl), nullptr, true); - } + // release the controller (asynchronously) + if (nEndEvent) + Application::RemoveUserEvent(nEndEvent); + nEndEvent = Application::PostUserEvent(LINK(this,EditBrowseBox,EndEditHdl), nullptr, true); } diff --git a/svtools/source/brwbox/editbrowsebox2.cxx b/svtools/source/brwbox/editbrowsebox2.cxx index d705b99d063a..3d962b425501 100644 --- a/svtools/source/brwbox/editbrowsebox2.cxx +++ b/svtools/source/brwbox/editbrowsebox2.cxx @@ -65,24 +65,24 @@ void EditBrowseBox::implCreateActiveAccessible( ) DBG_ASSERT( IsEditing(), "EditBrowseBox::implCreateActiveAccessible: not to be called if we're not editing currently!" ); DBG_ASSERT( !m_aImpl->m_xActiveCell.is(), "EditBrowseBox::implCreateActiveAccessible: not to be called if the old one is still alive!" ); - if ( !m_aImpl->m_xActiveCell.is() && IsEditing() ) - { - Reference< XAccessible > xCont = aController->GetWindow().GetAccessible(); - Reference< XAccessible > xMy = GetAccessible(); - if ( xMy.is() && xCont.is() ) - { - m_aImpl->m_xActiveCell = getAccessibleFactory().createEditBrowseBoxTableCellAccess( - xMy, // parent accessible - xCont, // control accessible - VCLUnoHelper::GetInterface( &aController->GetWindow() ), // focus window (for notifications) - *this, // the browse box - GetCurRow(), - GetColumnPos( GetCurColumnId() ) - ); - - commitBrowseBoxEvent( CHILD, makeAny( m_aImpl->m_xActiveCell ), Any() ); - } - } + if ( !(!m_aImpl->m_xActiveCell.is() && IsEditing()) ) + return; + + Reference< XAccessible > xCont = aController->GetWindow().GetAccessible(); + Reference< XAccessible > xMy = GetAccessible(); + if ( !(xMy.is() && xCont.is()) ) + return; + + m_aImpl->m_xActiveCell = getAccessibleFactory().createEditBrowseBoxTableCellAccess( + xMy, // parent accessible + xCont, // control accessible + VCLUnoHelper::GetInterface( &aController->GetWindow() ), // focus window (for notifications) + *this, // the browse box + GetCurRow(), + GetColumnPos( GetCurColumnId() ) + ); + + commitBrowseBoxEvent( CHILD, makeAny( m_aImpl->m_xActiveCell ), Any() ); } @@ -127,40 +127,40 @@ void EditBrowseBox::DetermineFocus( const GetFocusFlags _nGetFocusFlags ) pWindow = pWindow->GetParent()) bFocus = pWindow == this; - if (bFocus != bHasFocus) - { - bHasFocus = bFocus; + if (bFocus == bHasFocus) + return; + + bHasFocus = bFocus; + + if ( !(GetBrowserFlags( ) & EditBrowseBoxFlags::SMART_TAB_TRAVEL) ) + return; + + if ( !(bHasFocus // we got the focus + && ( _nGetFocusFlags & GetFocusFlags::Tab )) // using the TAB key + ) + return; - if ( GetBrowserFlags( ) & EditBrowseBoxFlags::SMART_TAB_TRAVEL ) + long nRows = GetRowCount(); + sal_uInt16 nCols = ColCount(); + + if ( ( nRows > 0 ) && ( nCols > 0 ) ) + { + if ( _nGetFocusFlags & GetFocusFlags::Forward ) { - if ( bHasFocus // we got the focus - && ( _nGetFocusFlags & GetFocusFlags::Tab ) // using the TAB key - ) + if ( GetColumnId( 0 ) != HandleColumnId ) { - long nRows = GetRowCount(); - sal_uInt16 nCols = ColCount(); - - if ( ( nRows > 0 ) && ( nCols > 0 ) ) - { - if ( _nGetFocusFlags & GetFocusFlags::Forward ) - { - if ( GetColumnId( 0 ) != HandleColumnId ) - { - GoToRowColumnId( 0, GetColumnId( 0 ) ); - } - else - { // the first column is the handle column -> not focussable - if ( nCols > 1 ) - GoToRowColumnId( 0, GetColumnId( 1 ) ); - } - } - else if ( _nGetFocusFlags & GetFocusFlags::Backward ) - { - GoToRowColumnId( nRows - 1, GetColumnId( nCols -1 ) ); - } - } + GoToRowColumnId( 0, GetColumnId( 0 ) ); + } + else + { // the first column is the handle column -> not focussable + if ( nCols > 1 ) + GoToRowColumnId( 0, GetColumnId( 1 ) ); } } + else if ( _nGetFocusFlags & GetFocusFlags::Backward ) + { + GoToRowColumnId( nRows - 1, GetColumnId( nCols -1 ) ); + } } } diff --git a/svtools/source/config/apearcfg.cxx b/svtools/source/config/apearcfg.cxx index 7ccfa0f142a9..e74cbe33ae84 100644 --- a/svtools/source/config/apearcfg.cxx +++ b/svtools/source/config/apearcfg.cxx @@ -54,35 +54,35 @@ SvtTabAppearanceCfg::SvtTabAppearanceCfg() const Any* pValues = aValues.getConstArray(); DBG_ASSERT(aValues.getLength() == rNames.getLength(), "GetProperties failed"); - if(aValues.getLength() == rNames.getLength()) + if(aValues.getLength() != rNames.getLength()) + return; + + for(int nProp = 0; nProp < rNames.getLength(); ++nProp, ++pValues) { - for(int nProp = 0; nProp < rNames.getLength(); ++nProp, ++pValues) + if(pValues->hasValue()) { - if(pValues->hasValue()) + switch(nProp) { - switch(nProp) + case 0: //"Window/Drag" + { + short nTmp; + if (*pValues >>= nTmp) + nDragMode = (DragMode)nTmp; + break; + } + case 1: bMenuMouseFollow = *o3tl::doAccess<bool>(*pValues); break; //"Menu/FollowMouse", + case 2: { - case 0: //"Window/Drag" - { - short nTmp; - if (*pValues >>= nTmp) - nDragMode = (DragMode)nTmp; - break; - } - case 1: bMenuMouseFollow = *o3tl::doAccess<bool>(*pValues); break; //"Menu/FollowMouse", - case 2: - { - short nTmp; - if (*pValues >>= nTmp) - nSnapMode = (SnapType)nTmp; //"Dialog/MousePositioning", - break; - } - case 3: { short nTmp = 0; *pValues >>= nTmp; nMiddleMouse = static_cast<MouseMiddleButtonAction>(nTmp); break; } //"Dialog/MiddleMouseButton", + short nTmp; + if (*pValues >>= nTmp) + nSnapMode = (SnapType)nTmp; //"Dialog/MousePositioning", + break; + } + case 3: { short nTmp = 0; *pValues >>= nTmp; nMiddleMouse = static_cast<MouseMiddleButtonAction>(nTmp); break; } //"Dialog/MiddleMouseButton", #if defined( UNX ) - case 4: bFontAntialiasing = *o3tl::doAccess<bool>(*pValues); break; // "FontAntialising/Enabled", - case 5: *pValues >>= nAAMinPixelHeight; break; // "FontAntialising/MinPixelHeight", + case 4: bFontAntialiasing = *o3tl::doAccess<bool>(*pValues); break; // "FontAntialising/Enabled", + case 5: *pValues >>= nAAMinPixelHeight; break; // "FontAntialising/MinPixelHeight", #endif - } } } } diff --git a/svtools/source/config/colorcfg.cxx b/svtools/source/config/colorcfg.cxx index 9acf01a6326c..c7be767896a3 100644 --- a/svtools/source/config/colorcfg.cxx +++ b/svtools/source/config/colorcfg.cxx @@ -346,24 +346,24 @@ IMPL_LINK( ColorConfig_Impl, DataChangedEventListener, VclSimpleEvent&, rEvent, void ColorConfig_Impl::ImplUpdateApplicationSettings() { Application* pApp = GetpApp(); - if( pApp ) - { - AllSettings aSettings = Application::GetSettings(); - StyleSettings aStyleSettings( aSettings.GetStyleSettings() ); + if( !pApp ) + return; - ColorConfigValue aRet = GetColorConfigValue(svtools::FONTCOLOR); - if(COL_AUTO == sal::static_int_cast<ColorData>(aRet.nColor)) - aRet.nColor = ColorConfig::GetDefaultColor(svtools::FONTCOLOR).GetColor(); + AllSettings aSettings = Application::GetSettings(); + StyleSettings aStyleSettings( aSettings.GetStyleSettings() ); - Color aFontColor(aRet.nColor); + ColorConfigValue aRet = GetColorConfigValue(svtools::FONTCOLOR); + if(COL_AUTO == sal::static_int_cast<ColorData>(aRet.nColor)) + aRet.nColor = ColorConfig::GetDefaultColor(svtools::FONTCOLOR).GetColor(); - if( aStyleSettings.GetFontColor() != aFontColor ) - { - aStyleSettings.SetFontColor( aFontColor ); + Color aFontColor(aRet.nColor); - aSettings.SetStyleSettings( aStyleSettings ); - Application::SetSettings( aSettings ); - } + if( aStyleSettings.GetFontColor() != aFontColor ) + { + aStyleSettings.SetFontColor( aFontColor ); + + aSettings.SetStyleSettings( aStyleSettings ); + Application::SetSettings( aSettings ); } } diff --git a/svtools/source/config/helpopt.cxx b/svtools/source/config/helpopt.cxx index bc1ac4d014c1..3a2ec50d60da 100644 --- a/svtools/source/config/helpopt.cxx +++ b/svtools/source/config/helpopt.cxx @@ -136,66 +136,66 @@ void SvtHelpOptions_Impl::Load(const uno::Sequence< OUString>& rPropertyNames) Sequence< Any > aValues = GetProperties( rPropertyNames ); const Any* pValues = aValues.getConstArray(); DBG_ASSERT( aValues.getLength() == rPropertyNames.getLength(), "GetProperties failed" ); - if ( aValues.getLength() == rPropertyNames.getLength() ) + if ( aValues.getLength() != rPropertyNames.getLength() ) + return; + + for ( int nProp = 0; nProp < rPropertyNames.getLength(); nProp++ ) { - for ( int nProp = 0; nProp < rPropertyNames.getLength(); nProp++ ) + assert(pValues[nProp].hasValue() && "property value missing"); + if ( pValues[nProp].hasValue() ) { - assert(pValues[nProp].hasValue() && "property value missing"); - if ( pValues[nProp].hasValue() ) + bool bTmp; + OUString aTmpStr; + sal_Int32 nTmpInt = 0; + if ( pValues[nProp] >>= bTmp ) { - bool bTmp; - OUString aTmpStr; - sal_Int32 nTmpInt = 0; - if ( pValues[nProp] >>= bTmp ) - { - switch ( static_cast< HelpProperty >( - lcl_MapPropertyName(rPropertyNames[nProp], aInternalPropertyNames) ) ) - { - case HelpProperty::ExtendedHelp: - bExtendedHelp = bTmp; - break; - case HelpProperty::HelpTips: - bHelpTips = bTmp; - break; - default: - SAL_WARN( "svtools.config", "Wrong Member!" ); - break; - } - } - else if ( pValues[nProp] >>= aTmpStr ) + switch ( static_cast< HelpProperty >( + lcl_MapPropertyName(rPropertyNames[nProp], aInternalPropertyNames) ) ) { - switch ( static_cast< HelpProperty >(nProp) ) - { - case HelpProperty::Locale: - aLocale = aTmpStr; - break; - - case HelpProperty::System: - aSystem = aTmpStr; - break; - case HelpProperty::StyleSheet: - sHelpStyleSheet = aTmpStr; + case HelpProperty::ExtendedHelp: + bExtendedHelp = bTmp; + break; + case HelpProperty::HelpTips: + bHelpTips = bTmp; + break; + default: + SAL_WARN( "svtools.config", "Wrong Member!" ); break; - default: - SAL_WARN( "svtools.config", "Wrong Member!" ); - break; - } - } - else if ( pValues[nProp] >>= nTmpInt ) - { - SAL_WARN( "svtools.config", "Wrong Member!" ); } - else + } + else if ( pValues[nProp] >>= aTmpStr ) + { + switch ( static_cast< HelpProperty >(nProp) ) { - SAL_WARN( "svtools.config", "Wrong Type!" ); + case HelpProperty::Locale: + aLocale = aTmpStr; + break; + + case HelpProperty::System: + aSystem = aTmpStr; + break; + case HelpProperty::StyleSheet: + sHelpStyleSheet = aTmpStr; + break; + default: + SAL_WARN( "svtools.config", "Wrong Member!" ); + break; } } + else if ( pValues[nProp] >>= nTmpInt ) + { + SAL_WARN( "svtools.config", "Wrong Member!" ); + } + else + { + SAL_WARN( "svtools.config", "Wrong Type!" ); + } } - if ( IsHelpTips() != Help::IsQuickHelpEnabled() ) - IsHelpTips() ? Help::EnableQuickHelp() : Help::DisableQuickHelp(); - if ( IsExtendedHelp() != Help::IsBalloonHelpEnabled() ) - IsExtendedHelp() ? Help::EnableBalloonHelp() : Help::DisableBalloonHelp(); } + if ( IsHelpTips() != Help::IsQuickHelpEnabled() ) + IsHelpTips() ? Help::EnableQuickHelp() : Help::DisableQuickHelp(); + if ( IsExtendedHelp() != Help::IsBalloonHelpEnabled() ) + IsExtendedHelp() ? Help::EnableBalloonHelp() : Help::DisableBalloonHelp(); } void SvtHelpOptions_Impl::ImplCommit() diff --git a/svtools/source/config/htmlcfg.cxx b/svtools/source/config/htmlcfg.cxx index f20d725f8e28..cbf6cff6282e 100644 --- a/svtools/source/config/htmlcfg.cxx +++ b/svtools/source/config/htmlcfg.cxx @@ -123,71 +123,71 @@ void SvxHtmlOptions::Load( const Sequence< OUString >& aNames ) Sequence<Any> aValues = GetProperties(aNames); const Any* pValues = aValues.getConstArray(); DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed"); - if(aValues.getLength() == aNames.getLength()) + if(aValues.getLength() != aNames.getLength()) + return; + + pImpl->nFlags = HtmlCfgFlags::NONE; + for(int nProp = 0; nProp < aNames.getLength(); nProp++) { - pImpl->nFlags = HtmlCfgFlags::NONE; - for(int nProp = 0; nProp < aNames.getLength(); nProp++) + if(pValues[nProp].hasValue()) { - if(pValues[nProp].hasValue()) + switch(nProp) { - switch(nProp) - { - case 0: - if(*o3tl::doAccess<bool>(pValues[nProp])) - pImpl->nFlags |= HtmlCfgFlags::UnknownTags; - break;//"Import/UnknownTag", - case 1: - if(*o3tl::doAccess<bool>(pValues[nProp])) - pImpl->nFlags |= HtmlCfgFlags::IgnoreFontFamily; - break;//"Import/FontSetting", - case 2: pValues[nProp] >>= pImpl->aFontSizeArr[0]; break;//"Import/FontSize/Size_1", - case 3: pValues[nProp] >>= pImpl->aFontSizeArr[1]; break;//"Import/FontSize/Size_2", - case 4: pValues[nProp] >>= pImpl->aFontSizeArr[2]; break;//"Import/FontSize/Size_3", - case 5: pValues[nProp] >>= pImpl->aFontSizeArr[3]; break;//"Import/FontSize/Size_4", - case 6: pValues[nProp] >>= pImpl->aFontSizeArr[4]; break;//"Import/FontSize/Size_5", - case 7: pValues[nProp] >>= pImpl->aFontSizeArr[5]; break;//"Import/FontSize/Size_6", - case 8: pValues[nProp] >>= pImpl->aFontSizeArr[6]; break;//"Import/FontSize/Size_7", - case 9://"Export/Browser", + case 0: + if(*o3tl::doAccess<bool>(pValues[nProp])) + pImpl->nFlags |= HtmlCfgFlags::UnknownTags; + break;//"Import/UnknownTag", + case 1: + if(*o3tl::doAccess<bool>(pValues[nProp])) + pImpl->nFlags |= HtmlCfgFlags::IgnoreFontFamily; + break;//"Import/FontSetting", + case 2: pValues[nProp] >>= pImpl->aFontSizeArr[0]; break;//"Import/FontSize/Size_1", + case 3: pValues[nProp] >>= pImpl->aFontSizeArr[1]; break;//"Import/FontSize/Size_2", + case 4: pValues[nProp] >>= pImpl->aFontSizeArr[2]; break;//"Import/FontSize/Size_3", + case 5: pValues[nProp] >>= pImpl->aFontSizeArr[3]; break;//"Import/FontSize/Size_4", + case 6: pValues[nProp] >>= pImpl->aFontSizeArr[4]; break;//"Import/FontSize/Size_5", + case 7: pValues[nProp] >>= pImpl->aFontSizeArr[5]; break;//"Import/FontSize/Size_6", + case 8: pValues[nProp] >>= pImpl->aFontSizeArr[6]; break;//"Import/FontSize/Size_7", + case 9://"Export/Browser", + { + sal_Int32 nExpMode = 0; + pValues[nProp] >>= nExpMode; + switch( nExpMode ) { - sal_Int32 nExpMode = 0; - pValues[nProp] >>= nExpMode; - switch( nExpMode ) - { - case 1: nExpMode = HTML_CFG_MSIE; break; - case 3: nExpMode = HTML_CFG_WRITER; break; - case 4: nExpMode = HTML_CFG_NS40; break; - default: nExpMode = HTML_CFG_NS40; break; - } - - pImpl->nExportMode = nExpMode; + case 1: nExpMode = HTML_CFG_MSIE; break; + case 3: nExpMode = HTML_CFG_WRITER; break; + case 4: nExpMode = HTML_CFG_NS40; break; + default: nExpMode = HTML_CFG_NS40; break; } - break; - case 10: - if(*o3tl::doAccess<bool>(pValues[nProp])) - pImpl->nFlags |= HtmlCfgFlags::StarBasic; - break;//"Export/Basic", - case 11: - if(*o3tl::doAccess<bool>(pValues[nProp])) - pImpl->nFlags |= HtmlCfgFlags::PrintLayoutExtension; - break;//"Export/PrintLayout", - case 12: - if(*o3tl::doAccess<bool>(pValues[nProp])) - pImpl->nFlags |= HtmlCfgFlags::LocalGrf; - break;//"Export/LocalGraphic", - case 13: - if(*o3tl::doAccess<bool>(pValues[nProp])) - pImpl->nFlags |= HtmlCfgFlags::IsBasicWarning; - break;//"Export/Warning" - - case 14: pValues[nProp] >>= pImpl->eEncoding; - pImpl->bIsEncodingDefault = false; - break;//"Export/Encoding" - - case 15: - if(*o3tl::doAccess<bool>(pValues[nProp])) - pImpl->nFlags |= HtmlCfgFlags::NumbersEnglishUS; - break;//"Import/NumbersEnglishUS" - } + + pImpl->nExportMode = nExpMode; + } + break; + case 10: + if(*o3tl::doAccess<bool>(pValues[nProp])) + pImpl->nFlags |= HtmlCfgFlags::StarBasic; + break;//"Export/Basic", + case 11: + if(*o3tl::doAccess<bool>(pValues[nProp])) + pImpl->nFlags |= HtmlCfgFlags::PrintLayoutExtension; + break;//"Export/PrintLayout", + case 12: + if(*o3tl::doAccess<bool>(pValues[nProp])) + pImpl->nFlags |= HtmlCfgFlags::LocalGrf; + break;//"Export/LocalGraphic", + case 13: + if(*o3tl::doAccess<bool>(pValues[nProp])) + pImpl->nFlags |= HtmlCfgFlags::IsBasicWarning; + break;//"Export/Warning" + + case 14: pValues[nProp] >>= pImpl->eEncoding; + pImpl->bIsEncodingDefault = false; + break;//"Export/Encoding" + + case 15: + if(*o3tl::doAccess<bool>(pValues[nProp])) + pImpl->nFlags |= HtmlCfgFlags::NumbersEnglishUS; + break;//"Import/NumbersEnglishUS" } } } diff --git a/svtools/source/contnr/fileview.cxx b/svtools/source/contnr/fileview.cxx index 7d6eeecd440e..d0f628798eba 100644 --- a/svtools/source/contnr/fileview.cxx +++ b/svtools/source/contnr/fileview.cxx @@ -1289,19 +1289,19 @@ IMPL_LINK( SvtFileView, HeaderSelect_Impl, HeaderBar*, pBar, void ) IMPL_LINK( SvtFileView, HeaderEndDrag_Impl, HeaderBar*, pBar, void ) { - if ( !pBar->IsItemMode() ) - { - Size aSize; - sal_uInt16 nTabs = pBar->GetItemCount(); - long nTmpSize = 0; + if ( pBar->IsItemMode() ) + return; - for ( sal_uInt16 i = 1; i <= nTabs; ++i ) - { - long nWidth = pBar->GetItemSize(i); - aSize.Width() = nWidth + nTmpSize; - nTmpSize += nWidth; - mpImpl->mpView->SetTab( i, aSize.Width(), MapUnit::MapPixel ); - } + Size aSize; + sal_uInt16 nTabs = pBar->GetItemCount(); + long nTmpSize = 0; + + for ( sal_uInt16 i = 1; i <= nTabs; ++i ) + { + long nWidth = pBar->GetItemSize(i); + aSize.Width() = nWidth + nTmpSize; + nTmpSize += nWidth; + mpImpl->mpView->SetTab( i, aSize.Width(), MapUnit::MapPixel ); } } diff --git a/svtools/source/contnr/foldertree.cxx b/svtools/source/contnr/foldertree.cxx index 2f2aae754a48..cc62de2a363a 100644 --- a/svtools/source/contnr/foldertree.cxx +++ b/svtools/source/contnr/foldertree.cxx @@ -41,48 +41,48 @@ void FolderTree::RequestingChildren( SvTreeListEntry* pEntry ) void FolderTree::FillTreeEntry( SvTreeListEntry* pEntry ) { - if( pEntry ) - { - OUString* pURL = static_cast< OUString* >( pEntry->GetUserData() ); + if( !pEntry ) + return; + + OUString* pURL = static_cast< OUString* >( pEntry->GetUserData() ); - if( pURL && m_sLastUpdatedDir != *pURL ) + if( pURL && m_sLastUpdatedDir != *pURL ) + { + while (SvTreeListEntry* pChild = FirstChild(pEntry)) { - while (SvTreeListEntry* pChild = FirstChild(pEntry)) - { - GetModel()->Remove(pChild); - } + GetModel()->Remove(pChild); + } - ::std::vector< SortingData_Impl* > aContent; + ::std::vector< SortingData_Impl* > aContent; - ::rtl::Reference< ::svt::FileViewContentEnumerator > - xContentEnumerator(new FileViewContentEnumerator( - m_xEnv, aContent, m_aMutex, nullptr)); + ::rtl::Reference< ::svt::FileViewContentEnumerator > + xContentEnumerator(new FileViewContentEnumerator( + m_xEnv, aContent, m_aMutex, nullptr)); - FolderDescriptor aFolder( *pURL ); + FolderDescriptor aFolder( *pURL ); - EnumerationResult eResult = - xContentEnumerator->enumerateFolderContentSync( aFolder, m_aBlackList ); + EnumerationResult eResult = + xContentEnumerator->enumerateFolderContentSync( aFolder, m_aBlackList ); - if ( EnumerationResult::SUCCESS == eResult ) + if ( EnumerationResult::SUCCESS == eResult ) + { + for(SortingData_Impl* i : aContent) { - for(SortingData_Impl* i : aContent) + if( i->mbIsFolder ) { - if( i->mbIsFolder ) - { - SvTreeListEntry* pNewEntry = InsertEntry( i->GetTitle(), pEntry, true ); + SvTreeListEntry* pNewEntry = InsertEntry( i->GetTitle(), pEntry, true ); - OUString* sData = new OUString( i->maTargetURL ); - pNewEntry->SetUserData( static_cast< void* >( sData ) ); - } + OUString* sData = new OUString( i->maTargetURL ); + pNewEntry->SetUserData( static_cast< void* >( sData ) ); } } } - else - { - // this dir was updated recently - // next time read this remote folder - m_sLastUpdatedDir.clear(); - } + } + else + { + // this dir was updated recently + // next time read this remote folder + m_sLastUpdatedDir.clear(); } } @@ -92,24 +92,24 @@ void FolderTree::FillTreeEntry( const OUString & rUrl, const ::std::vector< std: SvTreeListEntry* pParent = GetCurEntry(); - if( pParent && !IsExpanded( pParent ) ) - { - while (SvTreeListEntry* pChild = FirstChild(pParent)) - { - GetModel()->Remove(pChild); - } + if( !(pParent && !IsExpanded( pParent )) ) + return; + while (SvTreeListEntry* pChild = FirstChild(pParent)) + { + GetModel()->Remove(pChild); + } - for(::std::vector< std::pair< OUString, OUString > >::const_iterator it = rFolders.begin(); it != rFolders.end() ; ++it) - { - SvTreeListEntry* pNewEntry = InsertEntry( it->first, pParent, true ); - OUString* sData = new OUString( it->second ); - pNewEntry->SetUserData( static_cast< void* >( sData ) ); - } - m_sLastUpdatedDir = rUrl; - Expand( pParent ); + for(::std::vector< std::pair< OUString, OUString > >::const_iterator it = rFolders.begin(); it != rFolders.end() ; ++it) + { + SvTreeListEntry* pNewEntry = InsertEntry( it->first, pParent, true ); + OUString* sData = new OUString( it->second ); + pNewEntry->SetUserData( static_cast< void* >( sData ) ); } + + m_sLastUpdatedDir = rUrl; + Expand( pParent ); } void FolderTree::SetTreePath( OUString const & sUrl ) diff --git a/svtools/source/contnr/iconviewimpl.cxx b/svtools/source/contnr/iconviewimpl.cxx index d1221169afb4..4f36e04ae4a6 100644 --- a/svtools/source/contnr/iconviewimpl.cxx +++ b/svtools/source/contnr/iconviewimpl.cxx @@ -36,20 +36,20 @@ void IconViewImpl::CursorUp() for(short i = 0; i < pView->GetColumnsCount() && pPrevFirstToDraw; i++) pPrevFirstToDraw = pView->PrevVisible(pPrevFirstToDraw); - if( pPrevFirstToDraw ) - { - nFlags &= (~LBoxFlags::Filling); - long nEntryHeight = pView->GetEntryHeight(); - ShowCursor( false ); - pView->Update(); - pStartEntry = pPrevFirstToDraw; - tools::Rectangle aArea( GetVisibleArea() ); - aArea.Bottom() -= nEntryHeight; - pView->Scroll( 0, nEntryHeight, aArea, ScrollFlags::NoChildren ); - pView->Update(); - ShowCursor( true ); - pView->NotifyScrolled(); - } + if( !pPrevFirstToDraw ) + return; + + nFlags &= (~LBoxFlags::Filling); + long nEntryHeight = pView->GetEntryHeight(); + ShowCursor( false ); + pView->Update(); + pStartEntry = pPrevFirstToDraw; + tools::Rectangle aArea( GetVisibleArea() ); + aArea.Bottom() -= nEntryHeight; + pView->Scroll( 0, nEntryHeight, aArea, ScrollFlags::NoChildren ); + pView->Update(); + ShowCursor( true ); + pView->NotifyScrolled(); } void IconViewImpl::CursorDown() @@ -440,19 +440,19 @@ void IconViewImpl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectan void IconViewImpl::InvalidateEntry( long nId ) const { - if( !(nFlags & LBoxFlags::InPaint )) - { - tools::Rectangle aRect( GetVisibleArea() ); - long nMaxBottom = aRect.Bottom(); - aRect.Top() = nId / pView->GetColumnsCount() * pView->GetEntryHeight(); - aRect.Bottom() = aRect.Top(); aRect.Bottom() += pView->GetEntryHeight(); + if( (nFlags & LBoxFlags::InPaint )) + return; - if( aRect.Top() > nMaxBottom ) - return; - if( aRect.Bottom() > nMaxBottom ) - aRect.Bottom() = nMaxBottom; - pView->Invalidate( aRect ); - } + tools::Rectangle aRect( GetVisibleArea() ); + long nMaxBottom = aRect.Bottom(); + aRect.Top() = nId / pView->GetColumnsCount() * pView->GetEntryHeight(); + aRect.Bottom() = aRect.Top(); aRect.Bottom() += pView->GetEntryHeight(); + + if( aRect.Top() > nMaxBottom ) + return; + if( aRect.Bottom() > nMaxBottom ) + aRect.Bottom() = nMaxBottom; + pView->Invalidate( aRect ); } bool IconViewImpl::KeyInput( const KeyEvent& rKEvt ) diff --git a/svtools/source/contnr/imivctl1.cxx b/svtools/source/contnr/imivctl1.cxx index 8366a8c497e1..e789d1524a7d 100644 --- a/svtools/source/contnr/imivctl1.cxx +++ b/svtools/source/contnr/imivctl1.cxx @@ -371,26 +371,26 @@ void SvxIconChoiceCtrl_Impl::SelectEntry( SvxIconChoiceCtrlEntry* pEntry, bool b nFlags &= ~IconChoiceFlags::ClearingSelection; } } - if( pEntry->IsSelected() != bSelect ) + if( pEntry->IsSelected() == bSelect ) + return; + + pHdlEntry = pEntry; + SvxIconViewFlags nEntryFlags = pEntry->GetFlags(); + if( bSelect ) { - pHdlEntry = pEntry; - SvxIconViewFlags nEntryFlags = pEntry->GetFlags(); - if( bSelect ) - { - nEntryFlags |= SvxIconViewFlags::SELECTED; - pEntry->AssignFlags( nEntryFlags ); - nSelectionCount++; - CallSelectHandler(); - } - else - { - nEntryFlags &= ~SvxIconViewFlags::SELECTED; - pEntry->AssignFlags( nEntryFlags ); - nSelectionCount--; - CallSelectHandler(); - } - EntrySelected( pEntry, bSelect ); + nEntryFlags |= SvxIconViewFlags::SELECTED; + pEntry->AssignFlags( nEntryFlags ); + nSelectionCount++; + CallSelectHandler(); } + else + { + nEntryFlags &= ~SvxIconViewFlags::SELECTED; + pEntry->AssignFlags( nEntryFlags ); + nSelectionCount--; + CallSelectHandler(); + } + EntrySelected( pEntry, bSelect ); } void SvxIconChoiceCtrl_Impl::EntrySelected(SvxIconChoiceCtrlEntry* pEntry, bool bSelect) @@ -480,22 +480,22 @@ void SvxIconChoiceCtrl_Impl::AdjustVirtSize( const tools::Rectangle& rRect ) if( aVirtOutputSize.Height() < (rRect.Bottom()+TBOFFS_WINBORDER) ) nHeightOffs = (rRect.Bottom()+TBOFFS_WINBORDER) - aVirtOutputSize.Height(); - if( nWidthOffs || nHeightOffs ) - { - Range aRange; - aVirtOutputSize.Width() += nWidthOffs; - aRange.Max() = aVirtOutputSize.Width(); - aHorSBar->SetRange( aRange ); + if( !(nWidthOffs || nHeightOffs) ) + return; - aVirtOutputSize.Height() += nHeightOffs; - aRange.Max() = aVirtOutputSize.Height(); - aVerSBar->SetRange( aRange ); + Range aRange; + aVirtOutputSize.Width() += nWidthOffs; + aRange.Max() = aVirtOutputSize.Width(); + aHorSBar->SetRange( aRange ); - pImpCursor->Clear(); - pGridMap->OutputSizeChanged(); - AdjustScrollBars(); - DocRectChanged(); - } + aVirtOutputSize.Height() += nHeightOffs; + aRange.Max() = aVirtOutputSize.Height(); + aVerSBar->SetRange( aRange ); + + pImpCursor->Clear(); + pGridMap->OutputSizeChanged(); + AdjustScrollBars(); + DocRectChanged(); } void SvxIconChoiceCtrl_Impl::InitPredecessors() @@ -940,48 +940,48 @@ bool SvxIconChoiceCtrl_Impl::MouseMove( const MouseEvent& rMEvt ) void SvxIconChoiceCtrl_Impl::SetCursor_Impl( SvxIconChoiceCtrlEntry* pOldCursor, SvxIconChoiceCtrlEntry* pNewCursor, bool bMod1, bool bShift ) { - if( pNewCursor ) + if( !pNewCursor ) + return; + + SvxIconChoiceCtrlEntry* pFilterEntry = nullptr; + bool bDeselectAll = false; + if( eSelectionMode != SelectionMode::Single ) { - SvxIconChoiceCtrlEntry* pFilterEntry = nullptr; - bool bDeselectAll = false; - if( eSelectionMode != SelectionMode::Single ) + if( !bMod1 && !bShift ) + bDeselectAll = true; + else if( bShift && !bMod1 && !pAnchor ) { - if( !bMod1 && !bShift ) - bDeselectAll = true; - else if( bShift && !bMod1 && !pAnchor ) - { - bDeselectAll = true; - pFilterEntry = pOldCursor; - } + bDeselectAll = true; + pFilterEntry = pOldCursor; } - if( bDeselectAll ) - DeselectAllBut( pFilterEntry ); - ShowCursor( false ); - MakeEntryVisible( pNewCursor ); - SetCursor( pNewCursor ); - if( bMod1 && !bShift ) - { - if( pAnchor ) - { - AddSelectedRect( pAnchor, pOldCursor ); - pAnchor = nullptr; - } - } - else if( bShift ) + } + if( bDeselectAll ) + DeselectAllBut( pFilterEntry ); + ShowCursor( false ); + MakeEntryVisible( pNewCursor ); + SetCursor( pNewCursor ); + if( bMod1 && !bShift ) + { + if( pAnchor ) { - if( !pAnchor ) - pAnchor = pOldCursor; - if ( nWinBits & WB_ALIGN_LEFT ) - SelectRange( pAnchor, pNewCursor, bool(nFlags & IconChoiceFlags::AddMode) ); - else - SelectRect(pAnchor,pNewCursor, bool(nFlags & IconChoiceFlags::AddMode), &aSelectedRectList); + AddSelectedRect( pAnchor, pOldCursor ); + pAnchor = nullptr; } + } + else if( bShift ) + { + if( !pAnchor ) + pAnchor = pOldCursor; + if ( nWinBits & WB_ALIGN_LEFT ) + SelectRange( pAnchor, pNewCursor, bool(nFlags & IconChoiceFlags::AddMode) ); else - { - SelectEntry( pCursor, true, false ); - aCurSelectionRect = GetEntryBoundRect( pCursor ); - CallEventListeners( VclEventId::ListboxSelect, pCursor ); - } + SelectRect(pAnchor,pNewCursor, bool(nFlags & IconChoiceFlags::AddMode), &aSelectedRectList); + } + else + { + SelectEntry( pCursor, true, false ); + aCurSelectionRect = GetEntryBoundRect( pCursor ); + CallEventListeners( VclEventId::ListboxSelect, pCursor ); } } @@ -2123,20 +2123,20 @@ void SvxIconChoiceCtrl_Impl::Command( const CommandEvent& rCEvt ) void SvxIconChoiceCtrl_Impl::ToTop( SvxIconChoiceCtrlEntry* pEntry ) { - if( !pZOrderList->empty() - && pEntry != pZOrderList->back() + if( !(!pZOrderList->empty() + && pEntry != pZOrderList->back()) + ) return; + + for( + SvxIconChoiceCtrlEntryList_impl::iterator it = pZOrderList->begin(); + it != pZOrderList->end(); + ++it ) { - for( - SvxIconChoiceCtrlEntryList_impl::iterator it = pZOrderList->begin(); - it != pZOrderList->end(); - ++it - ) { - if ( *it == pEntry ) - { - pZOrderList->erase( it ); - pZOrderList->push_back( pEntry ); - break; - } + if ( *it == pEntry ) + { + pZOrderList->erase( it ); + pZOrderList->push_back( pEntry ); + break; } } } @@ -3070,24 +3070,24 @@ void SvxIconChoiceCtrl_Impl::InitSettings() pView->SetBackground( rStyleSettings.GetFieldColor()); long nScrBarSize = rStyleSettings.GetScrollBarSize(); - if( nScrBarSize != nHorSBarHeight || nScrBarSize != nVerSBarWidth ) - { - nHorSBarHeight = nScrBarSize; - Size aSize( aHorSBar->GetSizePixel() ); - aSize.Height() = nScrBarSize; - aHorSBar->Hide(); - aHorSBar->SetSizePixel( aSize ); + if( !(nScrBarSize != nHorSBarHeight || nScrBarSize != nVerSBarWidth) ) + return; - nVerSBarWidth = nScrBarSize; - aSize = aVerSBar->GetSizePixel(); - aSize.Width() = nScrBarSize; - aVerSBar->Hide(); - aVerSBar->SetSizePixel( aSize ); + nHorSBarHeight = nScrBarSize; + Size aSize( aHorSBar->GetSizePixel() ); + aSize.Height() = nScrBarSize; + aHorSBar->Hide(); + aHorSBar->SetSizePixel( aSize ); - Size aOSize( pView->Control::GetOutputSizePixel() ); - PositionScrollBars( aOSize.Width(), aOSize.Height() ); - AdjustScrollBars(); - } + nVerSBarWidth = nScrBarSize; + aSize = aVerSBar->GetSizePixel(); + aSize.Width() = nScrBarSize; + aVerSBar->Hide(); + aVerSBar->SetSizePixel( aSize ); + + Size aOSize( pView->Control::GetOutputSizePixel() ); + PositionScrollBars( aOSize.Width(), aOSize.Height() ); + AdjustScrollBars(); } EntryList_Impl::EntryList_Impl( SvxIconChoiceCtrl_Impl* pOwner ) : diff --git a/svtools/source/contnr/imivctl2.cxx b/svtools/source/contnr/imivctl2.cxx index ae2532edd7dd..6521751e5a86 100644 --- a/svtools/source/contnr/imivctl2.cxx +++ b/svtools/source/contnr/imivctl2.cxx @@ -674,24 +674,24 @@ sal_uLong IcnGridMap_Impl::GetGridCount( const Size& rSizePixel, sal_uInt16 nDX, void IcnGridMap_Impl::OutputSizeChanged() { - if( _pGridMap ) + if( !_pGridMap ) + return; + + sal_uInt16 nCols, nRows; + GetMinMapSize( nCols, nRows ); + if( _pView->nWinBits & WB_ALIGN_TOP ) { - sal_uInt16 nCols, nRows; - GetMinMapSize( nCols, nRows ); - if( _pView->nWinBits & WB_ALIGN_TOP ) - { - if( nCols != _nGridCols ) - Clear(); - else if( nRows >= _nGridRows ) - Expand(); - } - else - { - if( nRows != _nGridRows ) - Clear(); - else if( nCols >= _nGridCols ) - Expand(); - } + if( nCols != _nGridCols ) + Clear(); + else if( nRows >= _nGridRows ) + Expand(); + } + else + { + if( nRows != _nGridRows ) + Clear(); + else if( nCols >= _nGridCols ) + Expand(); } } diff --git a/svtools/source/contnr/ivctrl.cxx b/svtools/source/contnr/ivctrl.cxx index 31310df0313b..247442ce9165 100644 --- a/svtools/source/contnr/ivctrl.cxx +++ b/svtools/source/contnr/ivctrl.cxx @@ -330,54 +330,54 @@ void SvtIconChoiceCtrl::DataChanged( const DataChangedEvent& rDCEvt ) void SvtIconChoiceCtrl::SetBackground( const Wallpaper& rPaper ) { - if( rPaper != GetBackground() ) + if( rPaper == GetBackground() ) + return; + + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + // if it is the default (empty) wallpaper + if( rPaper.GetStyle() == WallpaperStyle::NONE && rPaper.GetColor() == COL_TRANSPARENT && + !rPaper.IsBitmap() && !rPaper.IsGradient() && !rPaper.IsRect()) { - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - // if it is the default (empty) wallpaper - if( rPaper.GetStyle() == WallpaperStyle::NONE && rPaper.GetColor() == COL_TRANSPARENT && - !rPaper.IsBitmap() && !rPaper.IsGradient() && !rPaper.IsRect()) + Control::SetBackground( rStyleSettings.GetFieldColor() ); + } + else + { + Wallpaper aBackground( rPaper ); + // HACK, as background might be transparent! + if( !aBackground.IsBitmap() ) + aBackground.SetStyle( WallpaperStyle::Tile ); + + WallpaperStyle eStyle = aBackground.GetStyle(); + Color aBack( aBackground.GetColor()); + Color aTrans( COL_TRANSPARENT ); + if( aBack == aTrans && + (!aBackground.IsBitmap() || + aBackground.GetBitmap().IsTransparent() || + (eStyle != WallpaperStyle::Tile && eStyle != WallpaperStyle::Scale)) ) { - Control::SetBackground( rStyleSettings.GetFieldColor() ); + aBackground.SetColor( rStyleSettings.GetFieldColor() ); + } + if( aBackground.IsScrollable() ) + { + tools::Rectangle aRect; + aRect.SetSize( Size(32765, 32765) ); + aBackground.SetRect( aRect ); } else { - Wallpaper aBackground( rPaper ); - // HACK, as background might be transparent! - if( !aBackground.IsBitmap() ) - aBackground.SetStyle( WallpaperStyle::Tile ); - - WallpaperStyle eStyle = aBackground.GetStyle(); - Color aBack( aBackground.GetColor()); - Color aTrans( COL_TRANSPARENT ); - if( aBack == aTrans && - (!aBackground.IsBitmap() || - aBackground.GetBitmap().IsTransparent() || - (eStyle != WallpaperStyle::Tile && eStyle != WallpaperStyle::Scale)) ) - { - aBackground.SetColor( rStyleSettings.GetFieldColor() ); - } - if( aBackground.IsScrollable() ) - { - tools::Rectangle aRect; - aRect.SetSize( Size(32765, 32765) ); - aBackground.SetRect( aRect ); - } - else - { - tools::Rectangle aRect( _pImpl->GetOutputRect() ); - aBackground.SetRect( aRect ); - } - Control::SetBackground( aBackground ); + tools::Rectangle aRect( _pImpl->GetOutputRect() ); + aBackground.SetRect( aRect ); } + Control::SetBackground( aBackground ); + } - // If text colors are attributed "hard," don't use automatism to select - // a readable text color. - vcl::Font aFont( GetFont() ); - aFont.SetColor( rStyleSettings.GetFieldTextColor() ); - SetFont( aFont ); + // If text colors are attributed "hard," don't use automatism to select + // a readable text color. + vcl::Font aFont( GetFont() ); + aFont.SetColor( rStyleSettings.GetFieldTextColor() ); + SetFont( aFont ); - Invalidate(InvalidateFlags::NoChildren); - } + Invalidate(InvalidateFlags::NoChildren); } void SvtIconChoiceCtrl::RequestHelp( const HelpEvent& rHEvt ) diff --git a/svtools/source/contnr/simptabl.cxx b/svtools/source/contnr/simptabl.cxx index 0b59579b4598..2e4e989054e5 100644 --- a/svtools/source/contnr/simptabl.cxx +++ b/svtools/source/contnr/simptabl.cxx @@ -175,21 +175,21 @@ void SvSimpleTable::SetTabs() SvHeaderTabListBox::SetTabs(); sal_uInt16 nPrivTabCount = TabCount(); - if ( nPrivTabCount ) - { - if ( nPrivTabCount > aHeaderBar->GetItemCount() ) - nPrivTabCount = aHeaderBar->GetItemCount(); + if ( !nPrivTabCount ) + return; - sal_uInt16 i, nPos = 0; - for ( i = 1; i < nPrivTabCount; ++i ) - { - sal_uInt16 nNewSize = static_cast< sal_uInt16 >( GetTab(i) ) - nPos; - aHeaderBar->SetItemSize( i, nNewSize ); - nPos = (sal_uInt16)GetTab(i); - } + if ( nPrivTabCount > aHeaderBar->GetItemCount() ) + nPrivTabCount = aHeaderBar->GetItemCount(); - aHeaderBar->SetItemSize( i, HEADERBAR_FULLSIZE ); // because no tab for last entry + sal_uInt16 i, nPos = 0; + for ( i = 1; i < nPrivTabCount; ++i ) + { + sal_uInt16 nNewSize = static_cast< sal_uInt16 >( GetTab(i) ) - nPos; + aHeaderBar->SetItemSize( i, nNewSize ); + nPos = (sal_uInt16)GetTab(i); } + + aHeaderBar->SetItemSize( i, HEADERBAR_FULLSIZE ); // because no tab for last entry } void SvSimpleTable::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) @@ -324,19 +324,19 @@ void SvSimpleTable::HBarClick() { sal_uInt16 nId=aHeaderBar->GetCurItemId(); - if (aHeaderBar->GetItemBits(nId) & HeaderBarItemBits::CLICKABLE) - { - if(nId==nSortCol+1) - { - SortByCol(nId-1,!bSortDirection); - } - else - { - SortByCol(nId-1,bSortDirection); - } + if (!(aHeaderBar->GetItemBits(nId) & HeaderBarItemBits::CLICKABLE)) + return; - aHeaderBarClickLink.Call(this); + if(nId==nSortCol+1) + { + SortByCol(nId-1,!bSortDirection); } + else + { + SortByCol(nId-1,bSortDirection); + } + + aHeaderBarClickLink.Call(this); } void SvSimpleTable::HBarDrag() diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx index c9f598dde923..6153f987efd3 100644 --- a/svtools/source/contnr/svimpbox.cxx +++ b/svtools/source/contnr/svimpbox.cxx @@ -221,20 +221,20 @@ void SvImpLBox::UpdateContextBmpWidthMax( SvTreeListEntry const * pEntry ) void SvImpLBox::CalcCellFocusRect( SvTreeListEntry const * pEntry, tools::Rectangle& rRect ) { - if ( pEntry && bIsCellFocusEnabled ) + if ( !(pEntry && bIsCellFocusEnabled) ) + return; + + if ( nCurTabPos > FIRST_ENTRY_TAB ) { - if ( nCurTabPos > FIRST_ENTRY_TAB ) - { - SvLBoxItem& rItem = pCursor->GetItem( nCurTabPos ); - rRect.Left() = pView->GetTab( pCursor, &rItem )->GetPos(); - } - if (pCursor->ItemCount() > static_cast<size_t>(nCurTabPos+1)) - { - SvLBoxItem& rNextItem = pCursor->GetItem( nCurTabPos + 1 ); - long nRight = pView->GetTab( pCursor, &rNextItem )->GetPos() - 1; - if ( nRight < rRect.Right() ) - rRect.Right() = nRight; - } + SvLBoxItem& rItem = pCursor->GetItem( nCurTabPos ); + rRect.Left() = pView->GetTab( pCursor, &rItem )->GetPos(); + } + if (pCursor->ItemCount() > static_cast<size_t>(nCurTabPos+1)) + { + SvLBoxItem& rNextItem = pCursor->GetItem( nCurTabPos + 1 ); + long nRight = pView->GetTab( pCursor, &rNextItem )->GetPos() - 1; + if ( nRight < rRect.Right() ) + rRect.Right() = nRight; } } @@ -374,20 +374,20 @@ void SvImpLBox::CursorUp() return; SvTreeListEntry* pPrevFirstToDraw = pView->PrevVisible(pStartEntry); - if( pPrevFirstToDraw ) - { - nFlags &= (~LBoxFlags::Filling); - long nEntryHeight = pView->GetEntryHeight(); - ShowCursor( false ); - pView->Update(); - pStartEntry = pPrevFirstToDraw; - tools::Rectangle aArea( GetVisibleArea() ); - aArea.Bottom() -= nEntryHeight; - pView->Scroll( 0, nEntryHeight, aArea, ScrollFlags::NoChildren ); - pView->Update(); - ShowCursor( true ); - pView->NotifyScrolled(); - } + if( !pPrevFirstToDraw ) + return; + + nFlags &= (~LBoxFlags::Filling); + long nEntryHeight = pView->GetEntryHeight(); + ShowCursor( false ); + pView->Update(); + pStartEntry = pPrevFirstToDraw; + tools::Rectangle aArea( GetVisibleArea() ); + aArea.Bottom() -= nEntryHeight; + pView->Scroll( 0, nEntryHeight, aArea, ScrollFlags::NoChildren ); + pView->Update(); + ShowCursor( true ); + pView->NotifyScrolled(); } void SvImpLBox::PageDown( sal_uInt16 nDelta ) @@ -1323,36 +1323,36 @@ void SvImpLBox::FillView() nTempThumb = nVisibleViewCount - 1; pStartEntry = pView->GetEntryAtVisPos(nTempThumb); } - if( pStartEntry ) + if( !pStartEntry ) + return; + + sal_uInt16 nLast = (sal_uInt16)(pView->GetVisiblePos(pView->LastVisible())); + sal_uInt16 nThumb = (sal_uInt16)(pView->GetVisiblePos( pStartEntry )); + sal_uLong nCurDispEntries = nLast-nThumb+1; + if( nCurDispEntries >= nVisibleCount ) + return; + + ShowCursor( false ); + // fill window by moving the thumb up incrementally + bool bFound = false; + SvTreeListEntry* pTemp = pStartEntry; + while( nCurDispEntries < nVisibleCount && pTemp ) { - sal_uInt16 nLast = (sal_uInt16)(pView->GetVisiblePos(pView->LastVisible())); - sal_uInt16 nThumb = (sal_uInt16)(pView->GetVisiblePos( pStartEntry )); - sal_uLong nCurDispEntries = nLast-nThumb+1; - if( nCurDispEntries < nVisibleCount ) + pTemp = pView->PrevVisible(pStartEntry); + if( pTemp ) { - ShowCursor( false ); - // fill window by moving the thumb up incrementally - bool bFound = false; - SvTreeListEntry* pTemp = pStartEntry; - while( nCurDispEntries < nVisibleCount && pTemp ) - { - pTemp = pView->PrevVisible(pStartEntry); - if( pTemp ) - { - nThumb--; - pStartEntry = pTemp; - nCurDispEntries++; - bFound = true; - } - } - if( bFound ) - { - aVerSBar->SetThumbPos( nThumb ); - ShowCursor( true ); // recalculate focus rectangle - pView->Invalidate(); - } + nThumb--; + pStartEntry = pTemp; + nCurDispEntries++; + bFound = true; } } + if( bFound ) + { + aVerSBar->SetThumbPos( nThumb ); + ShowCursor( true ); // recalculate focus rectangle + pView->Invalidate(); + } } @@ -1481,22 +1481,22 @@ void SvImpLBox::SetEntryHeight() void SvImpLBox::EntryExpanded( SvTreeListEntry* pEntry ) { // SelAllDestrAnch( false, true ); //DeselectAll(); - if( GetUpdateMode() ) + if( !GetUpdateMode() ) + return; + + ShowCursor( false ); + long nY = GetEntryLine( pEntry ); + if( IsLineVisible(nY) ) { - ShowCursor( false ); - long nY = GetEntryLine( pEntry ); - if( IsLineVisible(nY) ) - { - InvalidateEntriesFrom( nY ); - FindMostRight( pEntry, nullptr ); - } - aVerSBar->SetRange( Range(0, pView->GetVisibleCount()-1 ) ); - // if we expanded before the thumb, the thumb's position has to be - // corrected - SyncVerThumb(); - ShowVerSBar(); - ShowCursor( true ); + InvalidateEntriesFrom( nY ); + FindMostRight( pEntry, nullptr ); } + aVerSBar->SetRange( Range(0, pView->GetVisibleCount()-1 ) ); + // if we expanded before the thumb, the thumb's position has to be + // corrected + SyncVerThumb(); + ShowVerSBar(); + ShowCursor( true ); } void SvImpLBox::EntryCollapsed( SvTreeListEntry* pEntry ) @@ -1743,23 +1743,23 @@ void SvImpLBox::MovingEntry( SvTreeListEntry* pEntry ) ShowCursor( false ); if( IsEntryInView( pEntry ) ) pView->Invalidate(); - if( pEntry == pStartEntry ) + if( pEntry != pStartEntry ) + return; + + SvTreeListEntry* pNew = nullptr; + if( !pEntry->HasChildren() ) { - SvTreeListEntry* pNew = nullptr; - if( !pEntry->HasChildren() ) - { - pNew = pView->NextVisible(pStartEntry); - if( !pNew ) - pNew = pView->PrevVisible(pStartEntry); - } - else - { - pNew = SvTreeList::NextSibling( pEntry ); - if( !pNew ) - pNew = SvTreeList::PrevSibling( pEntry ); - } - pStartEntry = pNew; + pNew = pView->NextVisible(pStartEntry); + if( !pNew ) + pNew = pView->PrevVisible(pStartEntry); + } + else + { + pNew = SvTreeList::NextSibling( pEntry ); + if( !pNew ) + pNew = SvTreeList::PrevSibling( pEntry ); } + pStartEntry = pNew; } void SvImpLBox::EntryMoved( SvTreeListEntry* pEntry ) @@ -1799,56 +1799,56 @@ void SvImpLBox::EntryMoved( SvTreeListEntry* pEntry ) void SvImpLBox::EntryInserted( SvTreeListEntry* pEntry ) { - if( GetUpdateMode() ) - { - SvTreeListEntry* pParent = pTree->GetParent(pEntry); - if (pParent && pTree->GetChildList(pParent).size() == 1) - // draw plus sign - pTree->InvalidateEntry( pParent ); + if( !GetUpdateMode() ) + return; - if( !pView->IsEntryVisible( pEntry ) ) - return; - bool bDeselAll(nFlags & LBoxFlags::DeselectAll); - if( bDeselAll ) - SelAllDestrAnch( false ); - else - DestroyAnchor(); - // nFlags &= (~LBoxFlags::DeselectAll); + SvTreeListEntry* pParent = pTree->GetParent(pEntry); + if (pParent && pTree->GetChildList(pParent).size() == 1) + // draw plus sign + pTree->InvalidateEntry( pParent ); + + if( !pView->IsEntryVisible( pEntry ) ) + return; + bool bDeselAll(nFlags & LBoxFlags::DeselectAll); + if( bDeselAll ) + SelAllDestrAnch( false ); + else + DestroyAnchor(); + // nFlags &= (~LBoxFlags::DeselectAll); // ShowCursor( false ); // if cursor is moved lower - long nY = GetEntryLine( pEntry ); - bool bEntryVisible = IsLineVisible( nY ); - if( bEntryVisible ) - { - ShowCursor( false ); // if cursor is moved lower - nY -= pView->GetEntryHeight(); // because of lines - InvalidateEntriesFrom( nY ); - } - else if( pStartEntry && nY < GetEntryLine(pStartEntry) ) + long nY = GetEntryLine( pEntry ); + bool bEntryVisible = IsLineVisible( nY ); + if( bEntryVisible ) + { + ShowCursor( false ); // if cursor is moved lower + nY -= pView->GetEntryHeight(); // because of lines + InvalidateEntriesFrom( nY ); + } + else if( pStartEntry && nY < GetEntryLine(pStartEntry) ) + { + // Check if the view is filled completely. If not, then adjust + // pStartEntry and the Cursor (automatic scrolling). + sal_uInt16 nLast = (sal_uInt16)(pView->GetVisiblePos(pView->LastVisible())); + sal_uInt16 nThumb = (sal_uInt16)(pView->GetVisiblePos( pStartEntry )); + sal_uInt16 nCurDispEntries = nLast-nThumb+1; + if( nCurDispEntries < nVisibleCount ) { - // Check if the view is filled completely. If not, then adjust - // pStartEntry and the Cursor (automatic scrolling). - sal_uInt16 nLast = (sal_uInt16)(pView->GetVisiblePos(pView->LastVisible())); - sal_uInt16 nThumb = (sal_uInt16)(pView->GetVisiblePos( pStartEntry )); - sal_uInt16 nCurDispEntries = nLast-nThumb+1; - if( nCurDispEntries < nVisibleCount ) - { - // set at the next paint event - pStartEntry = nullptr; - SetCursor( nullptr ); - pView->Invalidate(); - } - } - else if( !pStartEntry ) + // set at the next paint event + pStartEntry = nullptr; + SetCursor( nullptr ); pView->Invalidate(); - - SetMostRight( pEntry ); - aVerSBar->SetRange( Range(0, pView->GetVisibleCount()-1)); - SyncVerThumb(); // if something was inserted before the thumb - ShowVerSBar(); - ShowCursor( true ); - if( pStartEntry != pView->First() && (nFlags & LBoxFlags::Filling) ) - pView->Update(); + } } + else if( !pStartEntry ) + pView->Invalidate(); + + SetMostRight( pEntry ); + aVerSBar->SetRange( Range(0, pView->GetVisibleCount()-1)); + SyncVerThumb(); // if something was inserted before the thumb + ShowVerSBar(); + ShowCursor( true ); + if( pStartEntry != pView->First() && (nFlags & LBoxFlags::Filling) ) + pView->Update(); } @@ -3073,27 +3073,27 @@ void SvImpLBox::SetCurEntry( SvTreeListEntry* pEntry ) IMPL_LINK_NOARG(SvImpLBox, EditTimerCall, Timer *, void) { - if( pView->IsInplaceEditingEnabled() ) + if( !pView->IsInplaceEditingEnabled() ) + return; + + bool bIsMouseTriggered = aEditClickPos.X() >= 0; + if ( bIsMouseTriggered ) { - bool bIsMouseTriggered = aEditClickPos.X() >= 0; - if ( bIsMouseTriggered ) + Point aCurrentMousePos = pView->GetPointerPosPixel(); + if ( ( std::abs( aCurrentMousePos.X() - aEditClickPos.X() ) > 5 ) + || ( std::abs( aCurrentMousePos.Y() - aEditClickPos.Y() ) > 5 ) + ) { - Point aCurrentMousePos = pView->GetPointerPosPixel(); - if ( ( std::abs( aCurrentMousePos.X() - aEditClickPos.X() ) > 5 ) - || ( std::abs( aCurrentMousePos.Y() - aEditClickPos.Y() ) > 5 ) - ) - { - return; - } + return; } + } - SvTreeListEntry* pEntry = GetCurEntry(); - if( pEntry ) - { - ShowCursor( false ); - pView->ImplEditEntry( pEntry ); - ShowCursor( true ); - } + SvTreeListEntry* pEntry = GetCurEntry(); + if( pEntry ) + { + ShowCursor( false ); + pView->ImplEditEntry( pEntry ); + ShowCursor( true ); } } diff --git a/svtools/source/contnr/svlbitm.cxx b/svtools/source/contnr/svlbitm.cxx index 78a74272eb1e..968dc5402ac4 100644 --- a/svtools/source/contnr/svlbitm.cxx +++ b/svtools/source/contnr/svlbitm.cxx @@ -317,30 +317,30 @@ void SvLBoxButton::Clone( SvLBoxItem* pSource ) void SvLBoxButton::ImplAdjustBoxSize(Size& io_rSize, ControlType i_eType, vcl::RenderContext const & rRenderContext) { - if (rRenderContext.IsNativeControlSupported( i_eType, ControlPart::Entire) ) + if (!rRenderContext.IsNativeControlSupported( i_eType, ControlPart::Entire) ) + return; + + ImplControlValue aControlValue; + tools::Rectangle aCtrlRegion( Point( 0, 0 ), io_rSize ); + + aControlValue.setTristateVal( ButtonValue::On ); + + tools::Rectangle aNativeBounds, aNativeContent; + bool bNativeOK = rRenderContext.GetNativeControlRegion( i_eType, + ControlPart::Entire, + aCtrlRegion, + ControlState::ENABLED, + aControlValue, + aNativeBounds, + aNativeContent ); + if( bNativeOK ) { - ImplControlValue aControlValue; - tools::Rectangle aCtrlRegion( Point( 0, 0 ), io_rSize ); - - aControlValue.setTristateVal( ButtonValue::On ); - - tools::Rectangle aNativeBounds, aNativeContent; - bool bNativeOK = rRenderContext.GetNativeControlRegion( i_eType, - ControlPart::Entire, - aCtrlRegion, - ControlState::ENABLED, - aControlValue, - aNativeBounds, - aNativeContent ); - if( bNativeOK ) - { - Size aContentSize( aNativeContent.GetSize() ); - // leave a little space around the box image (looks better) - if( aContentSize.Height() + 2 > io_rSize.Height() ) - io_rSize.Height() = aContentSize.Height() + 2; - if( aContentSize.Width() + 2 > io_rSize.Width() ) - io_rSize.Width() = aContentSize.Width() + 2; - } + Size aContentSize( aNativeContent.GetSize() ); + // leave a little space around the box image (looks better) + if( aContentSize.Height() + 2 > io_rSize.Height() ) + io_rSize.Height() = aContentSize.Height() + 2; + if( aContentSize.Width() + 2 > io_rSize.Width() ) + io_rSize.Width() = aContentSize.Width() + 2; } } diff --git a/svtools/source/contnr/svtabbx.cxx b/svtools/source/contnr/svtabbx.cxx index 53b0a0710e64..e5559a96814e 100644 --- a/svtools/source/contnr/svtabbx.cxx +++ b/svtools/source/contnr/svtabbx.cxx @@ -40,36 +40,36 @@ using namespace ::com::sun::star::accessibility; void SvTabListBox::SetTabs() { SvTreeListBox::SetTabs(); - if( nTabCount ) + if( !nTabCount ) + return; + + DBG_ASSERT(pTabList,"TabList ?"); + + // The tree listbox has now inserted its tabs into the list. Now we + // fluff up the list with additional tabs and adjust the rightmost tab + // of the tree listbox. + + // Picking the rightmost tab. + // HACK for the explorer! If ViewParent != 0, the first tab of the tree + // listbox is calculated by the tre listbox itself! This behavior is + // necessary for ButtonsOnRoot, as the explorer does not know in this + // case, which additional offset it need to add to the tabs in this mode + // -- the tree listbox knows that, though! + /* + if( !pViewParent ) { - DBG_ASSERT(pTabList,"TabList ?"); - - // The tree listbox has now inserted its tabs into the list. Now we - // fluff up the list with additional tabs and adjust the rightmost tab - // of the tree listbox. - - // Picking the rightmost tab. - // HACK for the explorer! If ViewParent != 0, the first tab of the tree - // listbox is calculated by the tre listbox itself! This behavior is - // necessary for ButtonsOnRoot, as the explorer does not know in this - // case, which additional offset it need to add to the tabs in this mode - // -- the tree listbox knows that, though! - /* - if( !pViewParent ) - { - SvLBoxTab* pFirstTab = (SvLBoxTab*)aTabs.GetObject( aTabs.Count()-1 ); - pFirstTab->SetPos( pTabList[0].GetPos() ); - pFirstTab->nFlags &= ~MYTABMASK; - pFirstTab->nFlags |= pTabList[0].nFlags; - } - */ + SvLBoxTab* pFirstTab = (SvLBoxTab*)aTabs.GetObject( aTabs.Count()-1 ); + pFirstTab->SetPos( pTabList[0].GetPos() ); + pFirstTab->nFlags &= ~MYTABMASK; + pFirstTab->nFlags |= pTabList[0].nFlags; + } + */ - // append all other tabs to the list - for( sal_uInt16 nCurTab = 1; nCurTab < nTabCount; nCurTab++ ) - { - SvLBoxTab* pTab = pTabList+nCurTab; - AddTab( pTab->GetPos(), pTab->nFlags ); - } + // append all other tabs to the list + for( sal_uInt16 nCurTab = 1; nCurTab < nTabCount; nCurTab++ ) + { + SvLBoxTab* pTab = pTabList+nCurTab; + AddTab( pTab->GetPos(), pTab->nFlags ); } } @@ -144,19 +144,19 @@ void SvTabListBox::SetTabs(const long* pTabs, MapUnit eMapUnit) void SvTabListBox::SetTab( sal_uInt16 nTab,long nValue,MapUnit eMapUnit ) { DBG_ASSERT(nTab<nTabCount,"Invalid Tab-Pos"); - if( nTab < nTabCount ) - { - DBG_ASSERT(pTabList,"TabList?"); - MapMode aMMSource( eMapUnit ); - MapMode aMMDest( MapUnit::MapPixel ); - Size aSize( nValue, 0 ); - aSize = LogicToLogic( aSize, &aMMSource, &aMMDest ); - nValue = aSize.Width(); - pTabList[ nTab ].SetPos( nValue ); - SvTreeListBox::nTreeFlags |= SvTreeFlags::RECALCTABS; - if( IsUpdateMode() ) - Invalidate(); - } + if( nTab >= nTabCount ) + return; + + DBG_ASSERT(pTabList,"TabList?"); + MapMode aMMSource( eMapUnit ); + MapMode aMMDest( MapUnit::MapPixel ); + Size aSize( nValue, 0 ); + aSize = LogicToLogic( aSize, &aMMSource, &aMMDest ); + nValue = aSize.Width(); + pTabList[ nTab ].SetPos( nValue ); + SvTreeListBox::nTreeFlags |= SvTreeFlags::RECALCTABS; + if( IsUpdateMode() ) + Invalidate(); } SvTreeListEntry* SvTabListBox::InsertEntry( const OUString& rText, SvTreeListEntry* pParent, diff --git a/svtools/source/contnr/treelist.cxx b/svtools/source/contnr/treelist.cxx index 89ff1edccac1..e4b501fa0c4d 100644 --- a/svtools/source/contnr/treelist.cxx +++ b/svtools/source/contnr/treelist.cxx @@ -1592,41 +1592,41 @@ void SvTreeList::GetInsertionPos( SvTreeListEntry const * pEntry, SvTreeListEntr rPos = TREELIST_ENTRY_NOTFOUND; const SvTreeListEntries& rChildList = GetChildList(pParent); - if (!rChildList.empty()) - { - long i = 0; - long j = rChildList.size()-1; - long k; - sal_Int32 nCompare = 1; + if (rChildList.empty()) + return; - do - { - k = (i+j)/2; - const SvTreeListEntry* pTempEntry = rChildList[k].get(); - nCompare = Compare( pEntry, pTempEntry ); - if( eSortMode == SortDescending && nCompare != 0 ) - { - if( nCompare < 0 ) - nCompare = 1; - else - nCompare = -1; - } - if( nCompare > 0 ) - i = k + 1; - else - j = k - 1; - } while( (nCompare != 0) && (i <= j) ); + long i = 0; + long j = rChildList.size()-1; + long k; + sal_Int32 nCompare = 1; - if( nCompare != 0 ) + do + { + k = (i+j)/2; + const SvTreeListEntry* pTempEntry = rChildList[k].get(); + nCompare = Compare( pEntry, pTempEntry ); + if( eSortMode == SortDescending && nCompare != 0 ) { - if (i > static_cast<long>(rChildList.size()-1)) // not found, end of list - rPos = TREELIST_ENTRY_NOTFOUND; + if( nCompare < 0 ) + nCompare = 1; else - rPos = i; // not found, middle of list + nCompare = -1; } + if( nCompare > 0 ) + i = k + 1; else - rPos = k; + j = k - 1; + } while( (nCompare != 0) && (i <= j) ); + + if( nCompare != 0 ) + { + if (i > static_cast<long>(rChildList.size()-1)) // not found, end of list + rPos = TREELIST_ENTRY_NOTFOUND; + else + rPos = i; // not found, middle of list } + else + rPos = k; } bool SvTreeList::HasChildren( const SvTreeListEntry* pEntry ) const diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx index 52be33e05b24..a3cbd9a8914a 100644 --- a/svtools/source/contnr/treelistbox.cxx +++ b/svtools/source/contnr/treelistbox.cxx @@ -744,31 +744,31 @@ SvTreeListEntry* SvTreeListBox::GetEntryFromPath( const ::std::deque< sal_Int32 void SvTreeListBox::FillEntryPath( SvTreeListEntry* pEntry, ::std::deque< sal_Int32 >& _rPath ) const { - if ( pEntry ) + if ( !pEntry ) + return; + + SvTreeListEntry* pParentEntry = GetParent( pEntry ); + while ( true ) { - SvTreeListEntry* pParentEntry = GetParent( pEntry ); - while ( true ) + sal_uLong i, nCount = GetLevelChildCount( pParentEntry ); + for ( i = 0; i < nCount; ++i ) { - sal_uLong i, nCount = GetLevelChildCount( pParentEntry ); - for ( i = 0; i < nCount; ++i ) + SvTreeListEntry* pTemp = GetEntry( pParentEntry, i ); + DBG_ASSERT( pEntry, "invalid entry" ); + if ( pEntry == pTemp ) { - SvTreeListEntry* pTemp = GetEntry( pParentEntry, i ); - DBG_ASSERT( pEntry, "invalid entry" ); - if ( pEntry == pTemp ) - { - _rPath.push_front( (sal_Int32)i ); - break; - } + _rPath.push_front( (sal_Int32)i ); + break; } + } - if ( pParentEntry ) - { - pEntry = pParentEntry; - pParentEntry = GetParent( pParentEntry ); - } - else - break; + if ( pParentEntry ) + { + pEntry = pParentEntry; + pParentEntry = GetParent( pParentEntry ); } + else + break; } } @@ -1764,17 +1764,17 @@ void SvTreeListBox::ImpEntryInserted( SvTreeListEntry* pEntry ) } SetEntryHeight( pEntry ); - if( nTreeFlags & SvTreeFlags::CHKBTN ) + if( !(nTreeFlags & SvTreeFlags::CHKBTN) ) + return; + + SvLBoxButton* pItem = static_cast<SvLBoxButton*>(pEntry->GetFirstItem(SvLBoxItemType::Button)); + if( pItem ) { - SvLBoxButton* pItem = static_cast<SvLBoxButton*>(pEntry->GetFirstItem(SvLBoxItemType::Button)); - if( pItem ) + long nWidth = pItem->GetSize(this, pEntry).Width(); + if( mnCheckboxItemWidth < nWidth ) { - long nWidth = pItem->GetSize(this, pEntry).Width(); - if( mnCheckboxItemWidth < nWidth ) - { - mnCheckboxItemWidth = nWidth; - nTreeFlags |= SvTreeFlags::RECALCTABS; - } + mnCheckboxItemWidth = nWidth; + nTreeFlags |= SvTreeFlags::RECALCTABS; } } } @@ -1782,27 +1782,27 @@ void SvTreeListBox::ImpEntryInserted( SvTreeListEntry* pEntry ) void SvTreeListBox::SetCheckButtonState( SvTreeListEntry* pEntry, SvButtonState eState) { - if( nTreeFlags & SvTreeFlags::CHKBTN ) + if( !(nTreeFlags & SvTreeFlags::CHKBTN) ) + return; + + SvLBoxButton* pItem = static_cast<SvLBoxButton*>(pEntry->GetFirstItem(SvLBoxItemType::Button)); + if(!(pItem && pItem->CheckModification())) + return ; + switch( eState ) { - SvLBoxButton* pItem = static_cast<SvLBoxButton*>(pEntry->GetFirstItem(SvLBoxItemType::Button)); - if(!(pItem && pItem->CheckModification())) - return ; - switch( eState ) - { - case SvButtonState::Checked: - pItem->SetStateChecked(); - break; + case SvButtonState::Checked: + pItem->SetStateChecked(); + break; - case SvButtonState::Unchecked: - pItem->SetStateUnchecked(); - break; + case SvButtonState::Unchecked: + pItem->SetStateUnchecked(); + break; - case SvButtonState::Tristate: - pItem->SetStateTristate(); - break; - } - InvalidateEntry( pEntry ); + case SvButtonState::Tristate: + pItem->SetStateTristate(); + break; } + InvalidateEntry( pEntry ); } void SvTreeListBox::SetCheckButtonInvisible( SvTreeListEntry* pEntry) @@ -2360,18 +2360,18 @@ void SvTreeListBox::Paint(vcl::RenderContext& rRenderContext, const tools::Recta pImpl->Paint(rRenderContext, rRect); //Add visual focus draw - if (!First()) + if (First()) + return; + + if (HasFocus()) { - if (HasFocus()) - { - long nHeight = rRenderContext.GetTextHeight(); - tools::Rectangle aRect(Point(0, 0), Size(GetSizePixel().Width(), nHeight)); - ShowFocus(aRect); - } - else - { - HideFocus(); - } + long nHeight = rRenderContext.GetTextHeight(); + tools::Rectangle aRect(Point(0, 0), Size(GetSizePixel().Width(), nHeight)); + ShowFocus(aRect); + } + else + { + HideFocus(); } } @@ -2509,47 +2509,47 @@ void SvTreeListBox::ImplEditEntry( SvTreeListEntry* pEntry ) EndEditing(); if( !pEntry ) pEntry = GetCurEntry(); - if( pEntry ) + if( !pEntry ) + return; + + long nClickX = pImpl->aEditClickPos.X(); + bool bIsMouseTriggered = nClickX >= 0; + + SvLBoxString* pItem = nullptr; + sal_uInt16 nCount = pEntry->ItemCount(); + long nTabPos, nNextTabPos = 0; + for( sal_uInt16 i = 0 ; i < nCount ; i++ ) { - long nClickX = pImpl->aEditClickPos.X(); - bool bIsMouseTriggered = nClickX >= 0; + SvLBoxItem& rTmpItem = pEntry->GetItem( i ); + if (rTmpItem.GetType() != SvLBoxItemType::String) + continue; - SvLBoxString* pItem = nullptr; - sal_uInt16 nCount = pEntry->ItemCount(); - long nTabPos, nNextTabPos = 0; - for( sal_uInt16 i = 0 ; i < nCount ; i++ ) + SvLBoxTab* pTab = GetTab( pEntry, &rTmpItem ); + nNextTabPos = -1; + if( i < nCount - 1 ) { - SvLBoxItem& rTmpItem = pEntry->GetItem( i ); - if (rTmpItem.GetType() != SvLBoxItemType::String) - continue; - - SvLBoxTab* pTab = GetTab( pEntry, &rTmpItem ); - nNextTabPos = -1; - if( i < nCount - 1 ) - { - SvLBoxItem& rNextItem = pEntry->GetItem( i + 1 ); - SvLBoxTab* pNextTab = GetTab( pEntry, &rNextItem ); - nNextTabPos = pNextTab->GetPos(); - } + SvLBoxItem& rNextItem = pEntry->GetItem( i + 1 ); + SvLBoxTab* pNextTab = GetTab( pEntry, &rNextItem ); + nNextTabPos = pNextTab->GetPos(); + } - if( pTab && pTab->IsEditable() ) + if( pTab && pTab->IsEditable() ) + { + nTabPos = pTab->GetPos(); + if( !bIsMouseTriggered || (nClickX > nTabPos && (nNextTabPos == -1 || nClickX < nNextTabPos ) ) ) { - nTabPos = pTab->GetPos(); - if( !bIsMouseTriggered || (nClickX > nTabPos && (nNextTabPos == -1 || nClickX < nNextTabPos ) ) ) - { - pItem = static_cast<SvLBoxString*>( &rTmpItem ); - break; - } + pItem = static_cast<SvLBoxString*>( &rTmpItem ); + break; } } + } - Selection aSel( SELECTION_MIN, SELECTION_MAX ); - if( pItem && EditingEntry( pEntry, aSel ) ) - { - SelectAll( false ); - MakeVisible( pEntry ); - EditItemText( pEntry, pItem, aSel ); - } + Selection aSel( SELECTION_MIN, SELECTION_MAX ); + if( pItem && EditingEntry( pEntry, aSel ) ) + { + SelectAll( false ); + MakeVisible( pEntry ); + EditItemText( pEntry, pItem, aSel ); } } @@ -2865,85 +2865,85 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, long nLine, vcl::Render nDynTabPos += 4; // 4 pixels of buffer, so the node bitmap is not too close // to the next tab - if( (!(rEntry.GetFlags() & SvTLEntryFlags::NO_NODEBMP)) && + if( !((!(rEntry.GetFlags() & SvTLEntryFlags::NO_NODEBMP)) && (nWindowStyle & WB_HASBUTTONS) && pFirstDynamicTab && - (rEntry.HasChildren() || rEntry.HasChildrenOnDemand())) + (rEntry.HasChildren() || rEntry.HasChildrenOnDemand()))) + return; + + // find first tab and check if the node bitmap extends into it + sal_uInt16 nNextTab = nFirstDynTabPos; + SvLBoxTab* pNextTab; + do { - // find first tab and check if the node bitmap extends into it - sal_uInt16 nNextTab = nFirstDynTabPos; - SvLBoxTab* pNextTab; - do - { - nNextTab++; - pNextTab = nNextTab < nTabCount ? aTabs[nNextTab] : nullptr; - } while (pNextTab && pNextTab->IsDynamic()); + nNextTab++; + pNextTab = nNextTab < nTabCount ? aTabs[nNextTab] : nullptr; + } while (pNextTab && pNextTab->IsDynamic()); - if (!pNextTab || (GetTabPos( &rEntry, pNextTab ) > nDynTabPos)) - { - if ((nWindowStyle & WB_HASBUTTONSATROOT) || pModel->GetDepth(&rEntry) > 0) - { - Point aPos(GetTabPos(&rEntry, pFirstDynamicTab), nLine); - aPos.X() += pImpl->nNodeBmpTabDistance; + if (!(!pNextTab || (GetTabPos( &rEntry, pNextTab ) > nDynTabPos))) + return; - const Image* pImg = nullptr; + if (!((nWindowStyle & WB_HASBUTTONSATROOT) || pModel->GetDepth(&rEntry) > 0)) + return; - if (IsExpanded(&rEntry)) - pImg = &pImpl->GetExpandedNodeBmp(); - else - { - if ((!rEntry.HasChildren()) && rEntry.HasChildrenOnDemand() && - (!(rEntry.GetFlags() & SvTLEntryFlags::HAD_CHILDREN)) && - pImpl->GetDontKnowNodeBmp().GetSizePixel().Width()) - { - pImg = &pImpl->GetDontKnowNodeBmp( ); - } - else - { - pImg = &pImpl->GetCollapsedNodeBmp( ); - } - } - aPos.Y() += (nTempEntryHeight - pImg->GetSizePixel().Height()) / 2; + Point aPos(GetTabPos(&rEntry, pFirstDynamicTab), nLine); + aPos.X() += pImpl->nNodeBmpTabDistance; - DrawImageFlags nStyle = DrawImageFlags::NONE; - if (!IsEnabled()) - nStyle |= DrawImageFlags::Disable; + const Image* pImg = nullptr; - //native - bool bNativeOK = false; - if (rRenderContext.IsNativeControlSupported(ControlType::ListNode, ControlPart::Entire)) - { - ImplControlValue aControlValue; - tools::Rectangle aCtrlRegion(aPos, pImg->GetSizePixel()); - ControlState nState = ControlState::NONE; - - if (IsEnabled()) - nState |= ControlState::ENABLED; - - if (IsExpanded(&rEntry)) - aControlValue.setTristateVal(ButtonValue::On); //expanded node - else - { - if ((!rEntry.HasChildren()) && rEntry.HasChildrenOnDemand() && - (!(rEntry.GetFlags() & SvTLEntryFlags::HAD_CHILDREN)) && - pImpl->GetDontKnowNodeBmp().GetSizePixel().Width()) - { - aControlValue.setTristateVal( ButtonValue::DontKnow ); //don't know - } - else - { - aControlValue.setTristateVal( ButtonValue::Off ); //collapsed node - } - } - - bNativeOK = rRenderContext.DrawNativeControl(ControlType::ListNode, ControlPart::Entire, aCtrlRegion, nState, aControlValue, OUString()); - } + if (IsExpanded(&rEntry)) + pImg = &pImpl->GetExpandedNodeBmp(); + else + { + if ((!rEntry.HasChildren()) && rEntry.HasChildrenOnDemand() && + (!(rEntry.GetFlags() & SvTLEntryFlags::HAD_CHILDREN)) && + pImpl->GetDontKnowNodeBmp().GetSizePixel().Width()) + { + pImg = &pImpl->GetDontKnowNodeBmp( ); + } + else + { + pImg = &pImpl->GetCollapsedNodeBmp( ); + } + } + aPos.Y() += (nTempEntryHeight - pImg->GetSizePixel().Height()) / 2; - if (!bNativeOK) - { - rRenderContext.DrawImage(aPos, *pImg ,nStyle); - } + DrawImageFlags nStyle = DrawImageFlags::NONE; + if (!IsEnabled()) + nStyle |= DrawImageFlags::Disable; + + //native + bool bNativeOK = false; + if (rRenderContext.IsNativeControlSupported(ControlType::ListNode, ControlPart::Entire)) + { + ImplControlValue aControlValue; + tools::Rectangle aCtrlRegion(aPos, pImg->GetSizePixel()); + ControlState nState = ControlState::NONE; + + if (IsEnabled()) + nState |= ControlState::ENABLED; + + if (IsExpanded(&rEntry)) + aControlValue.setTristateVal(ButtonValue::On); //expanded node + else + { + if ((!rEntry.HasChildren()) && rEntry.HasChildrenOnDemand() && + (!(rEntry.GetFlags() & SvTLEntryFlags::HAD_CHILDREN)) && + pImpl->GetDontKnowNodeBmp().GetSizePixel().Width()) + { + aControlValue.setTristateVal( ButtonValue::DontKnow ); //don't know + } + else + { + aControlValue.setTristateVal( ButtonValue::Off ); //collapsed node } } + + bNativeOK = rRenderContext.DrawNativeControl(ControlType::ListNode, ControlPart::Entire, aCtrlRegion, nState, aControlValue, OUString()); + } + + if (!bNativeOK) + { + rRenderContext.DrawImage(aPos, *pImg ,nStyle); } } 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() diff --git a/svtools/source/dialogs/PlaceEditDialog.cxx b/svtools/source/dialogs/PlaceEditDialog.cxx index 0a7ac213d5e7..e1318d1aa5dc 100644 --- a/svtools/source/dialogs/PlaceEditDialog.cxx +++ b/svtools/source/dialogs/PlaceEditDialog.cxx @@ -223,34 +223,34 @@ void PlaceEditDialog::InitDetails( ) IMPL_LINK( PlaceEditDialog, OKHdl, Button*, /*pBtn*/, void) { - if ( m_xCurrentDetails.get() ) - { - OUString sUrl = m_xCurrentDetails->getUrl().GetHost( INetURLObject::DecodeMechanism::WithCharset ); + if ( !m_xCurrentDetails.get() ) + return; - if ( sUrl.startsWith( GDRIVE_BASE_URL ) - || sUrl.startsWith( ALFRESCO_CLOUD_BASE_URL ) - || sUrl.startsWith( ONEDRIVE_BASE_URL ) ) - { - m_pBTRepoRefresh->Click(); + OUString sUrl = m_xCurrentDetails->getUrl().GetHost( INetURLObject::DecodeMechanism::WithCharset ); - sUrl = m_xCurrentDetails->getUrl().GetHost( INetURLObject::DecodeMechanism::WithCharset ); - INetURLObject aHostUrl( sUrl ); - OUString sRepoId = aHostUrl.GetMark(); + if ( sUrl.startsWith( GDRIVE_BASE_URL ) + || sUrl.startsWith( ALFRESCO_CLOUD_BASE_URL ) + || sUrl.startsWith( ONEDRIVE_BASE_URL ) ) + { + m_pBTRepoRefresh->Click(); - if ( !sRepoId.isEmpty() ) - { - EndDialog( RET_OK ); - } - else - { - // TODO: repository id missing. Auth error? - } + sUrl = m_xCurrentDetails->getUrl().GetHost( INetURLObject::DecodeMechanism::WithCharset ); + INetURLObject aHostUrl( sUrl ); + OUString sRepoId = aHostUrl.GetMark(); + + if ( !sRepoId.isEmpty() ) + { + EndDialog( RET_OK ); } else { - EndDialog( RET_OK ); + // TODO: repository id missing. Auth error? } } + else + { + EndDialog( RET_OK ); + } } IMPL_LINK( PlaceEditDialog, DelHdl, Button*, /*pButton*/, void) diff --git a/svtools/source/dialogs/addresstemplate.cxx b/svtools/source/dialogs/addresstemplate.cxx index 58f4c7c542f3..fd1c4a548285 100644 --- a/svtools/source/dialogs/addresstemplate.cxx +++ b/svtools/source/dialogs/addresstemplate.cxx @@ -627,21 +627,21 @@ void AssignmentPersistentData::ImplCommit() // so the dialog will at least show up before we do the loading of the // configuration data and the (maybe time consuming) analysis of the data source/table to select - if ( !m_pImpl->bWorkingPersistent ) - { - StyleSettings aSystemStyle = GetSettings().GetStyleSettings(); - const ::Color& rNewColor = aSystemStyle.GetDialogColor(); + if ( m_pImpl->bWorkingPersistent ) + return; - m_pDatasource->SetReadOnly(); - m_pDatasource->SetBackground( Wallpaper( rNewColor ) ); - m_pDatasource->SetControlBackground( rNewColor ); + StyleSettings aSystemStyle = GetSettings().GetStyleSettings(); + const ::Color& rNewColor = aSystemStyle.GetDialogColor(); - m_pTable->SetReadOnly(); - m_pTable->SetBackground( Wallpaper( rNewColor ) ); - m_pTable->SetControlBackground( rNewColor ); + m_pDatasource->SetReadOnly(); + m_pDatasource->SetBackground( Wallpaper( rNewColor ) ); + m_pDatasource->SetControlBackground( rNewColor ); - m_pAdministrateDatasources->Hide( ); - } + m_pTable->SetReadOnly(); + m_pTable->SetBackground( Wallpaper( rNewColor ) ); + m_pTable->SetControlBackground( rNewColor ); + + m_pAdministrateDatasources->Hide( ); } diff --git a/svtools/source/dialogs/wizdlg.cxx b/svtools/source/dialogs/wizdlg.cxx index 7694f7f6add6..a24522bcaf56 100644 --- a/svtools/source/dialogs/wizdlg.cxx +++ b/svtools/source/dialogs/wizdlg.cxx @@ -177,55 +177,55 @@ void WizardDialog::ImplPosCtrls() nOffY -= WIZARDDIALOG_BUTTON_OFFSET_Y; } - if ( mpViewWindow && mpViewWindow->IsVisible() ) + if ( !(mpViewWindow && mpViewWindow->IsVisible()) ) + return; + + long nViewOffX = 0; + long nViewOffY = 0; + long nViewWidth = 0; + long nViewHeight = 0; + long nDlgHeight = nOffY; + PosSizeFlags nViewPosFlags = PosSizeFlags::Pos; + if ( meViewAlign == WindowAlign::Top ) { - long nViewOffX = 0; - long nViewOffY = 0; - long nViewWidth = 0; - long nViewHeight = 0; - long nDlgHeight = nOffY; - PosSizeFlags nViewPosFlags = PosSizeFlags::Pos; - if ( meViewAlign == WindowAlign::Top ) - { - nViewOffX = WIZARDDIALOG_VIEW_DLGOFFSET_X; - nViewOffY = WIZARDDIALOG_VIEW_DLGOFFSET_Y; - nViewWidth = aDlgSize.Width()-(WIZARDDIALOG_VIEW_DLGOFFSET_X*2); - nViewPosFlags |= PosSizeFlags::Width; - } - else if ( meViewAlign == WindowAlign::Left ) + nViewOffX = WIZARDDIALOG_VIEW_DLGOFFSET_X; + nViewOffY = WIZARDDIALOG_VIEW_DLGOFFSET_Y; + nViewWidth = aDlgSize.Width()-(WIZARDDIALOG_VIEW_DLGOFFSET_X*2); + nViewPosFlags |= PosSizeFlags::Width; + } + else if ( meViewAlign == WindowAlign::Left ) + { + if ( mbEmptyViewMargin ) { - if ( mbEmptyViewMargin ) - { - nViewOffX = 0; - nViewOffY = 0; - nViewHeight = nDlgHeight; - } - else - { - nViewOffX = WIZARDDIALOG_VIEW_DLGOFFSET_X; - nViewOffY = WIZARDDIALOG_VIEW_DLGOFFSET_Y; - nViewHeight = nDlgHeight-(WIZARDDIALOG_VIEW_DLGOFFSET_Y*2); - } - nViewPosFlags |= PosSizeFlags::Height; + nViewOffX = 0; + nViewOffY = 0; + nViewHeight = nDlgHeight; } - else if ( meViewAlign == WindowAlign::Bottom ) + else { nViewOffX = WIZARDDIALOG_VIEW_DLGOFFSET_X; - nViewOffY = nDlgHeight-mpViewWindow->GetSizePixel().Height()-WIZARDDIALOG_VIEW_DLGOFFSET_Y; - nViewWidth = aDlgSize.Width()-(WIZARDDIALOG_VIEW_DLGOFFSET_X*2); - nViewPosFlags |= PosSizeFlags::Width; - } - else if ( meViewAlign == WindowAlign::Right ) - { - nViewOffX = aDlgSize.Width()-mpViewWindow->GetSizePixel().Width()-WIZARDDIALOG_VIEW_DLGOFFSET_X; nViewOffY = WIZARDDIALOG_VIEW_DLGOFFSET_Y; nViewHeight = nDlgHeight-(WIZARDDIALOG_VIEW_DLGOFFSET_Y*2); - nViewPosFlags |= PosSizeFlags::Height; } - mpViewWindow->setPosSizePixel( nViewOffX, nViewOffY, - nViewWidth, nViewHeight, - nViewPosFlags ); + nViewPosFlags |= PosSizeFlags::Height; + } + else if ( meViewAlign == WindowAlign::Bottom ) + { + nViewOffX = WIZARDDIALOG_VIEW_DLGOFFSET_X; + nViewOffY = nDlgHeight-mpViewWindow->GetSizePixel().Height()-WIZARDDIALOG_VIEW_DLGOFFSET_Y; + nViewWidth = aDlgSize.Width()-(WIZARDDIALOG_VIEW_DLGOFFSET_X*2); + nViewPosFlags |= PosSizeFlags::Width; + } + else if ( meViewAlign == WindowAlign::Right ) + { + nViewOffX = aDlgSize.Width()-mpViewWindow->GetSizePixel().Width()-WIZARDDIALOG_VIEW_DLGOFFSET_X; + nViewOffY = WIZARDDIALOG_VIEW_DLGOFFSET_Y; + nViewHeight = nDlgHeight-(WIZARDDIALOG_VIEW_DLGOFFSET_Y*2); + nViewPosFlags |= PosSizeFlags::Height; } + mpViewWindow->setPosSizePixel( nViewOffX, nViewOffY, + nViewWidth, nViewHeight, + nViewPosFlags ); } diff --git a/svtools/source/edit/editsyntaxhighlighter.cxx b/svtools/source/edit/editsyntaxhighlighter.cxx index b8bc4d118a83..6c081b4f11db 100644 --- a/svtools/source/edit/editsyntaxhighlighter.cxx +++ b/svtools/source/edit/editsyntaxhighlighter.cxx @@ -72,39 +72,39 @@ void MultiLineEditSyntaxHighlight::DoBracketHilight(sal_uInt16 nKey) } } - if (nChar != -1) + if (nChar == -1) + return; + + sal_uInt32 nPara = nStartPara; + do { - sal_uInt32 nPara = nStartPara; - do - { - if (nPara == nStartPara && nStartPos == 0) - continue; + if (nPara == nStartPara && nStartPos == 0) + continue; - OUString aLine( GetTextEngine()->GetText( nPara ) ); + OUString aLine( GetTextEngine()->GetText( nPara ) ); - if (aLine.isEmpty()) - continue; + if (aLine.isEmpty()) + continue; - for (sal_Int32 i = (nPara==nStartPara) ? nStartPos-1 : aLine.getLength()-1; i>0; --i) + for (sal_Int32 i = (nPara==nStartPara) ? nStartPos-1 : aLine.getLength()-1; i>0; --i) + { + if (aLine[i] == nChar) { - if (aLine[i] == nChar) + if (!nCount) { - if (!nCount) - { - GetTextEngine()->SetAttrib( TextAttribFontWeight( WEIGHT_ULTRABOLD ), nPara, i, i+1 ); - GetTextEngine()->SetAttrib( TextAttribFontColor( Color(0,0,0) ), nPara, i, i+1 ); - GetTextEngine()->SetAttrib( TextAttribFontWeight( WEIGHT_ULTRABOLD ), nStartPara, nStartPos, nStartPos ); - GetTextEngine()->SetAttrib( TextAttribFontColor( Color(0,0,0) ), nStartPara, nStartPos, nStartPos ); - return; - } - else - --nCount; + GetTextEngine()->SetAttrib( TextAttribFontWeight( WEIGHT_ULTRABOLD ), nPara, i, i+1 ); + GetTextEngine()->SetAttrib( TextAttribFontColor( Color(0,0,0) ), nPara, i, i+1 ); + GetTextEngine()->SetAttrib( TextAttribFontWeight( WEIGHT_ULTRABOLD ), nStartPara, nStartPos, nStartPos ); + GetTextEngine()->SetAttrib( TextAttribFontColor( Color(0,0,0) ), nStartPara, nStartPos, nStartPos ); + return; } - if (aLine[i] == nKey) - ++nCount; + else + --nCount; } - } while (nPara--); - } + if (aLine[i] == nKey) + ++nCount; + } + } while (nPara--); } bool MultiLineEditSyntaxHighlight::PreNotify( NotifyEvent& rNEvt ) diff --git a/svtools/source/filter/DocumentToGraphicRenderer.cxx b/svtools/source/filter/DocumentToGraphicRenderer.cxx index b5274078e3b1..812fea51d701 100644 --- a/svtools/source/filter/DocumentToGraphicRenderer.cxx +++ b/svtools/source/filter/DocumentToGraphicRenderer.cxx @@ -63,29 +63,29 @@ DocumentToGraphicRenderer::DocumentToGraphicRenderer( const Reference<XComponent { } - if (mbSelectionOnly && mxController.is()) + if (!(mbSelectionOnly && mxController.is())) + return; + + try { - try + uno::Reference< view::XSelectionSupplier > xSelSup( mxController, uno::UNO_QUERY); + if (xSelSup.is()) { - uno::Reference< view::XSelectionSupplier > xSelSup( mxController, uno::UNO_QUERY); - if (xSelSup.is()) + uno::Any aViewSelection( xSelSup->getSelection()); + if (aViewSelection.hasValue()) { - uno::Any aViewSelection( xSelSup->getSelection()); - if (aViewSelection.hasValue()) - { - /* FIXME: Writer always has a selection even if nothing is - * selected, but passing a selection to - * XRenderable::render() it always renders an empty page. - * So disable the selection already here. The current page - * the cursor is on is rendered. */ - if (!mbIsWriter) - maSelection = aViewSelection; - } + /* FIXME: Writer always has a selection even if nothing is + * selected, but passing a selection to + * XRenderable::render() it always renders an empty page. + * So disable the selection already here. The current page + * the cursor is on is rendered. */ + if (!mbIsWriter) + maSelection = aViewSelection; } } - catch (const uno::Exception&) - { - } + } + catch (const uno::Exception&) + { } } diff --git a/svtools/source/filter/SvFilterOptionsDialog.cxx b/svtools/source/filter/SvFilterOptionsDialog.cxx index 8c3b8e61012e..a699ea6acc9a 100644 --- a/svtools/source/filter/SvFilterOptionsDialog.cxx +++ b/svtools/source/filter/SvFilterOptionsDialog.cxx @@ -249,31 +249,31 @@ void SvFilterOptionsDialog::setSourceDocument( const uno::Reference< lang::XComp OUString aConfigPath; uno::Reference< lang::XServiceInfo > xServiceInfo ( xDoc, uno::UNO_QUERY ); - if ( xServiceInfo.is() ) + if ( !xServiceInfo.is() ) + return; + + if ( xServiceInfo->supportsService("com.sun.star.presentation.PresentationDocument") ) + aConfigPath = "Office.Impress/Layout/Other/MeasureUnit"; + else if ( xServiceInfo->supportsService("com.sun.star.drawing.DrawingDocument") ) + aConfigPath = "Office.Draw/Layout/Other/MeasureUnit"; + else { - if ( xServiceInfo->supportsService("com.sun.star.presentation.PresentationDocument") ) - aConfigPath = "Office.Impress/Layout/Other/MeasureUnit"; - else if ( xServiceInfo->supportsService("com.sun.star.drawing.DrawingDocument") ) - aConfigPath = "Office.Draw/Layout/Other/MeasureUnit"; + mbGraphicsSource = false; + if ( xServiceInfo->supportsService("com.sun.star.sheet.SpreadsheetDocument") ) + aConfigPath = "Office.Calc/Layout/Other/MeasureUnit"; + else if ( xServiceInfo->supportsService("com.sun.star.text.TextDocument") ) + aConfigPath = "Office.Writer/Layout/Other/MeasureUnit"; + } + if ( !aConfigPath.isEmpty() ) + { + FilterConfigItem aConfigItem( aConfigPath ); + OUString aPropertyName; + SvtSysLocale aSysLocale; + if ( aSysLocale.GetLocaleDataPtr()->getMeasurementSystemEnum() == MeasurementSystem::Metric ) + aPropertyName = "Metric"; else - { - mbGraphicsSource = false; - if ( xServiceInfo->supportsService("com.sun.star.sheet.SpreadsheetDocument") ) - aConfigPath = "Office.Calc/Layout/Other/MeasureUnit"; - else if ( xServiceInfo->supportsService("com.sun.star.text.TextDocument") ) - aConfigPath = "Office.Writer/Layout/Other/MeasureUnit"; - } - if ( !aConfigPath.isEmpty() ) - { - FilterConfigItem aConfigItem( aConfigPath ); - OUString aPropertyName; - SvtSysLocale aSysLocale; - if ( aSysLocale.GetLocaleDataPtr()->getMeasurementSystemEnum() == MeasurementSystem::Metric ) - aPropertyName = "Metric"; - else - aPropertyName = "NonMetric"; - meFieldUnit = (FieldUnit)aConfigItem.ReadInt32( aPropertyName, FUNIT_CM ); - } + aPropertyName = "NonMetric"; + meFieldUnit = (FieldUnit)aConfigItem.ReadInt32( aPropertyName, FUNIT_CM ); } } diff --git a/svtools/source/filter/exportdialog.cxx b/svtools/source/filter/exportdialog.cxx index b7f61c020683..a309b748e096 100644 --- a/svtools/source/filter/exportdialog.cxx +++ b/svtools/source/filter/exportdialog.cxx @@ -363,37 +363,37 @@ void ExportDialog::GetGraphicSource() if (mxGraphic.is()) return; - if ( mxSourceDocument.is() ) + if ( !mxSourceDocument.is() ) + return; + + uno::Reference< frame::XModel > xModel( mxSourceDocument, uno::UNO_QUERY ); + if ( !xModel.is() ) + return; + + uno::Reference< frame::XController > xController( xModel->getCurrentController() ); + if ( !xController.is() ) + return; + + if ( mbExportSelection ) // check if there is a selection + { + if (DocumentToGraphicRenderer::isShapeSelected( mxShapes, mxShape, xController)) + mbGraphicsSource = true; + } + if ( !mxShape.is() && !mxShapes.is() && mbGraphicsSource ) { - uno::Reference< frame::XModel > xModel( mxSourceDocument, uno::UNO_QUERY ); - if ( xModel.is() ) + uno::Reference< drawing::XDrawView > xDrawView( xController, uno::UNO_QUERY ); + if ( xDrawView.is() ) { - uno::Reference< frame::XController > xController( xModel->getCurrentController() ); - if ( xController.is() ) + uno::Reference< drawing::XDrawPage > xCurrentPage( xDrawView->getCurrentPage() ); + if ( xCurrentPage.is() ) { - if ( mbExportSelection ) // check if there is a selection - { - if (DocumentToGraphicRenderer::isShapeSelected( mxShapes, mxShape, xController)) - mbGraphicsSource = true; - } - if ( !mxShape.is() && !mxShapes.is() && mbGraphicsSource ) - { - uno::Reference< drawing::XDrawView > xDrawView( xController, uno::UNO_QUERY ); - if ( xDrawView.is() ) - { - uno::Reference< drawing::XDrawPage > xCurrentPage( xDrawView->getCurrentPage() ); - if ( xCurrentPage.is() ) - { - mxPage = xCurrentPage; // exporting whole page - } - } - } - // For !mbGraphicsSource the mxSourceDocument is used, from - // which XRenderable can query XController and - // XSelectionSupplier the same. + mxPage = xCurrentPage; // exporting whole page } } } + // For !mbGraphicsSource the mxSourceDocument is used, from + // which XRenderable can query XController and + // XSelectionSupplier the same. } void ExportDialog::GetGraphicStream() @@ -756,19 +756,20 @@ void ExportDialog::setupSizeControls() nUnit = UNIT_CM; mpLbSizeX->SelectEntryPos( static_cast< sal_uInt16 >( nUnit ) ); - if ( mbIsPixelFormat ) // TODO: (metafileresolutionsupport) should be supported for vector formats also... this makes - { // sense eg for bitmap fillings in metafiles, to preserve high dpi output - // (atm without special vector support the bitmaps are rendered with 96dpi) - sal_Int32 nResolution = mpOptionsItem->ReadInt32("PixelExportResolution", 96); - if ( nResolution < 1 ) - nResolution = 96; - mpNfResolution->SetValue( nResolution ); - - sal_Int32 nResolutionUnit = mpOptionsItem->ReadInt32("PixelExportResolutionUnit", 1); - if ( ( nResolutionUnit < 0 ) || ( nResolutionUnit > 2 ) ) - nResolutionUnit = 1; - mpLbResolution->SelectEntryPos( static_cast< sal_uInt16 >( nResolutionUnit ) ); - } + if ( !mbIsPixelFormat ) // TODO: (metafileresolutionsupport) should be supported for vector formats also... this makes +return; + +// sense eg for bitmap fillings in metafiles, to preserve high dpi output + // (atm without special vector support the bitmaps are rendered with 96dpi) + sal_Int32 nResolution = mpOptionsItem->ReadInt32("PixelExportResolution", 96); + if ( nResolution < 1 ) + nResolution = 96; + mpNfResolution->SetValue( nResolution ); + + sal_Int32 nResolutionUnit = mpOptionsItem->ReadInt32("PixelExportResolutionUnit", 1); + if ( ( nResolutionUnit < 0 ) || ( nResolutionUnit > 2 ) ) + nResolutionUnit = 1; + mpLbResolution->SelectEntryPos( static_cast< sal_uInt16 >( nResolutionUnit ) ); } void ExportDialog::createFilterOptions() diff --git a/svtools/source/graphic/descriptor.cxx b/svtools/source/graphic/descriptor.cxx index f89895826efd..b6e630d44083 100644 --- a/svtools/source/graphic/descriptor.cxx +++ b/svtools/source/graphic/descriptor.cxx @@ -101,51 +101,51 @@ void GraphicDescriptor::implCreate( SvStream& rIStm, const OUString* pURL ) mnBitsPerPixel = 0; mbTransparent = false; - if( aDescriptor.Detect( true ) && aDescriptor.GetFileFormat() != GraphicFileFormat::NOT ) - { - const char* pMimeType = nullptr; - sal_uInt8 cType = graphic::GraphicType::EMPTY; + if( !(aDescriptor.Detect( true ) && aDescriptor.GetFileFormat() != GraphicFileFormat::NOT) ) + return; - switch( aDescriptor.GetFileFormat() ) - { - case GraphicFileFormat::BMP: pMimeType = MIMETYPE_BMP; cType = graphic::GraphicType::PIXEL; break; - case GraphicFileFormat::GIF: pMimeType = MIMETYPE_GIF; cType = graphic::GraphicType::PIXEL; break; - case GraphicFileFormat::JPG: pMimeType = MIMETYPE_JPG; cType = graphic::GraphicType::PIXEL; break; - case GraphicFileFormat::PCD: pMimeType = MIMETYPE_PCD; cType = graphic::GraphicType::PIXEL; break; - case GraphicFileFormat::PCX: pMimeType = MIMETYPE_PCX; cType = graphic::GraphicType::PIXEL; break; - case GraphicFileFormat::PNG: pMimeType = MIMETYPE_PNG; cType = graphic::GraphicType::PIXEL; break; - case GraphicFileFormat::TIF: pMimeType = MIMETYPE_TIF; cType = graphic::GraphicType::PIXEL; break; - case GraphicFileFormat::XBM: pMimeType = MIMETYPE_XBM; cType = graphic::GraphicType::PIXEL; break; - case GraphicFileFormat::XPM: pMimeType = MIMETYPE_XPM; cType = graphic::GraphicType::PIXEL; break; - case GraphicFileFormat::PBM: pMimeType = MIMETYPE_PBM; cType = graphic::GraphicType::PIXEL; break; - case GraphicFileFormat::PGM: pMimeType = MIMETYPE_PGM; cType = graphic::GraphicType::PIXEL; break; - case GraphicFileFormat::PPM: pMimeType = MIMETYPE_PPM; cType = graphic::GraphicType::PIXEL; break; - case GraphicFileFormat::RAS: pMimeType = MIMETYPE_RAS; cType = graphic::GraphicType::PIXEL; break; - case GraphicFileFormat::TGA: pMimeType = MIMETYPE_TGA; cType = graphic::GraphicType::PIXEL; break; - case GraphicFileFormat::PSD: pMimeType = MIMETYPE_PSD; cType = graphic::GraphicType::PIXEL; break; - - case GraphicFileFormat::EPS: pMimeType = MIMETYPE_EPS; cType = graphic::GraphicType::VECTOR; break; - case GraphicFileFormat::DXF: pMimeType = MIMETYPE_DXF; cType = graphic::GraphicType::VECTOR; break; - case GraphicFileFormat::MET: pMimeType = MIMETYPE_MET; cType = graphic::GraphicType::VECTOR; break; - case GraphicFileFormat::PCT: pMimeType = MIMETYPE_PCT; cType = graphic::GraphicType::VECTOR; break; - case GraphicFileFormat::SVM: pMimeType = MIMETYPE_SVM; cType = graphic::GraphicType::VECTOR; break; - case GraphicFileFormat::WMF: pMimeType = MIMETYPE_WMF; cType = graphic::GraphicType::VECTOR; break; - case GraphicFileFormat::EMF: pMimeType = MIMETYPE_EMF; cType = graphic::GraphicType::VECTOR; break; - case GraphicFileFormat::SVG: pMimeType = MIMETYPE_SVG; cType = graphic::GraphicType::VECTOR; break; - - default: - break; - } + const char* pMimeType = nullptr; + sal_uInt8 cType = graphic::GraphicType::EMPTY; - if( graphic::GraphicType::EMPTY != cType ) - { - meType = ( ( graphic::GraphicType::PIXEL == cType ) ? GraphicType::Bitmap : GraphicType::GdiMetafile ); - maMimeType = OUString( pMimeType, strlen(pMimeType), RTL_TEXTENCODING_ASCII_US ); - maSizePixel = aDescriptor.GetSizePixel(); - maSize100thMM = aDescriptor.GetSize_100TH_MM(); - mnBitsPerPixel = aDescriptor.GetBitsPerPixel(); - mbTransparent = ( graphic::GraphicType::VECTOR == cType ); - } + switch( aDescriptor.GetFileFormat() ) + { + case GraphicFileFormat::BMP: pMimeType = MIMETYPE_BMP; cType = graphic::GraphicType::PIXEL; break; + case GraphicFileFormat::GIF: pMimeType = MIMETYPE_GIF; cType = graphic::GraphicType::PIXEL; break; + case GraphicFileFormat::JPG: pMimeType = MIMETYPE_JPG; cType = graphic::GraphicType::PIXEL; break; + case GraphicFileFormat::PCD: pMimeType = MIMETYPE_PCD; cType = graphic::GraphicType::PIXEL; break; + case GraphicFileFormat::PCX: pMimeType = MIMETYPE_PCX; cType = graphic::GraphicType::PIXEL; break; + case GraphicFileFormat::PNG: pMimeType = MIMETYPE_PNG; cType = graphic::GraphicType::PIXEL; break; + case GraphicFileFormat::TIF: pMimeType = MIMETYPE_TIF; cType = graphic::GraphicType::PIXEL; break; + case GraphicFileFormat::XBM: pMimeType = MIMETYPE_XBM; cType = graphic::GraphicType::PIXEL; break; + case GraphicFileFormat::XPM: pMimeType = MIMETYPE_XPM; cType = graphic::GraphicType::PIXEL; break; + case GraphicFileFormat::PBM: pMimeType = MIMETYPE_PBM; cType = graphic::GraphicType::PIXEL; break; + case GraphicFileFormat::PGM: pMimeType = MIMETYPE_PGM; cType = graphic::GraphicType::PIXEL; break; + case GraphicFileFormat::PPM: pMimeType = MIMETYPE_PPM; cType = graphic::GraphicType::PIXEL; break; + case GraphicFileFormat::RAS: pMimeType = MIMETYPE_RAS; cType = graphic::GraphicType::PIXEL; break; + case GraphicFileFormat::TGA: pMimeType = MIMETYPE_TGA; cType = graphic::GraphicType::PIXEL; break; + case GraphicFileFormat::PSD: pMimeType = MIMETYPE_PSD; cType = graphic::GraphicType::PIXEL; break; + + case GraphicFileFormat::EPS: pMimeType = MIMETYPE_EPS; cType = graphic::GraphicType::VECTOR; break; + case GraphicFileFormat::DXF: pMimeType = MIMETYPE_DXF; cType = graphic::GraphicType::VECTOR; break; + case GraphicFileFormat::MET: pMimeType = MIMETYPE_MET; cType = graphic::GraphicType::VECTOR; break; + case GraphicFileFormat::PCT: pMimeType = MIMETYPE_PCT; cType = graphic::GraphicType::VECTOR; break; + case GraphicFileFormat::SVM: pMimeType = MIMETYPE_SVM; cType = graphic::GraphicType::VECTOR; break; + case GraphicFileFormat::WMF: pMimeType = MIMETYPE_WMF; cType = graphic::GraphicType::VECTOR; break; + case GraphicFileFormat::EMF: pMimeType = MIMETYPE_EMF; cType = graphic::GraphicType::VECTOR; break; + case GraphicFileFormat::SVG: pMimeType = MIMETYPE_SVG; cType = graphic::GraphicType::VECTOR; break; + + default: + break; + } + + if( graphic::GraphicType::EMPTY != cType ) + { + meType = ( ( graphic::GraphicType::PIXEL == cType ) ? GraphicType::Bitmap : GraphicType::GdiMetafile ); + maMimeType = OUString( pMimeType, strlen(pMimeType), RTL_TEXTENCODING_ASCII_US ); + maSizePixel = aDescriptor.GetSizePixel(); + maSize100thMM = aDescriptor.GetSize_100TH_MM(); + mnBitsPerPixel = aDescriptor.GetBitsPerPixel(); + mbTransparent = ( graphic::GraphicType::VECTOR == cType ); } } diff --git a/svtools/source/graphic/grfcache.cxx b/svtools/source/graphic/grfcache.cxx index 1f99b841cea8..da41b631fc93 100644 --- a/svtools/source/graphic/grfcache.cxx +++ b/svtools/source/graphic/grfcache.cxx @@ -372,19 +372,19 @@ void GraphicCacheEntry::GraphicObjectWasSwappedOut() if( !maGraphicObjectList[ i ]->IsSwappedOut() ) mbSwappedAll = false; - if( mbSwappedAll ) - { - delete mpBmpEx; - mpBmpEx = nullptr; - delete mpMtf; - mpMtf = nullptr; - delete mpAnimation; - mpAnimation = nullptr; - - // #119176# also reset VectorGraphicData - maVectorGraphicData.reset(); - maPdfData = uno::Sequence<sal_Int8>(); - } + if( !mbSwappedAll ) + return; + + delete mpBmpEx; + mpBmpEx = nullptr; + delete mpMtf; + mpMtf = nullptr; + delete mpAnimation; + mpAnimation = nullptr; + + // #119176# also reset VectorGraphicData + maVectorGraphicData.reset(); + maPdfData = uno::Sequence<sal_Int8>(); } void GraphicCacheEntry::GraphicObjectWasSwappedIn( const GraphicObject& rObj ) @@ -1019,21 +1019,21 @@ void GraphicCache::SetMaxDisplayCacheSize( sal_uLong nNewCacheSize ) void GraphicCache::SetCacheTimeout( sal_uLong nTimeoutSeconds ) { - if( mnReleaseTimeoutSeconds != nTimeoutSeconds ) - { - ::salhelper::TTimeValue aReleaseTime; + if( mnReleaseTimeoutSeconds == nTimeoutSeconds ) + return; - if( ( mnReleaseTimeoutSeconds = nTimeoutSeconds ) != 0 ) - { - osl_getSystemTime( &aReleaseTime ); - aReleaseTime.addTime( ::salhelper::TTimeValue( nTimeoutSeconds, 0 ) ); - } + ::salhelper::TTimeValue aReleaseTime; - for( GraphicDisplayCacheEntryVector::const_iterator it = maDisplayCache.begin(); - it != maDisplayCache.end(); ++it ) - { - (*it)->SetReleaseTime( aReleaseTime ); - } + if( ( mnReleaseTimeoutSeconds = nTimeoutSeconds ) != 0 ) + { + osl_getSystemTime( &aReleaseTime ); + aReleaseTime.addTime( ::salhelper::TTimeValue( nTimeoutSeconds, 0 ) ); + } + + for( GraphicDisplayCacheEntryVector::const_iterator it = maDisplayCache.begin(); + it != maDisplayCache.end(); ++it ) + { + (*it)->SetReleaseTime( aReleaseTime ); } } diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx index 8d030fdc19c5..b65f092a6964 100644 --- a/svtools/source/graphic/grfmgr.cxx +++ b/svtools/source/graphic/grfmgr.cxx @@ -150,85 +150,85 @@ void GraphicObject::ImplAssignGraphicData() void GraphicObject::ImplEnsureGraphicManager() { - if (!mpGlobalMgr) + if (mpGlobalMgr) + return; + + sal_uLong nCacheSize = 20000; + sal_uLong nMaxObjCacheSize = 20000; + sal_uLong nTimeoutSeconds = 20000; + if (!utl::ConfigManager::IsFuzzing()) { - sal_uLong nCacheSize = 20000; - sal_uLong nMaxObjCacheSize = 20000; - sal_uLong nTimeoutSeconds = 20000; - if (!utl::ConfigManager::IsFuzzing()) + try + { + nCacheSize = officecfg::Office::Common::Cache::GraphicManager::TotalCacheSize::get(); + nMaxObjCacheSize = officecfg::Office::Common::Cache::GraphicManager::ObjectCacheSize::get(); + nTimeoutSeconds = officecfg::Office::Common::Cache::GraphicManager::ObjectReleaseTime::get(); + } + catch (...) { - try - { - nCacheSize = officecfg::Office::Common::Cache::GraphicManager::TotalCacheSize::get(); - nMaxObjCacheSize = officecfg::Office::Common::Cache::GraphicManager::ObjectCacheSize::get(); - nTimeoutSeconds = officecfg::Office::Common::Cache::GraphicManager::ObjectReleaseTime::get(); - } - catch (...) - { - } } - mpGlobalMgr = new GraphicManager(nCacheSize, nMaxObjCacheSize); - mpGlobalMgr->SetCacheTimeout(nTimeoutSeconds); } + mpGlobalMgr = new GraphicManager(nCacheSize, nMaxObjCacheSize); + mpGlobalMgr->SetCacheTimeout(nTimeoutSeconds); } void GraphicObject::ImplAutoSwapIn() { - if( IsSwappedOut() ) + if( !IsSwappedOut() ) + return; + { + mbIsInSwapIn = true; + + if( maGraphic.SwapIn() ) + mbAutoSwapped = false; + else { - mbIsInSwapIn = true; + SvStream* pStream = GetSwapStream(); - if( maGraphic.SwapIn() ) - mbAutoSwapped = false; - else + if( GRFMGR_AUTOSWAPSTREAM_NONE != pStream ) { - SvStream* pStream = GetSwapStream(); - - if( GRFMGR_AUTOSWAPSTREAM_NONE != pStream ) + if( GRFMGR_AUTOSWAPSTREAM_LINK == pStream ) { - if( GRFMGR_AUTOSWAPSTREAM_LINK == pStream ) + if( HasLink() ) { - if( HasLink() ) + OUString aURLStr; + + if( osl::FileBase::getFileURLFromSystemPath( GetLink(), aURLStr ) == osl::FileBase::E_None ) { - OUString aURLStr; + std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream( aURLStr, StreamMode::READ )); - if( osl::FileBase::getFileURLFromSystemPath( GetLink(), aURLStr ) == osl::FileBase::E_None ) + if( pIStm ) { - std::unique_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream( aURLStr, StreamMode::READ )); - - if( pIStm ) - { - ReadGraphic( *pIStm, maGraphic ); - mbAutoSwapped = ( maGraphic.GetType() != GraphicType::NONE ); - } + ReadGraphic( *pIStm, maGraphic ); + mbAutoSwapped = ( maGraphic.GetType() != GraphicType::NONE ); } } } - else if( GRFMGR_AUTOSWAPSTREAM_TEMP == pStream ) - mbAutoSwapped = !maGraphic.SwapIn(); - else if( GRFMGR_AUTOSWAPSTREAM_LOADED == pStream ) - mbAutoSwapped = maGraphic.IsSwapOut(); - else - { - mbAutoSwapped = !maGraphic.SwapIn( pStream ); - delete pStream; - } } + else if( GRFMGR_AUTOSWAPSTREAM_TEMP == pStream ) + mbAutoSwapped = !maGraphic.SwapIn(); + else if( GRFMGR_AUTOSWAPSTREAM_LOADED == pStream ) + mbAutoSwapped = maGraphic.IsSwapOut(); else { - DBG_ASSERT( ( GraphicType::NONE == meType ) || ( GraphicType::Default == meType ), - "GraphicObject::ImplAutoSwapIn: could not get stream to swap in graphic! (=>KA)" ); + mbAutoSwapped = !maGraphic.SwapIn( pStream ); + delete pStream; } } + else + { + DBG_ASSERT( ( GraphicType::NONE == meType ) || ( GraphicType::Default == meType ), + "GraphicObject::ImplAutoSwapIn: could not get stream to swap in graphic! (=>KA)" ); + } + } - mbIsInSwapIn = false; + mbIsInSwapIn = false; - if (!mbAutoSwapped) - mpGlobalMgr->ImplGraphicObjectWasSwappedIn( *this ); - } - ImplAssignGraphicData(); + if (!mbAutoSwapped) + mpGlobalMgr->ImplGraphicObjectWasSwappedIn( *this ); } + ImplAssignGraphicData(); } bool GraphicObject::ImplGetCropParams( OutputDevice const * pOut, Point& rPt, Size& rSz, const GraphicAttr* pAttr, diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx index 7a9fe8ddd166..f6dd8a198e82 100644 --- a/svtools/source/graphic/grfmgr2.cxx +++ b/svtools/source/graphic/grfmgr2.cxx @@ -186,34 +186,34 @@ void GraphicManager::ImplCheckSizeOfSwappedInGraphics(const GraphicObject* pGrap // to 200MB). const sal_uLong nMaxCacheSize(GetMaxCacheSize()); - if(mnUsedSize > nMaxCacheSize) - { - // Copy the object list for now, because maObjList can change in the meantime unexpectedly. - std::vector< GraphicObject* > aCandidates(maObjList.begin(), maObjList.end()); - // if we use more currently, sort by last DataChangeTimeStamp - // sort by DataChangeTimeStamp so that the oldest get removed first - std::sort(aCandidates.begin(), aCandidates.end(), simpleSortByDataChangeTimeStamp()); + if(mnUsedSize <= nMaxCacheSize) + return; - for(decltype(aCandidates)::size_type a(0); mnUsedSize >= nMaxCacheSize && a < aCandidates.size(); a++) + // Copy the object list for now, because maObjList can change in the meantime unexpectedly. + std::vector< GraphicObject* > aCandidates(maObjList.begin(), maObjList.end()); + // if we use more currently, sort by last DataChangeTimeStamp + // sort by DataChangeTimeStamp so that the oldest get removed first + std::sort(aCandidates.begin(), aCandidates.end(), simpleSortByDataChangeTimeStamp()); + + for(decltype(aCandidates)::size_type a(0); mnUsedSize >= nMaxCacheSize && a < aCandidates.size(); a++) + { + // swap out until we have no more or the goal to use less than nMaxCacheSize + // is reached + GraphicObject* pObj = aCandidates[a]; + if( pObj == pGraphicToIgnore ) { - // swap out until we have no more or the goal to use less than nMaxCacheSize - // is reached - GraphicObject* pObj = aCandidates[a]; - if( pObj == pGraphicToIgnore ) - { - continue; - } - if (maObjList.find(pObj) == maObjList.end()) - { - // object has been deleted when swapping out another one - continue; - } + continue; + } + if (maObjList.find(pObj) == maObjList.end()) + { + // object has been deleted when swapping out another one + continue; + } - // do not swap out when we have less than 16KB data objects - if(pObj->GetSizeBytes() >= (16 * 1024)) - { - pObj->FireSwapOutRequest(); - } + // do not swap out when we have less than 16KB data objects + if(pObj->GetSizeBytes() >= (16 * 1024)) + { + pObj->FireSwapOutRequest(); } } } @@ -1438,62 +1438,62 @@ void GraphicManager::ImplAdjust( BitmapEx& rBmpEx, const GraphicAttr& rAttr, Gra rBmpEx.Rotate( aAttr.GetRotation(), Color( COL_TRANSPARENT ) ); } - if( ( nAdjustmentFlags & GraphicAdjustmentFlags::TRANSPARENCY ) && aAttr.IsTransparent() ) + if( !(( nAdjustmentFlags & GraphicAdjustmentFlags::TRANSPARENCY ) && aAttr.IsTransparent()) ) + return; + + AlphaMask aAlpha; + sal_uInt8 cTrans = aAttr.GetTransparency(); + + if( !rBmpEx.IsTransparent() ) + aAlpha = AlphaMask( rBmpEx.GetSizePixel(), &cTrans ); + else if( !rBmpEx.IsAlpha() ) { - AlphaMask aAlpha; - sal_uInt8 cTrans = aAttr.GetTransparency(); + aAlpha = rBmpEx.GetMask(); + aAlpha.Replace( 0, cTrans ); + } + else + { + aAlpha = rBmpEx.GetAlpha(); + BitmapWriteAccess* pA = aAlpha.AcquireWriteAccess(); - if( !rBmpEx.IsTransparent() ) - aAlpha = AlphaMask( rBmpEx.GetSizePixel(), &cTrans ); - else if( !rBmpEx.IsAlpha() ) - { - aAlpha = rBmpEx.GetMask(); - aAlpha.Replace( 0, cTrans ); - } - else + if( pA ) { - aAlpha = rBmpEx.GetAlpha(); - BitmapWriteAccess* pA = aAlpha.AcquireWriteAccess(); + sal_uLong nTrans = cTrans, nNewTrans; + const long nWidth = pA->Width(), nHeight = pA->Height(); - if( pA ) + if( pA->GetScanlineFormat() == ScanlineFormat::N8BitPal ) { - sal_uLong nTrans = cTrans, nNewTrans; - const long nWidth = pA->Width(), nHeight = pA->Height(); - - if( pA->GetScanlineFormat() == ScanlineFormat::N8BitPal ) + for( long nY = 0; nY < nHeight; nY++ ) { - for( long nY = 0; nY < nHeight; nY++ ) - { - Scanline pAScan = pA->GetScanline( nY ); + Scanline pAScan = pA->GetScanline( nY ); - for( long nX = 0; nX < nWidth; nX++ ) - { - nNewTrans = nTrans + *pAScan; - *pAScan++ = (sal_uInt8) ( ( nNewTrans & 0xffffff00 ) ? 255 : nNewTrans ); - } + for( long nX = 0; nX < nWidth; nX++ ) + { + nNewTrans = nTrans + *pAScan; + *pAScan++ = (sal_uInt8) ( ( nNewTrans & 0xffffff00 ) ? 255 : nNewTrans ); } } - else - { - BitmapColor aAlphaValue( 0 ); + } + else + { + BitmapColor aAlphaValue( 0 ); - for( long nY = 0; nY < nHeight; nY++ ) + for( long nY = 0; nY < nHeight; nY++ ) + { + for( long nX = 0; nX < nWidth; nX++ ) { - for( long nX = 0; nX < nWidth; nX++ ) - { - nNewTrans = nTrans + pA->GetPixel( nY, nX ).GetIndex(); - aAlphaValue.SetIndex( (sal_uInt8) ( ( nNewTrans & 0xffffff00 ) ? 255 : nNewTrans ) ); - pA->SetPixel( nY, nX, aAlphaValue ); - } + nNewTrans = nTrans + pA->GetPixel( nY, nX ).GetIndex(); + aAlphaValue.SetIndex( (sal_uInt8) ( ( nNewTrans & 0xffffff00 ) ? 255 : nNewTrans ) ); + pA->SetPixel( nY, nX, aAlphaValue ); } } - - aAlpha.ReleaseAccess( pA ); } - } - rBmpEx = BitmapEx( rBmpEx.GetBitmap(), aAlpha ); + aAlpha.ReleaseAccess( pA ); + } } + + rBmpEx = BitmapEx( rBmpEx.GetBitmap(), aAlpha ); } void GraphicManager::ImplAdjust( GDIMetaFile& rMtf, const GraphicAttr& rAttr, GraphicAdjustmentFlags nAdjustmentFlags ) @@ -2083,23 +2083,23 @@ void GraphicObject::ImplTransformBitmap( BitmapEx& rBmpEx, const Size aSizePixel( rBmpEx.GetSizePixel() ); - if( rAttr.GetRotation() != 0 && !IsAnimated() ) - { - if( aSizePixel.Width() && aSizePixel.Height() && rDstSize.Width() && rDstSize.Height() ) - { - double fSrcWH = (double) aSizePixel.Width() / aSizePixel.Height(); - double fDstWH = (double) rDstSize.Width() / rDstSize.Height(); - double fScaleX = 1.0, fScaleY = 1.0; + if( !(rAttr.GetRotation() != 0 && !IsAnimated()) ) + return; - // always choose scaling to shrink bitmap - if( fSrcWH < fDstWH ) - fScaleY = aSizePixel.Width() / ( fDstWH * aSizePixel.Height() ); - else - fScaleX = fDstWH * aSizePixel.Height() / aSizePixel.Width(); + if( !(aSizePixel.Width() && aSizePixel.Height() && rDstSize.Width() && rDstSize.Height()) ) + return; - rBmpEx.Scale( fScaleX, fScaleY ); - } - } + double fSrcWH = (double) aSizePixel.Width() / aSizePixel.Height(); + double fDstWH = (double) rDstSize.Width() / rDstSize.Height(); + double fScaleX = 1.0, fScaleY = 1.0; + + // always choose scaling to shrink bitmap + if( fSrcWH < fDstWH ) + fScaleY = aSizePixel.Width() / ( fDstWH * aSizePixel.Height() ); + else + fScaleX = fDstWH * aSizePixel.Height() / aSizePixel.Width(); + + rBmpEx.Scale( fScaleX, fScaleY ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/graphic/provider.cxx b/svtools/source/graphic/provider.cxx index b70fd5ef4a4e..2e60b79b7ca2 100644 --- a/svtools/source/graphic/provider.cxx +++ b/svtools/source/graphic/provider.cxx @@ -490,33 +490,33 @@ uno::Sequence< uno::Reference<graphic::XGraphic> > SAL_CALL GraphicProvider::que void ImplCalculateCropRect( ::Graphic const & rGraphic, const text::GraphicCrop& rGraphicCropLogic, tools::Rectangle& rGraphicCropPixel ) { - if ( rGraphicCropLogic.Left || rGraphicCropLogic.Top || rGraphicCropLogic.Right || rGraphicCropLogic.Bottom ) + if ( !(rGraphicCropLogic.Left || rGraphicCropLogic.Top || rGraphicCropLogic.Right || rGraphicCropLogic.Bottom) ) + return; + + Size aSourceSizePixel( rGraphic.GetSizePixel() ); + if ( !(aSourceSizePixel.Width() && aSourceSizePixel.Height()) ) + return; + + if ( !(rGraphicCropLogic.Left || rGraphicCropLogic.Top || rGraphicCropLogic.Right || rGraphicCropLogic.Bottom) ) + return; + + Size aSize100thMM( 0, 0 ); + if( rGraphic.GetPrefMapMode().GetMapUnit() != MapUnit::MapPixel ) { - Size aSourceSizePixel( rGraphic.GetSizePixel() ); - if ( aSourceSizePixel.Width() && aSourceSizePixel.Height() ) - { - if ( rGraphicCropLogic.Left || rGraphicCropLogic.Top || rGraphicCropLogic.Right || rGraphicCropLogic.Bottom ) - { - Size aSize100thMM( 0, 0 ); - if( rGraphic.GetPrefMapMode().GetMapUnit() != MapUnit::MapPixel ) - { - aSize100thMM = OutputDevice::LogicToLogic(rGraphic.GetPrefSize(), rGraphic.GetPrefMapMode(), MapMode(MapUnit::Map100thMM)); - } - else - { - aSize100thMM = Application::GetDefaultDevice()->PixelToLogic(rGraphic.GetPrefSize(), MapMode(MapUnit::Map100thMM)); - } - if ( aSize100thMM.Width() && aSize100thMM.Height() ) - { - double fSourceSizePixelWidth = static_cast<double>(aSourceSizePixel.Width()); - double fSourceSizePixelHeight= static_cast<double>(aSourceSizePixel.Height()); - rGraphicCropPixel.Left() = static_cast< sal_Int32 >((fSourceSizePixelWidth * rGraphicCropLogic.Left ) / aSize100thMM.Width()); - rGraphicCropPixel.Top() = static_cast< sal_Int32 >((fSourceSizePixelHeight * rGraphicCropLogic.Top ) / aSize100thMM.Height()); - rGraphicCropPixel.Right() = static_cast< sal_Int32 >(( fSourceSizePixelWidth * ( aSize100thMM.Width() - rGraphicCropLogic.Right ) ) / aSize100thMM.Width() ); - rGraphicCropPixel.Bottom() = static_cast< sal_Int32 >(( fSourceSizePixelHeight * ( aSize100thMM.Height() - rGraphicCropLogic.Bottom ) ) / aSize100thMM.Height() ); - } - } - } + aSize100thMM = OutputDevice::LogicToLogic(rGraphic.GetPrefSize(), rGraphic.GetPrefMapMode(), MapMode(MapUnit::Map100thMM)); + } + else + { + aSize100thMM = Application::GetDefaultDevice()->PixelToLogic(rGraphic.GetPrefSize(), MapMode(MapUnit::Map100thMM)); + } + if ( aSize100thMM.Width() && aSize100thMM.Height() ) + { + double fSourceSizePixelWidth = static_cast<double>(aSourceSizePixel.Width()); + double fSourceSizePixelHeight= static_cast<double>(aSourceSizePixel.Height()); + rGraphicCropPixel.Left() = static_cast< sal_Int32 >((fSourceSizePixelWidth * rGraphicCropLogic.Left ) / aSize100thMM.Width()); + rGraphicCropPixel.Top() = static_cast< sal_Int32 >((fSourceSizePixelHeight * rGraphicCropLogic.Top ) / aSize100thMM.Height()); + rGraphicCropPixel.Right() = static_cast< sal_Int32 >(( fSourceSizePixelWidth * ( aSize100thMM.Width() - rGraphicCropLogic.Right ) ) / aSize100thMM.Width() ); + rGraphicCropPixel.Bottom() = static_cast< sal_Int32 >(( fSourceSizePixelHeight * ( aSize100thMM.Height() - rGraphicCropLogic.Bottom ) ) / aSize100thMM.Height() ); } } @@ -536,35 +536,35 @@ void ImplApplyBitmapScaling( ::Graphic& rGraphic, sal_Int32 nPixelWidth, sal_Int void ImplApplyBitmapResolution( ::Graphic& rGraphic, sal_Int32 nImageResolution, const Size& rVisiblePixelSize, const awt::Size& rLogicalSize ) { - if ( nImageResolution && rLogicalSize.Width && rLogicalSize.Height ) + if ( !(nImageResolution && rLogicalSize.Width && rLogicalSize.Height) ) + return; + + const double fImageResolution = static_cast<double>( nImageResolution ); + const double fSourceDPIX = ( static_cast<double>(rVisiblePixelSize.Width()) * 2540.0 ) / static_cast<double>(rLogicalSize.Width); + const double fSourceDPIY = ( static_cast<double>(rVisiblePixelSize.Height()) * 2540.0 ) / static_cast<double>(rLogicalSize.Height); + const sal_Int32 nSourcePixelWidth( rGraphic.GetSizePixel().Width() ); + const sal_Int32 nSourcePixelHeight( rGraphic.GetSizePixel().Height() ); + const double fSourcePixelWidth = static_cast<double>( nSourcePixelWidth ); + const double fSourcePixelHeight= static_cast<double>( nSourcePixelHeight ); + + sal_Int32 nDestPixelWidth = nSourcePixelWidth; + sal_Int32 nDestPixelHeight = nSourcePixelHeight; + + // check, if the bitmap DPI exceeds the maximum DPI + if( fSourceDPIX > fImageResolution ) { - const double fImageResolution = static_cast<double>( nImageResolution ); - const double fSourceDPIX = ( static_cast<double>(rVisiblePixelSize.Width()) * 2540.0 ) / static_cast<double>(rLogicalSize.Width); - const double fSourceDPIY = ( static_cast<double>(rVisiblePixelSize.Height()) * 2540.0 ) / static_cast<double>(rLogicalSize.Height); - const sal_Int32 nSourcePixelWidth( rGraphic.GetSizePixel().Width() ); - const sal_Int32 nSourcePixelHeight( rGraphic.GetSizePixel().Height() ); - const double fSourcePixelWidth = static_cast<double>( nSourcePixelWidth ); - const double fSourcePixelHeight= static_cast<double>( nSourcePixelHeight ); - - sal_Int32 nDestPixelWidth = nSourcePixelWidth; - sal_Int32 nDestPixelHeight = nSourcePixelHeight; - - // check, if the bitmap DPI exceeds the maximum DPI - if( fSourceDPIX > fImageResolution ) - { - nDestPixelWidth = static_cast<sal_Int32>(( fSourcePixelWidth * fImageResolution ) / fSourceDPIX); - if ( !nDestPixelWidth || ( nDestPixelWidth > nSourcePixelWidth ) ) - nDestPixelWidth = nSourcePixelWidth; - } - if ( fSourceDPIY > fImageResolution ) - { - nDestPixelHeight= static_cast<sal_Int32>(( fSourcePixelHeight* fImageResolution ) / fSourceDPIY); - if ( !nDestPixelHeight || ( nDestPixelHeight > nSourcePixelHeight ) ) - nDestPixelHeight = nSourcePixelHeight; - } - if ( ( nDestPixelWidth != nSourcePixelWidth ) || ( nDestPixelHeight != nSourcePixelHeight ) ) - ImplApplyBitmapScaling( rGraphic, nDestPixelWidth, nDestPixelHeight ); + nDestPixelWidth = static_cast<sal_Int32>(( fSourcePixelWidth * fImageResolution ) / fSourceDPIX); + if ( !nDestPixelWidth || ( nDestPixelWidth > nSourcePixelWidth ) ) + nDestPixelWidth = nSourcePixelWidth; + } + if ( fSourceDPIY > fImageResolution ) + { + nDestPixelHeight= static_cast<sal_Int32>(( fSourcePixelHeight* fImageResolution ) / fSourceDPIY); + if ( !nDestPixelHeight || ( nDestPixelHeight > nSourcePixelHeight ) ) + nDestPixelHeight = nSourcePixelHeight; } + if ( ( nDestPixelWidth != nSourcePixelWidth ) || ( nDestPixelHeight != nSourcePixelHeight ) ) + ImplApplyBitmapScaling( rGraphic, nDestPixelWidth, nDestPixelHeight ); } void ImplApplyFilterData( ::Graphic& rGraphic, uno::Sequence< beans::PropertyValue >& rFilterData ) @@ -741,94 +741,94 @@ void SAL_CALL GraphicProvider::storeGraphic( const uno::Reference< ::graphic::XG } } - if( pOStm ) + if( !pOStm ) + return; + + uno::Sequence< beans::PropertyValue > aFilterDataSeq; + const char* pFilterShortName = nullptr; + + for( i = 0; i < rMediaProperties.getLength(); ++i ) { - uno::Sequence< beans::PropertyValue > aFilterDataSeq; - const char* pFilterShortName = nullptr; + const OUString aName( rMediaProperties[ i ].Name ); + const uno::Any aValue( rMediaProperties[ i ].Value ); - for( i = 0; i < rMediaProperties.getLength(); ++i ) + if (aName == "FilterData") { - const OUString aName( rMediaProperties[ i ].Name ); - const uno::Any aValue( rMediaProperties[ i ].Value ); - - if (aName == "FilterData") - { - aValue >>= aFilterDataSeq; - } - else if (aName == "MimeType") - { - OUString aMimeType; - - aValue >>= aMimeType; - - if (aMimeType == MIMETYPE_BMP) - pFilterShortName = "bmp"; - else if (aMimeType == MIMETYPE_EPS) - pFilterShortName = "eps"; - else if (aMimeType == MIMETYPE_GIF) - pFilterShortName = "gif"; - else if (aMimeType == MIMETYPE_JPG) - pFilterShortName = "jpg"; - else if (aMimeType == MIMETYPE_MET) - pFilterShortName = "met"; - else if (aMimeType == MIMETYPE_PNG) - pFilterShortName = "png"; - else if (aMimeType == MIMETYPE_PCT) - pFilterShortName = "pct"; - else if (aMimeType == MIMETYPE_PBM) - pFilterShortName = "pbm"; - else if (aMimeType == MIMETYPE_PGM) - pFilterShortName = "pgm"; - else if (aMimeType == MIMETYPE_PPM) - pFilterShortName = "ppm"; - else if (aMimeType == MIMETYPE_RAS) - pFilterShortName = "ras"; - else if (aMimeType == MIMETYPE_SVM) - pFilterShortName = "svm"; - else if (aMimeType == MIMETYPE_TIF) - pFilterShortName = "tif"; - else if (aMimeType == MIMETYPE_EMF) - pFilterShortName = "emf"; - else if (aMimeType == MIMETYPE_WMF) - pFilterShortName = "wmf"; - else if (aMimeType == MIMETYPE_XPM) - pFilterShortName = "xpm"; - else if (aMimeType == MIMETYPE_SVG) - pFilterShortName = "svg"; - else if (aMimeType == MIMETYPE_VCLGRAPHIC) - pFilterShortName = MIMETYPE_VCLGRAPHIC; - } + aValue >>= aFilterDataSeq; } - - if( pFilterShortName ) + else if (aName == "MimeType") { - ::GraphicFilter& rFilter = ::GraphicFilter::GetGraphicFilter(); + OUString aMimeType; + + aValue >>= aMimeType; + + if (aMimeType == MIMETYPE_BMP) + pFilterShortName = "bmp"; + else if (aMimeType == MIMETYPE_EPS) + pFilterShortName = "eps"; + else if (aMimeType == MIMETYPE_GIF) + pFilterShortName = "gif"; + else if (aMimeType == MIMETYPE_JPG) + pFilterShortName = "jpg"; + else if (aMimeType == MIMETYPE_MET) + pFilterShortName = "met"; + else if (aMimeType == MIMETYPE_PNG) + pFilterShortName = "png"; + else if (aMimeType == MIMETYPE_PCT) + pFilterShortName = "pct"; + else if (aMimeType == MIMETYPE_PBM) + pFilterShortName = "pbm"; + else if (aMimeType == MIMETYPE_PGM) + pFilterShortName = "pgm"; + else if (aMimeType == MIMETYPE_PPM) + pFilterShortName = "ppm"; + else if (aMimeType == MIMETYPE_RAS) + pFilterShortName = "ras"; + else if (aMimeType == MIMETYPE_SVM) + pFilterShortName = "svm"; + else if (aMimeType == MIMETYPE_TIF) + pFilterShortName = "tif"; + else if (aMimeType == MIMETYPE_EMF) + pFilterShortName = "emf"; + else if (aMimeType == MIMETYPE_WMF) + pFilterShortName = "wmf"; + else if (aMimeType == MIMETYPE_XPM) + pFilterShortName = "xpm"; + else if (aMimeType == MIMETYPE_SVG) + pFilterShortName = "svg"; + else if (aMimeType == MIMETYPE_VCLGRAPHIC) + pFilterShortName = MIMETYPE_VCLGRAPHIC; + } + } - { - const uno::Reference< XInterface > xIFace( rxGraphic, uno::UNO_QUERY ); - const ::Graphic* pGraphic = ::unographic::Graphic::getImplementation( xIFace ); + if( !pFilterShortName ) + return; - if( pGraphic && ( pGraphic->GetType() != GraphicType::NONE ) ) - { - ::Graphic aGraphic( *pGraphic ); - ImplApplyFilterData( aGraphic, aFilterDataSeq ); - - /* sj: using a temporary memory stream, because some graphic filters are seeking behind - stream end (which leads to an invalid argument exception then). */ - SvMemoryStream aMemStrm; - aMemStrm.SetVersion( SOFFICE_FILEFORMAT_CURRENT ); - if( 0 == strcmp( pFilterShortName, MIMETYPE_VCLGRAPHIC ) ) - WriteGraphic( aMemStrm, aGraphic ); - else - { - rFilter.ExportGraphic( aGraphic, aPath, aMemStrm, - rFilter.GetExportFormatNumberForShortName( OUString::createFromAscii( pFilterShortName ) ), - ( aFilterDataSeq.getLength() ? &aFilterDataSeq : nullptr ) ); - } - aMemStrm.Seek( STREAM_SEEK_TO_END ); - pOStm->WriteBytes( aMemStrm.GetData(), aMemStrm.Tell() ); - } + ::GraphicFilter& rFilter = ::GraphicFilter::GetGraphicFilter(); + + { + const uno::Reference< XInterface > xIFace( rxGraphic, uno::UNO_QUERY ); + const ::Graphic* pGraphic = ::unographic::Graphic::getImplementation( xIFace ); + + if( pGraphic && ( pGraphic->GetType() != GraphicType::NONE ) ) + { + ::Graphic aGraphic( *pGraphic ); + ImplApplyFilterData( aGraphic, aFilterDataSeq ); + + /* sj: using a temporary memory stream, because some graphic filters are seeking behind + stream end (which leads to an invalid argument exception then). */ + SvMemoryStream aMemStrm; + aMemStrm.SetVersion( SOFFICE_FILEFORMAT_CURRENT ); + if( 0 == strcmp( pFilterShortName, MIMETYPE_VCLGRAPHIC ) ) + WriteGraphic( aMemStrm, aGraphic ); + else + { + rFilter.ExportGraphic( aGraphic, aPath, aMemStrm, + rFilter.GetExportFormatNumberForShortName( OUString::createFromAscii( pFilterShortName ) ), + ( aFilterDataSeq.getLength() ? &aFilterDataSeq : nullptr ) ); } + aMemStrm.Seek( STREAM_SEEK_TO_END ); + pOStm->WriteBytes( aMemStrm.GetData(), aMemStrm.Tell() ); } } } diff --git a/svtools/source/hatchwindow/documentcloser.cxx b/svtools/source/hatchwindow/documentcloser.cxx index f911712b1cd5..cbe95f7bcdc6 100644 --- a/svtools/source/hatchwindow/documentcloser.cxx +++ b/svtools/source/hatchwindow/documentcloser.cxx @@ -101,45 +101,45 @@ void MainThreadFrameCloserRequest::Start( MainThreadFrameCloserRequest* pMTReque IMPL_STATIC_LINK( MainThreadFrameCloserRequest, worker, void*, p, void ) { MainThreadFrameCloserRequest* pMTRequest = static_cast<MainThreadFrameCloserRequest*>(p); - if ( pMTRequest ) + if ( !pMTRequest ) + return; + + if ( pMTRequest->m_xFrame.is() ) { - if ( pMTRequest->m_xFrame.is() ) + // this is the main thread, the solar mutex must be locked + SolarMutexGuard aGuard; + + try { - // this is the main thread, the solar mutex must be locked - SolarMutexGuard aGuard; - - try - { - uno::Reference< awt::XWindow > xWindow = pMTRequest->m_xFrame->getContainerWindow(); - uno::Reference< awt::XVclWindowPeer > xWinPeer( xWindow, uno::UNO_QUERY_THROW ); - - xWindow->setVisible( false ); - - // reparent the window - xWinPeer->setProperty( "PluginParent", uno::makeAny( (sal_Int64) 0 ) ); - - VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow ); - if ( pWindow ) - Dialog::EndAllDialogs( pWindow ); - } - catch( uno::Exception& ) - { - // ignore all the errors - } - - try - { - uno::Reference< util::XCloseable > xCloseable( pMTRequest->m_xFrame, uno::UNO_QUERY_THROW ); - xCloseable->close( true ); - } - catch( uno::Exception& ) - { - // ignore all the errors - } + uno::Reference< awt::XWindow > xWindow = pMTRequest->m_xFrame->getContainerWindow(); + uno::Reference< awt::XVclWindowPeer > xWinPeer( xWindow, uno::UNO_QUERY_THROW ); + + xWindow->setVisible( false ); + + // reparent the window + xWinPeer->setProperty( "PluginParent", uno::makeAny( (sal_Int64) 0 ) ); + + VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow ); + if ( pWindow ) + Dialog::EndAllDialogs( pWindow ); + } + catch( uno::Exception& ) + { + // ignore all the errors } - delete pMTRequest; + try + { + uno::Reference< util::XCloseable > xCloseable( pMTRequest->m_xFrame, uno::UNO_QUERY_THROW ); + xCloseable->close( true ); + } + catch( uno::Exception& ) + { + // ignore all the errors + } } + + delete pMTRequest; } ODocumentCloser::ODocumentCloser(const css::uno::Sequence< css::uno::Any >& aArguments) diff --git a/svtools/source/hatchwindow/hatchwindow.cxx b/svtools/source/hatchwindow/hatchwindow.cxx index 4c0a9819ede6..0e8b4b964182 100644 --- a/svtools/source/hatchwindow/hatchwindow.cxx +++ b/svtools/source/hatchwindow/hatchwindow.cxx @@ -69,18 +69,18 @@ void VCLXHatchWindow::initializeWindow( const uno::Reference< awt::XWindowPeer > void VCLXHatchWindow::QueryObjAreaPixel( tools::Rectangle & aRect ) { - if ( m_xController.is() ) - { - awt::Rectangle aUnoRequestRect = AWTRectangle( aRect ); + if ( !m_xController.is() ) + return; - try { - awt::Rectangle aUnoResultRect = m_xController->calcAdjustedRectangle( aUnoRequestRect ); - aRect = VCLRectangle( aUnoResultRect ); - } - catch( uno::Exception& ) - { - OSL_FAIL( "Can't adjust rectangle size!" ); - } + awt::Rectangle aUnoRequestRect = AWTRectangle( aRect ); + + try { + awt::Rectangle aUnoResultRect = m_xController->calcAdjustedRectangle( aUnoRequestRect ); + aRect = VCLRectangle( aUnoResultRect ); + } + catch( uno::Exception& ) + { + OSL_FAIL( "Can't adjust rectangle size!" ); } } diff --git a/svtools/source/hatchwindow/ipwin.cxx b/svtools/source/hatchwindow/ipwin.cxx index af5d75cfaba5..071e47c7f4c0 100644 --- a/svtools/source/hatchwindow/ipwin.cxx +++ b/svtools/source/hatchwindow/ipwin.cxx @@ -463,31 +463,32 @@ void SvResizeWindow::SelectMouse( const Point & rPos ) short nGrab = m_aResizer.SelectMove( this, rPos ); if( nGrab >= 4 ) nGrab -= 4; - if( m_nMoveGrab != nGrab ) - { // Pointer did change - if( -1 == nGrab ) - SetPointer( m_aOldPointer ); - else + if( m_nMoveGrab == nGrab ) + return; + + // Pointer did change + if( -1 == nGrab ) + SetPointer( m_aOldPointer ); + else + { + PointerStyle aStyle = PointerStyle::Move; + if( nGrab == 3 ) + aStyle = PointerStyle::ESize; + else if( nGrab == 2 ) + aStyle = PointerStyle::NESize; + else if( nGrab == 1 ) + aStyle = PointerStyle::SSize; + else if( nGrab == 0 ) + aStyle = PointerStyle::SESize; + if( m_nMoveGrab == -1 ) // the first time { - PointerStyle aStyle = PointerStyle::Move; - if( nGrab == 3 ) - aStyle = PointerStyle::ESize; - else if( nGrab == 2 ) - aStyle = PointerStyle::NESize; - else if( nGrab == 1 ) - aStyle = PointerStyle::SSize; - else if( nGrab == 0 ) - aStyle = PointerStyle::SESize; - if( m_nMoveGrab == -1 ) // the first time - { - m_aOldPointer = GetPointer(); - SetPointer( Pointer( aStyle ) ); - } - else - SetPointer( Pointer( aStyle ) ); + m_aOldPointer = GetPointer(); + SetPointer( Pointer( aStyle ) ); } - m_nMoveGrab = nGrab; + else + SetPointer( Pointer( aStyle ) ); } + m_nMoveGrab = nGrab; } /************************************************************************* @@ -532,23 +533,23 @@ void SvResizeWindow::MouseMove( const MouseEvent & rEvt ) *************************************************************************/ void SvResizeWindow::MouseButtonUp( const MouseEvent & rEvt ) { - if( m_aResizer.GetGrab() != -1 ) - { - tools::Rectangle aRect( m_aResizer.GetTrackRectPixel( rEvt.GetPosPixel() ) ); - Point aDiff = GetPosPixel(); - aRect.SetPos( aRect.TopLeft() + aDiff ); - // aRect -= GetAllBorderPixel(); - m_aResizer.ValidateRect( aRect ); + if( m_aResizer.GetGrab() == -1 ) + return; - m_pWrapper->QueryObjAreaPixel( aRect ); + tools::Rectangle aRect( m_aResizer.GetTrackRectPixel( rEvt.GetPosPixel() ) ); + Point aDiff = GetPosPixel(); + aRect.SetPos( aRect.TopLeft() + aDiff ); + // aRect -= GetAllBorderPixel(); + m_aResizer.ValidateRect( aRect ); - tools::Rectangle aOutRect; - if( m_aResizer.SelectRelease( this, rEvt.GetPosPixel(), aOutRect ) ) - { - m_nMoveGrab = -1; - SetPointer( m_aOldPointer ); - m_pWrapper->RequestObjAreaPixel( aRect ); - } + m_pWrapper->QueryObjAreaPixel( aRect ); + + tools::Rectangle aOutRect; + if( m_aResizer.SelectRelease( this, rEvt.GetPosPixel(), aOutRect ) ) + { + m_nMoveGrab = -1; + SetPointer( m_aOldPointer ); + m_pWrapper->RequestObjAreaPixel( aRect ); } } diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx index 5355ce320b3a..45beb0d17853 100644 --- a/svtools/source/misc/embedhlp.cxx +++ b/svtools/source/misc/embedhlp.cxx @@ -159,23 +159,23 @@ void SAL_CALL EmbedEventListener_Impl::stateChanged( const lang::EventObject&, void SAL_CALL EmbedEventListener_Impl::modified( const lang::EventObject& ) { SolarMutexGuard aGuard; - if ( pObject && pObject->GetViewAspect() != embed::Aspects::MSOLE_ICON ) + if ( !(pObject && pObject->GetViewAspect() != embed::Aspects::MSOLE_ICON) ) + return; + + if ( nState == embed::EmbedStates::RUNNING ) { - if ( nState == embed::EmbedStates::RUNNING ) - { - // updates only necessary in non-active states - if( pObject->IsChart() ) - pObject->UpdateReplacementOnDemand(); - else - pObject->UpdateReplacement(); - } - else if ( nState == embed::EmbedStates::ACTIVE || - nState == embed::EmbedStates::UI_ACTIVE || - nState == embed::EmbedStates::INPLACE_ACTIVE ) - { - // in case the object is inplace or UI active the replacement image should be updated on demand + // updates only necessary in non-active states + if( pObject->IsChart() ) pObject->UpdateReplacementOnDemand(); - } + else + pObject->UpdateReplacement(); + } + else if ( nState == embed::EmbedStates::ACTIVE || + nState == embed::EmbedStates::UI_ACTIVE || + nState == embed::EmbedStates::INPLACE_ACTIVE ) + { + // in case the object is inplace or UI active the replacement image should be updated on demand + pObject->UpdateReplacementOnDemand(); } } diff --git a/svtools/source/misc/imap.cxx b/svtools/source/misc/imap.cxx index 4e7e2b4ab0ed..471399fd40bc 100644 --- a/svtools/source/misc/imap.cxx +++ b/svtools/source/misc/imap.cxx @@ -494,19 +494,19 @@ void IMapPolygonObject::Scale( const Fraction& rFracX, const Fraction& rFracY ) aPoly[ i ] = aScaledPt; } - if ( bEllipse ) - { - Point aTL( aEllipse.TopLeft() ); - Point aBR( aEllipse.BottomRight() ); + if ( !bEllipse ) + return; - if ( rFracX.GetDenominator() && rFracY.GetDenominator() ) - { - SCALEPOINT( aTL, rFracX, rFracY ); - SCALEPOINT( aBR, rFracX, rFracY ); - } + Point aTL( aEllipse.TopLeft() ); + Point aBR( aEllipse.BottomRight() ); - aEllipse = tools::Rectangle( aTL, aBR ); + if ( rFracX.GetDenominator() && rFracY.GetDenominator() ) + { + SCALEPOINT( aTL, rFracX, rFracY ); + SCALEPOINT( aBR, rFracX, rFracY ); } + + aEllipse = tools::Rectangle( aTL, aBR ); } bool IMapPolygonObject::IsEqual( const IMapPolygonObject& rEqObj ) diff --git a/svtools/source/misc/imap2.cxx b/svtools/source/misc/imap2.cxx index 648d4758eb87..a0b86edef094 100644 --- a/svtools/source/misc/imap2.cxx +++ b/svtools/source/misc/imap2.cxx @@ -263,41 +263,41 @@ void ImageMap::ImpReadCERNLine( const OString& rLine ) } OString aToken = aBuf.makeStringAndClear(); - if ( NOTEOL( cChar ) ) + if ( !(NOTEOL( cChar )) ) + return; + + if ( ( aToken == "rectangle" ) || ( aToken == "rect" ) ) { - if ( ( aToken == "rectangle" ) || ( aToken == "rect" ) ) - { - const Point aTopLeft( ImpReadCERNCoords( &pStr ) ); - const Point aBottomRight( ImpReadCERNCoords( &pStr ) ); - const OUString aURL( ImpReadCERNURL( &pStr, "" ) ); - const tools::Rectangle aRect( aTopLeft, aBottomRight ); + const Point aTopLeft( ImpReadCERNCoords( &pStr ) ); + const Point aBottomRight( ImpReadCERNCoords( &pStr ) ); + const OUString aURL( ImpReadCERNURL( &pStr, "" ) ); + const tools::Rectangle aRect( aTopLeft, aBottomRight ); - IMapRectangleObject* pObj = new IMapRectangleObject( aRect, aURL, OUString(), OUString(), OUString(), OUString() ); - maList.push_back( pObj ); - } - else if ( ( aToken == "circle" ) || ( aToken == "circ" ) ) - { - const Point aCenter( ImpReadCERNCoords( &pStr ) ); - const long nRadius = ImpReadCERNRadius( &pStr ); - const OUString aURL( ImpReadCERNURL( &pStr, "" ) ); + IMapRectangleObject* pObj = new IMapRectangleObject( aRect, aURL, OUString(), OUString(), OUString(), OUString() ); + maList.push_back( pObj ); + } + else if ( ( aToken == "circle" ) || ( aToken == "circ" ) ) + { + const Point aCenter( ImpReadCERNCoords( &pStr ) ); + const long nRadius = ImpReadCERNRadius( &pStr ); + const OUString aURL( ImpReadCERNURL( &pStr, "" ) ); - IMapCircleObject* pObj = new IMapCircleObject( aCenter, nRadius, aURL, OUString(), OUString(), OUString(), OUString() ); - maList.push_back( pObj ); - } - else if ( ( aToken == "polygon" ) || ( aToken == "poly" ) ) - { - const sal_uInt16 nCount = comphelper::string::getTokenCount(aStr, '(') - 1; - tools::Polygon aPoly( nCount ); - OUString aURL; + IMapCircleObject* pObj = new IMapCircleObject( aCenter, nRadius, aURL, OUString(), OUString(), OUString(), OUString() ); + maList.push_back( pObj ); + } + else if ( ( aToken == "polygon" ) || ( aToken == "poly" ) ) + { + const sal_uInt16 nCount = comphelper::string::getTokenCount(aStr, '(') - 1; + tools::Polygon aPoly( nCount ); + OUString aURL; - for ( sal_uInt16 i = 0; i < nCount; i++ ) - aPoly[ i ] = ImpReadCERNCoords( &pStr ); + for ( sal_uInt16 i = 0; i < nCount; i++ ) + aPoly[ i ] = ImpReadCERNCoords( &pStr ); - aURL = ImpReadCERNURL( &pStr, "" ); + aURL = ImpReadCERNURL( &pStr, "" ); - IMapPolygonObject* pObj = new IMapPolygonObject( aPoly, aURL, OUString(), OUString(), OUString(), OUString() ); - maList.push_back( pObj ); - } + IMapPolygonObject* pObj = new IMapPolygonObject( aPoly, aURL, OUString(), OUString(), OUString(), OUString() ); + maList.push_back( pObj ); } } @@ -404,42 +404,42 @@ void ImageMap::ImpReadNCSALine( const OString& rLine ) } OString aToken = aBuf.makeStringAndClear(); - if ( NOTEOL( cChar ) ) + if ( !(NOTEOL( cChar )) ) + return; + + if ( aToken == "rect" ) { - if ( aToken == "rect" ) - { - const OUString aURL( ImpReadNCSAURL( &pStr, "" ) ); - const Point aTopLeft( ImpReadNCSACoords( &pStr ) ); - const Point aBottomRight( ImpReadNCSACoords( &pStr ) ); - const tools::Rectangle aRect( aTopLeft, aBottomRight ); + const OUString aURL( ImpReadNCSAURL( &pStr, "" ) ); + const Point aTopLeft( ImpReadNCSACoords( &pStr ) ); + const Point aBottomRight( ImpReadNCSACoords( &pStr ) ); + const tools::Rectangle aRect( aTopLeft, aBottomRight ); - IMapRectangleObject* pObj = new IMapRectangleObject( aRect, aURL, OUString(), OUString(), OUString(), OUString() ); - maList.push_back( pObj ); - } - else if ( aToken == "circle" ) - { - const OUString aURL( ImpReadNCSAURL( &pStr, "" ) ); - const Point aCenter( ImpReadNCSACoords( &pStr ) ); - const Point aDX( aCenter - ImpReadNCSACoords( &pStr ) ); - long nRadius = (long) sqrt( (double) aDX.X() * aDX.X() + - (double) aDX.Y() * aDX.Y() ); - - IMapCircleObject* pObj = new IMapCircleObject( aCenter, nRadius, aURL, OUString(), OUString(), OUString(), OUString() ); - maList.push_back( pObj ); - } - else if ( aToken == "poly" ) - { - const sal_uInt16 nCount = comphelper::string::getTokenCount(aStr, - ',') - 1; - const OUString aURL( ImpReadNCSAURL( &pStr, "" ) ); - tools::Polygon aPoly( nCount ); + IMapRectangleObject* pObj = new IMapRectangleObject( aRect, aURL, OUString(), OUString(), OUString(), OUString() ); + maList.push_back( pObj ); + } + else if ( aToken == "circle" ) + { + const OUString aURL( ImpReadNCSAURL( &pStr, "" ) ); + const Point aCenter( ImpReadNCSACoords( &pStr ) ); + const Point aDX( aCenter - ImpReadNCSACoords( &pStr ) ); + long nRadius = (long) sqrt( (double) aDX.X() * aDX.X() + + (double) aDX.Y() * aDX.Y() ); + + IMapCircleObject* pObj = new IMapCircleObject( aCenter, nRadius, aURL, OUString(), OUString(), OUString(), OUString() ); + maList.push_back( pObj ); + } + else if ( aToken == "poly" ) + { + const sal_uInt16 nCount = comphelper::string::getTokenCount(aStr, + ',') - 1; + const OUString aURL( ImpReadNCSAURL( &pStr, "" ) ); + tools::Polygon aPoly( nCount ); - for ( sal_uInt16 i = 0; i < nCount; i++ ) - aPoly[ i ] = ImpReadNCSACoords( &pStr ); + for ( sal_uInt16 i = 0; i < nCount; i++ ) + aPoly[ i ] = ImpReadNCSACoords( &pStr ); - IMapPolygonObject* pObj = new IMapPolygonObject( aPoly, aURL, OUString(), OUString(), OUString(), OUString() ); - maList.push_back( pObj ); - } + IMapPolygonObject* pObj = new IMapPolygonObject( aPoly, aURL, OUString(), OUString(), OUString(), OUString() ); + maList.push_back( pObj ); } } diff --git a/svtools/source/misc/imap3.cxx b/svtools/source/misc/imap3.cxx index cef90050650d..eed27dd2a729 100644 --- a/svtools/source/misc/imap3.cxx +++ b/svtools/source/misc/imap3.cxx @@ -36,21 +36,21 @@ IMapCompat::IMapCompat( SvStream& rStm, const StreamMode nStreamMode ) { DBG_ASSERT( nStreamMode == StreamMode::READ || nStreamMode == StreamMode::WRITE, "Wrong Mode!" ); - if ( !pRWStm->GetError() ) + if ( pRWStm->GetError() ) + return; + + if ( nStmMode == StreamMode::WRITE ) + { + nCompatPos = pRWStm->Tell(); + pRWStm->SeekRel( 4 ); + nTotalSize = nCompatPos + 4; + } + else { - if ( nStmMode == StreamMode::WRITE ) - { - nCompatPos = pRWStm->Tell(); - pRWStm->SeekRel( 4 ); - nTotalSize = nCompatPos + 4; - } - else - { - sal_uInt32 nTotalSizeTmp; - pRWStm->ReadUInt32( nTotalSizeTmp ); - nTotalSize = nTotalSizeTmp; - nCompatPos = pRWStm->Tell(); - } + sal_uInt32 nTotalSizeTmp; + pRWStm->ReadUInt32( nTotalSizeTmp ); + nTotalSize = nTotalSizeTmp; + nCompatPos = pRWStm->Tell(); } } @@ -63,23 +63,23 @@ IMapCompat::IMapCompat( SvStream& rStm, const StreamMode nStreamMode ) IMapCompat::~IMapCompat() { - if ( !pRWStm->GetError() ) + if ( pRWStm->GetError() ) + return; + + if ( nStmMode == StreamMode::WRITE ) { - if ( nStmMode == StreamMode::WRITE ) - { - const sal_uInt64 nEndPos = pRWStm->Tell(); + const sal_uInt64 nEndPos = pRWStm->Tell(); - pRWStm->Seek( nCompatPos ); - pRWStm->WriteUInt32( nEndPos - nTotalSize ); - pRWStm->Seek( nEndPos ); - } - else - { - const sal_uInt64 nReadSize = pRWStm->Tell() - nCompatPos; + pRWStm->Seek( nCompatPos ); + pRWStm->WriteUInt32( nEndPos - nTotalSize ); + pRWStm->Seek( nEndPos ); + } + else + { + const sal_uInt64 nReadSize = pRWStm->Tell() - nCompatPos; - if ( nTotalSize > nReadSize ) - pRWStm->SeekRel( nTotalSize - nReadSize ); - } + if ( nTotalSize > nReadSize ) + pRWStm->SeekRel( nTotalSize - nReadSize ); } } diff --git a/svtools/source/misc/templatefoldercache.cxx b/svtools/source/misc/templatefoldercache.cxx index f83e11dcdf0a..01b7ddc6b024 100644 --- a/svtools/source/misc/templatefoldercache.cxx +++ b/svtools/source/misc/templatefoldercache.cxx @@ -477,27 +477,27 @@ namespace svt if ( !m_bValidCurrentState ) readCurrentState( ); - if ( m_bValidCurrentState && openCacheStream( false ) ) - { - m_pCacheStream->WriteInt32( getMagicNumber() ); + if ( !(m_bValidCurrentState && openCacheStream( false )) ) + return; - // store the template root folders - // the size - m_pCacheStream->WriteInt32( m_aCurrentState.size() ); - // the complete URLs - ::std::for_each( - m_aCurrentState.begin(), - m_aCurrentState.end(), - StoreContentURL( *m_pCacheStream, getOfficeInstDirs() ) - ); + m_pCacheStream->WriteInt32( getMagicNumber() ); - // the contents - ::std::for_each( - m_aCurrentState.begin(), - m_aCurrentState.end(), - StoreFolderContent( *m_pCacheStream, getOfficeInstDirs() ) - ); - } + // store the template root folders + // the size + m_pCacheStream->WriteInt32( m_aCurrentState.size() ); + // the complete URLs + ::std::for_each( + m_aCurrentState.begin(), + m_aCurrentState.end(), + StoreContentURL( *m_pCacheStream, getOfficeInstDirs() ) + ); + + // the contents + ::std::for_each( + m_aCurrentState.begin(), + m_aCurrentState.end(), + StoreFolderContent( *m_pCacheStream, getOfficeInstDirs() ) + ); } diff --git a/svtools/source/misc/transfer.cxx b/svtools/source/misc/transfer.cxx index 899263af6e7a..7db9601c8aa7 100644 --- a/svtools/source/misc/transfer.cxx +++ b/svtools/source/misc/transfer.cxx @@ -511,20 +511,20 @@ sal_Int64 SAL_CALL TransferableHelper::getSomething( const Sequence< sal_Int8 >& void TransferableHelper::ImplFlush() { - if( mxClipboard.is() ) - { - Reference< XFlushableClipboard > xFlushableClipboard( mxClipboard, UNO_QUERY ); - SolarMutexReleaser aReleaser; + if( !mxClipboard.is() ) + return; - try - { - if( xFlushableClipboard.is() ) - xFlushableClipboard->flushClipboard(); - } - catch( const css::uno::Exception& ) - { - OSL_FAIL( "Could not flush clipboard" ); - } + Reference< XFlushableClipboard > xFlushableClipboard( mxClipboard, UNO_QUERY ); + SolarMutexReleaser aReleaser; + + try + { + if( xFlushableClipboard.is() ) + xFlushableClipboard->flushClipboard(); + } + catch( const css::uno::Exception& ) + { + OSL_FAIL( "Could not flush clipboard" ); } } @@ -561,30 +561,30 @@ void TransferableHelper::AddFormat( const DataFlavor& rFlavor ) } } - if( bAdd ) - { - DataFlavorEx aFlavorEx; + if( !bAdd ) + return; - aFlavorEx.MimeType = rFlavor.MimeType; - aFlavorEx.HumanPresentableName = rFlavor.HumanPresentableName; - aFlavorEx.DataType = rFlavor.DataType; - aFlavorEx.mnSotId = SotExchange::RegisterFormat( rFlavor ); + DataFlavorEx aFlavorEx; - if ((SotClipboardFormatId::OBJECTDESCRIPTOR == aFlavorEx.mnSotId) && mxObjDesc) - aFlavorEx.MimeType += ::ImplGetParameterString(*mxObjDesc); + aFlavorEx.MimeType = rFlavor.MimeType; + aFlavorEx.HumanPresentableName = rFlavor.HumanPresentableName; + aFlavorEx.DataType = rFlavor.DataType; + aFlavorEx.mnSotId = SotExchange::RegisterFormat( rFlavor ); - maFormats.push_back(aFlavorEx); + if ((SotClipboardFormatId::OBJECTDESCRIPTOR == aFlavorEx.mnSotId) && mxObjDesc) + aFlavorEx.MimeType += ::ImplGetParameterString(*mxObjDesc); - if( SotClipboardFormatId::BITMAP == aFlavorEx.mnSotId ) - { - AddFormat( SotClipboardFormatId::PNG ); - AddFormat( SotClipboardFormatId::BMP ); - } - else if( SotClipboardFormatId::GDIMETAFILE == aFlavorEx.mnSotId ) - { - AddFormat( SotClipboardFormatId::EMF ); - AddFormat( SotClipboardFormatId::WMF ); - } + maFormats.push_back(aFlavorEx); + + if( SotClipboardFormatId::BITMAP == aFlavorEx.mnSotId ) + { + AddFormat( SotClipboardFormatId::PNG ); + AddFormat( SotClipboardFormatId::BMP ); + } + else if( SotClipboardFormatId::GDIMETAFILE == aFlavorEx.mnSotId ) + { + AddFormat( SotClipboardFormatId::EMF ); + AddFormat( SotClipboardFormatId::WMF ); } } @@ -918,19 +918,19 @@ void TransferableHelper::CopyToClipboard( vcl::Window *pWindow ) const if( xClipboard.is() ) mxClipboard = xClipboard; - if( mxClipboard.is() && !mxTerminateListener.is() ) + if( !(mxClipboard.is() && !mxTerminateListener.is()) ) + return; + + try { - try - { - TransferableHelper* pThis = const_cast< TransferableHelper* >( this ); - Reference< XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() ); - xDesktop->addTerminateListener( pThis->mxTerminateListener = new TerminateListener( *pThis ) ); + TransferableHelper* pThis = const_cast< TransferableHelper* >( this ); + Reference< XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() ); + xDesktop->addTerminateListener( pThis->mxTerminateListener = new TerminateListener( *pThis ) ); - mxClipboard->setContents( pThis, pThis ); - } - catch( const css::uno::Exception& ) - { - } + mxClipboard->setContents( pThis, pThis ); + } + catch( const css::uno::Exception& ) + { } } @@ -943,19 +943,19 @@ void TransferableHelper::CopyToSelection( vcl::Window *pWindow ) const if( pWindow ) xSelection = pWindow->GetPrimarySelection(); - if( xSelection.is() && !mxTerminateListener.is() ) + if( !(xSelection.is() && !mxTerminateListener.is()) ) + return; + + try { - try - { - TransferableHelper* pThis = const_cast< TransferableHelper* >( this ); - Reference< XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() ); - xDesktop->addTerminateListener( pThis->mxTerminateListener = new TerminateListener( *pThis ) ); + TransferableHelper* pThis = const_cast< TransferableHelper* >( this ); + Reference< XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() ); + xDesktop->addTerminateListener( pThis->mxTerminateListener = new TerminateListener( *pThis ) ); - xSelection->setContents( pThis, pThis ); - } - catch( const css::uno::Exception& ) - { - } + xSelection->setContents( pThis, pThis ); + } + catch( const css::uno::Exception& ) + { } } @@ -967,38 +967,38 @@ void TransferableHelper::StartDrag( vcl::Window* pWindow, sal_Int8 nDnDSourceAct DBG_ASSERT( pWindow, "Window pointer is NULL" ); Reference< XDragSource > xDragSource( pWindow->GetDragSource() ); - if( xDragSource.is() ) - { - /* - * #96792# release mouse before actually starting DnD. - * This is necessary for the X11 DnD implementation to work. - */ - if( pWindow->IsMouseCaptured() ) - pWindow->ReleaseMouse(); + if( !xDragSource.is() ) + return; - const Point aPt( pWindow->GetPointerPosPixel() ); + /* + * #96792# release mouse before actually starting DnD. + * This is necessary for the X11 DnD implementation to work. + */ + if( pWindow->IsMouseCaptured() ) + pWindow->ReleaseMouse(); - // On Mac OS X we are forced to execute 'startDrag' synchronously - // contrary to the XDragSource interface specification because - // we can receive drag events from the system only in the main - // thread + const Point aPt( pWindow->GetPointerPosPixel() ); + + // On Mac OS X we are forced to execute 'startDrag' synchronously + // contrary to the XDragSource interface specification because + // we can receive drag events from the system only in the main + // thread #if !defined(MACOSX) - SolarMutexReleaser aReleaser; + SolarMutexReleaser aReleaser; #endif - try - { - DragGestureEvent aEvt; - aEvt.DragAction = DNDConstants::ACTION_COPY; - aEvt.DragOriginX = aPt.X(); - aEvt.DragOriginY = aPt.Y(); - aEvt.DragSource = xDragSource; + try + { + DragGestureEvent aEvt; + aEvt.DragAction = DNDConstants::ACTION_COPY; + aEvt.DragOriginX = aPt.X(); + aEvt.DragOriginY = aPt.Y(); + aEvt.DragSource = xDragSource; - xDragSource->startDrag( aEvt, nDnDSourceActions, nDnDPointer, DND_IMAGE_NONE, this, this ); - } - catch( const css::uno::Exception& ) - { - } + xDragSource->startDrag( aEvt, nDnDSourceActions, nDnDPointer, DND_IMAGE_NONE, this, this ); + } + catch( const css::uno::Exception& ) + { } } @@ -1308,17 +1308,17 @@ void TransferableDataHelper::InitFormats() maFormats.clear(); mxObjDesc.reset(new TransferableObjectDescriptor); - if( mxTransfer.is() ) - { - TransferableDataHelper::FillDataFlavorExVector(mxTransfer->getTransferDataFlavors(), maFormats); + if( !mxTransfer.is() ) + return; - for (DataFlavorExVector::const_iterator aIter(maFormats.begin()), aEnd(maFormats.end()); aIter != aEnd; ++aIter) + TransferableDataHelper::FillDataFlavorExVector(mxTransfer->getTransferDataFlavors(), maFormats); + + for (DataFlavorExVector::const_iterator aIter(maFormats.begin()), aEnd(maFormats.end()); aIter != aEnd; ++aIter) + { + if( SotClipboardFormatId::OBJECTDESCRIPTOR == aIter->mnSotId ) { - if( SotClipboardFormatId::OBJECTDESCRIPTOR == aIter->mnSotId ) - { - ImplSetParameterString(*mxObjDesc, *aIter); - break; - } + ImplSetParameterString(*mxObjDesc, *aIter); + break; } } } diff --git a/svtools/source/misc/transfer2.cxx b/svtools/source/misc/transfer2.cxx index 7a4e1e3b6e44..6f8902785b3b 100644 --- a/svtools/source/misc/transfer2.cxx +++ b/svtools/source/misc/transfer2.cxx @@ -472,24 +472,24 @@ void TransferDataContainer::CopyImageMap( const ImageMap& rImgMap ) void TransferDataContainer::CopyGraphic( const Graphic& rGrf ) { GraphicType nType = rGrf.GetType(); - if( GraphicType::NONE != nType ) - { - if( !pImpl->pGrf ) - pImpl->pGrf = new Graphic( rGrf ); - else - *pImpl->pGrf = rGrf; + if( GraphicType::NONE == nType ) + return; - AddFormat( SotClipboardFormatId::SVXB ); + if( !pImpl->pGrf ) + pImpl->pGrf = new Graphic( rGrf ); + else + *pImpl->pGrf = rGrf; - if( GraphicType::Bitmap == nType ) - { - AddFormat( SotClipboardFormatId::PNG ); - AddFormat( SotClipboardFormatId::BITMAP ); - } - else if( GraphicType::GdiMetafile == nType ) - { - AddFormat( SotClipboardFormatId::GDIMETAFILE ); - } + AddFormat( SotClipboardFormatId::SVXB ); + + if( GraphicType::Bitmap == nType ) + { + AddFormat( SotClipboardFormatId::PNG ); + AddFormat( SotClipboardFormatId::BITMAP ); + } + else if( GraphicType::GdiMetafile == nType ) + { + AddFormat( SotClipboardFormatId::GDIMETAFILE ); } } diff --git a/svtools/source/svhtml/htmlsupp.cxx b/svtools/source/svhtml/htmlsupp.cxx index 619cc6009e0d..bda1cd41059c 100644 --- a/svtools/source/svhtml/htmlsupp.cxx +++ b/svtools/source/svhtml/htmlsupp.cxx @@ -108,34 +108,34 @@ void HTMLParser::RemoveSGMLComment( OUString &rString ) rString = rString.copy( nPos ); } - if( rString.endsWith("-->") ) + if( !rString.endsWith("-->") ) + return; + + rString = rString.copy( 0, rString.getLength()-3 ); + // "//" or "'", maybe preceding CR/LF + rString = comphelper::string::stripEnd(rString, ' '); + sal_Int32 nDel = 0, nLen = rString.getLength(); + if( nLen >= 2 && + rString.endsWith("//") ) { - rString = rString.copy( 0, rString.getLength()-3 ); - // "//" or "'", maybe preceding CR/LF - rString = comphelper::string::stripEnd(rString, ' '); - sal_Int32 nDel = 0, nLen = rString.getLength(); - if( nLen >= 2 && - rString.endsWith("//") ) - { - nDel = 2; - } - else if( nLen && '\'' == rString[nLen-1] ) - { - nDel = 1; - } - if( nDel && nLen >= nDel+1 ) + nDel = 2; + } + else if( nLen && '\'' == rString[nLen-1] ) + { + nDel = 1; + } + if( nDel && nLen >= nDel+1 ) + { + c = rString[nLen-(nDel+1)]; + if( '\r'==c || '\n'==c ) { - c = rString[nLen-(nDel+1)]; - if( '\r'==c || '\n'==c ) - { + nDel++; + if( '\n'==c && nLen >= nDel+1 && + '\r'==rString[nLen-(nDel+1)] ) nDel++; - if( '\n'==c && nLen >= nDel+1 && - '\r'==rString[nLen-(nDel+1)] ) - nDel++; - } } - rString = rString.copy( 0, nLen-nDel ); } + rString = rString.copy( 0, nLen-nDel ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/svrtf/svparser.cxx b/svtools/source/svrtf/svparser.cxx index bfcc511a8490..6b2d8a9683a0 100644 --- a/svtools/source/svrtf/svparser.cxx +++ b/svtools/source/svrtf/svparser.cxx @@ -136,38 +136,38 @@ void SvParser<T>::ClearTxtConvContext() template<typename T> void SvParser<T>::SetSrcEncoding( rtl_TextEncoding eEnc ) { - if( eEnc != eSrcEnc ) + if( eEnc == eSrcEnc ) + return; + + if( pImplData && pImplData->hConv ) { - if( pImplData && pImplData->hConv ) - { - rtl_destroyTextToUnicodeContext( pImplData->hConv, - pImplData->hContext ); - rtl_destroyTextToUnicodeConverter( pImplData->hConv ); - pImplData->hConv = nullptr; - pImplData->hContext = reinterpret_cast<rtl_TextToUnicodeContext>(1); - } + rtl_destroyTextToUnicodeContext( pImplData->hConv, + pImplData->hContext ); + rtl_destroyTextToUnicodeConverter( pImplData->hConv ); + pImplData->hConv = nullptr; + pImplData->hContext = reinterpret_cast<rtl_TextToUnicodeContext>(1); + } - if( rtl_isOctetTextEncoding(eEnc) || - RTL_TEXTENCODING_UCS2 == eEnc ) - { - eSrcEnc = eEnc; - if( !pImplData ) - pImplData.reset(new SvParser_Impl<T>); - pImplData->hConv = rtl_createTextToUnicodeConverter( eSrcEnc ); - DBG_ASSERT( pImplData->hConv, - "SvParser::SetSrcEncoding: no converter for source encoding" ); - if( !pImplData->hConv ) - eSrcEnc = RTL_TEXTENCODING_DONTKNOW; - else - pImplData->hContext = - rtl_createTextToUnicodeContext( pImplData->hConv ); - } - else - { - SAL_WARN( "svtools", - "SvParser::SetSrcEncoding: invalid source encoding" ); + if( rtl_isOctetTextEncoding(eEnc) || + RTL_TEXTENCODING_UCS2 == eEnc ) + { + eSrcEnc = eEnc; + if( !pImplData ) + pImplData.reset(new SvParser_Impl<T>); + pImplData->hConv = rtl_createTextToUnicodeConverter( eSrcEnc ); + DBG_ASSERT( pImplData->hConv, + "SvParser::SetSrcEncoding: no converter for source encoding" ); + if( !pImplData->hConv ) eSrcEnc = RTL_TEXTENCODING_DONTKNOW; - } + else + pImplData->hContext = + rtl_createTextToUnicodeContext( pImplData->hConv ); + } + else + { + SAL_WARN( "svtools", + "SvParser::SetSrcEncoding: invalid source encoding" ); + eSrcEnc = RTL_TEXTENCODING_DONTKNOW; } } @@ -582,21 +582,21 @@ template<typename T> void SvParser<T>::RestoreState() { // restore old status - if( pImplData ) - { - if( ERRCODE_IO_PENDING == rInput.GetError() ) - rInput.ResetError(); - aToken = pImplData->aToken; - nlLineNr = pImplData->nlLineNr; - nlLinePos = pImplData->nlLinePos; - nTokenValue= pImplData->nTokenValue; - bTokenHasValue=pImplData->bTokenHasValue; - nNextCh = pImplData->nNextCh; + if( !pImplData ) + return; - pImplData->nSaveToken = pImplData->nToken; + if( ERRCODE_IO_PENDING == rInput.GetError() ) + rInput.ResetError(); + aToken = pImplData->aToken; + nlLineNr = pImplData->nlLineNr; + nlLinePos = pImplData->nlLinePos; + nTokenValue= pImplData->nTokenValue; + bTokenHasValue=pImplData->bTokenHasValue; + nNextCh = pImplData->nNextCh; - rInput.Seek( pImplData->nFilePos ); - } + pImplData->nSaveToken = pImplData->nToken; + + rInput.Seek( pImplData->nFilePos ); } template<typename T> diff --git a/svtools/source/uno/framestatuslistener.cxx b/svtools/source/uno/framestatuslistener.cxx index 0985d618bb3d..0de8644bbc5c 100644 --- a/svtools/source/uno/framestatuslistener.cxx +++ b/svtools/source/uno/framestatuslistener.cxx @@ -256,20 +256,20 @@ void FrameStatusListener::bindListener() } // Call without locked mutex as we are called back from dispatch implementation - if ( xStatusListener.is() ) + if ( !xStatusListener.is() ) + return; + + try { - try - { - for (Listener & rListener : aDispatchVector) - { - if ( rListener.xDispatch.is() ) - rListener.xDispatch->addStatusListener( xStatusListener, rListener.aURL ); - } - } - catch (const Exception&) + for (Listener & rListener : aDispatchVector) { + if ( rListener.xDispatch.is() ) + rListener.xDispatch->addStatusListener( xStatusListener, rListener.aURL ); } } + catch (const Exception&) + { + } } } // svt diff --git a/svtools/source/uno/generictoolboxcontroller.cxx b/svtools/source/uno/generictoolboxcontroller.cxx index b755ac147caa..9c8617e525cd 100644 --- a/svtools/source/uno/generictoolboxcontroller.cxx +++ b/svtools/source/uno/generictoolboxcontroller.cxx @@ -97,22 +97,22 @@ void SAL_CALL GenericToolboxController::execute( sal_Int16 /*KeyModifier*/ ) } } - if ( xDispatch.is() ) - { - css::util::URL aTargetURL; - Sequence<PropertyValue> aArgs; - - aTargetURL.Complete = aCommandURL; - if ( m_xUrlTransformer.is() ) - m_xUrlTransformer->parseStrict( aTargetURL ); - - // Execute dispatch asynchronously - ExecuteInfo* pExecuteInfo = new ExecuteInfo; - pExecuteInfo->xDispatch = xDispatch; - pExecuteInfo->aTargetURL = aTargetURL; - pExecuteInfo->aArgs = aArgs; - Application::PostUserEvent( LINK(nullptr, GenericToolboxController , ExecuteHdl_Impl), pExecuteInfo ); - } + if ( !xDispatch.is() ) + return; + + css::util::URL aTargetURL; + Sequence<PropertyValue> aArgs; + + aTargetURL.Complete = aCommandURL; + if ( m_xUrlTransformer.is() ) + m_xUrlTransformer->parseStrict( aTargetURL ); + + // Execute dispatch asynchronously + ExecuteInfo* pExecuteInfo = new ExecuteInfo; + pExecuteInfo->xDispatch = xDispatch; + pExecuteInfo->aTargetURL = aTargetURL; + pExecuteInfo->aArgs = aArgs; + Application::PostUserEvent( LINK(nullptr, GenericToolboxController , ExecuteHdl_Impl), pExecuteInfo ); } void GenericToolboxController::statusChanged( const FeatureStateEvent& Event ) @@ -122,40 +122,40 @@ void GenericToolboxController::statusChanged( const FeatureStateEvent& Event ) if ( m_bDisposed ) return; - if ( m_pToolbox ) - { - m_pToolbox->EnableItem( m_nID, Event.IsEnabled ); + if ( !m_pToolbox ) + return; - ToolBoxItemBits nItemBits = m_pToolbox->GetItemBits( m_nID ); - nItemBits &= ~ToolBoxItemBits::CHECKABLE; - TriState eTri = TRISTATE_FALSE; + m_pToolbox->EnableItem( m_nID, Event.IsEnabled ); - bool bValue; - OUString aStrValue; - ItemStatus aItemState; + ToolBoxItemBits nItemBits = m_pToolbox->GetItemBits( m_nID ); + nItemBits &= ~ToolBoxItemBits::CHECKABLE; + TriState eTri = TRISTATE_FALSE; - if ( Event.State >>= bValue ) - { - // Boolean, treat it as checked/unchecked - m_pToolbox->SetItemBits( m_nID, nItemBits ); - m_pToolbox->CheckItem( m_nID, bValue ); - if ( bValue ) - eTri = TRISTATE_TRUE; - nItemBits |= ToolBoxItemBits::CHECKABLE; - } - else if ( Event.State >>= aStrValue ) - { - m_pToolbox->SetItemText( m_nID, aStrValue ); - } - else if ( Event.State >>= aItemState ) - { - eTri = TRISTATE_INDET; - nItemBits |= ToolBoxItemBits::CHECKABLE; - } + bool bValue; + OUString aStrValue; + ItemStatus aItemState; - m_pToolbox->SetItemState( m_nID, eTri ); + if ( Event.State >>= bValue ) + { + // Boolean, treat it as checked/unchecked m_pToolbox->SetItemBits( m_nID, nItemBits ); + m_pToolbox->CheckItem( m_nID, bValue ); + if ( bValue ) + eTri = TRISTATE_TRUE; + nItemBits |= ToolBoxItemBits::CHECKABLE; } + else if ( Event.State >>= aStrValue ) + { + m_pToolbox->SetItemText( m_nID, aStrValue ); + } + else if ( Event.State >>= aItemState ) + { + eTri = TRISTATE_INDET; + nItemBits |= ToolBoxItemBits::CHECKABLE; + } + + m_pToolbox->SetItemState( m_nID, eTri ); + m_pToolbox->SetItemBits( m_nID, nItemBits ); } IMPL_STATIC_LINK( GenericToolboxController, ExecuteHdl_Impl, void*, p, void ) diff --git a/svtools/source/uno/popupmenucontrollerbase.cxx b/svtools/source/uno/popupmenucontrollerbase.cxx index 67a2349eb13a..ae91f114af99 100644 --- a/svtools/source/uno/popupmenucontrollerbase.cxx +++ b/svtools/source/uno/popupmenucontrollerbase.cxx @@ -303,33 +303,33 @@ void SAL_CALL PopupMenuControllerBase::initialize( const Sequence< Any >& aArgum osl::MutexGuard aLock( m_aMutex ); bool bInitalized( m_bInitialized ); - if ( !bInitalized ) - { - PropertyValue aPropValue; - OUString aCommandURL; - Reference< XFrame > xFrame; + if ( bInitalized ) + return; - for ( int i = 0; i < aArguments.getLength(); i++ ) - { - if ( aArguments[i] >>= aPropValue ) - { - if ( aPropValue.Name == "Frame" ) - aPropValue.Value >>= xFrame; - else if ( aPropValue.Name == "CommandURL" ) - aPropValue.Value >>= aCommandURL; - else if ( aPropValue.Name == "ModuleIdentifier" ) - aPropValue.Value >>= m_aModuleName; - } - } + PropertyValue aPropValue; + OUString aCommandURL; + Reference< XFrame > xFrame; - if ( xFrame.is() && !aCommandURL.isEmpty() ) + for ( int i = 0; i < aArguments.getLength(); i++ ) + { + if ( aArguments[i] >>= aPropValue ) { - m_xFrame = xFrame; - m_aCommandURL = aCommandURL; - m_aBaseURL = determineBaseURL( aCommandURL ); - m_bInitialized = true; + if ( aPropValue.Name == "Frame" ) + aPropValue.Value >>= xFrame; + else if ( aPropValue.Name == "CommandURL" ) + aPropValue.Value >>= aCommandURL; + else if ( aPropValue.Name == "ModuleIdentifier" ) + aPropValue.Value >>= m_aModuleName; } } + + if ( xFrame.is() && !aCommandURL.isEmpty() ) + { + m_xFrame = xFrame; + m_aCommandURL = aCommandURL; + m_aBaseURL = determineBaseURL( aCommandURL ); + m_bInitialized = true; + } } // XPopupMenuController void SAL_CALL PopupMenuControllerBase::setPopupMenu( const Reference< awt::XPopupMenu >& xPopupMenu ) @@ -337,25 +337,25 @@ void SAL_CALL PopupMenuControllerBase::setPopupMenu( const Reference< awt::XPopu osl::MutexGuard aLock( m_aMutex ); throwIfDisposed(); - if ( m_xFrame.is() && !m_xPopupMenu.is() ) - { - // Create popup menu on demand - SolarMutexGuard aSolarMutexGuard; + if ( !(m_xFrame.is() && !m_xPopupMenu.is()) ) + return; + + // Create popup menu on demand + SolarMutexGuard aSolarMutexGuard; - m_xPopupMenu = xPopupMenu; - m_xPopupMenu->addMenuListener( Reference< awt::XMenuListener >( static_cast<OWeakObject*>(this), UNO_QUERY )); + m_xPopupMenu = xPopupMenu; + m_xPopupMenu->addMenuListener( Reference< awt::XMenuListener >( static_cast<OWeakObject*>(this), UNO_QUERY )); - Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); + Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); - URL aTargetURL; - aTargetURL.Complete = m_aCommandURL; - m_xURLTransformer->parseStrict( aTargetURL ); - m_xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 ); + URL aTargetURL; + aTargetURL.Complete = m_aCommandURL; + m_xURLTransformer->parseStrict( aTargetURL ); + m_xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 ); - impl_setPopupMenu(); + impl_setPopupMenu(); - updatePopupMenu(); - } + updatePopupMenu(); } void PopupMenuControllerBase::impl_setPopupMenu() { diff --git a/svtools/source/uno/statusbarcontroller.cxx b/svtools/source/uno/statusbarcontroller.cxx index 94433e733fbd..fbd5f80001e6 100644 --- a/svtools/source/uno/statusbarcontroller.cxx +++ b/svtools/source/uno/statusbarcontroller.cxx @@ -131,39 +131,39 @@ void SAL_CALL StatusbarController::initialize( const Sequence< Any >& aArguments bInitialized = m_bInitialized; } - if ( !bInitialized ) - { - SolarMutexGuard aSolarMutexGuard; - m_bInitialized = true; + if ( bInitialized ) + return; - PropertyValue aPropValue; - for ( int i = 0; i < aArguments.getLength(); i++ ) + SolarMutexGuard aSolarMutexGuard; + m_bInitialized = true; + + PropertyValue aPropValue; + for ( int i = 0; i < aArguments.getLength(); i++ ) + { + if ( aArguments[i] >>= aPropValue ) { - if ( aArguments[i] >>= aPropValue ) + if ( aPropValue.Name == "Frame" ) + aPropValue.Value >>= m_xFrame; + else if ( aPropValue.Name == "CommandURL" ) + aPropValue.Value >>= m_aCommandURL; + else if ( aPropValue.Name == "ServiceManager" ) { - if ( aPropValue.Name == "Frame" ) - aPropValue.Value >>= m_xFrame; - else if ( aPropValue.Name == "CommandURL" ) - aPropValue.Value >>= m_aCommandURL; - else if ( aPropValue.Name == "ServiceManager" ) - { - Reference<XMultiServiceFactory> xMSF; - aPropValue.Value >>= xMSF; - if( xMSF.is() ) - m_xContext = comphelper::getComponentContext(xMSF); - } - else if ( aPropValue.Name == "ParentWindow" ) - aPropValue.Value >>= m_xParentWindow; - else if ( aPropValue.Name == "Identifier" ) - aPropValue.Value >>= m_nID; - else if ( aPropValue.Name == "StatusbarItem" ) - aPropValue.Value >>= m_xStatusbarItem; + Reference<XMultiServiceFactory> xMSF; + aPropValue.Value >>= xMSF; + if( xMSF.is() ) + m_xContext = comphelper::getComponentContext(xMSF); } + else if ( aPropValue.Name == "ParentWindow" ) + aPropValue.Value >>= m_xParentWindow; + else if ( aPropValue.Name == "Identifier" ) + aPropValue.Value >>= m_nID; + else if ( aPropValue.Name == "StatusbarItem" ) + aPropValue.Value >>= m_xStatusbarItem; } - - if ( !m_aCommandURL.isEmpty() ) - m_aListenerMap.emplace( m_aCommandURL, Reference< XDispatch >() ); } + + if ( !m_aCommandURL.isEmpty() ) + m_aListenerMap.emplace( m_aCommandURL, Reference< XDispatch >() ); } void SAL_CALL StatusbarController::update() @@ -534,19 +534,19 @@ void StatusbarController::execute( const css::uno::Sequence< css::beans::Propert } } - if ( xDispatch.is() && xURLTransformer.is() ) + if ( !(xDispatch.is() && xURLTransformer.is()) ) + return; + + try { - try - { - css::util::URL aTargetURL; + css::util::URL aTargetURL; - aTargetURL.Complete = aCommandURL; - xURLTransformer->parseStrict( aTargetURL ); - xDispatch->dispatch( aTargetURL, aArgs ); - } - catch ( DisposedException& ) - { - } + aTargetURL.Complete = aCommandURL; + xURLTransformer->parseStrict( aTargetURL ); + xDispatch->dispatch( aTargetURL, aArgs ); + } + catch ( DisposedException& ) + { } } diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx index 234b5767af82..e6de4f65c100 100644 --- a/svtools/source/uno/svtxgridcontrol.cxx +++ b/svtools/source/uno/svtxgridcontrol.cxx @@ -434,25 +434,25 @@ void SVTXGridControl::setProperty( const OUString& PropertyName, const Any& aVal void SVTXGridControl::impl_checkTableModelInit() { - if ( !m_bTableModelInitCompleted && m_xTableModel->hasColumnModel() && m_xTableModel->hasDataModel() ) - { - VclPtr< TableControl > pTable = GetAsDynamic< TableControl >(); - if ( pTable ) - { - pTable->SetModel( PTableModel( m_xTableModel ) ); + if ( !(!m_bTableModelInitCompleted && m_xTableModel->hasColumnModel() && m_xTableModel->hasDataModel()) ) + return; - m_bTableModelInitCompleted = true; + VclPtr< TableControl > pTable = GetAsDynamic< TableControl >(); + if ( !pTable ) + return; - // ensure default columns exist, if they have not previously been added - Reference< XGridDataModel > const xDataModel( m_xTableModel->getDataModel(), UNO_QUERY_THROW ); - Reference< XGridColumnModel > const xColumnModel( m_xTableModel->getColumnModel(), UNO_QUERY_THROW ); + pTable->SetModel( PTableModel( m_xTableModel ) ); - sal_Int32 const nDataColumnCount = xDataModel->getColumnCount(); - if ( ( nDataColumnCount > 0 ) && ( xColumnModel->getColumnCount() == 0 ) ) - xColumnModel->setDefaultColumns( nDataColumnCount ); - // this will trigger notifications, which in turn will let us update our m_xTableModel - } - } + m_bTableModelInitCompleted = true; + + // ensure default columns exist, if they have not previously been added + Reference< XGridDataModel > const xDataModel( m_xTableModel->getDataModel(), UNO_QUERY_THROW ); + Reference< XGridColumnModel > const xColumnModel( m_xTableModel->getColumnModel(), UNO_QUERY_THROW ); + + sal_Int32 const nDataColumnCount = xDataModel->getColumnCount(); + if ( ( nDataColumnCount > 0 ) && ( xColumnModel->getColumnCount() == 0 ) ) + xColumnModel->setDefaultColumns( nDataColumnCount ); + // this will trigger notifications, which in turn will let us update our m_xTableModel } namespace diff --git a/svtools/source/uno/toolboxcontroller.cxx b/svtools/source/uno/toolboxcontroller.cxx index 848a1b065d69..e123da5a4c50 100644 --- a/svtools/source/uno/toolboxcontroller.cxx +++ b/svtools/source/uno/toolboxcontroller.cxx @@ -172,47 +172,47 @@ void SAL_CALL ToolboxController::initialize( const Sequence< Any >& aArguments ) bInitialized = m_bInitialized; } - if ( !bInitialized ) + if ( bInitialized ) + return; + + SolarMutexGuard aSolarMutexGuard; + m_bInitialized = true; + m_bSupportVisible = false; + PropertyValue aPropValue; + for ( int i = 0; i < aArguments.getLength(); i++ ) { - SolarMutexGuard aSolarMutexGuard; - m_bInitialized = true; - m_bSupportVisible = false; - PropertyValue aPropValue; - for ( int i = 0; i < aArguments.getLength(); i++ ) + if ( aArguments[i] >>= aPropValue ) { - if ( aArguments[i] >>= aPropValue ) + if ( aPropValue.Name == "Frame" ) + m_xFrame.set(aPropValue.Value,UNO_QUERY); + else if ( aPropValue.Name == "CommandURL" ) + aPropValue.Value >>= m_aCommandURL; + else if ( aPropValue.Name == "ServiceManager" ) { - if ( aPropValue.Name == "Frame" ) - m_xFrame.set(aPropValue.Value,UNO_QUERY); - else if ( aPropValue.Name == "CommandURL" ) - aPropValue.Value >>= m_aCommandURL; - else if ( aPropValue.Name == "ServiceManager" ) - { - Reference<XMultiServiceFactory> xMSF(aPropValue.Value, UNO_QUERY); - if (xMSF.is()) - m_xContext = comphelper::getComponentContext(xMSF); - } - else if ( aPropValue.Name == "ParentWindow" ) - m_xParentWindow.set(aPropValue.Value,UNO_QUERY); - else if ( aPropValue.Name == "ModuleIdentifier" ) - aPropValue.Value >>= m_sModuleName; - else if ( aPropValue.Name == "Identifier" ) - aPropValue.Value >>= m_nToolBoxId; + Reference<XMultiServiceFactory> xMSF(aPropValue.Value, UNO_QUERY); + if (xMSF.is()) + m_xContext = comphelper::getComponentContext(xMSF); } + else if ( aPropValue.Name == "ParentWindow" ) + m_xParentWindow.set(aPropValue.Value,UNO_QUERY); + else if ( aPropValue.Name == "ModuleIdentifier" ) + aPropValue.Value >>= m_sModuleName; + else if ( aPropValue.Name == "Identifier" ) + aPropValue.Value >>= m_nToolBoxId; } + } - try - { - if ( !m_xUrlTransformer.is() && m_xContext.is() ) - m_xUrlTransformer = URLTransformer::create( m_xContext ); - } - catch(const Exception&) - { - } - - if ( !m_aCommandURL.isEmpty() ) - m_aListenerMap.emplace( m_aCommandURL, Reference< XDispatch >() ); + try + { + if ( !m_xUrlTransformer.is() && m_xContext.is() ) + m_xUrlTransformer = URLTransformer::create( m_xContext ); } + catch(const Exception&) + { + } + + if ( !m_aCommandURL.isEmpty() ) + m_aListenerMap.emplace( m_aCommandURL, Reference< XDispatch >() ); } void SAL_CALL ToolboxController::update() @@ -332,25 +332,25 @@ void SAL_CALL ToolboxController::execute( sal_Int16 KeyModifier ) } } - if ( xDispatch.is() ) + if ( !xDispatch.is() ) + return; + + try { - try - { - css::util::URL aTargetURL; - Sequence<PropertyValue> aArgs( 1 ); + css::util::URL aTargetURL; + Sequence<PropertyValue> aArgs( 1 ); - // Provide key modifier information to dispatch function - aArgs[0].Name = "KeyModifier"; - aArgs[0].Value <<= KeyModifier; + // Provide key modifier information to dispatch function + aArgs[0].Name = "KeyModifier"; + aArgs[0].Value <<= KeyModifier; - aTargetURL.Complete = aCommandURL; - if ( m_xUrlTransformer.is() ) - m_xUrlTransformer->parseStrict( aTargetURL ); - xDispatch->dispatch( aTargetURL, aArgs ); - } - catch ( DisposedException& ) - { - } + aTargetURL.Complete = aCommandURL; + if ( m_xUrlTransformer.is() ) + m_xUrlTransformer->parseStrict( aTargetURL ); + xDispatch->dispatch( aTargetURL, aArgs ); + } + catch ( DisposedException& ) + { } } @@ -443,25 +443,25 @@ void ToolboxController::removeStatusListener( const OUString& aCommandURL ) SolarMutexGuard aSolarMutexGuard; URLToDispatchMap::iterator pIter = m_aListenerMap.find( aCommandURL ); - if ( pIter != m_aListenerMap.end() ) - { - Reference< XDispatch > xDispatch( pIter->second ); - Reference< XStatusListener > xStatusListener( static_cast< OWeakObject* >( this ), UNO_QUERY ); - m_aListenerMap.erase( pIter ); + if ( pIter == m_aListenerMap.end() ) + return; - try - { - css::util::URL aTargetURL; - aTargetURL.Complete = aCommandURL; - if ( m_xUrlTransformer.is() ) - m_xUrlTransformer->parseStrict( aTargetURL ); + Reference< XDispatch > xDispatch( pIter->second ); + Reference< XStatusListener > xStatusListener( static_cast< OWeakObject* >( this ), UNO_QUERY ); + m_aListenerMap.erase( pIter ); - if ( xDispatch.is() && xStatusListener.is() ) - xDispatch->removeStatusListener( xStatusListener, aTargetURL ); - } - catch ( Exception& ) - { - } + try + { + css::util::URL aTargetURL; + aTargetURL.Complete = aCommandURL; + if ( m_xUrlTransformer.is() ) + m_xUrlTransformer->parseStrict( aTargetURL ); + + if ( xDispatch.is() && xStatusListener.is() ) + xDispatch->removeStatusListener( xStatusListener, aTargetURL ); + } + catch ( Exception& ) + { } } @@ -524,36 +524,36 @@ void ToolboxController::bindListener() } // Call without locked mutex as we are called back from dispatch implementation - if ( xStatusListener.is() ) + if ( !xStatusListener.is() ) + return; + + try { - try + for (Listener & rListener : aDispatchVector) { - for (Listener & rListener : aDispatchVector) + if ( rListener.xDispatch.is() ) + rListener.xDispatch->addStatusListener( xStatusListener, rListener.aURL ); + else if ( rListener.aURL.Complete == m_aCommandURL ) { - if ( rListener.xDispatch.is() ) - rListener.xDispatch->addStatusListener( xStatusListener, rListener.aURL ); - else if ( rListener.aURL.Complete == m_aCommandURL ) + try + { + // Send status changed for the main URL, if we cannot get a valid dispatch object. + // UI disables the button. Catch exception as we release our mutex, it is possible + // that someone else already disposed this instance! + FeatureStateEvent aFeatureStateEvent; + aFeatureStateEvent.IsEnabled = false; + aFeatureStateEvent.FeatureURL = rListener.aURL; + aFeatureStateEvent.State = Any(); + xStatusListener->statusChanged( aFeatureStateEvent ); + } + catch ( Exception& ) { - try - { - // Send status changed for the main URL, if we cannot get a valid dispatch object. - // UI disables the button. Catch exception as we release our mutex, it is possible - // that someone else already disposed this instance! - FeatureStateEvent aFeatureStateEvent; - aFeatureStateEvent.IsEnabled = false; - aFeatureStateEvent.FeatureURL = rListener.aURL; - aFeatureStateEvent.State = Any(); - xStatusListener->statusChanged( aFeatureStateEvent ); - } - catch ( Exception& ) - { - } } } } - catch ( Exception& ) - { - } + } + catch ( Exception& ) + { } } @@ -566,33 +566,33 @@ void ToolboxController::unbindListener() // Collect all registered command URL's and store them temporary Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); - if ( m_xContext.is() && xDispatchProvider.is() ) + if ( !(m_xContext.is() && xDispatchProvider.is()) ) + return; + + Reference< XStatusListener > xStatusListener( static_cast< OWeakObject* >( this ), UNO_QUERY ); + URLToDispatchMap::iterator pIter = m_aListenerMap.begin(); + while ( pIter != m_aListenerMap.end() ) { - Reference< XStatusListener > xStatusListener( static_cast< OWeakObject* >( this ), UNO_QUERY ); - URLToDispatchMap::iterator pIter = m_aListenerMap.begin(); - while ( pIter != m_aListenerMap.end() ) - { - css::util::URL aTargetURL; - aTargetURL.Complete = pIter->first; - if ( m_xUrlTransformer.is() ) - m_xUrlTransformer->parseStrict( aTargetURL ); + css::util::URL aTargetURL; + aTargetURL.Complete = pIter->first; + if ( m_xUrlTransformer.is() ) + m_xUrlTransformer->parseStrict( aTargetURL ); - Reference< XDispatch > xDispatch( pIter->second ); - if ( xDispatch.is() ) + Reference< XDispatch > xDispatch( pIter->second ); + if ( xDispatch.is() ) + { + // We already have a dispatch object => we have to requery. + // Release old dispatch object and remove it as listener + try + { + xDispatch->removeStatusListener( xStatusListener, aTargetURL ); + } + catch ( Exception& ) { - // We already have a dispatch object => we have to requery. - // Release old dispatch object and remove it as listener - try - { - xDispatch->removeStatusListener( xStatusListener, aTargetURL ); - } - catch ( Exception& ) - { - } } - pIter->second.clear(); - ++pIter; } + pIter->second.clear(); + ++pIter; } } @@ -639,20 +639,20 @@ void ToolboxController::updateStatus( const OUString& aCommandURL ) } } - if ( xDispatch.is() && xStatusListener.is() ) + if ( !(xDispatch.is() && xStatusListener.is()) ) + return; + + // Catch exception as we release our mutex, it is possible that someone else + // has already disposed this instance! + // Add/remove status listener to get a update status information from the + // requested command. + try + { + xDispatch->addStatusListener( xStatusListener, aTargetURL ); + xDispatch->removeStatusListener( xStatusListener, aTargetURL ); + } + catch ( Exception& ) { - // Catch exception as we release our mutex, it is possible that someone else - // has already disposed this instance! - // Add/remove status listener to get a update status information from the - // requested command. - try - { - xDispatch->addStatusListener( xStatusListener, aTargetURL ); - xDispatch->removeStatusListener( xStatusListener, aTargetURL ); - } - catch ( Exception& ) - { - } } } diff --git a/svtools/source/uno/treecontrolpeer.cxx b/svtools/source/uno/treecontrolpeer.cxx index 247e0dc07618..e2c9f2b4edf6 100644 --- a/svtools/source/uno/treecontrolpeer.cxx +++ b/svtools/source/uno/treecontrolpeer.cxx @@ -252,65 +252,65 @@ UnoTreeListEntry* TreeControlPeer::createEntry( const Reference< XTreeNode >& xN void TreeControlPeer::updateEntry( UnoTreeListEntry* pEntry ) { bool bChanged = false; - if( pEntry && pEntry->mxNode.is() && mpTreeImpl ) + if( !(pEntry && pEntry->mxNode.is() && mpTreeImpl) ) + return; + + const OUString aValue( getEntryString( pEntry->mxNode->getDisplayValue() ) ); + UnoTreeListItem* pUnoItem = dynamic_cast< UnoTreeListItem* >( &pEntry->GetItem( 1 ) ); + if( pUnoItem ) { - const OUString aValue( getEntryString( pEntry->mxNode->getDisplayValue() ) ); - UnoTreeListItem* pUnoItem = dynamic_cast< UnoTreeListItem* >( &pEntry->GetItem( 1 ) ); - if( pUnoItem ) + if( aValue != pUnoItem->GetText() ) { - if( aValue != pUnoItem->GetText() ) - { - pUnoItem->SetText( aValue ); - bChanged = true; - } + pUnoItem->SetText( aValue ); + bChanged = true; + } - if( pUnoItem->GetGraphicURL() != pEntry->mxNode->getNodeGraphicURL() ) + if( pUnoItem->GetGraphicURL() != pEntry->mxNode->getNodeGraphicURL() ) + { + Image aImage; + if( loadImage( pEntry->mxNode->getNodeGraphicURL(), aImage ) ) { - Image aImage; - if( loadImage( pEntry->mxNode->getNodeGraphicURL(), aImage ) ) - { - pUnoItem->SetGraphicURL( pEntry->mxNode->getNodeGraphicURL() ); - pUnoItem->SetImage( aImage ); - mpTreeImpl->AdjustEntryHeight( aImage ); - bChanged = true; - } + pUnoItem->SetGraphicURL( pEntry->mxNode->getNodeGraphicURL() ); + pUnoItem->SetImage( aImage ); + mpTreeImpl->AdjustEntryHeight( aImage ); + bChanged = true; } } + } - if( bool(pEntry->mxNode->hasChildrenOnDemand()) != pEntry->HasChildrenOnDemand() ) - { - pEntry->EnableChildrenOnDemand( pEntry->mxNode->hasChildrenOnDemand() ); - bChanged = true; - } + if( bool(pEntry->mxNode->hasChildrenOnDemand()) != pEntry->HasChildrenOnDemand() ) + { + pEntry->EnableChildrenOnDemand( pEntry->mxNode->hasChildrenOnDemand() ); + bChanged = true; + } - ImplContextGraphicItem* pContextGraphicItem = dynamic_cast< ImplContextGraphicItem* >( &pEntry->GetItem( 0 ) ); - if( pContextGraphicItem ) + ImplContextGraphicItem* pContextGraphicItem = dynamic_cast< ImplContextGraphicItem* >( &pEntry->GetItem( 0 ) ); + if( pContextGraphicItem ) + { + if( pContextGraphicItem->msExpandedGraphicURL != pEntry->mxNode->getExpandedGraphicURL() ) { - if( pContextGraphicItem->msExpandedGraphicURL != pEntry->mxNode->getExpandedGraphicURL() ) + Image aImage; + if( loadImage( pEntry->mxNode->getExpandedGraphicURL(), aImage ) ) { - Image aImage; - if( loadImage( pEntry->mxNode->getExpandedGraphicURL(), aImage ) ) - { - pContextGraphicItem->msExpandedGraphicURL = pEntry->mxNode->getExpandedGraphicURL(); - mpTreeImpl->SetExpandedEntryBmp( pEntry, aImage ); - bChanged = true; - } + pContextGraphicItem->msExpandedGraphicURL = pEntry->mxNode->getExpandedGraphicURL(); + mpTreeImpl->SetExpandedEntryBmp( pEntry, aImage ); + bChanged = true; } - if( pContextGraphicItem->msCollapsedGraphicURL != pEntry->mxNode->getCollapsedGraphicURL() ) + } + if( pContextGraphicItem->msCollapsedGraphicURL != pEntry->mxNode->getCollapsedGraphicURL() ) + { + Image aImage; + if( loadImage( pEntry->mxNode->getCollapsedGraphicURL(), aImage ) ) { - Image aImage; - if( loadImage( pEntry->mxNode->getCollapsedGraphicURL(), aImage ) ) - { - pContextGraphicItem->msCollapsedGraphicURL = pEntry->mxNode->getCollapsedGraphicURL(); - mpTreeImpl->SetCollapsedEntryBmp( pEntry, aImage ); - bChanged = true; - } + pContextGraphicItem->msCollapsedGraphicURL = pEntry->mxNode->getCollapsedGraphicURL(); + mpTreeImpl->SetCollapsedEntryBmp( pEntry, aImage ); + bChanged = true; } } - - if( bChanged ) - mpTreeImpl->GetModel()->InvalidateEntry( pEntry ); } + + if( bChanged ) + mpTreeImpl->GetModel()->InvalidateEntry( pEntry ); } @@ -385,22 +385,22 @@ void TreeControlPeer::fillTree( UnoTreeListBoxImpl& rTree, const Reference< XTre { rTree.Clear(); - if( xDataModel.is() ) + if( !xDataModel.is() ) + return; + + Reference< XTreeNode > xRootNode( xDataModel->getRoot() ); + if( !xRootNode.is() ) + return; + + if( mbIsRootDisplayed ) { - Reference< XTreeNode > xRootNode( xDataModel->getRoot() ); - if( xRootNode.is() ) - { - if( mbIsRootDisplayed ) - { - addNode( rTree, xRootNode, nullptr ); - } - else - { - const sal_Int32 nChildCount = xRootNode->getChildCount(); - for( sal_Int32 nChild = 0; nChild < nChildCount; nChild++ ) - addNode( rTree, xRootNode->getChildAt( nChild ), nullptr ); - } - } + addNode( rTree, xRootNode, nullptr ); + } + else + { + const sal_Int32 nChildCount = xRootNode->getChildCount(); + for( sal_Int32 nChild = 0; nChild < nChildCount; nChild++ ) + addNode( rTree, xRootNode->getChildAt( nChild ), nullptr ); } } @@ -660,29 +660,29 @@ OUString SAL_CALL TreeControlPeer::getDefaultExpandedGraphicURL() void SAL_CALL TreeControlPeer::setDefaultExpandedGraphicURL( const OUString& sDefaultExpandedGraphicURL ) { SolarMutexGuard aGuard; - if( msDefaultExpandedGraphicURL != sDefaultExpandedGraphicURL ) - { - if( !sDefaultExpandedGraphicURL.isEmpty() ) - loadImage( sDefaultExpandedGraphicURL, maDefaultExpandedImage ); - else - maDefaultExpandedImage = Image(); + if( msDefaultExpandedGraphicURL == sDefaultExpandedGraphicURL ) + return; - UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow(); + if( !sDefaultExpandedGraphicURL.isEmpty() ) + loadImage( sDefaultExpandedGraphicURL, maDefaultExpandedImage ); + else + maDefaultExpandedImage = Image(); - SvTreeListEntry* pEntry = rTree.First(); - while( pEntry ) + UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow(); + + SvTreeListEntry* pEntry = rTree.First(); + while( pEntry ) + { + ImplContextGraphicItem* pContextGraphicItem = dynamic_cast< ImplContextGraphicItem* >( &pEntry->GetItem( 0 ) ); + if( pContextGraphicItem ) { - ImplContextGraphicItem* pContextGraphicItem = dynamic_cast< ImplContextGraphicItem* >( &pEntry->GetItem( 0 ) ); - if( pContextGraphicItem ) - { - if( pContextGraphicItem->msExpandedGraphicURL.isEmpty() ) - rTree.SetExpandedEntryBmp( pEntry, maDefaultExpandedImage ); - } - pEntry = rTree.Next( pEntry ); + if( pContextGraphicItem->msExpandedGraphicURL.isEmpty() ) + rTree.SetExpandedEntryBmp( pEntry, maDefaultExpandedImage ); } - - msDefaultExpandedGraphicURL = sDefaultExpandedGraphicURL; + pEntry = rTree.Next( pEntry ); } + + msDefaultExpandedGraphicURL = sDefaultExpandedGraphicURL; } @@ -696,29 +696,29 @@ OUString SAL_CALL TreeControlPeer::getDefaultCollapsedGraphicURL() void SAL_CALL TreeControlPeer::setDefaultCollapsedGraphicURL( const OUString& sDefaultCollapsedGraphicURL ) { SolarMutexGuard aGuard; - if( msDefaultCollapsedGraphicURL != sDefaultCollapsedGraphicURL ) - { - if( !sDefaultCollapsedGraphicURL.isEmpty() ) - loadImage( sDefaultCollapsedGraphicURL, maDefaultCollapsedImage ); - else - maDefaultCollapsedImage = Image(); + if( msDefaultCollapsedGraphicURL == sDefaultCollapsedGraphicURL ) + return; - UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow(); + if( !sDefaultCollapsedGraphicURL.isEmpty() ) + loadImage( sDefaultCollapsedGraphicURL, maDefaultCollapsedImage ); + else + maDefaultCollapsedImage = Image(); + + UnoTreeListBoxImpl& rTree = getTreeListBoxOrThrow(); - SvTreeListEntry* pEntry = rTree.First(); - while( pEntry ) + SvTreeListEntry* pEntry = rTree.First(); + while( pEntry ) + { + ImplContextGraphicItem* pContextGraphicItem = dynamic_cast< ImplContextGraphicItem* >( &pEntry->GetItem( 0 ) ); + if( pContextGraphicItem ) { - ImplContextGraphicItem* pContextGraphicItem = dynamic_cast< ImplContextGraphicItem* >( &pEntry->GetItem( 0 ) ); - if( pContextGraphicItem ) - { - if( pContextGraphicItem->msCollapsedGraphicURL.isEmpty() ) - rTree.SetCollapsedEntryBmp( pEntry, maDefaultCollapsedImage ); - } - pEntry = rTree.Next( pEntry ); + if( pContextGraphicItem->msCollapsedGraphicURL.isEmpty() ) + rTree.SetCollapsedEntryBmp( pEntry, maDefaultCollapsedImage ); } - - msDefaultCollapsedGraphicURL = sDefaultCollapsedGraphicURL; + pEntry = rTree.Next( pEntry ); } + + msDefaultCollapsedGraphicURL = sDefaultCollapsedGraphicURL; } @@ -1001,72 +1001,72 @@ void TreeControlPeer::updateTree( const css::awt::tree::TreeDataModelEvent& rEve void TreeControlPeer::updateNode( UnoTreeListBoxImpl const & rTree, const Reference< XTreeNode >& xNode ) { - if( xNode.is() ) - { - UnoTreeListEntry* pNodeEntry = getEntry( xNode, false ); + if( !xNode.is() ) + return; - if( !pNodeEntry ) - { - Reference< XTreeNode > xParentNode( xNode->getParent() ); - UnoTreeListEntry* pParentEntry = nullptr; - sal_uLong nChild = TREELIST_APPEND; + UnoTreeListEntry* pNodeEntry = getEntry( xNode, false ); - if( xParentNode.is() ) - { - pParentEntry = getEntry( xParentNode ); - nChild = xParentNode->getIndex( xNode ); - } + if( !pNodeEntry ) + { + Reference< XTreeNode > xParentNode( xNode->getParent() ); + UnoTreeListEntry* pParentEntry = nullptr; + sal_uLong nChild = TREELIST_APPEND; - pNodeEntry = createEntry( xNode, pParentEntry, nChild ); + if( xParentNode.is() ) + { + pParentEntry = getEntry( xParentNode ); + nChild = xParentNode->getIndex( xNode ); } - updateChildNodes( rTree, xNode, pNodeEntry ); + pNodeEntry = createEntry( xNode, pParentEntry, nChild ); } + + updateChildNodes( rTree, xNode, pNodeEntry ); } void TreeControlPeer::updateChildNodes( UnoTreeListBoxImpl const & rTree, const Reference< XTreeNode >& xParentNode, UnoTreeListEntry* pParentEntry ) { - if( xParentNode.is() && pParentEntry ) - { - UnoTreeListEntry* pCurrentChild = dynamic_cast< UnoTreeListEntry* >( rTree.FirstChild( pParentEntry ) ); + if( !(xParentNode.is() && pParentEntry) ) + return; - const sal_Int32 nChildCount = xParentNode->getChildCount(); - for( sal_Int32 nChild = 0; nChild < nChildCount; nChild++ ) + UnoTreeListEntry* pCurrentChild = dynamic_cast< UnoTreeListEntry* >( rTree.FirstChild( pParentEntry ) ); + + const sal_Int32 nChildCount = xParentNode->getChildCount(); + for( sal_Int32 nChild = 0; nChild < nChildCount; nChild++ ) + { + Reference< XTreeNode > xNode( xParentNode->getChildAt( nChild ) ); + if( !pCurrentChild || ( pCurrentChild->mxNode != xNode ) ) { - Reference< XTreeNode > xNode( xParentNode->getChildAt( nChild ) ); - if( !pCurrentChild || ( pCurrentChild->mxNode != xNode ) ) + UnoTreeListEntry* pNodeEntry = getEntry( xNode, false ); + if( pNodeEntry == nullptr ) { - UnoTreeListEntry* pNodeEntry = getEntry( xNode, false ); - if( pNodeEntry == nullptr ) - { - // child node is not yet part of the tree, add it - pCurrentChild = createEntry( xNode, pParentEntry, nChild ); - } - else if( pNodeEntry != pCurrentChild ) - { - // node is already part of the tree, but not on the correct position - rTree.GetModel()->Move( pNodeEntry, pParentEntry, nChild ); - pCurrentChild = pNodeEntry; - updateEntry( pCurrentChild ); - } + // child node is not yet part of the tree, add it + pCurrentChild = createEntry( xNode, pParentEntry, nChild ); } - else + else if( pNodeEntry != pCurrentChild ) { - // child node has entry and entry is equal to current entry, - // so no structural changes happened + // node is already part of the tree, but not on the correct position + rTree.GetModel()->Move( pNodeEntry, pParentEntry, nChild ); + pCurrentChild = pNodeEntry; updateEntry( pCurrentChild ); } - - pCurrentChild = dynamic_cast< UnoTreeListEntry* >( SvTreeListBox::NextSibling( pCurrentChild ) ); } - - // check if we have entries without nodes left, we need to remove them - while( pCurrentChild ) + else { - UnoTreeListEntry* pNextChild = dynamic_cast< UnoTreeListEntry* >( SvTreeListBox::NextSibling( pCurrentChild ) ); - rTree.GetModel()->Remove( pCurrentChild ); - pCurrentChild = pNextChild; + // child node has entry and entry is equal to current entry, + // so no structural changes happened + updateEntry( pCurrentChild ); } + + pCurrentChild = dynamic_cast< UnoTreeListEntry* >( SvTreeListBox::NextSibling( pCurrentChild ) ); + } + + // check if we have entries without nodes left, we need to remove them + while( pCurrentChild ) + { + UnoTreeListEntry* pNextChild = dynamic_cast< UnoTreeListEntry* >( SvTreeListBox::NextSibling( pCurrentChild ) ); + rTree.GetModel()->Remove( pCurrentChild ); + pCurrentChild = pNextChild; } } diff --git a/svtools/source/uno/unoevent.cxx b/svtools/source/uno/unoevent.cxx index 7125562135b6..4d6d4f130715 100644 --- a/svtools/source/uno/unoevent.cxx +++ b/svtools/source/uno/unoevent.cxx @@ -119,20 +119,20 @@ void getAnyFromMacro(Any& rAny, const SvxMacro& rMacro) // else: bRetValueOK not set // if we don't have a return value, make an empty one - if (! bRetValueOK) - { - // create "None" macro - Sequence<PropertyValue> aSequence(1); + if ( bRetValueOK) + return; - PropertyValue aKindValue; - aKindValue.Name = sEventType; - Any aTmp; - aTmp <<= OUString(sNone); - aKindValue.Value = aTmp; - aSequence[0] = aKindValue; + // create "None" macro + Sequence<PropertyValue> aSequence(1); - rAny <<= aSequence; - } + PropertyValue aKindValue; + aKindValue.Name = sEventType; + Any aTmp; + aTmp <<= OUString(sNone); + aKindValue.Value = aTmp; + aSequence[0] = aKindValue; + + rAny <<= aSequence; } /// @throws IllegalArgumentException diff --git a/svtools/source/uno/unoiface.cxx b/svtools/source/uno/unoiface.cxx index f72207e74133..1c3725a751a5 100644 --- a/svtools/source/uno/unoiface.cxx +++ b/svtools/source/uno/unoiface.cxx @@ -414,54 +414,54 @@ void VCLXMultiLineEdit::setProperty( const OUString& PropertyName, const css::un SolarMutexGuard aGuard; VclPtr< MultiLineEdit > pMultiLineEdit = GetAs< MultiLineEdit >(); - if ( pMultiLineEdit ) + if ( !pMultiLineEdit ) + return; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) { - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) + case BASEPROPERTY_LINE_END_FORMAT: { - case BASEPROPERTY_LINE_END_FORMAT: + sal_Int16 nLineEndType = css::awt::LineEndFormat::LINE_FEED; + OSL_VERIFY( Value >>= nLineEndType ); + switch ( nLineEndType ) { - sal_Int16 nLineEndType = css::awt::LineEndFormat::LINE_FEED; - OSL_VERIFY( Value >>= nLineEndType ); - switch ( nLineEndType ) - { - case css::awt::LineEndFormat::CARRIAGE_RETURN: meLineEndType = LINEEND_CR; break; - case css::awt::LineEndFormat::LINE_FEED: meLineEndType = LINEEND_LF; break; - case css::awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED: meLineEndType = LINEEND_CRLF; break; - default: OSL_FAIL( "VCLXMultiLineEdit::setProperty: invalid line end value!" ); break; - } + case css::awt::LineEndFormat::CARRIAGE_RETURN: meLineEndType = LINEEND_CR; break; + case css::awt::LineEndFormat::LINE_FEED: meLineEndType = LINEEND_LF; break; + case css::awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED: meLineEndType = LINEEND_CRLF; break; + default: OSL_FAIL( "VCLXMultiLineEdit::setProperty: invalid line end value!" ); break; } - break; + } + break; - case BASEPROPERTY_READONLY: - { - bool b; - if ( Value >>= b ) - pMultiLineEdit->SetReadOnly( b ); - } - break; - case BASEPROPERTY_MAXTEXTLEN: - { - sal_Int16 n = sal_Int16(); - if ( Value >>= n ) - pMultiLineEdit->SetMaxTextLen( n ); - } - break; - case BASEPROPERTY_HIDEINACTIVESELECTION: - { - bool b; - if ( Value >>= b ) - { - pMultiLineEdit->EnableFocusSelectionHide( b ); - lcl_setWinBits( pMultiLineEdit, WB_NOHIDESELECTION, !b ); - } - } - break; - default: + case BASEPROPERTY_READONLY: + { + bool b; + if ( Value >>= b ) + pMultiLineEdit->SetReadOnly( b ); + } + break; + case BASEPROPERTY_MAXTEXTLEN: + { + sal_Int16 n = sal_Int16(); + if ( Value >>= n ) + pMultiLineEdit->SetMaxTextLen( n ); + } + break; + case BASEPROPERTY_HIDEINACTIVESELECTION: + { + bool b; + if ( Value >>= b ) { - VCLXWindow::setProperty( PropertyName, Value ); + pMultiLineEdit->EnableFocusSelectionHide( b ); + lcl_setWinBits( pMultiLineEdit, WB_NOHIDESELECTION, !b ); } } + break; + default: + { + VCLXWindow::setProperty( PropertyName, Value ); + } } } @@ -568,25 +568,25 @@ void SAL_CALL VCLXFileControl::setProperty( const OUString& PropertyName, const SolarMutexGuard aGuard; VclPtr< FileControl > pControl = GetAs< FileControl >(); - if ( pControl ) + if ( !pControl ) + return; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) { - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) - { - case BASEPROPERTY_HIDEINACTIVESELECTION: - { - bool bValue(false); - OSL_VERIFY( Value >>= bValue ); + case BASEPROPERTY_HIDEINACTIVESELECTION: + { + bool bValue(false); + OSL_VERIFY( Value >>= bValue ); - lcl_setWinBits( pControl, WB_NOHIDESELECTION, !bValue ); - lcl_setWinBits( &pControl->GetEdit(), WB_NOHIDESELECTION, !bValue ); - } - break; + lcl_setWinBits( pControl, WB_NOHIDESELECTION, !bValue ); + lcl_setWinBits( &pControl->GetEdit(), WB_NOHIDESELECTION, !bValue ); + } + break; - default: - VCLXWindow::setProperty( PropertyName, Value ); - break; - } + default: + VCLXWindow::setProperty( PropertyName, Value ); + break; } } @@ -1306,19 +1306,19 @@ void SVTXFormattedField::setFormatsSupplier(const css::uno::Reference< css::util return; // TODO : how to process ? m_xCurrentSupplier = pNew; - if (pField) + if (!pField) + return; + + // save the actual value + css::uno::Any aCurrent = GetValue(); + pField->SetFormatter(m_xCurrentSupplier->GetNumberFormatter(), false); + if (nKeyToSetDelayed != -1) { - // save the actual value - css::uno::Any aCurrent = GetValue(); - pField->SetFormatter(m_xCurrentSupplier->GetNumberFormatter(), false); - if (nKeyToSetDelayed != -1) - { - pField->SetFormatKey(nKeyToSetDelayed); - nKeyToSetDelayed = -1; - } - SetValue(aCurrent); - NotifyTextListeners(); + pField->SetFormatKey(nKeyToSetDelayed); + nKeyToSetDelayed = -1; } + SetValue(aCurrent); + NotifyTextListeners(); } @@ -1332,19 +1332,19 @@ sal_Int32 SVTXFormattedField::getFormatKey() const void SVTXFormattedField::setFormatKey(sal_Int32 nKey) { VclPtr<FormattedField> pField = GetAs< FormattedField >(); - if (pField) + if (!pField) + return; + + if (pField->GetFormatter()) + pField->SetFormatKey(nKey); + else { - if (pField->GetFormatter()) - pField->SetFormatKey(nKey); - else - { - // probably I am in a block, in which first the key and next the formatter will be set, - // initially this happens quite certain, as the properties are set in alphabetic sequence, - // and the FormatsSupplier is processed before the FormatKey - nKeyToSetDelayed = nKey; - } - NotifyTextListeners(); + // probably I am in a block, in which first the key and next the formatter will be set, + // initially this happens quite certain, as the properties are set in alphabetic sequence, + // and the FormatsSupplier is processed before the FormatKey + nKeyToSetDelayed = nKey; } + NotifyTextListeners(); } @@ -1425,38 +1425,38 @@ void SVTXRoadmap::propertyChange( const css::beans::PropertyChangeEvent& evt ) { SolarMutexGuard aGuard; VclPtr<::svt::ORoadmap> pField = GetAs< svt::ORoadmap >(); - if ( pField ) - { - css::uno::Reference< css::uno::XInterface > xRoadmapItem; - xRoadmapItem = evt.Source; - sal_Int32 nID = 0; - css::uno::Reference< css::beans::XPropertySet > xPropertySet( xRoadmapItem, css::uno::UNO_QUERY ); - css::uno::Any aValue = xPropertySet->getPropertyValue("ID"); - aValue >>= nID; + if ( !pField ) + return; - OUString sPropertyName = evt.PropertyName; - if ( sPropertyName == "Enabled" ) - { - bool bEnable = false; - evt.NewValue >>= bEnable; - pField->EnableRoadmapItem( (RoadmapTypes::ItemId)nID , bEnable ); - } - else if ( sPropertyName == "Label" ) - { - OUString sLabel; - evt.NewValue >>= sLabel; - pField->ChangeRoadmapItemLabel( (RoadmapTypes::ItemId)nID , sLabel ); - } - else if ( sPropertyName == "ID" ) - { - sal_Int32 nNewID = 0; - evt.NewValue >>= nNewID; - evt.OldValue >>= nID; - pField->ChangeRoadmapItemID( (RoadmapTypes::ItemId)nID, (RoadmapTypes::ItemId)nNewID ); - } - // else - // TODO handle Interactive appropriately + css::uno::Reference< css::uno::XInterface > xRoadmapItem; + xRoadmapItem = evt.Source; + sal_Int32 nID = 0; + css::uno::Reference< css::beans::XPropertySet > xPropertySet( xRoadmapItem, css::uno::UNO_QUERY ); + css::uno::Any aValue = xPropertySet->getPropertyValue("ID"); + aValue >>= nID; + + OUString sPropertyName = evt.PropertyName; + if ( sPropertyName == "Enabled" ) + { + bool bEnable = false; + evt.NewValue >>= bEnable; + pField->EnableRoadmapItem( (RoadmapTypes::ItemId)nID , bEnable ); } + else if ( sPropertyName == "Label" ) + { + OUString sLabel; + evt.NewValue >>= sLabel; + pField->ChangeRoadmapItemLabel( (RoadmapTypes::ItemId)nID , sLabel ); + } + else if ( sPropertyName == "ID" ) + { + sal_Int32 nNewID = 0; + evt.NewValue >>= nNewID; + evt.OldValue >>= nID; + pField->ChangeRoadmapItemID( (RoadmapTypes::ItemId)nID, (RoadmapTypes::ItemId)nNewID ); + } +// else + // TODO handle Interactive appropriately } @@ -2051,52 +2051,52 @@ VCLXProgressBar::~VCLXProgressBar() void VCLXProgressBar::ImplUpdateValue() { VclPtr< ProgressBar > pProgressBar = GetAs< ProgressBar >(); - if ( pProgressBar ) - { - sal_Int32 nVal; - sal_Int32 nValMin; - sal_Int32 nValMax; + if ( !pProgressBar ) + return; - // check min and max - if (m_nValueMin < m_nValueMax) - { - nValMin = m_nValueMin; - nValMax = m_nValueMax; - } - else - { - nValMin = m_nValueMax; - nValMax = m_nValueMin; - } + sal_Int32 nVal; + sal_Int32 nValMin; + sal_Int32 nValMax; - // check value - if (m_nValue < nValMin) - { - nVal = nValMin; - } - else if (m_nValue > nValMax) - { - nVal = nValMax; - } - else - { - nVal = m_nValue; - } + // check min and max + if (m_nValueMin < m_nValueMax) + { + nValMin = m_nValueMin; + nValMax = m_nValueMax; + } + else + { + nValMin = m_nValueMax; + nValMax = m_nValueMin; + } - // calculate percent - sal_Int32 nPercent; - if (nValMin != nValMax) - { - nPercent = 100 * (nVal - nValMin) / (nValMax - nValMin); - } - else - { - nPercent = 0; - } + // check value + if (m_nValue < nValMin) + { + nVal = nValMin; + } + else if (m_nValue > nValMax) + { + nVal = nValMax; + } + else + { + nVal = m_nValue; + } - // set progressbar value - pProgressBar->SetValue( (sal_uInt16) nPercent ); + // calculate percent + sal_Int32 nPercent; + if (nValMin != nValMax) + { + nPercent = 100 * (nVal - nValMin) / (nValMax - nValMin); + } + else + { + nPercent = 0; } + + // set progressbar value + pProgressBar->SetValue( (sal_uInt16) nPercent ); } // css::uno::XInterface @@ -2182,56 +2182,56 @@ void VCLXProgressBar::setProperty( const OUString& PropertyName, const css::uno: SolarMutexGuard aGuard; VclPtr< ProgressBar > pProgressBar = GetAs< ProgressBar >(); - if ( pProgressBar ) + if ( !pProgressBar ) + return; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) { - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) + case BASEPROPERTY_PROGRESSVALUE: { - case BASEPROPERTY_PROGRESSVALUE: - { - if ( Value >>= m_nValue ) - ImplUpdateValue(); - } - break; - case BASEPROPERTY_PROGRESSVALUE_MIN: - { - if ( Value >>= m_nValueMin ) - ImplUpdateValue(); - } - break; - case BASEPROPERTY_PROGRESSVALUE_MAX: - { - if ( Value >>= m_nValueMax ) - ImplUpdateValue(); - } - break; - case BASEPROPERTY_FILLCOLOR: + if ( Value >>= m_nValue ) + ImplUpdateValue(); + } + break; + case BASEPROPERTY_PROGRESSVALUE_MIN: + { + if ( Value >>= m_nValueMin ) + ImplUpdateValue(); + } + break; + case BASEPROPERTY_PROGRESSVALUE_MAX: + { + if ( Value >>= m_nValueMax ) + ImplUpdateValue(); + } + break; + case BASEPROPERTY_FILLCOLOR: + { + VclPtr<vcl::Window> pWindow = GetWindow(); + if ( pWindow ) { - VclPtr<vcl::Window> pWindow = GetWindow(); - if ( pWindow ) - { - bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID; + bool bVoid = Value.getValueType().getTypeClass() == css::uno::TypeClass_VOID; - if ( bVoid ) - { - pWindow->SetControlForeground(); - } - else + if ( bVoid ) + { + pWindow->SetControlForeground(); + } + else + { + sal_Int32 nColor = 0; + if ( Value >>= nColor ) { - sal_Int32 nColor = 0; - if ( Value >>= nColor ) - { - Color aColor( nColor ); - pWindow->SetControlForeground( aColor ); - } + Color aColor( nColor ); + pWindow->SetControlForeground( aColor ); } } } - break; - default: - VCLXWindow::setProperty( PropertyName, Value ); - break; } + break; + default: + VCLXWindow::setProperty( PropertyName, Value ); + break; } } |