diff options
Diffstat (limited to 'svtools/source/brwbox')
-rw-r--r-- | svtools/source/brwbox/brwbox1.cxx | 2544 | ||||
-rw-r--r-- | svtools/source/brwbox/brwbox2.cxx | 2150 | ||||
-rw-r--r-- | svtools/source/brwbox/brwbox3.cxx | 571 | ||||
-rw-r--r-- | svtools/source/brwbox/brwhead.cxx | 118 | ||||
-rw-r--r-- | svtools/source/brwbox/brwimpl.hxx | 90 | ||||
-rw-r--r-- | svtools/source/brwbox/datwin.cxx | 772 | ||||
-rw-r--r-- | svtools/source/brwbox/datwin.hxx | 240 | ||||
-rw-r--r-- | svtools/source/brwbox/ebbcontrols.cxx | 630 | ||||
-rw-r--r-- | svtools/source/brwbox/editbrowsebox.cxx | 1419 | ||||
-rw-r--r-- | svtools/source/brwbox/editbrowsebox.hrc | 42 | ||||
-rw-r--r-- | svtools/source/brwbox/editbrowsebox.src | 56 | ||||
-rw-r--r-- | svtools/source/brwbox/editbrowsebox2.cxx | 224 | ||||
-rw-r--r-- | svtools/source/brwbox/editbrowseboximpl.hxx | 46 |
13 files changed, 0 insertions, 8902 deletions
diff --git a/svtools/source/brwbox/brwbox1.cxx b/svtools/source/brwbox/brwbox1.cxx deleted file mode 100644 index 986966072a..0000000000 --- a/svtools/source/brwbox/brwbox1.cxx +++ /dev/null @@ -1,2544 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svtools.hxx" -#include <svtools/brwbox.hxx> -#include <svtools/brwhead.hxx> -#include "datwin.hxx" -#include <tools/debug.hxx> -#include <tools/stream.hxx> - -#include <functional> -#include <algorithm> -#include <com/sun/star/accessibility/AccessibleTableModelChange.hpp> -#include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp> -#include <com/sun/star/accessibility/AccessibleEventId.hpp> -#include <com/sun/star/accessibility/XAccessible.hpp> -#include <tools/multisel.hxx> -#include "brwimpl.hxx" - -DBG_NAME(BrowseBox) - -extern const char* BrowseBoxCheckInvariants( const void* pVoid ); - -#define SCROLL_FLAGS (SCROLL_CLIP | SCROLL_NOCHILDREN) -#define getDataWindow() ((BrowserDataWin*)pDataWin) - -using namespace com::sun::star::accessibility::AccessibleEventId; -using namespace com::sun::star::accessibility::AccessibleTableModelChangeType; -using com::sun::star::accessibility::AccessibleTableModelChange; -using com::sun::star::lang::XComponent; -using namespace ::com::sun::star::uno; -using namespace svt; - -//------------------------------------------------------------------- - -namespace -{ - void disposeAndClearHeaderCell(::svt::BrowseBoxImpl::THeaderCellMap& _rHeaderCell) - { - ::std::for_each( - _rHeaderCell.begin(), - _rHeaderCell.end(), - ::svt::BrowseBoxImpl::THeaderCellMapFunctorDispose() - ); - _rHeaderCell.clear(); - } -} - -//=================================================================== - -void BrowseBox::ConstructImpl( BrowserMode nMode ) -{ - OSL_TRACE( "BrowseBox: %p->ConstructImpl", this ); - bMultiSelection = sal_False; - pColSel = 0; - pDataWin = 0; - pVScroll = 0; - - pDataWin = new BrowserDataWin( this ); - pCols = new BrowserColumns; - m_pImpl.reset( new ::svt::BrowseBoxImpl() ); - - aGridLineColor = Color( COL_LIGHTGRAY ); - InitSettings_Impl( this ); - InitSettings_Impl( pDataWin ); - - bBootstrapped = sal_False; - nDataRowHeight = 0; - nTitleLines = 1; - nFirstCol = 0; - nTopRow = 0; - nCurRow = BROWSER_ENDOFSELECTION; - nCurColId = 0; - bResizing = sal_False; - bSelect = sal_False; - bSelecting = sal_False; - bScrolling = sal_False; - bSelectionIsVisible = sal_False; - bNotToggleSel = sal_False; - bRowDividerDrag = sal_False; - bHit = sal_False; - mbInteractiveRowHeight = sal_False; - bHideSelect = sal_False; - bHideCursor = NO_CURSOR_HIDE; - nRowCount = 0; - m_bFocusOnlyCursor = sal_True; - m_aCursorColor = COL_TRANSPARENT; - m_nCurrentMode = 0; - nControlAreaWidth = USHRT_MAX; - uRow.nSel = BROWSER_ENDOFSELECTION; - - aHScroll.SetLineSize(1); - aHScroll.SetScrollHdl( LINK( this, BrowseBox, ScrollHdl ) ); - aHScroll.SetEndScrollHdl( LINK( this, BrowseBox, EndScrollHdl ) ); - pDataWin->Show(); - - SetMode( nMode ); - bSelectionIsVisible = bKeepHighlight; - bHasFocus = HasChildPathFocus(); - getDataWindow()->nCursorHidden = - ( bHasFocus ? 0 : 1 ) + ( GetUpdateMode() ? 0 : 1 ); -} - -//------------------------------------------------------------------- - -BrowseBox::BrowseBox( Window* pParent, WinBits nBits, BrowserMode nMode ) - :Control( pParent, nBits | WB_3DLOOK ) - ,DragSourceHelper( this ) - ,DropTargetHelper( this ) - ,aHScroll( this, WinBits( WB_HSCROLL ) ) -{ - DBG_CTOR( BrowseBox, NULL ); - ConstructImpl( nMode ); -} - -//------------------------------------------------------------------- - -BrowseBox::BrowseBox( Window* pParent, const ResId& rId, BrowserMode nMode ) - :Control( pParent, rId ) - ,DragSourceHelper( this ) - ,DropTargetHelper( this ) - ,aHScroll( this, WinBits(WB_HSCROLL) ) -{ - DBG_CTOR( BrowseBox, NULL ); - ConstructImpl(nMode); -} -//------------------------------------------------------------------- - -BrowseBox::~BrowseBox() -{ - DBG_DTOR(BrowseBox,BrowseBoxCheckInvariants); - OSL_TRACE( "BrowseBox: %p~", this ); - - if ( m_pImpl->m_pAccessible ) - { - disposeAndClearHeaderCell(m_pImpl->m_aColHeaderCellMap); - disposeAndClearHeaderCell(m_pImpl->m_aRowHeaderCellMap); - m_pImpl->m_pAccessible->dispose(); - } - - Hide(); - delete getDataWindow()->pHeaderBar; - delete getDataWindow()->pCornerWin; - delete pDataWin; - delete pVScroll; - - // free columns-space - for ( size_t i = 0, n = pCols->size(); i < n; ++i ) - delete (*pCols)[ i ]; - pCols->clear(); - delete pCols; - delete pColSel; - if ( bMultiSelection ) - delete uRow.pSel; -} - -//------------------------------------------------------------------- - -short BrowseBox::GetCursorHideCount() const -{ - return getDataWindow()->nCursorHidden; -} - -//------------------------------------------------------------------- - -void BrowseBox::DoShowCursor( const char * ) -{ - short nHiddenCount = --getDataWindow()->nCursorHidden; - if (PaintCursorIfHiddenOnce()) - { - if (1 == nHiddenCount) - DrawCursor(); - } - else - { - if (0 == nHiddenCount) - DrawCursor(); - } -} - -//------------------------------------------------------------------- - -void BrowseBox::DoHideCursor( const char * ) -{ - short nHiddenCount = ++getDataWindow()->nCursorHidden; - if (PaintCursorIfHiddenOnce()) - { - if (2 == nHiddenCount) - DrawCursor(); - } - else - { - if (1 == nHiddenCount) - DrawCursor(); - } -} - -//------------------------------------------------------------------- - -void BrowseBox::SetRealRowCount( const String &rRealRowCount ) -{ - getDataWindow()->aRealRowCount = rRealRowCount; -} - -//------------------------------------------------------------------- - -void BrowseBox::SetFont( const Font& rNewFont ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - pDataWin->SetFont( rNewFont ); - ImpGetDataRowHeight(); -} - -//------------------------------------------------------------------- - -sal_uLong BrowseBox::GetDefaultColumnWidth( const String& _rText ) const -{ - return GetDataWindow().GetTextWidth( _rText ) + GetDataWindow().GetTextWidth( '0' ) * 4; -} - -//------------------------------------------------------------------- - -void BrowseBox::InsertHandleColumn( sal_uLong nWidth ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - pCols->insert( pCols->begin(), new BrowserColumn( 0, Image(), String(), nWidth, GetZoom(), 0 ) ); - FreezeColumn( 0 ); - - // Headerbar anpassen - if ( getDataWindow()->pHeaderBar ) - { - getDataWindow()->pHeaderBar->SetPosSizePixel( - Point(nWidth, 0), - Size( GetOutputSizePixel().Width() - nWidth, GetTitleHeight() ) - ); - } - - ColumnInserted( 0 ); -} - -//------------------------------------------------------------------- - -void BrowseBox::InsertDataColumn( sal_uInt16 nItemId, const XubString& rText, - long nWidth, HeaderBarItemBits nBits, sal_uInt16 nPos ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - if ( nPos < pCols->size() ) - { - BrowserColumns::iterator it = pCols->begin(); - ::std::advance( it, nPos ); - pCols->insert( it, new BrowserColumn( nItemId, Image(), rText, nWidth, GetZoom(), nBits ) ); - } - else - { - pCols->push_back( new BrowserColumn( nItemId, Image(), rText, nWidth, GetZoom(), nBits ) ); - } - if ( nCurColId == 0 ) - nCurColId = nItemId; - - if ( getDataWindow()->pHeaderBar ) - { - // Handlecolumn nicht in der Headerbar - sal_uInt16 nHeaderPos = nPos; - if (nHeaderPos != HEADERBAR_APPEND && !GetColumnId(0)) - nHeaderPos--; - getDataWindow()->pHeaderBar->InsertItem( - nItemId, rText, nWidth, nBits, nHeaderPos ); - } - ColumnInserted( nPos ); -} - -//------------------------------------------------------------------- -sal_uInt16 BrowseBox::ToggleSelectedColumn() -{ - sal_uInt16 nSelectedColId = USHRT_MAX; - if ( pColSel && pColSel->GetSelectCount() ) - { - DoHideCursor( "ToggleSelectedColumn" ); - ToggleSelection(); - nSelectedColId = (*pCols)[ pColSel->FirstSelected() ]->GetId(); - pColSel->SelectAll(sal_False); - } - return nSelectedColId; -} -// ----------------------------------------------------------------------------- -void BrowseBox::SetToggledSelectedColumn(sal_uInt16 _nSelectedColumnId) -{ - if ( pColSel && _nSelectedColumnId != USHRT_MAX ) - { - pColSel->Select( GetColumnPos( _nSelectedColumnId ) ); - ToggleSelection(); - OSL_TRACE( "BrowseBox: %p->SetToggledSelectedColumn", this ); - DoShowCursor( "SetToggledSelectedColumn" ); - } -} -// ----------------------------------------------------------------------------- -void BrowseBox::FreezeColumn( sal_uInt16 nItemId, sal_Bool bFreeze ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - // never unfreeze the handle-column - if ( nItemId == 0 && !bFreeze ) - return; - - // get the position in the current array - size_t nItemPos = GetColumnPos( nItemId ); - if ( nItemPos >= pCols->size() ) - // not available! - return; - - // doesn't the state change? - if ( (*pCols)[ nItemPos ]->IsFrozen() == bFreeze ) - return; - - // remark the column selection - sal_uInt16 nSelectedColId = ToggleSelectedColumn(); - - // freeze or unfreeze? - if ( bFreeze ) - { - // to be moved? - if ( nItemPos != 0 && !(*pCols)[ nItemPos-1 ]->IsFrozen() ) - { - // move to the right of the last frozen column - sal_uInt16 nFirstScrollable = FrozenColCount(); - BrowserColumn *pColumn = (*pCols)[ nItemPos ]; - BrowserColumns::iterator it = pCols->begin(); - ::std::advance( it, nItemPos ); - pCols->erase( it ); - nItemPos = nFirstScrollable; - it = pCols->begin(); - ::std::advance( it, nItemPos ); - pCols->insert( it, pColumn ); - } - - // adjust the number of the first scrollable and visible column - if ( nFirstCol <= nItemPos ) - nFirstCol = nItemPos + 1; - } - else - { - // to be moved? - if ( (sal_Int32)nItemPos != FrozenColCount()-1 ) - { - // move to the leftmost scrollable colum - sal_uInt16 nFirstScrollable = FrozenColCount(); - BrowserColumn *pColumn = (*pCols)[ nItemPos ]; - BrowserColumns::iterator it = pCols->begin(); - ::std::advance( it, nItemPos ); - pCols->erase( it ); - nItemPos = nFirstScrollable; - it = pCols->begin(); - ::std::advance( it, nItemPos ); - pCols->insert( it, pColumn ); - } - - // adjust the number of the first scrollable and visible column - nFirstCol = nItemPos; - } - - // toggle the freeze-state of the column - (*pCols)[ nItemPos ]->Freeze( bFreeze ); - - // align the scrollbar-range - UpdateScrollbars(); - - // repaint - Control::Invalidate(); - getDataWindow()->Invalidate(); - - // remember the column selection - SetToggledSelectedColumn(nSelectedColId); -} - -//------------------------------------------------------------------- - -void BrowseBox::SetColumnPos( sal_uInt16 nColumnId, sal_uInt16 nPos ) -{ - // never set pos of the handle-column - if ( nColumnId == 0 ) - return; - - // do not move handle column - if (nPos == 0 && !(*pCols)[ 0 ]->GetId()) - return; - - // get the position in the current array - sal_uInt16 nOldPos = GetColumnPos( nColumnId ); - if ( nOldPos >= pCols->size() ) - // not available! - 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 ( getDataWindow()->pHeaderBar ) - aDataWinSize.Height() += getDataWindow()->pHeaderBar->GetSizePixel().Height(); - - Rectangle aFromRect( GetFieldRect( nColumnId) ); - aFromRect.Right() += 2*MIN_COLUMNWIDTH; - - sal_uInt16 nNextPos = nOldPos + 1; - if ( nOldPos > nPos ) - nNextPos = nOldPos - 1; - - BrowserColumn *pNextCol = (*pCols)[ nNextPos ]; - Rectangle aNextRect(GetFieldRect( pNextCol->GetId() )); - - // 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 ); - } - - // determine new column area - Rectangle aToRect( GetFieldRect( nColumnId ) ); - aToRect.Right() += 2*MIN_COLUMNWIDTH; - - // do scroll, let redraw - if( pDataWin->GetBackground().IsScrollable() ) - { - long nScroll = -aFromRect.GetWidth(); - Rectangle aScrollArea; - if ( nOldPos > nPos ) - { - long nFrozenWidth = GetFrozenWidth(); - if ( aToRect.Left() < nFrozenWidth ) - aToRect.Left() = nFrozenWidth; - aScrollArea = Rectangle(Point(aToRect.Left(),0), - Point(aNextRect.Right(),aDataWinSize.Height())); - nScroll *= -1; // reverse direction - } - else - aScrollArea = Rectangle(Point(aNextRect.Left(),0), - Point(aToRect.Right(),aDataWinSize.Height())); - - pDataWin->Scroll( nScroll, 0, aScrollArea ); - aToRect.Top() = 0; - aToRect.Bottom() = aScrollArea.Bottom(); - Invalidate( aToRect ); - } - else - pDataWin->Window::Invalidate( INVALIDATE_NOCHILDREN ); - - // adjust header bar positions - if ( getDataWindow()->pHeaderBar ) - { - sal_uInt16 nNewPos = nPos; - if ( !GetColumnId(0) ) - --nNewPos; - getDataWindow()->pHeaderBar->MoveItem(nColumnId,nNewPos); - } - // remember the column selection - SetToggledSelectedColumn(nSelectedColId); - - if ( isAccessibleAlive() ) - { - commitTableEvent( - TABLE_MODEL_CHANGED, - makeAny( AccessibleTableModelChange( - DELETE, - 0, - GetRowCount(), - nOldPos, - nOldPos - ) - ), - Any() - ); - - commitTableEvent( - TABLE_MODEL_CHANGED, - makeAny( AccessibleTableModelChange( - INSERT, - 0, - GetRowCount(), - nPos, - nPos - ) - ), - Any() - ); - } - } - -} - -//------------------------------------------------------------------- - -void BrowseBox::SetColumnTitle( sal_uInt16 nItemId, const String& rTitle ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - // never set title of the handle-column - if ( nItemId == 0 ) - return; - - // get the position in the current array - sal_uInt16 nItemPos = GetColumnPos( nItemId ); - if ( nItemPos >= pCols->size() ) - // not available! - return; - - // does the state change? - BrowserColumn *pCol = (*pCols)[ nItemPos ]; - if ( pCol->Title() != rTitle ) - { - ::rtl::OUString sNew(rTitle); - ::rtl::OUString sOld(pCol->Title()); - - pCol->Title() = rTitle; - - // Headerbar-Column anpassen - if ( getDataWindow()->pHeaderBar ) - getDataWindow()->pHeaderBar->SetItemText( - nItemId ? nItemId : USHRT_MAX - 1, rTitle ); - else - { - // redraw visible colums - if ( GetUpdateMode() && ( pCol->IsFrozen() || nItemPos > nFirstCol ) ) - Invalidate( Rectangle( Point(0,0), - Size( GetOutputSizePixel().Width(), GetTitleHeight() ) ) ); - } - - if ( isAccessibleAlive() ) - { - commitTableEvent( TABLE_COLUMN_DESCRIPTION_CHANGED, - makeAny( sNew ), - makeAny( sOld ) - ); - } - } -} - -//------------------------------------------------------------------- - -void BrowseBox::SetColumnWidth( sal_uInt16 nItemId, sal_uLong nWidth ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - // get the position in the current array - size_t nItemPos = GetColumnPos( nItemId ); - if ( nItemPos >= pCols->size() ) - return; - - // does the state change? - nWidth = QueryColumnResize( nItemId, nWidth ); - if ( nWidth >= LONG_MAX || (*pCols)[ nItemPos ]->Width() != nWidth ) - { - long nOldWidth = (*pCols)[ nItemPos ]->Width(); - - // ggf. letzte Spalte anpassen - if ( IsVisible() && nItemPos == pCols->size() - 1 ) - { - long nMaxWidth = pDataWin->GetSizePixel().Width(); - nMaxWidth -= getDataWindow()->bAutoSizeLastCol - ? GetFieldRect(nItemId).Left() - : GetFrozenWidth(); - if ( ( (BrowserDataWin*)pDataWin )->bAutoSizeLastCol || nWidth > (sal_uLong)nMaxWidth ) - { - nWidth = nMaxWidth > 16 ? nMaxWidth : nOldWidth; - nWidth = QueryColumnResize( nItemId, nWidth ); - } - } - - // OV - // In AutoSizeLastColumn() wird SetColumnWidth mit nWidth==0xffff - // gerufen. Deshalb muss hier nochmal geprueft werden, ob sich die - // Breite tatsaechlich geaendert hat. - if( (sal_uLong)nOldWidth == nWidth ) - return; - - // soll die Aenderung sofort dargestellt werden? - sal_Bool bUpdate = GetUpdateMode() && - ( (*pCols)[ nItemPos ]->IsFrozen() || nItemPos >= nFirstCol ); - - if ( bUpdate ) - { - // Selection hiden - DoHideCursor( "SetColumnWidth" ); - ToggleSelection(); - //!getDataWindow()->Update(); - //!Control::Update(); - } - - // Breite setzen - (*pCols)[ nItemPos ]->SetWidth(nWidth, GetZoom()); - - // scroll and invalidate - if ( bUpdate ) - { - // X-Pos der veraenderten Spalte ermitteln - long nX = 0; - for ( sal_uInt16 nCol = 0; nCol < nItemPos; ++nCol ) - { - BrowserColumn *pCol = (*pCols)[ nCol ]; - if ( pCol->IsFrozen() || nCol >= nFirstCol ) - nX += pCol->Width(); - } - - // eigentliches scroll+invalidate - pDataWin->SetClipRegion(); - sal_Bool bSelVis = bSelectionIsVisible; - bSelectionIsVisible = sal_False; - if( GetBackground().IsScrollable() ) - { - - 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(); - getDataWindow()->Scroll( nWidth-nOldWidth, 0, aScrRect, SCROLL_FLAGS ); - Rectangle aInvRect( nX, 0, nX + std::max( nWidth, (sal_uLong)nOldWidth ), USHRT_MAX ); - Control::Invalidate( aInvRect, INVALIDATE_NOCHILDREN ); - ( (BrowserDataWin*)pDataWin )->Invalidate( aInvRect ); - } - else - { - Control::Invalidate( INVALIDATE_NOCHILDREN ); - getDataWindow()->Window::Invalidate( INVALIDATE_NOCHILDREN ); - } - - - //!getDataWindow()->Update(); - //!Control::Update(); - bSelectionIsVisible = bSelVis; - ToggleSelection(); - DoShowCursor( "SetColumnWidth" ); - } - UpdateScrollbars(); - - // Headerbar-Column anpassen - if ( getDataWindow()->pHeaderBar ) - getDataWindow()->pHeaderBar->SetItemSize( - nItemId ? nItemId : USHRT_MAX - 1, nWidth ); - - // adjust last column - if ( nItemPos != pCols->size() - 1 ) - AutoSizeLastColumn(); - - } -} - -//------------------------------------------------------------------- - -void BrowseBox::AutoSizeLastColumn() -{ - if ( getDataWindow()->bAutoSizeLastCol && - getDataWindow()->GetUpdateMode() ) - { - sal_uInt16 nId = GetColumnId( (sal_uInt16)pCols->size() - 1 ); - SetColumnWidth( nId, LONG_MAX ); - ColumnResized( nId ); - } -} - -//------------------------------------------------------------------- - -void BrowseBox::RemoveColumn( sal_uInt16 nItemId ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - // Spaltenposition ermitteln - sal_uInt16 nPos = GetColumnPos(nItemId); - if ( nPos >= ColCount() ) - // nicht vorhanden - return; - - // Spaltenselektion korrigieren - if ( pColSel ) - pColSel->Remove( nPos ); - - // Spaltencursor korrigieren - if ( nCurColId == nItemId ) - nCurColId = 0; - - // Spalte entfernen - BrowserColumns::iterator it = pCols->begin(); - ::std::advance( it, nPos ); - delete *it; - pCols->erase( it ); - // OJ #93534# - if ( nFirstCol >= nPos && nFirstCol > FrozenColCount() ) - { - OSL_ENSURE(nFirstCol > 0,"FirstCol must be greater zero!"); - --nFirstCol; - } - - // Handlecolumn nicht in der Headerbar - if (nItemId) - { - if ( getDataWindow()->pHeaderBar ) - getDataWindow()->pHeaderBar->RemoveItem( nItemId ); - } - else - { - // Headerbar anpassen - if ( getDataWindow()->pHeaderBar ) - { - getDataWindow()->pHeaderBar->SetPosSizePixel( - Point(0, 0), - Size( GetOutputSizePixel().Width(), GetTitleHeight() ) - ); - } - } - - // vertikalen Scrollbar korrigieren - UpdateScrollbars(); - - // ggf. Repaint ausl"osen - if ( GetUpdateMode() ) - { - getDataWindow()->Invalidate(); - Control::Invalidate(); - if ( getDataWindow()->bAutoSizeLastCol && nPos ==ColCount() ) - SetColumnWidth( GetColumnId( nPos - 1 ), LONG_MAX ); - } - - if ( isAccessibleAlive() ) - { - commitTableEvent( - TABLE_MODEL_CHANGED, - makeAny( AccessibleTableModelChange( DELETE, - 0, - GetRowCount(), - nPos, - nPos - ) - ), - Any() - ); - - commitHeaderBarEvent( - CHILD, - Any(), - makeAny( CreateAccessibleColumnHeader( nPos ) ), - sal_True - ); - } -} - -//------------------------------------------------------------------- - -void BrowseBox::RemoveColumns() -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - size_t nOldCount = pCols->size(); - - // alle Spalten entfernen - for ( size_t i = 0; i < nOldCount; ++i ) - delete (*pCols)[ i ]; - pCols->clear(); - - // Spaltenselektion korrigieren - if ( pColSel ) - { - pColSel->SelectAll(sal_False); - pColSel->SetTotalRange( Range( 0, 0 ) ); - } - - // Spaltencursor korrigieren - nCurColId = 0; - nFirstCol = 0; - - if ( getDataWindow()->pHeaderBar ) - getDataWindow()->pHeaderBar->Clear( ); - - // vertikalen Scrollbar korrigieren - UpdateScrollbars(); - - // ggf. Repaint ausl"osen - if ( GetUpdateMode() ) - { - getDataWindow()->Invalidate(); - 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)) - ); - - // 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() - ); - } - } -} - -//------------------------------------------------------------------- - -String BrowseBox::GetColumnTitle( sal_uInt16 nId ) const -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - sal_uInt16 nItemPos = GetColumnPos( nId ); - if ( nItemPos >= pCols->size() ) - return String(); - return (*pCols)[ nItemPos ]->Title(); -} - -//------------------------------------------------------------------- - -long BrowseBox::GetRowCount() const -{ - return nRowCount; -} - -//------------------------------------------------------------------- - -sal_uInt16 BrowseBox::ColCount() const -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - return (sal_uInt16) pCols->size(); -} - -//------------------------------------------------------------------- - -long BrowseBox::ImpGetDataRowHeight() const -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - BrowseBox *pThis = (BrowseBox*)this; - pThis->nDataRowHeight = pThis->CalcReverseZoom(pDataWin->GetTextHeight() + 2); - pThis->Resize(); - getDataWindow()->Invalidate(); - return nDataRowHeight; -} - -//------------------------------------------------------------------- - -void BrowseBox::SetDataRowHeight( long nPixel ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - nDataRowHeight = CalcReverseZoom(nPixel); - Resize(); - getDataWindow()->Invalidate(); -} - -//------------------------------------------------------------------- - -void BrowseBox::SetTitleLines( sal_uInt16 nLines ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - nTitleLines = nLines; -} - -//------------------------------------------------------------------- - -long BrowseBox::ScrollColumns( long nCols ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - if ( nFirstCol + nCols < 0 || - nFirstCol + nCols >= (long)pCols->size() ) - return 0; - - // implicitly hides cursor while scrolling - StartScroll(); - bScrolling = sal_True; - sal_Bool bScrollable = pDataWin->GetBackground().IsScrollable(); - sal_Bool bInvalidateView = sal_False; - - // scrolling one column to the right? - if ( nCols == 1 ) - { - // update internal value and scrollbar - ++nFirstCol; - aHScroll.SetThumbPos( nFirstCol - FrozenColCount() ); - - if ( !bScrollable ) - { - bInvalidateView = sal_True; - } - else - { - long nDelta = (*pCols)[ nFirstCol-1 ]->Width(); - long nFrozenWidth = GetFrozenWidth(); - - Rectangle aScrollRect( Point( nFrozenWidth + nDelta, 0 ), - Size ( GetOutputSizePixel().Width() - nFrozenWidth - nDelta, - GetTitleHeight() - 1 - ) ); - - // scroll the header bar area (if there is no dedicated HeaderBar control) - if ( !getDataWindow()->pHeaderBar && nTitleLines ) - { - // actually scroll - Scroll( -nDelta, 0, aScrollRect, SCROLL_FLAGS ); - - // invalidate the area of the column which was scrolled out to the left hand side - Rectangle aInvalidateRect( aScrollRect ); - aInvalidateRect.Left() = nFrozenWidth; - aInvalidateRect.Right() = nFrozenWidth + nDelta - 1; - Invalidate( aInvalidateRect ); - } - - // scroll the data-area - aScrollRect.Bottom() = pDataWin->GetOutputSizePixel().Height(); - - // actually scroll - pDataWin->Scroll( -nDelta, 0, aScrollRect, SCROLL_FLAGS ); - - // invalidate the area of the column which was scrolled out to the left hand side - aScrollRect.Left() = nFrozenWidth; - aScrollRect.Right() = nFrozenWidth + nDelta - 1; - getDataWindow()->Invalidate( aScrollRect ); - } - } - - // scrolling one column to the left? - else if ( nCols == -1 ) - { - --nFirstCol; - aHScroll.SetThumbPos( nFirstCol - FrozenColCount() ); - - if ( !bScrollable ) - { - bInvalidateView = sal_True; - } - else - { - long nDelta = (*pCols)[ nFirstCol ]->Width(); - long nFrozenWidth = GetFrozenWidth(); - - Rectangle aScrollRect( Point( nFrozenWidth, 0 ), - Size ( GetOutputSizePixel().Width() - nFrozenWidth, - GetTitleHeight() - 1 - ) ); - - // scroll the header bar area (if there is no dedicated HeaderBar control) - if ( !getDataWindow()->pHeaderBar && nTitleLines ) - { - Scroll( nDelta, 0, aScrollRect, SCROLL_FLAGS ); - } - - // scroll the data-area - aScrollRect.Bottom() = pDataWin->GetOutputSizePixel().Height(); - pDataWin->Scroll( nDelta, 0, aScrollRect, SCROLL_FLAGS ); - } - } - else - { - if ( GetUpdateMode() ) - { - Invalidate( Rectangle( - Point( GetFrozenWidth(), 0 ), - Size( GetOutputSizePixel().Width(), GetTitleHeight() ) ) ); - getDataWindow()->Invalidate( Rectangle( - Point( GetFrozenWidth(), 0 ), - pDataWin->GetSizePixel() ) ); - } - - nFirstCol = nFirstCol + (sal_uInt16)nCols; - aHScroll.SetThumbPos( nFirstCol - FrozenColCount() ); - } - - // ggf. externe Headerbar anpassen - if ( getDataWindow()->pHeaderBar ) - { - long nWidth = 0; - for ( size_t nCol = 0; - nCol < pCols->size() && nCol < nFirstCol; - ++nCol ) - { - // HandleColumn nicht - if ( (*pCols)[ nCol ]->GetId() ) - nWidth += (*pCols)[ nCol ]->Width(); - } - - getDataWindow()->pHeaderBar->SetOffset( nWidth ); - } - - if( bInvalidateView ) - { - Control::Invalidate( INVALIDATE_NOCHILDREN ); - pDataWin->Window::Invalidate( INVALIDATE_NOCHILDREN ); - } - - // implicitly show cursor after scrolling - if ( nCols ) - { - getDataWindow()->Update(); - Update(); - } - bScrolling = sal_False; - EndScroll(); - - return nCols; -} - -//------------------------------------------------------------------- - -long BrowseBox::ScrollRows( long nRows ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - // out of range? - if ( getDataWindow()->bNoScrollBack && nRows < 0 ) - return 0; - - // compute new top row - long nTmpMin = Min( (long)(nTopRow + nRows), (long)(nRowCount - 1) ); - - long nNewTopRow = Max( (long)nTmpMin, (long)0 ); - - if ( nNewTopRow == nTopRow ) - return 0; - - sal_uInt16 nVisibleRows = - (sal_uInt16)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1); - - VisibleRowsChanged(nNewTopRow, nVisibleRows); - - // compute new top row again (nTopRow might have changed!) - nTmpMin = Min( (long)(nTopRow + nRows), (long)(nRowCount - 1) ); - - nNewTopRow = Max( (long)nTmpMin, (long)0 ); - - StartScroll(); - - // scroll area on screen and/or repaint - long nDeltaY = GetDataRowHeight() * ( nNewTopRow - nTopRow ); - long nOldTopRow = nTopRow; - nTopRow = nNewTopRow; - - if ( GetUpdateMode() ) - { - pVScroll->SetRange( Range( 0L, nRowCount ) ); - pVScroll->SetThumbPos( nTopRow ); - - if( pDataWin->GetBackground().IsScrollable() && - Abs( nDeltaY ) > 0 && - Abs( nDeltaY ) < pDataWin->GetSizePixel().Height() ) - { - pDataWin->Scroll( 0, (short)-nDeltaY, SCROLL_FLAGS ); - } - else - getDataWindow()->Invalidate(); - - if ( nTopRow - nOldTopRow ) - getDataWindow()->Update(); - } - - EndScroll(); - - return nTopRow - nOldTopRow; -} - -//------------------------------------------------------------------- - -void BrowseBox::RowModified( long nRow, sal_uInt16 nColId ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - if ( !GetUpdateMode() ) - return; - - Rectangle aRect; - if ( nColId == USHRT_MAX ) - // invalidate the whole row - aRect = Rectangle( Point( 0, (nRow-nTopRow) * GetDataRowHeight() ), - Size( pDataWin->GetSizePixel().Width(), GetDataRowHeight() ) ); - else - { - // invalidate the specific field - aRect = GetFieldRectPixel( nRow, nColId, sal_False ); - } - getDataWindow()->Invalidate( aRect ); -} - -//------------------------------------------------------------------- - -void BrowseBox::Clear() -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - // adjust the total number of rows - DoHideCursor( "Clear" ); - long nOldRowCount = nRowCount; - nRowCount = 0; - nCurRow = BROWSER_ENDOFSELECTION; - nTopRow = 0; - nCurColId = 0; - - // nFirstCol darf nicht zurueckgesetzt werden, da ansonsten das Scrollen - // total durcheinander kommt - // nFirstCol darf nur beim Hinzufuegen oder Loeschen von Spalten geaendert werden - // nFirstCol = 0; ->Falsch!!!! - aHScroll.SetThumbPos( 0 ); - pVScroll->SetThumbPos( 0 ); - - Invalidate(); - UpdateScrollbars(); - SetNoSelection(); - 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 ) ) - ); - - // 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, sal_Bool bDoPaint, sal_Bool bKeepSelection ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - if (nRow < 0) - nRow = 0; - else if (nRow > nRowCount) // maximal = nRowCount - nRow = nRowCount; - - if ( nNumRows <= 0 ) - return; - - // adjust total row count - sal_Bool bLastRow = nRow >= nRowCount; - nRowCount += nNumRows; - - DoHideCursor( "RowInserted" ); - - // must we paint the new rows? - long nOldCurRow = nCurRow; - Size aSz = pDataWin->GetOutputSizePixel(); - if ( bDoPaint && nRow >= nTopRow && - nRow <= nTopRow + aSz.Height() / GetDataRowHeight() ) - { - long nY = (nRow-nTopRow) * GetDataRowHeight(); - if ( !bLastRow ) - { - // scroll down the rows behind the new row - pDataWin->SetClipRegion(); - if( pDataWin->GetBackground().IsScrollable() ) - { - pDataWin->Scroll( 0, GetDataRowHeight() * nNumRows, - Rectangle( Point( 0, nY ), - Size( aSz.Width(), aSz.Height() - nY ) ), - SCROLL_FLAGS ); - } - else - pDataWin->Window::Invalidate( INVALIDATE_NOCHILDREN ); - } - else - // scroll would cause a repaint, so we must explicitly invalidate - pDataWin->Invalidate( Rectangle( Point( 0, nY ), - Size( aSz.Width(), nNumRows * GetDataRowHeight() ) ) ); - } - - // ggf. Top-Row korrigieren - if ( nRow < nTopRow ) - nTopRow += nNumRows; - - // adjust the selection - if ( bMultiSelection ) - uRow.pSel->Insert( nRow, nNumRows ); - else if ( uRow.nSel != BROWSER_ENDOFSELECTION && nRow <= uRow.nSel ) - uRow.nSel += nNumRows; - - // adjust the cursor - if ( nCurRow == BROWSER_ENDOFSELECTION ) - GoToRow( 0, sal_False, bKeepSelection ); - else if ( nRow <= nCurRow ) - GoToRow( nCurRow += nNumRows, sal_False, bKeepSelection ); - - // adjust the vertical scrollbar - if ( bDoPaint ) - { - UpdateScrollbars(); - AutoSizeLastColumn(); - } - - DoShowCursor( "RowInserted" ); - // notify accessible that rows were inserted - if ( isAccessibleAlive() ) - { - commitTableEvent( - TABLE_MODEL_CHANGED, - makeAny( AccessibleTableModelChange( - INSERT, - nRow, - nRow + nNumRows, - 0, - GetColumnCount() - ) - ), - Any() - ); - - for (sal_Int32 i = nRow+1 ; i <= nRowCount ; ++i) - { - commitHeaderBarEvent( - CHILD, - makeAny( CreateAccessibleRowHeader( i ) ), - Any(), - sal_False - ); - } - } - - if ( nCurRow != nOldCurRow ) - CursorMoved(); - - DBG_ASSERT(nRowCount > 0,"BrowseBox: nRowCount <= 0"); - DBG_ASSERT(nCurRow >= 0,"BrowseBox: nCurRow < 0"); - DBG_ASSERT(nCurRow < nRowCount,"nCurRow >= nRowCount"); -} - -//------------------------------------------------------------------- - -void BrowseBox::RowRemoved( long nRow, long nNumRows, sal_Bool bDoPaint ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - if ( nRow < 0 ) - nRow = 0; - else if ( nRow >= nRowCount ) - nRow = nRowCount - 1; - - if ( nNumRows <= 0 ) - return; - - if ( nRowCount <= 0 ) - return; - - if ( bDoPaint ) - { - // hide cursor and selection - OSL_TRACE( "BrowseBox: %p->HideCursor", this ); - ToggleSelection(); - DoHideCursor( "RowRemoved" ); - } - - // adjust total row count - nRowCount -= nNumRows; - if (nRowCount < 0) nRowCount = 0; - long nOldCurRow = nCurRow; - - // adjust the selection - if ( bMultiSelection ) - // uRow.pSel->Remove( nRow, nNumRows ); - for ( long i = 0; i < nNumRows; i++ ) - uRow.pSel->Remove( nRow ); - else if ( nRow < uRow.nSel && uRow.nSel >= nNumRows ) - uRow.nSel -= nNumRows; - else if ( nRow <= uRow.nSel ) - uRow.nSel = BROWSER_ENDOFSELECTION; - - // adjust the cursor - if ( nRowCount == 0 ) // don't compare nRowCount with nNumRows as nNumRows already was subtracted from nRowCount - nCurRow = BROWSER_ENDOFSELECTION; - else if ( nRow < nCurRow ) - { - nCurRow -= Min( nCurRow - nRow, nNumRows ); - // with the above nCurRow points a) to the first row after the removed block or b) to the same line - // as before, but moved up nNumRows - // case a) needs an additional correction if the last n lines were deleted, as 'the first row after the - // removed block' is an invalid position then - // FS - 09/28/99 - 68429 - if (nCurRow == nRowCount) - --nCurRow; - } - else if( nRow == nCurRow && nCurRow == nRowCount ) - nCurRow = nRowCount-1; - - // is the deleted row visible? - Size aSz = pDataWin->GetOutputSizePixel(); - if ( nRow >= nTopRow && - nRow <= nTopRow + aSz.Height() / GetDataRowHeight() ) - { - if ( bDoPaint ) - { - // scroll up the rows behind the deleted row - // if there are Rows behind - if (nRow < nRowCount) - { - long nY = (nRow-nTopRow) * GetDataRowHeight(); - pDataWin->SetClipRegion(); - if( pDataWin->GetBackground().IsScrollable() ) - { - pDataWin->Scroll( 0, - (short) GetDataRowHeight() * nNumRows, - Rectangle( Point( 0, nY ), Size( aSz.Width(), - aSz.Height() - nY + nNumRows*GetDataRowHeight() ) ), - SCROLL_FLAGS ); - } - else - pDataWin->Window::Invalidate( INVALIDATE_NOCHILDREN ); - } - else - { - // Repaint the Rect of the deleted row - Rectangle aRect( - Point( 0, (nRow-nTopRow)*GetDataRowHeight() ), - Size( pDataWin->GetSizePixel().Width(), - nNumRows * GetDataRowHeight() ) ); - pDataWin->Invalidate( aRect ); - } - } - } - // is the deleted row above of the visible area? - else if ( nRow < nTopRow ) - nTopRow = nTopRow >= nNumRows ? nTopRow-nNumRows : 0; - - if ( bDoPaint ) - { - // reshow cursor and selection - ToggleSelection(); - OSL_TRACE( "BrowseBox: %p->ShowCursor", this ); - DoShowCursor( "RowRemoved" ); - - // adjust the vertical scrollbar - UpdateScrollbars(); - AutoSizeLastColumn(); - } - - if ( isAccessibleAlive() ) - { - if ( nRowCount == 0 ) - { - // 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_ROWHEADERBAR ) ) - ); - - // and now append it again - commitBrowseBoxEvent( - CHILD, - makeAny(m_pImpl->getAccessibleHeaderBar(BBTYPE_ROWHEADERBAR)), - Any() - ); - commitBrowseBoxEvent( - CHILD, - Any(), - makeAny( m_pImpl->getAccessibleTable() ) - ); - - // and now append it again - commitBrowseBoxEvent( - CHILD, - makeAny( m_pImpl->getAccessibleTable() ), - Any() - ); - } - else - { - commitTableEvent( - TABLE_MODEL_CHANGED, - makeAny( AccessibleTableModelChange( - DELETE, - nRow, - nRow + nNumRows, - 0, - GetColumnCount() - ) - ), - Any() - ); - - for (sal_Int32 i = nRow+1 ; i <= (nRow+nNumRows) ; ++i) - { - commitHeaderBarEvent( - CHILD, - Any(), - makeAny( CreateAccessibleRowHeader( i ) ), - sal_False - ); - } - } - } - - if ( nOldCurRow != nCurRow ) - CursorMoved(); - - DBG_ASSERT(nRowCount >= 0,"BrowseBox: nRowCount < 0"); - DBG_ASSERT(nCurRow >= 0 || nRowCount == 0,"BrowseBox: nCurRow < 0 && nRowCount != 0"); - DBG_ASSERT(nCurRow < nRowCount,"nCurRow >= nRowCount"); -} - -//------------------------------------------------------------------- - -sal_Bool BrowseBox::GoToRow( long nRow) -{ - return GoToRow(nRow, sal_False, sal_False); -} - -//------------------------------------------------------------------- - -sal_Bool BrowseBox::GoToRow( long nRow, sal_Bool bRowColMove, sal_Bool bKeepSelection ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - long nOldCurRow = nCurRow; - - // nothing to do? - if ( nRow == nCurRow && ( bMultiSelection || uRow.nSel == nRow ) ) - return sal_True; - - // out of range? - if ( nRow < 0 || nRow >= nRowCount ) - return sal_False; - - // nicht erlaubt? - if ( ( !bRowColMove && !IsCursorMoveAllowed( nRow, nCurColId ) ) ) - return sal_False; - - if ( getDataWindow()->bNoScrollBack && nRow < nTopRow ) - nRow = nTopRow; - - // compute the last visible row - Size aSz( pDataWin->GetSizePixel() ); - sal_uInt16 nVisibleRows = sal_uInt16( aSz.Height() / GetDataRowHeight() - 1 ); - long nLastRow = nTopRow + nVisibleRows; - - // suspend Updates - getDataWindow()->EnterUpdateLock(); - - // ggf. altes Highlight weg - if ( !bMultiSelection && !bKeepSelection ) - ToggleSelection(); - DoHideCursor( "GoToRow" ); - - // must we scroll? - sal_Bool bWasVisible = bSelectionIsVisible; - if (! bMultiSelection) - { - if( !bKeepSelection ) - bSelectionIsVisible = sal_False; - } - if ( nRow < nTopRow ) - ScrollRows( nRow - nTopRow ); - else if ( nRow > nLastRow ) - ScrollRows( nRow - nLastRow ); - bSelectionIsVisible = bWasVisible; - - // adjust cursor (selection) and thumb - if ( GetUpdateMode() ) - pVScroll->SetThumbPos( nTopRow ); - - // relative positioning (because nCurRow might have changed in the meantime)! - if (nCurRow != BROWSER_ENDOFSELECTION ) - nCurRow = nCurRow + (nRow - nOldCurRow); - - // make sure that the current position is valid - if (nCurRow == BROWSER_ENDOFSELECTION && nRowCount > 0) - nCurRow = 0; - else if ( nCurRow >= nRowCount ) - nCurRow = nRowCount - 1; - aSelRange = Range( nCurRow, nCurRow ); - - // ggf. neues Highlight anzeigen - if ( !bMultiSelection && !bKeepSelection ) - uRow.nSel = nRow; - - // resume Updates - getDataWindow()->LeaveUpdateLock(); - - // Cursor+Highlight - if ( !bMultiSelection && !bKeepSelection) - ToggleSelection(); - DoShowCursor( "GoToRow" ); - if ( !bRowColMove && nOldCurRow != nCurRow ) - CursorMoved(); - - if ( !bMultiSelection && !bKeepSelection ) - { - if ( !bSelecting ) - Select(); - else - bSelect = sal_True; - } - return sal_True; -} - -//------------------------------------------------------------------- - -sal_Bool BrowseBox::GoToColumnId( sal_uInt16 nColId) -{ - return GoToColumnId(nColId,sal_True,sal_False); -} - - -sal_Bool BrowseBox::GoToColumnId( sal_uInt16 nColId, sal_Bool bMakeVisible, sal_Bool bRowColMove) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - if (!bColumnCursor) - return sal_False; - - // erlaubt? - if (!bRowColMove && !IsCursorMoveAllowed( nCurRow, nColId ) ) - return sal_False; - - if ( nColId != nCurColId || (bMakeVisible && !IsFieldVisible(nCurRow, nColId, sal_True))) - { - sal_uInt16 nNewPos = GetColumnPos(nColId); - BrowserColumn* pColumn = (nNewPos < pCols->size()) ? (*pCols)[ nNewPos ] : NULL; - DBG_ASSERT( pColumn, "no column object - invalid id?" ); - if ( !pColumn ) - return sal_False; - - DoHideCursor( "GoToColumnId" ); - nCurColId = nColId; - - sal_uInt16 nFirstPos = nFirstCol; - sal_uInt16 nWidth = (sal_uInt16)pColumn->Width(); - sal_uInt16 nLastPos = GetColumnAtXPosPixel( - pDataWin->GetSizePixel().Width()-nWidth, sal_False ); - sal_uInt16 nFrozen = FrozenColCount(); - if ( bMakeVisible && nLastPos && - nNewPos >= nFrozen && ( nNewPos < nFirstPos || nNewPos > nLastPos ) ) - { - if ( nNewPos < nFirstPos ) - ScrollColumns( nNewPos-nFirstPos ); - else if ( nNewPos > nLastPos ) - ScrollColumns( nNewPos-nLastPos ); - } - - DoShowCursor( "GoToColumnId" ); - if (!bRowColMove) - CursorMoved(); - return sal_True; - } - return sal_True; -} - -//------------------------------------------------------------------- - -sal_Bool BrowseBox::GoToRowColumnId( long nRow, sal_uInt16 nColId ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - // out of range? - if ( nRow < 0 || nRow >= nRowCount ) - return sal_False; - - if (!bColumnCursor) - return sal_False; - - // nothing to do ? - if ( nRow == nCurRow && ( bMultiSelection || uRow.nSel == nRow ) && - nColId == nCurColId && IsFieldVisible(nCurRow, nColId, sal_True)) - return sal_True; - - // erlaubt? - if (!IsCursorMoveAllowed(nRow, nColId)) - return sal_False; - - DoHideCursor( "GoToRowColumnId" ); - sal_Bool bMoved = GoToRow(nRow, sal_True) && GoToColumnId(nColId, sal_True, sal_True); - DoShowCursor( "GoToRowColumnId" ); - - if (bMoved) - CursorMoved(); - - return bMoved; -} - -//------------------------------------------------------------------- - -void BrowseBox::SetNoSelection() -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - // is there no selection - if ( ( !pColSel || !pColSel->GetSelectCount() ) && - ( ( !bMultiSelection && uRow.nSel == BROWSER_ENDOFSELECTION ) || - ( bMultiSelection && !uRow.pSel->GetSelectCount() ) ) ) - // nothing to do - return; - - OSL_TRACE( "BrowseBox: %p->HideCursor", this ); - ToggleSelection(); - - // unselect all - if ( bMultiSelection ) - uRow.pSel->SelectAll(sal_False); - else - uRow.nSel = BROWSER_ENDOFSELECTION; - if ( pColSel ) - pColSel->SelectAll(sal_False); - if ( !bSelecting ) - Select(); - else - bSelect = sal_True; - - // restore screen - OSL_TRACE( "BrowseBox: %p->ShowCursor", this ); - - if ( isAccessibleAlive() ) - { - commitTableEvent( - SELECTION_CHANGED, - Any(), - Any() - ); - } -} - -//------------------------------------------------------------------- - -void BrowseBox::SelectAll() -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - if ( !bMultiSelection ) - return; - - OSL_TRACE( "BrowseBox: %p->HideCursor", this ); - ToggleSelection(); - - // select all rows - if ( pColSel ) - pColSel->SelectAll(sal_False); - uRow.pSel->SelectAll(sal_True); - - // Handle-Column nicht highlighten - BrowserColumn *pFirstCol = (*pCols)[ 0 ]; - long nOfsX = pFirstCol->GetId() ? 0 : pFirstCol->Width(); - - // highlight the row selection - if ( !bHideSelect ) - { - Rectangle aHighlightRect; - sal_uInt16 nVisibleRows = - (sal_uInt16)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1); - for ( long nRow = Max( nTopRow, uRow.pSel->FirstSelected() ); - nRow != BROWSER_ENDOFSELECTION && nRow < nTopRow + nVisibleRows; - nRow = uRow.pSel->NextSelected() ) - aHighlightRect.Union( Rectangle( - Point( nOfsX, (nRow-nTopRow)*GetDataRowHeight() ), - Size( pDataWin->GetSizePixel().Width(), GetDataRowHeight() ) ) ); - pDataWin->Invalidate( aHighlightRect ); - } - - if ( !bSelecting ) - Select(); - else - bSelect = sal_True; - - // restore screen - OSL_TRACE( "BrowseBox: %p->ShowCursor", this ); - - if ( isAccessibleAlive() ) - { - commitTableEvent( - SELECTION_CHANGED, - Any(), - Any() - ); - commitHeaderBarEvent( - SELECTION_CHANGED, - Any(), - Any(), - sal_True - ); // column header event - - commitHeaderBarEvent( - SELECTION_CHANGED, - Any(), - Any(), - sal_False - ); // row header event - } -} - -//------------------------------------------------------------------- - -void BrowseBox::SelectRow( long nRow, sal_Bool _bSelect, sal_Bool bExpand ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - if ( !bMultiSelection ) - { - // deselecting is impossible, selecting via cursor - if ( _bSelect ) - GoToRow(nRow, sal_False); - return; - } - - OSL_TRACE( "BrowseBox: %p->HideCursor", this ); - - // remove old selection? - if ( !bExpand || !bMultiSelection ) - { - ToggleSelection(); - if ( bMultiSelection ) - uRow.pSel->SelectAll(sal_False); - else - uRow.nSel = BROWSER_ENDOFSELECTION; - if ( pColSel ) - pColSel->SelectAll(sal_False); - } - - // set new selection - if ( !bHideSelect - && ( ( bMultiSelection - && uRow.pSel->GetTotalRange().Max() >= nRow - && uRow.pSel->Select( nRow, _bSelect ) - ) - || ( !bMultiSelection - && ( uRow.nSel = nRow ) != BROWSER_ENDOFSELECTION ) - ) - ) - { - // Handle-Column nicht highlighten - BrowserColumn *pFirstCol = (*pCols)[ 0 ]; - long nOfsX = pFirstCol->GetId() ? 0 : pFirstCol->Width(); - - // highlight only newly selected part - Rectangle aRect( - Point( nOfsX, (nRow-nTopRow)*GetDataRowHeight() ), - Size( pDataWin->GetSizePixel().Width(), GetDataRowHeight() ) ); - pDataWin->Invalidate( aRect ); - } - - if ( !bSelecting ) - Select(); - else - bSelect = sal_True; - - // restore screen - OSL_TRACE( "BrowseBox: %p->ShowCursor", this ); - - if ( isAccessibleAlive() ) - { - commitTableEvent( - SELECTION_CHANGED, - Any(), - Any() - ); - commitHeaderBarEvent( - SELECTION_CHANGED, - Any(), - Any(), - sal_False - ); // row header event - } -} - -//------------------------------------------------------------------- - -long BrowseBox::GetSelectRowCount() const -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - return bMultiSelection ? uRow.pSel->GetSelectCount() : - uRow.nSel == BROWSER_ENDOFSELECTION ? 0 : 1; -} - -//------------------------------------------------------------------- - -void BrowseBox::SelectColumnPos( sal_uInt16 nNewColPos, sal_Bool _bSelect, sal_Bool bMakeVisible ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - if ( !bColumnCursor || nNewColPos == BROWSER_INVALIDID ) - return; - - if ( !bMultiSelection ) - { - if ( _bSelect ) - GoToColumnId( (*pCols)[ nNewColPos ]->GetId(), bMakeVisible ); - return; - } - else - { - if ( !GoToColumnId( (*pCols)[ nNewColPos ]->GetId(), bMakeVisible ) ) - return; - } - - OSL_TRACE( "BrowseBox: %p->HideCursor", this ); - ToggleSelection(); - if ( bMultiSelection ) - uRow.pSel->SelectAll(sal_False); - else - uRow.nSel = BROWSER_ENDOFSELECTION; - pColSel->SelectAll(sal_False); - - if ( pColSel->Select( nNewColPos, _bSelect ) ) - { - // GoToColumnId( pCols->GetObject(nNewColPos)->GetId(), bMakeVisible ); - - // only highlight painted areas - pDataWin->Update(); - Rectangle aFieldRectPix( GetFieldRectPixel( nCurRow, nCurColId, sal_False ) ); - Rectangle aRect( - Point( aFieldRectPix.Left() - MIN_COLUMNWIDTH, 0 ), - Size( (*pCols)[ nNewColPos ]->Width(), - pDataWin->GetOutputSizePixel().Height() ) ); - pDataWin->Invalidate( aRect ); - if ( !bSelecting ) - Select(); - else - bSelect = sal_True; - - if ( isAccessibleAlive() ) - { - commitTableEvent( - SELECTION_CHANGED, - Any(), - Any() - ); - commitHeaderBarEvent( - SELECTION_CHANGED, - Any(), - Any(), - sal_True - ); // column header event - } - } - - // restore screen - OSL_TRACE( "BrowseBox: %p->ShowCursor", this ); -} - -//------------------------------------------------------------------- - -sal_uInt16 BrowseBox::GetSelectColumnCount() const -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - // while bAutoSelect (==!pColSel), 1 if any rows (yes rows!) else none - return pColSel ? (sal_uInt16) pColSel->GetSelectCount() : - nCurRow >= 0 ? 1 : 0; -} - -//------------------------------------------------------------------- -long BrowseBox::FirstSelectedColumn( ) const -{ - return pColSel ? pColSel->FirstSelected() : BROWSER_ENDOFSELECTION; -} - -//------------------------------------------------------------------- - -long BrowseBox::FirstSelectedRow( sal_Bool bInverse ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - return bMultiSelection ? uRow.pSel->FirstSelected(bInverse) : uRow.nSel; -} - -//------------------------------------------------------------------- - -long BrowseBox::NextSelectedRow() -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - return bMultiSelection ? uRow.pSel->NextSelected() : BROWSER_ENDOFSELECTION; -} - -//------------------------------------------------------------------- - -long BrowseBox::LastSelectedRow() -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - return bMultiSelection ? uRow.pSel->LastSelected() : uRow.nSel; -} - -//------------------------------------------------------------------- - -bool BrowseBox::IsRowSelected( long nRow ) const -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - return bMultiSelection ? uRow.pSel->IsSelected(nRow) : nRow == uRow.nSel; -} - -//------------------------------------------------------------------- - -bool BrowseBox::IsColumnSelected( sal_uInt16 nColumnId ) const -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - return pColSel ? pColSel->IsSelected( GetColumnPos(nColumnId) ) : - nCurColId == nColumnId; -} - -//------------------------------------------------------------------- - -sal_Bool BrowseBox::MakeFieldVisible -( - long nRow, // Zeilen-Nr des Feldes (beginnend mit 0) - sal_uInt16 nColId, // Spalten-Id des Feldes - sal_Bool bComplete // (== sal_False), sal_True => vollst"andig sichtbar machen -) - -/* [Beschreibung] - - Macht das durch 'nRow' und 'nColId' beschriebene Feld durch - entsprechendes scrollen sichtbar. Ist 'bComplete' gesetzt, dann wird - gefordert, da\s das Feld ganz sichtbar wird. - - [R"uckgabewert] - - sal_Bool sal_True - Das angegebene Feld wurde sichtbar gemacht, bzw. war - bereits sichtbar. - - sal_False - Das angegebene Feld konnte nicht sichtbar bzw. bei - 'bComplete' nicht vollst"andig sichtbar gemacht werden. -*/ - -{ - Size aTestSize = pDataWin->GetSizePixel(); - - if ( !bBootstrapped || - ( aTestSize.Width() == 0 && aTestSize.Height() == 0 ) ) - return sal_False; - - // ist es schon sichtbar? - sal_Bool bVisible = IsFieldVisible( nRow, nColId, bComplete ); - if ( bVisible ) - return sal_True; - - // Spaltenposition und Feld-Rechteck und Ausgabebereich berechnen - sal_uInt16 nColPos = GetColumnPos( nColId ); - Rectangle aFieldRect = GetFieldRectPixel( nRow, nColId, sal_False ); - Rectangle aDataRect = Rectangle( Point(0, 0), pDataWin->GetSizePixel() ); - - // links au\serhalb? - if ( nColPos >= FrozenColCount() && nColPos < nFirstCol ) - // => nach rechts scrollen - ScrollColumns( nColPos - nFirstCol ); - - // solange rechts au\serhalb - while ( aDataRect.Right() < ( bComplete - ? aFieldRect.Right() - : aFieldRect.Left()+aFieldRect.GetWidth()/2 ) ) - { - // => nach links scrollen - if ( ScrollColumns( 1 ) != 1 ) - // nichts mehr zu scrollen - break; - aFieldRect = GetFieldRectPixel( nRow, nColId, sal_False ); - } - - // oben au\serhalb? - if ( nRow < nTopRow ) - // nach unten scrollen - ScrollRows( nRow - nTopRow ); - - // unten au\serhalb? - long nBottomRow = nTopRow + GetVisibleRows(); - // OV: damit nBottomRow die Nummer der letzten sichtbaren Zeile ist - // (Zaehlung ab Null!), muss sie dekrementiert werden. - // Beispiel: BrowseBox enthaelt genau einen Eintrag. nBottomRow := 0 + 1 - 1 - if( nBottomRow ) - nBottomRow--; - - if ( nRow > nBottomRow ) - // nach oben scrollen - ScrollRows( nRow - nBottomRow ); - - // jetzt kann es immer noch nicht passen, z.B. weil Window zu klein - return IsFieldVisible( nRow, nColId, bComplete ); -} - -//------------------------------------------------------------------- - -sal_Bool BrowseBox::IsFieldVisible( long nRow, sal_uInt16 nColumnId, - sal_Bool bCompletely ) const -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - // durch frozen-Column verdeckt? - sal_uInt16 nColPos = GetColumnPos( nColumnId ); - if ( nColPos >= FrozenColCount() && nColPos < nFirstCol ) - return sal_False; - - Rectangle aRect( ImplFieldRectPixel( nRow, nColumnId ) ); - if ( aRect.IsEmpty() ) - return sal_False; - - // get the visible area - Rectangle aOutRect( Point(0, 0), pDataWin->GetOutputSizePixel() ); - - if ( bCompletely ) - // test if the field is completely visible - return aOutRect.IsInside( aRect ); - else - // test if the field is partly of completely visible - return !aOutRect.Intersection( aRect ).IsEmpty(); -} - -//------------------------------------------------------------------- - -Rectangle BrowseBox::GetFieldRectPixel( long nRow, sal_uInt16 nColumnId, - sal_Bool bRelToBrowser) const -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - // get the rectangle relative to DataWin - Rectangle aRect( ImplFieldRectPixel( nRow, nColumnId ) ); - if ( aRect.IsEmpty() ) - return aRect; - - // adjust relative to BrowseBox's output area - Point aTopLeft( aRect.TopLeft() ); - if ( bRelToBrowser ) - { - aTopLeft = pDataWin->OutputToScreenPixel( aTopLeft ); - aTopLeft = ScreenToOutputPixel( aTopLeft ); - } - - return Rectangle( aTopLeft, aRect.GetSize() ); -} - -//------------------------------------------------------------------- - -Rectangle BrowseBox::GetRowRectPixel( long nRow, sal_Bool bRelToBrowser ) const -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - // get the rectangle relative to DataWin - Rectangle aRect; - if ( nTopRow > nRow ) - // row is above visible area - return aRect; - aRect = Rectangle( - Point( 0, GetDataRowHeight() * (nRow-nTopRow) ), - Size( pDataWin->GetOutputSizePixel().Width(), GetDataRowHeight() ) ); - if ( aRect.TopLeft().Y() > pDataWin->GetOutputSizePixel().Height() ) - // row is below visible area - return aRect; - - // adjust relative to BrowseBox's output area - Point aTopLeft( aRect.TopLeft() ); - if ( bRelToBrowser ) - { - aTopLeft = pDataWin->OutputToScreenPixel( aTopLeft ); - aTopLeft = ScreenToOutputPixel( aTopLeft ); - } - - return Rectangle( aTopLeft, aRect.GetSize() ); -} - -//------------------------------------------------------------------- - -Rectangle BrowseBox::ImplFieldRectPixel( long nRow, sal_uInt16 nColumnId ) const -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - // compute the X-coordinte realtiv to DataWin by accumulation - long nColX = 0; - sal_uInt16 nFrozenCols = FrozenColCount(); - size_t nCol; - for ( nCol = 0; - nCol < pCols->size() && (*pCols)[ nCol ]->GetId() != nColumnId; - ++nCol ) - if ( (*pCols)[ nCol ]->IsFrozen() || nCol >= nFirstCol ) - nColX += (*pCols)[ nCol ]->Width(); - - if ( nCol >= pCols->size() || ( nCol >= nFrozenCols && nCol < nFirstCol ) ) - return Rectangle(); - - // compute the Y-coordinate relative to DataWin - long nRowY = GetDataRowHeight(); - if ( nRow != BROWSER_ENDOFSELECTION ) // #105497# OJ - nRowY = ( nRow - nTopRow ) * GetDataRowHeight(); - - // assemble the Rectangle relative to DataWin - return Rectangle( - Point( nColX + MIN_COLUMNWIDTH, nRowY ), - Size( (*pCols)[ nCol ]->Width() - 2*MIN_COLUMNWIDTH, - GetDataRowHeight() - 1 ) ); -} - -//------------------------------------------------------------------- - -long BrowseBox::GetRowAtYPosPixel( long nY, sal_Bool bRelToBrowser ) const -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - // compute the Y-coord - if ( bRelToBrowser ) - { - Point aDataTopLeft = pDataWin->OutputToScreenPixel( Point(0, 0) ); - Point aTopLeft = OutputToScreenPixel( Point(0, 0) ); - nY -= aDataTopLeft.Y() - aTopLeft.Y(); - } - - // no row there (e.g. in the header) - if ( nY < 0 || nY >= pDataWin->GetOutputSizePixel().Height() ) - return -1; - - return nY / GetDataRowHeight() + nTopRow; -} - -//------------------------------------------------------------------- - -Rectangle BrowseBox::GetFieldRect( sal_uInt16 nColumnId ) const -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - return GetFieldRectPixel( nCurRow, nColumnId ); -} - -//------------------------------------------------------------------- - -sal_uInt16 BrowseBox::GetColumnAtXPosPixel( long nX, sal_Bool ) const -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - // accumulate the withds of the visible columns - long nColX = 0; - for ( size_t nCol = 0; nCol < pCols->size(); ++nCol ) - { - BrowserColumn *pCol = (*pCols)[ nCol ]; - if ( pCol->IsFrozen() || nCol >= nFirstCol ) - nColX += pCol->Width(); - - if ( nColX > nX ) - return nCol; - } - - return BROWSER_INVALIDID; -} - -//------------------------------------------------------------------- - -void BrowseBox::ReserveControlArea( sal_uInt16 nWidth ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - if ( nWidth != nControlAreaWidth ) - { - OSL_ENSURE(nWidth,"Control aera of 0 is not allowed, Use USHRT_MAX instead!"); - nControlAreaWidth = nWidth; - UpdateScrollbars(); - } -} - -//------------------------------------------------------------------- - -Rectangle BrowseBox::GetControlArea() const -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - return Rectangle( - Point( 0, GetOutputSizePixel().Height() - aHScroll.GetSizePixel().Height() ), - Size( GetOutputSizePixel().Width() - aHScroll.GetSizePixel().Width(), - aHScroll.GetSizePixel().Height() ) ); -} - -//------------------------------------------------------------------- - -void BrowseBox::SetMode( BrowserMode nMode ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - getDataWindow()->bAutoHScroll = BROWSER_AUTO_HSCROLL == ( nMode & BROWSER_AUTO_HSCROLL ); - getDataWindow()->bAutoVScroll = BROWSER_AUTO_VSCROLL == ( nMode & BROWSER_AUTO_VSCROLL ); - getDataWindow()->bNoHScroll = BROWSER_NO_HSCROLL == ( nMode & BROWSER_NO_HSCROLL ); - getDataWindow()->bNoVScroll = BROWSER_NO_VSCROLL == ( nMode & BROWSER_NO_VSCROLL ); - - DBG_ASSERT( !( getDataWindow()->bAutoHScroll && getDataWindow()->bNoHScroll ), - "BrowseBox::SetMode: AutoHScroll *and* NoHScroll?" ); - DBG_ASSERT( !( getDataWindow()->bAutoVScroll && getDataWindow()->bNoVScroll ), - "BrowseBox::SetMode: AutoVScroll *and* NoVScroll?" ); - if ( getDataWindow()->bAutoHScroll ) - getDataWindow()->bNoHScroll = sal_False; - if ( getDataWindow()->bAutoVScroll ) - getDataWindow()->bNoVScroll = sal_False; - - if ( getDataWindow()->bNoHScroll ) - aHScroll.Hide(); - - nControlAreaWidth = USHRT_MAX; - - getDataWindow()->bNoScrollBack = - BROWSER_NO_SCROLLBACK == ( nMode & BROWSER_NO_SCROLLBACK); - - long nOldRowSel = bMultiSelection ? uRow.pSel->FirstSelected() : uRow.nSel; - MultiSelection *pOldRowSel = bMultiSelection ? uRow.pSel : 0; - MultiSelection *pOldColSel = pColSel; - - delete pVScroll; - - bThumbDragging = ( nMode & BROWSER_THUMBDRAGGING ) == BROWSER_THUMBDRAGGING; - bMultiSelection = ( nMode & BROWSER_MULTISELECTION ) == BROWSER_MULTISELECTION; - bColumnCursor = ( nMode & BROWSER_COLUMNSELECTION ) == BROWSER_COLUMNSELECTION; - bKeepHighlight = ( nMode & BROWSER_KEEPSELECTION ) == BROWSER_KEEPSELECTION; - - bHideSelect = ((nMode & BROWSER_HIDESELECT) == BROWSER_HIDESELECT); - // default: do not hide the cursor at all (untaken scrolling and such) - bHideCursor = NO_CURSOR_HIDE; - - if ( BROWSER_SMART_HIDECURSOR == ( nMode & BROWSER_SMART_HIDECURSOR ) ) - { // smart cursor hide overrules hard cursor hide - bHideCursor = SMART_CURSOR_HIDE; - } - else if ( BROWSER_HIDECURSOR == ( nMode & BROWSER_HIDECURSOR ) ) - { - bHideCursor = HARD_CURSOR_HIDE; - } - - m_bFocusOnlyCursor = ((nMode & BROWSER_CURSOR_WO_FOCUS) == 0); - - bHLines = ( nMode & BROWSER_HLINESFULL ) == BROWSER_HLINESFULL; - bVLines = ( nMode & BROWSER_VLINESFULL ) == BROWSER_VLINESFULL; - bHDots = ( nMode & BROWSER_HLINESDOTS ) == BROWSER_HLINESDOTS; - bVDots = ( nMode & BROWSER_VLINESDOTS ) == BROWSER_VLINESDOTS; - - WinBits nVScrollWinBits = - WB_VSCROLL | ( ( nMode & BROWSER_THUMBDRAGGING ) ? WB_DRAG : 0 ); - pVScroll = ( nMode & BROWSER_TRACKING_TIPS ) == BROWSER_TRACKING_TIPS - ? new BrowserScrollBar( this, nVScrollWinBits, - (BrowserDataWin*) pDataWin ) - : new ScrollBar( this, nVScrollWinBits ); - pVScroll->SetLineSize( 1 ); - pVScroll->SetPageSize(1); - pVScroll->SetScrollHdl( LINK( this, BrowseBox, ScrollHdl ) ); - pVScroll->SetEndScrollHdl( LINK( this, BrowseBox, EndScrollHdl ) ); - - getDataWindow()->bAutoSizeLastCol = - BROWSER_AUTOSIZE_LASTCOL == ( nMode & BROWSER_AUTOSIZE_LASTCOL ); - getDataWindow()->bOwnDataChangedHdl = - BROWSER_OWN_DATACHANGED == ( nMode & BROWSER_OWN_DATACHANGED ); - - // Headerbar erzeugen, was passiert, wenn eine erzeugt werden mu� und schon Spalten bestehen ? - if ( BROWSER_HEADERBAR_NEW == ( nMode & BROWSER_HEADERBAR_NEW ) ) - { - if (!getDataWindow()->pHeaderBar) - getDataWindow()->pHeaderBar = CreateHeaderBar( this ); - } - else - { - DELETEZ(getDataWindow()->pHeaderBar); - } - - - - if ( bColumnCursor ) - { - pColSel = pOldColSel ? pOldColSel : new MultiSelection; - pColSel->SetTotalRange( Range( 0, pCols->size()-1 ) ); - } - else - { - pColSel = 0; - delete pColSel; - } - - if ( bMultiSelection ) - { - if ( pOldRowSel ) - uRow.pSel = pOldRowSel; - else - uRow.pSel = new MultiSelection; - } - else - { - uRow.nSel = nOldRowSel; - delete pOldRowSel; - } - - if ( bBootstrapped ) - { - StateChanged( STATE_CHANGE_INITSHOW ); - if ( bMultiSelection && !pOldRowSel && - nOldRowSel != BROWSER_ENDOFSELECTION ) - uRow.pSel->Select( nOldRowSel ); - } - - if ( pDataWin ) - pDataWin->Invalidate(); - - // kein Cursor auf Handle-Column - if ( nCurColId == 0 ) - nCurColId = GetColumnId( 1 ); - - m_nCurrentMode = nMode; -} - -//------------------------------------------------------------------- - -void BrowseBox::VisibleRowsChanged( long, sal_uInt16 ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - // Das alte Verhalten: NumRows automatisch korrigieren: - if ( nRowCount < GetRowCount() ) - { - RowInserted(nRowCount,GetRowCount() - nRowCount,sal_False); - } - else if ( nRowCount > GetRowCount() ) - { - RowRemoved(nRowCount-(nRowCount - GetRowCount()),nRowCount - GetRowCount(),sal_False); - } -} - -//------------------------------------------------------------------- - -sal_Bool BrowseBox::IsCursorMoveAllowed( long, sal_uInt16 ) const - -/* [Beschreibung] - - Diese virtuelle Methode wird immer gerufen bevor der Cursor direkt - bewegt werden soll. Durch 'return sal_False' kann verhindert werden, da\s - dies geschieht, wenn z.B. ein Datensatz irgendwelchen Rules widerspricht. - - Diese Methode wird nicht gerufen, wenn die Cursorbewegung durch - ein L"oschen oder Einf"ugen (einer Zeile/Spalte) ausgel"ost wird, also - genaugenommen nur eine Cursor-Korrektur vorliegt. - - Die Basisimplementierung liefert derzeit immer sal_True. -*/ - -{ - return sal_True; -} - -//------------------------------------------------------------------- - -long BrowseBox::GetDataRowHeight() const -{ - return CalcZoom(nDataRowHeight ? nDataRowHeight : ImpGetDataRowHeight()); -} - -//------------------------------------------------------------------- - -BrowserHeader* BrowseBox::CreateHeaderBar( BrowseBox* pParent ) -{ - BrowserHeader* pNewBar = new BrowserHeader( pParent ); - pNewBar->SetStartDragHdl( LINK( this, BrowseBox, StartDragHdl ) ); - return pNewBar; -} - -void BrowseBox::SetHeaderBar( BrowserHeader* pHeaderBar ) -{ - delete ( (BrowserDataWin*)pDataWin )->pHeaderBar; - ( (BrowserDataWin*)pDataWin )->pHeaderBar = pHeaderBar; - ( (BrowserDataWin*)pDataWin )->pHeaderBar->SetStartDragHdl( LINK( this, BrowseBox, StartDragHdl ) ); -} -//------------------------------------------------------------------- - -#ifdef DBG_UTIL -const char* BrowseBoxCheckInvariants( const void * pVoid ) -{ - const BrowseBox * p = (const BrowseBox *)pVoid; - - if (p->nRowCount < 0) return "BrowseBox: nRowCount < 0"; - if (p->nTopRow < 0) return "BrowseBox: nTopRow < 0"; - if (p->nTopRow >= p->nRowCount && p->nRowCount != 0) return "BrowseBox: nTopRow >= nRowCount && nRowCount != 0"; - if (p->nCurRow < -1) return "BrowseBox: nCurRow < -1"; - if (p->nCurRow > p->nRowCount) return "BrowseBox: nCurRow > nRowCount"; - - // Leider waehrend der Bearbeitung nicht immer der Fall: - //if (p->nCurRow < 0 && p->nRowCount != 0) return "nCurRow < 0 && nRowCount != 0"; - //if (p->nCurRow >= p->nRowCount && p->nRowCount != 0) return "nCurRow >= nRowCount && nRowCount != 0"; - - return NULL; -} -#endif - -//------------------------------------------------------------------- -long BrowseBox::GetTitleHeight() const -{ - long nHeight; - // ask the header bar for the text height (if possible), as the header bar's font is adjusted with - // our (and the header's) zoom factor - HeaderBar* pHeaderBar = ( (BrowserDataWin*)pDataWin )->pHeaderBar; - if ( pHeaderBar ) - nHeight = pHeaderBar->GetTextHeight(); - else - nHeight = GetTextHeight(); - - return nTitleLines ? nTitleLines * nHeight + 4 : 0; -} - -//------------------------------------------------------------------- -long BrowseBox::CalcReverseZoom(long nVal) -{ - if (IsZoom()) - { - const Fraction& rZoom = GetZoom(); - double n = (double)nVal; - n *= (double)rZoom.GetDenominator(); - n /= (double)rZoom.GetNumerator(); - nVal = n>0 ? (long)(n + 0.5) : -(long)(-n + 0.5); - } - - return nVal; -} - -void BrowseBox::CursorMoved() -{ - // before implementing more here, please adjust the EditBrowseBox - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - if ( isAccessibleAlive() && HasFocus() ) - commitTableEvent( - ACTIVE_DESCENDANT_CHANGED, - makeAny( CreateAccessibleCell( GetCurRow(),GetColumnPos( GetCurColumnId() ) ) ), - Any() - ); -} - -//------------------------------------------------------------------- - -void BrowseBox::LoseFocus() -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - OSL_TRACE( "BrowseBox: %p->LoseFocus", this ); - - if ( bHasFocus ) - { - OSL_TRACE( "BrowseBox: %p->HideCursor", this ); - DoHideCursor( "LoseFocus" ); - - if ( !bKeepHighlight ) - { - ToggleSelection(); - bSelectionIsVisible = sal_False; - } - - bHasFocus = sal_False; - } - Control::LoseFocus(); -} - -//------------------------------------------------------------------- - -void BrowseBox::GetFocus() -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - OSL_TRACE( "BrowseBox: %p->GetFocus", this ); - - if ( !bHasFocus ) - { - if ( !bSelectionIsVisible ) - { - bSelectionIsVisible = sal_True; - if ( bBootstrapped ) - ToggleSelection(); - } - - bHasFocus = sal_True; - DoShowCursor( "GetFocus" ); - } - Control::GetFocus(); -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/brwbox/brwbox2.cxx b/svtools/source/brwbox/brwbox2.cxx deleted file mode 100644 index 8f6968b778..0000000000 --- a/svtools/source/brwbox/brwbox2.cxx +++ /dev/null @@ -1,2150 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svtools.hxx" -#include <tools/debug.hxx> -#include <svtools/brwbox.hxx> -#include "datwin.hxx" -#include <svtools/colorcfg.hxx> -#include <vcl/salgtype.hxx> - -#include <tools/multisel.hxx> -#include <algorithm> - -using namespace ::com::sun::star::datatransfer; - -#define getDataWindow() ((BrowserDataWin*)pDataWin) - - -//=================================================================== - -DBG_NAMEEX(BrowseBox) - -//=================================================================== - -extern const char* BrowseBoxCheckInvariants( const void * pVoid ); - -//=================================================================== - -void BrowseBox::StartDrag( sal_Int8 /* _nAction */, const Point& /* _rPosPixel */ ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - // not interested in this event -} - -//=================================================================== - -sal_Int8 BrowseBox::AcceptDrop( const AcceptDropEvent& _rEvt ) -{ - BrowserDataWin* pDataWindow = static_cast<BrowserDataWin*>(pDataWin); - AcceptDropEvent aTransformed( _rEvt ); - aTransformed.maPosPixel = pDataWindow->ScreenToOutputPixel( OutputToScreenPixel( _rEvt.maPosPixel ) ); - return pDataWindow->AcceptDrop( aTransformed ); -} - -//=================================================================== - -sal_Int8 BrowseBox::ExecuteDrop( const ExecuteDropEvent& _rEvt ) -{ - BrowserDataWin* pDataWindow = static_cast<BrowserDataWin*>(pDataWin); - ExecuteDropEvent aTransformed( _rEvt ); - aTransformed.maPosPixel = pDataWindow->ScreenToOutputPixel( OutputToScreenPixel( _rEvt.maPosPixel ) ); - return pDataWindow->ExecuteDrop( aTransformed ); -} - -//=================================================================== - -sal_Int8 BrowseBox::AcceptDrop( const BrowserAcceptDropEvent& ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - // not interested in this event - return DND_ACTION_NONE; -} - -//=================================================================== - -sal_Int8 BrowseBox::ExecuteDrop( const BrowserExecuteDropEvent& ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - // not interested in this event - return DND_ACTION_NONE; -} - -//=================================================================== - -void* BrowseBox::implGetDataFlavors() const -{ - if (static_cast<BrowserDataWin*>(pDataWin)->bCallingDropCallback) - return &static_cast<BrowserDataWin*>(pDataWin)->GetDataFlavorExVector(); - return &GetDataFlavorExVector(); -} - -//=================================================================== - -sal_Bool BrowseBox::IsDropFormatSupported( SotFormatStringId _nFormat ) -{ - if ( static_cast< BrowserDataWin* >( pDataWin )->bCallingDropCallback ) - return static_cast< BrowserDataWin* >( pDataWin )->IsDropFormatSupported( _nFormat ); - - return DropTargetHelper::IsDropFormatSupported( _nFormat ); -} - -//=================================================================== - -sal_Bool BrowseBox::IsDropFormatSupported( SotFormatStringId _nFormat ) const -{ - return const_cast< BrowseBox* >( this )->IsDropFormatSupported( _nFormat ); -} - -//=================================================================== - -sal_Bool BrowseBox::IsDropFormatSupported( const DataFlavor& _rFlavor ) -{ - if ( static_cast< BrowserDataWin* >( pDataWin )->bCallingDropCallback ) - return static_cast< BrowserDataWin* >( pDataWin )->IsDropFormatSupported( _rFlavor ); - - return DropTargetHelper::IsDropFormatSupported( _rFlavor ); -} - -//=================================================================== - -sal_Bool BrowseBox::IsDropFormatSupported( const DataFlavor& _rFlavor ) const -{ - return const_cast< BrowseBox* >( this )->IsDropFormatSupported( _rFlavor ); -} - -//=================================================================== - -void BrowseBox::Command( const CommandEvent& rEvt ) -{ - if ( !getDataWindow()->bInCommand ) - Control::Command( rEvt ); -} - -//=================================================================== - -void BrowseBox::StateChanged( StateChangedType nStateChange ) -{ - Control::StateChanged( nStateChange ); - - if ( STATE_CHANGE_MIRRORING == nStateChange ) - { - getDataWindow()->EnableRTL( IsRTLEnabled() ); - - HeaderBar* pHeaderBar = getDataWindow()->pHeaderBar; - if ( pHeaderBar ) - pHeaderBar->EnableRTL( IsRTLEnabled() ); - aHScroll.EnableRTL( IsRTLEnabled() ); - if( pVScroll ) - pVScroll->EnableRTL( IsRTLEnabled() ); - Resize(); - } - else if ( STATE_CHANGE_INITSHOW == nStateChange ) - { - bBootstrapped = sal_True; // muss zuerst gesetzt werden! - - Resize(); - if ( bMultiSelection ) - uRow.pSel->SetTotalRange( Range( 0, nRowCount - 1 ) ); - if ( nRowCount == 0 ) - nCurRow = BROWSER_ENDOFSELECTION; - else if ( nCurRow == BROWSER_ENDOFSELECTION ) - nCurRow = 0; - - - if ( HasFocus() ) - { - bSelectionIsVisible = sal_True; - bHasFocus = sal_True; - } - UpdateScrollbars(); - AutoSizeLastColumn(); - CursorMoved(); - } - else if (STATE_CHANGE_ZOOM == nStateChange) - { - pDataWin->SetZoom(GetZoom()); - HeaderBar* pHeaderBar = getDataWindow()->pHeaderBar; - if (pHeaderBar) - pHeaderBar->SetZoom(GetZoom()); - - // let the cols calc their new widths and adjust the header bar - for ( size_t nPos = 0; nPos < pCols->size(); ++nPos ) - { - (*pCols)[ nPos ]->ZoomChanged(GetZoom()); - if ( pHeaderBar ) - pHeaderBar->SetItemSize( (*pCols)[ nPos ]->GetId(), (*pCols)[ nPos ]->Width() ); - } - - // all our controls have to be repositioned - Resize(); - } - else if (STATE_CHANGE_ENABLE == nStateChange) - { - // do we have a handle column? - sal_Bool bHandleCol = !pCols->empty() && (0 == (*pCols)[ 0 ]->GetId()); - // do we have a header bar - sal_Bool bHeaderBar = (NULL != static_cast<BrowserDataWin&>(GetDataWindow()).pHeaderBar); - - if ( nTitleLines - && ( !bHeaderBar - || bHandleCol - ) - ) - // we draw the text in our header bar in a color dependent on the enabled state. So if this state changed - // -> redraw - Invalidate(Rectangle(Point(0, 0), Size(GetOutputSizePixel().Width(), GetTitleHeight() - 1))); - } -} - -//=================================================================== - -void BrowseBox::Select() -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); -} - -//------------------------------------------------------------------- - -void BrowseBox::DoubleClick( const BrowserMouseEvent & ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); -} - -//------------------------------------------------------------------- - -long BrowseBox::QueryMinimumRowHeight() -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - return CalcZoom( 5 ); -} - -//------------------------------------------------------------------- - -void BrowseBox::ImplStartTracking() -{ - DBG_CHKTHIS( BrowseBox, BrowseBoxCheckInvariants ); -} - -//------------------------------------------------------------------- - -void BrowseBox::ImplTracking() -{ - DBG_CHKTHIS( BrowseBox, BrowseBoxCheckInvariants ); -} - -//------------------------------------------------------------------- - -void BrowseBox::ImplEndTracking() -{ - DBG_CHKTHIS( BrowseBox, BrowseBoxCheckInvariants ); -} - -//------------------------------------------------------------------- - -void BrowseBox::RowHeightChanged() -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); -} - -//------------------------------------------------------------------- - -long BrowseBox::QueryColumnResize( sal_uInt16, long nWidth ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - return nWidth; -} - -//------------------------------------------------------------------- - -void BrowseBox::ColumnResized( sal_uInt16 ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); -} - -//------------------------------------------------------------------- - -void BrowseBox::ColumnMoved( sal_uInt16 ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); -} - -//------------------------------------------------------------------- - -void BrowseBox::StartScroll() -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - DoHideCursor( "StartScroll" ); -} - -//------------------------------------------------------------------- - -void BrowseBox::EndScroll() -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - UpdateScrollbars(); - AutoSizeLastColumn(); - DoShowCursor( "EndScroll" ); -} - -//------------------------------------------------------------------- - -#ifdef _MSC_VER -#pragma optimize( "", off ) -#endif - -void BrowseBox::ToggleSelection( sal_Bool bForce ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - // selection highlight-toggling allowed? - if ( bHideSelect ) - return; - if ( !bForce && - ( bNotToggleSel || !IsUpdateMode() || !bSelectionIsVisible ) ) - return; - - // only highlight painted areas! - bNotToggleSel = sal_True; - if ( sal_False && !getDataWindow()->bInPaint ) - pDataWin->Update(); - - // accumulate areas of rows to highlight - RectangleList aHighlightList; - long nLastRowInRect = 0; // fuer den CFront - - // Handle-Column nicht highlighten - BrowserColumn *pFirstCol = pCols->empty() ? NULL : (*pCols)[ 0 ]; - long nOfsX = (!pFirstCol || pFirstCol->GetId()) ? 0 : pFirstCol->Width(); - - // accumulate old row selection - long nBottomRow = nTopRow + - pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight(); - if ( nBottomRow > GetRowCount() && GetRowCount() ) - nBottomRow = GetRowCount(); - for ( long nRow = bMultiSelection ? uRow.pSel->FirstSelected() : uRow.nSel; - nRow != BROWSER_ENDOFSELECTION && nRow <= nBottomRow; - nRow = bMultiSelection ? uRow.pSel->NextSelected() : BROWSER_ENDOFSELECTION ) - { - if ( nRow < nTopRow ) - continue; - - Rectangle aAddRect( - Point( nOfsX, (nRow-nTopRow)*GetDataRowHeight() ), - Size( pDataWin->GetSizePixel().Width(), GetDataRowHeight() ) ); - if ( aHighlightList.size() && nLastRowInRect == ( nRow - 1 ) ) - aHighlightList[ 0 ]->Union( aAddRect ); - else - aHighlightList.insert( aHighlightList.begin(), new Rectangle( aAddRect ) ); - nLastRowInRect = nRow; - } - - // unhighlight the old selection (if any) - for ( size_t i = aHighlightList.size(); i > 0; ) - { - Rectangle *pRect = aHighlightList[ --i ]; - pDataWin->Invalidate( *pRect ); - delete pRect; - } - aHighlightList.clear(); - - // unhighlight old column selection (if any) - for ( long nColId = pColSel ? pColSel->FirstSelected() : BROWSER_ENDOFSELECTION; - nColId != BROWSER_ENDOFSELECTION; - nColId = pColSel->NextSelected() ) - { - Rectangle aRect( GetFieldRectPixel(nCurRow, - (*pCols)[ nColId ]->GetId(), - sal_False ) ); - aRect.Left() -= MIN_COLUMNWIDTH; - aRect.Right() += MIN_COLUMNWIDTH; - aRect.Top() = 0; - aRect.Bottom() = pDataWin->GetOutputSizePixel().Height(); - pDataWin->Invalidate( aRect ); - } - - bNotToggleSel = sal_False; -} - -#ifdef _MSC_VER -#pragma optimize( "", on ) -#endif - -//------------------------------------------------------------------- - -void BrowseBox::DrawCursor() -{ - sal_Bool bReallyHide = sal_False; - if ( SMART_CURSOR_HIDE == bHideCursor ) - { - if ( !GetSelectRowCount() && !GetSelectColumnCount() ) - bReallyHide = sal_True; - } - else if ( HARD_CURSOR_HIDE == bHideCursor ) - { - bReallyHide = sal_True; - } - - bReallyHide |= !bSelectionIsVisible || !IsUpdateMode() || bScrolling || nCurRow < 0; - - if (PaintCursorIfHiddenOnce()) - bReallyHide |= ( GetCursorHideCount() > 1 ); - else - bReallyHide |= ( GetCursorHideCount() > 0 ); - - // keine Cursor auf Handle-Column - if ( nCurColId == 0 ) - nCurColId = GetColumnId(1); - - // Cursor-Rechteck berechnen - Rectangle aCursor; - if ( bColumnCursor ) - { - aCursor = GetFieldRectPixel( nCurRow, nCurColId, sal_False ); - aCursor.Left() -= MIN_COLUMNWIDTH; - aCursor.Right() += 1; - aCursor.Bottom() += 1; - } - else - aCursor = Rectangle( - Point( ( !pCols->empty() && (*pCols)[ 0 ]->GetId() == 0 ) ? - (*pCols)[ 0 ]->Width() : 0, - (nCurRow - nTopRow) * GetDataRowHeight() + 1 ), - Size( pDataWin->GetOutputSizePixel().Width() + 1, - GetDataRowHeight() - 2 ) ); - if ( bHLines ) - { - if ( !bMultiSelection ) - --aCursor.Top(); - --aCursor.Bottom(); - } - - if (m_aCursorColor == COL_TRANSPARENT) - { - // auf diesem Plattformen funktioniert der StarView-Focus richtig - if ( bReallyHide ) - ((Control*)pDataWin)->HideFocus(); - else - ((Control*)pDataWin)->ShowFocus( aCursor ); - } - else - { - Color rCol = bReallyHide ? pDataWin->GetFillColor() : m_aCursorColor; - Color aOldFillColor = pDataWin->GetFillColor(); - Color aOldLineColor = pDataWin->GetLineColor(); - pDataWin->SetFillColor(); - pDataWin->SetLineColor( rCol ); - pDataWin->DrawRect( aCursor ); - pDataWin->SetLineColor( aOldLineColor ); - pDataWin->SetFillColor( aOldFillColor ); - } -} - -//------------------------------------------------------------------- - -sal_uLong BrowseBox::GetColumnWidth( sal_uInt16 nId ) const -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - sal_uInt16 nItemPos = GetColumnPos( nId ); - if ( nItemPos >= pCols->size() ) - return 0; - return (*pCols)[ nItemPos ]->Width(); -} - -//------------------------------------------------------------------- - -sal_uInt16 BrowseBox::GetColumnId( sal_uInt16 nPos ) const -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - if ( nPos >= pCols->size() ) - return 0; - return (*pCols)[ nPos ]->GetId(); -} - -//------------------------------------------------------------------- - -sal_uInt16 BrowseBox::GetColumnPos( sal_uInt16 nId ) const -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - for ( sal_uInt16 nPos = 0; nPos < pCols->size(); ++nPos ) - if ( (*pCols)[ nPos ]->GetId() == nId ) - return nPos; - return BROWSER_INVALIDID; -} - -//------------------------------------------------------------------- - -sal_Bool BrowseBox::IsFrozen( sal_uInt16 nColumnId ) const -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - for ( size_t nPos = 0; nPos < pCols->size(); ++nPos ) - if ( (*pCols)[ nPos ]->GetId() == nColumnId ) - return (*pCols)[ nPos ]->IsFrozen(); - return sal_False; -} - -//------------------------------------------------------------------- - -void BrowseBox::ExpandRowSelection( const BrowserMouseEvent& rEvt ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - DoHideCursor( "ExpandRowSelection" ); - - // expand the last selection - if ( bMultiSelection ) - { - Range aJustifiedRange( aSelRange ); - aJustifiedRange.Justify(); - - sal_Bool bSelectThis = ( bSelect != aJustifiedRange.IsInside( rEvt.GetRow() ) ); - - if ( aJustifiedRange.IsInside( rEvt.GetRow() ) ) - { - // down and up - while ( rEvt.GetRow() < aSelRange.Max() ) - { // ZTC/Mac bug - dont put these statemants together! - SelectRow( aSelRange.Max(), bSelectThis, sal_True ); - --aSelRange.Max(); - } - while ( rEvt.GetRow() > aSelRange.Max() ) - { // ZTC/Mac bug - dont put these statemants together! - SelectRow( aSelRange.Max(), bSelectThis, sal_True ); - ++aSelRange.Max(); - } - } - else - { - // up and down - sal_Bool bOldSelecting = bSelecting; - bSelecting = sal_True; - while ( rEvt.GetRow() < aSelRange.Max() ) - { // ZTC/Mac bug - dont put these statemants together! - --aSelRange.Max(); - if ( !IsRowSelected( aSelRange.Max() ) ) - { - SelectRow( aSelRange.Max(), bSelectThis, sal_True ); - bSelect = sal_True; - } - } - while ( rEvt.GetRow() > aSelRange.Max() ) - { // ZTC/Mac bug - dont put these statemants together! - ++aSelRange.Max(); - if ( !IsRowSelected( aSelRange.Max() ) ) - { - SelectRow( aSelRange.Max(), bSelectThis, sal_True ); - bSelect = sal_True; - } - } - bSelecting = bOldSelecting; - if ( bSelect ) - Select(); - } - } - else - if ( !bMultiSelection || !IsRowSelected( rEvt.GetRow() ) ) - SelectRow( rEvt.GetRow(), sal_True ); - - GoToRow( rEvt.GetRow(), sal_False ); - DoShowCursor( "ExpandRowSelection" ); -} - -//------------------------------------------------------------------- - -void BrowseBox::Resize() -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - if ( !bBootstrapped && IsReallyVisible() ) - BrowseBox::StateChanged( STATE_CHANGE_INITSHOW ); - if ( pCols->empty() ) - { - getDataWindow()->bResizeOnPaint = sal_True; - return; - } - getDataWindow()->bResizeOnPaint = sal_False; - - // calc the size of the scrollbars - // (we can't ask the scrollbars for their widths cause if we're zoomed they still have to be - // resized - which is done in UpdateScrollbars) - sal_uLong nSBSize = GetSettings().GetStyleSettings().GetScrollBarSize(); - if (IsZoom()) - nSBSize = (sal_uLong)(nSBSize * (double)GetZoom()); - - DoHideCursor( "Resize" ); - sal_uInt16 nOldVisibleRows = - (sal_uInt16)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1); - - // did we need a horiz. scroll bar oder gibt es eine Control Area? - if ( !getDataWindow()->bNoHScroll && - ( ( pCols->size() - FrozenColCount() ) > 1 ) ) - aHScroll.Show(); - else - aHScroll.Hide(); - - // calculate the size of the data window - long nDataHeight = GetOutputSizePixel().Height() - GetTitleHeight(); - if ( aHScroll.IsVisible() || ( nControlAreaWidth != USHRT_MAX ) ) - nDataHeight -= nSBSize; - - long nDataWidth = GetOutputSizePixel().Width(); - if ( pVScroll->IsVisible() ) - nDataWidth -= nSBSize; - - // adjust position and size of data window - pDataWin->SetPosSizePixel( - Point( 0, GetTitleHeight() ), - Size( nDataWidth, nDataHeight ) ); - - sal_uInt16 nVisibleRows = - (sal_uInt16)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1); - - // TopRow ist unveraendert, aber die Anzahl sichtbarer Zeilen hat sich - // geaendert - if ( nVisibleRows != nOldVisibleRows ) - VisibleRowsChanged(nTopRow, nVisibleRows); - - UpdateScrollbars(); - - // Control-Area - Rectangle aInvalidArea( GetControlArea() ); - aInvalidArea.Right() = GetOutputSizePixel().Width(); - aInvalidArea.Left() = 0; - Invalidate( aInvalidArea ); - - // external header-bar - HeaderBar* pHeaderBar = getDataWindow()->pHeaderBar; - if ( pHeaderBar ) - { - // Handle-Column beruecksichtigen - BrowserColumn *pFirstCol = (*pCols)[ 0 ]; - long nOfsX = pFirstCol->GetId() ? 0 : pFirstCol->Width(); - pHeaderBar->SetPosSizePixel( Point( nOfsX, 0 ), Size( GetOutputSizePixel().Width() - nOfsX, GetTitleHeight() ) ); - } - - AutoSizeLastColumn(); // adjust last column width - DoShowCursor( "Resize" ); -} - -//------------------------------------------------------------------- - -void BrowseBox::Paint( const Rectangle& rRect ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - // initializations - if ( !bBootstrapped && IsReallyVisible() ) - BrowseBox::StateChanged( STATE_CHANGE_INITSHOW ); - if ( pCols->empty() ) - return; - - BrowserColumn *pFirstCol = (*pCols)[ 0 ]; - sal_Bool bHandleCol = pFirstCol && pFirstCol->GetId() == 0; - sal_Bool bHeaderBar = getDataWindow()->pHeaderBar != NULL; - - // draw delimitational lines - if ( !getDataWindow()->bNoHScroll ) - DrawLine( Point( 0, aHScroll.GetPosPixel().Y() ), - Point( GetOutputSizePixel().Width(), - aHScroll.GetPosPixel().Y() ) ); - - if ( nTitleLines ) - { - if ( !bHeaderBar ) - DrawLine( Point( 0, GetTitleHeight() - 1 ), - Point( GetOutputSizePixel().Width(), - GetTitleHeight() - 1 ) ); - else if ( bHandleCol ) - DrawLine( Point( 0, GetTitleHeight() - 1 ), - Point( pFirstCol->Width(), GetTitleHeight() - 1 ) ); - } - - // Title Bar - // Wenn es eine Handle Column gibt und die Headerbar verfuegbar ist, dann nur - // die HandleColumn - // Handle-Column beruecksichtigen - if ( nTitleLines && (!bHeaderBar || bHandleCol) ) - { - // iterate through columns to redraw - long nX = 0; - size_t nCol; - for ( nCol = 0; - nCol < pCols->size() && nX < rRect.Right(); - ++nCol ) - { - // skip invisible colums between frozen and scrollable area - if ( nCol < nFirstCol && !(*pCols)[ nCol ]->IsFrozen() ) - nCol = nFirstCol; - - // nur die HandleCol ? - if (bHeaderBar && bHandleCol && nCol > 0) - break; - - 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(), sal_False, sal_False, - 0 != (BROWSER_COLUMN_TITLEABBREVATION&pCol->Flags()), - !IsEnabled()); - aButtonFrame.Draw( *this ); - DrawLine( Point( nX + pCol->Width() - 1, 0 ), - Point( nX + pCol->Width() - 1, GetTitleHeight()-1 ) ); - } - else - { - Color aOldFillColor = GetFillColor(); - SetFillColor( Color( COL_BLACK ) ); - DrawRect( Rectangle( Point( nX, 0 ), Size( pCol->Width(), GetTitleHeight() - 1 ) ) ); - SetFillColor( aOldFillColor ); - } - - // skip column - nX += pCol->Width(); - } - - // retouching - if ( !bHeaderBar && nCol == pCols->size() ) - { - const StyleSettings &rSettings = GetSettings().GetStyleSettings(); - Color aColFace( rSettings.GetFaceColor() ); - Color aOldFillColor = GetFillColor(); - Color aOldLineColor = GetLineColor(); - SetFillColor( aColFace ); - SetLineColor( aColFace ); - DrawRect( Rectangle( - Point( nX, 0 ), - Point( rRect.Right(), GetTitleHeight() - 2 ) ) ); - SetFillColor( aOldFillColor); // aOldLineColor ); oj 09.02.00 seems to be a copy&paste bug - SetLineColor( aOldLineColor); // aOldFillColor ); - } - } -} - -//------------------------------------------------------------------- - -void BrowseBox::PaintRow( OutputDevice&, const Rectangle& ) -{ -} - -//------------------------------------------------------------------- - -void BrowseBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) -{ - sal_Bool bDrawSelection = (nFlags & WINDOW_DRAW_NOSELECTION) == 0; - - // we need pixel coordinates - Size aRealSize = pDev->LogicToPixel(rSize); - Point aRealPos = pDev->LogicToPixel(rPos); - - if ((rSize.Width() < 3) || (rSize.Height() < 3)) - // we want to have two pixels frame ... - return; - - Font aFont = GetDataWindow().GetDrawPixelFont( pDev ); - // the 'normal' painting uses always the data window as device to output to, so we have to calc the new font - // relative to the data wins current settings - - pDev->Push(); - pDev->SetMapMode(); - pDev->SetFont( aFont ); - - // draw a frame - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - pDev->SetLineColor(rStyleSettings.GetDarkShadowColor()); - pDev->DrawLine(Point(aRealPos.X(), aRealPos.Y()), - Point(aRealPos.X(), aRealPos.Y() + aRealSize.Height() - 1)); - pDev->DrawLine(Point(aRealPos.X(), aRealPos.Y()), - Point(aRealPos.X() + aRealSize.Width() - 1, aRealPos.Y())); - pDev->SetLineColor(rStyleSettings.GetShadowColor()); - pDev->DrawLine(Point(aRealPos.X() + aRealSize.Width() - 1, aRealPos.Y() + 1), - Point(aRealPos.X() + aRealSize.Width() - 1, aRealPos.Y() + aRealSize.Height() - 1)); - pDev->DrawLine(Point(aRealPos.X() + aRealSize.Width() - 1, aRealPos.Y() + aRealSize.Height() - 1), - Point(aRealPos.X() + 1, aRealPos.Y() + aRealSize.Height() - 1)); - - HeaderBar* pBar = getDataWindow()->pHeaderBar; - - // we're drawing onto a foreign device, so we have to fake the DataRowHeight for the subsequent ImplPaintData - // (as it is based on the settings of our data window, not the foreign device) - if (!nDataRowHeight) - ImpGetDataRowHeight(); - long nHeightLogic = PixelToLogic(Size(0, nDataRowHeight), MAP_10TH_MM).Height(); - long nForeignHeightPixel = pDev->LogicToPixel(Size(0, nHeightLogic), MAP_10TH_MM).Height(); - - long nOriginalHeight = nDataRowHeight; - nDataRowHeight = nForeignHeightPixel; - - // this counts for the column widths, too - size_t nPos; - for ( nPos = 0; nPos < pCols->size(); ++nPos ) - { - BrowserColumn* pCurrent = (*pCols)[ nPos ]; - - long nWidthLogic = PixelToLogic(Size(pCurrent->Width(), 0), MAP_10TH_MM).Width(); - long nForeignWidthPixel = pDev->LogicToPixel(Size(nWidthLogic, 0), MAP_10TH_MM).Width(); - - pCurrent->SetWidth(nForeignWidthPixel, GetZoom()); - if ( pBar ) - pBar->SetItemSize( pCurrent->GetId(), pCurrent->Width() ); - } - - // a smaller area for the content - ++aRealPos.X(); - ++aRealPos.Y(); - aRealSize.Width() -= 2; - aRealSize.Height() -= 2; - - // let the header bar draw itself - if ( pBar ) - { - // the title height with respect to the font set for the given device - long nTitleHeight = PixelToLogic(Size(0, GetTitleHeight()), MAP_10TH_MM).Height(); - nTitleHeight = pDev->LogicToPixel(Size(0, nTitleHeight), MAP_10TH_MM).Height(); - - BrowserColumn* pFirstCol = !pCols->empty() ? (*pCols)[ 0 ] : NULL; - - Point aHeaderPos(pFirstCol && (pFirstCol->GetId() == 0) ? pFirstCol->Width() : 0, 0); - Size aHeaderSize(aRealSize.Width() - aHeaderPos.X(), nTitleHeight); - - aHeaderPos += aRealPos; - // do this before converting to logics ! - - // the header's draw expects logic coordinates, again - aHeaderPos = pDev->PixelToLogic(aHeaderPos); - aHeaderSize = pDev->PixelToLogic(aHeaderSize); - - pBar->Draw(pDev, aHeaderPos, aHeaderSize, nFlags); - - // draw the "upper left cell" (the intersection between the header bar and the handle column) - if (( pFirstCol->GetId() == 0 ) && ( pFirstCol->Width() > 4 )) - { - ButtonFrame aButtonFrame( aRealPos, - Size( pFirstCol->Width()-1, nTitleHeight-1 ), - pFirstCol->Title(), sal_False, sal_False, sal_False, !IsEnabled()); - aButtonFrame.Draw( *pDev ); - - pDev->Push( PUSH_LINECOLOR ); - pDev->SetLineColor( Color( COL_BLACK ) ); - - pDev->DrawLine( Point( aRealPos.X(), aRealPos.Y() + nTitleHeight-1 ), - Point( aRealPos.X() + pFirstCol->Width() - 1, aRealPos.Y() + nTitleHeight-1 ) ); - pDev->DrawLine( Point( aRealPos.X() + pFirstCol->Width() - 1, aRealPos.Y() ), - Point( aRealPos.X() + pFirstCol->Width() - 1, aRealPos.Y() + nTitleHeight-1 ) ); - - pDev->Pop(); - } - - aRealPos.Y() += aHeaderSize.Height(); - aRealSize.Height() -= aHeaderSize.Height(); - } - - // draw our own content (with clipping) - Region aRegion(Rectangle(aRealPos, aRealSize)); - pDev->SetClipRegion( pDev->PixelToLogic( aRegion ) ); - - // do we have to paint the background - sal_Bool bBackground = !(nFlags & WINDOW_DRAW_NOBACKGROUND) && GetDataWindow().IsControlBackground(); - if ( bBackground ) - { - Rectangle aRect( aRealPos, aRealSize ); - pDev->SetFillColor( GetDataWindow().GetControlBackground() ); - pDev->DrawRect( aRect ); - } - - ImplPaintData( *pDev, Rectangle( aRealPos, aRealSize ), sal_True, bDrawSelection ); - - // restore the column widths/data row height - nDataRowHeight = nOriginalHeight; - for ( nPos = 0; nPos < pCols->size(); ++nPos ) - { - BrowserColumn* pCurrent = (*pCols)[ nPos ]; - - long nForeignWidthLogic = pDev->PixelToLogic(Size(pCurrent->Width(), 0), MAP_10TH_MM).Width(); - long nWidthPixel = LogicToPixel(Size(nForeignWidthLogic, 0), MAP_10TH_MM).Width(); - - pCurrent->SetWidth(nWidthPixel, GetZoom()); - if ( pBar ) - pBar->SetItemSize( pCurrent->GetId(), pCurrent->Width() ); - } - - pDev->Pop(); -} - -//------------------------------------------------------------------- - -void BrowseBox::ImplPaintData(OutputDevice& _rOut, const Rectangle& _rRect, sal_Bool _bForeignDevice, sal_Bool _bDrawSelections) -{ - Point aOverallAreaPos = _bForeignDevice ? _rRect.TopLeft() : Point(0,0); - Size aOverallAreaSize = _bForeignDevice ? _rRect.GetSize() : GetDataWindow().GetOutputSizePixel(); - Point aOverallAreaBRPos = _bForeignDevice ? _rRect.BottomRight() : Point( aOverallAreaSize.Width(), aOverallAreaSize.Height() ); - - long nDataRowHeigt = GetDataRowHeight(); - - // compute relative rows to redraw - sal_uLong nRelTopRow = _bForeignDevice ? 0 : ((sal_uLong)_rRect.Top() / nDataRowHeigt); - sal_uLong nRelBottomRow = (sal_uLong)(_bForeignDevice ? aOverallAreaSize.Height() : _rRect.Bottom()) / nDataRowHeigt; - - // cache frequently used values - Point aPos( aOverallAreaPos.X(), nRelTopRow * nDataRowHeigt + aOverallAreaPos.Y() ); - _rOut.SetLineColor( Color( COL_WHITE ) ); - const AllSettings& rAllSets = _rOut.GetSettings(); - const StyleSettings &rSettings = rAllSets.GetStyleSettings(); - const Color &rHighlightTextColor = rSettings.GetHighlightTextColor(); - const Color &rHighlightFillColor = rSettings.GetHighlightColor(); - Color aOldTextColor = _rOut.GetTextColor(); - Color aOldFillColor = _rOut.GetFillColor(); - Color aOldLineColor = _rOut.GetLineColor(); - long nHLineX = 0 == (*pCols)[ 0 ]->GetId() ? (*pCols)[ 0 ]->Width() : 0; - nHLineX += aOverallAreaPos.X(); - - Color aDelimiterLineColor( ::svtools::ColorConfig().GetColorValue( ::svtools::CALCGRID ).nColor ); - - // redraw the invalid fields - for ( sal_uLong nRelRow = nRelTopRow; - nRelRow <= nRelBottomRow && (sal_uLong)nTopRow+nRelRow < (sal_uLong)nRowCount; - ++nRelRow, aPos.Y() += nDataRowHeigt ) - { - // get row - // Zur Sicherheit auf zul"assigen Bereich abfragen: - DBG_ASSERT( (sal_uInt16)(nTopRow+nRelRow) < nRowCount, "BrowseBox::ImplPaintData: invalid seek" ); - if ( (nTopRow+long(nRelRow)) < 0 || (sal_uInt16)(nTopRow+nRelRow) >= nRowCount ) - continue; - - // prepare row - sal_uLong nRow = nTopRow+nRelRow; - if ( !SeekRow( nRow) ) { - OSL_FAIL("BrowseBox::ImplPaintData: SeekRow gescheitert"); - } - _rOut.SetClipRegion(); - aPos.X() = aOverallAreaPos.X(); - - - // #73325# don't paint the row outside the painting rectangle (DG) - // prepare auto-highlight - Rectangle aRowRect( Point( _rRect.TopLeft().X(), aPos.Y() ), - Size( _rRect.GetSize().Width(), nDataRowHeigt ) ); - PaintRow( _rOut, aRowRect ); - - sal_Bool bRowSelected = _bDrawSelections - && !bHideSelect - && IsRowSelected( nRow ); - if ( bRowSelected ) - { - _rOut.SetTextColor( rHighlightTextColor ); - _rOut.SetFillColor( rHighlightFillColor ); - _rOut.SetLineColor(); - _rOut.DrawRect( aRowRect ); - } - - // iterate through columns to redraw - size_t nCol; - for ( nCol = 0; nCol < pCols->size(); ++nCol ) - { - // get column - BrowserColumn *pCol = (*pCols)[ nCol ]; - - // at end of invalid area - if ( aPos.X() >= _rRect.Right() ) - break; - - // skip invisible colums between frozen and scrollable area - if ( nCol < nFirstCol && !pCol->IsFrozen() ) - { - nCol = nFirstCol; - pCol = (nCol < pCols->size() ) ? (*pCols)[ nCol ] : NULL; - if (!pCol) - { // FS - 21.05.99 - 66325 - // ist zwar eigentlich woanders (an der richtigen Stelle) gefixt, aber sicher ist sicher ... - OSL_FAIL("BrowseBox::PaintData : nFirstCol is probably invalid !"); - break; - } - } - - // prepare Column-AutoHighlight - sal_Bool bColAutoHighlight = _bDrawSelections - && bColumnCursor - && IsColumnSelected( pCol->GetId() ); - if ( bColAutoHighlight ) - { - _rOut.SetClipRegion(); - _rOut.SetTextColor( rHighlightTextColor ); - _rOut.SetFillColor( rHighlightFillColor ); - _rOut.SetLineColor(); - Rectangle aFieldRect( aPos, - Size( pCol->Width(), nDataRowHeigt ) ); - _rOut.DrawRect( aFieldRect ); - } - - if (!m_bFocusOnlyCursor && (pCol->GetId() == GetCurColumnId()) && (nRow == (sal_uLong)GetCurRow())) - DrawCursor(); - - // draw a single field - // #63864#, Sonst wird auch etwas gezeichnet, bsp Handle Column - if (pCol->Width()) - { - // clip the column's output to the field area - if (_bForeignDevice) - { // (not neccessary if painting onto the data window) - Size aFieldSize(pCol->Width(), nDataRowHeigt); - - if (aPos.X() + aFieldSize.Width() > aOverallAreaBRPos.X()) - aFieldSize.Width() = aOverallAreaBRPos.X() - aPos.X(); - - if (aPos.Y() + aFieldSize.Height() > aOverallAreaBRPos.Y() + 1) - { - // for non-handle cols we don't clip vertically : we just don't draw the cell if the line isn't completely visible - if (pCol->GetId() != 0) - continue; - aFieldSize.Height() = aOverallAreaBRPos.Y() + 1 - aPos.Y(); - } - - Region aClipToField(Rectangle(aPos, aFieldSize)); - _rOut.SetClipRegion(aClipToField); - } - pCol->Draw( *this, _rOut, aPos, sal_False ); - if (_bForeignDevice) - _rOut.SetClipRegion(); - } - - // reset Column-auto-highlight - if ( bColAutoHighlight ) - { - _rOut.SetTextColor( aOldTextColor ); - _rOut.SetFillColor( aOldFillColor ); - _rOut.SetLineColor( aOldLineColor ); - } - - // skip column - aPos.X() += pCol->Width(); - } - - // reset auto-highlight - if ( bRowSelected ) - { - _rOut.SetTextColor( aOldTextColor ); - _rOut.SetFillColor( aOldFillColor ); - _rOut.SetLineColor( aOldLineColor ); - } - - if ( bHLines ) - { - // draw horizontal delimitation lines - _rOut.SetClipRegion(); - _rOut.Push( PUSH_LINECOLOR ); - _rOut.SetLineColor( aDelimiterLineColor ); - long nY = aPos.Y() + nDataRowHeigt - 1; - if (nY <= aOverallAreaBRPos.Y()) - _rOut.DrawLine( Point( nHLineX, nY ), - Point( bVLines - ? std::min(long(long(aPos.X()) - 1), aOverallAreaBRPos.X()) - : aOverallAreaBRPos.X(), - nY ) ); - _rOut.Pop(); - } - } - - if (aPos.Y() > aOverallAreaBRPos.Y() + 1) - aPos.Y() = aOverallAreaBRPos.Y() + 1; - // needed for some of the following drawing - - // retouching - _rOut.SetClipRegion(); - aOldLineColor = _rOut.GetLineColor(); - aOldFillColor = _rOut.GetFillColor(); - _rOut.SetFillColor( rSettings.GetFaceColor() ); - if ( !pCols->empty() && ( (*pCols)[ 0 ]->GetId() == 0 ) && ( aPos.Y() <= _rRect.Bottom() ) ) - { - // fill rectangle gray below handle column - // DG: fill it only until the end of the drawing rect and not to the end, as this may overpaint handle columns - _rOut.SetLineColor( Color( COL_BLACK ) ); - _rOut.DrawRect( Rectangle( - Point( aOverallAreaPos.X() - 1, aPos.Y() - 1 ), - Point( aOverallAreaPos.X() + (*pCols)[ 0 ]->Width() - 1, - _rRect.Bottom() + 1) ) ); - } - _rOut.SetFillColor( aOldFillColor ); - - // draw vertical delimitational line between frozen and scrollable cols - _rOut.SetLineColor( COL_BLACK ); - long nFrozenWidth = GetFrozenWidth()-1; - _rOut.DrawLine( Point( aOverallAreaPos.X() + nFrozenWidth, aPos.Y() ), - Point( aOverallAreaPos.X() + nFrozenWidth, bHLines - ? aPos.Y() - 1 - : aOverallAreaBRPos.Y() ) ); - - // draw vertical delimitational lines? - if ( bVLines ) - { - _rOut.SetLineColor( aDelimiterLineColor ); - Point aVertPos( aOverallAreaPos.X() - 1, aOverallAreaPos.Y() ); - long nDeltaY = aOverallAreaBRPos.Y(); - for ( size_t nCol = 0; nCol < pCols->size(); ++nCol ) - { - // get column - BrowserColumn *pCol = (*pCols)[ nCol ]; - - // skip invisible colums between frozen and scrollable area - if ( nCol < nFirstCol && !pCol->IsFrozen() ) - { - nCol = nFirstCol; - pCol = (*pCols)[ nCol ]; - } - - // skip column - aVertPos.X() += pCol->Width(); - - // at end of invalid area - // invalid area is first reached when X > Right - // and not >= - if ( aVertPos.X() > _rRect.Right() ) - break; - - // draw a single line - if ( pCol->GetId() != 0 ) - _rOut.DrawLine( aVertPos, Point( aVertPos.X(), - bHLines - ? aPos.Y() - 1 - : aPos.Y() + nDeltaY ) ); - } - } - - _rOut.SetLineColor( aOldLineColor ); -} - -//------------------------------------------------------------------- - -void BrowseBox::PaintData( Window& rWin, const Rectangle& rRect ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - if ( !bBootstrapped && IsReallyVisible() ) - BrowseBox::StateChanged( STATE_CHANGE_INITSHOW ); - - // initializations - if ( !pCols || pCols->empty() || !rWin.IsUpdateMode() ) - return; - if ( getDataWindow()->bResizeOnPaint ) - Resize(); - // MI: wer war das denn? Window::Update(); - - ImplPaintData(rWin, rRect, sal_False, sal_True); -} - -//------------------------------------------------------------------- - -void BrowseBox::UpdateScrollbars() -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - if ( !bBootstrapped || !IsUpdateMode() ) - return; - - // Rekursionsschutz - BrowserDataWin *pBDW = (BrowserDataWin*) pDataWin; - if ( pBDW->bInUpdateScrollbars ) - { - pBDW->bHadRecursion = sal_True; - return; - } - pBDW->bInUpdateScrollbars = sal_True; - - // the size of the corner window (and the width of the VSB/height of the HSB) - sal_uLong nCornerSize = GetSettings().GetStyleSettings().GetScrollBarSize(); - if (IsZoom()) - nCornerSize = (sal_uLong)(nCornerSize * (double)GetZoom()); - - // needs VScroll? - long nMaxRows = (pDataWin->GetSizePixel().Height()) / GetDataRowHeight(); - sal_Bool bNeedsVScroll = getDataWindow()->bAutoVScroll - ? nTopRow || ( nRowCount > nMaxRows ) - : !getDataWindow()->bNoVScroll; - Size aDataWinSize = pDataWin->GetSizePixel(); - if ( !bNeedsVScroll ) - { - if ( pVScroll->IsVisible() ) - { - pVScroll->Hide(); - Size aNewSize( aDataWinSize ); - aNewSize.Width() = GetOutputSizePixel().Width(); - aDataWinSize = aNewSize; - } - } - else if ( !pVScroll->IsVisible() ) - { - Size aNewSize( aDataWinSize ); - aNewSize.Width() = GetOutputSizePixel().Width() - nCornerSize; - aDataWinSize = aNewSize; - } - - // needs HScroll? - sal_uLong nLastCol = GetColumnAtXPosPixel( aDataWinSize.Width() - 1 ); - - sal_uInt16 nFrozenCols = FrozenColCount(); - sal_Bool bNeedsHScroll = getDataWindow()->bAutoHScroll - ? ( nFirstCol > nFrozenCols ) || ( nLastCol <= pCols->size() ) - : !getDataWindow()->bNoHScroll; - if ( !bNeedsHScroll ) - { - if ( aHScroll.IsVisible() ) - { - aHScroll.Hide(); - } - aDataWinSize.Height() = GetOutputSizePixel().Height() - GetTitleHeight(); - if ( nControlAreaWidth != USHRT_MAX ) - aDataWinSize.Height() -= nCornerSize; - } - else if ( !aHScroll.IsVisible() ) - { - Size aNewSize( aDataWinSize ); - aNewSize.Height() = GetOutputSizePixel().Height() - GetTitleHeight() - nCornerSize; - aDataWinSize = aNewSize; - } - - // adjust position and Width of horizontal scrollbar - sal_uLong nHScrX = nControlAreaWidth == USHRT_MAX - ? 0 - : nControlAreaWidth; - - aHScroll.SetPosSizePixel( - Point( nHScrX, GetOutputSizePixel().Height() - nCornerSize ), - Size( aDataWinSize.Width() - nHScrX, nCornerSize ) ); - - // Scrollable Columns insgesamt - short nScrollCols = short(pCols->size()) - (short)nFrozenCols; - - // Sichtbare Columns - short nVisibleHSize = nLastCol == BROWSER_INVALIDID - ? (short)( pCols->size() - nFirstCol ) - : (short)( nLastCol - nFirstCol ); - - short nRange = Max( nScrollCols, (short)0 ); - aHScroll.SetVisibleSize( nVisibleHSize ); - aHScroll.SetRange( Range( 0, nRange )); - if ( bNeedsHScroll && !aHScroll.IsVisible() ) - aHScroll.Show(); - - // adjust position and height of vertical scrollbar - pVScroll->SetPageSize( nMaxRows ); - - if ( nTopRow > nRowCount ) - { - nTopRow = nRowCount - 1; - OSL_FAIL("BrowseBox: nTopRow > nRowCount"); - } - - if ( pVScroll->GetThumbPos() != nTopRow ) - pVScroll->SetThumbPos( nTopRow ); - long nVisibleSize = Min( Min( nRowCount, nMaxRows ), long(nRowCount-nTopRow) ); - pVScroll->SetVisibleSize( nVisibleSize ? nVisibleSize : 1 ); - pVScroll->SetRange( Range( 0, nRowCount ) ); - pVScroll->SetPosSizePixel( - Point( aDataWinSize.Width(), GetTitleHeight() ), - Size( nCornerSize, aDataWinSize.Height()) ); - if ( nRowCount < - long( aDataWinSize.Height() / GetDataRowHeight() ) ) - ScrollRows( -nTopRow ); - if ( bNeedsVScroll && !pVScroll->IsVisible() ) - pVScroll->Show(); - - pDataWin->SetPosSizePixel( - Point( 0, GetTitleHeight() ), - aDataWinSize ); - - // needs corner-window? - // (do that AFTER positioning BOTH scrollbars) - sal_uLong nActualCorderWidth = 0; - if (aHScroll.IsVisible() && pVScroll && pVScroll->IsVisible() ) - { - // if we have both scrollbars, the corner window fills the point of intersection of these two - nActualCorderWidth = nCornerSize; - } - else if ( !aHScroll.IsVisible() && ( nControlAreaWidth != USHRT_MAX ) ) - { - // if we have no horizontal scrollbar, but a control area, we need the corner window to - // fill the space between the control are and the right border - nActualCorderWidth = GetOutputSizePixel().Width() - nControlAreaWidth; - } - if ( nActualCorderWidth ) - { - if ( !getDataWindow()->pCornerWin ) - getDataWindow()->pCornerWin = new ScrollBarBox( this, 0 ); - getDataWindow()->pCornerWin->SetPosSizePixel( - Point( GetOutputSizePixel().Width() - nActualCorderWidth, aHScroll.GetPosPixel().Y() ), - Size( nActualCorderWidth, nCornerSize ) ); - getDataWindow()->pCornerWin->Show(); - } - else - DELETEZ( getDataWindow()->pCornerWin ); - - // ggf. Headerbar mitscrollen - if ( getDataWindow()->pHeaderBar ) - { - long nWidth = 0; - for ( size_t nCol = 0; - nCol < pCols->size() && nCol < nFirstCol; - ++nCol ) - { - // HandleColumn nicht - if ( (*pCols)[ nCol ]->GetId() ) - nWidth += (*pCols)[ nCol ]->Width(); - } - - getDataWindow()->pHeaderBar->SetOffset( nWidth ); - } - - pBDW->bInUpdateScrollbars = sal_False; - if ( pBDW->bHadRecursion ) - { - pBDW->bHadRecursion = sal_False; - UpdateScrollbars(); - } -} - -//------------------------------------------------------------------- - -void BrowseBox::SetUpdateMode( sal_Bool bUpdate ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - sal_Bool bWasUpdate = IsUpdateMode(); - if ( bWasUpdate == bUpdate ) - return; - - Control::SetUpdateMode( bUpdate ); - // OV - // Wenn an der BrowseBox WB_CLIPCHILDREN gesetzt ist (wg. Flackerminimierung), - // wird das Datenfenster nicht von SetUpdateMode invalidiert. - if( bUpdate ) - getDataWindow()->Invalidate(); - getDataWindow()->SetUpdateMode( bUpdate ); - - - if ( bUpdate ) - { - if ( bBootstrapped ) - { - UpdateScrollbars(); - AutoSizeLastColumn(); - } - DoShowCursor( "SetUpdateMode" ); - } - else - DoHideCursor( "SetUpdateMode" ); -} - -//------------------------------------------------------------------- - -sal_Bool BrowseBox::GetUpdateMode() const -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - return getDataWindow()->IsUpdateMode(); -} - -//------------------------------------------------------------------- - -long BrowseBox::GetFrozenWidth() const -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - long nWidth = 0; - for ( size_t nCol = 0; - nCol < pCols->size() && (*pCols)[ nCol ]->IsFrozen(); - ++nCol ) - nWidth += (*pCols)[ nCol ]->Width(); - return nWidth; -} - -//------------------------------------------------------------------- - -void BrowseBox::ColumnInserted( sal_uInt16 nPos ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - if ( pColSel ) - pColSel->Insert( nPos ); - UpdateScrollbars(); -} - -//------------------------------------------------------------------- - -sal_uInt16 BrowseBox::FrozenColCount() const -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - sal_uInt16 nCol; - for ( nCol = 0; - nCol < pCols->size() && (*pCols)[ nCol ]->IsFrozen(); - ++nCol ) - /* empty loop */; - return nCol; -} - -//------------------------------------------------------------------- - -IMPL_LINK(BrowseBox,ScrollHdl,ScrollBar*,pBar) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - if ( pBar->GetDelta() == 0 ) - return 0; - - if ( pBar->GetDelta() < 0 && getDataWindow()->bNoScrollBack ) - { - UpdateScrollbars(); - return 0; - } - - if ( pBar == &aHScroll ) - ScrollColumns( aHScroll.GetDelta() ); - if ( pBar == pVScroll ) - ScrollRows( pVScroll->GetDelta() ); - - return 0; -} - -//------------------------------------------------------------------- - -IMPL_LINK( BrowseBox,EndScrollHdl,ScrollBar*, EMPTYARG ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - // kein Focus grabben! - /// GrabFocus(); - - if ( getDataWindow()->bNoScrollBack ) - { - EndScroll(); - return 0; - } - - return 0; -} - -//------------------------------------------------------------------- - -IMPL_LINK( BrowseBox, StartDragHdl, HeaderBar*, pBar ) -{ - pBar->SetDragSize( pDataWin->GetOutputSizePixel().Height() ); - return 0; -} - -//------------------------------------------------------------------- -// MI: es wurde immer nur die 1. Spalte resized -#ifdef _MSC_VER -#pragma optimize("",off) -#endif - -void BrowseBox::MouseButtonDown( const MouseEvent& rEvt ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - GrabFocus(); - - // onl< mouse events in the title-line are supported - const Point &rEvtPos = rEvt.GetPosPixel(); - if ( rEvtPos.Y() >= GetTitleHeight() ) - return; - - long nX = 0; - long nWidth = GetOutputSizePixel().Width(); - for ( size_t nCol = 0; nCol < pCols->size() && nX < nWidth; ++nCol ) - { - // is this column visible? - BrowserColumn *pCol = (*pCols)[ nCol ]; - if ( pCol->IsFrozen() || nCol >= nFirstCol ) - { - // compute right end of column - long nR = nX + pCol->Width() - 1; - - // at the end of a column (and not handle column)? - if ( pCol->GetId() && Abs( nR - rEvtPos.X() ) < 2 ) - { - // start resizing the column - bResizing = sal_True; - nResizeCol = nCol; - nDragX = nResizeX = rEvtPos.X(); - SetPointer( Pointer( POINTER_HSPLIT ) ); - CaptureMouse(); - pDataWin->DrawLine( Point( nDragX, 0 ), - Point( nDragX, pDataWin->GetSizePixel().Height() ) ); - nMinResizeX = nX + MIN_COLUMNWIDTH; - return; - } - else if ( nX < rEvtPos.X() && nR > rEvtPos.X() ) - { - MouseButtonDown( BrowserMouseEvent( - this, rEvt, -1, nCol, pCol->GetId(), Rectangle() ) ); - return; - } - nX = nR + 1; - } - } - - // event occurred out of data area - if ( rEvt.IsRight() ) - pDataWin->Command( - CommandEvent( Point( 1, LONG_MAX ), COMMAND_CONTEXTMENU, sal_True ) ); - else - SetNoSelection(); -} - -#ifdef _MSC_VER -#pragma optimize("",on) -#endif - -//------------------------------------------------------------------- - -void BrowseBox::MouseMove( const MouseEvent& rEvt ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - OSL_TRACE( "BrowseBox::MouseMove( MouseEvent )" ); - - Pointer aNewPointer; - - sal_uInt16 nX = 0; - for ( size_t nCol = 0; - nCol < pCols->size() && - ( nX + (*pCols)[ nCol ]->Width() ) < sal_uInt16(GetOutputSizePixel().Width()); - ++nCol ) - // is this column visible? - if ( (*pCols)[ nCol ]->IsFrozen() || nCol >= nFirstCol ) - { - // compute right end of column - BrowserColumn *pCol = (*pCols)[ nCol ]; - sal_uInt16 nR = (sal_uInt16)(nX + pCol->Width() - 1); - - // show resize-pointer? - if ( bResizing || ( pCol->GetId() && - Abs( ((long) nR ) - rEvt.GetPosPixel().X() ) < MIN_COLUMNWIDTH ) ) - { - aNewPointer = Pointer( POINTER_HSPLIT ); - if ( bResizing ) - { - // alte Hilfslinie loeschen - pDataWin->HideTracking() ; - - // erlaubte breite abholen und neues Delta - nDragX = Max( rEvt.GetPosPixel().X(), nMinResizeX ); - long nDeltaX = nDragX - nResizeX; - sal_uInt16 nId = GetColumnId(nResizeCol); - sal_uLong nOldWidth = GetColumnWidth(nId); - nDragX = QueryColumnResize( GetColumnId(nResizeCol), - nOldWidth + nDeltaX ) - + nResizeX - nOldWidth; - - // neue Hilfslinie zeichnen - pDataWin->ShowTracking( Rectangle( Point( nDragX, 0 ), - Size( 1, pDataWin->GetSizePixel().Height() ) ), - SHOWTRACK_SPLIT|SHOWTRACK_WINDOW ); - } - - } - - nX = nR + 1; - } - - SetPointer( aNewPointer ); -} - -//------------------------------------------------------------------- - -void BrowseBox::MouseButtonUp( const MouseEvent & rEvt ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - if ( bResizing ) - { - // Hilfslinie loeschen - pDataWin->HideTracking(); - - // width changed? - nDragX = Max( rEvt.GetPosPixel().X(), nMinResizeX ); - if ( (nDragX - nResizeX) != (long)(*pCols)[ nResizeCol ]->Width() ) - { - // resize column - long nMaxX = pDataWin->GetSizePixel().Width(); - nDragX = Min( nDragX, nMaxX ); - long nDeltaX = nDragX - nResizeX; - sal_uInt16 nId = GetColumnId(nResizeCol); - SetColumnWidth( GetColumnId(nResizeCol), GetColumnWidth(nId) + nDeltaX ); - ColumnResized( nId ); - } - - // end action - SetPointer( Pointer() ); - ReleaseMouse(); - bResizing = sal_False; - } - else - MouseButtonUp( BrowserMouseEvent( (BrowserDataWin*)pDataWin, - MouseEvent( Point( rEvt.GetPosPixel().X(), - rEvt.GetPosPixel().Y() - pDataWin->GetPosPixel().Y() ), - rEvt.GetClicks(), rEvt.GetMode(), rEvt.GetButtons(), - rEvt.GetModifier() ) ) ); -} - -//------------------------------------------------------------------- - -sal_Bool bExtendedMode = sal_False; -sal_Bool bFieldMode = sal_False; - -void BrowseBox::MouseButtonDown( const BrowserMouseEvent& rEvt ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - GrabFocus(); - - // adjust selection while and after double-click - if ( rEvt.GetClicks() == 2 ) - { - SetNoSelection(); - if ( rEvt.GetRow() >= 0 ) - { - GoToRow( rEvt.GetRow() ); - SelectRow( rEvt.GetRow(), sal_True, sal_False ); - } - else - { - if ( bColumnCursor && rEvt.GetColumn() != 0 ) - { - if ( rEvt.GetColumn() < pCols->size() ) - SelectColumnPos( rEvt.GetColumn(), sal_True, sal_False); - } - } - DoubleClick( rEvt ); - } - // selections - else if ( ( rEvt.GetMode() & ( MOUSE_SELECT | MOUSE_SIMPLECLICK ) ) && - ( bColumnCursor || rEvt.GetRow() >= 0 ) ) - { - if ( rEvt.GetClicks() == 1 ) - { - // initialise flags - bHit = sal_False; - a1stPoint = - a2ndPoint = PixelToLogic( rEvt.GetPosPixel() ); - - // selection out of range? - if ( rEvt.GetRow() >= nRowCount || - rEvt.GetColumnId() == BROWSER_INVALIDID ) - { - SetNoSelection(); - return; - } - - // while selecting, no cursor - bSelecting = sal_True; - DoHideCursor( "MouseButtonDown" ); - - // DataRow? - if ( rEvt.GetRow() >= 0 ) - { - // Zeilenselektion? - if ( rEvt.GetColumnId() == 0 || !bColumnCursor ) - { - if ( bMultiSelection ) - { - // remove column-selection, if exists - if ( pColSel && pColSel->GetSelectCount() ) - { - ToggleSelection(); - if ( bMultiSelection ) - uRow.pSel->SelectAll(sal_False); - else - uRow.nSel = BROWSER_ENDOFSELECTION; - if ( pColSel ) - pColSel->SelectAll(sal_False); - bSelect = sal_True; - } - - // expanding mode? - if ( rEvt.GetMode() & MOUSE_RANGESELECT ) - { - // select the further touched rows too - bSelect = sal_True; - ExpandRowSelection( rEvt ); - return; - } - - // click in the selected area? - else if ( IsRowSelected( rEvt.GetRow() ) ) - { - // auf Drag&Drop warten - bHit = sal_True; - bExtendedMode = MOUSE_MULTISELECT == - ( rEvt.GetMode() & MOUSE_MULTISELECT ); - return; - } - - // extension mode? - else if ( rEvt.GetMode() & MOUSE_MULTISELECT ) - { - // determine the new selection range - // and selection/deselection - aSelRange = Range( rEvt.GetRow(), rEvt.GetRow() ); - SelectRow( rEvt.GetRow(), - !uRow.pSel->IsSelected( rEvt.GetRow() ) ); - bSelect = sal_True; - return; - } - } - - // select directly - SetNoSelection(); - GoToRow( rEvt.GetRow() ); - SelectRow( rEvt.GetRow(), sal_True ); - aSelRange = Range( rEvt.GetRow(), rEvt.GetRow() ); - bSelect = sal_True; - } - else // Column/Field-Selection - { - // click in selected column - if ( IsColumnSelected( rEvt.GetColumn() ) || - IsRowSelected( rEvt.GetRow() ) ) - { - bHit = sal_True; - bFieldMode = sal_True; - return; - } - - SetNoSelection(); - GoToRowColumnId( rEvt.GetRow(), rEvt.GetColumnId() ); - bSelect = sal_True; - } - } - else - { - if ( bMultiSelection && rEvt.GetColumnId() == 0 ) - { - // toggle all-selection - if ( uRow.pSel->GetSelectCount() > ( GetRowCount() / 2 ) ) - SetNoSelection(); - else - SelectAll(); - } - else - SelectColumnId( rEvt.GetColumnId(), sal_True, sal_False ); - } - - // ggf. Cursor wieder an - bSelecting = sal_False; - DoShowCursor( "MouseButtonDown" ); - if ( bSelect ) - Select(); - } - } -} - -//------------------------------------------------------------------- - -void BrowseBox::MouseMove( const BrowserMouseEvent& ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); -} - -//------------------------------------------------------------------- - -void BrowseBox::MouseButtonUp( const BrowserMouseEvent &rEvt ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - // D&D was possible, but did not occur - if ( bHit ) - { - aSelRange = Range( rEvt.GetRow(), rEvt.GetRow() ); - if ( bExtendedMode ) - SelectRow( rEvt.GetRow(), sal_False ); - else - { - SetNoSelection(); - if ( bFieldMode ) - GoToRowColumnId( rEvt.GetRow(), rEvt.GetColumnId() ); - else - { - GoToRow( rEvt.GetRow() ); - SelectRow( rEvt.GetRow(), sal_True ); - } - } - bSelect = sal_True; - bExtendedMode = sal_False; - bFieldMode = sal_False; - bHit = sal_False; - } - - // activate cursor - if ( bSelecting ) - { - bSelecting = sal_False; - DoShowCursor( "MouseButtonUp" ); - if ( bSelect ) - Select(); - } -} - -//------------------------------------------------------------------- - -void BrowseBox::KeyInput( const KeyEvent& rEvt ) -{ - if ( !ProcessKey( rEvt ) ) - Control::KeyInput( rEvt ); -} - -//------------------------------------------------------------------- - -sal_Bool BrowseBox::ProcessKey( const KeyEvent& rEvt ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - sal_uInt16 nCode = rEvt.GetKeyCode().GetCode(); - sal_Bool bShift = rEvt.GetKeyCode().IsShift(); - sal_Bool bCtrl = rEvt.GetKeyCode().IsMod1(); - sal_Bool bAlt = rEvt.GetKeyCode().IsMod2(); - - sal_uInt16 nId = BROWSER_NONE; - - if ( !bAlt && !bCtrl && !bShift ) - { - switch ( nCode ) - { - case KEY_DOWN: nId = BROWSER_CURSORDOWN; break; - case KEY_UP: nId = BROWSER_CURSORUP; break; - case KEY_HOME: nId = BROWSER_CURSORHOME; break; - case KEY_END: nId = BROWSER_CURSOREND; break; - case KEY_TAB: - if ( !bColumnCursor ) - break; - case KEY_RIGHT: nId = BROWSER_CURSORRIGHT; break; - case KEY_LEFT: nId = BROWSER_CURSORLEFT; break; - case KEY_SPACE: nId = BROWSER_SELECT; break; - } - if ( BROWSER_NONE != nId ) - SetNoSelection(); - - switch ( nCode ) - { - case KEY_PAGEDOWN: nId = BROWSER_CURSORPAGEDOWN; break; - case KEY_PAGEUP: nId = BROWSER_CURSORPAGEUP; break; - } - } - - if ( !bAlt && !bCtrl && bShift ) - switch ( nCode ) - { - case KEY_DOWN: nId = BROWSER_SELECTDOWN; break; - case KEY_UP: nId = BROWSER_SELECTUP; break; - case KEY_TAB: - if ( !bColumnCursor ) - break; - nId = BROWSER_CURSORLEFT; break; - case KEY_HOME: nId = BROWSER_SELECTHOME; break; - case KEY_END: nId = BROWSER_SELECTEND; break; - } - - - if ( !bAlt && bCtrl && !bShift ) - switch ( nCode ) - { - case KEY_DOWN: nId = BROWSER_CURSORDOWN; break; - case KEY_UP: nId = BROWSER_CURSORUP; break; - case KEY_PAGEDOWN: nId = BROWSER_CURSORENDOFFILE; break; - case KEY_PAGEUP: nId = BROWSER_CURSORTOPOFFILE; break; - case KEY_HOME: nId = BROWSER_CURSORTOPOFSCREEN; break; - case KEY_END: nId = BROWSER_CURSORENDOFSCREEN; break; - case KEY_SPACE: nId = BROWSER_ENHANCESELECTION; break; - case KEY_LEFT: nId = BROWSER_MOVECOLUMNLEFT; break; - case KEY_RIGHT: nId = BROWSER_MOVECOLUMNRIGHT; break; - } - - if ( nId != BROWSER_NONE ) - Dispatch( nId ); - return nId != BROWSER_NONE; -} - -//------------------------------------------------------------------- - -void BrowseBox::Dispatch( sal_uInt16 nId ) -{ - DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants); - - long nRowsOnPage = pDataWin->GetSizePixel().Height() / GetDataRowHeight(); - sal_Bool bDone = sal_False; - - switch ( nId ) - { - case BROWSER_SELECTCOLUMN: - if ( ColCount() ) - SelectColumnId( GetCurColumnId() ); - break; - - case BROWSER_CURSORDOWN: - if ( ( GetCurRow() + 1 ) < nRowCount ) - bDone = GoToRow( GetCurRow() + 1, sal_False ); - break; - case BROWSER_CURSORUP: - if ( GetCurRow() > 0 ) - bDone = GoToRow( GetCurRow() - 1, sal_False ); - break; - case BROWSER_SELECTHOME: - if ( GetRowCount() ) - { - DoHideCursor( "BROWSER_SELECTHOME" ); - for ( long nRow = GetCurRow(); nRow >= 0; --nRow ) - SelectRow( nRow ); - GoToRow( 0, sal_True ); - DoShowCursor( "BROWSER_SELECTHOME" ); - } - break; - case BROWSER_SELECTEND: - if ( GetRowCount() ) - { - DoHideCursor( "BROWSER_SELECTEND" ); - long nRows = GetRowCount(); - for ( long nRow = GetCurRow(); nRow < nRows; ++nRow ) - SelectRow( nRow ); - GoToRow( GetRowCount() - 1, sal_True ); - DoShowCursor( "BROWSER_SELECTEND" ); - } - break; - case BROWSER_SELECTDOWN: - { - if ( GetRowCount() && ( GetCurRow() + 1 ) < nRowCount ) - { - // deselect the current row, if it isn't the first - // and there is no other selected row above - long nRow = GetCurRow(); - sal_Bool bLocalSelect = ( !IsRowSelected( nRow ) || - GetSelectRowCount() == 1 || IsRowSelected( nRow - 1 ) ); - SelectRow( nRow, bLocalSelect, sal_True ); - bDone = GoToRow( GetCurRow() + 1 , sal_False ); - if ( bDone ) - SelectRow( GetCurRow(), sal_True, sal_True ); - } - else - bDone = ScrollRows( 1 ) != 0; - break; - } - case BROWSER_SELECTUP: - if ( GetRowCount() ) - { - // deselect the current row, if it isn't the first - // and there is no other selected row under - long nRow = GetCurRow(); - sal_Bool bLocalSelect = ( !IsRowSelected( nRow ) || - GetSelectRowCount() == 1 || IsRowSelected( nRow + 1 ) ); - SelectRow( nCurRow, bLocalSelect, sal_True ); - bDone = GoToRow( nRow - 1 , sal_False ); - if ( bDone ) - SelectRow( GetCurRow(), sal_True, sal_True ); - } - break; - case BROWSER_CURSORPAGEDOWN: - bDone = (sal_Bool)ScrollRows( nRowsOnPage ); - break; - case BROWSER_CURSORPAGEUP: - bDone = (sal_Bool)ScrollRows( -nRowsOnPage ); - break; - case BROWSER_CURSOREND: - if ( bColumnCursor ) - { - sal_uInt16 nNewId = GetColumnId(ColCount() -1); - bDone = (nNewId != 0) && GoToColumnId( nNewId ); - break; - } - case BROWSER_CURSORENDOFFILE: - bDone = GoToRow( nRowCount - 1, sal_False ); - break; - case BROWSER_CURSORRIGHT: - if ( bColumnCursor ) - { - sal_uInt16 nNewPos = GetColumnPos( GetCurColumnId() ) + 1; - sal_uInt16 nNewId = GetColumnId( nNewPos ); - if (nNewId != 0) // Am Zeilenende ? - bDone = GoToColumnId( nNewId ); - else - { - sal_uInt16 nColId = ( GetColumnId(0) == 0 ) ? GetColumnId(1) : GetColumnId(0); - if ( GetRowCount() ) - bDone = ( nCurRow < GetRowCount() - 1 ) && GoToRowColumnId( nCurRow + 1, nColId ); - else if ( ColCount() ) - GoToColumnId( nColId ); - } - } - else - bDone = ScrollColumns( 1 ) != 0; - break; - case BROWSER_CURSORHOME: - if ( bColumnCursor ) - { - sal_uInt16 nNewId = GetColumnId(1); - bDone = (nNewId != 0) && GoToColumnId( nNewId ); - break; - } - case BROWSER_CURSORTOPOFFILE: - bDone = GoToRow( 0, sal_False ); - break; - case BROWSER_CURSORLEFT: - if ( bColumnCursor ) - { - sal_uInt16 nNewPos = GetColumnPos( GetCurColumnId() ) - 1; - sal_uInt16 nNewId = GetColumnId( nNewPos ); - if (nNewId != 0) - bDone = GoToColumnId( nNewId ); - else - { - if ( GetRowCount() ) - bDone = (nCurRow > 0) && GoToRowColumnId(nCurRow - 1, GetColumnId(ColCount() -1)); - else if ( ColCount() ) - GoToColumnId( GetColumnId(ColCount() -1) ); - } - } - else - bDone = ScrollColumns( -1 ) != 0; - break; - case BROWSER_ENHANCESELECTION: - if ( GetRowCount() ) - SelectRow( GetCurRow(), !IsRowSelected( GetCurRow() ), sal_True ); - bDone = sal_True; - break; - case BROWSER_SELECT: - if ( GetRowCount() ) - SelectRow( GetCurRow(), !IsRowSelected( GetCurRow() ), sal_False ); - bDone = sal_True; - break; - case BROWSER_MOVECOLUMNLEFT: - case BROWSER_MOVECOLUMNRIGHT: - { // check if column moving is allowed - BrowserHeader* pHeaderBar = getDataWindow()->pHeaderBar; - if ( pHeaderBar && pHeaderBar->IsDragable() ) - { - sal_uInt16 nColId = GetCurColumnId(); - sal_Bool bColumnSelected = IsColumnSelected(nColId); - sal_uInt16 nNewPos = GetColumnPos(nColId); - sal_Bool bMoveAllowed = sal_False; - if ( BROWSER_MOVECOLUMNLEFT == nId && nNewPos > 1 ) - --nNewPos,bMoveAllowed = sal_True; - else if ( BROWSER_MOVECOLUMNRIGHT == nId && nNewPos < (ColCount()-1) ) - ++nNewPos,bMoveAllowed = sal_True; - - if ( bMoveAllowed ) - { - SetColumnPos( nColId, nNewPos ); - ColumnMoved( nColId ); - MakeFieldVisible(GetCurRow(),nColId,sal_True); - if ( bColumnSelected ) - SelectColumnId(nColId); - } - } - } - break; - } - - //! return bDone; -} - -//------------------------------------------------------------------- - -void BrowseBox::SetCursorColor(const Color& _rCol) -{ - if (_rCol == m_aCursorColor) - return; - - // ensure the cursor is hidden - DoHideCursor("SetCursorColor"); - if (!m_bFocusOnlyCursor) - DoHideCursor("SetCursorColor - force"); - - m_aCursorColor = _rCol; - - if (!m_bFocusOnlyCursor) - DoShowCursor("SetCursorColor - force"); - DoShowCursor("SetCursorColor"); -} -// ----------------------------------------------------------------------------- -Rectangle BrowseBox::calcHeaderRect(sal_Bool _bIsColumnBar,sal_Bool _bOnScreen) -{ - Window* pParent = NULL; - if ( !_bOnScreen ) - pParent = GetAccessibleParentWindow(); - - Point aTopLeft; - long nWidth; - long nHeight; - if ( _bIsColumnBar ) - { - nWidth = GetDataWindow().GetOutputSizePixel().Width(); - nHeight = GetDataRowHeight(); - } - else - { - aTopLeft.Y() = GetDataRowHeight(); - nWidth = GetColumnWidth(0); - nHeight = GetWindowExtentsRelative( pParent ).GetHeight() - aTopLeft.Y() - GetControlArea().GetSize().B(); - } - aTopLeft += GetWindowExtentsRelative( pParent ).TopLeft(); - return Rectangle(aTopLeft,Size(nWidth,nHeight)); -} -// ----------------------------------------------------------------------------- -Rectangle BrowseBox::calcTableRect(sal_Bool _bOnScreen) -{ - Window* pParent = NULL; - if ( !_bOnScreen ) - pParent = GetAccessibleParentWindow(); - - Rectangle aRect( GetWindowExtentsRelative( pParent ) ); - Rectangle aRowBar = calcHeaderRect(sal_False,pParent == NULL); - - long nX = aRowBar.Right() - aRect.Left(); - long nY = aRowBar.Top() - aRect.Top(); - Size aSize(aRect.GetSize()); - - return Rectangle(aRowBar.TopRight(), Size(aSize.A() - nX, aSize.B() - nY - aHScroll.GetSizePixel().Height()) ); -} -// ----------------------------------------------------------------------------- -Rectangle BrowseBox::GetFieldRectPixelAbs( sal_Int32 _nRowId,sal_uInt16 _nColId, sal_Bool /*_bIsHeader*/, sal_Bool _bOnScreen ) -{ - Window* pParent = NULL; - if ( !_bOnScreen ) - pParent = GetAccessibleParentWindow(); - - Rectangle aRect = GetFieldRectPixel(_nRowId,_nColId,_bOnScreen); - - Point aTopLeft = aRect.TopLeft(); - aTopLeft += GetWindowExtentsRelative( pParent ).TopLeft(); - - return Rectangle(aTopLeft,aRect.GetSize()); -} - -// ------------------------------------------------------------------------- EOF - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/brwbox/brwbox3.cxx b/svtools/source/brwbox/brwbox3.cxx deleted file mode 100644 index 705c8163aa..0000000000 --- a/svtools/source/brwbox/brwbox3.cxx +++ /dev/null @@ -1,571 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svtools.hxx" -#include <svtools/brwbox.hxx> -#include <svtools/AccessibleBrowseBoxObjType.hxx> -#include <tools/debug.hxx> -#include <tools/multisel.hxx> -#include "datwin.hxx" -#include "brwimpl.hxx" -#include <com/sun/star/accessibility/AccessibleStateType.hpp> -#include <com/sun/star/accessibility/AccessibleRole.hpp> -#include <toolkit/helper/vclunohelper.hxx> - -// Accessibility ============================================================== - -using ::rtl::OUString; -using namespace ::com::sun::star::uno; -using ::com::sun::star::accessibility::XAccessible; -using namespace ::com::sun::star::accessibility; - -// ============================================================================ -namespace svt -{ - using namespace ::com::sun::star::lang; - using namespace utl; - - Reference< XAccessible > getHeaderCell( BrowseBoxImpl::THeaderCellMap& _raHeaderCells, - sal_Int32 _nPos, - AccessibleBrowseBoxObjType _eType, - const Reference< XAccessible >& _rParent, - BrowseBox& _rBrowseBox, - IAccessibleFactory& rFactory - ) - { - Reference< XAccessible > xRet; - BrowseBoxImpl::THeaderCellMap::iterator aFind = _raHeaderCells.find( _nPos ); - if ( aFind == _raHeaderCells.end() ) - { - Reference< XAccessible > xAccessible = rFactory.createAccessibleBrowseBoxHeaderCell( - _nPos, - _rParent, - _rBrowseBox, - NULL, - _eType - ); - aFind = _raHeaderCells.insert( BrowseBoxImpl::THeaderCellMap::value_type( _nPos, xAccessible ) ).first; - } - if ( aFind != _raHeaderCells.end() ) - xRet = aFind->second; - return xRet; - } - - // ============================================================================ - // ---------------------------------------------------------------------------- - Reference< XAccessible > BrowseBoxImpl::getAccessibleHeaderBar( AccessibleBrowseBoxObjType _eObjType ) - { - if ( m_pAccessible && m_pAccessible->isAlive() ) - return m_pAccessible->getHeaderBar( _eObjType ); - return NULL; - } - - // ---------------------------------------------------------------------------- - Reference< XAccessible > BrowseBoxImpl::getAccessibleTable( ) - { - if ( m_pAccessible && m_pAccessible->isAlive() ) - return m_pAccessible->getTable( ); - return NULL; - } -} - -// ============================================================================ - -Reference< XAccessible > BrowseBox::CreateAccessible() -{ - Window* pParent = GetAccessibleParentWindow(); - DBG_ASSERT( pParent, "BrowseBox::CreateAccessible - parent not found" ); - - if( pParent && !m_pImpl->m_pAccessible) - { - Reference< XAccessible > xAccParent = pParent->GetAccessible(); - if( xAccParent.is() ) - { - m_pImpl->m_pAccessible = getAccessibleFactory().createAccessibleBrowseBox( - xAccParent, *this - ); - } - } - - Reference< XAccessible > xAccessible; - if ( m_pImpl->m_pAccessible ) - xAccessible = m_pImpl->m_pAccessible->getMyself(); - - return xAccessible; -} -// ----------------------------------------------------------------------------- - -// Children ------------------------------------------------------------------- - -Reference< XAccessible > BrowseBox::CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumnPos ) -{ - // BBINDEX_TABLE must be the table - OSL_ENSURE(m_pImpl->m_pAccessible,"Invalid call: Accessible is null"); - - return m_pImpl->m_aFactoryAccess.getFactory().createAccessibleBrowseBoxTableCell( - m_pImpl->getAccessibleTable(), - *this, - NULL, - _nRow, - _nColumnPos, - OFFSET_DEFAULT - ); -} -// ----------------------------------------------------------------------------- - -Reference< XAccessible > BrowseBox::CreateAccessibleRowHeader( sal_Int32 _nRow ) -{ - return svt::getHeaderCell( - m_pImpl->m_aRowHeaderCellMap, - _nRow, - svt::BBTYPE_ROWHEADERCELL, - m_pImpl->getAccessibleHeaderBar(svt::BBTYPE_ROWHEADERBAR), - *this, - m_pImpl->m_aFactoryAccess.getFactory() - ); -} -// ----------------------------------------------------------------------------- - -Reference< XAccessible > BrowseBox::CreateAccessibleColumnHeader( sal_uInt16 _nColumnPos ) -{ - return svt::getHeaderCell( - m_pImpl->m_aColHeaderCellMap, - _nColumnPos, - svt::BBTYPE_COLUMNHEADERCELL, - m_pImpl->getAccessibleHeaderBar(svt::BBTYPE_COLUMNHEADERBAR), - *this, - m_pImpl->m_aFactoryAccess.getFactory() - ); -} -// ----------------------------------------------------------------------------- - -sal_Int32 BrowseBox::GetAccessibleControlCount() const -{ - return 0; -} -// ----------------------------------------------------------------------------- - -Reference< XAccessible > BrowseBox::CreateAccessibleControl( sal_Int32 ) -{ - DBG_ASSERT( sal_False, "BrowseBox::CreateAccessibleControl: to be overwritten!" ); - return NULL; -} -// ----------------------------------------------------------------------------- - -// Conversions ---------------------------------------------------------------- - -sal_Bool BrowseBox::ConvertPointToCellAddress( - sal_Int32& rnRow, sal_uInt16& rnColumnPos, const Point& rPoint ) -{ - //! TODO has to be checked - rnRow = GetRowAtYPosPixel(rPoint.Y()); - rnColumnPos = GetColumnAtXPosPixel(rPoint.X()); - return rnRow != BROWSER_INVALIDID && rnColumnPos != BROWSER_INVALIDID; -} -// ----------------------------------------------------------------------------- - -sal_Bool BrowseBox::ConvertPointToRowHeader( sal_Int32& rnRow, const Point& rPoint ) -{ - rnRow = GetRowAtYPosPixel(rPoint.Y()); - // sal_uInt16 nColumnId = GetColumnAtXPosPixel(rPoint.X()); - return rnRow != BROWSER_INVALIDID;// && nColumnId == 0; -} -// ----------------------------------------------------------------------------- - -sal_Bool BrowseBox::ConvertPointToColumnHeader( sal_uInt16& _rnColumnPos, const Point& _rPoint ) -{ - _rnColumnPos = GetColumnAtXPosPixel(_rPoint.X()); - return _rnColumnPos != BROWSER_INVALIDID; -} -// ----------------------------------------------------------------------------- - -sal_Bool BrowseBox::ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint ) -{ - //! TODO has to be checked - sal_Int32 nRow = 0; - sal_uInt16 nColumn = 0; - sal_Bool bRet = ConvertPointToCellAddress(nRow,nColumn,_rPoint); - if ( bRet ) - _rnIndex = nRow * ColCount() + nColumn; - - return bRet; -} -// ----------------------------------------------------------------------------- - -// Object data and state ------------------------------------------------------ - -OUString BrowseBox::GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 ) const -{ - OUString aRetText; - switch( eObjType ) - { - case ::svt::BBTYPE_BROWSEBOX: - aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "BrowseBox" ) ); - break; - case ::svt::BBTYPE_TABLE: - aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "Table" ) ); - break; - case ::svt::BBTYPE_ROWHEADERBAR: - aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "RowHeaderBar" ) ); - break; - case ::svt::BBTYPE_COLUMNHEADERBAR: - aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "ColumnHeaderBar" ) ); - break; - case ::svt::BBTYPE_TABLECELL: - aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "TableCell" ) ); -#if OSL_DEBUG_LEVEL > 1 - aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( " [" ) ); - aRetText += OUString::valueOf(sal_Int32(GetCurRow())); - aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "," ) ); - aRetText += OUString::valueOf(sal_Int32(GetCurColumnId())); - aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "]" ) ); -#endif - break; - case ::svt::BBTYPE_ROWHEADERCELL: - aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "RowHeaderCell" ) ); -#if OSL_DEBUG_LEVEL > 1 - aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( " [" ) ); - aRetText += OUString::valueOf(sal_Int32(GetCurRow())); - aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "," ) ); - aRetText += OUString::valueOf(sal_Int32(GetCurColumnId())); - aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "]" ) ); -#endif - break; - case ::svt::BBTYPE_COLUMNHEADERCELL: - aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "ColumnHeaderCell" ) ); -#if OSL_DEBUG_LEVEL > 1 - aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( " [" ) ); - aRetText += OUString::valueOf(sal_Int32(GetCurRow())); - aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "," ) ); - aRetText += OUString::valueOf(sal_Int32(GetCurColumnId())); - aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "]" ) ); -#endif - break; - default: - OSL_FAIL("BrowseBox::GetAccessibleName: invalid enum!"); - } - return aRetText; -} -// ----------------------------------------------------------------------------- - -OUString BrowseBox::GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 ) const -{ - OUString aRetText; - switch( eObjType ) - { - case ::svt::BBTYPE_BROWSEBOX: - aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "BrowseBox description" ) ); - break; - case ::svt::BBTYPE_TABLE: - // aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "TABLE description" ) ); - break; - case ::svt::BBTYPE_ROWHEADERBAR: - // aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "ROWHEADERBAR description" ) ); - break; - case ::svt::BBTYPE_COLUMNHEADERBAR: - // aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "COLUMNHEADERBAR description" ) ); - break; - case ::svt::BBTYPE_TABLECELL: - // aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "TABLECELL description" ) ); - break; - case ::svt::BBTYPE_ROWHEADERCELL: - // aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "ROWHEADERCELL description" ) ); - break; - case ::svt::BBTYPE_COLUMNHEADERCELL: - // aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "COLUMNHEADERCELL description" ) ); - break; - case ::svt::BBTYPE_CHECKBOXCELL: - break; - } - return aRetText; -} -// ----------------------------------------------------------------------------- - -OUString BrowseBox::GetRowDescription( sal_Int32 ) const -{ - return OUString(); -} -// ----------------------------------------------------------------------------- - -OUString BrowseBox::GetColumnDescription( sal_uInt16 _nColumn ) const -{ - return OUString( GetColumnTitle( GetColumnId( _nColumn ) ) ); -} - -// ----------------------------------------------------------------------------- - -void BrowseBox::FillAccessibleStateSet( - ::utl::AccessibleStateSetHelper& rStateSet, - ::svt::AccessibleBrowseBoxObjType eObjType ) const -{ - switch( eObjType ) - { - case ::svt::BBTYPE_BROWSEBOX: - case ::svt::BBTYPE_TABLE: - - rStateSet.AddState( AccessibleStateType::FOCUSABLE ); - if ( HasFocus() ) - rStateSet.AddState( AccessibleStateType::FOCUSED ); - if ( IsActive() ) - rStateSet.AddState( AccessibleStateType::ACTIVE ); - if ( GetUpdateMode() ) - rStateSet.AddState( AccessibleStateType::EDITABLE ); - if ( IsEnabled() ) - { - rStateSet.AddState( AccessibleStateType::ENABLED ); - rStateSet.AddState( AccessibleStateType::SENSITIVE ); - } - if ( IsReallyVisible() ) - rStateSet.AddState( AccessibleStateType::VISIBLE ); - if ( eObjType == ::svt::BBTYPE_TABLE ) - rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS ); - - break; - case ::svt::BBTYPE_ROWHEADERBAR: - rStateSet.AddState( AccessibleStateType::FOCUSABLE ); - rStateSet.AddState( AccessibleStateType::VISIBLE ); - if ( GetSelectRowCount() ) - rStateSet.AddState( AccessibleStateType::FOCUSED ); - rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS ); - break; - case ::svt::BBTYPE_COLUMNHEADERBAR: - rStateSet.AddState( AccessibleStateType::FOCUSABLE ); - rStateSet.AddState( AccessibleStateType::VISIBLE ); - if ( GetSelectColumnCount() ) - rStateSet.AddState( AccessibleStateType::FOCUSED ); - rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS ); - break; - case ::svt::BBTYPE_TABLECELL: - { - sal_Int32 nRow = GetCurRow(); - sal_uInt16 nColumn = GetCurColumnId(); - if ( IsFieldVisible(nRow,nColumn) ) - rStateSet.AddState( AccessibleStateType::VISIBLE ); - if ( !IsFrozen( nColumn ) ) - rStateSet.AddState( AccessibleStateType::FOCUSABLE ); - rStateSet.AddState( AccessibleStateType::TRANSIENT ); - } - break; - case ::svt::BBTYPE_ROWHEADERCELL: - case ::svt::BBTYPE_COLUMNHEADERCELL: - case ::svt::BBTYPE_CHECKBOXCELL: - OSL_FAIL("Illegal call here!"); - break; - } -} -// ----------------------------------------------------------------------- -void BrowseBox::FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, - sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const -{ - //! TODO check if the state is valid for table cells - if ( IsCellVisible( _nRow, _nColumnPos ) ) - _rStateSet.AddState( AccessibleStateType::VISIBLE ); - if ( GetCurrRow() == _nRow && GetCurrColumn() == _nColumnPos ) - _rStateSet.AddState( AccessibleStateType::FOCUSED ); - else // only transient when column is not focused - _rStateSet.AddState( AccessibleStateType::TRANSIENT ); -} -// ----------------------------------------------------------------------------- - -void BrowseBox::GrabTableFocus() -{ - GrabFocus(); -} -// ----------------------------------------------------------------------------- -String BrowseBox::GetCellText(long, sal_uInt16 ) const -{ - DBG_ASSERT(0,"This method has to be implemented by the derived classes! BUG!!"); - return String(); -} - -// ----------------------------------------------------------------------------- -void BrowseBox::commitHeaderBarEvent(sal_Int16 nEventId, - const Any& rNewValue, const Any& rOldValue, sal_Bool _bColumnHeaderBar ) -{ - if ( isAccessibleAlive() ) - m_pImpl->m_pAccessible->commitHeaderBarEvent( nEventId, - rNewValue, rOldValue, _bColumnHeaderBar ); -} - -// ----------------------------------------------------------------------------- -void BrowseBox::commitTableEvent( sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue ) -{ - if ( isAccessibleAlive() ) - m_pImpl->m_pAccessible->commitTableEvent( _nEventId, _rNewValue, _rOldValue ); -} -// ----------------------------------------------------------------------------- -void BrowseBox::commitBrowseBoxEvent( sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue ) -{ - if ( isAccessibleAlive() ) - m_pImpl->m_pAccessible->commitEvent( _nEventId, _rNewValue, _rOldValue); -} - -// ----------------------------------------------------------------------------- -::svt::IAccessibleFactory& BrowseBox::getAccessibleFactory() -{ - return m_pImpl->m_aFactoryAccess.getFactory(); -} - -// ----------------------------------------------------------------------------- -sal_Bool BrowseBox::isAccessibleAlive( ) const -{ - return ( NULL != m_pImpl->m_pAccessible ) && m_pImpl->m_pAccessible->isAlive(); -} -// ----------------------------------------------------------------------------- -// IAccessibleTableProvider -// ----------------------------------------------------------------------------- -sal_Int32 BrowseBox::GetCurrRow() const -{ - return GetCurRow(); -} -// ----------------------------------------------------------------------------- -sal_uInt16 BrowseBox::GetCurrColumn() const -{ - return GetColumnPos( GetCurColumnId() ); -} -// ----------------------------------------------------------------------------- -sal_Bool BrowseBox::HasRowHeader() const -{ - return ( GetColumnId( 0 ) == 0 ); // HandleColumn == RowHeader -} -// ----------------------------------------------------------------------------- -sal_Bool BrowseBox::IsCellFocusable() const -{ - return sal_True; -} -// ----------------------------------------------------------------------------- -sal_Bool BrowseBox::GoToCell( sal_Int32 _nRow, sal_uInt16 _nColumn ) -{ - return GoToRowColumnId( _nRow, GetColumnId( _nColumn ) ); -} -// ----------------------------------------------------------------------------- -void BrowseBox::SelectColumn( sal_uInt16 _nColumn, sal_Bool _bSelect ) -{ - SelectColumnPos( _nColumn, _bSelect ); -} -// ----------------------------------------------------------------------------- -sal_Bool BrowseBox::IsColumnSelected( long _nColumn ) const -{ - return ( pColSel && (0 <= _nColumn) && (_nColumn <= 0xFFF) ) ? - pColSel->IsSelected( static_cast< sal_uInt16 >( _nColumn ) ) : - sal_False; -} -// ----------------------------------------------------------------------------- -sal_Int32 BrowseBox::GetSelectedRowCount() const -{ - return GetSelectRowCount(); -} -// ----------------------------------------------------------------------------- -sal_Int32 BrowseBox::GetSelectedColumnCount() const -{ - const MultiSelection* pColumnSel = GetColumnSelection(); - return pColumnSel ? pColumnSel->GetSelectCount() : 0; -} -// ----------------------------------------------------------------------------- -void BrowseBox::GetAllSelectedRows( ::com::sun::star::uno::Sequence< sal_Int32 >& _rRows ) const -{ - sal_Int32 nCount = GetSelectRowCount(); - if( nCount ) - { - _rRows.realloc( nCount ); - _rRows[ 0 ] = const_cast< BrowseBox* >( this )->FirstSelectedRow(); - for( sal_Int32 nIndex = 1; nIndex < nCount; ++nIndex ) - _rRows[ nIndex ] = const_cast< BrowseBox* >( this )->NextSelectedRow(); - DBG_ASSERT( const_cast< BrowseBox* >( this )->NextSelectedRow() == BROWSER_ENDOFSELECTION, - "BrowseBox::GetAllSelectedRows - too many selected rows found" ); - } -} -// ----------------------------------------------------------------------------- -void BrowseBox::GetAllSelectedColumns( ::com::sun::star::uno::Sequence< sal_Int32 >& _rColumns ) const -{ - const MultiSelection* pColumnSel = GetColumnSelection(); - sal_Int32 nCount = GetSelectedColumnCount(); - if( pColumnSel && nCount ) - { - _rColumns.realloc( nCount ); - - sal_Int32 nIndex = 0; - sal_uInt32 nRangeCount = pColumnSel->GetRangeCount(); - for( sal_uInt32 nRange = 0; nRange < nRangeCount; ++nRange ) - { - const Range& rRange = pColumnSel->GetRange( nRange ); - // loop has to include aRange.Max() - for( sal_Int32 nCol = rRange.Min(); nCol <= rRange.Max(); ++nCol ) - { - DBG_ASSERT( nIndex < nCount, - "GetAllSelectedColumns - range overflow" ); - _rColumns[ nIndex ] = nCol; - ++nIndex; - } - } - } -} -// ----------------------------------------------------------------------------- -sal_Bool BrowseBox::IsCellVisible( sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const -{ - return IsFieldVisible( _nRow, GetColumnId( _nColumnPos ) ); -} -// ----------------------------------------------------------------------------- -String BrowseBox::GetAccessibleCellText(long _nRow, sal_uInt16 _nColPos) const -{ - return GetCellText( _nRow, GetColumnId( _nColPos ) ); -} - -// ----------------------------------------------------------------------------- -sal_Bool BrowseBox::GetGlyphBoundRects( const Point& rOrigin, const String& rStr, int nIndex, int nLen, int nBase, MetricVector& rVector ) -{ - return Control::GetGlyphBoundRects( rOrigin, rStr, nIndex, nLen, nBase, rVector ); -} -// ----------------------------------------------------------------------------- -Rectangle BrowseBox::GetWindowExtentsRelative( Window *pRelativeWindow ) const -{ - return Control::GetWindowExtentsRelative( pRelativeWindow ); -} -// ----------------------------------------------------------------------------- -void BrowseBox::GrabFocus() -{ - Control::GrabFocus(); -} -// ----------------------------------------------------------------------------- -Reference< XAccessible > BrowseBox::GetAccessible( sal_Bool bCreate ) -{ - return Control::GetAccessible( bCreate ); -} -// ----------------------------------------------------------------------------- -Window* BrowseBox::GetAccessibleParentWindow() const -{ - return Control::GetAccessibleParentWindow(); -} -// ----------------------------------------------------------------------------- -Window* BrowseBox::GetWindowInstance() -{ - return this; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/brwbox/brwhead.cxx b/svtools/source/brwbox/brwhead.cxx deleted file mode 100644 index 5761cd1798..0000000000 --- a/svtools/source/brwbox/brwhead.cxx +++ /dev/null @@ -1,118 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svtools.hxx" - -#include <svtools/brwhead.hxx> -#include <svtools/brwbox.hxx> - -//=================================================================== - -BrowserHeader::BrowserHeader( BrowseBox* pParent, WinBits nWinBits ) - :HeaderBar( pParent, nWinBits ) - ,_pBrowseBox( pParent ) -{ - long nHeight = pParent->IsZoom() ? pParent->CalcZoom(pParent->GetTitleHeight()) : pParent->GetTitleHeight(); - - SetPosSizePixel( Point( 0, 0), - Size( pParent->GetOutputSizePixel().Width(), - nHeight ) ); - Show(); -} - -//------------------------------------------------------------------- - -void BrowserHeader::Command( const CommandEvent& rCEvt ) -{ - if ( !GetCurItemId() && COMMAND_CONTEXTMENU == rCEvt.GetCommand() ) - { - Point aPos( rCEvt.GetMousePosPixel() ); - if ( _pBrowseBox->IsFrozen(0) ) - aPos.X() += _pBrowseBox->GetColumnWidth(0); - _pBrowseBox->GetDataWindow().Command( CommandEvent( - Point( aPos.X(), aPos.Y() - GetSizePixel().Height() ), - COMMAND_CONTEXTMENU, rCEvt.IsMouseEvent() ) ); - } -} - -//------------------------------------------------------------------- - -void BrowserHeader::Select() -{ - HeaderBar::Select(); -} - -//------------------------------------------------------------------- - -void BrowserHeader::EndDrag() -{ - // call before other actions, it looks more nice in most cases - HeaderBar::EndDrag(); - Update(); - - // not aborted? - sal_uInt16 nId = GetCurItemId(); - if ( nId ) - { - // 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 - { - // column drag - // Hat sich die Position eigentlich veraendert - // Handlecolumn beruecksichtigen - sal_uInt16 nOldPos = _pBrowseBox->GetColumnPos(nId), - nNewPos = GetItemPos( nId ); - - if (!_pBrowseBox->GetColumnId(0)) // Handle - nNewPos++; - - if (nOldPos != nNewPos) - { - _pBrowseBox->SetColumnPos( nId, nNewPos ); - _pBrowseBox->ColumnMoved( nId ); - } - } - } -} -// ----------------------------------------------------------------------------- - - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/brwbox/brwimpl.hxx b/svtools/source/brwbox/brwimpl.hxx deleted file mode 100644 index a4ce8a7181..0000000000 --- a/svtools/source/brwbox/brwimpl.hxx +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _SVTOOLS_BRWIMPL_HXX -#define _SVTOOLS_BRWIMPL_HXX - -#include "svtaccessiblefactory.hxx" -#include <com/sun/star/lang/XComponent.hpp> - -#include <map> -#include <functional> - -namespace svt -{ - class BrowseBoxImpl - { - // member - public: - typedef ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > AccessibleRef; - typedef ::std::map< sal_Int32, AccessibleRef > THeaderCellMap; - - struct THeaderCellMapFunctorDispose : ::std::unary_function<THeaderCellMap::value_type,void> - { - inline void operator()(const THeaderCellMap::value_type& _aType) - { - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComp( - _aType.second, ::com::sun::star::uno::UNO_QUERY ); - OSL_ENSURE( xComp.is() || !_aType.second.is(), "THeaderCellMapFunctorDispose: invalid accessible cell (no XComponent)!" ); - if ( xComp.is() ) - try - { - xComp->dispose(); - } - catch( const ::com::sun::star::uno::Exception& ) - { - OSL_FAIL( "THeaderCellMapFunctorDispose: caught an exception!" ); - } - } - }; - - public: - AccessibleFactoryAccess m_aFactoryAccess; - IAccessibleBrowseBox* m_pAccessible; - THeaderCellMap m_aColHeaderCellMap; - THeaderCellMap m_aRowHeaderCellMap; - - public: - BrowseBoxImpl() : m_pAccessible(NULL) - { - } - - - /// @see AccessibleBrowseBox::getHeaderBar - ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > - getAccessibleHeaderBar( AccessibleBrowseBoxObjType _eObjType ); - - /// @see AccessibleBrowseBox::getTable - ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > - getAccessibleTable( ); - - }; -} - -#endif // _SVTOOLS_BRWIMPL_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/brwbox/datwin.cxx b/svtools/source/brwbox/datwin.cxx deleted file mode 100644 index 749e6b3d88..0000000000 --- a/svtools/source/brwbox/datwin.cxx +++ /dev/null @@ -1,772 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svtools.hxx" - -#include "datwin.hxx" - -#include <vcl/svapp.hxx> - -#include <vcl/help.hxx> -#include <vcl/image.hxx> - -#include <tools/debug.hxx> - -//=================================================================== -void ButtonFrame::Draw( OutputDevice& rDev ) -{ - Color aOldFillColor = rDev.GetFillColor(); - Color aOldLineColor = rDev.GetLineColor(); - - const StyleSettings &rSettings = rDev.GetSettings().GetStyleSettings(); - Color aColLight( rSettings.GetLightColor() ); - Color aColShadow( rSettings.GetShadowColor() ); - Color aColFace( rSettings.GetFaceColor() ); - - rDev.SetLineColor( aColFace ); - rDev.SetFillColor( aColFace ); - rDev.DrawRect( aRect ); - - if( rDev.GetOutDevType() == OUTDEV_WINDOW ) - { - Window *pWin = (Window*) &rDev; - if( bPressed ) - pWin->DrawSelectionBackground( aRect, 0, sal_True, sal_False, sal_False ); - } - else - { - rDev.SetLineColor( bPressed ? aColShadow : aColLight ); - rDev.DrawLine( aRect.TopLeft(), Point( aRect.Right(), aRect.Top() ) ); - rDev.DrawLine( aRect.TopLeft(), Point( aRect.Left(), aRect.Bottom() - 1 ) ); - rDev.SetLineColor( bPressed ? aColLight : aColShadow ); - rDev.DrawLine( aRect.BottomRight(), Point( aRect.Right(), aRect.Top() ) ); - rDev.DrawLine( aRect.BottomRight(), Point( aRect.Left(), aRect.Bottom() ) ); - } - - if ( aText.Len() ) - { - String aVal = rDev.GetEllipsisString(aText,aInnerRect.GetWidth() - 2*MIN_COLUMNWIDTH); - - Font aFont( rDev.GetFont() ); - sal_Bool bOldTransp = aFont.IsTransparent(); - if ( !bOldTransp ) - { - aFont.SetTransparent( sal_True ); - rDev.SetFont( aFont ); - } - - Color aOldColor = rDev.GetTextColor(); - if (m_bDrawDisabled) - rDev.SetTextColor(rSettings.GetDisableColor()); - - rDev.DrawText( Point( - ( aInnerRect.Left() + aInnerRect.Right() ) / 2 - ( rDev.GetTextWidth(aVal) / 2 ), - aInnerRect.Top() ), aVal ); - - // restore settings - if ( !bOldTransp ) - { - aFont.SetTransparent(sal_False); - rDev.SetFont( aFont ); - } - if (m_bDrawDisabled) - rDev.SetTextColor(aOldColor); - } - - if ( bCurs ) - { - rDev.SetLineColor( Color( COL_BLACK ) ); - rDev.SetFillColor(); - rDev.DrawRect( Rectangle( - Point( aRect.Left(), aRect.Top() ), Point( aRect.Right(), aRect.Bottom() ) ) ); - } - - rDev.SetLineColor( aOldLineColor ); - rDev.SetFillColor( aOldFillColor ); -} - -//------------------------------------------------------------------- - -BrowserColumn::BrowserColumn( sal_uInt16 nItemId, const class Image &rImage, - const String& rTitle, sal_uLong nWidthPixel, const Fraction& rCurrentZoom, - HeaderBarItemBits nFlags ) -: _nId( nItemId ), - _nWidth( nWidthPixel ), - _aImage( rImage ), - _aTitle( rTitle ), - _bFrozen( sal_False ), - _nFlags( nFlags ) -{ - double n = (double)_nWidth; - n *= (double)rCurrentZoom.GetDenominator(); - n /= (double)rCurrentZoom.GetNumerator(); - _nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5); -} - -BrowserColumn::~BrowserColumn() -{ -} - -//------------------------------------------------------------------- - -void BrowserColumn::SetWidth(sal_uLong nNewWidthPixel, const Fraction& rCurrentZoom) -{ - _nWidth = nNewWidthPixel; - double n = (double)_nWidth; - n *= (double)rCurrentZoom.GetDenominator(); - n /= (double)rCurrentZoom.GetNumerator(); - _nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5); -} - -//------------------------------------------------------------------- - -void BrowserColumn::Draw( BrowseBox& rBox, OutputDevice& rDev, const Point& rPos, sal_Bool bCurs ) -{ - if ( _nId == 0 ) - { - // paint handle column - ButtonFrame( rPos, Size( Width()-1, rBox.GetDataRowHeight()-1 ), - String(), sal_False, bCurs, - 0 != (BROWSER_COLUMN_TITLEABBREVATION&_nFlags) ).Draw( rDev ); - Color aOldLineColor = rDev.GetLineColor(); - rDev.SetLineColor( Color( COL_BLACK ) ); - rDev.DrawLine( - Point( rPos.X(), rPos.Y()+rBox.GetDataRowHeight()-1 ), - Point( rPos.X() + Width() - 1, rPos.Y()+rBox.GetDataRowHeight()-1 ) ); - rDev.DrawLine( - Point( rPos.X() + Width() - 1, rPos.Y() ), - Point( rPos.X() + Width() - 1, rPos.Y()+rBox.GetDataRowHeight()-1 ) ); - rDev.SetLineColor( aOldLineColor ); - - rBox.DoPaintField( rDev, - Rectangle( - Point( rPos.X() + 2, rPos.Y() + 2 ), - Size( Width()-1, rBox.GetDataRowHeight()-1 ) ), - GetId(), - BrowseBox::BrowserColumnAccess() ); - } - else - { - // paint data column - long nWidth = Width() == LONG_MAX ? rBox.GetDataWindow().GetSizePixel().Width() : Width(); - - rBox.DoPaintField( rDev, - Rectangle( - Point( rPos.X() + MIN_COLUMNWIDTH, rPos.Y() ), - Size( nWidth-2*MIN_COLUMNWIDTH, rBox.GetDataRowHeight()-1 ) ), - GetId(), - BrowseBox::BrowserColumnAccess() ); - } -} - -//------------------------------------------------------------------- - -void BrowserColumn::ZoomChanged(const Fraction& rNewZoom) -{ - double n = (double)_nOriginalWidth; - n *= (double)rNewZoom.GetNumerator(); - n /= (double)rNewZoom.GetDenominator(); - - _nWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5); -} - -//------------------------------------------------------------------- - -BrowserDataWin::BrowserDataWin( BrowseBox* pParent ) - :Control( pParent, WinBits(WB_CLIPCHILDREN) ) - ,DragSourceHelper( this ) - ,DropTargetHelper( this ) - ,pHeaderBar( 0 ) - ,pEventWin( pParent ) - ,pCornerWin( 0 ) - ,pDtorNotify( 0 ) - ,bInPaint( sal_False ) - ,bInCommand( sal_False ) - ,bNoScrollBack( sal_False ) - ,bNoHScroll( sal_False ) - ,bNoVScroll( sal_False ) - ,bUpdateMode( sal_True ) - ,bResizeOnPaint( sal_False ) - ,bUpdateOnUnlock( sal_False ) - ,bInUpdateScrollbars( sal_False ) - ,bHadRecursion( sal_False ) - ,bOwnDataChangedHdl( sal_False ) - ,bCallingDropCallback( sal_False ) - ,nUpdateLock( 0 ) - ,nCursorHidden( 0 ) - ,m_nDragRowDividerLimit( 0 ) - ,m_nDragRowDividerOffset( 0 ) -{ - aMouseTimer.SetTimeoutHdl( LINK( this, BrowserDataWin, RepeatedMouseMove ) ); - aMouseTimer.SetTimeout( 100 ); -} - -//------------------------------------------------------------------- -BrowserDataWin::~BrowserDataWin() -{ - if( pDtorNotify ) - *pDtorNotify = sal_True; - - for ( size_t i = 0, n = aInvalidRegion.size(); i < n; ++i ) - delete aInvalidRegion[ i ]; - aInvalidRegion.clear(); -} - -//------------------------------------------------------------------- -void BrowserDataWin::LeaveUpdateLock() -{ - if ( !--nUpdateLock ) - { - DoOutstandingInvalidations(); - if (bUpdateOnUnlock ) - { - Control::Update(); - bUpdateOnUnlock = sal_False; - } - } -} - -//------------------------------------------------------------------- -void InitSettings_Impl( Window *pWin, - sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ) -{ - const StyleSettings& rStyleSettings = - pWin->GetSettings().GetStyleSettings(); - - if ( bFont ) - { - Font aFont = rStyleSettings.GetFieldFont(); - if ( pWin->IsControlFont() ) - aFont.Merge( pWin->GetControlFont() ); - pWin->SetZoomedPointFont( aFont ); - } - - if ( bFont || bForeground ) - { - Color aTextColor = rStyleSettings.GetWindowTextColor(); - if ( pWin->IsControlForeground() ) - aTextColor = pWin->GetControlForeground(); - pWin->SetTextColor( aTextColor ); - } - - if ( bBackground ) - { - if( pWin->IsControlBackground() ) - pWin->SetBackground( pWin->GetControlBackground() ); - else - pWin->SetBackground( rStyleSettings.GetWindowColor() ); - } -} - -//------------------------------------------------------------------- -void BrowserDataWin::Update() -{ - if ( !nUpdateLock ) - Control::Update(); - else - bUpdateOnUnlock = sal_True; -} - -//------------------------------------------------------------------- -void BrowserDataWin::DataChanged( const DataChangedEvent& rDCEvt ) -{ - if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && - (rDCEvt.GetFlags() & SETTINGS_STYLE) ) - { - if( !bOwnDataChangedHdl ) - { - InitSettings_Impl( this, sal_True, sal_True, sal_True ); - Invalidate(); - InitSettings_Impl( GetParent(), sal_True, sal_True, sal_True ); - GetParent()->Invalidate(); - GetParent()->Resize(); - } - } - else - Control::DataChanged( rDCEvt ); -} - -//------------------------------------------------------------------- -void BrowserDataWin::Paint( const Rectangle& rRect ) -{ - if ( !nUpdateLock && GetUpdateMode() ) - { - if ( bInPaint ) - { - aInvalidRegion.push_back( new Rectangle( rRect ) ); - return; - } - bInPaint = sal_True; - ( (BrowseBox*) GetParent() )->PaintData( *this, rRect ); - bInPaint = sal_False; - DoOutstandingInvalidations(); - } - else - aInvalidRegion.push_back( new Rectangle( rRect ) ); -} - -//------------------------------------------------------------------- - -BrowseEvent BrowserDataWin::CreateBrowseEvent( const Point& rPosPixel ) -{ - BrowseBox *pBox = GetParent(); - - // seek to row under mouse - long nRelRow = rPosPixel.Y() < 0 - ? -1 - : rPosPixel.Y() / pBox->GetDataRowHeight(); - long nRow = nRelRow < 0 ? -1 : nRelRow + pBox->nTopRow; - - // find column under mouse - long nMouseX = rPosPixel.X(); - long nColX = 0; - size_t nCol; - for ( nCol = 0; - nCol < pBox->pCols->size() && nColX < GetSizePixel().Width(); - ++nCol ) - if ( (*pBox->pCols)[ nCol ]->IsFrozen() || nCol >= pBox->nFirstCol ) - { - nColX += (*pBox->pCols)[ nCol ]->Width(); - if ( nMouseX < nColX ) - break; - } - sal_uInt16 nColId = BROWSER_INVALIDID; - if ( nCol < pBox->pCols->size() ) - nColId = (*pBox->pCols)[ nCol ]->GetId(); - - // compute the field rectangle and field relative MouseEvent - Rectangle aFieldRect; - if ( nCol < pBox->pCols->size() ) - { - nColX -= (*pBox->pCols)[ nCol ]->Width(); - aFieldRect = Rectangle( - Point( nColX, nRelRow * pBox->GetDataRowHeight() ), - Size( (*pBox->pCols)[ nCol ]->Width(), - pBox->GetDataRowHeight() ) ); - } - - // assemble and return the BrowseEvent - return BrowseEvent( this, nRow, nCol, nColId, aFieldRect ); -} - -//------------------------------------------------------------------- -sal_Int8 BrowserDataWin::AcceptDrop( const AcceptDropEvent& _rEvt ) -{ - bCallingDropCallback = sal_True; - sal_Int8 nReturn = DND_ACTION_NONE; - nReturn = GetParent()->AcceptDrop( BrowserAcceptDropEvent( this, _rEvt ) ); - bCallingDropCallback = sal_False; - return nReturn; -} - -//------------------------------------------------------------------- -sal_Int8 BrowserDataWin::ExecuteDrop( const ExecuteDropEvent& _rEvt ) -{ - bCallingDropCallback = sal_True; - sal_Int8 nReturn = DND_ACTION_NONE; - nReturn = GetParent()->ExecuteDrop( BrowserExecuteDropEvent( this, _rEvt ) ); - bCallingDropCallback = sal_False; - return nReturn; -} - -//------------------------------------------------------------------- -void BrowserDataWin::StartDrag( sal_Int8 _nAction, const Point& _rPosPixel ) -{ - if ( !GetParent()->bRowDividerDrag ) - { - Point aEventPos( _rPosPixel ); - aEventPos.Y() += GetParent()->GetTitleHeight(); - GetParent()->StartDrag( _nAction, aEventPos ); - } -} - -//------------------------------------------------------------------- -void BrowserDataWin::Command( const CommandEvent& rEvt ) -{ - // Scrollmaus-Event? - BrowseBox *pBox = GetParent(); - if ( ( (rEvt.GetCommand() == COMMAND_WHEEL) || - (rEvt.GetCommand() == COMMAND_STARTAUTOSCROLL) || - (rEvt.GetCommand() == COMMAND_AUTOSCROLL) ) && - ( HandleScrollCommand( rEvt, &pBox->aHScroll, pBox->pVScroll ) ) ) - return; - - Point aEventPos( rEvt.GetMousePosPixel() ); - long nRow = pBox->GetRowAtYPosPixel( aEventPos.Y(), sal_False); - MouseEvent aMouseEvt( aEventPos, 1, MOUSE_SELECT, MOUSE_LEFT ); - if ( COMMAND_CONTEXTMENU == rEvt.GetCommand() && rEvt.IsMouseEvent() && - nRow < pBox->GetRowCount() && !pBox->IsRowSelected(nRow) ) - { - sal_Bool bDeleted = sal_False; - pDtorNotify = &bDeleted; - bInCommand = sal_True; - MouseButtonDown( aMouseEvt ); - if( bDeleted ) - return; - MouseButtonUp( aMouseEvt ); - if( bDeleted ) - return; - pDtorNotify = 0; - bInCommand = sal_False; - } - - aEventPos.Y() += GetParent()->GetTitleHeight(); - CommandEvent aEvt( aEventPos, rEvt.GetCommand(), - rEvt.IsMouseEvent(), rEvt.GetData() ); - bInCommand = sal_True; - sal_Bool bDeleted = sal_False; - pDtorNotify = &bDeleted; - GetParent()->Command( aEvt ); - if( bDeleted ) - return; - pDtorNotify = 0; - bInCommand = sal_False; - - if ( COMMAND_STARTDRAG == rEvt.GetCommand() ) - MouseButtonUp( aMouseEvt ); - - Control::Command( rEvt ); -} - -//------------------------------------------------------------------- - -sal_Bool BrowserDataWin::ImplRowDividerHitTest( const BrowserMouseEvent& _rEvent ) -{ - if ( ! ( GetParent()->IsInteractiveRowHeightEnabled() - && ( _rEvent.GetRow() >= 0 ) - && ( _rEvent.GetRow() < GetParent()->GetRowCount() ) - && ( _rEvent.GetColumnId() == 0 ) - ) - ) - return sal_False; - - long nDividerDistance = GetParent()->GetDataRowHeight() - ( _rEvent.GetPosPixel().Y() % GetParent()->GetDataRowHeight() ); - return ( nDividerDistance <= 4 ); -} - -//------------------------------------------------------------------- - -void BrowserDataWin::MouseButtonDown( const MouseEvent& rEvt ) -{ - aLastMousePos = OutputToScreenPixel( rEvt.GetPosPixel() ); - - BrowserMouseEvent aBrowserEvent( this, rEvt ); - if ( ( aBrowserEvent.GetClicks() == 1 ) && ImplRowDividerHitTest( aBrowserEvent ) ) - { - StartRowDividerDrag( aBrowserEvent.GetPosPixel() ); - return; - } - - GetParent()->MouseButtonDown( BrowserMouseEvent( this, rEvt ) ); -} - -//------------------------------------------------------------------- - -void BrowserDataWin::MouseMove( const MouseEvent& rEvt ) -{ - // Pseudo MouseMoves verhindern - Point aNewPos = OutputToScreenPixel( rEvt.GetPosPixel() ); - if ( ( aNewPos == aLastMousePos ) ) - return; - aLastMousePos = aNewPos; - - // transform to a BrowseEvent - BrowserMouseEvent aBrowserEvent( this, rEvt ); - GetParent()->MouseMove( aBrowserEvent ); - - // pointer shape - PointerStyle ePointerStyle = POINTER_ARROW; - if ( ImplRowDividerHitTest( aBrowserEvent ) ) - ePointerStyle = POINTER_VSIZEBAR; - SetPointer( Pointer( ePointerStyle ) ); - - // dragging out of the visible area? - if ( rEvt.IsLeft() && - ( rEvt.GetPosPixel().Y() > GetSizePixel().Height() || - rEvt.GetPosPixel().Y() < 0 ) ) - { - // repeat the event - aRepeatEvt = rEvt; - aMouseTimer.Start(); - } - else - // killing old repeat-event - if ( aMouseTimer.IsActive() ) - aMouseTimer.Stop(); -} - -//------------------------------------------------------------------- - -IMPL_LINK_INLINE_START( BrowserDataWin, RepeatedMouseMove, void *, EMPTYARG ) -{ - GetParent()->MouseMove( BrowserMouseEvent( this, aRepeatEvt ) ); - return 0; -} -IMPL_LINK_INLINE_END( BrowserDataWin, RepeatedMouseMove, void *, EMPTYARG ) - -//------------------------------------------------------------------- - -void BrowserDataWin::MouseButtonUp( const MouseEvent& rEvt ) -{ - // Pseudo MouseMoves verhindern - Point aNewPos = OutputToScreenPixel( rEvt.GetPosPixel() ); - aLastMousePos = aNewPos; - - // Move an die aktuelle Position simulieren - MouseMove( rEvt ); - - // eigentliches Up-Handling - ReleaseMouse(); - if ( aMouseTimer.IsActive() ) - aMouseTimer.Stop(); - GetParent()->MouseButtonUp( BrowserMouseEvent( this, rEvt ) ); -} - -//------------------------------------------------------------------- - -void BrowserDataWin::StartRowDividerDrag( const Point& _rStartPos ) -{ - long nDataRowHeight = GetParent()->GetDataRowHeight(); - // the exact separation pos of the two rows - long nDragRowDividerCurrentPos = _rStartPos.Y(); - if ( ( nDragRowDividerCurrentPos % nDataRowHeight ) > nDataRowHeight / 2 ) - nDragRowDividerCurrentPos += nDataRowHeight; - nDragRowDividerCurrentPos /= nDataRowHeight; - nDragRowDividerCurrentPos *= nDataRowHeight; - - m_nDragRowDividerOffset = nDragRowDividerCurrentPos - _rStartPos.Y(); - - m_nDragRowDividerLimit = nDragRowDividerCurrentPos - nDataRowHeight; - - GetParent()->bRowDividerDrag = sal_True; - GetParent()->ImplStartTracking(); - - Rectangle aDragSplitRect( 0, m_nDragRowDividerLimit, GetOutputSizePixel().Width(), nDragRowDividerCurrentPos ); - ShowTracking( aDragSplitRect, SHOWTRACK_SMALL ); - - StartTracking(); -} - -//------------------------------------------------------------------- - -void BrowserDataWin::Tracking( const TrackingEvent& rTEvt ) -{ - if ( !GetParent()->bRowDividerDrag ) - return; - - Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel(); - // stop resizing at our bottom line - if ( aMousePos.Y() > GetOutputSizePixel().Height() ) - aMousePos.Y() = GetOutputSizePixel().Height(); - - if ( rTEvt.IsTrackingEnded() ) - { - HideTracking(); - GetParent()->bRowDividerDrag = sal_False; - GetParent()->ImplEndTracking(); - - if ( !rTEvt.IsTrackingCanceled() ) - { - long nNewRowHeight = aMousePos.Y() + m_nDragRowDividerOffset - m_nDragRowDividerLimit; - - // care for minimum row height - if ( nNewRowHeight < GetParent()->QueryMinimumRowHeight() ) - nNewRowHeight = GetParent()->QueryMinimumRowHeight(); - - GetParent()->SetDataRowHeight( nNewRowHeight ); - GetParent()->RowHeightChanged(); - } - } - else - { - GetParent()->ImplTracking(); - - long nDragRowDividerCurrentPos = aMousePos.Y() + m_nDragRowDividerOffset; - - // care for minimum row height - if ( nDragRowDividerCurrentPos < m_nDragRowDividerLimit + GetParent()->QueryMinimumRowHeight() ) - nDragRowDividerCurrentPos = m_nDragRowDividerLimit + GetParent()->QueryMinimumRowHeight(); - - Rectangle aDragSplitRect( 0, m_nDragRowDividerLimit, GetOutputSizePixel().Width(), nDragRowDividerCurrentPos ); - ShowTracking( aDragSplitRect, SHOWTRACK_SMALL ); - } -} - -//------------------------------------------------------------------- - -void BrowserDataWin::KeyInput( const KeyEvent& rEvt ) -{ - // pass to parent window - if ( !GetParent()->ProcessKey( rEvt ) ) - Control::KeyInput( rEvt ); -} - -//------------------------------------------------------------------- - -void BrowserDataWin::RequestHelp( const HelpEvent& rHEvt ) -{ - pEventWin = this; - GetParent()->RequestHelp( rHEvt ); - pEventWin = GetParent(); -} - -//=================================================================== - -BrowseEvent::BrowseEvent( Window* pWindow, - long nAbsRow, sal_uInt16 nColumn, sal_uInt16 nColumnId, - const Rectangle& rRect ): - pWin(pWindow), - nRow(nAbsRow), - aRect(rRect), - nCol(nColumn), - nColId(nColumnId) -{ -} - -//=================================================================== -BrowserMouseEvent::BrowserMouseEvent( BrowserDataWin *pWindow, - const MouseEvent& rEvt ): - MouseEvent(rEvt), - BrowseEvent( pWindow->CreateBrowseEvent( rEvt.GetPosPixel() ) ) -{ -} - -//------------------------------------------------------------------- - -BrowserMouseEvent::BrowserMouseEvent( Window *pWindow, const MouseEvent& rEvt, - long nAbsRow, sal_uInt16 nColumn, sal_uInt16 nColumnId, - const Rectangle& rRect ): - MouseEvent(rEvt), - BrowseEvent( pWindow, nAbsRow, nColumn, nColumnId, rRect ) -{ -} - -//=================================================================== - -BrowserAcceptDropEvent::BrowserAcceptDropEvent( BrowserDataWin *pWindow, const AcceptDropEvent& rEvt ) - :AcceptDropEvent(rEvt) - ,BrowseEvent( pWindow->CreateBrowseEvent( rEvt.maPosPixel ) ) -{ -} - -//=================================================================== - -BrowserExecuteDropEvent::BrowserExecuteDropEvent( BrowserDataWin *pWindow, const ExecuteDropEvent& rEvt ) - :ExecuteDropEvent(rEvt) - ,BrowseEvent( pWindow->CreateBrowseEvent( rEvt.maPosPixel ) ) -{ -} - -//=================================================================== - -//------------------------------------------------------------------- - -void BrowserDataWin::SetUpdateMode( sal_Bool bMode ) -{ - DBG_ASSERT( !bUpdateMode || aInvalidRegion.empty(), "invalid region not empty" ); - if ( bMode == bUpdateMode ) - return; - - bUpdateMode = bMode; - if ( bMode ) - DoOutstandingInvalidations(); -} - -//------------------------------------------------------------------- -void BrowserDataWin::DoOutstandingInvalidations() -{ - for ( size_t i = 0, n = aInvalidRegion.size(); i < n; ++i ) { - Control::Invalidate( *aInvalidRegion[ i ] ); - delete aInvalidRegion[ i ]; - } - aInvalidRegion.clear(); -} - -//------------------------------------------------------------------- - -void BrowserDataWin::Invalidate( sal_uInt16 nFlags ) -{ - if ( !GetUpdateMode() ) - { - for ( size_t i = 0, n = aInvalidRegion.size(); i < n; ++i ) - delete aInvalidRegion[ i ]; - aInvalidRegion.clear(); - aInvalidRegion.push_back( new Rectangle( Point( 0, 0 ), GetOutputSizePixel() ) ); - } - else - Window::Invalidate( nFlags ); -} - -//------------------------------------------------------------------- - -void BrowserDataWin::Invalidate( const Rectangle& rRect, sal_uInt16 nFlags ) -{ - if ( !GetUpdateMode() ) - aInvalidRegion.push_back( new Rectangle( rRect ) ); - else - Window::Invalidate( rRect, nFlags ); -} - -//=================================================================== - -void BrowserScrollBar::Tracking( const TrackingEvent& rTEvt ) -{ - sal_uLong nPos = GetThumbPos(); - if ( nPos != _nLastPos ) - { - String aTip( String::CreateFromInt32(nPos) ); - aTip += '/'; - if ( _pDataWin->GetRealRowCount().Len() ) - aTip += _pDataWin->GetRealRowCount(); - else - aTip += String::CreateFromInt32(GetRangeMax()); - - Rectangle aRect( GetPointerPosPixel(), Size( GetTextHeight(), GetTextWidth( aTip ) ) ); - if ( _nTip ) - Help::UpdateTip( _nTip, this, aRect, aTip ); - else - _nTip = Help::ShowTip( this, aRect, aTip ); - _nLastPos = nPos; - } - - ScrollBar::Tracking( rTEvt ); -} - -//------------------------------------------------------------------- - -void BrowserScrollBar::EndScroll() -{ - if ( _nTip ) - Help::HideTip( _nTip ); - _nTip = 0; - ScrollBar::EndScroll(); -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/brwbox/datwin.hxx b/svtools/source/brwbox/datwin.hxx deleted file mode 100644 index b159c77053..0000000000 --- a/svtools/source/brwbox/datwin.hxx +++ /dev/null @@ -1,240 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _SFXDATWIN_HXX -#define _SFXDATWIN_HXX - -#include <svtools/brwbox.hxx> -#include <svtools/brwhead.hxx> -#include <vcl/timer.hxx> -#include <vcl/image.hxx> -#include <svtools/transfer.hxx> -#include <vector> - -//=================================================================== - -#define MIN_COLUMNWIDTH 2 -#define DRAG_CRITICAL 4 - -typedef ::std::vector< Rectangle* > RectangleList; - -//=================================================================== - -class ButtonFrame -{ - Rectangle aRect; - Rectangle aInnerRect; - String aText; - sal_Bool bPressed; - sal_Bool bCurs; - sal_Bool bAbbr; - sal_Bool m_bDrawDisabled; - -public: - ButtonFrame( const Point& rPt, const Size& rSz, - const String &rText, - sal_Bool bPress = sal_False, - sal_Bool bCursor = sal_False, - sal_Bool bAbbreviate = sal_True, - sal_Bool _bDrawDisabled = sal_False) - :aRect( rPt, rSz ) - ,aInnerRect( Point( aRect.Left()+1, aRect.Top()+1 ), - Size( aRect.GetWidth()-2, aRect.GetHeight()-2 ) ) - ,aText(rText) - ,bPressed(bPress) - ,bCurs(bCursor) - ,bAbbr(bAbbreviate) - ,m_bDrawDisabled(_bDrawDisabled) - { - } - - void Draw( OutputDevice& rDev ); -}; - -//=================================================================== - -class BrowserColumn -{ - sal_uInt16 _nId; - sal_uLong _nOriginalWidth; - sal_uLong _nWidth; - Image _aImage; - String _aTitle; - sal_Bool _bFrozen; - HeaderBarItemBits _nFlags; - -public: - BrowserColumn( sal_uInt16 nItemId, const Image &rImage, - const String& rTitle, sal_uLong nWidthPixel, const Fraction& rCurrentZoom, - HeaderBarItemBits nFlags ); - virtual ~BrowserColumn(); - - sal_uInt16 GetId() const { return _nId; } - - sal_uLong Width() { return _nWidth; } - Image& GetImage() { return _aImage; } - String& Title() { return _aTitle; } - HeaderBarItemBits& Flags() { return _nFlags; } - - sal_Bool IsFrozen() const { return _bFrozen; } - void Freeze( sal_Bool bFreeze = sal_True ) { _bFrozen = bFreeze; } - - virtual void Draw( BrowseBox& rBox, OutputDevice& rDev, - const Point& rPos, sal_Bool bCurs ); - - void SetWidth(sal_uLong nNewWidthPixel, const Fraction& rCurrentZoom); - void ZoomChanged(const Fraction& rNewZoom); -}; - -//=================================================================== - -class BrowserDataWin - :public Control - ,public DragSourceHelper - ,public DropTargetHelper -{ -public: - BrowserHeader* pHeaderBar; // only for BROWSER_HEADERBAR_NEW - Window* pEventWin; // Window of forwarded events - ScrollBarBox* pCornerWin; // Window in the corner btw the ScrollBars - sal_Bool* pDtorNotify; - AutoTimer aMouseTimer; // recalls MouseMove on dragging out - MouseEvent aRepeatEvt; // a MouseEvent to repeat - Point aLastMousePos; // verhindert pseudo-MouseMoves - - String aRealRowCount; // zur Anzeige im VScrollBar - - RectangleList aInvalidRegion; // invalidated Rectangles during !UpdateMode - bool bInPaint; // TRUE while in Paint - bool bInCommand; // TRUE while in Command - bool bNoScrollBack; // nur vorwaerts scrollen - bool bNoHScroll; // kein horizontaler Scrollbar - bool bNoVScroll; // no vertical scrollbar - bool bAutoHScroll; // autohide horizontaler Scrollbar - bool bAutoVScroll; // autohide horizontaler Scrollbar - bool bUpdateMode; // nicht SV-UpdateMode wegen Invalidate() - bool bAutoSizeLastCol; // last column always fills up window - bool bResizeOnPaint; // outstanding resize-event - bool bUpdateOnUnlock; // Update() while locked - bool bInUpdateScrollbars; // Rekursionsschutz - bool bHadRecursion; // Rekursion war aufgetreten - bool bOwnDataChangedHdl; // dont change colors in DataChanged - bool bCallingDropCallback; // we're in a callback to AcceptDrop or ExecuteDrop curently - sal_uInt16 nUpdateLock; // lock count, dont call Control::Update()! - short nCursorHidden; // new conuter for DoHide/ShowCursor - - long m_nDragRowDividerLimit; - long m_nDragRowDividerOffset; - -public: - BrowserDataWin( BrowseBox* pParent ); - ~BrowserDataWin(); - - virtual void DataChanged( const DataChangedEvent& rDCEvt ); - virtual void Paint( const Rectangle& rRect ); - virtual void RequestHelp( const HelpEvent& rHEvt ); - virtual void Command( const CommandEvent& rEvt ); - virtual void MouseButtonDown( const MouseEvent& rEvt ); - virtual void MouseMove( const MouseEvent& rEvt ); - DECL_LINK( RepeatedMouseMove, void * ); - - virtual void MouseButtonUp( const MouseEvent& rEvt ); - virtual void KeyInput( const KeyEvent& rEvt ); - virtual void Tracking( const TrackingEvent& rTEvt ); - - // DropTargetHelper overridables - virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ); - virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ); - - // DragSourceHelper overridables - virtual void StartDrag( sal_Int8 _nAction, const Point& _rPosPixel ); - - - BrowseEvent CreateBrowseEvent( const Point& rPosPixel ); - void Repaint(); - BrowseBox* GetParent() const - { return (BrowseBox*) Window::GetParent(); } - const String& GetRealRowCount() const { return aRealRowCount; } - - void SetUpdateMode( sal_Bool bMode ); - bool GetUpdateMode() const { return bUpdateMode; } - void EnterUpdateLock() { ++nUpdateLock; } - void LeaveUpdateLock(); - void Update(); - void DoOutstandingInvalidations(); - void Invalidate( sal_uInt16 nFlags = 0 ); - void Invalidate( const Rectangle& rRect, sal_uInt16 nFlags = 0 ); - void Invalidate( const Region& rRegion, sal_uInt16 nFlags = 0 ) - { Control::Invalidate( rRegion, nFlags ); } - -protected: - void StartRowDividerDrag( const Point& _rStartPos ); - sal_Bool ImplRowDividerHitTest( const BrowserMouseEvent& _rEvent ); -}; - -//------------------------------------------------------------------- - -inline void BrowserDataWin::Repaint() -{ - if ( GetUpdateMode() ) - Update(); - Paint( Rectangle( Point(), GetOutputSizePixel() ) ); -} - -//=================================================================== - -class BrowserScrollBar: public ScrollBar -{ - sal_uLong _nTip; - sal_uLong _nLastPos; - BrowserDataWin* _pDataWin; - -public: - BrowserScrollBar( Window* pParent, WinBits nStyle, - BrowserDataWin *pDataWin ) - : ScrollBar( pParent, nStyle ), - _nTip( 0 ), - _nLastPos( ULONG_MAX ), - _pDataWin( pDataWin ) - {} - //ScrollBar( Window* pParent, const ResId& rResId ); - - virtual void Tracking( const TrackingEvent& rTEvt ); - virtual void EndScroll(); -}; - -//=================================================================== - -void InitSettings_Impl( Window *pWin, - sal_Bool bFont = sal_True, sal_Bool bForeground = sal_True, sal_Bool bBackground = sal_True ); - -//=================================================================== - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/brwbox/ebbcontrols.cxx b/svtools/source/brwbox/ebbcontrols.cxx deleted file mode 100644 index 65e59fdcc9..0000000000 --- a/svtools/source/brwbox/ebbcontrols.cxx +++ /dev/null @@ -1,630 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svtools.hxx" -#include <svtools/editbrowsebox.hxx> -#include <vcl/decoview.hxx> -#include <svtools/fmtfield.hxx> -#include <svtools/xtextedt.hxx> - -#include <algorithm> - -// ....................................................................... -namespace svt -{ -// ....................................................................... - - TYPEINIT0(CellController); - TYPEINIT1(EditCellController, CellController); - TYPEINIT1(SpinCellController, CellController); - TYPEINIT1(CheckBoxCellController, CellController); - TYPEINIT1(ComboBoxCellController, CellController); - TYPEINIT1(ListBoxCellController, CellController); - - TYPEINIT1( FormattedFieldCellController, EditCellController ); - - //================================================================== - //= ComboBoxControl - //================================================================== - ComboBoxControl::ComboBoxControl(Window* pParent, WinBits nWinStyle) - :ComboBox(pParent, nWinStyle|WB_DROPDOWN|WB_NOBORDER) - { - EnableAutoSize(sal_False); - EnableAutocomplete(sal_True); - SetDropDownLineCount(5); - } - - //------------------------------------------------------------------ - long ComboBoxControl::PreNotify( NotifyEvent& rNEvt ) - { - switch (rNEvt.GetType()) - { - case EVENT_KEYINPUT: - if (!IsInDropDown()) - { - const KeyEvent *pEvt = rNEvt.GetKeyEvent(); - const KeyCode rKey = pEvt->GetKeyCode(); - - if ((rKey.GetCode() == KEY_UP || rKey.GetCode() == KEY_DOWN) && - (!pEvt->GetKeyCode().IsShift() && pEvt->GetKeyCode().IsMod1())) - { - // select next resp. previous entry - int nPos = GetEntryPos(GetText()); - nPos = nPos + (rKey.GetCode() == KEY_DOWN ? 1 : -1); - if (nPos < 0) - nPos = 0; - if (nPos >= GetEntryCount()) - nPos = GetEntryCount() - 1; - SetText(GetEntry(sal::static_int_cast< sal_uInt16 >(nPos))); - return 1; - } - } - break; - } - return ComboBox::PreNotify(rNEvt); - } - - //================================================================== - //= ComboBoxCellController - //================================================================== - //------------------------------------------------------------------ - ComboBoxCellController::ComboBoxCellController(ComboBoxControl* pWin) - :CellController(pWin) - { - } - - //------------------------------------------------------------------ - sal_Bool ComboBoxCellController::MoveAllowed(const KeyEvent& rEvt) const - { - ComboBoxControl& rBox = GetComboBox(); - switch (rEvt.GetKeyCode().GetCode()) - { - case KEY_END: - case KEY_RIGHT: - { - Selection aSel = rBox.GetSelection(); - return !aSel && aSel.Max() == rBox.GetText().Len(); - } - case KEY_HOME: - case KEY_LEFT: - { - Selection aSel = rBox.GetSelection(); - return !aSel && aSel.Min() == 0; - } - case KEY_UP: - case KEY_DOWN: - if (rBox.IsInDropDown()) - return sal_False; - if (!rEvt.GetKeyCode().IsShift() && - rEvt.GetKeyCode().IsMod1()) - return sal_False; - // drop down the list box - else if (rEvt.GetKeyCode().IsMod2() && rEvt.GetKeyCode().GetCode() == KEY_DOWN) - return sal_False; - case KEY_PAGEUP: - case KEY_PAGEDOWN: - case KEY_RETURN: - if (rBox.IsInDropDown()) - return sal_False; - default: - return sal_True; - } - } - - //------------------------------------------------------------------ - sal_Bool ComboBoxCellController::IsModified() const - { - return GetComboBox().GetSavedValue() != GetComboBox().GetText(); - } - - //------------------------------------------------------------------ - void ComboBoxCellController::ClearModified() - { - GetComboBox().SaveValue(); - } - - //------------------------------------------------------------------ - void ComboBoxCellController::SetModifyHdl(const Link& rLink) - { - GetComboBox().SetModifyHdl(rLink); - } - - //================================================================== - //= ListBoxControl - //================================================================== - //------------------------------------------------------------------ - ListBoxControl::ListBoxControl(Window* pParent, WinBits nWinStyle) - :ListBox(pParent, nWinStyle|WB_DROPDOWN|WB_NOBORDER) - { - EnableAutoSize(sal_False); - EnableMultiSelection(sal_False); - SetDropDownLineCount(20); - } - - //------------------------------------------------------------------ - long ListBoxControl::PreNotify( NotifyEvent& rNEvt ) - { - switch (rNEvt.GetType()) - { - case EVENT_KEYINPUT: - if (!IsInDropDown()) - { - const KeyEvent *pEvt = rNEvt.GetKeyEvent(); - const KeyCode rKey = pEvt->GetKeyCode(); - - if ((rKey.GetCode() == KEY_UP || rKey.GetCode() == KEY_DOWN) && - (!pEvt->GetKeyCode().IsShift() && pEvt->GetKeyCode().IsMod1())) - { - // select next resp. previous entry - int nPos = GetSelectEntryPos(); - nPos = nPos + (rKey.GetCode() == KEY_DOWN ? 1 : -1); - if (nPos < 0) - nPos = 0; - if (nPos >= GetEntryCount()) - nPos = GetEntryCount() - 1; - SelectEntryPos(sal::static_int_cast< sal_uInt16 >(nPos)); - Select(); // for calling Modify - return 1; - } - else if (GetParent()->PreNotify(rNEvt)) - return 1; - } - break; - } - return ListBox::PreNotify(rNEvt); - } - - //================================================================== - //= ListBoxCellController - //================================================================== - //------------------------------------------------------------------ - ListBoxCellController::ListBoxCellController(ListBoxControl* pWin) - :CellController(pWin) - { - } - - //------------------------------------------------------------------ - sal_Bool ListBoxCellController::MoveAllowed(const KeyEvent& rEvt) const - { - ListBoxControl& rBox = GetListBox(); - switch (rEvt.GetKeyCode().GetCode()) - { - case KEY_UP: - case KEY_DOWN: - if (!rEvt.GetKeyCode().IsShift() && - rEvt.GetKeyCode().IsMod1()) - return sal_False; - // drop down the list box - else - if (rEvt.GetKeyCode().IsMod2() && rEvt.GetKeyCode().GetCode() == KEY_DOWN) - return sal_False; - case KEY_PAGEUP: - case KEY_PAGEDOWN: - if (rBox.IsTravelSelect()) - return sal_False; - default: - return sal_True; - } - } - - //------------------------------------------------------------------ - sal_Bool ListBoxCellController::IsModified() const - { - return GetListBox().GetSelectEntryPos() != GetListBox().GetSavedValue(); - } - - //------------------------------------------------------------------ - void ListBoxCellController::ClearModified() - { - GetListBox().SaveValue(); - } - - //------------------------------------------------------------------ - void ListBoxCellController::SetModifyHdl(const Link& rLink) - { - GetListBox().SetSelectHdl(rLink); - } - - //================================================================== - //= CheckBoxControl - //================================================================== - //------------------------------------------------------------------ - CheckBoxControl::CheckBoxControl(Window* pParent, WinBits nWinStyle) - :Control(pParent, nWinStyle) - { - const Wallpaper& rParentBackground = pParent->GetBackground(); - if ( (pParent->GetStyle() & WB_CLIPCHILDREN) || rParentBackground.IsFixed() ) - SetBackground( rParentBackground ); - else - { - SetPaintTransparent( sal_True ); - SetBackground(); - } - - EnableChildTransparentMode(); - - pBox = new TriStateBox(this,WB_CENTER|WB_VCENTER); - pBox->EnableChildTransparentMode(); - pBox->SetPaintTransparent( sal_True ); - pBox->SetClickHdl( LINK( this, CheckBoxControl, OnClick ) ); - pBox->Show(); - } - - //------------------------------------------------------------------ - CheckBoxControl::~CheckBoxControl() - { - delete pBox; - } - - //------------------------------------------------------------------ - IMPL_LINK( CheckBoxControl, OnClick, void*, EMPTYARG ) - { - m_aClickLink.Call(pBox); - return m_aModifyLink.Call(pBox); - } - - //------------------------------------------------------------------ - void CheckBoxControl::Resize() - { - Control::Resize(); - pBox->SetPosSizePixel(Point(0,0),GetSizePixel()); - } - - //------------------------------------------------------------------------------ - void CheckBoxControl::DataChanged( const DataChangedEvent& _rEvent ) - { - if ( _rEvent.GetType() == DATACHANGED_SETTINGS ) - pBox->SetSettings( GetSettings() ); - } - - //------------------------------------------------------------------------------ - void CheckBoxControl::StateChanged( StateChangedType nStateChange ) - { - Control::StateChanged(nStateChange); - if ( nStateChange == STATE_CHANGE_ZOOM ) - pBox->SetZoom(GetZoom()); - } - - //------------------------------------------------------------------ - void CheckBoxControl::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) - { - pBox->Draw(pDev,rPos,rSize,nFlags); - } - - //------------------------------------------------------------------ - void CheckBoxControl::GetFocus() - { - pBox->GrabFocus(); - } - - //------------------------------------------------------------------ - void CheckBoxControl::Paint(const Rectangle& rClientRect) - { - Control::Paint(rClientRect); - if (HasFocus()) - ShowFocus(aFocusRect); - } - - //------------------------------------------------------------------ - long CheckBoxControl::PreNotify(NotifyEvent& rEvt) - { - switch (rEvt.GetType()) - { - case EVENT_GETFOCUS: - ShowFocus(aFocusRect); - break; - case EVENT_LOSEFOCUS: - HideFocus(); - } - return Control::PreNotify(rEvt); - } - - //================================================================== - //= CheckBoxCellController - //================================================================== - //------------------------------------------------------------------ - sal_Bool CheckBoxCellController::WantMouseEvent() const - { - return sal_True; - } - - //------------------------------------------------------------------ - CheckBox& CheckBoxCellController::GetCheckBox() const - { - return ((CheckBoxControl &)GetWindow()).GetBox(); - } - - //------------------------------------------------------------------ - sal_Bool CheckBoxCellController::IsModified() const - { - return GetCheckBox().GetSavedValue() != GetCheckBox().GetState(); - } - - //------------------------------------------------------------------ - void CheckBoxCellController::ClearModified() - { - GetCheckBox().SaveValue(); - } - - //------------------------------------------------------------------ - void CheckBoxCellController::SetModifyHdl(const Link& rLink) - { - ((CheckBoxControl &)GetWindow()).SetModifyHdl(rLink); - } - - //================================================================== - //= MultiLineEditImplementation - //================================================================== - //------------------------------------------------------------------ - String MultiLineEditImplementation::GetText( LineEnd aSeparator ) const - { - return const_cast< MultiLineEditImplementation* >( this )->GetEditWindow().GetText( aSeparator ); - } - - //------------------------------------------------------------------ - String MultiLineEditImplementation::GetSelected( LineEnd aSeparator ) const - { - return const_cast< MultiLineEditImplementation* >( this )->GetEditWindow().GetSelected( aSeparator ); - } - - //================================================================== - //= EditCellController - //================================================================== - //------------------------------------------------------------------ - EditCellController::EditCellController( Edit* _pEdit ) - :CellController( _pEdit ) - ,m_pEditImplementation( new EditImplementation( *_pEdit ) ) - ,m_bOwnImplementation( sal_True ) - { - } - - //------------------------------------------------------------------ - EditCellController::EditCellController( MultiLineTextCell* _pEdit ) - :CellController( _pEdit ) - ,m_pEditImplementation( new MultiLineEditImplementation( *_pEdit ) ) - ,m_bOwnImplementation( sal_True ) - { - } - - //------------------------------------------------------------------ - EditCellController::EditCellController( IEditImplementation* _pImplementation ) - :CellController( &_pImplementation->GetControl() ) - ,m_pEditImplementation( _pImplementation ) - ,m_bOwnImplementation( sal_False ) - { - } - - //----------------------------------------------------------------------------- - EditCellController::~EditCellController( ) - { - if ( m_bOwnImplementation ) - DELETEZ( m_pEditImplementation ); - } - - //----------------------------------------------------------------------------- - void EditCellController::SetModified() - { - m_pEditImplementation->SetModified(); - } - - //----------------------------------------------------------------------------- - void EditCellController::ClearModified() - { - m_pEditImplementation->ClearModified(); - } - - //------------------------------------------------------------------ - sal_Bool EditCellController::MoveAllowed(const KeyEvent& rEvt) const - { - sal_Bool bResult; - switch (rEvt.GetKeyCode().GetCode()) - { - case KEY_END: - case KEY_RIGHT: - { - Selection aSel = m_pEditImplementation->GetSelection(); - bResult = !aSel && aSel.Max() == m_pEditImplementation->GetText( LINEEND_LF ).Len(); - } break; - case KEY_HOME: - case KEY_LEFT: - { - Selection aSel = m_pEditImplementation->GetSelection(); - bResult = !aSel && aSel.Min() == 0; - } break; - default: - bResult = sal_True; - } - return bResult; - } - - //------------------------------------------------------------------ - sal_Bool EditCellController::IsModified() const - { - return m_pEditImplementation->IsModified(); - } - - //------------------------------------------------------------------ - void EditCellController::SetModifyHdl(const Link& rLink) - { - m_pEditImplementation->SetModifyHdl(rLink); - } - - //================================================================== - //= SpinCellController - //================================================================== - //------------------------------------------------------------------ - SpinCellController::SpinCellController(SpinField* pWin) - :CellController(pWin) - { - } - - //----------------------------------------------------------------------------- - void SpinCellController::SetModified() - { - GetSpinWindow().SetModifyFlag(); - } - - //----------------------------------------------------------------------------- - void SpinCellController::ClearModified() - { - GetSpinWindow().ClearModifyFlag(); - } - - //------------------------------------------------------------------ - sal_Bool SpinCellController::MoveAllowed(const KeyEvent& rEvt) const - { - sal_Bool bResult; - switch (rEvt.GetKeyCode().GetCode()) - { - case KEY_END: - case KEY_RIGHT: - { - Selection aSel = GetSpinWindow().GetSelection(); - bResult = !aSel && aSel.Max() == GetSpinWindow().GetText().Len(); - } break; - case KEY_HOME: - case KEY_LEFT: - { - Selection aSel = GetSpinWindow().GetSelection(); - bResult = !aSel && aSel.Min() == 0; - } break; - default: - bResult = sal_True; - } - return bResult; - } - - //------------------------------------------------------------------ - sal_Bool SpinCellController::IsModified() const - { - return GetSpinWindow().IsModified(); - } - - //------------------------------------------------------------------ - void SpinCellController::SetModifyHdl(const Link& rLink) - { - GetSpinWindow().SetModifyHdl(rLink); - } - - //================================================================== - //= FormattedFieldCellController - //================================================================== - //------------------------------------------------------------------ - FormattedFieldCellController::FormattedFieldCellController( FormattedField* _pFormatted ) - :EditCellController( _pFormatted ) - { - } - - //------------------------------------------------------------------ - void FormattedFieldCellController::CommitModifications() - { - static_cast< FormattedField& >( GetWindow() ).Commit(); - } - - //================================================================== - //= MultiLineTextCell - //================================================================== - //------------------------------------------------------------------ - void MultiLineTextCell::Modify() - { - GetTextEngine()->SetModified( sal_True ); - MultiLineEdit::Modify(); - } - - //------------------------------------------------------------------ - sal_Bool MultiLineTextCell::dispatchKeyEvent( const KeyEvent& _rEvent ) - { - Selection aOldSelection( GetSelection() ); - - sal_Bool bWasModified = IsModified(); - ClearModifyFlag( ); - - sal_Bool bHandled = GetTextView()->KeyInput( _rEvent ); - - sal_Bool bIsModified = IsModified(); - if ( bWasModified && !bIsModified ) - // not sure whether this can really happen - SetModifyFlag(); - - if ( bHandled ) // the view claimed it handled the key input - { - // unfortunately, KeyInput also returns <TRUE/> (means "I handled this key input") - // when nothing really changed. Let's care for this. - Selection aNewSelection( GetSelection() ); - if ( aNewSelection != aOldSelection // selection changed - || bIsModified // or some other modification - ) - return sal_True; - } - return sal_False; - } - - //------------------------------------------------------------------ - long MultiLineTextCell::PreNotify( NotifyEvent& rNEvt ) - { - if ( rNEvt.GetType() == EVENT_KEYINPUT ) - { - if ( IsWindowOrChild( rNEvt.GetWindow() ) ) - { - // give the text view a chance to handle the keys - // this is necessary since a lot of keys which are normally handled - // by this view (in KeyInput) are intercepted by the EditBrowseBox, - // which uses them for other reasons. An example is the KeyUp key, - // which is used by both the text view and the edit browse box - - const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent(); - const KeyCode& rKeyCode = pKeyEvent->GetKeyCode(); - sal_uInt16 nCode = rKeyCode.GetCode(); - - if ( ( nCode == KEY_RETURN ) && ( rKeyCode.GetModifier() == KEY_MOD1 ) ) - { - KeyEvent aEvent( pKeyEvent->GetCharCode(), - KeyCode( KEY_RETURN ), - pKeyEvent->GetRepeat() - ); - if ( dispatchKeyEvent( aEvent ) ) - return 1; - } - - if ( ( nCode != KEY_TAB ) && ( nCode != KEY_RETURN ) ) // everything but tab and enter - { - if ( dispatchKeyEvent( *pKeyEvent ) ) - return 1; - } - } - } - return MultiLineEdit::PreNotify( rNEvt ); - } - -// ....................................................................... -} // namespace svt -// ....................................................................... - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/brwbox/editbrowsebox.cxx b/svtools/source/brwbox/editbrowsebox.cxx deleted file mode 100644 index 39db5754ab..0000000000 --- a/svtools/source/brwbox/editbrowsebox.cxx +++ /dev/null @@ -1,1419 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svtools.hxx" -#include <svtools/editbrowsebox.hxx> - -#include "editbrowsebox.hrc" - -#include <vcl/svapp.hxx> -#include <tools/debug.hxx> -#include <vcl/window.hxx> - -#include <vcl/edit.hxx> -#include <tools/resid.hxx> -#include <vcl/spinfld.hxx> -#include <svtools/svtdata.hxx> - -#include <svtools/svtools.hrc> - -#include <algorithm> -#include <tools/multisel.hxx> -#include "editbrowseboximpl.hxx" -#include <com/sun/star/accessibility/AccessibleEventId.hpp> -#include <com/sun/star/accessibility/XAccessible.hpp> -#include <comphelper/types.hxx> - -// ....................................................................... -namespace svt -{ -// ....................................................................... - namespace - { - //.............................................................. - sal_uInt16 getRealGetFocusFlags( Window* _pWindow ) - { - sal_uInt16 nFlags = 0; - while ( _pWindow && !nFlags ) - { - nFlags = _pWindow->GetGetFocusFlags( ); - _pWindow = _pWindow->GetParent(); - } - return nFlags; - } - } - - using namespace ::com::sun::star::uno; - using namespace com::sun::star::accessibility::AccessibleEventId; - using com::sun::star::accessibility::XAccessible; - //================================================================== - - #define HANDLE_ID 0 - - //================================================================== - //= EditBrowserHeader - //================================================================== - //------------------------------------------------------------------------------ - void EditBrowserHeader::DoubleClick() - { - sal_uInt16 nColId = GetCurItemId(); - if (nColId) - { - sal_uInt32 nAutoWidth = ((EditBrowseBox*)GetParent())->GetAutoColumnWidth(nColId); - if (nAutoWidth != ((EditBrowseBox*)GetParent())->GetColumnWidth(nColId)) - { - ((EditBrowseBox*)GetParent())->SetColumnWidth(nColId, nAutoWidth); - ((EditBrowseBox*)GetParent())->ColumnResized(nColId); - } - } - } - - - //================================================================== - //= EditBrowseBox - //================================================================== - //------------------------------------------------------------------------------ - void EditBrowseBox::BrowserMouseEventPtr::Clear() - { - DELETEZ(pEvent); - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::BrowserMouseEventPtr::Set(const BrowserMouseEvent* pEvt, sal_Bool bIsDown) - { - if (pEvt == pEvent) - { - bDown = bIsDown; - return; - } - Clear(); - if (pEvt) - { - pEvent = new BrowserMouseEvent(pEvt->GetWindow(), - *pEvt, - pEvt->GetRow(), - pEvt->GetColumn(), - pEvt->GetColumnId(), - pEvt->GetRect()); - bDown = bIsDown; - } - } - - //------------------------------------------------------------------------------ - DBG_NAME(EditBrowseBox); - void EditBrowseBox::impl_construct() - { - m_aImpl = ::std::auto_ptr<EditBrowseBoxImpl>(new EditBrowseBoxImpl()); - - SetCompoundControl(sal_True); - SetGridLineColor( Color( COL_LIGHTGRAY ) ); - - ImplInitSettings(sal_True, sal_True, sal_True); - - pCheckBoxPaint = new CheckBoxControl(&GetDataWindow()); - pCheckBoxPaint->SetPaintTransparent( sal_True ); - pCheckBoxPaint->SetBackground(); - } - - //------------------------------------------------------------------------------ - EditBrowseBox::EditBrowseBox(Window* pParent, const ResId& rId, sal_Int32 nBrowserFlags, BrowserMode _nMode ) - :BrowseBox( pParent, rId, _nMode ) - ,nStartEvent(0) - ,nEndEvent(0) - ,nCellModifiedEvent(0) - ,nPaintRow(-1) - ,nEditRow(-1) - ,nOldEditRow(-1) - ,nEditCol(0) - ,nOldEditCol(0) - ,bHasFocus(sal_False) - ,bPaintStatus(sal_True) - ,bActiveBeforeTracking( sal_False ) - ,m_nBrowserFlags(nBrowserFlags) - { - DBG_CTOR(EditBrowseBox,NULL); - - impl_construct(); - } - - //================================================================== - EditBrowseBox::EditBrowseBox( Window* pParent, sal_Int32 nBrowserFlags, WinBits nBits, BrowserMode _nMode ) - :BrowseBox( pParent, nBits, _nMode ) - ,nStartEvent(0) - ,nEndEvent(0) - ,nCellModifiedEvent(0) - ,nPaintRow(-1) - ,nEditRow(-1) - ,nOldEditRow(-1) - ,nEditCol(0) - ,nOldEditCol(0) - ,bHasFocus(sal_False) - ,bPaintStatus(sal_True) - ,bActiveBeforeTracking( sal_False ) - ,m_nBrowserFlags(nBrowserFlags) - ,pHeader(NULL) - { - DBG_CTOR(EditBrowseBox,NULL); - - impl_construct(); - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::Init() - { - // spaetes Construieren, - } - - //------------------------------------------------------------------------------ - EditBrowseBox::~EditBrowseBox() - { - if (nStartEvent) - Application::RemoveUserEvent(nStartEvent); - if (nEndEvent) - Application::RemoveUserEvent(nEndEvent); - if (nCellModifiedEvent) - Application::RemoveUserEvent(nCellModifiedEvent); - - delete pCheckBoxPaint; - - DBG_DTOR(EditBrowseBox,NULL); - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::RemoveRows() - { - BrowseBox::Clear(); - nOldEditRow = nEditRow = nPaintRow = -1; - nEditCol = nOldEditCol = 0; - } - - //------------------------------------------------------------------------------ - BrowserHeader* EditBrowseBox::CreateHeaderBar(BrowseBox* pParent) - { - pHeader = imp_CreateHeaderBar(pParent); - if (!IsUpdateMode()) - pHeader->SetUpdateMode(sal_False); - return pHeader; - } - - //------------------------------------------------------------------------------ - BrowserHeader* EditBrowseBox::imp_CreateHeaderBar(BrowseBox* pParent) - { - return new EditBrowserHeader(pParent); - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::LoseFocus() - { - BrowseBox::LoseFocus(); - DetermineFocus( 0 ); - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::GetFocus() - { - BrowseBox::GetFocus(); - - // This should handle the case that the BrowseBox (or one of it's children) - // gets the focus from outside by pressing Tab - if (IsEditing() && Controller()->GetWindow().IsVisible()) - Controller()->GetWindow().GrabFocus(); - - DetermineFocus( getRealGetFocusFlags( this ) ); - } - - //------------------------------------------------------------------------------ - sal_Bool EditBrowseBox::SeekRow(long nRow) - { - nPaintRow = nRow; - return sal_True; - } - - //------------------------------------------------------------------------------ - IMPL_LINK(EditBrowseBox, StartEditHdl, void*, EMPTYARG) - { - nStartEvent = 0; - if (IsEditing()) - { - EnableAndShow(); - if (!aController->GetWindow().HasFocus() && (m_pFocusWhileRequest == Application::GetFocusWindow())) - aController->GetWindow().GrabFocus(); - } - return 0; - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::PaintField( OutputDevice& rDev, const Rectangle& rRect, - sal_uInt16 nColumnId ) const - { - if (nColumnId == HANDLE_ID) - { - if (bPaintStatus) - PaintStatusCell(rDev, rRect); - } - else - { - // don't paint the current cell - if (&rDev == &GetDataWindow()) - // but only if we're painting onto our data win (which is the usual painting) - if (nPaintRow == nEditRow) - { - if (IsEditing() && nEditCol == nColumnId && aController->GetWindow().IsVisible()) - return; - } - PaintCell(rDev, rRect, nColumnId); - } - } - - //------------------------------------------------------------------------------ - Image EditBrowseBox::GetImage(RowStatus eStatus) const - { - if ( !m_aStatusImages.GetImageCount() ) - { - const_cast<EditBrowseBox*>(this)->m_aStatusImages = ImageList( SvtResId( RID_SVTOOLS_IMAGELIST_EDITBROWSEBOX ) ); - } - - Image aImage; - bool bNeedMirror = IsRTLEnabled(); - switch (eStatus) - { - case CURRENT: - aImage = m_aStatusImages.GetImage(IMG_EBB_CURRENT); - break; - case CURRENTNEW: - aImage = m_aStatusImages.GetImage(IMG_EBB_CURRENTNEW); - break; - case MODIFIED: - aImage = m_aStatusImages.GetImage(IMG_EBB_MODIFIED); - bNeedMirror = false; // the pen is not mirrored - break; - case NEW: - aImage = m_aStatusImages.GetImage(IMG_EBB_NEW); - break; - case DELETED: - aImage = m_aStatusImages.GetImage(IMG_EBB_DELETED); - break; - case PRIMARYKEY: - aImage = m_aStatusImages.GetImage(IMG_EBB_PRIMARYKEY); - break; - case CURRENT_PRIMARYKEY: - aImage = m_aStatusImages.GetImage(IMG_EBB_CURRENT_PRIMARYKEY); - break; - case FILTER: - aImage = m_aStatusImages.GetImage(IMG_EBB_FILTER); - break; - case HEADERFOOTER: - aImage = m_aStatusImages.GetImage(IMG_EBB_HEADERFOOTER); - break; - case CLEAN: - break; - } - if ( bNeedMirror ) - { - BitmapEx aBitmap( aImage.GetBitmapEx() ); - aBitmap.Mirror( BMP_MIRROR_HORZ ); - aImage = Image( aBitmap ); - } - return aImage; - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::PaintStatusCell(OutputDevice& rDev, const Rectangle& rRect) const - { - if (nPaintRow < 0) - return; - - RowStatus eStatus = GetRowStatus( nPaintRow ); - sal_Int32 nBrowserFlags = GetBrowserFlags(); - - if (nBrowserFlags & EBBF_NO_HANDLE_COLUMN_CONTENT) - return; - - // draw the text of the header column - if (nBrowserFlags & EBBF_HANDLE_COLUMN_TEXT ) - { - rDev.DrawText( rRect, GetCellText( nPaintRow, 0 ), - TEXT_DRAW_CENTER | TEXT_DRAW_VCENTER | TEXT_DRAW_CLIP ); - } - // draw an image - else if (eStatus != CLEAN && rDev.GetOutDevType() == OUTDEV_WINDOW) - { - Image aImage(GetImage(eStatus)); - // calc the image position - Size aImageSize(aImage.GetSizePixel()); - aImageSize.Width() = CalcZoom(aImageSize.Width()); - aImageSize.Height() = CalcZoom(aImageSize.Height()); - Point aPos( rRect.TopLeft() ); - - if ( ( aImageSize.Width() > rRect.GetWidth() ) || ( aImageSize.Height() > rRect.GetHeight() ) ) - rDev.SetClipRegion(rRect); - - if ( aImageSize.Width() < rRect.GetWidth() ) - aPos.X() += ( rRect.GetWidth() - aImageSize.Width() ) / 2; - - if ( aImageSize.Height() < rRect.GetHeight() ) - aPos.Y() += ( rRect.GetHeight() - aImageSize.Height() ) / 2; - - if ( IsZoom() ) - rDev.DrawImage( aPos, aImageSize, aImage, 0 ); - else - rDev.DrawImage( aPos, aImage, 0 ); - - if (rDev.IsClipRegion()) - rDev.SetClipRegion(); - } - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::ImplStartTracking() - { - bActiveBeforeTracking = IsEditing(); - if ( bActiveBeforeTracking ) - { - DeactivateCell(); - Update(); - } - - BrowseBox::ImplStartTracking(); - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::ImplTracking() - { - BrowseBox::ImplTracking(); - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::ImplEndTracking() - { - if ( bActiveBeforeTracking ) - ActivateCell(); - bActiveBeforeTracking = sal_False; - - BrowseBox::ImplEndTracking(); - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::RowHeightChanged() - { - if ( IsEditing() ) - { - Rectangle aRect( GetCellRect( nEditRow, nEditCol, sal_False ) ); - CellControllerRef aCellController( Controller() ); - ResizeController( aCellController, aRect ); - aCellController->GetWindow().GrabFocus(); - } - - BrowseBox::RowHeightChanged(); - } - - //------------------------------------------------------------------------------ - EditBrowseBox::RowStatus EditBrowseBox::GetRowStatus(long) const - { - return CLEAN; - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::KeyInput( const KeyEvent& rEvt ) - { - sal_uInt16 nCode = rEvt.GetKeyCode().GetCode(); - sal_Bool bShift = rEvt.GetKeyCode().IsShift(); - sal_Bool bCtrl = rEvt.GetKeyCode().IsMod1(); - - switch (nCode) - { - case KEY_RETURN: - if (!bCtrl && !bShift && IsTabAllowed(sal_True)) - { - Dispatch(BROWSER_CURSORRIGHT); - } - else - BrowseBox::KeyInput(rEvt); - return; - case KEY_TAB: - if (!bCtrl && !bShift) - { - if (IsTabAllowed(sal_True)) - Dispatch(BROWSER_CURSORRIGHT); - else - // do NOT call BrowseBox::KeyInput : this would handle the tab, but we already now - // that tab isn't allowed here. So give the Control class a chance - Control::KeyInput(rEvt); - return; - } - else if (!bCtrl && bShift) - { - if (IsTabAllowed(sal_False)) - Dispatch(BROWSER_CURSORLEFT); - else - // do NOT call BrowseBox::KeyInput : this would handle the tab, but we already now - // that tab isn't allowed here. So give the Control class a chance - Control::KeyInput(rEvt); - return; - } - default: - BrowseBox::KeyInput(rEvt); - } - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::MouseButtonDown(const BrowserMouseEvent& rEvt) - { - sal_uInt16 nColPos = GetColumnPos( rEvt.GetColumnId() ); - long nRow = rEvt.GetRow(); - - // absorb double clicks - if (rEvt.GetClicks() > 1 && rEvt.GetRow() >= 0) - return; - - // change to a new position - if (IsEditing() && (nColPos != nEditCol || nRow != nEditRow) && (nColPos != BROWSER_INVALIDID) && (nRow < GetRowCount())) - { - CellControllerRef aCellController(Controller()); - HideAndDisable(aCellController); - } - - // we are about to leave the current cell. If there is a "this cell has been modified" notification - // pending (asynchronously), this may be deadly -> do it synchronously - if ( nCellModifiedEvent ) - { - Application::RemoveUserEvent( nCellModifiedEvent ); - nCellModifiedEvent = 0; - LINK( this, EditBrowseBox, CellModifiedHdl ).Call( NULL ); - } - - if (0 == rEvt.GetColumnId()) - { // it was the handle column. save the current cell content if necessary - // (clicking on the handle column results in selecting the current row) - if (IsEditing() && aController->IsModified()) - SaveModified(); - } - - aMouseEvent.Set(&rEvt,sal_True); - BrowseBox::MouseButtonDown(rEvt); - aMouseEvent.Clear(); - - if (0 != (m_nBrowserFlags & EBBF_ACTIVATE_ON_BUTTONDOWN)) - { - // the base class does not travel upon MouseButtonDown, but implActivateCellOnMouseEvent assumes we traveled ... - GoToRowColumnId( rEvt.GetRow(), rEvt.GetColumnId() ); - if (rEvt.GetRow() >= 0) - implActivateCellOnMouseEvent(rEvt, sal_False); - } - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::MouseButtonUp( const BrowserMouseEvent& rEvt ) - { - // absorb double clicks - if (rEvt.GetClicks() > 1 && rEvt.GetRow() >= 0) - return; - - aMouseEvent.Set(&rEvt,sal_False); - BrowseBox::MouseButtonUp(rEvt); - aMouseEvent.Clear(); - - if (0 == (m_nBrowserFlags & EBBF_ACTIVATE_ON_BUTTONDOWN)) - if (rEvt.GetRow() >= 0) - implActivateCellOnMouseEvent(rEvt, sal_True); - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::implActivateCellOnMouseEvent(const BrowserMouseEvent& _rEvt, sal_Bool _bUp) - { - if (!IsEditing()) - ActivateCell(); - else if (IsEditing() && !aController->GetWindow().IsEnabled()) - DeactivateCell(); - else if (IsEditing() && !aController->GetWindow().HasChildPathFocus()) - AsynchGetFocus(); - - if (IsEditing() && aController->GetWindow().IsEnabled() && aController->WantMouseEvent()) - { // forwards the event to the control - - // If the field has been moved previously, we have to adjust the position - - 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 - 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()); - - pRealHandler->MouseButtonDown(aEvent); - if (_bUp) - pRealHandler->MouseButtonUp(aEvent); - - Window *pWin = &aController->GetWindow(); - if (!pWin->IsTracking()) - { - for (pWin = pWin->GetWindow(WINDOW_FIRSTCHILD); - pWin && !pWin->IsTracking(); - pWin = pWin->GetWindow(WINDOW_NEXT)) - { - } - } - if (pWin && pWin->IsTracking()) - pWin->EndTracking(); - } - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::Dispatch( sal_uInt16 _nId ) - { - if ( _nId == BROWSER_ENHANCESELECTION ) - { // this is a workaround for the bug in the base class: - // if the row selection is to be extended (which is what BROWSER_ENHANCESELECTION tells us) - // then the base class does not revert any column selections, while, for doing a "simple" - // selection (BROWSER_SELECT), it does. In fact, it does not only revert the col selection then, - // but also any current row selections. - // This clearly tells me that the both ids are for row selection only - there this behaviour does - // make sense. - // But here, where we have column selection, too, we take care of this ourself. - if ( GetSelectColumnCount( ) ) - { - while ( GetSelectColumnCount( ) ) - SelectColumnPos( - sal::static_int_cast< sal_uInt16 >(FirstSelectedColumn()), - sal_False ); - Select(); - } - } - BrowseBox::Dispatch( _nId ); - } - - //------------------------------------------------------------------------------ - long EditBrowseBox::PreNotify(NotifyEvent& rEvt) - { - switch (rEvt.GetType()) - { - case EVENT_KEYINPUT: - if ( (IsEditing() && Controller()->GetWindow().HasChildPathFocus()) - || rEvt.GetWindow() == &GetDataWindow() - || (!IsEditing() && HasChildPathFocus()) - ) - { - const KeyEvent* pKeyEvent = rEvt.GetKeyEvent(); - sal_uInt16 nCode = pKeyEvent->GetKeyCode().GetCode(); - sal_Bool bShift = pKeyEvent->GetKeyCode().IsShift(); - sal_Bool bCtrl = pKeyEvent->GetKeyCode().IsMod1(); - sal_Bool bAlt = pKeyEvent->GetKeyCode().IsMod2(); - sal_Bool bLocalSelect= sal_False; - sal_Bool bNonEditOnly = sal_False; - sal_uInt16 nId = BROWSER_NONE; - - if (!bAlt && !bCtrl && !bShift ) - switch ( nCode ) - { - case KEY_DOWN: nId = BROWSER_CURSORDOWN; break; - case KEY_UP: nId = BROWSER_CURSORUP; break; - case KEY_PAGEDOWN: nId = BROWSER_CURSORPAGEDOWN; break; - case KEY_PAGEUP: nId = BROWSER_CURSORPAGEUP; break; - case KEY_HOME: nId = BROWSER_CURSORHOME; break; - case KEY_END: nId = BROWSER_CURSOREND; break; - - case KEY_TAB: - // ask if traveling to the next cell is allowed - if (IsTabAllowed(sal_True)) - nId = BROWSER_CURSORRIGHT; - break; - - case KEY_RETURN: - // save the cell content (if necessary) - if (IsEditing() && aController->IsModified() && !((EditBrowseBox *) this)->SaveModified()) - { - // maybe we're not visible ... - EnableAndShow(); - aController->GetWindow().GrabFocus(); - return 1; - } - // ask if traveling to the next cell is allowed - if (IsTabAllowed(sal_True)) - nId = BROWSER_CURSORRIGHT; - - break; - case KEY_RIGHT: nId = BROWSER_CURSORRIGHT; break; - case KEY_LEFT: nId = BROWSER_CURSORLEFT; break; - case KEY_SPACE: nId = BROWSER_SELECT; bNonEditOnly = bLocalSelect = sal_True;break; - } - - if ( !bAlt && !bCtrl && bShift ) - switch ( nCode ) - { - case KEY_DOWN: nId = BROWSER_SELECTDOWN; bLocalSelect = sal_True;break; - case KEY_UP: nId = BROWSER_SELECTUP; bLocalSelect = sal_True;break; - case KEY_HOME: nId = BROWSER_SELECTHOME; bLocalSelect = sal_True;break; - case KEY_END: nId = BROWSER_SELECTEND; bLocalSelect = sal_True;break; - case KEY_TAB: - if (IsTabAllowed(sal_False)) - nId = BROWSER_CURSORLEFT; - break; - } - - if ( !bAlt && bCtrl && bShift ) - switch ( nCode ) - { - case KEY_SPACE: nId = BROWSER_SELECTCOLUMN; bLocalSelect = sal_True; break; - } - - - if ( !bAlt && bCtrl && !bShift ) - switch ( nCode ) - { - case KEY_DOWN: nId = BROWSER_SCROLLUP; break; - case KEY_UP: nId = BROWSER_SCROLLDOWN; break; - case KEY_PAGEDOWN: nId = BROWSER_CURSORENDOFFILE; break; - case KEY_PAGEUP: nId = BROWSER_CURSORTOPOFFILE; break; - case KEY_HOME: nId = BROWSER_CURSORTOPOFSCREEN; break; - case KEY_END: nId = BROWSER_CURSORENDOFSCREEN; break; - case KEY_SPACE: nId = BROWSER_ENHANCESELECTION; bLocalSelect = sal_True;break; - } - - - if ( ( nId != BROWSER_NONE ) - && ( !IsEditing() - || ( !bNonEditOnly - && aController->MoveAllowed( *pKeyEvent ) - ) - ) - ) - { - if (nId == BROWSER_SELECT || BROWSER_SELECTCOLUMN == nId ) - { - // save the cell content (if necessary) - if (IsEditing() && aController->IsModified() && !((EditBrowseBox *) this)->SaveModified()) - { - // maybe we're not visible ... - EnableAndShow(); - aController->GetWindow().GrabFocus(); - return 1; - } - } - - Dispatch(nId); - - if (bLocalSelect && (GetSelectRowCount() || GetSelection() != NULL)) - DeactivateCell(); - return 1; - } - } - } - return BrowseBox::PreNotify(rEvt); - } - - //------------------------------------------------------------------------------ - sal_Bool EditBrowseBox::IsTabAllowed(sal_Bool) const - { - return sal_True; - } - - //------------------------------------------------------------------------------ - long EditBrowseBox::Notify(NotifyEvent& rEvt) - { - switch (rEvt.GetType()) - { - case EVENT_GETFOCUS: - DetermineFocus( getRealGetFocusFlags( this ) ); - break; - - case EVENT_LOSEFOCUS: - DetermineFocus( 0 ); - break; - } - return BrowseBox::Notify(rEvt); - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::StateChanged( StateChangedType nType ) - { - BrowseBox::StateChanged( nType ); - - bool bNeedCellReActivation = false; - if ( nType == STATE_CHANGE_MIRRORING ) - { - bNeedCellReActivation = true; - } - else if ( nType == STATE_CHANGE_ZOOM ) - { - ImplInitSettings( sal_True, sal_False, sal_False ); - bNeedCellReActivation = true; - } - else if ( nType == STATE_CHANGE_CONTROLFONT ) - { - ImplInitSettings( sal_True, sal_False, sal_False ); - Invalidate(); - } - else if ( nType == STATE_CHANGE_CONTROLFOREGROUND ) - { - ImplInitSettings( sal_False, sal_True, sal_False ); - Invalidate(); - } - else if ( nType == STATE_CHANGE_CONTROLBACKGROUND ) - { - ImplInitSettings( sal_False, sal_False, sal_True ); - Invalidate(); - } - else if (nType == STATE_CHANGE_STYLE) - { - WinBits nStyle = GetStyle(); - if (!(nStyle & WB_NOTABSTOP) ) - nStyle |= WB_TABSTOP; - - SetStyle(nStyle); - } - if ( bNeedCellReActivation ) - { - if ( IsEditing() ) - { - DeactivateCell(); - ActivateCell(); - } - } - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::DataChanged( const DataChangedEvent& rDCEvt ) - { - BrowseBox::DataChanged( rDCEvt ); - - if ((( rDCEvt.GetType() == DATACHANGED_SETTINGS ) || - ( rDCEvt.GetType() == DATACHANGED_DISPLAY )) && - ( rDCEvt.GetFlags() & SETTINGS_STYLE )) - { - ImplInitSettings( sal_True, sal_True, sal_True ); - Invalidate(); - } - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground ) - { - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - - if (bFont) - { - Font aFont = rStyleSettings.GetFieldFont(); - if (IsControlFont()) - { - GetDataWindow().SetControlFont(GetControlFont()); - aFont.Merge(GetControlFont()); - } - else - GetDataWindow().SetControlFont(); - - GetDataWindow().SetZoomedPointFont(aFont); - } - - if ( bFont || bForeground ) - { - Color aTextColor = rStyleSettings.GetFieldTextColor(); - if (IsControlForeground()) - { - aTextColor = GetControlForeground(); - GetDataWindow().SetControlForeground(aTextColor); - } - else - GetDataWindow().SetControlForeground(); - - GetDataWindow().SetTextColor( aTextColor ); - } - - if ( bBackground ) - { - 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() ); - } - } - } - - //------------------------------------------------------------------------------ - sal_Bool EditBrowseBox::IsCursorMoveAllowed(long nNewRow, sal_uInt16 nNewColId) const - { - sal_uInt16 nInfo = 0; - - if (GetSelectColumnCount() || (aMouseEvent.Is() && aMouseEvent->GetRow() < 0)) - nInfo |= COLSELECT; - if ((GetSelection() != NULL && GetSelectRowCount()) || - (aMouseEvent.Is() && aMouseEvent->GetColumnId() == HANDLE_ID)) - nInfo |= ROWSELECT; - if (!nInfo && nNewRow != nEditRow) - nInfo |= ROWCHANGE; - if (!nInfo && nNewColId != nEditCol) - nInfo |= COLCHANGE; - - if (nInfo == 0) // nothing happened - return sal_True; - - // save the cell content - if (IsEditing() && aController->IsModified() && !((EditBrowseBox *) this)->SaveModified()) - { - // maybe we're not visible ... - EnableAndShow(); - aController->GetWindow().GrabFocus(); - return sal_False; - } - - EditBrowseBox * pTHIS = (EditBrowseBox *) this; - - // save the cell content if - // a) a selection is beeing made - // b) the row is changing - if (IsModified() && (nInfo & (ROWCHANGE | COLSELECT | ROWSELECT)) && - !pTHIS->SaveRow()) - { - if (nInfo & COLSELECT || - nInfo & ROWSELECT) - { - // cancel selected - pTHIS->SetNoSelection(); - } - - if (IsEditing()) - { - if (!Controller()->GetWindow().IsVisible()) - { - EnableAndShow(); - } - aController->GetWindow().GrabFocus(); - } - return sal_False; - } - - if (nNewRow != nEditRow) - { - Window& rWindow = GetDataWindow(); - // don't paint too much - // update the status immediatly if possible - if ((nEditRow >= 0) && (GetBrowserFlags() & EBBF_NO_HANDLE_COLUMN_CONTENT) == 0) - { - Rectangle aRect = GetFieldRectPixel(nEditRow, 0, sal_False ); - // status cell should be painted if and only if text is displayed - // note: bPaintStatus is mutable, but Solaris has problems with assigning - // probably because it is part of a bitfield - pTHIS->bPaintStatus = static_cast< sal_Bool > - (( GetBrowserFlags() & EBBF_HANDLE_COLUMN_TEXT ) == EBBF_HANDLE_COLUMN_TEXT ); - rWindow.Paint(aRect); - pTHIS->bPaintStatus = sal_True; - } - - // don't paint during row change - rWindow.EnablePaint(sal_False); - - // the last veto chance for derived classes - if (!pTHIS->CursorMoving(nNewRow, nNewColId)) - { - pTHIS->InvalidateStatusCell(nEditRow); - rWindow.EnablePaint(sal_True); - return sal_False; - } - else - { - rWindow.EnablePaint(sal_True); - return sal_True; - } - } - else - return pTHIS->CursorMoving(nNewRow, nNewColId); - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::ColumnMoved(sal_uInt16 nId) - { - BrowseBox::ColumnMoved(nId); - if (IsEditing()) - { - Rectangle aRect( GetCellRect(nEditRow, nEditCol, sal_False)); - CellControllerRef aControllerRef = Controller(); - ResizeController(aControllerRef, aRect); - Controller()->GetWindow().GrabFocus(); - } - } - - //------------------------------------------------------------------------------ - sal_Bool EditBrowseBox::SaveRow() - { - return sal_True; - } - - //------------------------------------------------------------------------------ - sal_Bool EditBrowseBox::CursorMoving(long, sal_uInt16) - { - ((EditBrowseBox *) this)->DeactivateCell(sal_False); - return sal_True; - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::CursorMoved() - { - long nNewRow = GetCurRow(); - if (nEditRow != nNewRow) - { - if ((GetBrowserFlags() & EBBF_NO_HANDLE_COLUMN_CONTENT) == 0) - InvalidateStatusCell(nNewRow); - nEditRow = nNewRow; - } - ActivateCell(); - GetDataWindow().EnablePaint(sal_True); - // should not be called here because the descant event is not needed here - //BrowseBox::CursorMoved(); - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::EndScroll() - { - if (IsEditing()) - { - Rectangle aRect = GetCellRect(nEditRow, nEditCol, sal_False); - ResizeController(aController,aRect); - AsynchGetFocus(); - } - BrowseBox::EndScroll(); - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::ActivateCell(long nRow, sal_uInt16 nCol, sal_Bool bCellFocus) - { - if (IsEditing()) - return; - - nEditCol = nCol; - - if ((GetSelectRowCount() && GetSelection() != NULL) || GetSelectColumnCount() || - (aMouseEvent.Is() && (aMouseEvent.IsDown() || aMouseEvent->GetClicks() > 1))) // bei MouseDown passiert noch nichts - { - return; - } - - if (nEditRow >= 0 && nEditCol > HANDLE_ID) - { - aController = GetController(nRow, nCol); - if (aController.Is()) - { - Rectangle aRect( GetCellRect(nEditRow, nEditCol, sal_False)); - ResizeController(aController, aRect); - - InitController(aController, nEditRow, nEditCol); - - aController->ClearModified(); - aController->SetModifyHdl(LINK(this,EditBrowseBox,ModifyHdl)); - EnableAndShow(); - - if ( isAccessibleAlive() ) - implCreateActiveAccessible(); - - // 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() ) - { - commitTableEvent( - ACTIVE_DESCENDANT_CHANGED, - makeAny( CreateAccessibleCell( nRow, GetColumnPos( nCol ) ) ), - Any() - ); - } - } - } - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::DeactivateCell(sal_Bool bUpdate) - { - if (IsEditing()) - { - if ( isAccessibleAlive() ) - { - commitBrowseBoxEvent( CHILD, Any(), makeAny( m_aImpl->m_xActiveCell ) ); - m_aImpl->clearActiveCell(); - } - - aOldController = aController; - aController.Clear(); - - // reset the modify handler - aOldController->SetModifyHdl(Link()); - - if (bHasFocus) - GrabFocus(); // ensure that we have (and keep) the focus - - HideAndDisable(aOldController); - - // update if requested - if (bUpdate) - Update(); - - nOldEditCol = nEditCol; - nOldEditRow = nEditRow; - - // release the controller (asynchronously) - if (nEndEvent) - Application::RemoveUserEvent(nEndEvent); - nEndEvent = Application::PostUserEvent(LINK(this,EditBrowseBox,EndEditHdl)); - } - } - - //------------------------------------------------------------------------------ - Rectangle EditBrowseBox::GetCellRect(long nRow, sal_uInt16 nColId, sal_Bool bRel) const - { - Rectangle aRect( GetFieldRectPixel(nRow, nColId, bRel)); - if ((GetMode() & BROWSER_CURSOR_WO_FOCUS) == BROWSER_CURSOR_WO_FOCUS) - { - aRect.Top() += 1; - aRect.Bottom() -= 1; - } - return aRect; - } - - //------------------------------------------------------------------------------ - IMPL_LINK(EditBrowseBox, EndEditHdl, void*, EMPTYARG) - { - nEndEvent = 0; - ReleaseController(aOldController, nOldEditRow, nOldEditCol); - - aOldController = CellControllerRef(); - nOldEditRow = -1; - nOldEditCol = 0; - - return 0; - } - - //------------------------------------------------------------------------------ - IMPL_LINK(EditBrowseBox, ModifyHdl, void*, EMPTYARG) - { - if (nCellModifiedEvent) - Application::RemoveUserEvent(nCellModifiedEvent); - nCellModifiedEvent = Application::PostUserEvent(LINK(this,EditBrowseBox,CellModifiedHdl)); - return 0; - } - - //------------------------------------------------------------------------------ - IMPL_LINK(EditBrowseBox, CellModifiedHdl, void*, EMPTYARG) - { - nCellModifiedEvent = 0; - CellModified(); - return 0; - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::ColumnResized( sal_uInt16 ) - { - if (IsEditing()) - { - Rectangle aRect( GetCellRect(nEditRow, nEditCol, sal_False)); - CellControllerRef aControllerRef = Controller(); - ResizeController(aControllerRef, aRect); - Controller()->GetWindow().GrabFocus(); - } - } - - //------------------------------------------------------------------------------ - sal_uInt16 EditBrowseBox::AppendColumn(const String& rName, sal_uInt16 nWidth, sal_uInt16 nPos, sal_uInt16 nId) - { - if (nId == (sal_uInt16)-1) - { - // look for the next free id - for (nId = ColCount(); nId > 0 && GetColumnPos(nId) != BROWSER_INVALIDID; nId--) - ; - - if (!nId) - { - // if there is no handle column - // increment the id - if (!ColCount() || GetColumnId(0)) - nId = ColCount() + 1; - } - } - - DBG_ASSERT(nId, "EditBrowseBox::AppendColumn: invalid id!"); - - long w = nWidth; - if (!w) - w = GetDefaultColumnWidth(rName); - - InsertDataColumn(nId, rName, w, (HIB_CENTER | HIB_VCENTER | HIB_CLICKABLE), nPos); - return nId; - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::Resize() - { - BrowseBox::Resize(); - - // if the window is smaller than "title line height" + "control area", - // do nothing - if (GetOutputSizePixel().Height() < - (GetControlArea().GetHeight() + GetDataWindow().GetPosPixel().Y())) - return; - - // the size of the control area - Point aPoint(GetControlArea().TopLeft()); - sal_uInt16 nX = (sal_uInt16)aPoint.X(); - - ArrangeControls(nX, (sal_uInt16)aPoint.Y()); - - if (!nX) - nX = USHRT_MAX; - ReserveControlArea((sal_uInt16)nX); - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::ArrangeControls(sal_uInt16&, sal_uInt16) - { - } - - //------------------------------------------------------------------------------ - CellController* EditBrowseBox::GetController(long, sal_uInt16) - { - return NULL; - } - - //----------------------------------------------------------------------------- - void EditBrowseBox::ResizeController(CellControllerRef& rController, const Rectangle& rRect) - { - rController->GetWindow().SetPosSizePixel(rRect.TopLeft(), rRect.GetSize()); - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::InitController(CellControllerRef&, long, sal_uInt16) - { - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::ReleaseController(CellControllerRef&, long, sal_uInt16) - { - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::CellModified() - { - } - - - //------------------------------------------------------------------------------ - sal_Bool EditBrowseBox::SaveModified() - { - return sal_True; - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::DoubleClick(const BrowserMouseEvent& rEvt) - { - // when double clicking on the column, the optimum size will be calculated - sal_uInt16 nColId = rEvt.GetColumnId(); - if (nColId != HANDLE_ID) - SetColumnWidth(nColId, GetAutoColumnWidth(nColId)); - } - - //------------------------------------------------------------------------------ - sal_uInt32 EditBrowseBox::GetAutoColumnWidth(sal_uInt16 nColId) - { - sal_uInt32 nCurColWidth = GetColumnWidth(nColId); - sal_uInt32 nMinColWidth = CalcZoom(20); // minimum - sal_uInt32 nNewColWidth = nMinColWidth; - long nMaxRows = Min(long(GetVisibleRows()), GetRowCount()); - long nLastVisRow = GetTopRow() + nMaxRows - 1; - - if (GetTopRow() <= nLastVisRow) // calc the column with using the cell contents - { - for (long i = GetTopRow(); i <= nLastVisRow; ++i) - nNewColWidth = std::max(nNewColWidth,GetTotalCellWidth(i,nColId) + 12); - - if (nNewColWidth == nCurColWidth) // size has not changed - nNewColWidth = GetDefaultColumnWidth(GetColumnTitle(nColId)); - } - else - nNewColWidth = GetDefaultColumnWidth(GetColumnTitle(nColId)); - return nNewColWidth; - } - - //------------------------------------------------------------------------------ - sal_uInt32 EditBrowseBox::GetTotalCellWidth(long, sal_uInt16) - { - return 0; - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::InvalidateHandleColumn() - { - Rectangle aHdlFieldRect( GetFieldRectPixel( 0, 0 )); - Rectangle aInvalidRect( Point(0,0), GetOutputSizePixel() ); - aInvalidRect.Right() = aHdlFieldRect.Right(); - Invalidate( aInvalidRect ); - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::PaintTristate(OutputDevice&, const Rectangle& rRect,const TriState& eState,sal_Bool _bEnabled) const - { - pCheckBoxPaint->GetBox().SetState(eState); - pCheckBoxPaint->SetPosSizePixel(rRect.TopLeft(), rRect.GetSize()); - - // First update the parent, preventing that while painting this window - // an update for the parent is done (because it's in the queue already) - // which may lead to hiding this window immediately -// #95598# comment out OJ -/* if (pCheckBoxPaint->GetParent()) - pCheckBoxPaint->GetParent()->Update(); -*/ - pCheckBoxPaint->GetBox().Enable(_bEnabled); - pCheckBoxPaint->Show(); - pCheckBoxPaint->SetParentUpdateMode( sal_False ); - pCheckBoxPaint->Update(); - pCheckBoxPaint->Hide(); - pCheckBoxPaint->SetParentUpdateMode( sal_True ); - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::AsynchGetFocus() - { - if (nStartEvent) - Application::RemoveUserEvent(nStartEvent); - - m_pFocusWhileRequest = Application::GetFocusWindow(); - nStartEvent = Application::PostUserEvent(LINK(this,EditBrowseBox,StartEditHdl)); - } - - //------------------------------------------------------------------------------ - void EditBrowseBox::SetBrowserFlags(sal_Int32 nFlags) - { - if (m_nBrowserFlags == nFlags) - return; - - sal_Bool RowPicturesChanges = ((m_nBrowserFlags & EBBF_NO_HANDLE_COLUMN_CONTENT) != - (nFlags & EBBF_NO_HANDLE_COLUMN_CONTENT)); - m_nBrowserFlags = nFlags; - - if (RowPicturesChanges) - InvalidateStatusCell(GetCurRow()); - } - //------------------------------------------------------------------------------ - inline void EditBrowseBox::HideAndDisable(CellControllerRef& rController) - { - rController->suspend(); - } - //------------------------------------------------------------------------------ - inline void EditBrowseBox::EnableAndShow() const - { - Controller()->resume(); - } - //=============================================================================== - - DBG_NAME(CellController); - //------------------------------------------------------------------------------ - CellController::CellController(Control* pW) - :pWindow( pW ) - ,bSuspended( sal_True ) - { - DBG_CTOR(CellController,NULL); - - DBG_ASSERT(pWindow, "CellController::CellController: missing the window!"); - DBG_ASSERT(!pWindow->IsVisible(), "CellController::CellController: window should not be visible!"); - } - - //----------------------------------------------------------------------------- - CellController::~CellController() - { - - DBG_DTOR(CellController,NULL); - } - - //----------------------------------------------------------------------------- - void CellController::suspend( ) - { - DBG_ASSERT( bSuspended == !GetWindow().IsVisible(), "CellController::suspend: inconsistence!" ); - if ( !isSuspended( ) ) - { - CommitModifications(); - GetWindow().Hide( ); - GetWindow().Disable( ); - bSuspended = sal_True; - } - } - - //----------------------------------------------------------------------------- - void CellController::resume( ) - { - DBG_ASSERT( bSuspended == !GetWindow().IsVisible(), "CellController::resume: inconsistence!" ); - if ( isSuspended( ) ) - { - GetWindow().Enable( ); - GetWindow().Show( ); - bSuspended = sal_False; - } - } - - //----------------------------------------------------------------------------- - void CellController::CommitModifications() - { - // nothing to do in this base class - } - - //----------------------------------------------------------------------------- - sal_Bool CellController::WantMouseEvent() const - { - return sal_False; - } - - //----------------------------------------------------------------------------- - void CellController::SetModified() - { - } - - //----------------------------------------------------------------------------- - sal_Bool CellController::MoveAllowed(const KeyEvent&) const - { - return sal_True; - } -// ....................................................................... -} // namespace svt -// ....................................................................... - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/brwbox/editbrowsebox.hrc b/svtools/source/brwbox/editbrowsebox.hrc deleted file mode 100644 index f16e32a7b8..0000000000 --- a/svtools/source/brwbox/editbrowsebox.hrc +++ /dev/null @@ -1,42 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _SVTOOLS_EDITBROWSEBOX_HRC_ -#define _SVTOOLS_EDITBROWSEBOX_HRC_ - -#define IMG_EBB_CURRENT 1 -#define IMG_EBB_MODIFIED 2 -#define IMG_EBB_NEW 3 -#define IMG_EBB_DELETED 4 -#define IMG_EBB_CURRENTNEW 5 -#define IMG_EBB_PRIMARYKEY 6 -#define IMG_EBB_CURRENT_PRIMARYKEY 7 -#define IMG_EBB_FILTER 8 -#define IMG_EBB_HEADERFOOTER 9 - -#endif // _SVTOOLS_EDITBROWSEBOX_HRC_ - diff --git a/svtools/source/brwbox/editbrowsebox.src b/svtools/source/brwbox/editbrowsebox.src deleted file mode 100644 index beb2236ab2..0000000000 --- a/svtools/source/brwbox/editbrowsebox.src +++ /dev/null @@ -1,56 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _SVTOOLS_EDITBROWSEBOX_HRC_ -#include "editbrowsebox.hrc" -#endif - -#ifndef _SVTOOLS_HRC -#include <svtools/svtools.hrc> -#endif - -ImageList RID_SVTOOLS_IMAGELIST_EDITBROWSEBOX -{ - Prefix = "ed"; - MaskColor = Color { - Red = 0xFFFF; - Green = 0x0000; - Blue = 0xFFFF; - }; - IdList = { - IMG_EBB_CURRENT; - IMG_EBB_MODIFIED; - IMG_EBB_NEW; - IMG_EBB_DELETED; - IMG_EBB_CURRENTNEW; - IMG_EBB_PRIMARYKEY; - IMG_EBB_CURRENT_PRIMARYKEY; - IMG_EBB_FILTER; - IMG_EBB_HEADERFOOTER; - }; - IdCount = { 9; }; -}; diff --git a/svtools/source/brwbox/editbrowsebox2.cxx b/svtools/source/brwbox/editbrowsebox2.cxx deleted file mode 100644 index dea2043553..0000000000 --- a/svtools/source/brwbox/editbrowsebox2.cxx +++ /dev/null @@ -1,224 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svtools.hxx" -#include <svtools/editbrowsebox.hxx> -#include <com/sun/star/accessibility/XAccessible.hpp> -#include <com/sun/star/accessibility/AccessibleEventId.hpp> -#include "editbrowseboximpl.hxx" -#include <comphelper/types.hxx> -#include <toolkit/helper/vclunohelper.hxx> -#include "svtaccessiblefactory.hxx" - -namespace svt -{ - using namespace com::sun::star::accessibility; - using namespace com::sun::star::uno; - using namespace ::com::sun::star::accessibility::AccessibleEventId; - -// ----------------------------------------------------------------------------- -Reference< XAccessible > EditBrowseBox::CreateAccessibleCheckBoxCell(long _nRow, sal_uInt16 _nColumnPos,const TriState& eState,sal_Bool _bEnabled) -{ - Reference< XAccessible > xAccessible( GetAccessible() ); - Reference< XAccessibleContext > xAccContext; - if ( xAccessible.is() ) - xAccContext = xAccessible->getAccessibleContext(); - - Reference< XAccessible > xReturn; - if ( xAccContext.is() ) - { - xReturn = getAccessibleFactory().createAccessibleCheckBoxCell( - xAccContext->getAccessibleChild( ::svt::BBINDEX_TABLE ), - *this, - NULL, - _nRow, - _nColumnPos, - eState, - _bEnabled, - sal_True - ); - } - return xReturn; -} -// ----------------------------------------------------------------------------- -Reference< XAccessible > EditBrowseBox::CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumnPos ) -{ - return BrowseBox::CreateAccessibleCell( _nRow, _nColumnPos ); -} -// ----------------------------------------------------------------------------- -sal_Int32 EditBrowseBox::GetAccessibleControlCount() const -{ - return IsEditing() ? 1 : 0; -} -// ----------------------------------------------------------------------------- -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() ); - } - } -} - -// ----------------------------------------------------------------------------- -Reference< XAccessible > EditBrowseBox::CreateAccessibleControl( sal_Int32 -#ifdef DBG_UTIL -_nIndex -#endif -) -{ - DBG_ASSERT( 0 == _nIndex, "EditBrowseBox::CreateAccessibleControl: invalid index!" ); - - if ( isAccessibleAlive() ) - { - if ( !m_aImpl->m_xActiveCell.is() ) - implCreateActiveAccessible(); - } - - return m_aImpl->m_xActiveCell; -} -// ----------------------------------------------------------------------------- -Reference<XAccessible > EditBrowseBox::CreateAccessibleRowHeader( sal_Int32 _nRow ) -{ - return BrowseBox::CreateAccessibleRowHeader( _nRow ); -} -// ----------------------------------------------------------------------------- -void EditBrowseBoxImpl::clearActiveCell() -{ - try - { - ::comphelper::disposeComponent(m_xActiveCell); - } - catch(const Exception&) - { - OSL_FAIL( "EditBrowseBoxImpl::clearActiveCell: caught an exception while disposing the AccessibleCell!" ); - } - - m_xActiveCell = NULL; -} -// ----------------------------------------------------------------------------- -void EditBrowseBox::GrabTableFocus() -{ - if ( aController.Is() ) - aController->GetWindow().GrabFocus(); -} -//------------------------------------------------------------------------------ -void EditBrowseBox::DetermineFocus( const sal_uInt16 _nGetFocusFlags ) -{ - sal_Bool bFocus = sal_False; - for (Window* pWindow = Application::GetFocusWindow(); - pWindow && !bFocus; - pWindow = pWindow->GetParent()) - bFocus = pWindow == this; - - if (bFocus != bHasFocus) - { - bHasFocus = bFocus; - - if ( GetBrowserFlags( ) & EBBF_SMART_TAB_TRAVEL ) - { - if ( bHasFocus // we got the focus - && ( _nGetFocusFlags & GETFOCUS_TAB ) // using the TAB key - ) - { - long nRows = GetRowCount(); - sal_uInt16 nCols = ColCount(); - - if ( ( nRows > 0 ) && ( nCols > 0 ) ) - { - if ( _nGetFocusFlags & GETFOCUS_FORWARD ) - { - if ( GetColumnId( 0 ) != 0 ) - { - GoToRowColumnId( 0, GetColumnId( 0 ) ); - } - else - { // the first column is the handle column -> not focussable - if ( nCols > 1 ) - GoToRowColumnId( 0, GetColumnId( 1 ) ); - } - } - else if ( _nGetFocusFlags & GETFOCUS_BACKWARD ) - { - GoToRowColumnId( nRows - 1, GetColumnId( nCols -1 ) ); - } - } - } - } - } -} -// ----------------------------------------------------------------------------- -Rectangle EditBrowseBox::GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 _nIndex) -{ - Rectangle aRect; - if ( SeekRow(_nRow) ) - { - CellController* pController = GetController( - _nRow, GetColumnId( sal::static_int_cast< sal_uInt16 >(_nColumnPos) ) ); - if ( pController ) - aRect = pController->GetWindow().GetCharacterBounds(_nIndex); - } - return aRect; -} -// ----------------------------------------------------------------------------- -sal_Int32 EditBrowseBox::GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint) -{ - sal_Int32 nRet = -1; - if ( SeekRow(_nRow) ) - { - CellController* pController = GetController( - _nRow, GetColumnId( sal::static_int_cast< sal_uInt16 >(_nColumnPos) ) ); - if ( pController ) - nRet = pController->GetWindow().GetIndexForPoint(_rPoint); - } - return nRet; -} -// ----------------------------------------------------------------------------- -// ----------------------------------------------------------------------------- -} // namespace svt -// ----------------------------------------------------------------------------- - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/brwbox/editbrowseboximpl.hxx b/svtools/source/brwbox/editbrowseboximpl.hxx deleted file mode 100644 index ec5bdcd2df..0000000000 --- a/svtools/source/brwbox/editbrowseboximpl.hxx +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SVTOOLS_EDITBROWSEBOX_IMPL_HXX -#define SVTOOLS_EDITBROWSEBOX_IMPL_HXX - -#include <com/sun/star/accessibility/XAccessible.hpp> - -namespace svt -{ - // impl class for the class EditBrowseBox - class EditBrowseBoxImpl - { - public: - ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > m_xActiveCell; - - void clearActiveCell(); - }; -} -#endif // SVTOOLS_EDITBROWSEBOX_IMPL_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |